Add color_temp_kelvin to set_temperature action variables (#146448)

This commit is contained in:
Petro31 2025-06-11 05:58:07 -04:00 committed by GitHub
parent a53997dfc7
commit 37d904dfdc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

View File

@ -524,8 +524,10 @@ class AbstractTemplateLight(AbstractTemplateEntity, LightEntity):
ATTR_COLOR_TEMP_KELVIN in kwargs
and (script := CONF_TEMPERATURE_ACTION) in self._action_scripts
):
kelvin = kwargs[ATTR_COLOR_TEMP_KELVIN]
common_params[ATTR_COLOR_TEMP_KELVIN] = kelvin
common_params["color_temp"] = color_util.color_temperature_kelvin_to_mired(
kwargs[ATTR_COLOR_TEMP_KELVIN]
kelvin
)
return (script, common_params)

View File

@ -79,6 +79,7 @@ OPTIMISTIC_COLOR_TEMP_LIGHT_CONFIG = {
"action": "set_temperature",
"caller": "{{ this.entity_id }}",
"color_temp": "{{color_temp}}",
"color_temp_kelvin": "{{color_temp_kelvin}}",
},
},
}
@ -1535,6 +1536,7 @@ async def test_temperature_action_no_template(
assert calls[-1].data["action"] == "set_temperature"
assert calls[-1].data["caller"] == "light.test_template_light"
assert calls[-1].data["color_temp"] == 345
assert calls[-1].data["color_temp_kelvin"] == 2898
state = hass.states.get("light.test_template_light")
assert state is not None