Comments (9)
You can try to enable retries, so requests will retry after a connection aborted exception:
with teslapy.Tesla(username, retry=3, timeout=20) as tesla:
You can even have TeslaPy retry HTTP exceptions:
retry = teslapy.Retry(total=3, status_forcelist=(500, 502, 503, 504))
with teslapy.Tesla(username, retry=retry, timeout=20) as tesla:
from teslapy.
Thanks, I'll give it a try.
from teslapy.
No crash today with the addition of the retry and timeout parameters. I'll report back tomorrow and close the issue if all is well, thanks.
from teslapy.
Great. The reason that retries aren't enabled by default, is that if you hammer the API too much, your account can be blocked temporarily. But if you retry a couple of times and back off a while and retry again, then it shouldn't be an issue.
from teslapy.
Hi, it crashed again reading the following line:
vehicleData = vehicles[vehicle].get_vehicle_data()
With a 408 exception. The line just before that was
if vehicles[vehicle].available() == True: # Only read if the car isn't asleep
From what I got in your doc for 'available':
checks if the vehicle is online based on cached data or refreshed status when aged out
It looks like the car went offline before the cache aged out.
I'm just starting with Python and not sure I would go about forcing a cache refresh before the 'available()' call or adding a HTTPError 408 exception around that 'get_vehicle_data()' so it acts as if the car is offline when it's thrown.
For now, i'm doing my own 'available' check as such
available = False
vehicles = tesla.vehicle_list()
if vehicles[vehicle]['state'] != 'asleep':
available = True
Wondering if there is a better way.
Thanks,
from teslapy.
I would catch the 408 exception, because it takes about 30 seconds for the car to actually go to sleep.
from teslapy.
Thanks, I've set the retry and connection parameters as such
retry = teslapy.Retry(total=5, status_forcelist=(408, 500, 502, 503, 504, 540))
tesla = teslapy.Tesla(Config.get('Tesla', 'username'), retry=retry, timeout=10)
I'll see how it goes in the following days. Thanks for maintaining this library btw :-)
from teslapy.
Has been stable since my last post 5 days ago. I'll go ahead and close this issue. Thanks for your help :-)
I do wish Tesla would implement internally what I'm doing here, which is when rain is detected (it does already), close the windows if the car is parked. Could work similar to cabin overheat protection. It would work everywhere, not just close to my weather station.
from teslapy.
Working, thanks for your help.
from teslapy.
Related Issues (20)
- Upgrade of Tesla App breaks API calls HOT 6
- looks like charge_state has moved HOT 4
- Any way to know if heated steering wheel is present or not? HOT 3
- minutes to full charge = 0 HOT 3
- Unlock charge port HOT 2
- Security issue with cache.json HOT 1
- May be an issue with CHANGE_CLIMATE_TEMPERATURE_SETTING command HOT 2
- Calling api() returns 404 error HOT 1
- Unable to edit wpa_supplicant.conf HOT 1
- WebSocket does not terminate in streaming HOT 1
- 'drive_state' Data Sometimes Not Provided Following 'get_vehicle_data'? HOT 6
- sync_wake_up Works Fine With One Car But Sometimes Times Out On Another HOT 3
- TypeError: unsupported format string passed to NoneType.__format__ HOT 9
- last_seen() raises HOT 9
- Charging stops HOT 1
- How to call `mobile-app/*` endpoints?
- Error 404 in every endpoint HOT 2
- (missing_token) Missing access token parameter. HOT 14
- Powerwall - cannot retrieve the mode HOT 3
- 429 on every sync_wake_up() call HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from teslapy.