Skip to content

Commit bb2a9d2

Browse files
committed
Bug fix: handle dimmer value before turn off in ramp events
1 parent 41bcc46 commit bb2a9d2

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

inelsmqtt/devices/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,10 @@ def set_ha_value(self, value: Any) -> bool:
314314
last_value=LastHAValue(self.__values.ha_value if self.__values else None),
315315
)
316316

317-
# self.__state = dev.ha_value
318-
# self.__values = dev
317+
# This is a workaround to the last value before turn off since ramp increments are built into mqtt events
318+
if hasattr(value, 'light_coa_toa'):
319+
self.__state = dev.ha_value
320+
self.__values = dev
319321

320322
ret = False
321323
if self.__set_topic is not None:

inelsmqtt/protocols/cu3.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1664,6 +1664,7 @@ def create_ha_value_object(cls, device_value: DeviceValue) -> Any:
16641664
light_coa_toa.append(
16651665
LightCoaToa(
16661666
brightness=out[i],
1667+
brightness_before_off=device_value.last_value.ha_value.light_coa_toa[i].brightness_before_off if device_value.last_value else 0,
16671668
toa=toa[i],
16681669
coa=coa[i],
16691670
)

inelsmqtt/utils/common.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,10 @@ class Shutter_pos(Shutter):
4949
set_pos: bool
5050

5151

52-
@dataclass
52+
@dataclass(kw_only=True)
5353
class SimpleLight:
54-
brightness: int
54+
brightness: int = 0
55+
brightness_before_off: Optional[int] = None
5556

5657

5758
@dataclass

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
setup(
66
name="elkoep-mqtt",
7-
version="0.2.33.beta.22",
7+
version="0.2.33.beta.23",
88
url="https://github.com/epdevlab/elkoep-mqtt",
99
license="MIT",
1010
author="Elko EP s.r.o.",

0 commit comments

Comments
 (0)