that seems very unlikely… the exact state is required though
I dont have a single double inside quote in my entire config (and it’s against guidelines too…)
any valid jinja template should work, and just test that in the dev tools template. also, those iif’s can have unexpected results, so best not use them in these cases.
instead of
{{ iif(states(config.entity) |int >= 50,'lime', iif(states(config.entity) |int >= 30,'yellow',iif(states(config.entity) |int >= 0,'red')))}}
why not simply do
{% set state = states(config.entity) |int(-1) %}
{% if state >= 50 %} lime
{% elif state >= 30 %} yellow
{% elif state >= 0 %} red
{% else %} black
{% endif %}
you could also leave out the final condition for the red, and do:
{% set state = states(config.entity) |int(-1) %}
{% if state >= 50 %} lime
{% elif state >= 30 %} yellow
{% else %} red
{% endif %}
but, given the default I set in the state, I prefer catching that too
same for
{{ iif(states(config.entity) == "On" ,'green', iif(states(config.entity) =="Off",'yellow',iif(states(config.entity) == "Auto (off)",'red')))}};
use:
{% set state = states(config.entity) %}
{% if state == 'On' %} green
{% elif state == 'Off' %} yellow
{% else %} red
{% endif %}
or, use a mapper for the equality checks:
{% set state = states(config.entity) %}
{% set color = {'On':'green',
'Off':'yellow',
'Auto (off)':'red'} %}
{{color.get(state,'black')}}
same as before, either ditch the last check, or add it and use an extra guard for unforseen states