My intention was to only do the action part if sensor.max24h minus input_number.some_variable is greater than 0.
Whenever I put in the jinja template in the template section of the developer tools I get a true as a outcome. So in my opinion this should work…
The error I get is :
Error occurred while testing condition
template value should be a string for dictionary value @ data['value_template']. Got None
Well, in Dutch it isn’t a misspelling . It was a Dutch variable name but I changed it just before posting.
I forgot to mention in the OP that my code works in the template section of the developer tools and it returns true.
For sanity I’ve add the default zero but unfortunately this doesn’t seem to help…
Well, it is only a issue in the automation editor when editing and testing. Just test your templates in the developer section (templates tab) and all should work fine.
So the GH link doesn’t help me but I learned to live with the issue
Just got bit by this after spinning a lot of cycles trying to figure out what I’m doing wrong. This is a pretty bad UI situation here, if you’re going to offer a TEST button, it’s probably better if it returns valid results.
I’d posit that returning invalid results is worse than not offering a test function at all.
I just tried to create an automation to check every half hour if my temperature was 3 degrees higher than the thermostat is set (having breaker issues).
The template works fine in the template editor. When I put it in the automation, it always shows true and has the error when I test it.
I’ve noticed that when I switch to yaml, it adds extra characters after the “value_template:” section. (Same as in OP, it makes it “value_template: >-”)
Ok… Well, it seems to work when it triggers itself. When I hit “Run Action”, it reads the condition wrong (or else doesn’t even evaluate the condition?).
When you hit “Run Actions” it does what it says, runs the actions. Nothing to do with conditions or triggers.
If you want to test the automation including conditions go to Developer Tools → Services and use the Trigger Automation service. It has an option to skip conditions that you can turn off.
Maybe my experience with this will help others. I had the same problem: the “template value should be a string for dictionary value” error message obscured things but @pathia last tip helped: calling the trigger service without skipping conditions revealed the condition was in fact not working.
My previous condition template:
"{{ now().month >= 5 or now().month <= 9 }}"
My working one:
{{ now().month >= 5 or now().month <= 9 }}
So, removing the quotation marks was necessary because home assistant automatically adds single quotation marks .