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
70.46k stars 29.39k forks source link

2024.7.0b10 breaks Tradfri Integration #121082

Closed pedolsky closed 2 weeks ago

pedolsky commented 1 month ago

The problem

The Tradfri Integration fails to initialize so all devices became unavailable. Restart of Home Assistant and host reboot didn't help.

In the 2024.7 beta versions before I had countless aiocaop warnings and had to reload the integration.

What version of Home Assistant Core has the issue?

core-2024.7.0b10

What was the last working version of Home Assistant Core?

core-2024.6.3

What type of installation are you running?

Home Assistant Supervised

Integration causing the issue

Tradfri

Link to integration documentation on our website

https://www.home-assistant.io/integrations/tradfri/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Error setting up entry 192.168.178.47 for tradfri

2024-07-03 16:48:17.863 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry 192.168.178.47 for tradfri
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/asyncio/tasks.py", line 520, in wait_for
    return await fut
           ^^^^^^^^^
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/pytradfri/api/aiocoap_api.py", line 107, in _get_response
    pr_resp = await asyncio.wait_for(pr_req.response, timeout)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/tasks.py", line 519, in wait_for
    async with timeouts.timeout(timeout):
  File "/usr/local/lib/python3.12/asyncio/timeouts.py", line 115, in __aexit__
    raise TimeoutError from exc_val
TimeoutError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 586, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/tradfri/__init__.py", line 82, in async_setup_entry
    devices: list[Device] = await api(devices_commands, timeout=TIMEOUT_API)
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pytradfri/api/aiocoap_api.py", line 204, in request
    command_results = await asyncio.gather(*commands)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pytradfri/api/aiocoap_api.py", line 167, in _execute
    _, res = await self._get_response(msg, timeout)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pytradfri/api/aiocoap_api.py", line 116, in _get_response
    await self._reset_protocol(exc)
  File "/usr/local/lib/python3.12/site-packages/pytradfri/api/aiocoap_api.py", line 87, in _reset_protocol
    await protocol.shutdown()
  File "/usr/local/lib/python3.12/site-packages/aiocoap/protocol.py", line 438, in shutdown
    await item
  File "/usr/local/lib/python3.12/site-packages/aiocoap/tokenmanager.py", line 62, in shutdown
    request.add_exception(error.LibraryShutdown())
  File "/usr/local/lib/python3.12/site-packages/aiocoap/pipe.py", line 195, in add_exception
    self._add_event(self.Event(None, exception, True))
  File "/usr/local/lib/python3.12/site-packages/aiocoap/pipe.py", line 180, in _add_event
    keep_calling = cb(event)
                   ^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiocoap/protocol.py", line 577, in process
    self._runner.send(event)
  File "/usr/local/lib/python3.12/site-packages/aiocoap/protocol.py", line 620, in _run
    self.response.set_exception(first_event.exception)
asyncio.exceptions.InvalidStateError: invalid state

Additional information

I'm using the old IKEA hub.

home-assistant[bot] commented 1 month ago

tradfri documentation tradfri source

dwd1 commented 1 month ago

Edit: fixed

https://github.com/home-assistant/core/issues/120036#issuecomment-2209475200

I'm on 2024.6.4 and I get

Logger: homeassistant.components.sensor Source: helpers/entity_platform.py:366 integration: Sensor (documentation, issues) First occurred: 20:55:54 (1 occurrences) Last logged: 20:55:54 Error while setting up tradfri platform for sensor

Traceback (most recent call last):

  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 366, in _async_setup_platform
    await asyncio.shield(awaitable)
  File "/usr/src/homeassistant/homeassistant/components/tradfri/sensor.py", line 162, in async_setup_entry
    TradfriSensor(
  File "/usr/src/homeassistant/homeassistant/components/tradfri/sensor.py", line 186, in __init__
    super().__init__(
  File "/usr/src/homeassistant/homeassistant/components/tradfri/base_class.py", line 65, in __init__
    sw_version=info.firmware_version,
               ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pytradfri/device/__init__.py", line 177, in firmware_version
    return self.raw[ATTR_DEVICE_FIRMWARE_VERSION]
           ~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyError: '3'

Logger: homeassistant.components.light Source: helpers/entity_platform.py:374 integration: Light (documentation, issues) First occurred: 20:55:54 (1 occurrences) Last logged: 20:55:54 Error while setting up tradfri platform for light

Traceback (most recent call last):

  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 374, in _async_setup_platform
    await asyncio.gather(*pending)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 633, in async_add_entities
    for entity in new_entities:
  File "/usr/src/homeassistant/homeassistant/components/tradfri/light.py", line 41, in <genexpr>
    TradfriLight(
  File "/usr/src/homeassistant/homeassistant/components/tradfri/light.py", line 65, in __init__
    super().__init__(
  File "/usr/src/homeassistant/homeassistant/components/tradfri/base_class.py", line 65, in __init__
    sw_version=info.firmware_version,
               ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pytradfri/device/__init__.py", line 177, in firmware_version
    return self.raw[ATTR_DEVICE_FIRMWARE_VERSION]
           ~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyError: '3'

Logger: homeassistant.components.cover Source: helpers/entity_platform.py:374 integration: Cover (documentation, issues) First occurred: 20:55:54 (1 occurrences) Last logged: 20:55:54 Error while setting up tradfri platform for cover

Traceback (most recent call last):

  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 374, in _async_setup_platform
    await asyncio.gather(*pending)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 633, in async_add_entities
    for entity in new_entities:
  File "/usr/src/homeassistant/homeassistant/components/tradfri/cover.py", line 31, in <genexpr>
    TradfriCover(
  File "/usr/src/homeassistant/homeassistant/components/tradfri/cover.py", line 53, in __init__
    super().__init__(
  File "/usr/src/homeassistant/homeassistant/components/tradfri/base_class.py", line 65, in __init__
    sw_version=info.firmware_version,
               ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pytradfri/device/__init__.py", line 177, in firmware_version
    return self.raw[ATTR_DEVICE_FIRMWARE_VERSION]
           ~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyError: '3'
Bassadin commented 1 month ago

This also seems to happen to me on 2024.7.1

maartenv23717 commented 1 month ago

can confirm 2024.7.0 and 2024.7.1 also affected

All my lights: "This entity is no longer being provided by the tradfri integration. If the entity is no longer in use, delete it in settings."

rolfvanleeningen commented 1 month ago

And I also confirm on 2024.7.2. I also get the message: "This entity is no longer being provided by the tradfri integration. If the entity is no longer in use, delete it in settings."

pedolsky commented 2 weeks ago

Solved with v2024.7.3 - thanks!