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.
This commit is contained in:
Mike Degatano 2022-02-21 13:41:10 -05:00 committed by GitHub
parent 364fdc00f7
commit 5c29959324
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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: 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. 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. 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*
3. Copy your template code and paste it in Template editor straight after your variables. 1. 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. Change the template and (if necessary) sources' value until the template works as expected without errors.