Write debug messages / file from Jinja2 (template)


I have some little complex Jinja2 scripts in state template and it would be niche to write some debug output within the Jinja2 part to a log or file?

Is there any solution to get detail output whereby the trigger and template steps could monitored?


1 Like

You can log whatever messages you want to the logbook (not the system log), see:


Or you can write them to a file using the file notification integration, see:


Example of use: https://www.home-assistant.io/integrations/file/#entries-as-csv

1 Like

Within the Jinja2 code there is no possibility?

I want o return vars on certain places in the Jinja template code.


Correct. Jinja2 returns strings, and does not have the capability to “do” anything beyond that.

1 Like