ReneNulschDE / mbapi2020

Custom Component to integrate MercedesME devices into Home-Assistant
Other
149 stars 29 forks source link

Getting PIN email, but it doesn't work #192

Closed mflagler closed 7 months ago

mflagler commented 7 months ago

Seeing unknown error occurred, but also getting these errors in the logs (guessing the first one is the one that triggers the prompt to reconfigure after updating to the latest version that was just pushed): Home Assistant v2024.1.6 Integration v0.10.0

Logger: homeassistant.config_entries
Source: config_entries.py:430
First occurred: 8:21:21 PM (1 occurrences)
Last logged: 8:21:21 PM

Config entry 'GLE350' for mbapi2020 integration could not authenticate: 400, message='Bad Request', url=URL('https://id.mercedes-benz.com/as/token.oauth2')
This error originated from a custom integration.

Logger: custom_components.mbapi2020.oauth
Source: custom_components/mbapi2020/oauth.py:274
Integration: MercedesME 2020 (documentation, issues)
First occurred: 8:21:21 PM (2 occurrences)
Last logged: 8:25:12 PM

ClientError requesting data from https://id.mercedes-benz.com/as/token.oauth2: 400, message='Bad Request', url=URL('https://id.mercedes-benz.com/as/token.oauth2')
ReneNulschDE commented 7 months ago

Does this happen when you add the integration or in the normal operation?. Could you share your region? Is this the first/only mb account or do you use multiple accounts?

Could you please share the system details too? (Can be found in: Settings ⇒ System ⇒ Repairs ⇒ Three Dots in Upper Right ⇒ System information)

thx

Pieter-HA commented 7 months ago

Same here (Netherlands): ClientError requesting data from https://id.mercedes-benz.com/as/token.oauth2: 400, message='Bad Request', url=URL('https://id.mercedes-benz.com/as/token.oauth2')

It was all working fine (0.9.9) until yesterday. Updated to the beta version. After that, the PIN code email came through. Only one account.

Whatsek commented 7 months ago

Same problem, after upgrading to Integration v0.10.0, deleting the token and reconfiguring the plugin with email adres and the received code, my car is detected but all entities are unknown. (Code is accepted and the plugin loads fine)

This is in my system info:

MercedesME 2020 MB API reachable ok MB WS state unknown Connected cars 0 Version v0.10.0

Region is Europe, one account, worked fine for a long time.

ReneNulschDE commented 7 months ago

I can reproduce it. Working on a fix.

ReneNulschDE commented 7 months ago

Question to all of you: Do you have deleted the integration before upgrading the MBAPI2020 version or did you an direct update and restart? (looks like option one has a bug in the flow, or better I always tested option two)

Could you please check the following workaround:

  1. Delete the token file in your "HA config dir"/.storage/.mercedesme-token-cache-....
  2. Restart HA
  3. Add the integration again
Pieter-HA commented 7 months ago

I did a direct update and restart of HA because the PIN didn't come through email. Upgrade to 0.10.0 made the PIN come through in email, but raised an error on entry in teh add-on. Same for the beta version. Deleted the token cache after every update / restart.

Don't understand your point 3. Why add the integration again if it wasn't deleted but just updated.

ReneNulschDE commented 7 months ago

@Pieter-HA: My work around assumed you have deleted it from HA (not from your disk)...

To have a clean state, I would propose that you

  1. delete the integration from HA (not from HACS).
  2. delete the ".mercedesme-token-cache"-file in /config if present, delete the ".mercedesme-token-cache-..."-files in /config/.storage if present
  3. restart HA
  4. Add the integration again.
Pieter-HA commented 7 months ago

@ReneNulschDE: I deleted the integration, deleted the mbapi2020 directory in custom_components and restarted HA. Re-installed the integration from HACS (v.0.10.0), restarted HA (v.2024.2.0). Added the integration and SUCCESS! Thanks for your help.

mflagler commented 7 months ago

Following the steps also fixed it for me on HA v2024.1.6

ReneNulschDE commented 7 months ago

Solved with v0.10.1