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
72.13k stars 30.18k forks source link

EZSP start attempts not enough to start ZHA #84303

Closed gribouk closed 1 year ago

gribouk commented 1 year ago

The problem

Dear All,

I am using TCP coordinators for Zigbee network. Power outages turned common phenomena in my area recently. After power returns it takes some time for my router to boot. Then the coordinators may be accessed. Meanwhile, my HA server, being parked at Intel's NUC, boots swiftly, and by the time coordinators are within it's reach I alredy see below in the logs and integration is marked as 'failed to load':


Logger: homeassistant.components.zha.core.gateway
Source: components/zha/core/gateway.py:172
Integration: Zigbee Home Automation ([documentation](https://www.home-assistant.io/integrations/zha), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+zha%22))
First occurred: 16:13:32 (3 occurrences)
Last logged: 16:13:38

Couldn't start EZSP = Silicon Labs EmberZNet protocol: Elelabs, HUSBZB-1, Telegesis coordinator (attempt 1 of 3)
Couldn't start EZSP = Silicon Labs EmberZNet protocol: Elelabs, HUSBZB-1, Telegesis coordinator (attempt 2 of 3)
Couldn't start EZSP = Silicon Labs EmberZNet protocol: Elelabs, HUSBZB-1, Telegesis coordinator (attempt 3 of 3)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/zha/core/gateway.py", line 172, in async_initialize
    self.application_controller = await app_controller_cls.new(
  File "/usr/local/lib/python3.10/site-packages/zigpy/application.py", line 144, in new
    await app.startup(auto_form=auto_form)
  File "/usr/local/lib/python3.10/site-packages/zigpy/application.py", line 124, in startup
    await self.connect()
  File "/usr/local/lib/python3.10/site-packages/bellows/zigbee/application.py", line 124, in connect
    self._ezsp = await bellows.ezsp.EZSP.initialize(self.config)
  File "/usr/local/lib/python3.10/site-packages/bellows/ezsp/__init__.py", line 103, in initialize
    await ezsp.connect()
  File "/usr/local/lib/python3.10/site-packages/bellows/ezsp/__init__.py", line 120, in connect
    self._gw = await bellows.uart.connect(self._config, self)
  File "/usr/local/lib/python3.10/site-packages/bellows/uart.py", line 382, in connect
    protocol, connection_done = await thread.run_coroutine_threadsafe(
  File "/usr/local/lib/python3.10/site-packages/bellows/uart.py", line 361, in _connect
    transport, protocol = await zigpy.serial.create_serial_connection(
  File "/usr/local/lib/python3.10/site-packages/zigpy/serial.py", line 33, in create_serial_connection
    transport, protocol = await loop.create_connection(
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1064, in create_connection
    raise exceptions[0]
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1049, in create_connection
    sock = await self._connect_sock(
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 960, in _connect_sock
    await self.sock_connect(sock, address)
  File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 500, in sock_connect
    return await fut
  File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 505, in _sock_connect
    sock.connect(address)
OSError: [Errno 101] Network unreachable

Would it be possible to make ZHA boot in the background with, let's say 3 minutes interval, untill success if it failed to load on startup? I belive it should not be an impediment since I go to integration's setup and pick oprion 'reload ' every time, which it does, and I can use it after that, meaning that evety 3 minutes integration itself may call same option for me until it is loaded...

Thanks in advance!

What version of Home Assistant Core has the issue?

2022.12

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

ZHA

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 1 year ago

Hey there @dmulcahey, @adminiuga, @puddly, mind taking a look at this issue as it has been labeled with an integration (zha) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `zha` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Change the title of the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign zha` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


zha documentation zha source (message by IssueLinks)

puddly commented 1 year ago

Would it be possible to make ZHA boot in the background with, let's say 3 minutes interval, untill success if it failed to load on startup?

We specifically removed this behavior so that the ZHA integration wouldn't be perpetually stuck "initializing" when there is an uncorrectable problem. However, I think we can specifically catch the Network unreachable error and keep retrying.