From c28fac70108a38e86f3c7e6a7ab471b137874682 Mon Sep 17 00:00:00 2001 From: Maarten Weyns Date: Tue, 15 Dec 2020 20:09:10 +0100 Subject: [PATCH 1/2] This makes lights smoothly fade from one state to a new state, without the intermediate "turn off" --- custom_components/localtuya/light.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/custom_components/localtuya/light.py b/custom_components/localtuya/light.py index d929286..5f34ead 100644 --- a/custom_components/localtuya/light.py +++ b/custom_components/localtuya/light.py @@ -284,7 +284,8 @@ class LocaltuyaLight(LocalTuyaEntity, LightEntity): async def async_turn_on(self, **kwargs): """Turn on or control the light.""" states = {} - states[self._dp_id] = True + if not self.is_on: + states[self._dp_id] = True features = self.supported_features brightness = None if ATTR_EFFECT in kwargs and (features & SUPPORT_EFFECT): From a6e8f282c57a9f0076b6ae545251fe5de3f1b3e7 Mon Sep 17 00:00:00 2001 From: Maarten Weyns Date: Tue, 15 Dec 2020 20:11:34 +0100 Subject: [PATCH 2/2] Fixed editor line indentation --- custom_components/localtuya/light.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/custom_components/localtuya/light.py b/custom_components/localtuya/light.py index 5f34ead..b419909 100644 --- a/custom_components/localtuya/light.py +++ b/custom_components/localtuya/light.py @@ -284,8 +284,8 @@ class LocaltuyaLight(LocalTuyaEntity, LightEntity): async def async_turn_on(self, **kwargs): """Turn on or control the light.""" states = {} - if not self.is_on: - states[self._dp_id] = True + if not self.is_on: + states[self._dp_id] = True features = self.supported_features brightness = None if ATTR_EFFECT in kwargs and (features & SUPPORT_EFFECT):