Help with template with IF this OR this ELSE this

HI,

can someone please help me with this template?

I’ve made in in dev tools and in this environment it works.

When I copy pasted it to vscode I see many error and in effect config is wrong.

{% if is_state('sensor.ultimo_carico', 'lavastoviglie') or is_state('sensor.ultimo_carico', 'lavatrice')  %}
  Il controllo carichi ha spento la {{ states('sensor.ultimo_carico') }}.
{% else %}
  Il controllo carichi ha spento il {{ states('sensor.ultimo_carico') }}.
{% endif %}

Thank you in advance!

There’s nothing wrong with that template. Show where it is used.

Found out:

This was a message and the > symbol was missing:

          message: >
              {% if is_state('sensor.ultimo_carico', 'lavastoviglie') or is_state('sensor.ultimo_carico', 'lavatrice')  %}
                Il controllo carichi ha spento la {{ states('sensor.ultimo_carico') }}.
              {% else %}
                Il controllo carichi ha spento il {{ states('sensor.ultimo_carico') }}.
              {% endif %}```

If you’re interested, you can also write the template like this:

          message: >
            {% set s = state('sensor.ultimo_carico') %}
            Il controllo carichi ha spento {{'la' if s in ['lavastoviglie', 'lavatrice'] else 'il'}} {{s}}.
1 Like

MUCH simpler! Thank you so much!