mirror of
https://github.com/home-assistant/core.git
synced 2025-06-17 03:27:07 +00:00
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
@ -3,7 +3,8 @@ from homeassistant.components.light import (
|
|||||||
ATTR_BRIGHTNESS,
|
ATTR_BRIGHTNESS,
|
||||||
ATTR_FLASH,
|
ATTR_FLASH,
|
||||||
ATTR_TRANSITION,
|
ATTR_TRANSITION,
|
||||||
SUPPORT_BRIGHTNESS,
|
COLOR_MODE_BRIGHTNESS,
|
||||||
|
COLOR_MODE_ONOFF,
|
||||||
SUPPORT_FLASH,
|
SUPPORT_FLASH,
|
||||||
SUPPORT_TRANSITION,
|
SUPPORT_TRANSITION,
|
||||||
LightEntity,
|
LightEntity,
|
||||||
@ -55,11 +56,23 @@ class UpbLight(UpbAttachedEntity, LightEntity):
|
|||||||
super().__init__(element, unique_id, upb)
|
super().__init__(element, unique_id, upb)
|
||||||
self._brightness = self._element.status
|
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
|
@property
|
||||||
def supported_features(self):
|
def supported_features(self):
|
||||||
"""Flag supported features."""
|
"""Flag supported features."""
|
||||||
if self._element.dimmable:
|
if self._element.dimmable:
|
||||||
return SUPPORT_BRIGHTNESS | SUPPORT_TRANSITION | SUPPORT_FLASH
|
return SUPPORT_TRANSITION | SUPPORT_FLASH
|
||||||
return SUPPORT_FLASH
|
return SUPPORT_FLASH
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
Loading…
x
Reference in New Issue
Block a user