4
0
Эх сурвалжийг харах

Light: silently handle out of range color_temp

Discussion #1259
Jason Rumney 2 жил өмнө
parent
commit
0b0bc97973

+ 7 - 0
custom_components/tuya_local/light.py

@@ -249,6 +249,13 @@ class TuyaLocalLight(TuyaLocalEntity, LightEntity):
                 color_mode = ColorMode.COLOR_TEMP
 
             color_temp = params.get(ATTR_COLOR_TEMP_KELVIN)
+            # Light groups use the widest range from the lights in the
+            # group, so we are expected to silently handle out of range values
+            if color_temp < self.min_color_temp_kelvin:
+                color_temp = self.min_color_temp_kelvin
+            if color_temp > self.max_color_temp_kelvin:
+                color_temp = self.max_color_temp_kelvin
+
             _LOGGER.debug("Setting color temp to %d", color_temp)
             settings = {
                 **settings,