Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

D2CND Gas boiler becomes unavailable after aprox. 2 days #53

Closed
mihsu81 opened this issue Dec 25, 2022 · 11 comments
Closed

D2CND Gas boiler becomes unavailable after aprox. 2 days #53

mihsu81 opened this issue Dec 25, 2022 · 11 comments

Comments

@mihsu81
Copy link
Contributor

mihsu81 commented Dec 25, 2022

Hi @tadasdanielius,
Whenever I enable this integration my D2CND Gas boiler becomes unavailable after aprox. 2 days.
The DRGATEWAYAA won't reply to pings and I'd have to power cycle the boiler to get it working.
Could this happen because the integration pulls data from the gateway every 5 seconds?
Would it be possible to adjust the polling times for various sensors?
Thanks in advance for your help.
image

@tadasdanielius
Copy link
Owner

tadasdanielius commented Dec 25, 2022

This is weird that the device becomes unresponsive. At the moment you can't configure pull times for individual sensors. What you could do is to go config/custom_components/daikin_altherma/const.py and change UPDATE_INTERVAL_SECONDS value. This would affect all sensors.

UPDATE_INTERVAL_SECONDS = 2

Keep in mind if you re-download or upgrade to new release, your modifications will be overwritten and you will have to change again.

@mihsu81
Copy link
Contributor Author

mihsu81 commented Dec 25, 2022

I've changed it to 10 seconds. We'll know in 2 days if it made a difference. 🤞😊
P.S. The file is config/custom_components/daikin_altherma/const.py. Just in case somebody else needs to change some of the values in the future.

@mihsu81
Copy link
Contributor Author

mihsu81 commented Dec 30, 2022

The change to 10 seconds helped. The gateway didn't become unavailable anymore.
I'll continue with a value of 10 seconds for another week. I'll try decreasing the value over time until i find the smallest stable one and report back here.
Would be great if you could modify the integration to have a configurable update value.

@mihsu81
Copy link
Contributor Author

mihsu81 commented Mar 11, 2023

Changing the update interval didn't help in the long run.
I guess the issue has to do with the fact that my boiler is connected over ethernet to an Asus AiMesh node which connects over Wi-Fi to the router where the HA server is connected over ethernet.
Whenever there's a high latency on the Wi-Fi (for various reasons) for a period of time, the boiler's gateway would get "stuck" after a while, stop replying to commands or ICMP packets and would only start working again after I power cycle the boiler.
This only happens when using this integration, not when using the Onecta app, probably because it only connects to the boiler when open.
Would there be any optimisation you could implement in the integration to prevent this issue?

@tadasdanielius
Copy link
Owner

The Onecta app connects directly to the cloud, and the gateway provides data to the cloud at its own discretion. On the other hand, the integration connects directly to the gateway on a regular basis. I can only speculate that the problem might be due to poor connectivity, and perhaps the gateway fails to handle abrupt disconnects properly, resulting in a crash on the gateway side. The gateway can only handle one open websocket connection, so there may be a bug in the gateway that prevents it from cleaning up the "broken" connection and responding to the future requests. Maybe even a memory leak. However, this is just a tentative theory, and I am not certain whether anything can be done to prevent this behavior, as it is not related to the integration itself. Impossible to know if things will go wrong in the middle of the "conversation". Maybe it is worth contacting daikin and report that their gateway might break if the connection is not good.

It may be possible to make some changes to the integration by stopping regular data polling and instead making a service call to request updates. With this approach, using combination of automations, for example before pulling updates, you can ping the device and check if the reply is "good," then request an update. This way, you can control when you want to refresh the settings, but of course the downside of this is that you might see some lag in HA. This also does not guarantee that connection would not be terminated in the middle of the data pulling.

Alternatively, you could explore a Raspberry Pi solution, where the Raspberry Pi would act as a proxy server connected to the same network. However, this would be a different story and beyond the scope of the integration.

@mihsu81
Copy link
Contributor Author

mihsu81 commented Jun 29, 2023

