mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 06:07:17 +00:00
Fix light color mode in tplink (#109831)
This commit is contained in:
parent
5d1da0b3e4
commit
2e194c4ec3
@ -163,6 +163,7 @@ class TPLinkSmartBulb(CoordinatedTPLinkEntity, LightEntity):
|
|||||||
|
|
||||||
_attr_supported_features = LightEntityFeature.TRANSITION
|
_attr_supported_features = LightEntityFeature.TRANSITION
|
||||||
_attr_name = None
|
_attr_name = None
|
||||||
|
_fixed_color_mode: ColorMode | None = None
|
||||||
|
|
||||||
device: SmartBulb
|
device: SmartBulb
|
||||||
|
|
||||||
@ -193,6 +194,9 @@ class TPLinkSmartBulb(CoordinatedTPLinkEntity, LightEntity):
|
|||||||
if device.is_dimmable:
|
if device.is_dimmable:
|
||||||
modes.add(ColorMode.BRIGHTNESS)
|
modes.add(ColorMode.BRIGHTNESS)
|
||||||
self._attr_supported_color_modes = filter_supported_color_modes(modes)
|
self._attr_supported_color_modes = filter_supported_color_modes(modes)
|
||||||
|
if len(self._attr_supported_color_modes) == 1:
|
||||||
|
# If the light supports only a single color mode, set it now
|
||||||
|
self._fixed_color_mode = next(iter(self._attr_supported_color_modes))
|
||||||
self._async_update_attrs()
|
self._async_update_attrs()
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
@ -273,14 +277,14 @@ class TPLinkSmartBulb(CoordinatedTPLinkEntity, LightEntity):
|
|||||||
|
|
||||||
def _determine_color_mode(self) -> ColorMode:
|
def _determine_color_mode(self) -> ColorMode:
|
||||||
"""Return the active color mode."""
|
"""Return the active color mode."""
|
||||||
if self.device.is_color:
|
if self._fixed_color_mode:
|
||||||
if self.device.is_variable_color_temp and self.device.color_temp:
|
# The light supports only a single color mode, return it
|
||||||
return ColorMode.COLOR_TEMP
|
return self._fixed_color_mode
|
||||||
return ColorMode.HS
|
|
||||||
if self.device.is_variable_color_temp:
|
|
||||||
return ColorMode.COLOR_TEMP
|
|
||||||
|
|
||||||
return ColorMode.BRIGHTNESS
|
# The light supports both color temp and color, determine which on is active
|
||||||
|
if self.device.is_variable_color_temp and self.device.color_temp:
|
||||||
|
return ColorMode.COLOR_TEMP
|
||||||
|
return ColorMode.HS
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def _async_update_attrs(self) -> None:
|
def _async_update_attrs(self) -> None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user