Skip to content

Interact with your Ford vehicle from Python and the command-line

License

Notifications You must be signed in to change notification settings

PyMyFord/prefect

Repository files navigation

prefect

MyFordMobile reverse-engineered API in Python
Sonar Quality Gate Travis (.org) branch
GitHub last commit PyPI GitHub

prefect is a Python library for interacting with your MyFordMobile-enabled vehicle. With prefect, you can:

  • Lock your car
  • Unlock your car
  • Check your gas level, and, if you have one, your EV battery level
  • Start your engine (e.g. to preheat your car in the Blustery Times Of Year), and stop your engine if you decide to stay home after all

prefect uses a reverse-engineered API, and may be unstable. DON'T PANIC.

Examples

Example Description
AWS Lambda Start your car with ford-prefect from an AWS Lambda
🚧 HomeAssistant Start/stop, lock/unlock your car with Home Assistant

Installation

pip3 install -U ford-prefect

Usage

from prefect import FordAPI

F = FordAPI()
F.authenticate(USERNAME, PASSWORD)
F.get_vehicles() # returns a list of dicts with metadata
my_car = F.get_vehicles()[0]

my_car.start_engine()

print(my_car.status()) # metadata dictionary

Authentication

There are three ways to authenticate:

Plaintext username and password

You can pass credentials directly into the authenticate call:

F.authenticate(USERNAME, PASSWORD)

Environment variables

You can set PREFECT_USERNAME and PREFECT_PASSWORD environment variables. If these are set, pass nothing to the FordAPI#authenticate call and they will be automatically detected.

Config file

You can store credentials in a JSON config file, and pass the filename into the authenticate call:

~/.config/myfordmobile.json

{
    "username": "",
    "password": ""
}
F.authenticate("~/.config/myfordmobile.json")

Or, if you're using that filename (the default), you can omit it entirely:

F.authenticate()

If no arguments are passed to this constructor, environment variables (method 2) will be checked first before the config file is checked. If both techniques fail, and no username and password were provided, the authenticate() call will fail.

Hacking on this repo

  • Submit pull requests for individual features

  • Make sure things work locally before pushing

  • When pushing new changes to the function signatures or new documentation, re-generate the Reference.md file under /docs. You can use docshund to do this, thusly:

docshund prefect/__init__.py > docs/Reference.md

Install docshund with pip3 install -U docshund.

About

Interact with your Ford vehicle from Python and the command-line

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages