Template 'If' statement Lovelace

Hi all,

I use the custom sidebar and added a template sensor to identify how many switches are active and or lights.

For example: it states when switches are active as:
0 switches active or 1 switches active. i rather have it read out as 0 switches active or 1 switch active and for 1 and above it implies as: switches again. I would like to be able to sort out the plural ways of this statement. but i couldnt figure out how to write the if.

All help is appreciated. thanks!

{% set lights = states.light | selectattr('state','eq','on') | list %}
{{ "%d %s" | format(lights | length, "lampen" if lights | length > 1 else "lampe") }}
1 Like

Worked great, thank you! appreciate it