ReneNulschDE / mbapi2020

Custom Component to integrate MercedesME devices into Home-Assistant
Other
168 stars 32 forks source link

Re-authentication failing #200

Closed mattcd216 closed 8 months ago

mattcd216 commented 8 months ago

The problem

After upgrading to homeassistant core 2024.2.1 I was advised re-authentication was required for this integration. When putting in the code I received by email I get 'unknown error occured'. This is repeatable.

What version of MBAPI2020 do use?

0.10.0

What was the last working version of MBAPI2020?

0.10.0

What type of installation are you running?

Home Assistant OS

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Logger: aiohttp.server
Source: /usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py:421
First occurred: 08:13:49 (1 occurrences)
Last logged: 08:13:49

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 452, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_app.py", line 543, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_middlewares.py", line 114, in impl
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 91, in security_filter_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 80, in ban_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 235, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 31, in headers_middleware
    response = await handler(request)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 149, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/decorators.py", line 72, in with_admin
    return await func(self, request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 185, in post
    return await super().post(request, flow_id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 72, in wrapper
    result = await method(view, request, data, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 110, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 358, in async_configure
    result = await self._async_configure(flow_id, user_input)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 404, in _async_configure
    result = await self._async_handle_step(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 501, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/mbapi2020/config_flow.py", line 114, in async_step_pin
    self.hass.config_entries.async_update_entry(self._existing_entry, data=self.data)
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1535, in async_update_entry
    if data is not UNDEFINED and entry.data != data:
                                 ^^^^^^^^^^
AttributeError: 'dict' object has no attribute 'data'

Additional information

No response

ReneNulschDE commented 8 months ago

This should be fixed with v0.10.1, please update to this version of the component and report back.

mattcd216 commented 8 months ago

Thanks. Getting 'failed to set up' integration now. Tried reload and restart.

This error originated from a custom integration.

Logger: homeassistant
Source: custom_components/mbapi2020/config_flow.py:128
Integration: MercedesME 2020 (documentation, issues)
First occurred: 10:10:10 (5 occurrences)
Last logged: 11:57:36

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 947, in async_init
    flow, result = await task
                   ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 975, in _async_init
    result = await self._async_handle_step(flow, flow.init_step, data)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 501, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/mbapi2020/config_flow.py", line 128, in async_step_reauth
    self._reauth_entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
                                                                  ~~~~~~~~~~~~^^^^^^^^^^^^
KeyError: 'entry_id'
mattcd216 commented 8 months ago

Also seeing authentication error in the logs. Is there a way to re-authenticate without removing and re-adding the integration, do you know? Thanks for the support

ReneNulschDE commented 8 months ago

Sorry Matt, did not saw your question. As already answered in the forum:

To have a clean state, I would propose that you

  1. delete the integration from HA (Deletion from HACS is not needed).
  2. delete the ".mercedesme-token-cache"-file in /config if present
  3. delete the ".mercedesme-token-cache-..."-files in /config/.storage if present
  4. restart HA
  5. Add the integration again.

This has no impact on your configuration like automations as the id for the sensors will be the same.

mattcd216 commented 8 months ago

Thanks. All working again. Appreciate the help.