mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +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_BRIGHTNESS,
|
||||||
ATTR_COLOR_TEMP_KELVIN,
|
ATTR_COLOR_TEMP_KELVIN,
|
||||||
ATTR_HS_COLOR,
|
ATTR_HS_COLOR,
|
||||||
|
DEFAULT_MAX_KELVIN,
|
||||||
|
DEFAULT_MIN_KELVIN,
|
||||||
ColorMode,
|
ColorMode,
|
||||||
LightEntity,
|
LightEntity,
|
||||||
)
|
)
|
||||||
@ -53,6 +55,9 @@ async def async_setup_entry(
|
|||||||
class HomeKitLight(HomeKitEntity, LightEntity):
|
class HomeKitLight(HomeKitEntity, LightEntity):
|
||||||
"""Representation of a Homekit light."""
|
"""Representation of a Homekit light."""
|
||||||
|
|
||||||
|
_attr_max_color_temp_kelvin = DEFAULT_MAX_KELVIN
|
||||||
|
_attr_min_color_temp_kelvin = DEFAULT_MIN_KELVIN
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def _async_reconfigure(self) -> None:
|
def _async_reconfigure(self) -> None:
|
||||||
"""Reconfigure entity."""
|
"""Reconfigure entity."""
|
||||||
@ -98,24 +103,24 @@ class HomeKitLight(HomeKitEntity, LightEntity):
|
|||||||
def max_color_temp_kelvin(self) -> int:
|
def max_color_temp_kelvin(self) -> int:
|
||||||
"""Return the coldest color_temp_kelvin that this light supports."""
|
"""Return the coldest color_temp_kelvin that this light supports."""
|
||||||
if not self.service.has(CharacteristicsTypes.COLOR_TEMPERATURE):
|
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
|
min_value_mireds = self.service[CharacteristicsTypes.COLOR_TEMPERATURE].minValue
|
||||||
return (
|
return (
|
||||||
color_util.color_temperature_mired_to_kelvin(min_value_mireds)
|
color_util.color_temperature_mired_to_kelvin(min_value_mireds)
|
||||||
if min_value_mireds
|
if min_value_mireds
|
||||||
else super().max_color_temp_kelvin
|
else DEFAULT_MAX_KELVIN
|
||||||
)
|
)
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def min_color_temp_kelvin(self) -> int:
|
def min_color_temp_kelvin(self) -> int:
|
||||||
"""Return the warmest color_temp_kelvin that this light supports."""
|
"""Return the warmest color_temp_kelvin that this light supports."""
|
||||||
if not self.service.has(CharacteristicsTypes.COLOR_TEMPERATURE):
|
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
|
max_value_mireds = self.service[CharacteristicsTypes.COLOR_TEMPERATURE].maxValue
|
||||||
return (
|
return (
|
||||||
color_util.color_temperature_mired_to_kelvin(max_value_mireds)
|
color_util.color_temperature_mired_to_kelvin(max_value_mireds)
|
||||||
if max_value_mireds
|
if max_value_mireds
|
||||||
else super().min_color_temp_kelvin
|
else DEFAULT_MIN_KELVIN
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
Loading…
x
Reference in New Issue
Block a user