core: OTGW unable to connect

The problem

Since the update to 2022.7.x I’m not able to connect with my serial connected OTGW.

What version of Home Assistant Core has the issue?

2022.7.7

What was the last working version of Home Assistant Core?

2022.6.7

What type of installation are you running?

Home Assistant Container

Integration causing the issue

OTGW

Link to integration documentation on our website

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

Diagnostics information

2022-07-26 18:45:00 ERROR (MainThread) [homeassistant.util.logging] Exception in receive_report when dispatching 'opentherm_gw_1_update': ({'outside_temp': None},)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/opentherm_gw/sensor.py", line 132, in receive_report
    value = status[self._source].get(self._var)
KeyError: 'boiler'

2022-07-26 18:45:00 ERROR (MainThread) [homeassistant.util.logging] Exception in receive_report when dispatching 'opentherm_gw_1_update': ({'outside_temp': None},)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/opentherm_gw/sensor.py", line 132, in receive_report
    value = status[self._source].get(self._var)
KeyError: 'boiler'

2022-07-26 18:45:00 ERROR (MainThread) [homeassistant.util.logging] Exception in receive_report when dispatching 'opentherm_gw_1_update': ({'outside_temp': None},)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/opentherm_gw/sensor.py", line 132, in receive_report
    value = status[self._source].get(self._var)
KeyError: 'thermostat'

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

#75663 and #75285 did not fix the issue. But since there where already issues filed I did not report or checked my logs.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 46 (34 by maintainers)

Most upvoted comments

@balloob I have not seen this fix in the latest releases. Can you tell when this fix will be included?

@mvn23 this patch works for me.

I may have found the problem, but I’m not able to reproduce the mangled messages on my networked setup. Can you try adding the following line to homeassistant/components/opentherm_gw/__init__.py?

--- a/homeassistant/components/opentherm_gw/__init__.py
+++ b/homeassistant/components/opentherm_gw/__init__.py
@@ -117,6 +117,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
             timeout=CONNECTION_TIMEOUT,
         )
     except (asyncio.TimeoutError, ConnectionError, SerialException) as ex:
+        await gateway.cleanup()
         raise ConfigEntryNotReady(
             f"Could not connect to gateway at {gateway.device_path}: {ex}"
         ) from ex

If the gateway is not responding to commands even when you send them through otmonitor or screen there’s definitely something wrong with it. We can’t do anything in Home Assistant to fix that. It may have seemed to work fine before as it is still sending out data and previous versions did not rely on commands to connect and initialize, but then you probably just never noticed that the commands didn’t work (i.e. it seems not to receive data).

I think you’re spot on. Also with OTmonitor I can see values and since I never send commands I didn’t know that didn’t work. Anyway, removed OTGW and checked by connecting to my laptop directly using USB - TTL, working fine. So flashed latest firmware and re-installed back onto boiler, now it’s working! Perhaps it just needed a good reboot, but now I commands also work.

So in my experience with latest pyotgw and RC home assistant it works again 😃. Thanks for the hard work!

You can add something like this to configuration.yaml to enable relevant debug logging:

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

This will log sent and received traffic among other things. Just don’t forget to remove it again after you’re done because it generates quite a lot of messages.