max13fr / Airzonecloud-HomeAssistant

Airzone Cloud plugin for Home Assistant
MIT License
28 stars 15 forks source link

Update fails after few minutes #10

Closed mvillarejo closed 3 years ago

mvillarejo commented 3 years ago

Hello, First of all, thank you for making this plugin is an amazing implementation (I started my own but not good at all compared to this one).

Just wanted to report an issue that has started since a few weeks back. My climates are detected properly but after a while, they throw an error and stopped working (having to restart the instance to get them back online).

This is the error I'm getting (note that climate.p1 is the global climate of the floor):

2021-01-07 10:50:58 INFO (SyncWorker_6) [AirzoneCloud.System] Data refreshed for System(name=P1, mode=heat-both, eco=eco-aaa, velocity=None, airflow=None, id=5d2453268b9c2d5511ceaad5, system_number=1, device_id=5c6ae4a04149527d280e0000)
2021-01-07 10:50:58 ERROR (MainThread) [homeassistant.helpers.entity] Update for climate.p1 fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 278, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 474, in async_device_update
    raise exc
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/airzonecloud/climate.py", line 256, in update
    self._azc_system.refresh(True)
  File "/usr/local/lib/python3.8/site-packages/AirzoneCloud/System.py", line 230, in refresh
    self._load_zones()
  File "/usr/local/lib/python3.8/site-packages/AirzoneCloud/System.py", line 247, in _load_zones
    zone._set_data_refreshed(zone_data)
  File "/usr/local/lib/python3.8/site-packages/AirzoneCloud/Zone.py", line 185, in _set_data_refreshed
    _LOGGER.info("Data refreshed for {}".format(self.str_complete))
  File "/usr/local/lib/python3.8/site-packages/AirzoneCloud/Zone.py", line 37, in str_complete
    self.mode,
  File "/usr/local/lib/python3.8/site-packages/AirzoneCloud/Zone.py", line 89, in mode
    return MODES_CONVERTER[self.mode_raw]["name"]
KeyError: 5

after that, any subsequent update of params or function call stopped working, any idea of what's happening?

Cheers, Manuel

mvillarejo commented 3 years ago

I think I managed to get some extra details. Looks like the main issue is related to the fact that the climate that is created to control all the zones, does not contain the 'mode' information and seems that when there's an update on the climate zone devices, it also tries to update the virtual climate from the system.

In my case I have 4 zones so as soon as I modify one of them, zone P1 fails and start throwing all the errors above.

Hope that helps

mvillarejo commented 3 years ago

Only thing I can think of is that the KeyError exception is caused because originally the 'mode_raw' variable is a string and then for some reason it's kind of 'presented' as an integer and therefore the MODES_CONVERTER stop working for the common System climate.

I don't use it that much so I wouldn't mind excluding it if it is possible.

max13fr commented 3 years ago

Hi, sorry for the delay, I lack free time.

Indeed it's strange, API seems to suddenly returning the mode as an integer instead of string.

Just fix it in the last version.

Max