I have an automation that runs when a sensor is updated. It performs a bunch of analysis and then returns a structure with a scene and a boolean (whether or not to activate the scene).
When I paste my script into the template tool it evaluates, as I expect it to, to:
{
"scene": "scene.high_power",
"update": true
}
But I can’t get the conditional in my automation to use the value of update.
When I do a trace, it comes back that the conditional was false
Executed: January 17, 2025 at 1:44:28 PM
if
Executed: January 17, 2025 at 1:44:28 PM
Result:
result: false
if/condition/0
[If template renders a value equal to true]
Executed: January 17, 2025 at 1:44:28 PM
Result:
result: false
entities: []
I tried that and now I get this error in my trace:
Error: In 'template' condition: ValueError: Template error: bool got invalid input '' when rendering template '{{ new_scene.update | bool }}' but no default was specified
Am I correct that this makes it look like a scope issue? like my value_template doesn’t know about new_scene?
Thank you both so much for helping me with this. I finally got it working.
I think update must be some kind of reserved keyword or something. I changed the name of the variable from ‘update’ to ‘doit’ and everything started working just as I intended.
That is strange, it must be clashing with an underlying Python method… I just checked and it does work if you use bracket notation instead of dot notation as follows: