mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 22:27:07 +00:00
light.tplink: initialize min & max mireds only once, avoid i/o outside update (#15571)
* light.tplink: initialize min & max mireds only once, avoid i/o outside update * revert the index change * fix indent, sorry for overwriting your fix, balloob
This commit is contained in:
parent
3341c5cf21
commit
5cf9cd686c
@ -66,6 +66,8 @@ class TPLinkSmartBulb(Light):
|
|||||||
self._brightness = None
|
self._brightness = None
|
||||||
self._hs = None
|
self._hs = None
|
||||||
self._supported_features = 0
|
self._supported_features = 0
|
||||||
|
self._min_mireds = None
|
||||||
|
self._max_mireds = None
|
||||||
self._emeter_params = {}
|
self._emeter_params = {}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -107,12 +109,12 @@ class TPLinkSmartBulb(Light):
|
|||||||
@property
|
@property
|
||||||
def min_mireds(self):
|
def min_mireds(self):
|
||||||
"""Return minimum supported color temperature."""
|
"""Return minimum supported color temperature."""
|
||||||
return kelvin_to_mired(self.smartbulb.valid_temperature_range[1])
|
return self._min_mireds
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def max_mireds(self):
|
def max_mireds(self):
|
||||||
"""Return maximum supported color temperature."""
|
"""Return maximum supported color temperature."""
|
||||||
return kelvin_to_mired(self.smartbulb.valid_temperature_range[0])
|
return self._max_mireds
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def color_temp(self):
|
def color_temp(self):
|
||||||
@ -195,5 +197,9 @@ class TPLinkSmartBulb(Light):
|
|||||||
self._supported_features += SUPPORT_BRIGHTNESS
|
self._supported_features += SUPPORT_BRIGHTNESS
|
||||||
if self.smartbulb.is_variable_color_temp:
|
if self.smartbulb.is_variable_color_temp:
|
||||||
self._supported_features += SUPPORT_COLOR_TEMP
|
self._supported_features += SUPPORT_COLOR_TEMP
|
||||||
|
self._min_mireds = kelvin_to_mired(
|
||||||
|
self.smartbulb.valid_temperature_range[1])
|
||||||
|
self._max_mireds = kelvin_to_mired(
|
||||||
|
self.smartbulb.valid_temperature_range[0])
|
||||||
if self.smartbulb.is_color:
|
if self.smartbulb.is_color:
|
||||||
self._supported_features += SUPPORT_COLOR
|
self._supported_features += SUPPORT_COLOR
|
||||||
|
Loading…
x
Reference in New Issue
Block a user