From 5a9b3f73f52381a17b18750bcb992867c3c9108a Mon Sep 17 00:00:00 2001 From: Philipp Grimm Date: Thu, 15 Feb 2024 16:20:52 +0100 Subject: [PATCH] debug eneity key error --- custom_components/eltako/binary_sensor.py | 4 ++-- custom_components/eltako/device.py | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/custom_components/eltako/binary_sensor.py b/custom_components/eltako/binary_sensor.py index 667c47a..7126a02 100644 --- a/custom_components/eltako/binary_sensor.py +++ b/custom_components/eltako/binary_sensor.py @@ -244,12 +244,12 @@ class GatewayConnectionState(AbstractBinarySensor): """Protocols last time when message received""" def __init__(self, platform: str, gateway: EnOceanGateway): - description_key = "Gateway_Connection_State" + self.description_key = "Gateway_Connection_State" self._attr_icon = "mdi:connection" self._attr_name = "Connected" - super().__init__(platform, gateway, gateway.base_id, dev_name="Connected", description_key=description_key) + super().__init__(platform, gateway, gateway.base_id, dev_name="Connected") self.gateway.set_connection_state_changed_handler(self.async_value_changed) @property diff --git a/custom_components/eltako/device.py b/custom_components/eltako/device.py index bf431d3..12f5368 100644 --- a/custom_components/eltako/device.py +++ b/custom_components/eltako/device.py @@ -22,7 +22,7 @@ class EltakoEntity(Entity): """Parent class for all entities associated with the Eltako component.""" - def __init__(self, platform: str, gateway: EnOceanGateway, dev_id: AddressExpression, dev_name: str="Device", dev_eep: EEP=None, description_key:str=None): + def __init__(self, platform: str, gateway: EnOceanGateway, dev_id: AddressExpression, dev_name: str="Device", dev_eep: EEP=None): """Initialize the device.""" self._attr_has_entity_name = True self._attr_should_poll = True @@ -36,7 +36,7 @@ def __init__(self, platform: str, gateway: EnOceanGateway, dev_id: AddressExpres self._attr_dev_eep = dev_eep self.listen_to_addresses = [] self.listen_to_addresses.append(self.dev_id[0]) - self.description_key = self._get_description_key(description_key) + self.description_key = self._get_description_key() self._attr_unique_id = EltakoEntity._get_identifier(self.gateway, self.dev_id, self.description_key) # self._attr_identifier = EltakoEntity._get_identifier(self.gateway, self.dev_id, self._get_description_key()) self.entity_id = f"{self._attr_ha_platform}.{self._attr_unique_id}" @@ -62,6 +62,7 @@ def _get_description_key(self, description_key:str=None): if hasattr(self, 'entity_description') and self.entity_description is not None: if self.description_key is None: self.description_key = self.entity_description.key + return self.description_key @property