You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
hey all, seeing a very weird failure here. i had to change my pw and re-auth, updated to 2.0 via pip3, also pulled down the repo locally.
Name: TeslaPy
Version: 2.0.0
Summary: A Python module to use the Tesla Motors Owner API
Home-page: https://github.com/tdorssers/TeslaPy
Author: Tim Dorssers
Author-email: tim.dorssers@xs4all.nl
License: UNKNOWN
Location: /usr/local/lib/python3.6/site-packages
Requires: requests-oauthlib, requests, websocket-client
unfortunately after updating, i can only get my scripts to work if in the current directory.
sample script
root@pigts:/var/www/scripts/notify/TeslaPy# cat teslakev.py
import teslapy
with teslapy.Tesla('XXXXX') as tesla:
tesla.fetch_token()
vehicles = tesla.vehicle_list()
vehicles[1].sync_wake_up()
print(vehicles[1].get_vehicle_data()['drive_state'])
command output :
root@pigts:~# python3 /var/www/scripts/notify/TeslaPy/teslakev.py
Traceback (most recent call last):
File "/var/www/scripts/notify/TeslaPy/teslakev.py", line 5, in <module>
vehicles = tesla.vehicle_list()
File "/var/www/scripts/notify/TeslaPy/teslapy/__init__.py", line 281, in vehicle_list
return [Vehicle(v, self) for v in self.api('VEHICLE_LIST')['response']]
File "/var/www/scripts/notify/TeslaPy/teslapy/__init__.py", line 276, in api
return self.request('GET', uri, params=kwargs)
File "/var/www/scripts/notify/TeslaPy/teslapy/__init__.py", line 119, in request
response.raise_for_status() # Raise HTTPError, if one occurred
File "/usr/local/lib/python3.6/site-packages/requests/models.py", line 940, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://owner-api.teslamotors.com/api/1/vehicles
root@pigts:~# cd /var/www/scripts/notify/TeslaPy/
root@pigts:/var/www/scripts/notify/TeslaPy# python3 teslakev.py
{
"gps_as_of": XXX,
"heading": 258,
"latitude": XXX,
"longitude": -XXX,
"native_latitude": XXX,
"native_location_supported": 1,
"native_longitude": -XXX,
"native_type": "wgs",
"power": 0,
"shift_state": null,
"speed": null,
"timestamp": 1632799082968
}
The text was updated successfully, but these errors were encountered:
88gts
changed the title
Just updated to latest, cron will not run scripts, need to be in directory
Can only auth successfully in TeslaPy directory
Sep 28, 2021
When you run your script like that, the cache.json file is searched in the working directory, which is your home dir in your case. This cache.json has probably your old credentials. I can't think of any other reason for the 401. When you change the working dir to the script folder, then a different cache.json is used and the script runs without issue. I suggest you specify the directory for the cache.json file, to make sure that the correct file is used.
hey all, seeing a very weird failure here. i had to change my pw and re-auth, updated to 2.0 via pip3, also pulled down the repo locally.
unfortunately after updating, i can only get my scripts to work if in the current directory.
sample script
command output :
The text was updated successfully, but these errors were encountered: