Help with conditional icon colour

Hey guys,

first post here so please go easy on me. Im a long term openhanded user but after hearing everyone raving about how good ha is I’m in the process of moving everything across to home assistant to see how it compares.

Im playing around with the web gui atm and creating a dashboard. What I’ve done is create a group of the 3 main ceiling lights in the lounge and what im hoping to achieve is if one of the lights is on in the group the icon will be orange but it’s not working atm.

This is my code. that I’ve put into the colour box while creating the card.

(% if is_state('light.main_lounge', 'on) %)
orange
{% endif %)

Hello and welcome to the forum.

Very few Core Dashboard Cards support templates.

There are third party options, but you have not supplied sufficient information to advise you.

What card are you trying to use?

What is your full card configuration, correctly formatted for the forum (do not post a screen shot).

1 Like

Sorry, here’s a little more info.

Im using the mushroom cards, precisely the mushroom template card. I’m loosely following a YouTube video where it works I can’t get it to work. My updated code

{% if is_state('light.main_lounge,'on') %)
orange
{% endif %)

just saw the other tab showing the code editor.

type: horizontal-stack
cards:
  - type: custom:mushroom-template-card
    primary: Lounge
    secondary: '{{ states(''sensor.lounge_sensor_temperature'')}} °c'
    icon: mdi:television
    entity: light.dimmer_2_6
    icon_color: |-
      {% if is_state('light.main_lounge,'on') %)
      orange
      {% endif %)
    tap_action:
      action: navigate
      navigation_path: Lounge
    hold_action:
      action: toggle
    double_tap_action:
      action: toggle

You need to supply an else case for when the light is not on. What colour should it be then?

    icon_color: |-
      {% if is_state('light.main_lounge,'on') %}
        orange
      {% else %}
        blue
      {% endif %)

Also your last bracket %} for the if statement was incorrectly a parenthesis %)

Awesome, thanks for your help. here’s the working code incase it helps anyone else.

{% if is_state('light.main_lounge','on') %}
orange
{% endif %}