Hi,
I want to start a pump based on a time but want to make a test before that. When I test the template in developer options it works, meaning it returns either a true or false but when I use it in my automation it always returns a false thus the autiomation does not trigger. Anybody that can help me?
A great input. This is what I get:
1(number): 1653905762.04604
2 (string) : 2022-05-29 18:17:54.801431+00:00
3 (number): 1653848274.801431
4 (number): 57628.371796131134
And if I do the last one (the template from the first post) I get a string “True”
So all looks good to me. However in the automation is reminds false thus the automation never initiate.
the difference in your template is like 50k. You have to have that difference drop below 4k, then that difference has to go above 4k to trigger. In order for templates to trigger they need to resolve False then at a later time, resolve True. Otherwise it will not trigger.
Okay then there must be something I have misunderstood. I wanted to make an automation that triggers at a fixed time with the condition below and only trigger if this condition is true.
Was it less than one second ago since the automation triggered last time?
You need to make sure the template returns false when you save the automation.
I doubt the template you posted returns false.
I see your problem. You aren’t understanding the differences between YAML and the templating engine and you’re combining single line yaml and multi-line yaml syntax.
When you use some_field: >-, you’re telling the yaml that all indented lines below this belong to this some_field.
When you use some_field: "..." you’re telling the yaml that everything between the quotation marks belongs to this field and is a string. Yaml will naturally remove the quotation marks because it’s not part of the value.
When you combine the 2, your result will always be wrapped in quotes. And "True" does not resolve to True and "False" does not resolve to False.
We would have seen this sooner if you posted your entire yaml, i.e. the field and the template.
Either way, I can see that in your condition.
If you’re going to use multiline notation for your templates, remove the exterior quotes.