Use light enums in shelly (#70790)

This commit is contained in:
epenet 2022-04-26 14:29:56 +02:00 committed by GitHub
parent 13fc6ee426
commit 5af496682b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -12,10 +12,9 @@ from homeassistant.components.light import (
ATTR_RGB_COLOR,
ATTR_RGBW_COLOR,
ATTR_TRANSITION,
SUPPORT_EFFECT,
SUPPORT_TRANSITION,
ColorMode,
LightEntity,
LightEntityFeature,
brightness_supported,
)
from homeassistant.config_entries import ConfigEntry
@ -158,7 +157,7 @@ class BlockShellyLight(ShellyBlockEntity, LightEntity):
self._attr_supported_color_modes.add(ColorMode.ONOFF)
if hasattr(block, "effect"):
self._attr_supported_features |= SUPPORT_EFFECT
self._attr_supported_features |= LightEntityFeature.EFFECT
if wrapper.model in MODELS_SUPPORTING_LIGHT_TRANSITION:
match = FIRMWARE_PATTERN.search(wrapper.device.settings.get("fw", ""))
@ -166,7 +165,7 @@ class BlockShellyLight(ShellyBlockEntity, LightEntity):
match is not None
and int(match[0]) >= LIGHT_TRANSITION_MIN_FIRMWARE_DATE
):
self._attr_supported_features |= SUPPORT_TRANSITION
self._attr_supported_features |= LightEntityFeature.TRANSITION
@property
def is_on(self) -> bool:
@ -264,7 +263,7 @@ class BlockShellyLight(ShellyBlockEntity, LightEntity):
@property
def effect_list(self) -> list[str] | None:
"""Return the list of supported effects."""
if not self.supported_features & SUPPORT_EFFECT:
if not self.supported_features & LightEntityFeature.EFFECT:
return None
if self.wrapper.model == "SHBLB-1":
@ -275,7 +274,7 @@ class BlockShellyLight(ShellyBlockEntity, LightEntity):
@property
def effect(self) -> str | None:
"""Return the current effect."""
if not self.supported_features & SUPPORT_EFFECT:
if not self.supported_features & LightEntityFeature.EFFECT:
return None
if self.control_result: