Mushroom Chips Card icon colour change

Hi,
I have seen some other topics on this subject, but I have not been able to use the info in these to get a colour change working. Here’s my code for the chip:

  - type: entity
    entity: sensor.hot_water_temperature
    icon: mdi:thermometer-water
    name: Hot Water
    use_entity_picture: false
    icon_color: |-
      {% set hwstatus = states(sensor.hot_water_state)}
      {% if hwstatus = "On"}
        red
      {% else %}
        black
      {% endif %}

sensor.hot_water_state is a template to pull a nested attribute out of the entity and has the values On or Off. I have tried a few syntax options without success. Can anyone see what I am doing wrong?

On a side note, whenever I save changes to the yaml, >- gets changed to |- and the line break between the set and if statements gets deleted. Is this related?

Many thanks.

Looks like you aren’t properly closing your braces. You have a } ending your first two lines when it should be %}

As for the change between >- and |- you want the second not the first for a block like that.

See this site for why and to play around with the different multi-line styles for YAML.

>- and |- seems to be mutually interchangeable just like ' and " so that is probably not it.
The rearranging of the lines happens all the time and it should have no general impact, except when you want to set or remove extra line break in the output, which is not the case here.

I can’t seem to find an attribute called icon_color. Where did you find the documentation on that?

Thanks all.

icon_color seems to be a standard attribute. Here’s another chip from the same card:

  - type: entity
    entity: switch.bedroom_upright_lamp
    name: Bedroom
    icon: mdi:lightbulb
    icon_color: blue

I tried changing the braces to %}, but that didn’t seem to help.

Ahh, found it.

But it looks like it is only a string and it might not be templateable (if that work exist :smiley: )

Perhaps that’s the problem. The same(ish) question has been asked on other threads:

And there were a lot of suggestions, but I have not been able to make them work.

I use card_mod for that, but I do not know how mushroom cards react with that.
You could test it.

If you use a template chips card, you can change the icon color with a template, this is one of mine:

  - type: custom:mushroom-chips-card
    chips:
      - type: template
        entity: sensor.toilet_current_temperature
        icon: mdi:thermometer
        icon_color: >-
          {% if states ('sensor.toilet_state') == "ON" %}
            red 
          {% endif %}
        content: '{{ states ("sensor.toilet_current_temperature") }}°C'

Just noticed that to do a compare the OP used a = instead of ==

@jbarrett-fmad There are two main mushroom threads