bellows icon indicating copy to clipboard operation
bellows copied to clipboard

Controller doesnt reconnect after serial connection lost.

Open ryanwinter opened this issue 1 year ago • 8 comments

Previously in home assistant 2024.10.3, I would see the following errors, but everything recovered fine:

2024-12-03 11:58:02.028 ERROR (bellows.thread_0) [bellows.uart] Lost serial connection: SerialException('device reports readiness to read but returned no data (device disconnected or multiple access on port?)')
2024-12-03 11:58:02.029 ERROR (MainThread) [bellows.ezsp] NCP entered failed state. Requesting APP controller restart

But now (home assistant 2024.11), it seems that if the serial connection is lost, it doesnt appear to reestablish? I think it might be related to #633

This issue is also being tracked at in Home Assistant Core.

ryanwinter avatar Dec 03 '24 20:12 ryanwinter

Can you attach a full ZHA debug log of it failing to reconnect?

puddly avatar Dec 03 '24 20:12 puddly

Can you attach a full ZHA debug log of it failing to reconnect?

The are several logs in the references issue https://github.com/home-assistant/core/issues/130548. Failed reconnect will be part of them

erkr avatar Dec 04 '24 16:12 erkr

+1 having similar issue when using zigpy + bellows fromthe Z4D plugin

pipiche38 avatar Dec 04 '24 16:12 pipiche38

@erkr Your logs seem to specifically omit the logging I'm interested in. I need to see if this occurs with other people because reconnection logic is working as far as I'm able to test with SiLabs radios.

puddly avatar Dec 04 '24 17:12 puddly

@puddly pity they don't provide what you need. I was able to return my ZBDongle-E and reverted to my Conbee2. Less range but stable

erkr avatar Dec 04 '24 17:12 erkr

I'm still running ha 2024.10.3 without any issues, I'll try and roll forward again and capture more logs but unfortunately I'm away into early Jan.

ryanwinter avatar Dec 07 '24 05:12 ryanwinter

I have the same issue as described in the bug, that the serial connection is not reconnecting. I hope my logs are helpful. This error is most noticable: TypeError: object NoneType can't be used in 'await' expression

Logs:

Failed to send request: ApplicationController is not running


Logger: py.warnings
Quelle: /usr/local/lib/python3.13/warnings.py:110
Erstmals aufgetreten: 09:01:55 (1 Vorkommnisse)
Zuletzt protokolliert: 09:01:55

/usr/local/lib/python3.13/asyncio/base_events.py:746: RuntimeWarning: coroutine 'SerialProtocol.disconnect' was never awaited self._ready.clear()

Logger: zigpy.application
Quelle: /usr/local/lib/python3.13/site-packages/zigpy/application.py:427
Erstmals aufgetreten: 08:32:43 (2 Vorkommnisse)
Zuletzt protokolliert: 08:35:57

Failed to disconnect from radio
Traceback (most recent call last):
  File "/usr/local/lib/python3.13/site-packages/zigpy/application.py", line 425, in shutdown
    await self.disconnect()
  File "/usr/local/lib/python3.13/site-packages/bellows/zigbee/application.py", line 459, in disconnect
    await self._ezsp.disconnect()
  File "/usr/local/lib/python3.13/site-packages/bellows/ezsp/__init__.py", line 193, in disconnect
    await self._gw.disconnect()
TypeError: object NoneType can't be used in 'await' expression

Logger: bellows.thread
Quelle: components/zha/helpers.py:761
Erstmals aufgetreten: 08:32:43 (2 Vorkommnisse)
Zuletzt protokolliert: 08:35:57

Attempted to use a closed event loop

Logger: zigpy.application
Quelle: /usr/local/lib/python3.13/site-packages/zigpy/application.py:663
Erstmals aufgetreten: 08:32:43 (1 Vorkommnisse)
Zuletzt protokolliert: 08:32:43

Watchdog failure
Traceback (most recent call last):
  File "/usr/local/lib/python3.13/site-packages/zigpy/application.py", line 661, in _watchdog_loop
    await self.watchdog_feed()
  File "/usr/local/lib/python3.13/site-packages/zigpy/application.py", line 647, in watchdog_feed
    await self._watchdog_feed()
  File "/usr/local/lib/python3.13/site-packages/bellows/zigbee/application.py", line 925, in _watchdog_feed
    current_counters = await self._ezsp.read_counters()
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/bellows/ezsp/v4/__init__.py", line 191, in read_counters
    (res,) = await self.readCounters()
             ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/bellows/ezsp/protocol.py", line 126, in command
    await self._gw.send_data(data)
  File "/usr/local/lib/python3.13/site-packages/bellows/uart.py", line 31, in send_data
    await self._transport.send_data(data)
  File "/usr/local/lib/python3.13/site-packages/bellows/ash.py", line 708, in send_data
    await asyncio.shield(
    ...<6 lines>...
    )
  File "/usr/local/lib/python3.13/site-packages/bellows/ash.py", line 656, in _send_data_frame
    await ack_future
RuntimeError: Connection has been closed


Logger: homeassistant
Quelle: /usr/src/homeassistant/homeassistant/runner.py:112
Erstmals aufgetreten: 08:32:43 (1 Vorkommnisse)
Zuletzt protokolliert: 08:32:43

Error doing job: Fatal write error on serial transport (None)
Traceback (most recent call last):
  File "/usr/local/lib/python3.13/site-packages/serial/serialposix.py", line 621, in write
    n = os.write(self.fd, d)
OSError: [Errno 19] No such device

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.13/site-packages/serial_asyncio_fast/__init__.py", line 310, in _write_data
    n = self._serial.write(data)
  File "/usr/local/lib/python3.13/site-packages/serial/serialposix.py", line 655, in write
    raise SerialException('write failed: {}'.format(e))
serial.serialutil.SerialException: write failed: [Errno 19] No such device

ktrask avatar Dec 07 '24 11:12 ktrask

Also rolled back to 2024.10.3

luca-mg avatar Dec 29 '24 16:12 luca-mg

Not sure if it's relevant here, but I'm having part of the same error message. The whole ZHA network stops working around once every 2-3 days, and I have to restart HA to recover.

Logger: zigpy.application
Source: /usr/local/lib/python3.13/site-packages/zigpy/application.py:465
First occurred: 22 November 2025 at 07:59:41 (8 occurrences)
Last logged: 08:08:52
Failed to disconnect from radio

Traceback (most recent call last):
  File "/usr/local/lib/python3.13/site-packages/zigpy/application.py", line 463, in shutdown
    await self.disconnect()
  File "/usr/local/lib/python3.13/site-packages/bellows/zigbee/application.py", line 586, in disconnect
    await self._ezsp.disconnect()
  File "/usr/local/lib/python3.13/site-packages/bellows/ezsp/__init__.py", line 218, in disconnect
    await self._gw.disconnect()
TypeError: object NoneType can't be used in 'await' expression

davet2001 avatar Nov 24 '25 15:11 davet2001

We're tracking this issue here: https://github.com/home-assistant/core/issues/130548. This isn't an issue with the bellows library.

puddly avatar Nov 24 '25 15:11 puddly