mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Fix MQTT publish from a script with templates (#42398)
This commit is contained in:
@@ -702,7 +702,9 @@ async def test_set_position_templated(hass, mqtt_mock):
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
mqtt_mock.async_publish.assert_called_once_with("set-position-topic", 38, 0, False)
|
||||
mqtt_mock.async_publish.assert_called_once_with(
|
||||
"set-position-topic", "38", 0, False
|
||||
)
|
||||
|
||||
|
||||
async def test_set_position_untemplated(hass, mqtt_mock):
|
||||
@@ -732,7 +734,7 @@ async def test_set_position_untemplated(hass, mqtt_mock):
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
mqtt_mock.async_publish.assert_called_once_with("position-topic", 62, 0, False)
|
||||
mqtt_mock.async_publish.assert_called_once_with("position-topic", "62", 0, False)
|
||||
|
||||
|
||||
async def test_set_position_untemplated_custom_percentage_range(hass, mqtt_mock):
|
||||
@@ -764,7 +766,7 @@ async def test_set_position_untemplated_custom_percentage_range(hass, mqtt_mock)
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
mqtt_mock.async_publish.assert_called_once_with("position-topic", 62, 0, False)
|
||||
mqtt_mock.async_publish.assert_called_once_with("position-topic", "62", 0, False)
|
||||
|
||||
|
||||
async def test_no_command_topic(hass, mqtt_mock):
|
||||
@@ -896,7 +898,9 @@ async def test_tilt_via_invocation_defaults(hass, mqtt_mock):
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
mqtt_mock.async_publish.assert_called_once_with("tilt-command-topic", 100, 0, False)
|
||||
mqtt_mock.async_publish.assert_called_once_with(
|
||||
"tilt-command-topic", "100", 0, False
|
||||
)
|
||||
mqtt_mock.async_publish.reset_mock()
|
||||
|
||||
await hass.services.async_call(
|
||||
@@ -906,7 +910,7 @@ async def test_tilt_via_invocation_defaults(hass, mqtt_mock):
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
mqtt_mock.async_publish.assert_called_once_with("tilt-command-topic", 0, 0, False)
|
||||
mqtt_mock.async_publish.assert_called_once_with("tilt-command-topic", "0", 0, False)
|
||||
mqtt_mock.async_publish.reset_mock()
|
||||
|
||||
# Close tilt status would be received from device when non-optimistic
|
||||
@@ -924,7 +928,9 @@ async def test_tilt_via_invocation_defaults(hass, mqtt_mock):
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
mqtt_mock.async_publish.assert_called_once_with("tilt-command-topic", 100, 0, False)
|
||||
mqtt_mock.async_publish.assert_called_once_with(
|
||||
"tilt-command-topic", "100", 0, False
|
||||
)
|
||||
mqtt_mock.async_publish.reset_mock()
|
||||
|
||||
# Open tilt status would be received from device when non-optimistic
|
||||
@@ -942,7 +948,7 @@ async def test_tilt_via_invocation_defaults(hass, mqtt_mock):
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
mqtt_mock.async_publish.assert_called_once_with("tilt-command-topic", 0, 0, False)
|
||||
mqtt_mock.async_publish.assert_called_once_with("tilt-command-topic", "0", 0, False)
|
||||
|
||||
|
||||
async def test_tilt_given_value(hass, mqtt_mock):
|
||||
@@ -976,7 +982,9 @@ async def test_tilt_given_value(hass, mqtt_mock):
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
mqtt_mock.async_publish.assert_called_once_with("tilt-command-topic", 80, 0, False)
|
||||
mqtt_mock.async_publish.assert_called_once_with(
|
||||
"tilt-command-topic", "80", 0, False
|
||||
)
|
||||
mqtt_mock.async_publish.reset_mock()
|
||||
|
||||
await hass.services.async_call(
|
||||
@@ -986,7 +994,9 @@ async def test_tilt_given_value(hass, mqtt_mock):
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
mqtt_mock.async_publish.assert_called_once_with("tilt-command-topic", 25, 0, False)
|
||||
mqtt_mock.async_publish.assert_called_once_with(
|
||||
"tilt-command-topic", "25", 0, False
|
||||
)
|
||||
mqtt_mock.async_publish.reset_mock()
|
||||
|
||||
# Close tilt status would be received from device when non-optimistic
|
||||
@@ -1004,7 +1014,9 @@ async def test_tilt_given_value(hass, mqtt_mock):
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
mqtt_mock.async_publish.assert_called_once_with("tilt-command-topic", 80, 0, False)
|
||||
mqtt_mock.async_publish.assert_called_once_with(
|
||||
"tilt-command-topic", "80", 0, False
|
||||
)
|
||||
mqtt_mock.async_publish.reset_mock()
|
||||
|
||||
# Open tilt status would be received from device when non-optimistic
|
||||
@@ -1022,7 +1034,9 @@ async def test_tilt_given_value(hass, mqtt_mock):
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
mqtt_mock.async_publish.assert_called_once_with("tilt-command-topic", 25, 0, False)
|
||||
mqtt_mock.async_publish.assert_called_once_with(
|
||||
"tilt-command-topic", "25", 0, False
|
||||
)
|
||||
|
||||
|
||||
async def test_tilt_given_value_optimistic(hass, mqtt_mock):
|
||||
@@ -1062,7 +1076,9 @@ async def test_tilt_given_value_optimistic(hass, mqtt_mock):
|
||||
]
|
||||
assert current_cover_tilt_position == 80
|
||||
|
||||
mqtt_mock.async_publish.assert_called_once_with("tilt-command-topic", 80, 0, False)
|
||||
mqtt_mock.async_publish.assert_called_once_with(
|
||||
"tilt-command-topic", "80", 0, False
|
||||
)
|
||||
mqtt_mock.async_publish.reset_mock()
|
||||
|
||||
await hass.services.async_call(
|
||||
@@ -1077,7 +1093,9 @@ async def test_tilt_given_value_optimistic(hass, mqtt_mock):
|
||||
]
|
||||
assert current_cover_tilt_position == 25
|
||||
|
||||
mqtt_mock.async_publish.assert_called_once_with("tilt-command-topic", 25, 0, False)
|
||||
mqtt_mock.async_publish.assert_called_once_with(
|
||||
"tilt-command-topic", "25", 0, False
|
||||
)
|
||||
|
||||
|
||||
async def test_tilt_given_value_altered_range(hass, mqtt_mock):
|
||||
@@ -1119,7 +1137,9 @@ async def test_tilt_given_value_altered_range(hass, mqtt_mock):
|
||||
]
|
||||
assert current_cover_tilt_position == 50
|
||||
|
||||
mqtt_mock.async_publish.assert_called_once_with("tilt-command-topic", 25, 0, False)
|
||||
mqtt_mock.async_publish.assert_called_once_with(
|
||||
"tilt-command-topic", "25", 0, False
|
||||
)
|
||||
mqtt_mock.async_publish.reset_mock()
|
||||
|
||||
await hass.services.async_call(
|
||||
@@ -1134,7 +1154,7 @@ async def test_tilt_given_value_altered_range(hass, mqtt_mock):
|
||||
]
|
||||
assert current_cover_tilt_position == 0
|
||||
|
||||
mqtt_mock.async_publish.assert_called_once_with("tilt-command-topic", 0, 0, False)
|
||||
mqtt_mock.async_publish.assert_called_once_with("tilt-command-topic", "0", 0, False)
|
||||
mqtt_mock.async_publish.reset_mock()
|
||||
|
||||
await hass.services.async_call(
|
||||
@@ -1149,7 +1169,9 @@ async def test_tilt_given_value_altered_range(hass, mqtt_mock):
|
||||
]
|
||||
assert current_cover_tilt_position == 50
|
||||
|
||||
mqtt_mock.async_publish.assert_called_once_with("tilt-command-topic", 25, 0, False)
|
||||
mqtt_mock.async_publish.assert_called_once_with(
|
||||
"tilt-command-topic", "25", 0, False
|
||||
)
|
||||
|
||||
|
||||
async def test_tilt_via_topic(hass, mqtt_mock):
|
||||
@@ -1353,7 +1375,9 @@ async def test_tilt_position(hass, mqtt_mock):
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
mqtt_mock.async_publish.assert_called_once_with("tilt-command-topic", 50, 0, False)
|
||||
mqtt_mock.async_publish.assert_called_once_with(
|
||||
"tilt-command-topic", "50", 0, False
|
||||
)
|
||||
|
||||
|
||||
async def test_tilt_position_altered_range(hass, mqtt_mock):
|
||||
@@ -1389,7 +1413,9 @@ async def test_tilt_position_altered_range(hass, mqtt_mock):
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
mqtt_mock.async_publish.assert_called_once_with("tilt-command-topic", 25, 0, False)
|
||||
mqtt_mock.async_publish.assert_called_once_with(
|
||||
"tilt-command-topic", "25", 0, False
|
||||
)
|
||||
|
||||
|
||||
async def test_find_percentage_in_range_defaults(hass, mqtt_mock):
|
||||
|
||||
Reference in New Issue
Block a user