From 7e2f024e29832eedc3a45143961b05be3e2c6e0f Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Sun, 3 Apr 2022 13:59:27 +0200 Subject: [PATCH] Migrate decora_wifi light to color_mode (#69175) --- homeassistant/components/decora_wifi/light.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/decora_wifi/light.py b/homeassistant/components/decora_wifi/light.py index 03cbe31b336..c2227ed31e1 100644 --- a/homeassistant/components/decora_wifi/light.py +++ b/homeassistant/components/decora_wifi/light.py @@ -14,8 +14,9 @@ from homeassistant.components import persistent_notification from homeassistant.components.light import ( ATTR_BRIGHTNESS, ATTR_TRANSITION, + COLOR_MODE_BRIGHTNESS, + COLOR_MODE_ONOFF, PLATFORM_SCHEMA, - SUPPORT_BRIGHTNESS, SUPPORT_TRANSITION, LightEntity, ) @@ -98,11 +99,23 @@ class DecoraWifiLight(LightEntity): self._switch = switch self._attr_unique_id = switch.serial + @property + def color_mode(self) -> str: + """Return the color mode of the light.""" + if self._switch.canSetLevel: + return COLOR_MODE_BRIGHTNESS + return COLOR_MODE_ONOFF + + @property + def supported_color_modes(self) -> set[str] | None: + """Flag supported color modes.""" + return {self.color_mode} + @property def supported_features(self): """Return supported features.""" if self._switch.canSetLevel: - return SUPPORT_BRIGHTNESS | SUPPORT_TRANSITION + return SUPPORT_TRANSITION return 0 @property