From 08817e566f4e3dea425ba48875df4a40c1418cf7 Mon Sep 17 00:00:00 2001 From: akasma74 Date: Mon, 13 Apr 2020 07:23:15 +0100 Subject: [PATCH] correct note about trigger (#12372) * correct note about trigger Don't think the existing way of testing automations with trigger in templates makes sense. I tried to show how to debug such automations. * add missing bracket to fix the build --- source/_docs/automation/templating.markdown | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/source/_docs/automation/templating.markdown b/source/_docs/automation/templating.markdown index d5ff1b98553..4743ec8ea57 100644 --- a/source/_docs/automation/templating.markdown +++ b/source/_docs/automation/templating.markdown @@ -76,7 +76,15 @@ Knowing how to access the [state object](/docs/configuration/state_object/) of a
- Be aware that if you reference a trigger state object in an automation action, attempting to test that automation by calling the `automation.trigger` service or by clicking EXECUTE in the More Info box for the automation will not work. This is because the trigger state object doesn't exist in those contexts. One way to test automations like these is to manually change the state of the trigger entity at Developer Tools > States. + Be aware that if you reference a `trigger` state object in templates of automation `action`, attempting to test that automation by calling the `automation.trigger` service or by clicking EXECUTE in the More Info box for the automation will not work. This is because the trigger state object doesn't exist in those contexts. One way to test automations like these is to manually check that the templates work as expected by pasting them in Developer Tools > Template together with your trigger's definition like: + +{%raw%} +```yaml +{% set trigger={'to_state':{'state': 'heat'}} %} +{% set option = trigger.to_state.state %} +{{ 'on' if option == 'heat' else 'off' }} +``` +{%endraw%}