home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.61k stars 30.37k forks source link

bmw_connected_drive - 403 Quota Exceeded #85962

Closed smeee-again closed 1 year ago

smeee-again commented 1 year ago

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

home-assistant[bot] commented 1 year ago

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)

mikestarkenburg commented 1 year ago

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@redacted.com' 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 commented 1 year ago

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! :)

smeee-again commented 1 year ago

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.

rikroe commented 1 year ago

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 commented 1 year ago

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.

manuelcarvajal commented 1 year ago

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

mikestarkenburg commented 1 year ago

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?

rikroe commented 1 year ago

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?

A69Tor commented 1 year ago

@rikroe Just hit the limit in NA today

aabeijon commented 1 year ago

@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?

rikroe commented 1 year ago

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

TimeLimitXceeded commented 1 year ago

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

gumbald commented 1 year ago

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.

rikroe commented 1 year ago

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.

manuelcarvajal commented 1 year ago

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

rikroe commented 1 year ago

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 ')

collinscochran commented 1 year ago

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?

rikroe commented 1 year ago

Yep, should be included since 0b3.

rikroe commented 1 year ago

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.

collinscochran commented 1 year ago

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.

silfa718 commented 1 year ago

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

gumbald commented 1 year ago

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.

robthebold commented 1 year ago

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. :(

TimeLimitXceeded commented 1 year ago

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: @.***>

robthebold commented 1 year ago

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)

rikroe commented 1 year ago

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

robthebold commented 1 year ago

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.

erpeters3 commented 1 year ago

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.

aabeijon commented 1 year ago

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 'abeijon@live.com' 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

54Comet commented 1 year ago

I am also in North America and seeing similar issue to aabeijon. I am prompted to reconfigure the bmw integration by entering my credentials approximately once a day.

Looking at debug logging, the integration looks like 20 entities are being updated every 5 minutes on a 2017 330e.

Error log entry:

cat home-assistant.log | grep '\(ERR\|WARN\).*bmw'
2023-06-29 14:06:53.609 ERROR (MainThread) [homeassistant.components.bmw_connected_drive.coordinator] Authentication failed while fetching bmw_connected_drive-[xyz]@[xyz].com data: HTTPStatusError: { "statusCode": 403, "message": "Out of call volume quota. Quota will be replenished in 04:53:07." }
Home Assistant 2023.6.3
Supervisor 2023.06.4
Operating System 10.3
Frontend 20230608.0 - latest
rikroe commented 1 year ago

Grml. The Quota error doesn't apply right now because BMW changed the status response. Will update the library and then HA. Will also update the default polling interval for north america, as it seems to happen mostly there.

rikroe commented 1 year ago

Did the changes added to 2023.7 help? If yes, I'll close this issue soon.

robthebold commented 1 year ago

Did the changes added to 2023.7 help? If yes, I'll close this issue soon.

I haven't seen the problem for a while now. Looking back thru the last week's data, I don't see gaps, either.

rikroe commented 1 year ago

Closing this as increasing the polling time for NA to 10 minutes seems to do the trick for now.

rikroe commented 1 year ago

@home-assistant close