mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 06:07:17 +00:00
Use ColorMode enum in tplink (#70542)
This commit is contained in:
parent
9a38172d1f
commit
121d2008c2
@ -14,12 +14,9 @@ from homeassistant.components.light import (
|
|||||||
ATTR_EFFECT,
|
ATTR_EFFECT,
|
||||||
ATTR_HS_COLOR,
|
ATTR_HS_COLOR,
|
||||||
ATTR_TRANSITION,
|
ATTR_TRANSITION,
|
||||||
COLOR_MODE_BRIGHTNESS,
|
|
||||||
COLOR_MODE_COLOR_TEMP,
|
|
||||||
COLOR_MODE_HS,
|
|
||||||
COLOR_MODE_ONOFF,
|
|
||||||
SUPPORT_EFFECT,
|
SUPPORT_EFFECT,
|
||||||
SUPPORT_TRANSITION,
|
SUPPORT_TRANSITION,
|
||||||
|
ColorMode,
|
||||||
LightEntity,
|
LightEntity,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
@ -285,32 +282,32 @@ class TPLinkSmartBulb(CoordinatedTPLinkEntity, LightEntity):
|
|||||||
return SUPPORT_TRANSITION
|
return SUPPORT_TRANSITION
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_color_modes(self) -> set[str] | None:
|
def supported_color_modes(self) -> set[ColorMode | str] | None:
|
||||||
"""Return list of available color modes."""
|
"""Return list of available color modes."""
|
||||||
modes = set()
|
modes: set[ColorMode | str] = set()
|
||||||
if self.device.is_variable_color_temp:
|
if self.device.is_variable_color_temp:
|
||||||
modes.add(COLOR_MODE_COLOR_TEMP)
|
modes.add(ColorMode.COLOR_TEMP)
|
||||||
if self.device.is_color:
|
if self.device.is_color:
|
||||||
modes.add(COLOR_MODE_HS)
|
modes.add(ColorMode.HS)
|
||||||
if self.device.is_dimmable:
|
if self.device.is_dimmable:
|
||||||
modes.add(COLOR_MODE_BRIGHTNESS)
|
modes.add(ColorMode.BRIGHTNESS)
|
||||||
|
|
||||||
if not modes:
|
if not modes:
|
||||||
modes.add(COLOR_MODE_ONOFF)
|
modes.add(ColorMode.ONOFF)
|
||||||
|
|
||||||
return modes
|
return modes
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def color_mode(self) -> str | None:
|
def color_mode(self) -> ColorMode:
|
||||||
"""Return the active color mode."""
|
"""Return the active color mode."""
|
||||||
if self.device.is_color:
|
if self.device.is_color:
|
||||||
if self.device.is_variable_color_temp and self.device.color_temp:
|
if self.device.is_variable_color_temp and self.device.color_temp:
|
||||||
return COLOR_MODE_COLOR_TEMP
|
return ColorMode.COLOR_TEMP
|
||||||
return COLOR_MODE_HS
|
return ColorMode.HS
|
||||||
if self.device.is_variable_color_temp:
|
if self.device.is_variable_color_temp:
|
||||||
return COLOR_MODE_COLOR_TEMP
|
return ColorMode.COLOR_TEMP
|
||||||
|
|
||||||
return COLOR_MODE_BRIGHTNESS
|
return ColorMode.BRIGHTNESS
|
||||||
|
|
||||||
|
|
||||||
class TPLinkSmartLightStrip(TPLinkSmartBulb):
|
class TPLinkSmartLightStrip(TPLinkSmartBulb):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user