gglockner / teslajson Goto Github PK
View Code? Open in Web Editor NEWSimple Python class to access the Tesla JSON API
License: MIT License
Simple Python class to access the Tesla JSON API
License: MIT License
Hi there, in the prior version of the library it was possible to access the Connection.access_token value which allowed for caching of the access token for extended periods and allowed me to pass it back in later. The recent changes broke that interface (access_token no longer there) and prohibits caching of the token.
Nice repo but do you have any plans to publish to pypi so that it's easier for people to use this module?
been using this for a while, simple query for status failed this evening.
urllib2.HTTPError: HTTP Error 301: The HTTP server returned a redirect error that would lead to an infinite loop.
The last 30x error message was:
Moved Permanently
I simply cannot get the sharing of navigation to work. Neither sharing media for that matter. It always returns a 500 error code. Might be connected to #19
Code:
import teslajson, time; c = teslajson.Connection('youremail', 'yourpassword'); v = c.vehicles[0]; location = '59.9375206,10.9285069'; params = {'type':'share_ext_content_raw','value':{'android.intent.extra.TEXT':location},'locale':'en-US','timestamp_ms':str(time.time())[:10]}; v.command('navigation_request',params):
It is, to say the least, extremely suspicious that this library gets the Tesla API base URL from a pastbin.com URL managed by the maintainer (@gglockner). This would suggest that all login credentials from the clients using this can be relayed to anywhere he wants.
Line 56 in e91d787
For this reason I would advise caution using it and at least fork and modify the code.
I get this error sometimes and the script breaks. I think this is caused by the Tesla Servers being unavailable. Any way to try it again until it works or have some proper return?
The mobile_enabled API endpoint doesn't seem to implemented/proxied by this wrapper, if I'm reading the code correctly. Any reason for that?
Anyone else getting access issues suddenly? no changes on my end!
File "/var/www/scripts/notify/teslajson/teslajson.py", line 72, in init
self.vehicles = [Vehicle(v, self) for v in self.get('vehicles')['response']]
File "/var/www/scripts/notify/teslajson/teslajson.py", line 76, in get
return self.post(command, None)
File "/var/www/scripts/notify/teslajson/teslajson.py", line 82, in post
auth = self.__open("/oauth/token", data=self.oauth)
File "/var/www/scripts/notify/teslajson/teslajson.py", line 119, in __open
resp = opener.open(req)
File "/usr/lib/python2.7/urllib2.py", line 437, in open
response = meth(req, response)
File "/usr/lib/python2.7/urllib2.py", line 550, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib/python2.7/urllib2.py", line 475, in error
return self._call_chain(*args)
File "/usr/lib/python2.7/urllib2.py", line 409, in _call_chain
result = func(*args)
File "/usr/lib/python2.7/urllib2.py", line 558, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 400: Bad Request
def vehicle_data(self):
result = self.get('vehicle_data')
return result['response']
Hi there, theres a small tweak needed to allow things like sunroof state to be passed through. I can commit the changes but I don't have access. Thanks for making this little library available.
Attached is the file with the changes if you want to preview.
teslajson.py.zip
does anyone have experience with the streaming of vehicle data.
Is there an example in Python?
Hi,
This was working and I have just started to get 403 errors. Is this happening to anybody else?
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://auth.tesla.com/oauth2/v3/authorize?code_challenge=NDk3YmI5MzZhOWRkNTBiNDA2MDlkYjdkZWI4ZGE1NDY2ODlhMTVmZDczZWVjZjUwYjg4Y2Y0NzVlOTVmYzJiOA%3D%3D&client_id=ownerapi&state=lmim84twliip2m0dm46zl1u7&redirect_uri=https%3A%2F%2Fauth.tesla.com%2Fvoid%2Fcallback&response_type=code&code_challenge_method=S256&scope=openid+email+offline_access
hello Greg
Firstly, this is not an issue! Its more of understanding python constructors
thanks for sharing the example code. I am looking for a way to code a constructor which can be more modular. In your code, I see its a long function with quite a few things. How can I define some functions which constructor can call?
I tried calling other class methods but I am getting scope error (undefined)
such breakdown is more modular and maybe reusable elsewhere
thanks
Sriram
Hi
I copied the sample odometer script and just calling as is, seems to give me an error as shown below. Any idea about how to fix it?
File "./tesla.py", line 7, in
TESLA_EMAIL = os.environ['[email protected]']
File "/usr/lib64/python2.7/UserDict.py", line 23, in getitem
raise KeyError(key)
KeyError: '[email protected]'
Is there a way to close the http connections when the requests and posts are done?
Our vehicle seems to be awake all the time an I have the suspicion that it is because the API is connected all the time...
I get a lot of http 408 (timeout) errors when I try to do a .get
(e.g., charge_state = v.get('data_request/charge_state')
Is there a timeout parameter that I should modify to avoid this?
I don’t, but I’m curious what your use case would be...
Originally posted by @ejsuncy in #17 (comment)
code and pw have not changed but i have not been able to auth for two days or so. anyone else experiencing this?
87, in fetch_sso_token
m = re.search('code=([^&]*)',r.headers['location'])
File "/usr/local/lib/python3.6/site-packages/requests/structures.py", line 52, in getitem
return self._store[key.lower()][1]
KeyError: 'location'
This package fails with HTTP 401 unauthorized.
Does it still work? Does it work with Model 3?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.