Explorar o código

Light: silently handle out of range color_temp

Discussion #1259
Jason Rumney %!s(int64=2) %!d(string=hai) anos
pai
achega
0b0bc97973
Modificáronse 1 ficheiros con 7 adicións e 0 borrados
  1. 7 0
      custom_components/tuya_local/light.py

+ 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,