mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 13:47:35 +00:00
Use shorthand attrs for more tplink light attributes (#106399)
* Use shorthand attrs for more tplink light attributes supported_color_modes and features were having to be recalced every time state was written * preen
This commit is contained in:
parent
18ace16744
commit
b800475242
@ -182,6 +182,16 @@ class TPLinkSmartBulb(CoordinatedTPLinkEntity, LightEntity):
|
||||
self._attr_unique_id = legacy_device_id(device)
|
||||
else:
|
||||
self._attr_unique_id = device.mac.replace(":", "").upper()
|
||||
modes: set[ColorMode] = set()
|
||||
if device.is_variable_color_temp:
|
||||
modes.add(ColorMode.COLOR_TEMP)
|
||||
if device.is_color:
|
||||
modes.add(ColorMode.HS)
|
||||
if device.is_dimmable:
|
||||
modes.add(ColorMode.BRIGHTNESS)
|
||||
if not modes:
|
||||
modes.add(ColorMode.ONOFF)
|
||||
self._attr_supported_color_modes = modes
|
||||
|
||||
@callback
|
||||
def _async_extract_brightness_transition(
|
||||
@ -267,22 +277,6 @@ class TPLinkSmartBulb(CoordinatedTPLinkEntity, LightEntity):
|
||||
hue, saturation, _ = self.device.hsv
|
||||
return hue, saturation
|
||||
|
||||
@property
|
||||
def supported_color_modes(self) -> set[ColorMode]:
|
||||
"""Return list of available color modes."""
|
||||
modes: set[ColorMode] = set()
|
||||
if self.device.is_variable_color_temp:
|
||||
modes.add(ColorMode.COLOR_TEMP)
|
||||
if self.device.is_color:
|
||||
modes.add(ColorMode.HS)
|
||||
if self.device.is_dimmable:
|
||||
modes.add(ColorMode.BRIGHTNESS)
|
||||
|
||||
if not modes:
|
||||
modes.add(ColorMode.ONOFF)
|
||||
|
||||
return modes
|
||||
|
||||
@property
|
||||
def color_mode(self) -> ColorMode:
|
||||
"""Return the active color mode."""
|
||||
@ -300,11 +294,7 @@ class TPLinkSmartLightStrip(TPLinkSmartBulb):
|
||||
"""Representation of a TPLink Smart Light Strip."""
|
||||
|
||||
device: SmartLightStrip
|
||||
|
||||
@property
|
||||
def supported_features(self) -> LightEntityFeature:
|
||||
"""Flag supported features."""
|
||||
return super().supported_features | LightEntityFeature.EFFECT
|
||||
_attr_supported_features = LightEntityFeature.TRANSITION | LightEntityFeature.EFFECT
|
||||
|
||||
@property
|
||||
def effect_list(self) -> list[str] | None:
|
||||
|
Loading…
x
Reference in New Issue
Block a user