mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Use light enums in shelly (#70790)
This commit is contained in:
parent
13fc6ee426
commit
5af496682b
@ -12,10 +12,9 @@ from homeassistant.components.light import (
|
|||||||
ATTR_RGB_COLOR,
|
ATTR_RGB_COLOR,
|
||||||
ATTR_RGBW_COLOR,
|
ATTR_RGBW_COLOR,
|
||||||
ATTR_TRANSITION,
|
ATTR_TRANSITION,
|
||||||
SUPPORT_EFFECT,
|
|
||||||
SUPPORT_TRANSITION,
|
|
||||||
ColorMode,
|
ColorMode,
|
||||||
LightEntity,
|
LightEntity,
|
||||||
|
LightEntityFeature,
|
||||||
brightness_supported,
|
brightness_supported,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
@ -158,7 +157,7 @@ class BlockShellyLight(ShellyBlockEntity, LightEntity):
|
|||||||
self._attr_supported_color_modes.add(ColorMode.ONOFF)
|
self._attr_supported_color_modes.add(ColorMode.ONOFF)
|
||||||
|
|
||||||
if hasattr(block, "effect"):
|
if hasattr(block, "effect"):
|
||||||
self._attr_supported_features |= SUPPORT_EFFECT
|
self._attr_supported_features |= LightEntityFeature.EFFECT
|
||||||
|
|
||||||
if wrapper.model in MODELS_SUPPORTING_LIGHT_TRANSITION:
|
if wrapper.model in MODELS_SUPPORTING_LIGHT_TRANSITION:
|
||||||
match = FIRMWARE_PATTERN.search(wrapper.device.settings.get("fw", ""))
|
match = FIRMWARE_PATTERN.search(wrapper.device.settings.get("fw", ""))
|
||||||
@ -166,7 +165,7 @@ class BlockShellyLight(ShellyBlockEntity, LightEntity):
|
|||||||
match is not None
|
match is not None
|
||||||
and int(match[0]) >= LIGHT_TRANSITION_MIN_FIRMWARE_DATE
|
and int(match[0]) >= LIGHT_TRANSITION_MIN_FIRMWARE_DATE
|
||||||
):
|
):
|
||||||
self._attr_supported_features |= SUPPORT_TRANSITION
|
self._attr_supported_features |= LightEntityFeature.TRANSITION
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self) -> bool:
|
def is_on(self) -> bool:
|
||||||
@ -264,7 +263,7 @@ class BlockShellyLight(ShellyBlockEntity, LightEntity):
|
|||||||
@property
|
@property
|
||||||
def effect_list(self) -> list[str] | None:
|
def effect_list(self) -> list[str] | None:
|
||||||
"""Return the list of supported effects."""
|
"""Return the list of supported effects."""
|
||||||
if not self.supported_features & SUPPORT_EFFECT:
|
if not self.supported_features & LightEntityFeature.EFFECT:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if self.wrapper.model == "SHBLB-1":
|
if self.wrapper.model == "SHBLB-1":
|
||||||
@ -275,7 +274,7 @@ class BlockShellyLight(ShellyBlockEntity, LightEntity):
|
|||||||
@property
|
@property
|
||||||
def effect(self) -> str | None:
|
def effect(self) -> str | None:
|
||||||
"""Return the current effect."""
|
"""Return the current effect."""
|
||||||
if not self.supported_features & SUPPORT_EFFECT:
|
if not self.supported_features & LightEntityFeature.EFFECT:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if self.control_result:
|
if self.control_result:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user