core: ZHA reloads on timeouts

The problem

The recent change ( https://github.com/home-assistant/core/pull/105659 ) added ZHA reload on any error. Unfortunately, this now causes controller reinitialization after timeouts. This in turn can cause ZHA to enter a restart loop. After a couple hundred iterations of restarts, it can also completely confuse Zigbee devices, rendering the whole network inoperable.

What version of Home Assistant Core has the issue?

core-2023.12.2

What was the last working version of Home Assistant Core?

core-2023.12.1

What type of installation are you running?

Home Assistant OS

Integration causing the issue

ZHA

Link to integration documentation on our website

No response

Diagnostics information

2023-12-13 16:35:09.890 ERROR (MainThread) [bellows.uart] Lost serial connection: ConnectionResetError('Remote server closed connection')
2023-12-13 16:35:09.891 ERROR (MainThread) [bellows.ezsp] NCP entered failed state. Requesting APP controller restart
2023-12-13 16:35:10.002 WARNING (MainThread) [homeassistant.helpers.dispatcher] Unable to remove unknown dispatcher <bound method GroupProbe._reprobe_g
roup of <homeassistant.components.zha.core.discovery.GroupProbe object at 0x7ff24107e810>>
2023-12-13 16:35:10.098 ERROR (MainThread) [zigpy.zcl] [0x559E:1:0xff01] Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/zha/core/cluster_handlers/__init__.py", line 518, in write_attributes_safe
    res = await self.write_attributes(attributes, manufacturer=manufacturer)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/zha/core/cluster_handlers/__init__.py", line 84, in wrapper
    return await RETRYABLE_REQUEST_DECORATOR(func)(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/zigpy/util.py", line 138, in retry
    return await func()
           ^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/zigpy/zcl/__init__.py", line 620, in write_attributes
    return await self.write_attributes_raw(attrs, manufacturer)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/zigpy/zcl/__init__.py", line 626, in write_attributes_raw
    result = await self._write_attributes(attrs, manufacturer=manufacturer)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/zigpy/quirks/__init__.py", line 321, in _write_attributes
    return await super()._write_attributes(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/zigpy/zcl/__init__.py", line 377, in request
    return await self._endpoint.request(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/zigpy/endpoint.py", line 253, in request
    return await self.device.request(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/zigpy/device.py", line 299, in request
    await self._application.request(
  File "/usr/local/lib/python3.11/site-packages/zigpy/application.py", line 829, in request
    await self.send_packet(
  File "/usr/local/lib/python3.11/site-packages/bellows/zigbee/application.py", line 762, in send_packet
    status, _ = await self._ezsp.sendUnicast(
                      ^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'sendUnicast'

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

About this issue

  • Original URL
  • State: closed
  • Created 7 months ago
  • Reactions: 2
  • Comments: 42 (15 by maintainers)

Most upvoted comments

same here, upgrading to 2023.12.2 or 2023.12.3, completely messed up my zha

It’s the beta Home Assistant Core version you need to install: https://www.home-assistant.io/common-tasks/os/#run-a-beta-version

Thanks! That makes sense, I was looking for a separate ZHA beta 😅😂 Things are stable after 2024.01 for me 👍

I just installed 2024.1.0b3 and I think things are stable! Been running for 15 mins with no devices going unavailable. Things seem responsive. Thanks @dmulcahey @puddly and everyone else who investigated this.

hey guys… same here… just went to 2023.12.0 to 2023.12.3 and have the same issue: bounce between unavailable to the current state every few minutes, stays unavailable for 15sec or so. All ZigBee devices; using SONOFF_Zigbee_3.0_USB_Dongle_Plus, ZHA, rpi4 edit: rolled back to 2023.12.0 overnight, back to normal Screenshot_20231216_013606_Home Assistant

I go back to the previous version, 2023.12.0 ! now, i deactivated the automated updates and waiting for the next bug fixe release.

yup! good thing to disable auto updates, I only update when I actually have the time to troubleshoot. when I did this it was Friday night so I had time to try other thing and troubleshoot before ultimatly rolling back. (the number of times I updated just before going to work ending up worrying all day because I couldn’t start troubleshooting untill after my shift lol) I’m sure it will be patched soon though, from experience I know the devs are doing a great job

hey guys… same here… just went to 2023.12.0 to 2023.12.3 and have the same issue: bounce between unavailable to the current state every few minutes, stays unavailable for 15sec or so. All ZigBee devices; using SONOFF_Zigbee_3.0_USB_Dongle_Plus, ZHA, rpi4

edit: rolled back to 2023.12.0 overnight, back to normal

Screenshot_20231216_013606_Home Assistant

I go back to the previous version, 2023.12.0 ! now, i deactivated the automated updates and waiting for the next bug fixe release.