core icon indicating copy to clipboard operation
core copied to clipboard

bmw_connected_drive - 403 Quota Exceeded

Open Cebeerre opened this issue 3 years ago • 35 comments

The problem

Seems that BMW has limited the amount of queries you can do to their API, as it's now throwing a 403 with a "Quote Exceeded" message making all the sensors unavailable.

What version of Home Assistant Core has the issue?

2022.9.5

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

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

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2022-09-19 19:43:30.442 ERROR (MainThread) [homeassistant.components.bmw_connected_drive.coordinator] Error fetching [email protected] data: Error communicating with BMW API: Client error '403 Quota Exceeded' for url 'https://cocoapi.bmwgroup.com/eadrax-vcs/v2/vehicles'
For more information check: https://httpstatuses.com/403
2022-09-19 19:53:36.015 ERROR (MainThread) [homeassistant.components.bmw_connected_drive.coordinator] Error fetching [email protected] data: Error communicating with BMW API: Client error '403 Quota Exceeded' for url 'https://cocoapi.bmwgroup.com/eadrax-vcs/v2/vehicles'
For more information check: https://httpstatuses.com/403
2022-09-19 20:13:40.208 ERROR (MainThread) [homeassistant.components.bmw_connected_drive.coordinator] Error fetching [email protected] data: Error communicating with BMW API: Client error '403 Quota Exceeded' for url 'https://cocoapi.bmwgroup.com/eadrax-vcs/v2/vehicles'
For more information check: https://httpstatuses.com/403
2022-09-19 20:28:44.379 ERROR (MainThread) [homeassistant.components.bmw_connected_drive.coordinator] Error fetching [email protected] data: Error communicating with BMW API: Client error '403 Quota Exceeded' for url 'https://cocoapi.bmwgroup.com/eadrax-vcs/v2/vehicles'
For more information check: https://httpstatuses.com/403
2022-09-19 20:58:47.330 ERROR (MainThread) [homeassistant.components.bmw_connected_drive.coordinator] Error fetching [email protected] data: Error communicating with BMW API: Client error '403 Quota Exceeded' for url 'https://cocoapi.bmwgroup.com/eadrax-vcs/v2/vehicles'
For more information check: https://httpstatuses.com/403
2022-09-19 21:13:50.213 ERROR (MainThread) [homeassistant.components.bmw_connected_drive.coordinator] Error fetching [email protected] data: Error communicating with BMW API: Client error '403 Quota Exceeded' for url 'https://cocoapi.bmwgroup.com/eadrax-vcs/v2/vehicles'

Additional information

No response

Cebeerre avatar Sep 19 '22 20:09 Cebeerre

Hey there @gerard33, @rikroe, mind taking a look at this issue as it has been labeled with an integration (bmw_connected_drive) you are listed as a code owner for? Thanks! (message by CodeOwnersMention)

Can confirm, thanks for the report. Could be a temporary configuration thing at BMW or a very deliberately one. I'll see if I find some time to debug this tomorrow.

rikroe avatar Sep 19 '22 20:09 rikroe

Same here. MyBMW app isn't updating vehicle status too.

macieksonik avatar Sep 19 '22 20:09 macieksonik

MyBMW app was updated 12 hours ago so probably (hopefully) not related to HA integration?

rhoddan avatar Sep 19 '22 21:09 rhoddan

Same here after updating to 2022.9.5

nexus256 avatar Sep 19 '22 21:09 nexus256

Same here - still on 2022.9.4 so probably not related to the new version...

bdeprez avatar Sep 19 '22 22:09 bdeprez

It seems as if BMW pulled on too tight quotas - it worked for almost the whole night for me (after a restart of HA) and then just this morning it had some issues (that self-healed).

It might not even be related to the 5 minute polling intervall, but rather if we do our requests too quickly:

2022-09-20 08:06:52.526 DEBUG (MainThread) [httpx._client] HTTP Request: GET https://cocoapi.bmwgroup.com/eadrax-vcs/v2/vehicles "HTTP/1.1 200 OK"
2022-09-20 08:06:52.901 DEBUG (MainThread) [httpx._client] HTTP Request: GET https://cocoapi.bmwgroup.com/eadrax-vcs/v2/vehicles "HTTP/1.1 200 OK"
2022-09-20 08:06:53.454 DEBUG (MainThread) [httpx._client] HTTP Request: GET https://cocoapi.bmwgroup.com/eadrax-vcs/v2/vehicles/VIN/state "HTTP/1.1 200 OK"
2022-09-20 08:06:53.458 DEBUG (MainThread) [custom_components.bmw_connected_drive.coordinator] Finished fetching bmw_connected_drive-ACCOUNT data in 2.457 seconds (success: True)
2022-09-20 08:11:53.893 DEBUG (MainThread) [httpx._client] HTTP Request: GET https://cocoapi.bmwgroup.com/eadrax-vcs/v2/vehicles "HTTP/1.1 200 OK"
2022-09-20 08:11:54.309 DEBUG (MainThread) [httpx._client] HTTP Request: GET https://cocoapi.bmwgroup.com/eadrax-vcs/v2/vehicles "HTTP/1.1 200 OK"
2022-09-20 08:11:54.358 DEBUG (MainThread) [httpx._client] HTTP Request: GET https://cocoapi.bmwgroup.com/eadrax-vcs/v2/vehicles/VIN/state "HTTP/1.1 403 Quota Exceeded"
2022-09-20 08:11:54.361 ERROR (MainThread) [custom_components.bmw_connected_drive.coordinator] Error fetching bmw_connected_drive-ACCOUNT data: Error communicating with BMW API: Client error '403 Quota Exceeded' for url 'https://cocoapi.bmwgroup.com/eadrax-vcs/v2/vehicles/VIN/state'
2022-09-20 08:11:54.362 DEBUG (MainThread) [custom_components.bmw_connected_drive.coordinator] Finished fetching bmw_connected_drive-ACCOUNT data in 1.361 seconds (success: False)
2022-09-20 08:16:54.231 DEBUG (MainThread) [httpx._client] HTTP Request: GET https://cocoapi.bmwgroup.com/eadrax-vcs/v2/vehicles "HTTP/1.1 403 Quota Exceeded"
2022-09-20 08:16:54.233 DEBUG (MainThread) [custom_components.bmw_connected_drive.coordinator] Finished fetching bmw_connected_drive-ACCOUNT data in 0.233 seconds (success: False)
2022-09-20 08:21:54.360 DEBUG (MainThread) [httpx._client] HTTP Request: GET https://cocoapi.bmwgroup.com/eadrax-vcs/v2/vehicles "HTTP/1.1 403 Quota Exceeded"
2022-09-20 08:21:54.362 DEBUG (MainThread) [custom_components.bmw_connected_drive.coordinator] Finished fetching bmw_connected_drive-ACCOUNT data in 0.361 seconds (success: False)
2022-09-20 08:26:54.744 DEBUG (MainThread) [httpx._client] HTTP Request: GET https://cocoapi.bmwgroup.com/eadrax-vcs/v2/vehicles "HTTP/1.1 200 OK"
2022-09-20 08:26:55.065 DEBUG (MainThread) [httpx._client] HTTP Request: GET https://cocoapi.bmwgroup.com/eadrax-vcs/v2/vehicles "HTTP/1.1 200 OK"
2022-09-20 08:26:55.537 DEBUG (MainThread) [httpx._client] HTTP Request: GET https://cocoapi.bmwgroup.com/eadrax-vcs/v2/vehicles/VIN/state "HTTP/1.1 200 OK"
2022-09-20 08:26:55.541 INFO (MainThread) [custom_components.bmw_connected_drive.coordinator] Fetching bmw_connected_drive-ACCOUNT data recovered

At 08:11:54.358 there was a request only 0.049 seconds after the last, while it is usually rather around 0.5 seconds. But it self-healed at least...

I'll continue to monitor this.

rikroe avatar Sep 20 '22 07:09 rikroe

It seems as if BMW pulled on too tight quotas - it worked for almost the whole night for me (after a restart of HA) and then just this morning it had some issues (that self-healed).

It might not even be related to the 5 minute polling intervall, but rather if we do our requests too quickly:

