mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Support variables in templates with timeout (#66990)
This commit is contained in:
parent
0dfc4ec9be
commit
8ea6cbc257
@ -346,7 +346,7 @@ async def handle_render_template(
|
||||
if timeout:
|
||||
try:
|
||||
timed_out = await template_obj.async_render_will_timeout(
|
||||
timeout, strict=msg["strict"]
|
||||
timeout, variables, strict=msg["strict"]
|
||||
)
|
||||
except TemplateError as ex:
|
||||
connection.send_error(msg["id"], const.ERR_TEMPLATE_ERROR, str(ex))
|
||||
|
@ -706,6 +706,38 @@ async def test_render_template_renders_template(hass, websocket_client):
|
||||
}
|
||||
|
||||
|
||||
async def test_render_template_with_timeout_and_variables(hass, websocket_client):
|
||||
"""Test a template with a timeout and variables renders without error."""
|
||||
await websocket_client.send_json(
|
||||
{
|
||||
"id": 5,
|
||||
"type": "render_template",
|
||||
"timeout": 10,
|
||||
"variables": {"test": {"value": "hello"}},
|
||||
"template": "{{ test.value }}",
|
||||
}
|
||||
)
|
||||
|
||||
msg = await websocket_client.receive_json()
|
||||
assert msg["id"] == 5
|
||||
assert msg["type"] == const.TYPE_RESULT
|
||||
assert msg["success"]
|
||||
|
||||
msg = await websocket_client.receive_json()
|
||||
assert msg["id"] == 5
|
||||
assert msg["type"] == "event"
|
||||
event = msg["event"]
|
||||
assert event == {
|
||||
"result": "hello",
|
||||
"listeners": {
|
||||
"all": False,
|
||||
"domains": [],
|
||||
"entities": [],
|
||||
"time": False,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
async def test_render_template_manual_entity_ids_no_longer_needed(
|
||||
hass, websocket_client
|
||||
):
|
||||
|
Loading…
x
Reference in New Issue
Block a user