From 25d2c638278594c06e37ae4249882d1913eec5c5 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Wed, 27 Apr 2022 16:17:48 +0200 Subject: [PATCH] Migrate plum_lightpad light to ColorMode (#70880) --- .../components/plum_lightpad/light.py | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/homeassistant/components/plum_lightpad/light.py b/homeassistant/components/plum_lightpad/light.py index f9983135e14..42fdcb538d8 100644 --- a/homeassistant/components/plum_lightpad/light.py +++ b/homeassistant/components/plum_lightpad/light.py @@ -8,8 +8,7 @@ from plumlightpad import Plum from homeassistant.components.light import ( ATTR_BRIGHTNESS, ATTR_HS_COLOR, - SUPPORT_BRIGHTNESS, - SUPPORT_COLOR, + ColorMode, LightEntity, ) from homeassistant.config_entries import ConfigEntry @@ -115,11 +114,16 @@ class PlumLight(LightEntity): return self._brightness > 0 @property - def supported_features(self): + def color_mode(self) -> ColorMode: """Flag supported features.""" if self._load.dimmable: - return SUPPORT_BRIGHTNESS - return 0 + return ColorMode.BRIGHTNESS + return ColorMode.ONOFF + + @property + def supported_color_modes(self) -> set[ColorMode]: + """Flag supported color modes.""" + return {self.color_mode} async def async_turn_on(self, **kwargs): """Turn the light on.""" @@ -136,6 +140,9 @@ class PlumLight(LightEntity): class GlowRing(LightEntity): """Representation of a Plum Lightpad dimmer glow ring.""" + _attr_color_mode = ColorMode.HS + _attr_supported_color_modes = {ColorMode.HS} + def __init__(self, lightpad): """Initialize the light.""" self._lightpad = lightpad @@ -215,11 +222,6 @@ class GlowRing(LightEntity): """Return the crop-portrait icon representing the glow ring.""" return "mdi:crop-portrait" - @property - def supported_features(self): - """Flag supported features.""" - return SUPPORT_BRIGHTNESS | SUPPORT_COLOR - async def async_turn_on(self, **kwargs): """Turn the light on.""" if ATTR_BRIGHTNESS in kwargs: