Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration crashing Home Assistant when Reloading device that is down #308

Open
irvintim opened this issue Mar 3, 2025 · 0 comments
Open

Comments

@irvintim
Copy link
Contributor

irvintim commented Mar 3, 2025

I just upgraded HA to 2025.2.5. The Hubitat integration version is 0.9.43.

I have 4 Hubitats configured with the integration. The configuration uses a different server port for each.

These are the ports:
tcp 0 0 10.26.10.11:18125 0.0.0.0:* LISTEN
tcp 0 0 10.26.10.11:18124 0.0.0.0:* LISTEN
tcp 0 0 10.26.10.11:18126 0.0.0.0:* LISTEN
tcp 0 0 10.26.10.11:18123 0.0.0.0:* LISTEN

One of the Hubitats is down when Home Assistant reboots, and so it is not configured correctly by the Hubutat integration (as you would expect).

Logger: homeassistant.config_entries
Source: config_entries.py:637
First occurred: 7:36:12 PM (1 occurrences)
Last logged: 7:36:12 PM

Error setting up entry Guest House Hubitat (06e43743) for hubitat
Traceback (most recent call last):
  File "/usr/local/lib/python3.13/site-packages/aiohttp/connector.py", line 1115, in _wrap_create_connection
    sock = await aiohappyeyeballs.start_connection(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<5 lines>...
    )
    ^
  File "/usr/local/lib/python3.13/site-packages/aiohappyeyeballs/impl.py", line 93, in start_connection
    raise first_exception
  File "/usr/local/lib/python3.13/site-packages/aiohappyeyeballs/impl.py", line 71, in start_connection
    sock = await _connect_sock(
           ^^^^^^^^^^^^^^^^^^^^
        current_loop, exceptions, addrinfo, local_addr_infos
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/local/lib/python3.13/site-packages/aiohappyeyeballs/impl.py", line 163, in _connect_sock
    await loop.sock_connect(sock, address)
  File "/usr/local/lib/python3.13/asyncio/selector_events.py", line 641, in sock_connect
    return await fut
           ^^^^^^^^^
  File "/usr/local/lib/python3.13/asyncio/selector_events.py", line 681, in _sock_connect_cb
    raise OSError(err, f'Connect call failed {address}')
OSError: [Errno 113] Connect call failed ('10.26.10.9', 80)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/hubitat/hubitatmaker/hub.py", line 197, in start
    await self._start_server()
  File "/config/custom_components/hubitat/hubitatmaker/hub.py", line 503, in _start_server
    await self.set_event_url(self.event_url)
  File "/config/custom_components/hubitat/hubitatmaker/hub.py", line 247, in set_event_url
    await self._api_request(f"postURL/{url}")
  File "/config/custom_components/hubitat/hubitatmaker/hub.py", line 479, in _api_request
    raise e
  File "/config/custom_components/hubitat/hubitatmaker/hub.py", line 426, in _api_request
    async with aiohttp.request(
               ~~~~~~~~~~~~~~~^
        method, f"{self.api_url}/{path}", params=params, connector=conn
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ) as resp:
    ^
  File "/usr/local/lib/python3.13/site-packages/aiohttp/client.py", line 1456, in __aenter__
    self._resp = await self._coro
                 ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/aiohttp/client.py", line 703, in _request
    conn = await self._connector.connect(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        req, traces=traces, timeout=real_timeout
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/local/lib/python3.13/site-packages/aiohttp/connector.py", line 548, in connect
    proto = await self._create_connection(req, traces, timeout)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/aiohttp/connector.py", line 1056, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/aiohttp/connector.py", line 1400, in _create_direct_connection
    raise last_exc
  File "/usr/local/lib/python3.13/site-packages/aiohttp/connector.py", line 1369, in _create_direct_connection
    transp, proto = await self._wrap_create_connection(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<7 lines>...
    )
    ^
  File "/usr/local/lib/python3.13/site-packages/aiohttp/connector.py", line 1130, in _wrap_create_connection
    raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host 10.26.10.9:80 ssl:default [Connect call failed ('10.26.10.9', 80)]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 637, in __async_setup_with_context
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hubitat/__init__.py", line 39, in async_setup_entry
    hub: Hub = await Hub.create(
               ^^^^^^^^^^^^^^^^^
        hass, config_entry, len(cast(dict[str, Any], hass.data[DOMAIN])) + 1
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/config/custom_components/hubitat/hub.py", line 324, in create
    await hubitat_hub.start()
  File "/config/custom_components/hubitat/hubitatmaker/hub.py", line 201, in start
    raise ConnectionError(str(e))
ConnectionError: Cannot connect to host 10.26.10.9:80 ssl:default [Connect call failed ('10.26.10.9', 80)]

However, it seems that it gets part of the way configured and is listening on the port for the device to connect.

So, then if I click on the "Reload" button in the service for the configured Hubitat device, Home Assistant crashes and I need to manually restart it (or reboot):

2025-03-02 19:51:29.248 INFO (MainThread) [custom_components.hubitat.hubitatmaker.hub] Created hub <Hub host=10.26.10.9 app_id=2>
2025-03-02 19:51:29.252 ERROR (Thread-8 (_run)) [root] Uncaught thread exception
Traceback (most recent call last):
  File "/usr/local/lib/python3.13/threading.py", line 1041, in _bootstrap_inner
    self.run()
    ~~~~~~~~^^
  File "/usr/local/lib/python3.13/threading.py", line 992, in run
    self._target(*self._args, **self._kwargs)
    ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hubitat/hubitatmaker/server.py", line 75, in _run
    self._server_loop.run_until_complete(site.start())
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/asyncio/base_events.py", line 720, in run_until_complete
    return future.result()
           ~~~~~~~~~~~~~^^
  File "/usr/local/lib/python3.13/site-packages/aiohttp/web_runner.py", line 121, in start
    self._server = await loop.create_server(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<7 lines>...
    )
    ^
  File "/usr/local/lib/python3.13/asyncio/base_events.py", line 1615, in create_server
    raise OSError(err.errno, msg) from None
OSError: [Errno 98] error while attempting to bind on address ('10.26.10.11', 18124): [errno 98] address in use
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant