Return the listeners with the template result for the websocket api (#39925)

This commit is contained in:
J. Nick Koston authored and GitHub committed 2020-09-11 13:18:40 -05:00
1 parent 9b29d09d45
commit 741487a1fc
4 files changed
+118 -11

No files matched your search

@@ -253,9 +253,11 @@ def handle_render_template(hass, connection, msg):
template.hass = hass
variables = msg.get("variables")
info = None
@callback
def _template_listener(event, updates):
nonlocal info
track_template_result = updates.pop()
result = track_template_result.result
if isinstance(result, TemplateError):
@@ -267,7 +269,11 @@ def handle_render_template(hass, connection, msg):
result = None
connection.send_message(messages.event_message(msg["id"], {"result": result}))
connection.send_message(
messages.event_message(
msg["id"], {"result": result, "listeners": info.listeners} # type: ignore
)
)
info = async_track_template_result(
hass, [TrackTemplate(template, variables)], _template_listener