Set default min/max color temperature in mqtt lights (#133356)

This commit is contained in:
epenet 2024-12-16 17:48:59 +01:00 committed by GitHub
parent cefb4a4ccc
commit 239767ee62
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 6 deletions

View File

@ -26,6 +26,8 @@ from homeassistant.components.light import (
ATTR_SUPPORTED_COLOR_MODES,
ATTR_WHITE,
ATTR_XY_COLOR,
DEFAULT_MAX_KELVIN,
DEFAULT_MIN_KELVIN,
ENTITY_ID_FORMAT,
ColorMode,
LightEntity,
@ -264,12 +266,12 @@ class MqttLight(MqttEntity, LightEntity, RestoreEntity):
self._attr_min_color_temp_kelvin = (
color_util.color_temperature_mired_to_kelvin(max_mireds)
if (max_mireds := config.get(CONF_MAX_MIREDS))
else super().min_color_temp_kelvin
else DEFAULT_MIN_KELVIN
)
self._attr_max_color_temp_kelvin = (
color_util.color_temperature_mired_to_kelvin(min_mireds)
if (min_mireds := config.get(CONF_MIN_MIREDS))
else super().max_color_temp_kelvin
else DEFAULT_MAX_KELVIN
)
self._attr_effect_list = config.get(CONF_EFFECT_LIST)

View File

@ -22,6 +22,8 @@ from homeassistant.components.light import (
ATTR_TRANSITION,
ATTR_WHITE,
ATTR_XY_COLOR,
DEFAULT_MAX_KELVIN,
DEFAULT_MIN_KELVIN,
DOMAIN as LIGHT_DOMAIN,
ENTITY_ID_FORMAT,
FLASH_LONG,
@ -276,12 +278,12 @@ class MqttLightJson(MqttEntity, LightEntity, RestoreEntity):
self._attr_min_color_temp_kelvin = (
color_util.color_temperature_mired_to_kelvin(max_mireds)
if (max_mireds := config.get(CONF_MAX_MIREDS))
else super().min_color_temp_kelvin
else DEFAULT_MIN_KELVIN
)
self._attr_max_color_temp_kelvin = (
color_util.color_temperature_mired_to_kelvin(min_mireds)
if (min_mireds := config.get(CONF_MIN_MIREDS))
else super().max_color_temp_kelvin
else DEFAULT_MAX_KELVIN
)
self._attr_effect_list = config.get(CONF_EFFECT_LIST)

View File

@ -15,6 +15,8 @@ from homeassistant.components.light import (
ATTR_FLASH,
ATTR_HS_COLOR,
ATTR_TRANSITION,
DEFAULT_MAX_KELVIN,
DEFAULT_MIN_KELVIN,
ENTITY_ID_FORMAT,
ColorMode,
LightEntity,
@ -129,12 +131,12 @@ class MqttLightTemplate(MqttEntity, LightEntity, RestoreEntity):
self._attr_min_color_temp_kelvin = (
color_util.color_temperature_mired_to_kelvin(max_mireds)
if (max_mireds := config.get(CONF_MAX_MIREDS))
else super().min_color_temp_kelvin
else DEFAULT_MIN_KELVIN
)
self._attr_max_color_temp_kelvin = (
color_util.color_temperature_mired_to_kelvin(min_mireds)
if (min_mireds := config.get(CONF_MIN_MIREDS))
else super().max_color_temp_kelvin
else DEFAULT_MAX_KELVIN
)
self._attr_effect_list = config.get(CONF_EFFECT_LIST)