Browse Source

Fixed setting brightness during setting to white color_mode

Jon 2 years ago
parent
commit
c1a6976b0d
1 changed files with 14 additions and 13 deletions
  1. 14 13
      custom_components/tuya_local/light.py

+ 14 - 13
custom_components/tuya_local/light.py

@@ -53,6 +53,7 @@ class TuyaLocalLight(TuyaLocalEntity, LightEntity):
         self._color_temp_dps = dps_map.pop("color_temp", None)
         self._rgbhsv_dps = dps_map.pop("rgbhsv", None)
         self._effect_dps = dps_map.pop("effect", None)
+        self._white_dps = dps_map.pop("white", None)
         self._init_end(dps_map)
 
     @property
@@ -214,19 +215,19 @@ class TuyaLocalLight(TuyaLocalEntity, LightEntity):
         if self._color_mode_dps and ATTR_WHITE in params:
             if self.color_mode != ColorMode.WHITE:
                 color_mode = ColorMode.WHITE
-                if (
-                   ATTR_BRIGHTNESS not in params
-                   and self._brightness_dps
-                 ):
-                   bright = params.get(ATTR_WHITE)
-                   _LOGGER.debug(f"Setting brightness via WHITE parameter to {bright}")
-                   settings = {
-                       **settings,
-                       **self._brightness_dps.get_values_to_set(
-                           self._device,
-                           bright,
-                       ),
-                   }
+            if (
+               ATTR_BRIGHTNESS not in params
+               and self._brightness_dps
+             ):
+                bright = params.get(ATTR_WHITE)
+                _LOGGER.debug(f"Setting brightness via WHITE parameter to {bright}")
+                settings = {
+                    **settings,
+                    **self._brightness_dps.get_values_to_set(
+                        self._device,
+                        bright,
+                    ),
+                }
         elif self._color_temp_dps and ATTR_COLOR_TEMP in params:
             if self.color_mode != ColorMode.COLOR_TEMP:
                 color_mode = ColorMode.COLOR_TEMP