core icon indicating copy to clipboard operation
core copied to clipboard

bmw_connected_drive - 403 Quota Exceeded

Open smeee-again opened this issue 2 years ago • 19 comments

The problem

It appears 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. I did recently get a new BMW but the previous one has been removed. The new vehicle has a lot more information being returned.

What version of Home Assistant Core has the issue?

2022.12.1

What was the last working version of Home Assistant Core?

No response

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

2023-01-15 13:35:17.319 WARNING (MainThread) [homeassistant.config_entries] Config entry 'redacted' for bmw_connected_drive integration not ready yet: Error communicating with BMW API: Client error '403 Quota Exceeded' for url 'https://cocoapi.bmwgroup.us/eadrax-vcs/v4/vehicles' For more information check: https://httpstatuses.com/403; Retrying in background

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

smeee-again avatar Jan 15 '23 19:01 smeee-again

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!

Code owner commands

Code owners of bmw_connected_drive can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Change the title of the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign bmw_connected_drive Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


bmw_connected_drive documentation bmw_connected_drive source (message by IssueLinks)

home-assistant[bot] avatar Jan 15 '23 19:01 home-assistant[bot]

Hi there: I got this today as well. Using HassOS in a proxmox VM. This actually happened on the restart immediately after upgrading to 2023.1.5. Only have one car (2022 330e) on the integration, for about the last two months. Never noticed any problem before.

2023-01-17 13:18:58.918 WARNING (MainThread) [homeassistant.config_entries] Config entry '[email protected]' for bmw_connected_drive integration not ready yet: Error communicating with BMW API: Client error '403 Quota Exceeded' for url 'https://cocoapi.bmwgroup.us/eadrax-vcs/v4/vehicles' For more information check: https://httpstatuses.com/403; Retrying in background

lmk if I can do anything to help diagnose it.

mikestarkenburg avatar Jan 17 '23 22:01 mikestarkenburg

Just leaving this here for anyone else who recently got hit with this: it's been an ongoing thing being investigated upstream. A couple of fixes have been tried, (most recent 2 weeks ago in 2023.1.1) but I guess didn't totally nail it.

A totally reasonable workaround was presented here and later in the thread there are a bunch of examples. I'll try them tomorrow when the BMW banhammer times out! :)

mikestarkenburg avatar Jan 18 '23 00:01 mikestarkenburg

With getting a new vehicle, I was using the My BMW app more than usual. When the limitation was hit, the vehicle was not updating the in My BMW app either.

So maybe 5 minutes is fine if the stars align

This idea would be a change to Home Assistant. Currently the HA App can report the BT Connection attributes; which would list the BT devices connected to the phone. Unfortunately, using the attributes is not straightforward. If it were, then using it to control how often to poll BMW could be used.

Example: If the phone is connected, then poll every five minutes. If the phone is not connected, then poll every 15 minutes.

If there is a counter on the BMW, they aren't saying. Most of the time, the vehicle is not moving; either at work or at home. If it sits in a garage at home, then even polling every 15 minutes would be excessive.

smeee-again avatar Jan 18 '23 01:01 smeee-again

Did you guys in north america have issues with quota exceeded before 2023.1.1? #86063 rather sounds like BMW has not implemented the new API endpoints for the US yet, so I'm rather wondering that you were able to get any data at all.

rikroe avatar Jan 18 '23 07:01 rikroe

Ok, double checked against the latest MyBMW app for north_america. You do seem to use the same endpoints as in rest_of_world.

So probably you'll need to adjust the polling interval manually (as mentioned in #83128) and report back. I could increase the polling interval to 10 or 20 minutes, giving you more room to work with. At least for rest_of_world, we observed the quota resetting at 0:00 UTC.

rikroe avatar Jan 18 '23 17:01 rikroe

Les funciona BMW connected? llevo meses que me ha dejado de funcionar

manuelcarvajal avatar Jan 25 '23 09:01 manuelcarvajal

I wanted to come back here and close the loop and add whatever little value I can add.

  1. For sure we're using the same endpoints in North America as the rest of the world.

  2. Before any adjustments. I was hitting quota at about 1PM Pacific time (-8) and getting connected again at 4PM, which means our quota gets reset at 0:00 UTC.

  3. I used a modified version of the workaround from @RuiSSousa. -- 5 min updates when charging -- 20 min updates when not charging -- reload after unavailable for 15 mins -- the only change I made was to suspend updates entirely from 2am - 6am. I think this was probably unnecessary, but I was having fun optimizing this thing and did it anyway.

  4. Once I did that, the 3 hour afternoon gap went completely away. I have wierdly intermittent dropouts one or twice a day, but my reload automation catches them so they are never longer than 15 mins. Since my non-charging interval is 20 minutes, I rarely notice this issue.

I'd love to get it quicker, but I can probably poll a refresh for almost every use case I can think of ...

@rikroe , (which I always read in my head as rickroll :) ) I don't think a standard switch to 10 or 20 minutes is necessary, but perhaps we put something in the integration docs about this with some sample code? I will happily do the writing and contribute my code, who do I need to ask?? Or is it just a pull request?

mikestarkenburg avatar Mar 14 '23 23:03 mikestarkenburg

Well, if it is in your head @mikestarkenburg: click me

On a more general note: For rest_of_world, I am able to get data from BMW servers every 5 since the changes in https://github.com/home-assistant/core/pull/85255 (2023.1.1). Does limiting still apply for north_america?

rikroe avatar Mar 18 '23 17:03 rikroe

@rikroe Just hit the limit in NA today

A69Tor avatar Apr 06 '23 23:04 A69Tor

@rikroe, I am in North America, and got limited today

Just leaving this here for anyone else who recently got hit with this: it's been an ongoing thing being investigated upstream. A couple of fixes have been tried, (most recent 2 weeks ago in 2023.1.1) but I guess didn't totally nail it.

A totally reasonable workaround was presented here and later in the thread there are a bunch of examples. I'll try them tomorrow when the BMW banhammer times out! :)

One of the fixes I noted in those threads was this: https://github.com/evcc-io/evcc/issues/3525

They chagned the useragent with a new App Version which claims to resolve the query limit...
Prev: xUserAgent: fmt.Sprintf("android(v1.07_20200330);%s;1.7.0(11152)", brand), Curr: xUserAgent: fmt.Sprintf("android(SP1A.210812.016.C1);%s;2.5.2(14945)", brand)

I am taking it with a grain of salt- can anyone test?

aabeijon avatar Apr 14 '23 19:04 aabeijon

