瀏覽代碼

light: color_mode. Don't do mired conversion on non-numeric values

Avoid an exception in color_mode due to mired conversion, which occurs even
when the value is not inverted.
Jason Rumney 3 年之前
父節點
當前提交
23ed078ecb
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      custom_components/tuya_local/generic/light.py

+ 1 - 1
custom_components/tuya_local/generic/light.py

@@ -95,7 +95,7 @@ class TuyaLocalLight(TuyaLocalEntity, LightEntity):
         if self._color_temp_dps:
             unscaled = self._color_temp_dps.get_value(self._device)
             r = self._color_temp_dps.range(self._device)
-            if r:
+            if r and isinstance(unscaled, (int, float)):
                 return round(unscaled * 347 / (r["max"] - r["min"]) + 153 - r["min"])
             else:
                 return unscaled