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
Steve Dwyer 2021-02-11 13:57:27 +00:00 committed by GitHub
parent b1a7bfee14
commit 5ce49c62b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View File

@ -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,

View File

@ -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
)