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
73.93k stars 30.98k forks source link

OpenTherm Gateway failed to reconnect #126732

Closed DJTerentjev closed 1 month ago

DJTerentjev commented 2 months ago

The problem

I case Gateway lost power or was disconnected from ethernet and was connected again HA failed to reconnect. Once connection was lost, got error (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None). This error appear once and no more attempts to reconnect as I can see in the log. HA doesn't reconnect to Gateway unless integration reloaded or HA restarted.

What version of Home Assistant Core has the issue?

core-2024.9.3

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Supervised

Integration causing the issue

opentherm_gw

Link to integration documentation on our website

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

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Logger: homeassistant
Source: /usr/src/homeassistant/homeassistant/runner.py:147
First occurred: 1:09:55 PM (1 occurrences)
Last logged: 1:09:55 PM

Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/pyotgw/connection.py", line 84, in reconnect
    await self._otgw.connect(self._port)
  File "/usr/local/lib/python3.12/site-packages/pyotgw/pyotgw.py", line 53, in connect
    if not await self.connection.connect(port, timeout):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyotgw/connection.py", line 59, in connect
    transport, protocol = await self._connecting_task
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyotgw/connection.py", line 115, in _attempt_connect
    transport, protocol = await (
                          ^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/serial_asyncio_fast/__init__.py", line 524, in create_serial_connection
    transport, protocol = await loop.create_connection(
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1122, in create_connection
    raise exceptions[0]
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1104, in create_connection
    sock = await self._connect_sock(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1007, in _connect_sock
    await self.sock_connect(sock, address)
  File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 641, in sock_connect
    return await fut
           ^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 681, in _sock_connect_cb
    raise OSError(err, f'Connect call failed {address}')
OSError: [Errno 113] Connect call failed ('192.168.1.12', 23)

Additional information

No response

home-assistant[bot] commented 2 months ago

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

Code owner commands Code owners of `opentherm_gw` 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 opentherm_gw` 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)


opentherm_gw documentation opentherm_gw source (message by IssueLinks)

DJTerentjev commented 2 months ago

I downgrade HA to core-2024.5.1 And in case of lost connection error was: Could not connect to serial device on socket://192.168.1.12:23. Will keep trying. Reported error was: Could not open port socket://192.168.1.12:23: timed out Once Gateway back to ethernet, HA successfully reconnect to Gateway .

mvn23 commented 1 month ago

Thanks for the report. Looks like we're not handling the OSError in the library. Does this happen every time the connection fails on the latest version of Home Assistant or only spuriously?

DJTerentjev commented 1 month ago

Thank you for quick response. It happen every time connection fails.