Package: teslajson
teslajsonSimple Python class to access the Tesla JSON API.Written by Greg GlocknerDescriptionThis is a simple Python interface to theTesla JSON
API. With this, you can query your
vehicle, control charge settings, turn on the air conditioning, and
more.  You can also embed this into other programs to automate these
controls.The class is designed to be simple.  You initialize aConnectionobject, retrieve the list ofVehicleobjects, then perform get/set
methods on aVehicle.  There is a single get method
[Vehicle.data_request()] and a single set method [Vehicle.command()] so
that the class does not require changes when there are minor updates
to the underlying JSON API.This has been tested with Python 3.7 and requires theRequests-OAuthliblibrary.InstallationUse any of these methods to download and install the teslajson module:Easiest method: use pip via the command :pip install teslajsonDownload the source code fromhttps://github.com/gglockner/teslajson, then run:python setup.py installDownload the source code, install requests-oauthlib and its dependencies, then add the file teslajson/teslajson.py to your Python projectPublic APIConnection(email, password, **kwargs):
Initialize the connection to the Tesla Motors website.Required parameters:email: your login for teslamotors.compassword: your password for teslamotors.comOptional parameters:mfa: your multi-factor authentication code, if enabled on your accountmfa_id: if you have multiple MFA devices, the UUID for the MFA device you want to use**kwargs: arguments passed to the Requests objectsConnection.vehicles: A list of Vehicle objects, corresponding to the
vehicles associated with your account on teslamotors.com.Vehicle: The vehicle class is a subclass of a Python dictionary
(dict).  AVehicleobject contains fields that identify your
vehicle, such as the Vehicle Identification Number (Vehicle['vin']).
All standard dictionary methods are supported.Vehicle.wake_up(): Wake the vehicle.Vehicle.data_request(name): Retrieve data values specified byname, such
ascharge_state,climate_state,vehicle_state. Returns a
dictionary (dict).  For a full list ofnamevalues, see theGETcommands in theTesla JSON API.Vehicle.command(name): Execute the command specified byname, such
ascharge_port_door_open,charge_max_range. Returns a
dictionary (dict).  For a full list ofnamevalues, see thePOSTcommands
in theTesla JSON API.Exampleimport teslajson
c = teslajson.Connection('youremail', 'yourpassword')
v = c.vehicles[0]
v.wake_up()
v.data_request('charge_state')
v.command('charge_start')CreditsMany thanks toTim Dorrfor documenting the Tesla JSON API.
This would not be possible without his work.DisclaimerThis software is provided as-is. This software is not supported by or
endorsed by Tesla. It was developed via reverse-engineering of an
unpublished JSON API. Tesla does not publicly support the underlying
JSON API, so this software may stop working at any time. The author
makes no guarantee to release an updated version to fix any
incompatibilities.ChangelogVersion 2.0Rewritten with Requests library, in order to support the latest Tesla authentication protocolPackaged via PyPI (pip)Version 1.3Removed API and baseurl from constructor; added proxy supportVersion 1.2Refactored to keep sessions persistent and refresh according to the values returned
by the serverVersion 1.1Remove hard-coded client_id and client_secret; read them from pastebin insteadVersion 1.0Initial release