Use LightEntityFeature enum in hue (#70987)

pull/71022/head
epenet 2022-04-28 20:32:39 +02:00 committed by GitHub
parent 7fbc3f6364
commit d907eb2810
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 15 deletions

View File

@ -20,11 +20,9 @@ from homeassistant.components.light import (
EFFECT_RANDOM,
FLASH_LONG,
FLASH_SHORT,
SUPPORT_EFFECT,
SUPPORT_FLASH,
SUPPORT_TRANSITION,
ColorMode,
LightEntity,
LightEntityFeature,
filter_supported_color_modes,
)
from homeassistant.core import callback
@ -73,10 +71,10 @@ COLOR_MODES_HUE = {
"Color temperature light": COLOR_MODES_HUE_COLOR_TEMP,
}
SUPPORT_HUE_ON_OFF = SUPPORT_FLASH | SUPPORT_TRANSITION
SUPPORT_HUE_ON_OFF = LightEntityFeature.FLASH | LightEntityFeature.TRANSITION
SUPPORT_HUE_DIMMABLE = SUPPORT_HUE_ON_OFF
SUPPORT_HUE_COLOR_TEMP = SUPPORT_HUE_DIMMABLE
SUPPORT_HUE_COLOR = SUPPORT_HUE_DIMMABLE | SUPPORT_EFFECT
SUPPORT_HUE_COLOR = SUPPORT_HUE_DIMMABLE | LightEntityFeature.EFFECT
SUPPORT_HUE_EXTENDED = SUPPORT_HUE_COLOR_TEMP | SUPPORT_HUE_COLOR
SUPPORT_HUE = {

View File

@ -15,10 +15,9 @@ from homeassistant.components.light import (
ATTR_TRANSITION,
ATTR_XY_COLOR,
FLASH_SHORT,
SUPPORT_FLASH,
SUPPORT_TRANSITION,
ColorMode,
LightEntity,
LightEntityFeature,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant, callback
@ -81,8 +80,8 @@ class GroupedHueLight(HueBaseEntity, LightEntity):
self.group = group
self.controller = controller
self.api: HueBridgeV2 = bridge.api
self._attr_supported_features |= SUPPORT_FLASH
self._attr_supported_features |= SUPPORT_TRANSITION
self._attr_supported_features |= LightEntityFeature.FLASH
self._attr_supported_features |= LightEntityFeature.TRANSITION
self._dynamic_mode_active = False
self._update_values()

View File

@ -17,11 +17,9 @@ from homeassistant.components.light import (
ATTR_TRANSITION,
ATTR_XY_COLOR,
FLASH_SHORT,
SUPPORT_EFFECT,
SUPPORT_FLASH,
SUPPORT_TRANSITION,
ColorMode,
LightEntity,
LightEntityFeature,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant, callback
@ -74,7 +72,7 @@ class HueLight(HueBaseEntity, LightEntity):
"""Initialize the light."""
super().__init__(bridge, controller, resource)
if self.resource.alert and self.resource.alert.action_values:
self._attr_supported_features |= SUPPORT_FLASH
self._attr_supported_features |= LightEntityFeature.FLASH
self.resource = resource
self.controller = controller
self._supported_color_modes: set[ColorMode | str] = set()
@ -87,7 +85,7 @@ class HueLight(HueBaseEntity, LightEntity):
# only add color mode brightness if no color variants
self._supported_color_modes.add(ColorMode.BRIGHTNESS)
# support transition if brightness control
self._attr_supported_features |= SUPPORT_TRANSITION
self._attr_supported_features |= LightEntityFeature.TRANSITION
# get list of supported effects (combine effects and timed_effects)
self._attr_effect_list = []
if effects := resource.effects:
@ -102,7 +100,7 @@ class HueLight(HueBaseEntity, LightEntity):
]
if len(self._attr_effect_list) > 0:
self._attr_effect_list.insert(0, EFFECT_NONE)
self._attr_supported_features |= SUPPORT_EFFECT
self._attr_supported_features |= LightEntityFeature.EFFECT
@property
def brightness(self) -> int | None: