Condition and template (not even example is working)

I am having trouble to use template elements in automations. It works with Telegram messages but for example I am not even able to use the example found at the bottom of the page here: Automation Conditions - Home Assistant

When I click on Test or Save i get the error (please see screenshot).

What am I doing wrong?

There is a known bug in the Automation Editors condition tester with Template and Zone conditions. Use the Developers Tool > Template tool to test your templates. This bug does not affect the function of the templates, it it just the tester which is broken.

When using the gui for automations, only the template should go in. Remove the “condition:”

thanks for the hint but somehow it still does not work. If I use the gui I need to select a condition type first …for example “and” or “template”. For a while I thought that this is not important since I see that in yml and can change it there directly in the gui but maybe that is wrong.

actuallly I get the error when saving the automation - well - i get the error also when testing but since I get it there when trying to save I can not even use the gui there. I might need to do it completely without gui …not sure

This is how it looks, in a working condition.

First the yaml version


condition: template
value_template: >-
  {{  (as_timestamp(now()) - as_timestamp(states('sensor.elmaler_2_last_seen')))
  | float(0) > 120 }}

Then the GUI view of the same. You can not see all the text, however it is all on one line.

thanks a lot for posting the screenshot and the yml code. That helps quite a lot.
I am wondering if I partly fooled myself by the way I tried to test my automation.

I did one where i put a condition like this
{{ state_attr(‘sun.sun’, ‘elevation’) < 4 }}
and one where i put it like this
{{ state_attr(‘sun.sun’, ‘elevation’) > 4 }}

when I manually execute them they both fire a telegram message which is the action at the end. I am wondering if a manual execution overrides the condition.

I also did a timer trigger

platform: time_pattern
minutes: “1”

…but that does not fire a single time

Are there some best practises to debug / troubleshoot automations? Of couse I am able to just test a condition in the developer tools but if the automation is not working there are many potential root causes.

Is there something I am missing regarding the timer trigger? That could be a nice an easy way to trigger an automation without overriding the condition (which of course is only needed if I am right when I am thinking that a manual exection overrides the condition …at least it seems to happen for me).

oh …while I am writing this I got one telegram message …maybe it takes more than a minute before it first works … …at least i got only one message even there are 2 automatons just with opposite conditions …

thank you all for you feedback

just noticed that i set the timer to run every hour and not every minute :wink: …looks i finally got the condition working :slight_smile: thank you all