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_BRIGHTNESS,
ATTR_HS_COLOR, ATTR_HS_COLOR,
ENTITY_ID_FORMAT, ENTITY_ID_FORMAT,
SUPPORT_BRIGHTNESS, ColorMode,
SUPPORT_COLOR,
LightEntity, LightEntity,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
@ -63,11 +62,18 @@ class VeraLight(VeraDevice[veraApi.VeraDimmer], LightEntity):
return self._color return self._color
@property @property
def supported_features(self) -> int: def color_mode(self) -> ColorMode:
"""Flag supported features.""" """Return the color mode of the light."""
if self._color: if self.vera_device.is_dimmable:
return SUPPORT_BRIGHTNESS | SUPPORT_COLOR if self._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: def turn_on(self, **kwargs: Any) -> None:
"""Turn the light on.""" """Turn the light on."""