That's a very old version string. But we're upgrading to a later version soon (https://github.com/bimmerconnected/bimmer_connected/pull/525).

rikroe avatar Apr 15 '23 06:04 rikroe

Failed to set up: Client error '403 Quota Exceeded' for url 'https://cocoapi.bmwgroup.us/eadrax-vcs/v4/vehicles/state' For more information check: https://httpstatuses.com/40

same problem

TimeLimitXceeded avatar Apr 24 '23 22:04 TimeLimitXceeded

Failed to set up: Client error '403 Quota Exceeded' for url 'https://cocoapi.bmwgroup.us/eadrax-vcs/v4/vehicles/state' For more information check: https://httpstatuses.com/40

same problem

Also seeing this after moving migrating HA server and restoring from a backup.

gumbald avatar Apr 27 '23 08:04 gumbald

With https://github.com/home-assistant/core/pull/91081 merged (will be released in 2023.5), the user agent is updated to the current MyBMW app. Please let me know this changes something. Otherwise, please test higher polling intervals and let me know if 10, 15 or 20 minutes work reliably for you.

rikroe avatar Apr 30 '23 06:04 rikroe

Me ha dejado de funcionar connected Drive en Home Assistant, alguien mas tiene el mismo problema? bmw420s

manuelcarvajal avatar Apr 30 '23 07:04 manuelcarvajal

Please ask in English and create a new issue as this is a different error message. Please check if you have any special characters in your password. BMW changes some characters of your password before sending them to the server (i.e. ` to ')

rikroe avatar Apr 30 '23 08:04 rikroe

With #91081 merged (will be released in 2023.5), the user agent is updated to the current MyBMW app. Please let me know this changes something. Otherwise, please test higher polling intervals and let me know if 10, 15 or 20 minutes work reliably for you.

Is that merge now available in 0b5?

collinscochran avatar May 01 '23 03:05 collinscochran

Yep, should be included since 0b3.

rikroe avatar May 01 '23 21:05 rikroe

Please let me know if you still get 403 Quota Exceeded on HA >= 2023.5.0. If yes, we need to increase the default polling interval.

rikroe avatar May 06 '23 08:05 rikroe

Please let me know if you still get 403 Quota Exceeded on HA >= 2023.5.0. If yes, we need to increase the default polling interval.

I'm still seeing that, so may want to go up from where it currently is. Once I have it going for a few more days I can get a better idea of when it gets rate limited.

collinscochran avatar May 06 '23 09:05 collinscochran

I am on 2023.5.3 and I am still getting this error.

silfa718 avatar May 22 '23 21:05 silfa718

I am on 2023.5.3 and I am still getting this error.

I fixed it in the end by changing my BMW account password and re-adding to HA.

gumbald avatar May 23 '23 05:05 gumbald

Just saw it happen again in 2023.6.1 -- ban-hammered for 1 hour 15 minutes and HA (incorrectly) thinks the config is screwed up. And North America, BTW. :(

robthebold avatar Jun 14 '23 23:06 robthebold

Same here it was great up until that update

Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: robthebold @.> Sent: Wednesday, June 14, 2023 7:19:33 PM To: home-assistant/core @.> Cc: TimeLimitXceeded @.>; Comment @.> Subject: Re: [home-assistant/core] bmw_connected_drive - 403 Quota Exceeded (Issue #85962)

Just saw it happen again in 2023.6.1 -- ban-hammered for 1 hour 15 minutes and HA (incorrectly) thinks the config is screwed up. And North America, BTW. :(

— Reply to this email directly, view it on GitHubhttps://github.com/home-assistant/core/issues/85962#issuecomment-1592115875, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A4ACNPBVXIOWPNMG3CWSMN3XLJBILANCNFSM6AAAAAAT4BEL2M. You are receiving this because you commented.Message ID: @.***>

TimeLimitXceeded avatar Jun 14 '23 23:06 TimeLimitXceeded

On more thorough examination, I looked back thru the logs and it seems like it had also happened on the 9th and 12th of June at 17:15 and 16:26 respectively local time. (UTC -5)

robthebold avatar Jun 15 '23 00:06 robthebold

If HA thinks the config is screwed, does it recover it you enter your old password after 0:00 UTC?

rikroe avatar Jun 15 '23 05:06 rikroe

If HA thinks the config is screwed, does it recover it you enter your old password after 0:00 UTC?

I'd tried once before re-entering the credentials at midnight UTC, and that seemed to work, but it also just got better on another day at 0:00 when I did nothing, so I don't think re-configuring is necessary, just waiting it out.

robthebold avatar Jun 15 '23 12:06 robthebold

I wanted to come back here and close the loop and add whatever little value I can add.

  1. For sure we're using the same endpoints in North America as the rest of the world.
  2. Before any adjustments. I was hitting quota at about 1PM Pacific time (-8) and getting connected again at 4PM, which means our quota gets reset at 0:00 UTC.
  3. I used a modified version of the workaround from @RuiSSousa. -- 5 min updates when charging -- 20 min updates when not charging -- reload after unavailable for 15 mins -- the only change I made was to suspend updates entirely from 2am - 6am. I think this was probably unnecessary, but I was having fun optimizing this thing and did it anyway.
  4. Once I did that, the 3 hour afternoon gap went completely away. I have wierdly intermittent dropouts one or twice a day, but my reload automation catches them so they are never longer than 15 mins. Since my non-charging interval is 20 minutes, I rarely notice this issue.

I'd love to get it quicker, but I can probably poll a refresh for almost every use case I can think of ...

@rikroe , (which I always read in my head as rickroll :) ) I don't think a standard switch to 10 or 20 minutes is necessary, but perhaps we put something in the integration docs about this with some sample code? I will happily do the writing and contribute my code, who do I need to ask?? Or is it just a pull request?

How do you disable automatic polling? I tried to find system options on the … menu if the integration but not there. Any help appreciated.

erpeters3 avatar Jun 27 '23 14:06 erpeters3

I am in North America.

Instead of giving me the quota error on the Devices and Services page, I get promoted to reconfigure by entering my credentials. They are already saved. This occurs daily.

Looking at the logs I get:

2023-06-29 17:34:58.816 ERROR (MainThread) [bimmer_connected.api.client] MyBMWAuthError due to HTTPStatusError: { "statusCode": 403, "message": "Out of call volume quota. Quota will be replenished in 02:25:02." }
2023-06-29 17:34:58.843 ERROR (MainThread) [homeassistant.components.bmw_connected_drive.coordinator] Authentication failed while fetching bmw_connected_drive-[email] data: HTTPStatusError: { "statusCode": 403, "message": "Out of call volume quota. Quota will be replenished in 02:25:02." }
2023-06-29 17:47:40.087 WARNING (MainThread) [homeassistant.config_entries] Config entry '[email protected]' for bmw_connected_drive integration could not authenticate: HTTPStatusError: { "statusCode": 403, "message": "Out of call volume quota. Quota will be replenished in 02:12:20." }

I would also like to change poll frequency by doing the hack above, or at least have this recover automatically once quota is replenished

aabeijon avatar Jun 29 '23 21:06 aabeijon