Skip to content
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 Fleet is polling too often #141462

Closed
BarBaar44 opened this issue Mar 26, 2025 · 18 comments · Fixed by #142130
Closed

Tesla Fleet is polling too often #141462

BarBaar44 opened this issue Mar 26, 2025 · 18 comments · Fixed by #142130

Comments

@BarBaar44
Copy link

The problem

The Tesla Fleet integration is polling too often. I just received an e-mail that the monthly limits have been reached. As a result, the fleet connection is disabled.

If I look at the stats at the Tesla Developers site, I see about 286 polls each day. Some days are lower, for reasons unknown to me.

I think we either make polling configurable or make polling dynamic. For example, increase polling rate when charging, etc.

What version of Home Assistant Core has the issue?

2025.3.4

What was the last working version of Home Assistant Core?

2025.3.4

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Tesla Fleet

Link to integration documentation on our website

https://www.home-assistant.io/integrations/tesla_fleet

Diagnostics information

No response

Example YAML snippet

Anything in the logs that might be useful for us?

Additional information

No response

@home-assistant
Copy link

Hey there @Bre77, mind taking a look at this issue as it has been labeled with an integration (tesla_fleet) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of tesla_fleet can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign tesla_fleet Removes the current integration label and assignees on the issue, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


tesla_fleet documentation
tesla_fleet source
(message by IssueLinks)

@Bre77
Copy link
Contributor

Bre77 commented Mar 26, 2025

You can disable polling in the config entry option and setup your own polling logic with an automation and the update entity action on a single vehicle entity.

https://www.home-assistant.io/common-tasks/general/#why-use-an-automation-instead-of-changing-the-integrations-polling-configuration

@BarBaar44
Copy link
Author

Thanks, didn't know that. And provides a solution for now.

But, it may be nice to set a default polling interval that makes sure you never hit Tesla's limitation on the 10 dollar (thus free) option?

@Bre77
Copy link
Contributor

Bre77 commented Mar 26, 2025

Thanks, didn't know that. And provides a solution for now.

But, it may be nice to set a default polling interval that makes sure you never hit Tesla's limitation on the 10 dollar (thus free) option?

What would you suggest? It's currently set to 5 minutes which assumes a vehicle is only awake 50% of the day per day.

The problem is some people have vehicles asleep for days at a time and others who rideshare and their vehicles are rarely asleep.

No default will suit all people, and a default that will mathematically never hit the $10 credit only does so when you have a single vehicle.

Ultimately if you want a good data experience you should use a paid service like Teslemetry instead.

@Jjesper
Copy link

Jjesper commented Mar 29, 2025

Hi Bre77,
Running into the same problems and noticing increase in battery usage. Looks like my vehicle is held more awake than before.
Suggestion: let the user be able to configure the polling interval in the integration settings.
For single car users a default of 6 minutes won’t hit the free limit, but like you said it depends on use case and amount of products.
I personally think 6 times per hour default should be enough for home automation purposes. This also leaves room in credit for sending commands.
Thank you.

@Bre77
Copy link
Contributor

Bre77 commented Mar 29, 2025

Running into the same problems and noticing increase in battery usage. Looks like my vehicle is held more awake than before.

Unless you have an old Model S / X or haven't firmware updates your new model, that shouldn't be happening.

Suggestion: let the user be able to configure the polling interval in the integration settings.

Not allowed to do that in the Home Assistant project. You have to use the method I linked above.

@smougenot
Copy link

Same trouble for me
It worked flowlessly then the polling frequency goes from 62 a day to 286 a day.

  • no update on the car
  • maybe an update on HA

Image

@Bre77
Copy link
Contributor

Bre77 commented Mar 29, 2025

Same trouble for me
It worked flowlessly then the polling frequency goes from 62 a day to 286 a day.

  • no update on the car
  • maybe an update on HA

Image

Turn debug logging on for the integration for 30-60 minutes and share that with me so I can troubleshoot this. If you don't want to post them to GitHub email admin@teslemetry.com

@Jjesper
Copy link

Jjesper commented Mar 29, 2025

Hi Bre77,
Thanks for replying.
To understand, what do you mean with
“Not allowed to do that in the Home Assistant project.”?

I have a 2023 model 3. Always update when released asap.

Also seeing a 3x increase like smougenot.
Will try to supply you with a debug log next week.
Thanks. Have a good weekend.

@smougenot
Copy link

smougenot commented Mar 29, 2025

Same trouble for me
It worked flowlessly then the polling frequency goes from 62 a day to 286 a day.

  • no update on the car
  • maybe an update on HA

Image

Turn debug logging on for the integration for 30-60 minutes and share that with me so I can troubleshoot this. If you don't want to post them to GitHub email admin@teslemetry.com

Looks like I've some debug logs ... but not much (every 5').
Maybe I did not activate the proper log?

2025-03-29 23:31:27.943 DEBUG (MainThread) [homeassistant.components.tesla_fleet] Finished fetching Tesla Fleet Vehicle data in 0.077 seconds (success: True)
2025-03-29 23:36:27.744 DEBUG (MainThread) [homeassistant.components.tesla_fleet] Finished fetching Tesla Fleet Vehicle data in 0.162 seconds (success: True)
2025-03-29 23:41:27.760 DEBUG (MainThread) [homeassistant.components.tesla_fleet] Finished fetching Tesla Fleet Vehicle data in 0.178 seconds (success: True)
2025-03-29 23:46:27.710 DEBUG (MainThread) [homeassistant.components.tesla_fleet] Finished fetching Tesla Fleet Vehicle data in 0.128 seconds (success: True)
2025-03-29 23:51:27.738 DEBUG (MainThread) [homeassistant.components.tesla_fleet] Finished fetching Tesla Fleet Vehicle data in 0.155 seconds (success: True)
2025-03-29 23:56:27.764 DEBUG (MainThread) [homeassistant.components.tesla_fleet] Finished fetching Tesla Fleet Vehicle data in 0.182 seconds (success: True)
2025-03-30 00:01:27.718 DEBUG (MainThread) [homeassistant.components.tesla_fleet] Finished fetching Tesla Fleet Vehicle data in 0.136 seconds (success: True)

Also added an automation to manually trigger the update (for test purposes). No more log are generated.

automation definition
- id: '1743289658517'
  alias: update_entity_tut_tut
  description: ''
  triggers: []
  conditions: []
  actions:
  - action: homeassistant.update_entity
    metadata: {}
    data:
      entity_id:
      - sensor.tut_tut_bolide_charge_energy_added
      - sensor.tut_tut_bolide_tire_pressure_front_left
      - sensor.tut_tut_bolide_odometer
      - sensor.tut_tut_bolide_battery_level
  mode: single

Also added some credit on Tesla developer (1$). No change

  • No more info in the logs
  • No more telemetry received

@Bre77
Copy link
Contributor

Bre77 commented Mar 30, 2025

To understand, what do you mean with
“Not allowed to do that in the Home Assistant project.”?

If I raise a PR that allows the user to configure the coordinator refresh interval it will be rejected, because the Home Assistant project doesn't allow that. If users want to change the polling interval they must use a custom automation to do so.

@Bre77
Copy link
Contributor

Bre77 commented Mar 30, 2025

2025-03-29 23:31:27.943 DEBUG (MainThread) [homeassistant.components.tesla_fleet] Finished fetching Tesla Fleet Vehicle data in 0.077 seconds (success: True)
2025-03-29 23:36:27.744 DEBUG (MainThread) [homeassistant.components.tesla_fleet] Finished fetching Tesla Fleet Vehicle data in 0.162 seconds (success: True)
2025-03-29 23:41:27.760 DEBUG (MainThread) [homeassistant.components.tesla_fleet] Finished fetching Tesla Fleet Vehicle data in 0.178 seconds (success: True)
2025-03-29 23:46:27.710 DEBUG (MainThread) [homeassistant.components.tesla_fleet] Finished fetching Tesla Fleet Vehicle data in 0.128 seconds (success: True)
2025-03-29 23:51:27.738 DEBUG (MainThread) [homeassistant.components.tesla_fleet] Finished fetching Tesla Fleet Vehicle data in 0.155 seconds (success: True)
2025-03-29 23:56:27.764 DEBUG (MainThread) [homeassistant.components.tesla_fleet] Finished fetching Tesla Fleet Vehicle data in 0.182 seconds (success: True)
2025-03-30 00:01:27.718 DEBUG (MainThread) [homeassistant.components.tesla_fleet] Finished fetching Tesla Fleet Vehicle data in 0.136 seconds (success: True)

That looks correct, and the change your seeing is likely a result of this PR I did #138576

So long story short if you don't want your vehicle polled every 5 minutes when awake, disabled entity updates and create your own automation.

@smougenot
Copy link

