From 33f8bcf66423590398132c41c3454ac60a8ac72f Mon Sep 17 00:00:00 2001 From: Philipp Grimm Date: Wed, 14 Feb 2024 01:27:22 +0100 Subject: [PATCH] debug last message received --- custom_components/eltako/device.py | 7 +------ custom_components/eltako/light.py | 25 +++++++------------------ 2 files changed, 8 insertions(+), 24 deletions(-) diff --git a/custom_components/eltako/device.py b/custom_components/eltako/device.py index 24d26e19..8a50a5bb 100644 --- a/custom_components/eltako/device.py +++ b/custom_components/eltako/device.py @@ -121,9 +121,7 @@ def load_value_initially(self, latest_state:State): elif hasattr(self, '_attr_is_on'): self._attr_is_on = 'on' == latest_state.state - super(self,BinarySensorEntity).self._attr_state = latest_state.state - super(self,Entity).self._attr_state = latest_state.state - + elif attributs.get('state_class', None) == 'measurement': if '.' in latest_state.state: self._attr_native_value = float(latest_state.state) @@ -151,9 +149,6 @@ def load_value_initially(self, latest_state:State): LOGGER.debug(f"[device] latest state - _attr_state {self._attr_state}") LOGGER.debug(f"[device] latest state - state {self.state}") - LOGGER.debug(f"[device] latest state - super().state {super().state}") - if isinstance(self, BinarySensorEntity): - LOGGER.debug(f"[device] latest state - super(BinarySensorEntity).state {super(BinarySensorEntity,self).state}") LOGGER.debug(f"properties: {self.__dict__.keys()}") diff --git a/custom_components/eltako/light.py b/custom_components/eltako/light.py index 4d496d5c..65113bcb 100644 --- a/custom_components/eltako/light.py +++ b/custom_components/eltako/light.py @@ -68,15 +68,9 @@ class EltakoDimmableLight(EltakoEntity, LightEntity): def __init__(self, platform:str, gateway: EnOceanGateway, dev_id: AddressExpression, dev_name: str, dev_eep: EEP, sender_id: AddressExpression, sender_eep: EEP): """Initialize the Eltako light source.""" super().__init__(platform, gateway, dev_id, dev_name, dev_eep) - self._on_state = False - self._attr_brightness = 50 self._sender_id = sender_id self._sender_eep = sender_eep - @property - def is_on(self): - """If light is on.""" - return self._on_state def turn_on(self, **kwargs: Any) -> None: """Turn the light source on or sets a specific dimmer value.""" @@ -90,7 +84,7 @@ def turn_on(self, **kwargs: Any) -> None: self.send_message(msg) if self.general_settings[CONF_FAST_STATUS_CHANGE]: - self._on_state = True + self._attr_is_on = True self.schedule_update_ha_state() @@ -105,7 +99,7 @@ def turn_off(self, **kwargs: Any) -> None: if self.general_settings[CONF_FAST_STATUS_CHANGE]: self._attr_brightness = 0 - self._on_state = False + self._attr_is_on = False self.schedule_update_ha_state() @@ -131,7 +125,7 @@ def value_changed(self, msg): if decoded.switching.learn_button != 1: return - self._on_state = decoded.switching.switching_command + self._attr_is_on = decoded.switching.switching_command elif decoded.command == 0x02: if decoded.dimming.learn_button != 1: return @@ -141,7 +135,7 @@ def value_changed(self, msg): elif decoded.dimming.dimming_range == 1: self._attr_brightness = decoded.dimming.dimming_value - self._on_state = decoded.dimming.switching_command + self._attr_is_on = decoded.dimming.switching_command else: return @@ -157,14 +151,9 @@ class EltakoSwitchableLight(EltakoEntity, LightEntity): def __init__(self, platform: str, gateway: EnOceanGateway, dev_id: AddressExpression, dev_name: str, dev_eep: EEP, sender_id: AddressExpression, sender_eep: EEP): """Initialize the Eltako light source.""" super().__init__(platform, gateway, dev_id, dev_name, dev_eep) - self._on_state = False self._sender_id = sender_id self._sender_eep = sender_eep - @property - def is_on(self): - """If light is on.""" - return self._on_state def turn_on(self, **kwargs: Any) -> None: """Turn the light source on or sets a specific dimmer value.""" @@ -176,7 +165,7 @@ def turn_on(self, **kwargs: Any) -> None: self.send_message(msg) if self.general_settings[CONF_FAST_STATUS_CHANGE]: - self._on_state = True + self._attr_is_on = True self.schedule_update_ha_state() @@ -190,7 +179,7 @@ def turn_off(self, **kwargs: Any) -> None: self.send_message(msg) if self.general_settings[CONF_FAST_STATUS_CHANGE]: - self._on_state = False + self._attr_is_on = False self.schedule_update_ha_state() @@ -203,5 +192,5 @@ def value_changed(self, msg): return if self.dev_eep in [M5_38_08]: - self._on_state = decoded.state + self._attr_is_on = decoded.state self.schedule_update_ha_state()