mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +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 (
|
from homeassistant.components.light import (
|
||||||
ATTR_BRIGHTNESS,
|
ATTR_BRIGHTNESS,
|
||||||
ATTR_TRANSITION,
|
ATTR_TRANSITION,
|
||||||
|
COLOR_MODE_BRIGHTNESS,
|
||||||
|
COLOR_MODE_ONOFF,
|
||||||
PLATFORM_SCHEMA,
|
PLATFORM_SCHEMA,
|
||||||
SUPPORT_BRIGHTNESS,
|
|
||||||
SUPPORT_TRANSITION,
|
SUPPORT_TRANSITION,
|
||||||
LightEntity,
|
LightEntity,
|
||||||
)
|
)
|
||||||
@ -98,11 +99,23 @@ class DecoraWifiLight(LightEntity):
|
|||||||
self._switch = switch
|
self._switch = switch
|
||||||
self._attr_unique_id = switch.serial
|
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
|
@property
|
||||||
def supported_features(self):
|
def supported_features(self):
|
||||||
"""Return supported features."""
|
"""Return supported features."""
|
||||||
if self._switch.canSetLevel:
|
if self._switch.canSetLevel:
|
||||||
return SUPPORT_BRIGHTNESS | SUPPORT_TRANSITION
|
return SUPPORT_TRANSITION
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
Loading…
x
Reference in New Issue
Block a user