Giter Site home page Giter Site logo

teslajson's Introduction

teslajson

Simple Python class to access the Tesla JSON API.

Written by Greg Glockner

Description

This is a simple Python interface to the Tesla 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 a Connection object, retrieve the list of Vehicle objects, then perform get/set methods on a Vehicle. 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 2.7 and Python 3.5. It has no dependencies beyond the standard Python libraries.

Installation

  1. Download the repository zip file and uncompress it
  2. Run the following command with your Python interpreter: python setup.py install

Alternately, add the teslajson.py code to your program.

Public API

Connection(email, password, **kwargs): Initialize the connection to the Tesla Motors website.

Required parameters:

  • email: your login for teslamotors.com
  • password: your password for teslamotors.com

Optional parameters:

  • access_token: the session access token; requires baseurl and API
  • baseurl: the URL required by the Tesla Motors JSON service
  • api: the API string required by the Tesla Motors JSON service

Connection.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). A Vehicle object 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 by name, such as charge_state, climate_state, vehicle_state. Returns a dictionary (dict). For a full list of name values, see the GET commands in the Tesla JSON API.

Vehicle.command(name): Execute the command specified by name, such as charge_port_door_open, charge_max_range. Returns a dictionary (dict). For a full list of name values, see the POST commands in the Tesla JSON API.

Example

import teslajson
c = teslajson.Connection('youremail', 'yourpassword')
v = c.vehicles[0]
v.wake_up()
v.data_request('charge_state')
v.command('charge_start')

Credits

Many thanks to Tim Dorr for documenting the Tesla JSON API. This would not be possible without his work.

Disclaimer

This software is provided as-is. This software is not supported by or endorsed by Tesla Motors. Tesla Motors 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.

teslajson's People

Contributors

gglockner avatar the-mace avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.