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.48k stars 29.42k forks source link

Opentherm loses connection: Future exception was never retrieved #26873

Closed bartandeweg closed 4 years ago

bartandeweg commented 4 years ago

Home Assistant release with the issue: 0.99.2

Operating environment (Hass.io/Docker/Windows/etc.): Hassio

Component/platform: Opentherm GW https://www.home-assistant.io/components/opentherm_gw/

Description of problem: The opentherm inegration is losing its connection to the gateway after working for a few hours / days.

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

living_room:
  device: /dev/ttyUSB0
  name: CV Thermo
  climate: 
    precision: 0.5
    Floor_temperature: True

Traceback

Mon Sep 23 2019 06:49:13 GMT+0200 (Midden-Europese zomertijd)

Error doing job: Future exception was never retrieved

Traceback (most recent call last):

Sun Sep 22 2019 13:25:21 GMT+0200 (Midden-Europese zomertijd)

Error doing job: Task exception was never retrieved

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/pyotgw/protocol.py", line 131, in _watchdog
    await self._watchdog_cb()
  File "/usr/local/lib/python3.7/site-packages/pyotgw/pyotgw.py", line 93, in reconnect
    connection_timeout, inactivity_timeout)
  File "/usr/local/lib/python3.7/site-packages/pyotgw/pyotgw.py", line 70, in connect
    stopbits, connection_timeout))
  File "/usr/local/lib/python3.7/asyncio/coroutines.py", line 120, in coro
    res = func(*args, **kw)
  File "/usr/local/lib/python3.7/site-packages/serial_asyncio/__init__.py", line 410, in create_serial_connection
    ser = serial.serial_for_url(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/serial/__init__.py", line 88, in serial_for_url
    instance.open()
  File "/usr/local/lib/python3.7/site-packages/serial/serialposix.py", line 265, in open
    self._update_dtr_state()
  File "/usr/local/lib/python3.7/site-packages/serial/serialposix.py", line 595, in _update_dtr_state
    fcntl.ioctl(self.fd, TIOCMBIS, TIOCM_DTR_str)
OSError: [Errno 5] I/O error
probot-home-assistant[bot] commented 4 years ago

Hey there @mvn23, mind taking a look at this issue as its been labeled with a integration (opentherm_gw) you are listed as a codeowner for? Thanks!

mvn23 commented 4 years ago

Thanks for the report. Unfortunately, the traceback you provided seems to be unrelated. Looks like it's coming from the icloud device tracker. The opentherm_gw integration and the pyotgw library it's using are designed to handle disconnects as gracefully as possible. Upon disconnect, pyotgw.protocol will log an error-level message stating the reason for the disconnect. After that, it will keep trying to reconnect automatically. Please look for the disconnect message and post it here. I see that you are connecting to the Gateway directly via a USB cable. This rules out any network-related problems, but still leaves other problems that can arise. I recently experienced some problems myself that were caused by a problem with the USB-TTL cable. Please check your dmesg for any possibly-related messages. In my case it looked like this:

[3876849.643274] pl2303 ttyUSB2: usb_serial_generic_read_bulk_callback - urb stopped: -32
bartandeweg commented 4 years ago

@mvn23 sorry about this. I copied the wrong traceback. Updated this in my initial post. You are right. I have the OTG connected thru USB. The USB is extended over Ethernet. I will dig into my dmesg

mvn23 commented 4 years ago

Can you still access the gateway on /dev/ttyUSB0 (e.g. with screen) after this happens? You may need to stop HA before you can test this.

bartandeweg commented 4 years ago

Did some more testing. It keeps stopping. After server reboot it works for a couple of hours. Sometimes days.

Looking at my dmesg gives me lines like:

[82223.241525] pl203 ttyUSB0: usb_serial_generic_read_bulk_callback - urb stopped: -32

I don;t know how ta access the gateway on /dev/ttyUSB0 (screen command is not found).

mvn23 commented 4 years ago

Did some more testing. It keeps stopping. After server reboot it works for a couple of hours. Sometimes days.

Looking at my dmesg gives me lines like:

[82223.241525] pl203 ttyUSB0: usb_serial_generic_read_bulk_callback - urb stopped: -32

This is exactly what I was seeing at the time. In my case it turned out to be a hardware issue. I don't suppose you have another USB-TTL cable you can try?

I don;t know how ta access the gateway on /dev/ttyUSB0 (screen command is not found).

cat should work as well, but it will be read-only.

bartandeweg commented 4 years ago

No output on CAT. Also not when HA is stopped. Now its up and running. But will test when down again.

Got no USB TTL cable left. But i will also first test it with an USB extender cable instead of a USB over Ethernet connection.

bartandeweg commented 4 years ago

Did update my Hassio install a few weeks ago to the latest version. Somehow this also made the OTGW work as it supposed to. No outfall anymore for over 2 weeks now.

Probably not the right place to ask. But how can i prevent my thermostat to overrulle the gateway on the heating settings?

mvn23 commented 4 years ago

Did update my Hassio install a few weeks ago to the latest version. Somehow this also made the OTGW work as it supposed to. No outfall anymore for over 2 weeks now.

Probably not the right place to ask. But how can i prevent my thermostat to overrulle the gateway on the heating settings?

Not possible with HA at the moment. This would require a separate service to set the target temperature with an option to disallow scheduled changes from the thermostat. Manual changes on the thermostat are always allowed as far as I know. What you could do instead is create a heating schedule in HA and disable the thermostat schedule to allow for greater control over scheduled changes.

Good to hear your issue is solved. I take it this issue can be closed?

bartandeweg commented 4 years ago

Yes. I will close the issue. Thanks for the fast replies!