From 8ee9695e3befe32eef9da362660dcf0d2167a139 Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Mon, 4 Apr 2022 10:53:06 +0200 Subject: [PATCH] Migrate control4 light to color_mode (#69079) --- homeassistant/components/control4/light.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/control4/light.py b/homeassistant/components/control4/light.py index e2aa7ccd443..e9226cc3716 100644 --- a/homeassistant/components/control4/light.py +++ b/homeassistant/components/control4/light.py @@ -11,7 +11,8 @@ from pyControl4.light import C4Light from homeassistant.components.light import ( ATTR_BRIGHTNESS, ATTR_TRANSITION, - SUPPORT_BRIGHTNESS, + COLOR_MODE_BRIGHTNESS, + COLOR_MODE_ONOFF, SUPPORT_TRANSITION, LightEntity, ) @@ -164,6 +165,12 @@ class Control4Light(Control4Entity, LightEntity): device_id, ) self._is_dimmer = is_dimmer + if is_dimmer: + self._attr_color_mode = COLOR_MODE_BRIGHTNESS + self._attr_supported_color_modes = {COLOR_MODE_BRIGHTNESS} + else: + self._attr_color_mode = COLOR_MODE_ONOFF + self._attr_supported_color_modes = {COLOR_MODE_ONOFF} def create_api_object(self): """Create a pyControl4 device object. @@ -188,7 +195,7 @@ class Control4Light(Control4Entity, LightEntity): def supported_features(self) -> int: """Flag supported features.""" if self._is_dimmer: - return SUPPORT_BRIGHTNESS | SUPPORT_TRANSITION + return SUPPORT_TRANSITION return 0 async def async_turn_on(self, **kwargs) -> None: