core: BMW Connected Drive - 403 Quota Exceeded
The problem
I’m suddenly getting a lot of these:
2022-12-02 12:48:25.497 ERROR (MainThread) [homeassistant.components.bmw_connected_drive.coordinator] Error fetching bmw_connected_drive-XXX@YYY.ZZ data: Error communicating with BMW API: Client error '403 Quota Exceeded' for url 'https://cocoapi.bmwgroup.com/eadrax-vcs/v2/vehicles/VIN-redacted/state'
When this happens, all related entities become unknown (of course). The car can be «lost» for hours, or just minutes, the reappears (for hours or just minutes). Started about 20 h ago.
What version of Home Assistant Core has the issue?
2022.11.4 and 2022.11.5
What was the last working version of Home Assistant Core?
2022.11.4
What type of installation are you running?
Home Assistant OS
Integration causing the issue
BMW Connected Drive
Link to integration documentation on our website
https://www.home-assistant.io/integrations/bmw_connected_drive
Diagnostics information
Not available
Example YAML snippet
No response
Anything in the logs that might be useful for us?
See above
Additional information
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 4
- Comments: 42 (14 by maintainers)
Since I’m not having issues, I’m going to share my config:
I have three automations and automatic polling disabled. I detect if the car is charging using a power meter, but you can use the car charging status (enable the disabled conditions and disable the enabled ones):
1 - Refresh while charging:
2 - Refresh while not charging:
3 - Reload when unavailable for over 15 minutes because a sensor update sometimes wouldn’t work after service outage:
Hope it helps
Looks like they have lowered the quota again. Mine started doing this again last night. Last time this happened 5 minutes seemed to be ok now it’s more like 10 mins. BMW devs suck
Good point 😉
Annoying as it may be, that we cannot request updates from the API as often as we like, let’s look at it from BMW’s perspective:
If I’m not mistaken, we’re exploiting an API that BMW has set up for the benefits of their customers using the MyBMW app (correct me if I’m wrong). The infrastructure required to provide this service requires investments by BMW.
BMW has decided to provide another API for which they charge the users (https://bmw-cardata.bmwgroup.com/thirdparty/public/car-data/technical-configuration/api-documentation). If everyone instead of paying for the use of that commercial API, exploits the MyBMW app API, they lose income and have to invest more in the MyBMW app API.
Looking at it this way, I can’t really blame BMW for limiting the number of API calls per day. Even the commercial API has a limit, although that limit is 100 requests per minute.
I am now updating my BMW entities like this:
unavailableI am counting the calls, and so far today (since midnight UTC) I have 63 calls. I will probably end up at about 75 or so before midnight UTC. I could probably limit it even more, without losing the functions I’m after (I mainly use the BMW data to control smart charging during less expensive electricity hours and to start climatizing the car before departure).
So, if the quota stays at 120 per day (which has been suggested), I should be fine. 😄
Just in case it short-circuits someone else’s search and debugging, the solution mentioned above and in #78792 seems to have resolved the BMW API rate limit contention issues. Here’s what I did:
Disable automatic polling for the BMW Connected Drive integration
Settings->Devices & Services->BMW Connected Drive 3-dot menu->System Options->Enable polling for updates.Create a new automation, something similar to the following:
Note: Per @RuiSSousa’s comment on #78792:
Note: 15 minutes should be good if you don’t care much about manual refreshes, but I’ve just implemented this workaround today so we’ll see how it stands up to the test of time.
:upvote:“HA Enhancement: Integration-specific polling interval configuration option”The educated guess is that the cap is 120 requests/day (i.e. 10 hours of requests every 5 minutes). My guess is that this is on a per-endpoint basis, so two cars should be counted seperately (however I’m not sure of this).
So 24 hours/120 requests = 12,5 minutes between the requests. However I would not go down that far, as we sometimes request additional vehicle refreshs (i.e. after service execution).
You might want to create an automation that adjusts the timing manually, e.g. every 30 minutes by default but every 10 minutes while the car is charging (or whatever you’re interested in).
Happy to get your feedback what works and what is too much (please try it out!) and let me know so we can adjust the defaults and write some help to the documentation.