I’m trying to change an icon color to orange if the count of lights on in the room is > 0 using the following code:
{% set total = 0 %}
{% if is_state('light.front_office_overhead_lights_dimmer', 'on') %}
{% set total = total + 1 %}
{% endif %}
{% if is_state('light.front_office_desk_lamp', 'on') %}
{% set total = total + 1 %}
{% endif %}
{% if is_state('light.front_office_fan_light', 'on') %}
{% set total = total + 1 %}
{% endif %}
({{total}}) Lights ON
icon: mdi:lightbulb-group
icon_color: |-
{% if total > 0 %}
orange
{% else %}
gray
{% endif %}
but that doesn’t work. The only way I’m able to get it to work is if I create an if statement that checks if each light is on and if so, set it to orange. Would rather do it if the count is greater than 0, to safe a lot of copy/pasting.
It evaluates correctly in Developer template tools, but the icon color doesn’t actually change.
Thanks.