فهرست منبع

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 ماه پیش
والد
کامیت
3aadb39a48
1فایلهای تغییر یافته به همراه10 افزوده شده و 2 حذف شده
  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)
                 r = self._brightness_dps.range(self._device)
                 if r:
                 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 = {
                     **settings,
                     **settings,
@@ -448,7 +452,11 @@ class TuyaLocalLight(TuyaLocalEntity, LightEntity):
 
 
             r = self._brightness_dps.range(self._device)
             r = self._brightness_dps.range(self._device)
             if r:
             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 = {
                 **settings,
                 **settings,