From 54bb86d198317f4dd59cd12ff73b1719adbc90b9 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Thu, 7 Apr 2022 09:58:50 +0200 Subject: [PATCH] Migrate upb light to color_mode (#69524) * Migrate upb light to color_mode * Add supported_color_modes * Apply code review --- homeassistant/components/upb/light.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/upb/light.py b/homeassistant/components/upb/light.py index 1ed1e788936..609bf0f0e32 100644 --- a/homeassistant/components/upb/light.py +++ b/homeassistant/components/upb/light.py @@ -3,7 +3,8 @@ from homeassistant.components.light import ( ATTR_BRIGHTNESS, ATTR_FLASH, ATTR_TRANSITION, - SUPPORT_BRIGHTNESS, + COLOR_MODE_BRIGHTNESS, + COLOR_MODE_ONOFF, SUPPORT_FLASH, SUPPORT_TRANSITION, LightEntity, @@ -55,11 +56,23 @@ class UpbLight(UpbAttachedEntity, LightEntity): super().__init__(element, unique_id, upb) self._brightness = self._element.status + @property + def color_mode(self) -> str: + """Return the color mode of the light.""" + if self._element.dimmable: + return COLOR_MODE_BRIGHTNESS + return COLOR_MODE_ONOFF + + @property + def supported_color_modes(self) -> set[str]: + """Flag supported color modes.""" + return {self.color_mode} + @property def supported_features(self): """Flag supported features.""" if self._element.dimmable: - return SUPPORT_BRIGHTNESS | SUPPORT_TRANSITION | SUPPORT_FLASH + return SUPPORT_TRANSITION | SUPPORT_FLASH return SUPPORT_FLASH @property