jnimmo/hass-intesishome

Error on device update!

Opened this issue · 2 comments

When adding my airconwithme account only 1 of the 2 connected units is showed within this integration. And when I look in the logs I noticed the folowing error:

intesishome: Error on device update!Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 570, in _async_add_entity await entity.async_device_update(warning=False) File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 940, in async_device_update await self.async_update() File "/config/custom_components/intesishome/climate.py", line 358, in async_update self._current_temp = self._controller.get_temperature(self._device_id) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/pyintesishome/intesisbase.py", line 403, in get_temperature temperature = self.get_device_property(device_id, "temperature") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/pyintesishome/intesisbase.py", line 193, in get_device_property return self._devices[str(device_id)].get(property_name) ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^ KeyError: '224571441711392'

I've rebooted HA a couple of times, removed and readded the integration, the account, etc. But now effect. Every time the same device is not listed in the entity list for this integration. With the built-in plugin for IntesisHome the second unit did work.

Any suggestion on where to look at?

I had the same issue today with my intensishome account (although I can't remember having this earlier). I debugged a lot and saw that somewhere in the initialization the first device is created, updated, then added to HA and then connected to the API. The second device gets updated before the first one is connected to the API and somehow, the device list of the controller is empty then, resulting in the above error.

What fixed it for me is disabling the update before add function by changing the following in custom_components\intensishome\climate.py

if ih_devices := controller.get_devices():
        async_add_entities(
            [
                IntesisAC(ih_device_id, device, controller)
                for ih_device_id, device in ih_devices.items()
            ],
            update_before_add=True,
        )

Into

if ih_devices := controller.get_devices():
        async_add_entities(
            [
                IntesisAC(ih_device_id, device, controller)
                for ih_device_id, device in ih_devices.items()
            ],
            update_before_add=False,
        )

After adding each device to HA, each device is connected to the API and gets updated when the API is called, so no need for the update before add anyway.

Just wanted to note that this didn't hurt, but it didn't help either unfortunately.