2022-09-20 08:06:52.526 DEBUG (MainThread) [httpx._client] HTTP Request: GET https://cocoapi.bmwgroup.com/eadrax-vcs/v2/vehicles "HTTP/1.1 200 OK"
2022-09-20 08:06:52.901 DEBUG (MainThread) [httpx._client] HTTP Request: GET https://cocoapi.bmwgroup.com/eadrax-vcs/v2/vehicles "HTTP/1.1 200 OK"
2022-09-20 08:06:53.454 DEBUG (MainThread) [httpx._client] HTTP Request: GET https://cocoapi.bmwgroup.com/eadrax-vcs/v2/vehicles/VIN/state "HTTP/1.1 200 OK"
2022-09-20 08:06:53.458 DEBUG (MainThread) [custom_components.bmw_connected_drive.coordinator] Finished fetching bmw_connected_drive-ACCOUNT data in 2.457 seconds (success: True)
2022-09-20 08:11:53.893 DEBUG (MainThread) [httpx._client] HTTP Request: GET https://cocoapi.bmwgroup.com/eadrax-vcs/v2/vehicles "HTTP/1.1 200 OK"
2022-09-20 08:11:54.309 DEBUG (MainThread) [httpx._client] HTTP Request: GET https://cocoapi.bmwgroup.com/eadrax-vcs/v2/vehicles "HTTP/1.1 200 OK"
2022-09-20 08:11:54.358 DEBUG (MainThread) [httpx._client] HTTP Request: GET https://cocoapi.bmwgroup.com/eadrax-vcs/v2/vehicles/VIN/state "HTTP/1.1 403 Quota Exceeded"
2022-09-20 08:11:54.361 ERROR (MainThread) [custom_components.bmw_connected_drive.coordinator] Error fetching bmw_connected_drive-ACCOUNT data: Error communicating with BMW API: Client error '403 Quota Exceeded' for url 'https://cocoapi.bmwgroup.com/eadrax-vcs/v2/vehicles/VIN/state'
2022-09-20 08:11:54.362 DEBUG (MainThread) [custom_components.bmw_connected_drive.coordinator] Finished fetching bmw_connected_drive-ACCOUNT data in 1.361 seconds (success: False)
2022-09-20 08:16:54.231 DEBUG (MainThread) [httpx._client] HTTP Request: GET https://cocoapi.bmwgroup.com/eadrax-vcs/v2/vehicles "HTTP/1.1 403 Quota Exceeded"
2022-09-20 08:16:54.233 DEBUG (MainThread) [custom_components.bmw_connected_drive.coordinator] Finished fetching bmw_connected_drive-ACCOUNT data in 0.233 seconds (success: False)
2022-09-20 08:21:54.360 DEBUG (MainThread) [httpx._client] HTTP Request: GET https://cocoapi.bmwgroup.com/eadrax-vcs/v2/vehicles "HTTP/1.1 403 Quota Exceeded"
2022-09-20 08:21:54.362 DEBUG (MainThread) [custom_components.bmw_connected_drive.coordinator] Finished fetching bmw_connected_drive-ACCOUNT data in 0.361 seconds (success: False)
2022-09-20 08:26:54.744 DEBUG (MainThread) [httpx._client] HTTP Request: GET https://cocoapi.bmwgroup.com/eadrax-vcs/v2/vehicles "HTTP/1.1 200 OK"
2022-09-20 08:26:55.065 DEBUG (MainThread) [httpx._client] HTTP Request: GET https://cocoapi.bmwgroup.com/eadrax-vcs/v2/vehicles "HTTP/1.1 200 OK"
2022-09-20 08:26:55.537 DEBUG (MainThread) [httpx._client] HTTP Request: GET https://cocoapi.bmwgroup.com/eadrax-vcs/v2/vehicles/VIN/state "HTTP/1.1 200 OK"
2022-09-20 08:26:55.541 INFO (MainThread) [custom_components.bmw_connected_drive.coordinator] Fetching bmw_connected_drive-ACCOUNT data recovered

At 08:11:54.358 there was a request only 0.049 seconds after the last, while it is usually rather around 0.5 seconds. But it self-healed at least...

I'll continue to monitor this.

it's indeed quite random, as it works for maybe two or three hours then maybe doesn't work for two hours (or 5 minutes), then self-heals ... so, yes, probably this has something to do more with a rate limit than with a total amount of queries ...

I'll try to do some tests later today ...

Cebeerre avatar Sep 20 '22 08:09 Cebeerre

FWIW, everything was fine for me until 3PM ET yesterday.

BeerDiet avatar Sep 20 '22 12:09 BeerDiet

Same here, if it helps uploading more logs, let me know

TheGabeMan avatar Sep 20 '22 14:09 TheGabeMan

Obvisously, everyone is affected... hopefully is a temporary malfunction and not a permanent strict quota policy.

sfortis avatar Sep 20 '22 14:09 sfortis

Same problem here. Car is also thrown out of the 'My BMW'-app and it can not be added anymore. I guess that is connected to this problem?

olivierdj avatar Sep 20 '22 15:09 olivierdj

Same Problem here. But the myBMW App is still working.

schmitzmichael avatar Sep 20 '22 16:09 schmitzmichael

Same problem, started yesterday. Sending commands from the myBMW app works fine, but the charge state does not update. I´ve opened a ticket with BMW.

Also logging out and in again in the app will yield 0 cars.

danhusan avatar Sep 20 '22 17:09 danhusan

perhaps superfluous - but same issues here - worked untill today for me est 1500 hours - then nothing any more... also the quota messages.

poweredgenl avatar Sep 20 '22 18:09 poweredgenl

