Extend template entities with a script section (#96175)

* Extend template entities with a script section

This allows making a trigger entity that triggers a few times a day,
and allows collecting data from a service resopnse which can be
fed into a template entity.

The current alternatives are to publish and subscribe to events or to
store data in input entities.

* Make variables set in actions accessible to templates

* Format code

---------

Co-authored-by: Erik <erik@montnemery.com>
This commit is contained in:
Allen Porter
2023-09-02 16:19:45 -07:00
committed by GitHub
parent 6312f34538
commit 7b1c0c2df2
7 changed files with 79 additions and 10 deletions

View File

@ -713,12 +713,12 @@ async def handle_execute_script(
context = connection.context(msg)
script_obj = Script(hass, script_config, f"{const.DOMAIN} script", const.DOMAIN)
response = await script_obj.async_run(msg.get("variables"), context=context)
script_result = await script_obj.async_run(msg.get("variables"), context=context)
connection.send_result(
msg["id"],
{
"context": context,
"response": response,
"response": script_result.service_response if script_result else None,
},
)