mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
Set default min/max color temperature in homekit_controller lights (#133334)
This commit is contained in:
parent
d062171be3
commit
4b3893eadf
@ -12,6 +12,8 @@ from homeassistant.components.light import (
|
||||
ATTR_BRIGHTNESS,
|
||||
ATTR_COLOR_TEMP_KELVIN,
|
||||
ATTR_HS_COLOR,
|
||||
DEFAULT_MAX_KELVIN,
|
||||
DEFAULT_MIN_KELVIN,
|
||||
ColorMode,
|
||||
LightEntity,
|
||||
)
|
||||
@ -53,6 +55,9 @@ async def async_setup_entry(
|
||||
class HomeKitLight(HomeKitEntity, LightEntity):
|
||||
"""Representation of a Homekit light."""
|
||||
|
||||
_attr_max_color_temp_kelvin = DEFAULT_MAX_KELVIN
|
||||
_attr_min_color_temp_kelvin = DEFAULT_MIN_KELVIN
|
||||
|
||||
@callback
|
||||
def _async_reconfigure(self) -> None:
|
||||
"""Reconfigure entity."""
|
||||
@ -98,24 +103,24 @@ class HomeKitLight(HomeKitEntity, LightEntity):
|
||||
def max_color_temp_kelvin(self) -> int:
|
||||
"""Return the coldest color_temp_kelvin that this light supports."""
|
||||
if not self.service.has(CharacteristicsTypes.COLOR_TEMPERATURE):
|
||||
return super().max_color_temp_kelvin
|
||||
return DEFAULT_MAX_KELVIN
|
||||
min_value_mireds = self.service[CharacteristicsTypes.COLOR_TEMPERATURE].minValue
|
||||
return (
|
||||
color_util.color_temperature_mired_to_kelvin(min_value_mireds)
|
||||
if min_value_mireds
|
||||
else super().max_color_temp_kelvin
|
||||
else DEFAULT_MAX_KELVIN
|
||||
)
|
||||
|
||||
@cached_property
|
||||
def min_color_temp_kelvin(self) -> int:
|
||||
"""Return the warmest color_temp_kelvin that this light supports."""
|
||||
if not self.service.has(CharacteristicsTypes.COLOR_TEMPERATURE):
|
||||
return super().min_color_temp_kelvin
|
||||
return DEFAULT_MIN_KELVIN
|
||||
max_value_mireds = self.service[CharacteristicsTypes.COLOR_TEMPERATURE].maxValue
|
||||
return (
|
||||
color_util.color_temperature_mired_to_kelvin(max_value_mireds)
|
||||
if max_value_mireds
|
||||
else super().min_color_temp_kelvin
|
||||
else DEFAULT_MIN_KELVIN
|
||||
)
|
||||
|
||||
@property
|
||||
|
Loading…
x
Reference in New Issue
Block a user