diff --git a/homeassistant/components/mqtt/light/schema_template.py b/homeassistant/components/mqtt/light/schema_template.py index 1f4421205e0..665e1a30d99 100644 --- a/homeassistant/components/mqtt/light/schema_template.py +++ b/homeassistant/components/mqtt/light/schema_template.py @@ -383,7 +383,7 @@ class MqttLightTemplate(MqttEntity, LightEntity, RestoreEntity): values["flash"] = kwargs.get(ATTR_FLASH) if ATTR_TRANSITION in kwargs: - values["transition"] = int(kwargs[ATTR_TRANSITION]) + values["transition"] = kwargs[ATTR_TRANSITION] mqtt.async_publish( self.hass, @@ -408,7 +408,7 @@ class MqttLightTemplate(MqttEntity, LightEntity, RestoreEntity): self._state = False if ATTR_TRANSITION in kwargs: - values["transition"] = int(kwargs[ATTR_TRANSITION]) + values["transition"] = kwargs[ATTR_TRANSITION] mqtt.async_publish( self.hass, diff --git a/tests/components/mqtt/test_light_template.py b/tests/components/mqtt/test_light_template.py index 733a39ce252..7b5d34edd69 100644 --- a/tests/components/mqtt/test_light_template.py +++ b/tests/components/mqtt/test_light_template.py @@ -677,7 +677,7 @@ async def test_transition(hass, mqtt_mock): "name": "test", "command_topic": "test_light_rgb/set", "command_on_template": "on,{{ transition }}", - "command_off_template": "off,{{ transition|d }}", + "command_off_template": "off,{{ transition|int|d }}", "qos": 1, } }, @@ -689,15 +689,15 @@ async def test_transition(hass, mqtt_mock): assert state.attributes.get(ATTR_SUPPORTED_FEATURES) == 40 - await common.async_turn_on(hass, "light.test", transition=10) + await common.async_turn_on(hass, "light.test", transition=10.0) mqtt_mock.async_publish.assert_called_once_with( - "test_light_rgb/set", "on,10", 1, False + "test_light_rgb/set", "on,10.0", 1, False ) mqtt_mock.async_publish.reset_mock() state = hass.states.get("light.test") assert state.state == STATE_ON - await common.async_turn_off(hass, "light.test", transition=20) + await common.async_turn_off(hass, "light.test", transition=20.0) mqtt_mock.async_publish.assert_called_once_with( "test_light_rgb/set", "off,20", 1, False )