2025-03-29 23:31:27.943 DEBUG (MainThread) [homeassistant.components.tesla_fleet] Finished fetching Tesla Fleet Vehicle data in 0.077 seconds (success: True)
2025-03-29 23:36:27.744 DEBUG (MainThread) [homeassistant.components.tesla_fleet] Finished fetching Tesla Fleet Vehicle data in 0.162 seconds (success: True)
2025-03-29 23:41:27.760 DEBUG (MainThread) [homeassistant.components.tesla_fleet] Finished fetching Tesla Fleet Vehicle data in 0.178 seconds (success: True)
2025-03-29 23:46:27.710 DEBUG (MainThread) [homeassistant.components.tesla_fleet] Finished fetching Tesla Fleet Vehicle data in 0.128 seconds (success: True)
2025-03-29 23:51:27.738 DEBUG (MainThread) [homeassistant.components.tesla_fleet] Finished fetching Tesla Fleet Vehicle data in 0.155 seconds (success: True)
2025-03-29 23:56:27.764 DEBUG (MainThread) [homeassistant.components.tesla_fleet] Finished fetching Tesla Fleet Vehicle data in 0.182 seconds (success: True)
2025-03-30 00:01:27.718 DEBUG (MainThread) [homeassistant.components.tesla_fleet] Finished fetching Tesla Fleet Vehicle data in 0.136 seconds (success: True)

That looks correct, and the change your seeing is likely a result of this PR I did #138576

So long story short if you don't want your vehicle polled every 5 minutes when awake, disabled entity updates and create your own automation.

Thank you for the explanation

The older way with a "dynamic rate" for Tesla API calls looked much more effective to me

  • We (as HA users) can not know if the vehicle is awake or not before doing the update (only Tesla API provides that info)
  • So it means we only will have 5 minute polling so 288 API calls a day (that's what the graph is showing)
  • Consequently we (as HA users) are doomed to pay Tesla due to that change
    • in my case API cost is 2€/1000 calls with the first 5000 calls free
    • 1 month at 5 minutes period means 8928 (= 12 * 24 * 31)
    • 7.85€/month of cost (that could be saved)
  • The former implementation (removed in the PR you mentioned) allowed better user experience
    • API calls rate was dynamic,
      • providing more accuracy when it maters
      • providing savings and efficiency
      • As shown in the graph
        • some day could be covered by only 60 calls (one every half our)
    • based on what Tesla API provide as code (tesla_fleet_api.ratecalculator)
      • So it is not a big deal to implement on your side (inside the integration)

It would be nice to revert to the dynamic rate or at least let us choose to disable it with a warning about costs and efficiency.
Could you do it please?

@BarBaar44
Copy link
Author

Agree @smougenot

I am a bit surprised about that PR, as I don't agree there no longer is a rate limit. There is a rate limit, unless you decide to pay.

It would be an option to configure this in the integration:

  • free Tesla: use the old-style dynamic polling
  • paid tesla: poll every 5 minutes

@Bre77
Copy link
Contributor

Bre77 commented Mar 30, 2025

  • We (as HA users) can not know if the vehicle is awake or not before doing the update (only Tesla API provides that info)

That's a good point, and that is something I can solve. I could independently populate the status entity every minute since its API is free.

That said, if you simply want to set the polling rate to a fixed rate (like 10 minutes) you don't need to know if the vehicle is awake. The integration never wakes your vehicle for data.

@smougenot
Copy link

Why not reverting the change (simple, efficient) that reduced the functionality (in both quality and cost).
The PR that causes the trouble is here #138576
This course of actions makes me sad.

It looks like the reduced functionality is intentional. Maybe it is a conflit of interest with another project.

@Bre77
Copy link
Contributor

Bre77 commented Apr 3, 2025

Why not reverting the change (simple, efficient) that reduced the functionality (in both quality and cost).
The PR that causes the trouble is here #138576
This course of actions makes me sad.

Because it was causing the integration to stop polling for long periods and someone complained about that. I think the rate limit code has been removed from the library so a straight rollback isn't possible.

It looks like the reduced functionality is intentional. Maybe it is a conflit of interest with another project.

Making the integration more predictable and easier to maintain helps. I'm code owner of 6 different integrations so I do have to prioritise my time, and first priority is the integration people pay me money to develop and support (Teslemetry).

This is open source, anyone can contribute.

@Olen
Copy link
Contributor

Olen commented Apr 8, 2025

Maybe we could crowdsource a nice automation (or even a blueprint) to implement "best practices" for dynamic polling?

https://community.home-assistant.io/t/dynamic-polling-of-tesla-fleet/875314

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants