mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Migrate decora_wifi light to color_mode (#69175)
This commit is contained in:
parent
eeeb21a9f1
commit
7e2f024e29
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user