Skip to content

Commit

Permalink
debug last message received
Browse files Browse the repository at this point in the history
  • Loading branch information
grimmpp committed Feb 14, 2024
1 parent e148fb9 commit 33f8bcf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 24 deletions.
7 changes: 1 addition & 6 deletions custom_components/eltako/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()}")

Expand Down
25 changes: 7 additions & 18 deletions custom_components/eltako/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand All @@ -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()


Expand All @@ -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()


Expand All @@ -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
Expand All @@ -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

Expand All @@ -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."""
Expand All @@ -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()


Expand All @@ -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()


Expand All @@ -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()

0 comments on commit 33f8bcf

Please sign in to comment.