jontofront / ecoNET-300-Home-Assistant-Integration

ecoNET 300 integration to HA
11 stars 2 forks source link

Fix binary sensor issue #48

Closed denpamusic closed 11 months ago

denpamusic commented 11 months ago

Fixes the issue with binary sensor when coordinator object of type EconetDataCoordinator being replaced with it's data of type dict[str, Any] here and then passed to the EconetBinarySensor here which leads to the following errors in the log.

This resolves the issue by iterating over the coordinator data in the same way as it was done in sensor.py.

homeassistant.log ``` 2023-12-24 02:44:15.293 ERROR (MainThread) [homeassistant.components.binary_sensor] Error adding entities for domain binary_sensor with platform econet300 Traceback (most recent call last): File "/home/denpa/hass/core/homeassistant/helpers/entity_platform.py", line 509, in async_add_entities await asyncio.gather(*tasks) File "/home/denpa/hass/core/homeassistant/helpers/entity_platform.py", line 754, in _async_add_entity await entity.add_to_platform_finish() File "/home/denpa/hass/core/homeassistant/helpers/entity.py", line 1024, in add_to_platform_finish await self.async_added_to_hass() File "/home/denpa/hass/core/config/custom_components/econet300/entity.py", line 66, in async_added_to_hass if self.coordinator.data[self.entity_description.key] is None: ^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'dict' object has no attribute 'data' 2023-12-24 02:44:15.301 ERROR (MainThread) [homeassistant.components.binary_sensor] Error while setting up econet300 platform for binary_sensor Traceback (most recent call last): File "/home/denpa/hass/core/homeassistant/helpers/entity_platform.py", line 369, in _async_setup_platform await asyncio.gather(*pending) File "/home/denpa/hass/core/homeassistant/helpers/entity_platform.py", line 509, in async_add_entities await asyncio.gather(*tasks) File "/home/denpa/hass/core/homeassistant/helpers/entity_platform.py", line 754, in _async_add_entity await entity.add_to_platform_finish() File "/home/denpa/hass/core/homeassistant/helpers/entity.py", line 1024, in add_to_platform_finish await self.async_added_to_hass() File "/home/denpa/hass/core/config/custom_components/econet300/entity.py", line 66, in async_added_to_hass if self.coordinator.data[self.entity_description.key] is None: ^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'dict' object has no attribute 'data' ```