Просмотр исходного кода

fix(light): allow native K color temperature

Color temperature range was only set from target_range.
But in case of lights that use K natively, target_range is
not needed, and we should set it based on range.

PR #4928
Jason Rumney 2 месяцев назад
Родитель
Сommit
d29b478c16
1 измененных файлов с 8 добавлено и 0 удалено
  1. 8 0
      custom_components/tuya_local/light.py

+ 8 - 0
custom_components/tuya_local/light.py

@@ -60,12 +60,20 @@ class TuyaLocalLight(TuyaLocalEntity, LightEntity):
 
         # Set min and max color temp
         if self._color_temp_dps:
+            range_set = False
             m = self._color_temp_dps._find_map_for_dps(0, self._device)
             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")
+                    range_set = True
+            if not range_set:
+                range = self._color_temp_dps.range(self._device)
+                if range:
+                    # For lights that use K natively, use range
+                    self._attr_min_color_temp_kelvin = range[0]
+                    self._attr_max_color_temp_kelvin = range[1]
 
     @property
     def supported_color_modes(self):