Răsfoiți Sursa

fix (light): use the full lower range of light brightness

Tuya lights commonly have a range of 10-1000 for brightness, but due
to rounding error, 13 is the lowest that HA can set it to. When HA is
setting brightness 1, use the minimum rather than the standard HA range
calculation.

Issue #4060
Jason Rumney 2 luni în urmă
părinte
comite
3aadb39a48
1 a modificat fișierele cu 10 adăugiri și 2 ștergeri
  1. 10 2
      custom_components/tuya_local/light.py

+ 10 - 2
custom_components/tuya_local/light.py

@@ -289,7 +289,11 @@ class TuyaLocalLight(TuyaLocalEntity, LightEntity):
                 )
                 r = self._brightness_dps.range(self._device)
                 if r:
-                    bright = color_util.brightness_to_value(r, bright)
+                    # ensure full range is used
+                    if bright == 1 and r[0] != 0:
+                        bright = r[0]
+                    else:
+                        bright = color_util.brightness_to_value(r, bright)
 
                 settings = {
                     **settings,
@@ -448,7 +452,11 @@ class TuyaLocalLight(TuyaLocalEntity, LightEntity):
 
             r = self._brightness_dps.range(self._device)
             if r:
-                bright = color_util.brightness_to_value(r, bright)
+                # ensure full range is used
+                if bright == 1 and r[0] != 0:
+                    bright = r[0]
+                else:
+                    bright = color_util.brightness_to_value(r, bright)
 
             settings = {
                 **settings,