Migrate decora_wifi light to color_mode (#69175)

This commit is contained in:
Erik Montnemery 2022-04-03 13:59:27 +02:00 committed by GitHub
parent eeeb21a9f1
commit 7e2f024e29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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