Jelajahi Sumber

fix (light): don't override switch if it is already indirectly set

If a light reuses the switch dp as another setting, it can already be set
in async_turn_on before we process the switch dp. This means the setting
gets overridden by the default "on" value, despite turn_on was called
with an argument that might be setting it to a different value.

Example: a light has a single dp with "off", "warm", "cold". It is set
with "cold" as the default on value, but the user wants to turn it on
as warm so gives the 2700K color_temp as a parameter to turn_on.

PR #4398
Jason Rumney 5 hari lalu
induk
melakukan
d4f835b66e
1 mengubah file dengan 1 tambahan dan 1 penghapusan
  1. 1 1
      custom_components/tuya_local/light.py

+ 1 - 1
custom_components/tuya_local/light.py

@@ -480,7 +480,7 @@ class TuyaLocalLight(TuyaLocalEntity, LightEntity):
                     ),
                 }
 
-        if self._switch_dps and not self.is_on:
+        if self._switch_dps and not self.is_on and self._switch_dps.id not in settings:
             if (
                 self._switch_dps.readonly
                 and self._effect_dps