alandtse / tesla

Tesla custom integration for Home Assistant. This requires a refresh token be generated by third-party apps to login.
Apache License 2.0
586 stars 100 forks source link

Force data update doesn't work when polling is disabled #855

Open ddaddy opened 7 months ago

ddaddy commented 7 months ago

Version of the custom_component

v3.19.8

Describe the bug

When the Polling switch is enabled and I press the Force data update button, the Data last updated time resets to zero and clearly the data has been updated. If I disable the Polling switch and hit the refresh button, the UI data doesn't update. The logs show that an API request has happened, but it skips the update for some reason.

I want to have the car never to be automatically polled (I also updated the polling interval to 10,000) and only update when I tell it to.

Debug log


2024-02-13 10:09:46.359 DEBUG (MainThread) [teslajsonpy.controller] Get vehicles. Force: True Time: 27 Interval 60
2024-02-13 10:09:46.361 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in 7:23:55
2024-02-13 10:09:46.362 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/products {}
2024-02-13 10:09:48.827 DEBUG (MainThread) [teslajsonpy.connection] 200: {"response":[{"id":<<REDACTED>>,"user_id":<<REDACTED>>,"vehicle_id":<<REDACTED>>,"vin":"<<REDACTED>>","color":null,"access_type":"OWNER","display_name":"<<REDACTED>>","option_codes":null,"cached_data":"<<REDACTED>>","granular_access":{"hide_private":false},"tokens":["<<REDACTED>>","<<REDACTED>>"],"state":"online","in_service":false,"id_s":"<<REDACTED>>","calendar_enabled":true,"api_version":36,"backseat_token":null,"backseat_token_updated_at":null,"ble_autopair_enrolled":false,"command_signing":"off"}],"count":1}
2024-02-13 10:09:48.828 DEBUG (MainThread) [teslajsonpy.controller] 17481: Skipping update with state online. Polling: False. Last update: 51 ago. Last parked: 51 ago. Last wake up 260 ago. 
2024-02-13 10:09:48.828 DEBUG (MainThread) [custom_components.tesla_custom] Running controller.update()
2024-02-13 10:09:48.829 DEBUG (MainThread) [teslajsonpy.controller] Get vehicles. Force: False Time: 3 Interval 60
2024-02-13 10:09:48.829 DEBUG (MainThread) [teslajsonpy.controller] 17481: Skipping update with state online. Polling: False. Last update: 54 ago. Last parked: 54 ago. Last wake up 263 ago. 
2024-02-13 10:09:48.830 DEBUG (MainThread) [custom_components.tesla_custom] Finished fetching tesla_custom data in 0.001 seconds (success: True)
MrBLJ commented 6 months ago

Same behavior on my end. Thing is : with polling enabled my model Y is never going to sleep, even with the interval set to 6000. This is not the case for my model 3. For now, i have to turn polling on before requesting a data update.