Service template, jinja,


Can someone explain to me why code 1 works, but code 2 doesn’t? It should produce the same command fed to the service … according to dev tools > templates
I either get

in both cases.

- service: >
    {% if 'hold' in command %} 
    {% else %}
    {% endif %}


- service: >    
      input_boolean.turn_{{ 'on' if 'hold' in command else 'off' }}

No. I cant explain it. They should be equivalent.

What error do you see with the second version?

None… I can safely reload my automations without errors but the automation stops working.
And that is the only change made in the automation
And makes the difference from working to non working

What about the automation trace?

Does that reveal anything?

I’ll have to get back to you on that, tracing does not appear to work while the automation is in a package.
The option is disabled.

Does the automation have an id:?

I thought that was the only requirement for trace to be able to be used.

Did not know that, alright. I’ll give it a go after lunch :clap: thank you

1 Like

Alright thank you once again, I’ve narrowed down the culprit.
It wasn’t the service at all, was just unfortunate enough to try the code change
with different circumstances (light was on as opposed to off) which showed me an unrelated fault in my code :stuck_out_tongue:

nice feature, wasnt even aware of tracing before this!