Migrate eufy light to color_mode (#69181)
This commit is contained in:
parent
88b01b80ce
commit
dbb9dc2d39
1 changed files with 17 additions and 12 deletions
|
@ -7,9 +7,9 @@ from homeassistant.components.light import (
|
|||
ATTR_BRIGHTNESS,
|
||||
ATTR_COLOR_TEMP,
|
||||
ATTR_HS_COLOR,
|
||||
SUPPORT_BRIGHTNESS,
|
||||
SUPPORT_COLOR,
|
||||
SUPPORT_COLOR_TEMP,
|
||||
COLOR_MODE_BRIGHTNESS,
|
||||
COLOR_MODE_COLOR_TEMP,
|
||||
COLOR_MODE_HS,
|
||||
LightEntity,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
@ -54,11 +54,11 @@ class EufyLight(LightEntity):
|
|||
self._bulb = lakeside.bulb(self._address, self._code, self._type)
|
||||
self._colormode = False
|
||||
if self._type == "T1011":
|
||||
self._features = SUPPORT_BRIGHTNESS
|
||||
self._attr_supported_color_modes = {COLOR_MODE_BRIGHTNESS}
|
||||
elif self._type == "T1012":
|
||||
self._features = SUPPORT_BRIGHTNESS | SUPPORT_COLOR_TEMP
|
||||
elif self._type == "T1013":
|
||||
self._features = SUPPORT_BRIGHTNESS | SUPPORT_COLOR_TEMP | SUPPORT_COLOR
|
||||
self._attr_supported_color_modes = {COLOR_MODE_COLOR_TEMP}
|
||||
else: # T1013
|
||||
self._attr_supported_color_modes = {COLOR_MODE_COLOR_TEMP, COLOR_MODE_HS}
|
||||
self._bulb.connect()
|
||||
|
||||
def update(self):
|
||||
|
@ -115,14 +115,19 @@ class EufyLight(LightEntity):
|
|||
@property
|
||||
def hs_color(self):
|
||||
"""Return the color of this light."""
|
||||
if not self._colormode:
|
||||
return None
|
||||
return self._hs
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Flag supported features."""
|
||||
return self._features
|
||||
def color_mode(self) -> str | None:
|
||||
"""Return the color mode of the light."""
|
||||
if self._type == "T1011":
|
||||
return COLOR_MODE_BRIGHTNESS
|
||||
if self._type == "T1012":
|
||||
return COLOR_MODE_COLOR_TEMP
|
||||
# T1013
|
||||
if not self._colormode:
|
||||
return COLOR_MODE_COLOR_TEMP
|
||||
return COLOR_MODE_HS
|
||||
|
||||
def turn_on(self, **kwargs):
|
||||
"""Turn the specified light on."""
|
||||
|
|
Loading…
Add table
Reference in a new issue