Browse Source

Use brightness to turn on light when there is no other way.

We used to have this feature, but it was lost in some of the refactoring,
I think when a light that did not support turning off was added.

Note though that the light will always come on at full brightness if we
rely on the brightness control to turn on and off.

Should solve the issue mentioned in PR #743
Jason Rumney 2 years ago
parent
commit
0d28a347af
1 changed files with 4 additions and 0 deletions
  1. 4 0
      custom_components/tuya_local/light.py

+ 4 - 0
custom_components/tuya_local/light.py

@@ -364,6 +364,10 @@ class TuyaLocalLight(TuyaLocalEntity, LightEntity):
                 settings = settings | self._switch_dps.get_values_to_set(
                 settings = settings | self._switch_dps.get_values_to_set(
                     self._device, True
                     self._device, True
                 )
                 )
+        elif self._brightness_dps and not self.is_on:
+            settings = settings | self._brightness_dps.get_values_to_set(
+                self._device, 255
+            )
 
 
         if settings:
         if settings:
             await self._device.async_set_properties(settings)
             await self._device.async_set_properties(settings)