From 5c29959324336cd0628278ca8afad609be3d346a Mon Sep 17 00:00:00 2001 From: Mike Degatano Date: Mon, 21 Feb 2022 13:41:10 -0500 Subject: [PATCH] Use context data to debug templates New context data option on the Developer Tools -> Template tab makes it easier to debug automations. Can just copy and paste the YAML from from the traces instead of creating a bunch of variables in Jinja at the top. --- source/_docs/automation/troubleshooting.markdown | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/_docs/automation/troubleshooting.markdown b/source/_docs/automation/troubleshooting.markdown index fcdcbbe9a8a..41d2e87f4d4 100644 --- a/source/_docs/automation/troubleshooting.markdown +++ b/source/_docs/automation/troubleshooting.markdown @@ -40,6 +40,6 @@ It is also useful to go to **{% my server_controls title="Configuration -> Serve If your automation uses templates in any part, you can do the following to make sure it works as expected: 1. Go to **{% my developer_template title="Developer tools -> Template" %}** tab. -2. Create all variables (sources) required for your template as described at the end of [this](https://www.home-assistant.io/docs/configuration/templating/#processing-incoming-data) paragraph. -3. Copy your template code and paste it in Template editor straight after your variables. -4. If necessary, change your sources' value and check if the template works as you want and does not generate any errors. +1. In your trace go through the steps preceeding the one with your template and copy what you need from the `changed variables` tabs into `Context data for template` in the Template tab. *Tip: `trigger` and `this` are set in the very first step* +1. Copy your template code and paste it in Template editor straight after your variables. +1. Change the template and (if necessary) sources' value until the template works as expected without errors.