Migrate vera light to ColorMode (#70861)

This commit is contained in:
epenet 2022-04-27 17:18:35 +02:00 committed by GitHub
parent c5d69ab1b2
commit 71f95d199a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,8 +9,7 @@ from homeassistant.components.light import (
ATTR_BRIGHTNESS,
ATTR_HS_COLOR,
ENTITY_ID_FORMAT,
SUPPORT_BRIGHTNESS,
SUPPORT_COLOR,
ColorMode,
LightEntity,
)
from homeassistant.config_entries import ConfigEntry
@ -63,11 +62,18 @@ class VeraLight(VeraDevice[veraApi.VeraDimmer], LightEntity):
return self._color
@property
def supported_features(self) -> int:
"""Flag supported features."""
def color_mode(self) -> ColorMode:
"""Return the color mode of the light."""
if self.vera_device.is_dimmable:
if self._color:
return SUPPORT_BRIGHTNESS | SUPPORT_COLOR
return SUPPORT_BRIGHTNESS
return ColorMode.HS
return ColorMode.BRIGHTNESS
return ColorMode.ONOFF
@property
def supported_color_modes(self) -> set[ColorMode]:
"""Flag supported color modes."""
return {self.color_mode}
def turn_on(self, **kwargs: Any) -> None:
"""Turn the light on."""