Use EntityFeature in mystrom

This commit is contained in:
epenet 2022-04-06 11:59:05 +00:00
parent 792d85bc52
commit 7260ee0384

View file

@ -14,9 +14,8 @@ from homeassistant.components.light import (
PLATFORM_SCHEMA,
SUPPORT_BRIGHTNESS,
SUPPORT_COLOR,
SUPPORT_EFFECT,
SUPPORT_FLASH,
LightEntity,
LightEntityFeature,
)
from homeassistant.const import CONF_HOST, CONF_MAC, CONF_NAME
from homeassistant.core import HomeAssistant
@ -29,7 +28,6 @@ _LOGGER = logging.getLogger(__name__)
DEFAULT_NAME = "myStrom bulb"
SUPPORT_MYSTROM = SUPPORT_BRIGHTNESS | SUPPORT_EFFECT | SUPPORT_FLASH | SUPPORT_COLOR
EFFECT_RAINBOW = "rainbow"
EFFECT_SUNRISE = "sunrise"
@ -74,6 +72,13 @@ async def async_setup_platform(
class MyStromLight(LightEntity):
"""Representation of the myStrom WiFi bulb."""
_attr_supported_features = (
SUPPORT_BRIGHTNESS
| LightEntityFeature.EFFECT
| LightEntityFeature.FLASH
| SUPPORT_COLOR
)
def __init__(self, bulb, name, mac):
"""Initialize the light."""
self._bulb = bulb
@ -95,11 +100,6 @@ class MyStromLight(LightEntity):
"""Return a unique ID."""
return self._mac
@property
def supported_features(self):
"""Flag supported features."""
return SUPPORT_MYSTROM
@property
def brightness(self):
"""Return the brightness of the light."""