mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Fix velbus dimming control (#33139)
* Fix light control * Optimize conversion logic
This commit is contained in:
parent
3f4a7ec396
commit
46985bba0d
@ -64,7 +64,7 @@ class VelbusLight(VelbusEntity, Light):
|
|||||||
@property
|
@property
|
||||||
def brightness(self):
|
def brightness(self):
|
||||||
"""Return the brightness of the light."""
|
"""Return the brightness of the light."""
|
||||||
return self._module.get_dimmer_state(self._channel)
|
return int((self._module.get_dimmer_state(self._channel) * 255) / 100)
|
||||||
|
|
||||||
def turn_on(self, **kwargs):
|
def turn_on(self, **kwargs):
|
||||||
"""Instruct the Velbus light to turn on."""
|
"""Instruct the Velbus light to turn on."""
|
||||||
@ -80,10 +80,15 @@ class VelbusLight(VelbusEntity, Light):
|
|||||||
attr, *args = "set_led_state", self._channel, "on"
|
attr, *args = "set_led_state", self._channel, "on"
|
||||||
else:
|
else:
|
||||||
if ATTR_BRIGHTNESS in kwargs:
|
if ATTR_BRIGHTNESS in kwargs:
|
||||||
|
# Make sure a low but non-zero value is not rounded down to zero
|
||||||
|
if kwargs[ATTR_BRIGHTNESS] == 0:
|
||||||
|
brightness = 0
|
||||||
|
else:
|
||||||
|
brightness = max(int((kwargs[ATTR_BRIGHTNESS] * 100) / 255), 1)
|
||||||
attr, *args = (
|
attr, *args = (
|
||||||
"set_dimmer_state",
|
"set_dimmer_state",
|
||||||
self._channel,
|
self._channel,
|
||||||
kwargs[ATTR_BRIGHTNESS],
|
brightness,
|
||||||
kwargs.get(ATTR_TRANSITION, 0),
|
kwargs.get(ATTR_TRANSITION, 0),
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user