Explorar el Código

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 hace 7 meses
padre
commit
3aadb39a48
Se han modificado 1 ficheros con 10 adiciones y 2 borrados
  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,