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.46k stars 29.4k forks source link

[Openterm Gateay] Failed to connect #43967

Closed BarBaar44 closed 3 years ago

BarBaar44 commented 3 years ago

The problem

Cannot use integration Opentherm Gateway in Home Assistant

Environment

Problem-relevant configuration.yaml

I'm trying to setup the Opentherm Gateway integration. It always fails with the message "Failed to connect"

Connection parameters: socket://192.168.0.140:23

Traceback/Error logs

Logs show different error messages:

Logger: pyotgw.pyotgw
Source: /usr/local/lib/python3.8/site-packages/pyotgw/pyotgw.py:880
First occurred: 2 December 2020, 20:57:03 (49 occurrences)
Last logged: 16:34:32

* Timed out waiting for command: PR, value: L.
* Timed out waiting for command: PR, value: M.
* Timed out waiting for command: PR, value: A.
* Timed out waiting for command: PR, value: B.
* Timed out waiting for command: PR, value: C.

or

Logger: pyotgw.protocol
Source: /usr/local/lib/python3.8/site-packages/pyotgw/protocol.py:206
First occurred: 2 December 2020, 21:04:09 (1051 occurrences)
Last logged: 16:38:31

* Received erroneous message, ignoring: b'\xf0p\x00\x00'
* Received erroneous message, ignoring: b'\x80!~\x00'
* Received erroneous message, ignoring: b'\x80!p\x00'
* Received erroneous message, ignoring: b'\x80s\x01\xff'
* Received erroneous message, ignoring: b'\x80\x13\x01\xff'

Additional information

I am able to connect using otmonitor (https://otgw.tclcode.com/otmonitor.html) and see output.

I am also able to connect using Node-Red and get some output.

I have a Atag heather, of which I know it hasn't got the best Openthem compatibility. But given that otmonitor is working, I would expect the HA integration to do the same.

probot-home-assistant[bot] commented 3 years ago

opentherm_gw documentation opentherm_gw source (message by IssueLinks)

BarBaar44 commented 3 years ago

So, upgraded to a new Opentherm gateway, and now running the latest firmware version of the gateway. However, it still fails with the HA integration.

I found in the otmonitor logging that some of the expected values are returned:

PR: A=OpenTherm Gateway 4.2.7 PR: B=21:38 30-11-2020 PR: C=4 MHz PR: G=00

So have no idea what the integration in failing on... any help would be appreciated!

mvn23 commented 3 years ago

Sorry for the late reply, I'm just seeing this issue now.

Logger: pyotgw.protocol Source: /usr/local/lib/python3.8/site-packages/pyotgw/protocol.py:206 First occurred: 2 December 2020, 21:04:09 (1051 occurrences) Last logged: 16:38:31

  • Received erroneous message, ignoring: b'\xf0p\x00\x00'
  • Received erroneous message, ignoring: b'\x80!~\x00'
  • Received erroneous message, ignoring: b'\x80!p\x00'
  • Received erroneous message, ignoring: b'\x80s\x01\xff'
  • Received erroneous message, ignoring: b'\x80\x13\x01\xff'

These are just warnings. The pyotgw library logs erroneous messages (messages starting with E, see the "Reports" section in the OpenTherm Gateway docs) that are reported by the OpenTherm Gateway as warnings. This is not an issue in Home Assistant or pyotgw, it just means that the OpenTherm Gateway received an OpenTherm message it does not understand.

As for the timeouts, there have been several reports of similar issues when connecting to the OpenTherm Gateway via wifi (e.g. with a NodeMCU or other - usually ESP-based - controller). So far I have always been unable to reproduce the issue. If you are connecting to the gateway via wifi, please provide as much information about the connection as possible. What hardware is involved? Which firmware and version are you using? Can you get any reports on signal quality? Can you test with another means of connecting to the gateway to verify that this is indeed causing the issue? If you are using another method to connect to the gateway, please provide some info on that.

BarBaar44 commented 3 years ago

I am using a Gateway from Nodo with an USR-TCP232-T2 ethernet module. Wired connection.

I just upgraded to OTGW firmware version 4.2.8.1 and tried connecting again. No success..

mvn23 commented 3 years ago

Whoa, a new firmware version for the gateway! Didn't see that one yet. Can you provide a debug log for the following components from the moment the problem occurs:

- homeassistant.components.opentherm_gw
- pyotgw

See the logger docs for reference.

BarBaar44 commented 3 years ago

Hope this helps:

2021-01-04 17:02:23 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [281473449523136] Received {'type': 'frontend/get_translations', 'language': 'en-GB', 'category': 'config', 'integration': 'opentherm_gw', 'id': 34} 2021-01-04 17:02:23 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [281473449523136] Sending {'id': 34, 'type': 'result', 'success': True, 'result': {'resources': {'component.opentherm_gw.config.error.already_configured': 'Device is already configured', 'component.opentherm_gw.config.error.cannot_connect': 'Failed to connect', 'component.opentherm_gw.config.error.id_exists': 'Gateway id already exists', 'component.opentherm_gw.config.step.init.data.device': 'Path or URL', 'component.opentherm_gw.config.step.init.data.id': 'ID', 'component.opentherm_gw.config.step.init.data.name': 'Name', 'component.opentherm_gw.config.step.init.title': 'OpenTherm Gateway'}}}

The above one surprises me, as I am not aware that I already have OTGW configured...

For pyotgw:

2021-01-04 17:02:45 DEBUG (MainThread) [pyotgw.protocol] Received line 10: T90383700 2021-01-04 17:02:45 DEBUG (MainThread) [pyotgw.protocol] Added line 10 to message queue. Queue size: 1 2021-01-04 17:02:45 DEBUG (MainThread) [pyotgw.protocol] Processing: T 01 38 37 00 2021-01-04 17:02:45 DEBUG (MainThread) [pyotgw.protocol] Watchdog timer reset! 2021-01-04 17:02:45 DEBUG (MainThread) [pyotgw.protocol] Received line 11: B50383700 2021-01-04 17:02:45 DEBUG (MainThread) [pyotgw.protocol] Added line 11 to message queue. Queue size: 1 2021-01-04 17:02:45 DEBUG (MainThread) [pyotgw.protocol] Processing: B 05 38 37 00 2021-01-04 17:02:45 DEBUG (MainThread) [pyotgw.protocol] Watchdog timer reset! 2021-01-04 17:02:46 DEBUG (MainThread) [pyotgw.protocol] Received line 12: T00197FFF 2021-01-04 17:02:46 DEBUG (MainThread) [pyotgw.protocol] Added line 12 to message queue. Queue size: 1 2021-01-04 17:02:46 DEBUG (MainThread) [pyotgw.protocol] Processing: T 00 19 7f ff 2021-01-04 17:02:46 DEBUG (MainThread) [pyotgw.protocol] Watchdog timer reset! 2021-01-04 17:02:46 ERROR (MainThread) [pyotgw.pyotgw] Timed out waiting for command: PR, value: A. 2021-01-04 17:02:46 DEBUG (MainThread) [pyotgw.protocol] Sending command: PR with value B 2021-01-04 17:02:46 DEBUG (MainThread) [pyotgw.protocol] Received line 13: BC01932C0 2021-01-04 17:02:46 DEBUG (MainThread) [pyotgw.protocol] Added line 13 to message queue. Queue size: 1 2021-01-04 17:02:46 DEBUG (MainThread) [pyotgw.protocol] Processing: B 04 19 32 c0 2021-01-04 17:02:46 DEBUG (MainThread) [pyotgw.protocol] Watchdog timer reset! 2021-01-04 17:02:46 DEBUG (influxdb) [homeassistant.components.influxdb] Wrote 4 events. 2021-01-04 17:02:46 DEBUG (MainThread) [pyotgw.protocol] Received line 14: T00110000 2021-01-04 17:02:46 DEBUG (MainThread) [pyotgw.protocol] Added line 14 to message queue. Queue size: 1 2021-01-04 17:02:46 DEBUG (MainThread) [pyotgw.protocol] Processing: T 00 11 00 00 2021-01-04 17:02:46 DEBUG (MainThread) [pyotgw.protocol] Watchdog timer reset!

Messages like the ones below keep reappearing (with different content though)

2021-01-04 17:02:46 DEBUG (MainThread) [pyotgw.protocol] Received line 15: BC0110000 2021-01-04 17:02:46 DEBUG (MainThread) [pyotgw.protocol] Added line 15 to message queue. Queue size: 1 2021-01-04 17:02:46 DEBUG (MainThread) [pyotgw.protocol] Processing: B 04 11 00 00 2021-01-04 17:02:46 DEBUG (MainThread) [pyotgw.protocol] Watchdog timer reset! 2021-01-04 17:02:47 DEBUG (MainThread) [pyotgw.protocol] Received line 16: T90395500 2021-01-04 17:02:47 DEBUG (MainThread) [pyotgw.protocol] Added line 16 to message queue. Queue size: 1 2021-01-04 17:02:47 DEBUG (MainThread) [pyotgw.protocol] Processing: T 01 39 55 00 2021-01-04 17:02:47 DEBUG (MainThread) [pyotgw.protocol] Watchdog timer reset!

2021-01-04 17:03:16 DEBUG (MainThread) [pyotgw.protocol] Received line 127: BC0000000 2021-01-04 17:03:16 DEBUG (MainThread) [pyotgw.protocol] Added line 127 to message queue. Queue size: 1 2021-01-04 17:03:16 DEBUG (MainThread) [pyotgw.protocol] Processing: B 04 00 00 00 2021-01-04 17:03:16 DEBUG (MainThread) [pyotgw.protocol] Watchdog timer reset! 2021-01-04 17:03:17 DEBUG (MainThread) [pyotgw.protocol] Received line 128: T00000000 2021-01-04 17:03:17 DEBUG (MainThread) [pyotgw.protocol] Added line 128 to message queue. Queue size: 1 2021-01-04 17:03:17 DEBUG (MainThread) [pyotgw.protocol] Processing: T 00 00 00 00 2021-01-04 17:03:17 DEBUG (MainThread) [pyotgw.protocol] Watchdog timer reset! 2021-01-04 17:03:17 DEBUG (MainThread) [homeassistant.components.wled] Finished fetching wled data in 0.095 seconds 2021-01-04 17:03:17 DEBUG (MainThread) [pyotgw.protocol] Received line 129: BC0000000 2021-01-04 17:03:17 DEBUG (MainThread) [pyotgw.protocol] Added line 129 to message queue. Queue size: 1 2021-01-04 17:03:17 DEBUG (MainThread) [pyotgw.protocol] Processing: B 04 00 00 00 2021-01-04 17:03:17 DEBUG (MainThread) [pyotgw.protocol] Watchdog timer reset! 2021-01-04 17:03:17 DEBUG (MainThread) [pyotgw.protocol] Received line 130: T00000000 2021-01-04 17:03:17 DEBUG (MainThread) [pyotgw.protocol] Added line 130 to message queue. Queue size: 1 2021-01-04 17:03:17 DEBUG (MainThread) [pyotgw.protocol] Processing: T 00 00 00 00 2021-01-04 17:03:17 DEBUG (MainThread) [pyotgw.protocol] Watchdog timer reset! 2021-01-04 17:03:17 DEBUG (influxdb) [homeassistant.components.influxdb] Wrote 1 events. 2021-01-04 17:03:17 DEBUG (MainThread) [pyotgw.protocol] Received line 131: BC0000000 2021-01-04 17:03:17 DEBUG (MainThread) [pyotgw.protocol] Added line 131 to message queue. Queue size: 1 2021-01-04 17:03:17 DEBUG (MainThread) [pyotgw.protocol] Processing: B 04 00 00 00 2021-01-04 17:03:17 DEBUG (MainThread) [pyotgw.protocol] Watchdog timer reset! 2021-01-04 17:03:18 DEBUG (MainThread) [pyotgw.protocol] Received line 132: T001A7FFF 2021-01-04 17:03:18 DEBUG (MainThread) [pyotgw.protocol] Added line 132 to message queue. Queue size: 1 2021-01-04 17:03:18 DEBUG (MainThread) [pyotgw.protocol] Processing: T 00 1a 7f ff 2021-01-04 17:03:18 DEBUG (MainThread) [pyotgw.protocol] Watchdog timer reset!

mvn23 commented 3 years ago

Thanks for the logs, unfortunately it looks like the most interesting parts have been cut off and that there is some additional debug info from other components in there. I can see that Home Assistant is receiving and processing a steady stream of information from the gateway, but that at least 1 command either doesn't seem to get through or that the answer is lost somewhere. The first part is nothing to worry about, that's just the websocket component providing data for the frontend and has nothing to do with the issue.

Can you put the following in configuration.yaml and re-run the setup?

logger:
  default: warning
  logs:
    homeassistant.components.opentherm_gw: debug
    pyotgw: debug

Then please upload the log to a service like hastebin to avoid polluting the thread with long log posts.

One more thing: is anything else connected to the gateway while the issue occurs?

BarBaar44 commented 3 years ago

Okay, tnx. That got me one step further. NODE-Red was still connected. Disconnecting it solved the connection issue (thought I tried this before, apparently not..)

But....

All OTGW entities in HA are unavailable, except for climate.cv

https://pastebin.com/rB9SVMWQ

mvn23 commented 3 years ago

Good to hear that it's working now. All sensor and binary_sensor entities are disabled by default as they are not needed in most scenarios. You can enable them from the Configuration>Integrations panel. This is also stated in the docs. If your problem is now fully solved, please don't forget to close the issue :+1:

BarBaar44 commented 3 years ago

cool, tnx!

odicedmondgershom commented 3 years ago

Close the issue if the problem is fully solved