This template basically checks a light and if it’s been turned off within the last 4 hours. This template works fine testing under dev tools, but never returns a true verdict when inside an automation value template, even when it’s been more than 14400 seconds. What am I doing wrong?
The Template Condition I posted was intended to be placed within an automation’s YAML code. That’s why it has indentation and a leading hyphen (and mimics your original example).
You appear to have placed it into the UI’s editing window for a Template Condition. In that situation, there should be no leading hyphen or indentation of its keys. In fact, it should only be the template itself and no YAML at all.
Look at your screenshot and you’ll see the field’s name is “Value template”. Therefore the only thing it expects in that field is a Jinja2 template (and not any YAML).
Now that you have used the UI to create a valid Template Condition, switch the Automation Editor to YAML mode and observe how it translates the UI-based Template Condition into a YAML-based Template Condition. It will look very much like what I originally posted.
The takeaway here is that when you create a Template Condition via the UI, the “Value template” field expects to receive just the Jinja2 template. It knows how to automatically include all the YAML parts. If you add YAML in that field, the end result is an invalid Template Condition.