Use light enums in yeelight (#70797)

This commit is contained in:
epenet 2022-04-26 14:55:44 +02:00 committed by GitHub
parent d58430bc93
commit 5d8b35face
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 11 deletions

View File

@ -23,11 +23,9 @@ from homeassistant.components.light import (
ATTR_TRANSITION,
FLASH_LONG,
FLASH_SHORT,
SUPPORT_EFFECT,
SUPPORT_FLASH,
SUPPORT_TRANSITION,
ColorMode,
LightEntity,
LightEntityFeature,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_ENTITY_ID, ATTR_MODE, CONF_NAME
@ -68,8 +66,6 @@ from .entity import YeelightEntity
_LOGGER = logging.getLogger(__name__)
SUPPORT_YEELIGHT = SUPPORT_TRANSITION | SUPPORT_FLASH | SUPPORT_EFFECT
ATTR_MINUTES = "minutes"
SERVICE_SET_MODE = "set_mode"
@ -410,6 +406,11 @@ class YeelightGenericLight(YeelightEntity, LightEntity):
_attr_color_mode = ColorMode.BRIGHTNESS
_attr_supported_color_modes = {ColorMode.BRIGHTNESS}
_attr_supported_features = (
LightEntityFeature.TRANSITION
| LightEntityFeature.FLASH
| LightEntityFeature.EFFECT
)
_attr_should_poll = False
def __init__(self, device, entry, custom_effects=None):
@ -452,11 +453,6 @@ class YeelightGenericLight(YeelightEntity, LightEntity):
)
await super().async_added_to_hass()
@property
def supported_features(self) -> int:
"""Flag supported features."""
return SUPPORT_YEELIGHT
@property
def effect_list(self):
"""Return the list of supported effects."""

View File

@ -35,6 +35,7 @@ from homeassistant.components.light import (
FLASH_SHORT,
SERVICE_TURN_OFF,
SERVICE_TURN_ON,
LightEntityFeature,
)
from homeassistant.components.yeelight.const import (
ATTR_COUNT,
@ -82,7 +83,6 @@ from homeassistant.components.yeelight.light import (
SERVICE_SET_MODE,
SERVICE_SET_MUSIC_MODE,
SERVICE_START_FLOW,
SUPPORT_YEELIGHT,
YEELIGHT_COLOR_EFFECT_LIST,
YEELIGHT_MONO_EFFECT_LIST,
YEELIGHT_TEMP_ONLY_EFFECT_LIST,
@ -133,6 +133,10 @@ CONFIG_ENTRY_DATA = {
CONF_NIGHTLIGHT_SWITCH: DEFAULT_NIGHTLIGHT_SWITCH,
}
SUPPORT_YEELIGHT = (
LightEntityFeature.TRANSITION | LightEntityFeature.FLASH | LightEntityFeature.EFFECT
)
async def test_services(hass: HomeAssistant, caplog):
"""Test Yeelight services."""