Allow MQTT template light floating point transition (#46385)
Allow to use floating point values for the transition time of the MQTT template light.
This commit is contained in:
parent
b1a7bfee14
commit
5ce49c62b1
2 changed files with 6 additions and 6 deletions
|
@ -383,7 +383,7 @@ class MqttLightTemplate(MqttEntity, LightEntity, RestoreEntity):
|
||||||
values["flash"] = kwargs.get(ATTR_FLASH)
|
values["flash"] = kwargs.get(ATTR_FLASH)
|
||||||
|
|
||||||
if ATTR_TRANSITION in kwargs:
|
if ATTR_TRANSITION in kwargs:
|
||||||
values["transition"] = int(kwargs[ATTR_TRANSITION])
|
values["transition"] = kwargs[ATTR_TRANSITION]
|
||||||
|
|
||||||
mqtt.async_publish(
|
mqtt.async_publish(
|
||||||
self.hass,
|
self.hass,
|
||||||
|
@ -408,7 +408,7 @@ class MqttLightTemplate(MqttEntity, LightEntity, RestoreEntity):
|
||||||
self._state = False
|
self._state = False
|
||||||
|
|
||||||
if ATTR_TRANSITION in kwargs:
|
if ATTR_TRANSITION in kwargs:
|
||||||
values["transition"] = int(kwargs[ATTR_TRANSITION])
|
values["transition"] = kwargs[ATTR_TRANSITION]
|
||||||
|
|
||||||
mqtt.async_publish(
|
mqtt.async_publish(
|
||||||
self.hass,
|
self.hass,
|
||||||
|
|
|
@ -677,7 +677,7 @@ async def test_transition(hass, mqtt_mock):
|
||||||
"name": "test",
|
"name": "test",
|
||||||
"command_topic": "test_light_rgb/set",
|
"command_topic": "test_light_rgb/set",
|
||||||
"command_on_template": "on,{{ transition }}",
|
"command_on_template": "on,{{ transition }}",
|
||||||
"command_off_template": "off,{{ transition|d }}",
|
"command_off_template": "off,{{ transition|int|d }}",
|
||||||
"qos": 1,
|
"qos": 1,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -689,15 +689,15 @@ async def test_transition(hass, mqtt_mock):
|
||||||
|
|
||||||
assert state.attributes.get(ATTR_SUPPORTED_FEATURES) == 40
|
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(
|
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()
|
mqtt_mock.async_publish.reset_mock()
|
||||||
state = hass.states.get("light.test")
|
state = hass.states.get("light.test")
|
||||||
assert state.state == STATE_ON
|
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(
|
mqtt_mock.async_publish.assert_called_once_with(
|
||||||
"test_light_rgb/set", "off,20", 1, False
|
"test_light_rgb/set", "off,20", 1, False
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue