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
74.03k stars 31.06k forks source link

Issue adding Opentherm Gateway to Home Assistant #89938

Closed tamesvanderdoes closed 1 year ago

tamesvanderdoes commented 1 year ago

The problem

Hi,

I'm trying to add my OpenTherm Gateway to Home Assistant. I have a working gateway that is working via otmonitor either via the USB-serial connection or directly from TCP using ser2net. The OpenTherm gateway is connected via USB to a Raspberry PI.

When I start adding the OpenTherm gateway in Home Assistant it first gives me an unknown error:

image

"Unknown error occurred"

Tcpdump on the Rapberry PI shows a lot of traffic between Home Assistant and the Raspberry PI on the port (in my case tcp port 2000).

When I re-add the gateway I get the following error message:

image

"Failed to connect"

I tried both firmware 4.3 and 5.8 on the Opentherm Gateway.

How can I troubleshoot this issue?

What version of Home Assistant Core has the issue?

Home Assistant 2023.3.5

What was the last working version of Home Assistant Core?

none

What type of installation are you running?

Home Assistant OS

Integration causing the issue

integration: 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?

No response

Additional information

No response

home-assistant[bot] commented 1 year 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.

(message by CodeOwnersMention)


opentherm_gw documentation opentherm_gw source (message by IssueLinks)

mvn23 commented 1 year ago

Thank you for the report. Can you provide some logs of the events? Preferably with debug logging enabled for homeassistant.components.opentherm_gw and pyotgw.

Can you also check if ser2net is throwing some additional characters (e.g. welcome banners) on the connection? A simple telnet to the gateway/pi should be sufficient to establish their presence. If they are, please try to get rid of them in your ser2net config.

tamesvanderdoes commented 1 year ago

Hi,

No, I don’t have additional chars. Snippet from my ser2net config:

2000:telnet:600:/dev/ttyUSB0:9600 8DATABITS NONE 1STOPBIT banner

Logging from the attempt to connect to the RPI/OTGW. Hopefully you can spot something:

2023-03-21 20:50:43.206 ERROR (MainThread) [aiohttp.server] Error handling request Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request resp = await request_handler(request) File "/usr/local/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle resp = await handler(request) File "/usr/local/lib/python3.10/site-packages/aiohttp/web_middlewares.py", line 117, in impl return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 67, in security_filter_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 80, in ban_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 235, in auth_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 146, in handle result = await result File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 180, in post return await super().post(request, flow_id) File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 72, in wrapper result = await method(view, request, data, *args, **kwargs) File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 110, in post result = await self._flow_mgr.async_configure(flow_id, data) File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 271, in async_configure result = await self._async_handle_step( File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 367, in _async_handle_step result: FlowResult = await getattr(flow, method)(user_input) File "/usr/src/homeassistant/homeassistant/components/opentherm_gw/config_flow.py", line 71, in async_step_init await asyncio.wait_for( File "/usr/local/lib/python3.10/asyncio/tasks.py", line 445, in wait_for return fut.result() File "/usr/src/homeassistant/homeassistant/components/opentherm_gw/config_flow.py", line 64, in test_connection status = await otgw.connect(device) File "/usr/local/lib/python3.10/site-packages/pyotgw/pyotgw.py", line 58, in connect await self.get_status() File "/usr/local/lib/python3.10/site-packages/pyotgw/pyotgw.py", line 346, in get_status dhw_setp_bounds = fields[13].split("/") IndexError: list index out of range 2023-03-21 20:50:43.336 WARNING (MainThread) [pyotgw.commandprocessor] Unknown message in command queue: 00000010/00000100,10.00,00000011/00000011,100.00,75.00,0.00,0/22,35.75,0.00,1.18,0.00,20.00,20.00,49.75,33.75,0.00,48.00,PS: 0 2023-03-21 20:50:43.344 WARNING (MainThread) [pyotgw.commandprocessor] Command PS failed with 00000010/00000100,10.00,00000011/00000011,100.00,75.00,0.00,0/22,35.75,0.00,1.18,0.00,20.00,20.00,49.75,33.75,0.00,48.00,PS: 0, retrying... 2023-03-21 20:50:50.154 WARNING (MainThread) [pyotgw.commandprocessor] Unknown message in command queue: Port already in use 2023-03-21 20:50:50.156 WARNING (MainThread) [pyotgw.commandprocessor] Command PS failed with Port already in use, retrying... 2023-03-21 20:50:50.161 ERROR (MainThread) [homeassistant] Error doing job: Fatal write error on serial transport Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/serial/urlhandler/protocol_socket.py", line 203, in write n = self._socket.send(d) BrokenPipeError: [Errno 32] Broken pipe

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/serial_asyncio/init.py", line 261, in _write_ready n = self._serial.write(data) File "/usr/local/lib/python3.10/site-packages/serial/urlhandler/protocol_socket.py", line 231, in write raise SerialException('write failed: {}'.format(e)) serial.serialutil.SerialException: write failed: [Errno 32] Broken pipe 2023-03-21 20:50:50.170 ERROR (MainThread) [pyotgw.protocol] Disconnected: write failed: [Errno 32] Broken pipe 2023-03-21 20:50:50.177 ERROR (MainThread) [homeassistant] Error doing job: Exception in callback SerialTransport._call_connection_lost(SerialExcepti... Broken pipe')) Traceback (most recent call last): File "/usr/local/lib/python3.10/asyncio/events.py", line 80, in _run self._context.run(self._callback, *self._args) File "/usr/local/lib/python3.10/site-packages/serial_asyncio/init.py", line 417, in _call_connection_lost self._serial.close() File "/usr/local/lib/python3.10/site-packages/serial/urlhandler/protocolsocket.py", line 104, in close time.sleep(0.3) File "/usr/src/homeassistant/homeassistant/util/async.py", line 159, in protected_loop_func checkloop(func, strict=strict) File "/usr/src/homeassistant/homeassistant/util/async.py", line 116, in check_loop raise RuntimeError( RuntimeError: Detected blocking call to sleep inside the event loop. Use await hass.async_add_executor_job(); This is causing stability issues. Please report issue 2023-03-21 20:50:55.154 ERROR (MainThread) [pyotgw.connection] The serial device on socket://10.1.13.250:2000 is not responding. Will keep trying.

Tames.

From: mvn23 @.> Reply to: home-assistant/core @.> Date: Sunday, 19 March 2023 at 16:15 To: home-assistant/core @.> Cc: tamesvanderdoes @.>, Author @.***> Subject: Re: [home-assistant/core] Issue adding Opentherm Gateway to Home Assistant (Issue #89938)

Thank you for the report. Can you provide some logs of the events? Preferably with debug logging enabled for homeassistant.components.opentherm_gw and pyotgw.

Can you also check if ser2net is throwing some additional characters (e.g. welcome banners) on the connection? A simple telnet to the gateway/pi should be sufficient to establish their presence. If they are, please try to get rid of them in your ser2net config.

— Reply to this email directly, view it on GitHubhttps://github.com/home-assistant/core/issues/89938#issuecomment-1475290420, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AIZE7P7JMKEKSY7WZGDWZSLW44PIDANCNFSM6AAAAAAV77VXUI. You are receiving this because you authored the thread.Message ID: @.***>

mvn23 commented 1 year ago

2000:telnet:600:/dev/ttyUSB0:9600 8DATABITS NONE 1STOPBIT banner

Can you try with raw instead of telnet?

2023-03-21 20:50:43.336 WARNING (MainThread) [pyotgw.commandprocessor] Unknown message in command queue: 00000010/00000100,10.00,00000011/00000011,100.00,75.00,0.00,0/22,35.75,0.00,1.18,0.00,20.00,20.00,49.75,33.75,0.00,48.00,PS: 0 2023-03-21 20:50:43.344 WARNING (MainThread) [pyotgw.commandprocessor] Command PS failed with 00000010/00000100,10.00,00000011/00000011,100.00,75.00,0.00,0/22,35.75,0.00,1.18,0.00,20.00,20.00,49.75,33.75,0.00,48.00,PS: 0, retrying... 2023-03-21 20:50:50.154 WARNING (MainThread) [pyotgw.commandprocessor] Unknown message in command queue: Port already in use 2023-03-21 20:50:50.156 WARNING (MainThread) [pyotgw.commandprocessor] Command PS failed with Port already in use, retrying...

These lines indicate that Home Assistant is receiving invalid data from the gateway (or ser2net). The first response is 00000010/00000100,10.00,00000011/00000011,100.00,75.00,0.00,0/22,35.75,0.00,1.18,0.00,20.00,20.00,49.75,33.75,0.00,48.00,PS: 0. The first part up to and including the last comma is a partial status report from the gateway, but it is truncated for some reason and should not end with a comma. The PS: 0 part after that is the response from a second command, but it should be on a separate line.

After that, on the second attempt to request the status report, ser2net responds with Port already in use. This is definitely not coming from the gateway, so it's either ser2net or something else in between sending this.

So there probably are some things getting mangled in the communications. If the change to raw in your ser2net config doesn't work, can you try to temporarily connect the gateway to Home Assistant via USB to check that the integration logic and the gateway itself are working as expected?

issue-triage-workflows[bot] commented 1 year ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.