Use shorthand attrs for tplink color temp min/max (#106796)
The valid_temperature_range property does a regex match over every possible model. Avoid calling it more than once since it will never change as its based on the model
This commit is contained in:
parent
74e02fe057
commit
41f0eda712
1 changed files with 3 additions and 10 deletions
|
@ -185,6 +185,9 @@ class TPLinkSmartBulb(CoordinatedTPLinkEntity, LightEntity):
|
||||||
modes: set[ColorMode] = set()
|
modes: set[ColorMode] = set()
|
||||||
if device.is_variable_color_temp:
|
if device.is_variable_color_temp:
|
||||||
modes.add(ColorMode.COLOR_TEMP)
|
modes.add(ColorMode.COLOR_TEMP)
|
||||||
|
temp_range = device.valid_temperature_range
|
||||||
|
self._attr_min_color_temp_kelvin = temp_range.min
|
||||||
|
self._attr_max_color_temp_kelvin = temp_range.max
|
||||||
if device.is_color:
|
if device.is_color:
|
||||||
modes.add(ColorMode.HS)
|
modes.add(ColorMode.HS)
|
||||||
if device.is_dimmable:
|
if device.is_dimmable:
|
||||||
|
@ -251,16 +254,6 @@ class TPLinkSmartBulb(CoordinatedTPLinkEntity, LightEntity):
|
||||||
transition = int(transition * 1_000)
|
transition = int(transition * 1_000)
|
||||||
await self.device.turn_off(transition=transition)
|
await self.device.turn_off(transition=transition)
|
||||||
|
|
||||||
@property
|
|
||||||
def min_color_temp_kelvin(self) -> int:
|
|
||||||
"""Return minimum supported color temperature."""
|
|
||||||
return cast(int, self.device.valid_temperature_range.min)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def max_color_temp_kelvin(self) -> int:
|
|
||||||
"""Return maximum supported color temperature."""
|
|
||||||
return cast(int, self.device.valid_temperature_range.max)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def color_temp_kelvin(self) -> int:
|
def color_temp_kelvin(self) -> int:
|
||||||
"""Return the color temperature of this light."""
|
"""Return the color temperature of this light."""
|
||||||
|
|
Loading…
Add table
Reference in a new issue