mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 10:17:09 +00:00
Use ColorMode enum in wled (#70555)
This commit is contained in:
parent
663dbc4080
commit
da2312765c
@ -10,9 +10,7 @@ from homeassistant.components.light import (
|
|||||||
ATTR_RGB_COLOR,
|
ATTR_RGB_COLOR,
|
||||||
ATTR_RGBW_COLOR,
|
ATTR_RGBW_COLOR,
|
||||||
ATTR_TRANSITION,
|
ATTR_TRANSITION,
|
||||||
COLOR_MODE_BRIGHTNESS,
|
ColorMode,
|
||||||
COLOR_MODE_RGB,
|
|
||||||
COLOR_MODE_RGBW,
|
|
||||||
LightEntity,
|
LightEntity,
|
||||||
LightEntityFeature,
|
LightEntityFeature,
|
||||||
)
|
)
|
||||||
@ -52,16 +50,16 @@ async def async_setup_entry(
|
|||||||
class WLEDMasterLight(WLEDEntity, LightEntity):
|
class WLEDMasterLight(WLEDEntity, LightEntity):
|
||||||
"""Defines a WLED master light."""
|
"""Defines a WLED master light."""
|
||||||
|
|
||||||
_attr_color_mode = COLOR_MODE_BRIGHTNESS
|
_attr_color_mode = ColorMode.BRIGHTNESS
|
||||||
_attr_icon = "mdi:led-strip-variant"
|
_attr_icon = "mdi:led-strip-variant"
|
||||||
_attr_supported_features = LightEntityFeature.TRANSITION
|
_attr_supported_features = LightEntityFeature.TRANSITION
|
||||||
|
_attr_supported_color_modes = {ColorMode.BRIGHTNESS}
|
||||||
|
|
||||||
def __init__(self, coordinator: WLEDDataUpdateCoordinator) -> None:
|
def __init__(self, coordinator: WLEDDataUpdateCoordinator) -> None:
|
||||||
"""Initialize WLED master light."""
|
"""Initialize WLED master light."""
|
||||||
super().__init__(coordinator=coordinator)
|
super().__init__(coordinator=coordinator)
|
||||||
self._attr_name = f"{coordinator.data.info.name} Master"
|
self._attr_name = f"{coordinator.data.info.name} Master"
|
||||||
self._attr_unique_id = coordinator.data.info.mac_address
|
self._attr_unique_id = coordinator.data.info.mac_address
|
||||||
self._attr_supported_color_modes = {COLOR_MODE_BRIGHTNESS}
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def brightness(self) -> int | None:
|
def brightness(self) -> int | None:
|
||||||
@ -128,11 +126,11 @@ class WLEDSegmentLight(WLEDEntity, LightEntity):
|
|||||||
f"{self.coordinator.data.info.mac_address}_{self._segment}"
|
f"{self.coordinator.data.info.mac_address}_{self._segment}"
|
||||||
)
|
)
|
||||||
|
|
||||||
self._attr_color_mode = COLOR_MODE_RGB
|
self._attr_color_mode = ColorMode.RGB
|
||||||
self._attr_supported_color_modes = {COLOR_MODE_RGB}
|
self._attr_supported_color_modes = {ColorMode.RGB}
|
||||||
if self._rgbw and self._wv:
|
if self._rgbw and self._wv:
|
||||||
self._attr_color_mode = COLOR_MODE_RGBW
|
self._attr_color_mode = ColorMode.RGBW
|
||||||
self._attr_supported_color_modes = {COLOR_MODE_RGBW}
|
self._attr_supported_color_modes = {ColorMode.RGBW}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def available(self) -> bool:
|
def available(self) -> bool:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user