mirror of
https://github.com/home-assistant/core
synced 2024-08-28 03:36:46 +02:00
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
@ -185,6 +185,9 @@ class TPLinkSmartBulb(CoordinatedTPLinkEntity, LightEntity):
|
||||
modes: set[ColorMode] = set()
|
||||
if device.is_variable_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:
|
||||
modes.add(ColorMode.HS)
|
||||
if device.is_dimmable:
|
||||
@ -251,16 +254,6 @@ class TPLinkSmartBulb(CoordinatedTPLinkEntity, LightEntity):
|
||||
transition = int(transition * 1_000)
|
||||
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
|
||||
def color_temp_kelvin(self) -> int:
|
||||
"""Return the color temperature of this light."""
|
||||
|
Loading…
Reference in New Issue
Block a user