mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 10:17:09 +00:00
Keep previous brightness of dimming zwave light upon turning it on/off (#5160)
* Keep previous brightness of dimming zwave light upon turning it on/off * Fix initialization * Use value 255 to set dimmer to previous value
This commit is contained in:
parent
21f59a0732
commit
a0a9f26312
@ -79,7 +79,7 @@ def brightness_state(value):
|
|||||||
if value.data > 0:
|
if value.data > 0:
|
||||||
return (value.data / 99) * 255, STATE_ON
|
return (value.data / 99) * 255, STATE_ON
|
||||||
else:
|
else:
|
||||||
return 255, STATE_OFF
|
return 0, STATE_OFF
|
||||||
|
|
||||||
|
|
||||||
class ZwaveDimmer(zwave.ZWaveDeviceEntity, Light):
|
class ZwaveDimmer(zwave.ZWaveDeviceEntity, Light):
|
||||||
@ -165,12 +165,13 @@ class ZwaveDimmer(zwave.ZWaveDeviceEntity, Light):
|
|||||||
|
|
||||||
def turn_on(self, **kwargs):
|
def turn_on(self, **kwargs):
|
||||||
"""Turn the device on."""
|
"""Turn the device on."""
|
||||||
|
# Zwave multilevel switches use a range of [0, 99] to control
|
||||||
|
# brightness. Level 255 means to set it to previous value.
|
||||||
if ATTR_BRIGHTNESS in kwargs:
|
if ATTR_BRIGHTNESS in kwargs:
|
||||||
self._brightness = kwargs[ATTR_BRIGHTNESS]
|
self._brightness = kwargs[ATTR_BRIGHTNESS]
|
||||||
|
brightness = int((self._brightness / 255) * 99)
|
||||||
# Zwave multilevel switches use a range of [0, 99] to control
|
else:
|
||||||
# brightness.
|
brightness = 255
|
||||||
brightness = int((self._brightness / 255) * 99)
|
|
||||||
|
|
||||||
if self._value.node.set_dimmer(self._value.value_id, brightness):
|
if self._value.node.set_dimmer(self._value.value_id, brightness):
|
||||||
self._state = STATE_ON
|
self._state = STATE_ON
|
||||||
|
Loading…
x
Reference in New Issue
Block a user