diff --git a/homeassistant/components/template/light.py b/homeassistant/components/template/light.py index 9fc935bf0ee..c852ee1808d 100644 --- a/homeassistant/components/template/light.py +++ b/homeassistant/components/template/light.py @@ -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) diff --git a/tests/components/template/test_light.py b/tests/components/template/test_light.py index f240c2412e0..eaa1708aea7 100644 --- a/tests/components/template/test_light.py +++ b/tests/components/template/test_light.py @@ -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