jwillemsen / daikin_onecta

Home Assistant Integration for devices supported by the Daikin Onecta App
https://github.com/jwillemsen/daikin_onecta
GNU General Public License v3.0
295 stars 9 forks source link

[Issue]: Issue to Set temperature with last update #43

Closed GroGerome closed 9 months ago

GroGerome commented 9 months ago

Hi, Here is an issue I get probably due to the new rate limitation by Daikin. I have 4 AC unit on the plugin.

While I set up the temperature on one of the unit it sometimes fail as I guess it is too close in time to the previous API call, if I retry a litlle time later it is working. When it fail, HA go back to the current setting and never try again later. As a first tried I've created automatic retry but this morning none of the call are working, I think that I went over the limit with the amount of retry.

I think we should aim at the addon "accepting" the thermostat change so HA believe it is done and send the API call a bit later on when the rate allow it.

jwillemsen commented 9 months ago

I made a change about an hour ago to log the limite when receiving a response from daikin, please update to the latest on master, and retry, check the logs whether the limits are problematic

GroGerome commented 9 months ago

Here is what the log show (just updated the plugin):

`Logger: homeassistant.components.websocket_api.http.connection
Source: components/websocket_api/commands.py:240
Integration: Home Assistant WebSocket API ([documentation](https://www.home-assistant.io/integrations/websocket_api), [issues](https://github.com/home-assistant/core/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+websocket_api%22))
First occurred: 5:33:24 PM (5 occurrences)
Last logged: 5:33:45 PM

[140371947290304] Communication failed! Status: 429
[140371943991232] Communication failed! Status: 429
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/homeassistant/components/websocket_api/commands.py", line 240, in handle_call_service
    response = await hass.services.async_call(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/homeassistant/core.py", line 2279, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/homeassistant/core.py", line 2316, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/service.py", line 892, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/service.py", line 962, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/homeassistant/components/climate/__init__.py", line 835, in async_service_temperature_set
    await entity.async_set_temperature(**kwargs)
  File "/config/custom_components/daikin_residential_altherma/climate.py", line 311, in async_set_temperature
    res = await self._device.set_path(self._device.getId(), self.embedded_id, "temperatureControl", f"/operationModes/{omv}/setpoints/{self._setpoint}", value)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/daikin_residential_altherma/device.py", line 125, in set_path
    res = await self.api.doBearerRequest(setPath, setOptions)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/daikin_residential_altherma/daikin_api.py", line 105, in doBearerRequest
    raise Exception("Communication failed! Status: " + str(res.status_code))
Exception: Communication failed! Status: 429`

I further investigate what's happen on my system. It looks to be when all my AC are changing at the same time or if two changes are close to each other. I believe that with the 4 units, when my automation are switching the temp all at the same time, (like when I activate my away mode), I have a chance of hitting th 6calls/minute limit as I'm doing already 4 for just the temp settings.

I'll try to unsync my automation and see if it help.

jwillemsen commented 9 months ago

Please enable the debug logging, see readme

GroGerome commented 9 months ago

The config line is in my config yaml and that's all I have unless I need to go somewhere else to read it?

jwillemsen commented 9 months ago

You need to press the load full log button, the page shows warning/error by default, we need debug/info also

GroGerome commented 9 months ago

You can find the full log here. It is quite hard to filter. At 1:41 I get for the last time the rate limit: LIMIT: remaining minute 5 day 66 According to value in HA that seems to be the last time my sensors value updated. At 01:51:31.605 I get my first error during the night since then I get no answer. I've left a big part of the log as maybe you can see something. I can share more if you need.

https://www.dropbox.com/scl/fi/37wlkpz5gf62ex8jr7fix/home-assistant_2024-02-19T06-30-55.606Z.log?rlkey=4ioa62byi8qvu5yvxnvfyyb2b&dl=0

This morning I removed / reinstall the addon and got it back working

2024-02-19 08:06:48.615 INFO (MainThread) [custom_components.daikin_residential_altherma.config_flow] Successfully authenticated 2024-02-19 08:06:48.616 DEBUG (MainThread) [custom_components.daikin_residential_altherma.daikin_api] Initialing Daikin Residential Altherma API... 2024-02-19 08:06:48.616 INFO (MainThread) [custom_components.daikin_residential_altherma.daikin_api] Daikin Residential Altherma API initialized. 2024-02-19 08:06:48.616 DEBUG (MainThread) [custom_components.daikin_residential_altherma.daikin_api] BEARER REQUEST URL: https://api.onecta.daikineurope.com/v1/gateway-devices 2024-02-19 08:06:49.127 DEBUG (MainThread) [custom_components.daikin_residential_altherma.daikin_api] BEARER RESPONSE CODE: 200 LIMIT: remaining minute 5 day 101 MAX: minute 6 day 200 2024-02-19 08:06:49.129 INFO (MainThread) [custom_components.daikin_residential_altherma.device] Initialized Daikin Residential Device 'Clim Chambre' (id ) 2024-02-19 08:06:49.130 INFO (MainThread) [custom_components.daikin_residential_altherma.device] Initialized Daikin Residential Device 'Clim Salon' (id ) 2024-02-19 08:06:49.130 INFO (MainThread) [custom_components.daikin_residential_altherma.device] Initialized Daikin Residential Device 'Clim Bureau' (id ) 2024-02-19 08:06:49.130 INFO (MainThread) [custom_components.daikin_residential_altherma.device] Initialized Daikin Residential Device 'Clim Atelier' (id )

jwillemsen commented 9 months ago

At 2024-02-19 01:51:31.605 the token refresh failed, very strange as it seems to have worked a few times

jwillemsen commented 9 months ago

I think we should aim at the addon "accepting" the thermostat change so HA believe it is done and send the API call a bit later on when the rate allow it.

Adding such support would be a lot of work but also could have other unwanted side effects. What when there are multiple updates for the same device are in the queue, can we skip some, or not. At the end the user doesn't see a reaction of his physical device so he starts sending more and more commands, making it even more complex.

It would really help when the minute rate limit is per device, maybe something @Daikin-Europe could look at.

jwillemsen commented 9 months ago

I am going to close this issue, nothing really I can do about it, the rate limitation is defined by @Daikin-Europe.