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.39k forks source link

OpenTherm integration only works against OTMonitor and not directly #61433

Closed djvandijk closed 2 years ago

djvandijk commented 2 years ago

The problem

First an overview of my setup: I've got an OpenTherm GateWay (OTGW) with serial support only. In order to make this network accessible I've attached a Raspberry PI to the serial connection and using 'ser2net' I can access the OTGW via TCP. This has worked great while I was still using Domoticz, however I recently switched to Home Assistant. If I use the OpenTherm integration and let it talk directly to the OTGW (via the PI) I get an error message. Something about 'unknown message in command queue'. However if I let OTMonitor connect to OTGW (again via the PI) and enable 'relay server' in OTMonitor and then let the OpenTherm integration connect to this relay server everything works out. I thought the relay server from OTMonitor was really doing nothing else than relay commands back and forth and it shouldn't matter if I connect straight to OTGW or to OTMonitor-relay-server. I noticed that OTMonitor crashes every couple of days so this is really inconvenient. Any ideas?

What version of Home Assistant Core has the issue?

2021.11.5

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

OpenTherm Gateway

Link to integration documentation on our website

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

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

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

opentherm_gw documentation opentherm_gw source (message by IssueLinks)

probot-home-assistant[bot] commented 2 years 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! (message by CodeOwnersMention)

mvn23 commented 2 years ago

From the information you provided so far there's not a lot we can do with this report. Since it's working with OTMonitor in between, it's more likely to be a problem with your setup than with Home Assistant. I'm expecting some extra data in the serial protocol which gets silently discarded by OTMonitor.

Can you please provide the following additional information:

As a side note, the warning you're getting (Unknown message in command queue: <message>) should contain the data that's not recognised. It is also not necessarily fatal, so the integration may still work despite the warning.

djvandijk commented 2 years ago

ser2net.conf (relevant part): 2000:raw:600:/dev/ttyUSB1:9600 8DATABITS NONE 1STOPBIT banner

I'm relatively new to HASS so the only logs that I know about are via the web interface 'configuration->logs'. What I can get from that log (there's an ERROR there as well related to pyotgw): Command PR failed with PR: D=O, retrying... 5:36:48 PM – (WARNING) /usr/local/lib/python3.9/site-packages/pyotgw/protocol.py - message first occurred at 5:36:47 PM and shows up 18 times Unknown message in command queue: PR: D=O 5:36:48 PM – (WARNING) /usr/local/lib/python3.9/site-packages/pyotgw/protocol.py - message first occurred at 5:36:47 PM and shows up 18 times Error handling request 5:36:48 PM – (ERROR) components/opentherm_gw/config_flow.py

I get this error the moment I add the integration. While adding I get an 'unknown error' and nothing is added. The socket connection however is kept open. I cannot connect via OTMonitor after trying to add the integration until I restart HASS-Core.

mvn23 commented 2 years ago

Which firmware version is your OpenTherm Gateway using? There is a bug in the library that may cause problems with versions before 5.0. It is fixed in the latest master, but it is not used in Home Assistant yet. If you're on 4.x you could try upgrading to 5.1.

djvandijk commented 2 years ago

I'm already running version 5.1

mvn23 commented 2 years ago

Ok, to avoid any additional data on the serial protocol, you should remove banner from your ser2net.conf. This will avoid any distracting warnings during debugging. Then we will need to get a debug log from Home Assistant to see what's really happening. You can install the SSH addon to gain access to Home Assistant's files. They should be located in the /config folder once you're logged in via ssh. Add the snippet above to configuration.yaml, restart Home Assistant, trigger the error and have a look at home-assistant.log in the same folder. Please use a service like hastebin to share the log, as it may be rather long.

djvandijk commented 2 years ago

Ok. Removing the banner from ser2net.conf was enough to get it all working. Thanks a bunch and I learned a couple of new tricks. So all good.