Looking over the last ~30hrs of HA entity availability (which I can confirm correlates to my 403 quota issues), it appears my API quota reset promptly at 5PM PST (which is coincidentally midnight UTC). I am guessing we are dealing with a [new??] daily quota. Based on how long my requests were completing successfully (~10 hrs), I am also going to make a guess that a default, 1-car, minimal MyBMW app usage cases that quota to be exceeded by about 3x the allowable rate. As such, I have attempted to reduce my scan interval by 3x to 900s (or once every 15m). I added some notes as to what I did over here. If the above is correctly, it sounds like we will have to wait another 3 hours to test this theory (when the daily quota likely resets).

jprouty avatar Sep 20 '22 20:09 jprouty

Looking over the last ~30hrs of HA entity availability (which I can confirm correlates to my 403 quota issues), it appears my API quota reset promptly at 5PM PST (which is coincidentally midnight UTC). I am guessing we are dealing with a [new??] daily quota. Based on how long my requests were completing successfully (~10 hrs), I am also going to make a guess that a default, 1-car, minimal MyBMW app usage cases that quota to be exceeded by about 3x the allowable rate. As such, I have attempted to reduce my scan interval by 3x to 900s (or once every 15m). I added some notes as to what I did over here. If the above is correctly, it sounds like we will have to wait another 3 hours to test this theory (when the daily quota likely resets).

I can't see my vehicle in myBMW app after logout/login. So it's pretty massive bug of bmw's systems rather than "new quota" feature...

macieksonik avatar Sep 20 '22 21:09 macieksonik

Same Problem here. Worked fine till yesterday. MyBMW app also doesnt Update location/status.

grbatrain avatar Sep 20 '22 22:09 grbatrain

The car is back in "My BMW" app since tonight. Data is up to date again in Home assistant also. I had a test version of HA with the BMW connected integration activated, but I have disabled it since yesterday to lower the amount of data requests.

olivierdj avatar Sep 21 '22 02:09 olivierdj

Right. It does seem that it's a daily rate limit quota which reset about 2.5 hrs ago. Reports on this issue seem to corroborate this theory of a UTC midnight reset.

jprouty avatar Sep 21 '22 02:09 jprouty

Same here, so it seems that the polling needs to be limited?

kimbo1st avatar Sep 21 '22 08:09 kimbo1st

Thanks for the debugging guys! I'll implement a higher polling interval (probably 30 minutes to be safe) later today and make it configurable via the integration options.

rikroe avatar Sep 21 '22 08:09 rikroe

Today I woke up with everything available on my HA, and 2 hours later it's already unavailable :(

max-men-cat avatar Sep 21 '22 08:09 max-men-cat

Same here. 6 hours ago I mentioned that all was working again. Now HA has 403 error again. Csr is still available in the BMW app, but last update was 2 hours ago.

olivierdj avatar Sep 21 '22 08:09 olivierdj

It worked for three hours for me today, so that must be 36 requests. If we need to spread those out onto an entire day, I guess we need at least 40 minutes in between the requests. If the app requests count against the same limit as well, we will probably need even more time in between the request - otherwise could we risk not being able to use the app??? Just guessing here :-)

jrhansen avatar Sep 21 '22 09:09 jrhansen

Thanks for the debugging guys! I'll implement a higher polling interval (probably 30 minutes to be safe) later today and make it configurable via the integration options.

This is a good approach. Eventually we'll be able to determinate the quota (calls / day).

sfortis avatar Sep 21 '22 09:09 sfortis

It worked for three hours for me today, so that must be 36 requests. If we need to spread those out onto an entire day, I guess we need at least 40 minutes in between the requests. If the app requests count against the same limit as well, we will probably need even more time in between the request - otherwise could we risk not being able to use the app??? Just guessing here :-)

It seems that there is no relation between the app and the quota. For example, yesterday i was getting the quote exceeded message in HA, but the app was fine (i've tried also to send a flash lights command and was executed successfully). How they discriminate the traffic between the app and other requests is still unknown. I'll capture the traffic with wireshark and see if they're using any extra headers or something.

sfortis avatar Sep 21 '22 09:09 sfortis

Same here with a very clear pattern:

It starts working at midnight, becomes intermittent at dawn and completely becomes unavailable a few hours later.

SoC in the MyBMW app main screen ceases to work too. In the details, SoC is still available.

Already contacted BMW complaining about the app not working correctly, maybe they will raise the quotas if we all complain.

RuiSSousa avatar Sep 21 '22 09:09 RuiSSousa

Another idea that just came to my mind: At each refresh, we are currently calling at least 3 endpoints: 2 for basic vehicle information (one for BMW, one for MINI, e.g. here) and the actual vehicle state which is what is most interesting to us. The MyBMW also always calls both endpoints.

Maybe we can skip reloading the vehicles endpoint at every polling cycle and just call it at first execution, reducing the number of calls by two thirds.

rikroe avatar Sep 21 '22 10:09 rikroe