Write debug messages / file from Jinja2 (template)

Hi,

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?

Steffen

1 Like

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

https://www.home-assistant.io/integrations/logbook/#custom-entries

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

https://www.home-assistant.io/integrations/file/#notifications

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.

Steffen

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

1 Like