I’m trying to trigger a WLED device using the automation below.
I’ve verified that the boolean state of the template correctly transitions from false to true (and back again) according to the status of Zwift (sensor.zwift_online_xxxxxx) via the developer template test area as well as in the automation template debugger itself.
Running the automation action manually also works as expected.
Despite this I cannot get the automation to trigger for some reason. Can anyone kindly help?
I have tried restarting HA also but this has had no effect. I’m on HA Core version 2026.2.2 on the latest HA OS 17.1.
The automation was set-up via the UI but I’ve copied the YAML out unmodified to paste here. Is there any reason this shouldn’t trigger?
Others will check, but I think this simplifies things a but…
Your original I think was just missing the .state if I am correct.
However all the template wants is true or false, and your original sensor you are stating gives you that. (Are you sure that’s not a binary sensor?)
Thanks both! I can confirm that the script Taras posted worked correctly and triggered when Zwift was online.
I’m a little confused why that works and my own script doesn’t since they both evaluate to either true or false. Is it because my script is missing the bool() part?
Your version includes a YAML-style comment in the middle of a Jinja2 template (specifically where it’s supposed to return true). Jinja2 comments use different syntax so that entire line became part of what was supposed to be a logical true response (rendering it invalid).