home-assistant-comfoconnect
home-assistant-comfoconnect copied to clipboard
Integration doesn't always properly reconnect to the bridge
Since there are a lot of similar issues, I'll create a new issue and link them all to this one.
This integration sometimes doesn't reconnect properly after the connection was dropped to the bridge. The exact reason for these disconnects are unknown, but it might be related to one of those:
- Overloaded bridge due to too many registered sensors (https://github.com/michaelarnauts/home-assistant-comfoconnect/issues/36#issuecomment-2013328187)
- Some firmware had a problem that triggered a disconnect on a DHCP renew. Check your lease time and increase it to 24h or something higher. It seems that version 1.5.1 should fix this. You can upgrade the firmware from the Zehnder Comfoconnect mobile app.
Since these disconnects happen, it is important that we have a proper reconnect logic in place. Unfortunately, when the bridge disconnects (maybe it just crashes and restarts?), it seems it doesn't properly close the TCP connection, so we don't know that we got disconnected until we make a request and don't get a reply in due time. That's why there is a keepalive that is send every 30 seconds.
More information about the new reconnect logic is written here: https://github.com/michaelarnauts/aiocomfoconnect/pull/23
Please try the latest code in Home Assistant with HACS. I've created a release for 0.1.9 for the release before these changes, in case you want to rollback. If you want to test the new reconnect logic, please select the "master" branch in HACS when (re)installing.
Related issues:
- https://github.com/michaelarnauts/home-assistant-comfoconnect/issues/40
- https://github.com/michaelarnauts/home-assistant-comfoconnect/issues/36
- https://github.com/michaelarnauts/home-assistant-comfoconnect/issues/33
- https://github.com/michaelarnauts/home-assistant-comfoconnect/issues/32
- https://github.com/michaelarnauts/home-assistant-comfoconnect/issues/23
- https://github.com/michaelarnauts/home-assistant-comfoconnect/issues/22
- https://github.com/michaelarnauts/home-assistant-comfoconnect/issues/13
Awesome! Thanks for both of your time, very very appreciated!!
Did the update, 4 new sensors were added and I enabled all 38 sensors.
[edit]
The new sensors are from the ComfoFond which we don't have :)
Thank you very much for your work! I updated it and now it connects properly. I will let you know if there are any issues, but it will probably be fine now! Again, nice job @litinoveweedle and @michaelarnauts !
Thank you. I will start testing the updated Hacs integration today.
For now it looks rock solid! Very nice job guys!!
[edit 03-04-2024 07:40] Still going strong!
Having some issues here. The fan is not updating it's state after +- one day. But when pushing the fan speed button it is strangely working but still gives an error message. Ps. DHCP lease time is set very high.
Hello all, first big thanks to @michaelarnauts! All the credits for the fix belongs to him. I did only learn a lot from him during last few days ;-)
As you are probably aware, the fix provided solves situation where your HA looses connection the the ComfoConnect gateway. In the past, the integration was not able to handle such state completely gracefully, without raising nuch of errors and warnings. As about the root cause, I was finally able to find it and fix it also based on information provided by @michaelarnauts.
Disclaimer: I did never used phone app with my gateway, as I didn't had a reason to do so. Also my gateway is not connected to the network with internet access - so no cloud connection. But due to this I was not aware, that there is new updated firmware - as you get firmware update prompt during registering of your gateway with mobile application.
As I discovered original shipped firmware version U1.1.10 was having following issue: My standard DHCP server has lease time 10 minutes. 5 minutes after getting IP (DHCP ACK) gateway always asked for DHCP renew (DHCP RENEW). At this moment, even if the gateway kept responding to the ping, it immediately ceases all data communication to ANY client (both Home Assistant as well as mobile app). After 5-20 sec Comfoconnect HA integration timeout, raised exception and restarted communication. At that time gateway is already able to reestablish communication - but only to repeat whole story 5 minutes later. I did validated this behavior with tcpdump and also by increasing DHCP lease time.
I was able to solve this DHCP renew related disconnect by upgrading my gateway to firmware U1.5.1. This can be done from mobile app. Please see firmware release notes:
- Security updates
- Improved support for Cloud features
- Improved ComfoNet operation
- Improved network stability
So for anyone previously having disconnect/reconnect issue please check your firmware version and also network stability.
After firmware upgrade and update of the integration everything works perfect for last few days. I am also planning to simulate some network instability artificially to test improvements in the integration - as right now my connection is rock stable.
Again huge thanks to @michaelarnauts!
This is not stable at all for me. After one day it is not possible anymore to control the comfoAirQ. I'm returning to the default comfoconnect integration in home assistant. @michaelarnauts @litinoveweedle any chance that you want to offer remote support for some compensation of course...? This problem is driving me nuts for months now
Ok, after several more days of using integration I had almost no issues. That is probably mostly due to removing the root cause of the instability (by firmware upgrade). But I observe really crazy chain of exceptions to be triggered, which required HA restart. Something went really crazy and I did not tried to trigger this, it simple happened somehow....
I am attaching filtered HA log:
This is not stable at all for me. After one day it is not possible anymore to control the comfoAirQ. I'm returning to the default comfoconnect integration in home assistant. @michaelarnauts @litinoveweedle any chance that you want to offer remote support for some compensation of course...? This problem is driving me nuts for months now
Would it be please possible to describe your problem in more technical manners? Did you checked your FW version? Do you have errors in the home assistant log? Please try to collect more information first, than lets see what we can do to help.
My integration is running fine. Fingers crossed.
Some "specs":
Home Assistant (docker) --> Core 2024.4.1 --> Frontend 20240307.0
Zehnder ComfoAirQ integration via HACS --> v0.1.9
ComfoAir Q350 B R ST ERV Prem --> Firmware: R1.11.0 ComfoConnect LAN C --> Firmware: R1.5.1
@litinoveweedle Hope this helps?
My integration is running fine. Fingers crossed.
Some "specs":
Home Assistant (docker) --> Core 2024.4.1 --> Frontend 20240307.0
Zehnder ComfoAirQ integration via HACS --> v0.1.9
ComfoAir Q350 B R ST ERV Prem --> Firmware: R1.11.0 ComfoConnect LAN C --> Firmware: R1.5.1
@litinoveweedle Hope this helps?
v0.1.9 is still the old version. You'll need to select master to have the latest changes.
v0.1.9 is still the old version. You'll need to select master to have the latest changes.
And that unfortunately goes as well for me, mea culpa. I just installed 'Master' branch. So please disregard my previous report.
Here it's working flawlessly.
Core > 2024.4.2
Supervisor > 2024.04.0
Operating System > 12.1
Frontend > 20240404.1
Zehnder ComfoAirQ integration > Master
From log "Attempting install of aiocomfoconnect==0.1.9"
ComfoAir Q350 > Firmware: R1.11.0
ComfoConnect LAN C > Firmware: R1.5.1
I added a +/- 5h log from yesterday. home-assistant_comfoconnect_2024-04-10T12-21-05.800Z.log
I just switched to the 'master' version. Thanks for the hint!
I'll try to create a 0.1.10 version or something to avoid more confusion.
This is not stable at all for me. After one day it is not possible anymore to control the comfoAirQ. I'm returning to the default comfoconnect integration in home assistant. @michaelarnauts @litinoveweedle any chance that you want to offer remote support for some compensation of course...? This problem is driving me nuts for months now
Would it be please possible to describe your problem in more technical manners? Did you checked your FW version? Do you have errors in the home assistant log? Please try to collect more information first, than lets see what we can do to help.
I will try... :) I was not on the Hacs integration for a long time since it was not stable for me. After changing DHCP lease to 10 days on my router I got it working quiet stable on the default confoconnect integration for sometimes more than a week (probably these 10 days) allthough at some moments it was losing connection earlier. After hearing about the new HACS version I switched back to it, also changed the DHCP lease time back to 1 day to test. Quiet fast (less then a day later) I noticed that the fan state was not updating anymore in Home Assistant GUI but it was still controllable manually (that is different from the default comfoconnect integration). After 1 day it was also not controllable anymore. This is why again I switched back to the default integration. Since my DHCP lease was still on 1 day, today it lost connection again, so that is definitely (one of) the issue(s).
What I see in the logs now (still on the default integration):
I will switch back now to the HACS integration and try to collect some logs. Should I turn on 'enable defug logging' and collect these logs?
Here are some details about my configuration:
Home Assistant (Synology VM) --> Core 2024.4.1 Zehnder ComfoAirQ integration via HACS --> v0.1.9 ComfoAir Q350 --> Firmware: R1.11.0 (most recent firmware) ComfoConnect LAN C --> Firmware: R1.5.1 (most recent firmware)
I did not get the master version as well. So now starting to test the master version.
edit: I noticed that installing the master version from scratch it is not possible to connect to the ComfoAir system (using GUI). So I first downloaded 0.1.9 again, connected it and after that did a 'redownload' to the master version + restart
To avoid all the confusion, I've released 0.1.10. It's easy to go back to the previous release anyway.
The home assistant log is filled with errors...
Logger: homeassistant Source: /usr/src/homeassistant/homeassistant/runner.py:146 First occurred: 10:09:59 PM (412 occurrences) Last logged: 10:39:35 PM
Error doing job: Exception in callback ComfoConnect._unhold_sensors() Traceback (most recent call last): File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run self._context.run(self._callback, *self._args) File "/usr/local/lib/python3.12/site-packages/aiocomfoconnect/comfoconnect.py", line 68, in _unhold_sensors if self._sensors_values[sensor_id] is not None: ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^ KeyError: 65
Logger: homeassistant Source: /usr/src/homeassistant/homeassistant/runner.py:146 First occurred: 10:21:03 PM (91 occurrences) Last logged: 10:39:34 PM
Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/aiocomfoconnect/bridge.py", line 108, in _read_messages await self._process_message() File "/usr/local/lib/python3.12/site-packages/aiocomfoconnect/bridge.py", line 239, in _process_message self._event_bus.emit(message.cmd.reference, message.msg) File "/usr/local/lib/python3.12/site-packages/aiocomfoconnect/bridge.py", line 56, in emit del self.listeners[event_name] ~~~~~~~~~~~~~~^^^^^^^^^^^^ KeyError: 1
Logger: homeassistant Source: /usr/src/homeassistant/homeassistant/runner.py:146 First occurred: 10:07:37 PM (1556 occurrences) Last logged: 10:39:34 PM
Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/aiocomfoconnect/bridge.py", line 213, in _process_message message = await self._read() ^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiocomfoconnect/bridge.py", line 176, in _read msg_len_buf = await self._reader.readexactly(4) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/asyncio/streams.py", line 750, in readexactly raise exceptions.IncompleteReadError(incomplete, n) asyncio.exceptions.IncompleteReadError: 0 bytes read on a total of 4 expected bytes
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/aiocomfoconnect/bridge.py", line 108, in _read_messages await self._process_message() File "/usr/local/lib/python3.12/site-packages/aiocomfoconnect/bridge.py", line 247, in _process_message raise AioComfoConnectNotConnected aiocomfoconnect.exceptions.AioComfoConnectNotConnected
Logger: aiocomfoconnect.bridge Source: runner.py:189 First occurred: 10:06:47 PM (1724 occurrences) Last logged: 10:39:29 PM
Timeout while connecting to bridge 192.168.0.35 Timeout while waiting for response from bridge Failed to decode message: Error parsing message
Logger: homeassistant Source: /usr/src/homeassistant/homeassistant/runner.py:146 First occurred: 10:39:22 PM (1 occurrences) Last logged: 10:39:22 PM
Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/aiocomfoconnect/comfoconnect.py", line 79, in _reconnect_loop read_task = await self._connect(uuid) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiocomfoconnect/bridge.py", line 95, in _connect self._reader, self._writer = await asyncio.wait_for(asyncio.open_connection(self.host, self.PORT), TIMEOUT) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/asyncio/tasks.py", line 520, in wait_for return await fut ^^^^^^^^^ File "/usr/local/lib/python3.12/asyncio/streams.py", line 48, in open_connection transport, _ = await loop.create_connection( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1120, in create_connection raise exceptions[0] File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1102, in create_connection sock = await self._connect_sock( ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1005, in _connect_sock await self.sock_connect(sock, address) File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 641, in sock_connect return await fut ^^^^^^^^^ File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 681, in _sock_connect_cb raise OSError(err, f'Connect call failed {address}') ConnectionRefusedError: [Errno 111] Connect call failed ('192.168.0.35', 56747)
Logger: homeassistant.helpers.entity Source: helpers/entity.py:951 First occurred: 10:10:22 PM (36 occurrences) Last logged: 10:38:52 PM
Update for select.comfoairq_balance_mode fails Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 951, in async_update_ha_state await self.async_device_update() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1268, in async_device_update await self.async_update() File "/config/custom_components/comfoconnect/select.py", line 199, in async_update self._attr_current_option = await self.entity_description.get_value_fn( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiocomfoconnect/comfoconnect.py", line 323, in get_balance_mode result_06 = await self.cmd_rmi_request(bytes([0x83, UNIT_SCHEDULE, SUBUNIT_06, 0x01])) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiocomfoconnect/bridge.py", line 137, in _send raise AioComfoConnectNotConnected aiocomfoconnect.exceptions.AioComfoConnectNotConnected
Can you please check/share/confirm the versions you use?
I have never seen this:
ConnectionRefusedError: [Errno 111] Connect call failed ('192.168.0.35', 56747)
I would guess your bridge is running an old Firmware, or you have some odd network issues going on?
I have never seen this:
ConnectionRefusedError: [Errno 111] Connect call failed ('192.168.0.35', 56747)
I would guess your bridge is running an old Firmware, or you have some odd network issues going on?
No it is not old firmware.... And no odd network issues that I know off. I'm using all ubiquiti unify network devices. Also the Comfo control app is working flawlessly.
Home Assistant (Synology VM) --> Core 2024.4.1 Zehnder ComfoAirQ integration via HACS --> v0.1.10 ComfoAir Q350 --> Firmware: R1.11.0 (most recent firmware) ComfoConnect LAN C --> Firmware: R1.5.1 (most recent firmware)
I have never seen this:
ConnectionRefusedError: [Errno 111] Connect call failed ('192.168.0.35', 56747)
https://github.com/michaelarnauts/home-assistant-comfoconnect/issues/9#issuecomment-1526189226 last logline
I have never seen this: ConnectionRefusedError: [Errno 111] Connect call failed ('192.168.0.35', 56747)
#9 (comment) last logline
Thanks! But anyway, I have no clue what could be going on. I understand this can be frustrating, but remember I'm just another user like all of you. I don't work for Zehnder and I need to carefully plan the free time I have.
Feel free to experiment with network settings, cable lengths or any other changes you can try to pinpoint the cause. It might even be an idea to contact Zehnder and ask them why the bridge is disconnecting?
What I tried today is replacing the interface cable to the lan c module. I noticed that Zehnder has a specific recommendation on what cable it needs to be. And the cable that I used was not the same. There might have been an instability because of that resulting in unusual errors... Fingers crossed.
@joshuavandermeulen would you be able to capture traffic to/from gateway on your HA interface using tcpdump? It would be great to see, what is going on.
No clue how to do this... First testing the default home assistant integration with the new cable. If that is stable (so far so good) I wil try the hacs integration again and check the logs
My integration is running fine. Fingers crossed.
Some "specs":
Home Assistant (docker) --> Core 2024.4.1 --> Frontend 20240307.0
Zehnder ComfoAirQ integration via HACS --> v0.1.9
ComfoAir Q350 B R ST ERV Prem --> Firmware: R1.11.0 ComfoConnect LAN C --> Firmware: R1.5.1
@litinoveweedle Hope this helps?
How did you update the Q350 firmware? I'm using Q450 SI TR ERV but the latest firmware is R1.10.0
I have a personal Comfoconnect Cloud account to use in the App