Fix mqtt light attributes (#132941)

pull/131219/head
epenet 2024-12-11 17:18:54 +01:00 committed by GitHub
parent 00ab5db661
commit 39f8de0159
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 3 deletions

View File

@ -261,8 +261,16 @@ class MqttLight(MqttEntity, LightEntity, RestoreEntity):
def _setup_from_config(self, config: ConfigType) -> None:
"""(Re)Setup the entity."""
self._attr_min_mireds = config.get(CONF_MIN_MIREDS, super().min_mireds)
self._attr_max_mireds = config.get(CONF_MAX_MIREDS, super().max_mireds)
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
)
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
)
self._attr_effect_list = config.get(CONF_EFFECT_LIST)
topic: dict[str, str | None] = {

View File

@ -639,7 +639,7 @@ class MqttLightJson(MqttEntity, LightEntity, RestoreEntity):
message["color"]["s"] = hs_color[1]
if self._optimistic:
self._attr_color_temp = None
self._attr_color_temp_kelvin = None
self._attr_hs_color = kwargs[ATTR_HS_COLOR]
should_update = True