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.02k stars 29.09k forks source link

ZHA gets stuck in initialization at startup if host is not connected to the Internet #110321

Closed VenominousX closed 4 months ago

VenominousX commented 5 months ago

The problem

I am currently having problems with my ISP, the Internet is not working. My Home Assistant is restarted every morning, which now leads to the problem that nothing works anymore.

No lights, no buttons, no monitoring - nothing that depends on ZHA works without internet. Wasn't Home Assistant's plan to not need this dependency to work?

If I use my mobile data to connect to the Internet as a test, everything starts. This is not a good solution.

What version of Home Assistant Core has the issue?

2024.2.1

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

ZHA

Link to integration documentation on our website

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

Diagnostics information

home-assistant_zha_2024-02-12T06-45-05.174Z.log

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2024-02-12 07:31:26.337 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry ConBee II for zha
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 444, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/zha/__init__.py", line 163, in async_setup_entry
    zha_gateway = await ZHAGateway.async_from_config(
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/zha/core/gateway.py", line 196, in async_from_config
    await instance.async_initialize()
  File "/usr/src/homeassistant/homeassistant/components/zha/core/gateway.py", line 214, in async_initialize
    await app.startup(auto_form=True)
  File "/usr/local/lib/python3.12/site-packages/zigpy/application.py", line 226, in startup
    await self.initialize(auto_form=auto_form)
  File "/usr/local/lib/python3.12/site-packages/zigpy/application.py", line 219, in initialize
    await self.ota.initialize()
  File "/usr/local/lib/python3.12/site-packages/zigpy/ota/__init__.py", line 154, in initialize
    await self.async_event("initialize_provider", self._app.config[CONF_OTA])
  File "/usr/local/lib/python3.12/site-packages/zigpy/util.py", line 81, in async_event
    for result in await asyncio.gather(*tasks, return_exceptions=True):
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/zigpy/ota/provider.py", line 792, in initialize_provider
    await self.refresh_firmware_list()
  File "/usr/local/lib/python3.12/site-packages/zigpy/ota/provider.py", line 801, in refresh_firmware_list
    async with req.get(self.UPDATE_URL) as rsp:
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 1194, in __aenter__
    self._resp = await self._coro
                 ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 578, in _request
    conn = await self._connector.connect(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 544, in connect
    proto = await self._create_connection(req, traces, timeout)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 911, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1204, in _create_direct_connection
    transp, proto = await self._wrap_create_connection(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 992, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1101, in create_connection
    sock = await self._connect_sock(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1004, in _connect_sock
    await self.sock_connect(sock, address)
  File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 637, in sock_connect
    return await fut
           ^^^^^^^^^
asyncio.exceptions.CancelledError: Global task timeout

Additional information

No response

home-assistant[bot] commented 5 months ago

Hey there @dmulcahey, @adminiuga, @puddly, @thejulianjes, 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` Renames 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. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


zha documentation zha source (message by IssueLinks)

TheJulianJES commented 5 months ago

Known issue. Error handling will be improved soon. You can disable the OTA providers for now. See the ZHA docs page, copy the OTA YAML part, but change all providers to false.

Other issue:

Docs: Copy this YAML section into your configuration.yaml, but change true to false everywhere. https://www.home-assistant.io/integrations/zha/#ota-firmware-updates

VenominousX commented 5 months ago

Nope, does not work with zha config. Is it possible to install a check that determines the manufacturers used and only activates the OTA function for the existing manufacturers used? I only have Aqara, Hue and INNR devices, as only manufacturers that are not listed in the ZHA Config. This is slightly annoying when you are disabled by functions for devices that you don't even use yourself.

TheJulianJES commented 5 months ago

Again, it's a known bug. Error handling will be improved soon.

Try this:

zha:
  zigpy_config:
    ota:
      ikea_provider: false
      ledvance_provider: false
      salus_provider: false
      sonoff_provider: false
      inovelli_provider: false
      thirdreality_provider: false

If it doesn't work, post the updated exception and integration diagnostics if they can be downloaded.

VenominousX commented 5 months ago

Yes, i have understood that this is a bug and that it will be fixed. The question i asked is also more about providing device-specific functions in the future if you also use these devices. For now i have restarted my system via mobile Hotspot so that everything like the security works. I am at work now, so I can't deal with it right now. Thank you for your answers.

12.02.2024 08:12:38 TheJulianJES @.***>:

Again, it's a known bug. Error handling will be improved soon.

Try this:

zha: zigpy_config: ota: ikea_provider: false ledvance_provider: false salus_provider: false sonoff_provider: false inovelli_provider: false thirdreality_provider: false

If it doesn't work, post the updated exception.

— Reply to this email directly, view it on GitHub[https://github.com/home-assistant/core/issues/110321#issuecomment-1938152349], or unsubscribe[https://github.com/notifications/unsubscribe-auth/APYRWIUHGFYINSMSCNF22ALYTG6GLAVCNFSM6AAAAABDEHA5MGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMZYGE2TEMZUHE]. You are receiving this because you authored the thread. [Verfolgungsbild][https://github.com/notifications/beacon/APYRWITKICVYQTWBGKC6NVLYTG6GLA5CNFSM6AAAAABDEHA5MGWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTTTQXNZ2.gif]

VenominousX commented 5 months ago

@TheJulianJES The configuration as you have posted it works. I had copied the yaml configuration from home-assistant.io/integrations/zha/#ota-firmware-updates this morning and set true => false, which doesn't work. Unfortunately I didn't have time to correct it this morning. Thanks for the hint.

The ZHA configuration after copy and paste and storing: image

Looks like the sonoff line is missing on the website