Allow MQTT template light floating point transition (#46385)
Allow to use floating point values for the transition time of the MQTT template light.pull/46399/head
parent
b1a7bfee14
commit
5ce49c62b1
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue