Aohzan / ipx800

IPX800 V4 integration for Home-Assistant
Apache License 2.0
20 stars 12 forks source link

Error DataUpdateCoordinator.async_refresh #55

Open S1M8N opened 1 month ago

S1M8N commented 1 month ago

Describe the bug Hey Aohzan

Sometimes when I try to turn on/off my switch in my HA, My IPX800v4 dosen't return states to my HA.

The consequences of that is that my switches states on my IPX800v4 look "ON" and the switches on my HA look "OFF"

After that I have this error logs :

Error logs

Enregistreur: custom_components.ipx800v4
Source: helpers/debounce.py:137
intégration: GCE IPX800 V4 ([documentation](https://github.com/Aohzan/ipx800), [problèmes](https://github.com/Aohzan/ipx800/issues))
S'est produit pour la première fois: 21:53:19 (16 occurrences)
Dernier enregistrement: 21:55:15
Unexpected exception from <bound method DataUpdateCoordinator.async_refresh of <homeassistant.helpers.update_coordinator.DataUpdateCoordinator object at 0x7f1332bf8590>>

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/debounce.py", line 137, in _handle_timer_finish
    await task
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 288, in async_refresh
    await self._async_refresh(log_failures=True)
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 411, in _async_refresh
    self.async_update_listeners()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 165, in async_update_listeners
    update_callback()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 491, in _handle_coordinator_update
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1007, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1133, in _async_write_ha_state
    state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1068, in __async_calculate_state
    state = self._stringify_state(available)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1013, in _stringify_state
    if (state := self.state) is None:
                 ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 533, in state
    value = self.native_value
            ^^^^^^^^^^^^^^^^^
  File "/config/custom_components/ipx800v4/sensor.py", line 124, in native_value
    return self.coordinator.data[f"VA{self._id}"]
           ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
KeyError: 'VA29'

Thank you in advance

Aohzan commented 1 month ago

Hello This is a known issue that the IPX doens't return the state of all entities so it raise errors on all the integration It can happen when you query too much the IPX