FL550 / dwd_weather

Deutscher Wetterdienst integration for Home-Assistant
MIT License
194 stars 12 forks source link

v2.1.4 on HA 2023.9: Error setting up entry <City> for dwd_weather #135

Closed bcutter closed 3 months ago

bcutter commented 3 months ago

Version of home_assistant

2023.9.3

Version of the custom_component

2024.6.0

Describe the bug

After updating HA to 2023.9.3 I was able to upgrade DWD from 1.2.28 to latest verstion (2.1.4) using HACS. After the update and restarting HA, the integration can not be configured and an error is logged (HA log).

As my HA version matches the minium required version listed in https://github.com/FL550/dwd_weather/blob/master/hacs.json (currently 2023.9.1) I don't get what this error is about.

Debug log


Dieser Fehler wurde von einer benutzerdefinierten Integration verursacht

Logger: homeassistant.config_entries
Source: custom_components/dwd_weather/__init__.py:55
Integration: Deutscher Wetterdienst (documentation, issues)
First occurred: 21:35:52 (1 occurrences)
Last logged: 21:35:52

Error setting up entry <City> for dwd_weather
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 387, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/dwd_weather/__init__.py", line 55, in async_setup_entry
    if entry.data[CONF_ENTITY_TYPE] == CONF_ENTITY_TYPE_STATION:
       ~~~~~~~~~~^^^^^^^^^^^^^^^^^^
KeyError: 'entity_type'

When trying to configure the integration from the UI I get: grafik

This logs:

Dieser Fehler wurde von einer benutzerdefinierten Integration verursacht

Logger: aiohttp.server
Source: custom_components/dwd_weather/config_flow.py:410
Integration: Deutscher Wetterdienst (documentation, issues)
First occurred: 21:48:27 (4 occurrences)
Last logged: 21:49:00

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 85, 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 236, 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 148, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/decorators.py", line 63, in with_admin
    return await func(self, request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 213, in post
    return await super().post(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  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 71, in post
    result = await self._flow_mgr.async_init(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 270, in async_init
    result = await self._async_handle_step(flow, flow.init_step, data)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 394, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/dwd_weather/config_flow.py", line 410, in async_step_init
    if self.config_entry.data[CONF_ENTITY_TYPE] == CONF_ENTITY_TYPE_STATION:
       ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
KeyError: 'entity_type'

So obviously something's broken here. Please advise. For now I need to downgrade to the safe harbour 1.2.28 again :-(

bcutter commented 3 months ago

Update: tried to remove the former integration (successful) and added a new one with the same city. Took quite a while.

Finally, it seems everything is working again.

I think at https://github.com/FL550/dwd_weather/releases/tag/v2.0.1 this

You have to change existing configurations to the new entity.

Should have been "You need to delete the old integration and add it from scratch, passing the same name to the integration and the same entity_id's to all entities to remain history".

And

All sensors should remain working, as I was able to migrate them successfully.

no in my case it seems they did not.

I'll have a closer look at it now.