From b97cd2b8e2034f74058d8639a0af3f1843e7d617 Mon Sep 17 00:00:00 2001 From: Kyah Rindlisbacher Date: Mon, 1 May 2023 18:56:14 +1000 Subject: [PATCH 1/2] Update light.py --- custom_components/sengledapi/light.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/sengledapi/light.py b/custom_components/sengledapi/light.py index 9f6f4d9..d1383d8 100755 --- a/custom_components/sengledapi/light.py +++ b/custom_components/sengledapi/light.py @@ -151,7 +151,7 @@ def is_on(self): return self._state @property - def supported_features(self): + def supported_color_modes(self): """Flags Supported Features""" features = 0 if self._support_brightness: From 73f2b4bc714d731fbd7e094abcd612eb9177e5d9 Mon Sep 17 00:00:00 2001 From: Kyah Rindlisbacher Date: Mon, 1 May 2023 20:32:07 +1000 Subject: [PATCH 2/2] Add back support for binary flag features. Fix Enum based color modes to use the correct property name and return the expected set. --- custom_components/sengledapi/light.py | 34 +++++++++++++++++++-------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/custom_components/sengledapi/light.py b/custom_components/sengledapi/light.py index d1383d8..c450ce5 100755 --- a/custom_components/sengledapi/light.py +++ b/custom_components/sengledapi/light.py @@ -11,6 +11,9 @@ ATTR_COLOR_TEMP, ATTR_HS_COLOR, PLATFORM_SCHEMA, + SUPPORT_BRIGHTNESS, + SUPPORT_COLOR_TEMP, + SUPPORT_COLOR, LightEntity, ColorMode, ) @@ -151,22 +154,33 @@ def is_on(self): return self._state @property - def supported_color_modes(self): + def supported_features(self): """Flags Supported Features""" features = 0 if self._support_brightness: - features = ColorMode.BRIGHTNESS - if self._support_color_temp and self._support_brightness: - features = ColorMode.BRIGHTNESS | ColorMode.COLOR_TEMP - if ( - self._support_brightness - and self._support_color_temp - and self._support_color - ): - features = ColorMode.BRIGHTNESS | ColorMode.COLOR_TEMP | ColorMode.HS + features = SUPPORT_BRIGHTNESS + if self._support_color_temp: + features = features | SUPPORT_COLOR_TEMP + if self._support_color: + features = features | SUPPORT_COLOR + _LOGGER.debug("supported_features: %s", features) + return features + + @property + def supported_color_modes(self): + """Flags Supported Features""" + features = set() + if self._support_brightness: + features.add(ColorMode.BRIGHTNESS) + if self._support_color_temp: + features.add(ColorMode.COLOR_TEMP) + if self._support_color: + features.add(ColorMode.HS) + _LOGGER.debug("supported_color_modes: %s", features) return features async def async_turn_on(self, **kwargs): + _LOGGER.debug("turn_on kwargs: %s", kwargs) """Turn on or control the light.""" if ( ATTR_BRIGHTNESS not in kwargs