zigpy / zha

Zigbee Home Automation
Apache License 2.0
26 stars 23 forks source link

Adding an IKEA STYRBAR (and some other) device fails with a KeyError #249

Open lopezio opened 4 weeks ago

lopezio commented 4 weeks ago

Hi,

I have an IKEA STYRBAR that used to work well (paired last year with HA 2023.12.x), which I wanted to re-configure. Now running HA 2024.10.3, it fails all the time in the "Interview Complete - Configuring" Phase. I had another small remote (RODRIK), which initially had the same errors, but after a restart of HA/ZHA was finally paired. The STYRBAR Remote does not finish pairing, instead it produces a log entry that I am adding here. Can't figure whether it's a problem with the device or possibly a bug in ZHA.

Apparently, it's IEEE is not in _device_init_tasks it seems. Maybe someone has an idea. Adding two relevant log entries from 2 different (failed) attempts to pair it.

Update: So far, it looks like it is a problem with the device. But it used to work until recently, so maybe having a look at why that IEEE is missing from the "init tasks" may lead to other bug findings or even to a solution for that device.

Logger: homeassistant
Source: /usr/src/homeassistant/homeassistant/runner.py:147
First occurred: 2:14:41 AM (1 occurrences)
Last logged: 2:14:41 AM

Error doing job: Exception in callback Gateway.device_initialized..() at /usr/local/lib/python3.12/site-packages/zha/application/gateway.py:454 (None)
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/local/lib/python3.12/site-packages/zha/application/gateway.py", line 454, in 
    init_task.add_done_callback(lambda _: self._device_init_tasks.pop(device.ieee))
                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyError: 28:76:81:ff:fe:23:4c:c5

Logger: homeassistant
Source: /usr/src/homeassistant/homeassistant/runner.py:147
First occurred: 3:06:27 PM (1 occurrences)
Last logged: 3:06:27 PM

Error doing job: Exception in callback Gateway.device_initialized..() at /usr/local/lib/python3.12/site-packages/zha/application/gateway.py:454 (None)
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/local/lib/python3.12/site-packages/zha/application/gateway.py", line 454, in 
    init_task.add_done_callback(lambda _: self._device_init_tasks.pop(device.ieee))
                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyError: 28:76:81:ff:fe:23:4c:c5

lopezio commented 4 weeks ago

Update: It looks like I have this problem with all STYRBARs that I re-pair or pair anew. Same error in the logs. Any hints? The difference between the two installations (and the time before, where the existing STYRBARs were added) is the Coordinator stick. I switched from a SkyConnect (Nabu Casa) Firmware: 7.3.1.0 build 176, using Migrate Network function, to a Slae.sh TI CC2652, Firmware: Z-Stack 20240710. So it looks like it might be related either to the new coordinator, or to the migration. Any hints on how to further debug this and/or forward it to the appropriate forum/repo? Other devices seem to pair and work fine. Best Regards, Lorenzo