Skip to content

Commit

Permalink
Merge pull request #26 from gglockner/requests
Browse files Browse the repository at this point in the history
Merge requests branch
  • Loading branch information
gglockner authored Feb 23, 2021
2 parents 77aeb71 + d94d25a commit b42a79a
Show file tree
Hide file tree
Showing 9 changed files with 268 additions and 204 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ build/
teslajson.egg-info/
dist/
MANIFEST
new/*
old/*
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Version 2.0
- Rewritten with Requests library, in order to support the latest Tesla authentication protocol
- Packaged via PyPI (pip)

## Version 1.3
- Removed API and baseurl from constructor; added proxy support

Expand Down
33 changes: 17 additions & 16 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
MIT License

Copyright (c) 2016-2018 Greg Glockner
Copyright (c) 2016-2021 Greg Glockner

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37 changes: 19 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Written by Greg Glockner

## Description
This is a simple Python interface to the [Tesla JSON
API](http://docs.timdorr.apiary.io/). With this, you can query your
API](https://tesla-api.timdorr.com). 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.
Expand All @@ -17,14 +17,16 @@ methods on a _Vehicle_. There is a single get method
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.
This has been tested with Python 3.7 and requires the
[Requests-OAuthlib](https://requests-oauthlib.readthedocs.io) library.

## Installation
0. Download the repository zip file and uncompress it
0. Run the following command with your Python interpreter: `python setup.py install`

Alternately, add the teslajson.py code to your program.
Use any of these methods to download and install the teslajson module:

1. Easiest method: use pip via the command :`pip install teslajson`
2. Download the source code from https://github.com/gglockner/teslajson, then run: `python setup.py install`
3. Download the source code, install requests-oauthlib and its dependencies, then add the file teslajson/teslajson.py to your Python project

## Public API
`Connection(email, password, **kwargs)`:
Expand All @@ -36,11 +38,9 @@ Required parameters:
- _password_: your password for teslamotors.com

Optional parameters:

- _access\_token_: the session access token
- _proxy\_url_: URL for proxy server
- _proxy\_user_: username for proxy server
- _proxy\_password_: password for proxy server
- _mfa_: your multi-factor authentication code, if enabled on your account
- _mfa\_id_: if you have multiple MFA devices, the UUID for the MFA device you want to use
- _\*\*kwargs_: arguments passed to the Requests objects


`Connection.vehicles`: A list of Vehicle objects, corresponding to the
Expand All @@ -56,12 +56,12 @@ All standard dictionary methods are supported.
`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](http://docs.timdorr.apiary.io/).
commands in the [Tesla JSON API](https://tesla-api.timdorr.com).

`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](http://docs.timdorr.apiary.io/).
dictionary (_dict_). For a full list of _name_ values, see the _POST_ commands
in the [Tesla JSON API](https://tesla-api.timdorr.com/).

## Example
import teslajson
Expand All @@ -76,8 +76,9 @@ Many thanks to [Tim Dorr](http://timdorr.com) 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
This 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.
18 changes: 18 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[metadata]
name = teslajson
version = 2.0.0
author = Greg Glockner
author_email = [email protected]
description = Simple Python class to access the Tesla JSON API
long_description = file: README.md, CHANGES.md
long_description_content_type = text/markdown
url = https://github.com/gglockner/teslajson
classifiers =
Programming Language :: Python :: 3
License :: OSI Approved :: MIT License
Operating System :: OS Independent

[options]
packages = find:
install_requires =
requests_oauthlib
14 changes: 2 additions & 12 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
from setuptools import setup, find_packages
# To use a consistent encoding
from codecs import open
from os import path
import setuptools

setup(name='teslajson',
version='1.3.1',
description='',
url='https://github.com/gglockner/teslajson',
py_modules=['teslajson'],
author='Greg Glockner',
license='MIT',
)
setuptools.setup()
158 changes: 0 additions & 158 deletions teslajson.py

This file was deleted.

1 change: 1 addition & 0 deletions teslajson/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .teslajson import *
Loading

0 comments on commit b42a79a

Please sign in to comment.