1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-23 12:29:55 +00:00

Support templating MQTT triggers (#45614)

* Add support for limited templates (no HASS access)

* Pass variables to automation triggers

* Support templates in MQTT triggers

* Spelling

* Handle trigger referenced by variables

* Raise on unsupported function in limited templates

* Validate MQTT trigger schema in MQTT device trigger

* Add trigger_variables to automation config schema

* Don't print stacktrace when setting up trigger throws

* Make pylint happy

* Add trigger_variables to variables

* Add debug prints, document limited template

* Add tests

* Validate MQTT trigger topic early when possible

* Improve valid_subscribe_topic_template
This commit is contained in:
Erik Montnemery
2021-02-08 10:50:38 +01:00
committed by GitHub
parent b9b1caf4d7
commit 047f16772f
12 changed files with 262 additions and 15 deletions

View File

@@ -21,6 +21,7 @@ class ScriptVariables:
run_variables: Optional[Mapping[str, Any]],
*,
render_as_defaults: bool = True,
limited: bool = False,
) -> Dict[str, Any]:
"""Render script variables.
@@ -55,7 +56,9 @@ class ScriptVariables:
if render_as_defaults and key in rendered_variables:
continue
rendered_variables[key] = template.render_complex(value, rendered_variables)
rendered_variables[key] = template.render_complex(
value, rendered_variables, limited
)
return rendered_variables