-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tesla integration ignores configured scan_interval... at first #37340
Comments
I can confirm that bringing the car back online after a longer time (by opening the tesla app) immediately triggers an update (OK), and that keeping the car awake using the Tesla app, does not lead to another poll after 11 minutes. So indeed, AFTER that token update, the 1800 seconds does take effect. But not right away after startup! |
What the? it suddenly reverted back to 660 again: Here are the polls, the poll at 13:48 is OK (30 min), but the one at 13:59 wasn't supposed to happen! 13:18:06 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles/00000000000000000/vehicle_data None
13:19:06 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
13:20:06 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
13:21:07 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
13:22:08 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
13:23:09 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
13:24:10 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
13:25:11 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
13:26:12 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
13:27:12 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
13:28:14 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
13:29:15 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
13:30:15 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
13:31:17 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
13:32:18 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
13:33:19 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
13:34:20 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
13:35:21 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
13:36:21 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
13:37:23 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
13:38:30 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
13:39:33 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
13:40:34 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
13:41:36 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
13:42:38 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
13:43:40 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
13:44:42 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
13:45:44 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
13:46:46 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
13:47:48 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
13:48:15 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles/00000000000000000/vehicle_data None
13:48:50 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
13:49:52 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
13:50:54 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
13:51:56 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
13:52:58 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
13:54:00 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
13:55:02 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
13:56:04 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
13:57:06 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
13:58:08 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
13:59:10 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
13:59:22 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles/00000000000000000/vehicle_data None
14:00:12 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
14:01:14 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
14:02:16 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
14:03:18 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
14:04:20 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
14:05:21 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
14:06:24 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
14:07:26 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
14:08:28 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
14:09:30 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
14:10:24 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles/00000000000000000/vehicle_data None
14:10:32 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
14:11:34 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
14:12:36 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
14:13:38 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
14:14:40 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
14:15:42 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
14:16:44 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
14:17:46 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
14:18:46 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
14:19:50 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
14:20:52 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
14:21:26 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles/00000000000000000/vehicle_data None
14:21:54 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
14:22:56 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
14:23:58 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
14:25:00 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
14:26:02 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
14:27:04 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
14:28:06 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
14:29:08 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
14:30:10 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
14:31:10 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
14:32:12 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
14:32:29 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles/00000000000000000/vehicle_data None
14:33:14 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
14:34:16 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
14:35:17 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
14:36:18 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
14:37:19 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
14:38:20 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
14:39:21 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
14:40:22 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
14:41:23 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
14:42:24 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles None
|
Thanks. I'll take a look to see why the value would reset. It should only go to 660 if it can't find the setting, so perhaps when we refresh the token it's overwriting the value so it's lost. Can you confirm in your For the default, we probably won't change it just because it may conflict with people using other tracking items. We assume advanced users are doing what you are doing and upping the value to work with their other items. For default, we just assume people only use the HA app and the Tesla app. Of course, if testing shows that 660 doesn't work as a default, we can continue to up it but again, there's a downside to delaying it. As to why we reset the oauth token, on reboot the component doesn't know how long the token has been in play, so assumes it needs to reset it after set default. We could probably rewrite the component to save when the token was granted so it avoids that in the future. However, that would only hide the issue you found of the random reset. :) I'll fix your issue first before trying to fix the oauth refresh. |
Also, are you filtering out the |
Ok, it's likely because it's currently trying to go back to sleep after being in a driving/active state. There's some hardcoded values in the controller to handle the immediate case of driving and letting a car that just parked go back to sleep. The user set We can probably change the sleep period to allow the |
Fix staged. Would want the controller logs to confirm though. Or you can try loading it manually. |
storage/core.config_entries: {
"connection_class": "cloud_poll",
"data": {
"access_token": "360af....0d39c7cd",
"token": "310b1686d....5ddfc2fd1ce4af"
},
"domain": "tesla",
"entry_id": "603dde34080343baa488e807d81cc8e5",
"options": {
"scan_interval": 1800
},
"source": "import",
"system_options": {
"disable_new_entities": false
},
"title": ".....@gmail.com",
"unique_id": null,
"version": 1
}, I've done a |
Ok I've confirmed it. You can delete your logs. Thanks. |
* Bump teslajsonpy to 0.9.1 closes #37340 * Bump teslajsonpy to 0.9.2
* Bump teslajsonpy to 0.9.1 closes #37340 * Bump teslajsonpy to 0.9.2
Presuming it's in 112.2, it works like a charm. The car now falls asleep nicely... about 18 minutes after waking it with the Tesla app, which immediately causes Hass to fetch data from it (OK) So in MY case, not sure why, but the car needs a break in polling of > 15 minutes in order to fall asleep. I had to disable the A-Better-Route-planner integration, as it polls the car every 15 minutes, and that caused the car never to fall asleep. When I disconnected that app yesterday afternoon, it fell asleep within 20 minutes, after NOT having slept in days. So I really think some due diligence is in place: did Tesla maybe change this 'timeout'? |
The problem
After starting Home Assistant, the tesla component initialises and starts polling the general vehicles api every minute, to see if the car(s) are online (OK).
If a car is online, it immediately polls its vehicles_data (OK).
And then keeps polling the vehicles api (OK).
Then every 660 seconds, regardless of the configured scan_interval, it checks the vehicle_data again (NOK).
I have scan_interval configured to 1800 because empirical data shows that otherwise, my car will never fall asleep.
In my case, after half an hour (coincidence?) or to be precise, 1830 ish seconds, hass refreshes the API key.
Immediately after that, it logs 'Changing scan interval from 1800 to 1800', but calls the vehicle_data once more at exactly 11 minutes after it last did so.
Exactly 11 minutes after that (12:42:25), it says it 'skips' the update with state online, and one more minute later (12:43:25), the vehicle is offline (asleep).
So it seems that the setting does work, but that it takes a while (until the token refresh, of which I'm not sure what triggers it) for it to actually be used.
Note that 660 seconds might be a too-low default; especially if some other application (Tezlab, Teslafi, ABRP or so) are also polling the vehicle, this may very well to a nover-sleeping car.
Environment
Problem-relevant
configuration.yaml
Traceback/Error logs
Additional information
The text was updated successfully, but these errors were encountered: