Migrate upb light to color_mode (#69524)

* Migrate upb light to color_mode

* Add supported_color_modes

* Apply code review
This commit is contained in:
epenet 2022-04-07 09:58:50 +02:00 committed by GitHub
parent 3e426c0fa6
commit 54bb86d198
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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