I managed to run a temporary network cable between the router and the Daikin gateway and after a bit more than a week the gateway became unavailable again. I guess it is a bug in the gateway and it can't handle the amount of traffic generated by the websocket.
I'll open a case with Daikin, but based on previous experience they weren't very helpful.
I'll also try again with the increased update interval and see if it makes a difference.

@tadasdanielius
Copy link
Owner

Good luck with Daikin 😄 . I guess other approach could be to disable polling and implement HA service to pull limited data out from the gateway. In that case you could just control whenever you want to pull data with HA and refresh like every minute. Worst case plug some zigbee relay so HA could just turn it off and on again if it detects that device became unavailable.

@mihsu81
Copy link
Contributor Author

mihsu81 commented Jul 15, 2023

Apparently the Asus RT-AX88U Router was causing the issues (even after a factory reset). After replacing it with a RT-AX88U Pro it didn't go offline anymore, still replies to ping and I can controll it with Onecta, but in the integration appears unavailable after a while.
If I try to reload the integration I get the following errors in HA:

This error originated from a custom integration.

Logger: homeassistant.config_entries
Source: custom_components/daikin_altherma/__init__.py:33
Integration: Daikin Altherma HVAC (documentation, issues)
First occurred: 16:03:51 (1 occurrences)
Last logged: 16:03:51

Error setting up entry Daikin HVAC controller (180400597) for daikin_altherma
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 980, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)  # type: ignore[return-value]  # noqa
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 1085, in create_connection
    raise exceptions[0]
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 1069, in create_connection
    sock = await self._connect_sock(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 973, in _connect_sock
    await self.sock_connect(sock, address)
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 634, in sock_connect
    return await fut
           ^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 674, in _sock_connect_cb
    raise OSError(err, f'Connect call failed {address}')
TimeoutError: [Errno 110] Connect call failed ('192.168.45.22', 80)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 390, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/daikin_altherma/__init__.py", line 68, in async_setup_entry
    hass.data[DOMAIN][entry.entry_id] = api = await setup_api_instance(
                                              ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/daikin_altherma/__init__.py", line 33, in setup_api_instance
    await device.discover_units()
  File "/usr/local/lib/python3.11/site-packages/pyaltherma/controllers.py", line 458, in discover_units
    resp_obj = await self._connection.request(dest)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyaltherma/comm.py", line 39, in request
    result = await self._request(dest, payload, wait_for_response, assert_response_fn)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyaltherma/comm.py", line 45, in _request
    await self.connect()
  File "/usr/local/lib/python3.11/site-packages/pyaltherma/comm.py", line 30, in connect
    self._client = await self._session.ws_connect(self.ws_address)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client.py", line 779, in _ws_connect
    resp = await self.request(
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client.py", line 536, in _request
    conn = await self._connector.connect(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 540, in connect
    proto = await self._create_connection(req, traces, timeout)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 901, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 1206, in _create_direct_connection
    raise last_exc
  File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 1175, in _create_direct_connection
    transp, proto = await self._wrap_create_connection(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 988, in _wrap_create_connection
    raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host 192.168.45.22:80 ssl:default [Connect call failed ('192.168.45.22', 80)]

I've also contacted Daikin but didn't get a reply yet.😁

@mihsu81
Copy link
Contributor Author

mihsu81 commented Jul 15, 2023

The issue with the integration not loading while the gateway was pingable, was caused by the running Add-on https://github.com/jaakla/home-assistant-addons/tree/main/daikin, even though I can't remember starting it or setting it to auto-start. 😁 I'll monitor the status and let you know.

@tadasdanielius
Copy link
Owner

This router issue is interesting indeed. I'd suggest reaching out to Asus directly as it appears to be a potential bug with the router firmware.

In addition, it seems that the addon is likely keeping open connection. I've noticed that the gateway accepts only one active connection. Consequently, if one process is already connected, no other process can connect.

For this reason, I've added some additional code to ensure that connection is closed when data isn't being pulled.

@mihsu81
Copy link
Contributor Author

mihsu81 commented Aug 10, 2023

The connection is stable for almost a month now.
Resetting the RT-AX88U using the 30-30-30 method helped making it usable again.
Thanks a lot for all your help.

@mihsu81 mihsu81 closed this as completed Aug 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants