Make sure MQTT light brightness is not rounded to 0 (#35207)
This commit is contained in:
1 parent
94b6130af6
commit
f9b420a5a5
4 files changed
+209
-12
No files matched your search
@@ -732,11 +732,13 @@ class MqttLight(
|
||||
ATTR_BRIGHTNESS in kwargs
|
||||
and self._topic[CONF_BRIGHTNESS_COMMAND_TOPIC] is not None
|
||||
):
|
||||
percent_bright = float(kwargs[ATTR_BRIGHTNESS]) / 255
|
||||
brightness_normalized = kwargs[ATTR_BRIGHTNESS] / 255
|
||||
brightness_scale = self._config[CONF_BRIGHTNESS_SCALE]
|
||||
device_brightness = min(
|
||||
round(percent_bright * brightness_scale), brightness_scale
|
||||
round(brightness_normalized * brightness_scale), brightness_scale
|
||||
)
|
||||
# Make sure the brightness is not rounded down to 0
|
||||
device_brightness = max(device_brightness, 1)
|
||||
mqtt.async_publish(
|
||||
self.hass,
|
||||
self._topic[CONF_BRIGHTNESS_COMMAND_TOPIC],
|
||||
|
||||
Reference in new issue
Block a user