Преглед изворни кода

fix(light): allow reversed target range for min and max color temperature

Some lights have reversed color temperature. Target range is designed to handle this
without needing a separate invert directive, but the light entity was directly using
the target range min and max values as min and max color temperature, so inverting
them to reverse the range was resulting in an incorrect min and max setting sent to
HA.

Issue #6111
Jason Rumney пре 1 дан
родитељ
комит
05abfe9170
1 измењених фајлова са 3 додато и 2 уклоњено
  1. 3 2
      custom_components/tuya_local/light.py

+ 3 - 2
custom_components/tuya_local/light.py

@@ -74,8 +74,9 @@ class TuyaLocalLight(TuyaLocalEntity, LightEntity):
             if m:
                 tr = m.get("target_range")
                 if tr:
-                    self._attr_min_color_temp_kelvin = tr.get("min")
-                    self._attr_max_color_temp_kelvin = tr.get("max")
+                    # Target range can be inverted, so use min/max functions to ensure correct order
+                    self._attr_min_color_temp_kelvin = min(tr.get("min"), tr.get("max"))
+                    self._attr_max_color_temp_kelvin = max(tr.get("min"), tr.get("max"))
                     range_set = True
             if not range_set:
                 r = self._color_temp_dps.range(self._device)