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:
parent
3e426c0fa6
commit
54bb86d198
1 changed files with 15 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue