Mushroom Chips - entity icon coloring by state?

Hello All,

I’m using the mushroom cards and love the way that when I create an entity card, I get the icon/card color coded dynamic based on the state of the entity. I’m trying to get that same functionality to work on the chips, but can’t seem to get it to work and noice that the chips have only an “icon color” and options for default or a color picker.

Is there a way to do this without having to write my own conditionals in a chip template?

Thanks!

use the template chip. Here’s one of mine to give you an idea (ignore that it is sitting inside a conditional card):

- type: conditional
  conditions:
  - entity: sensor.count_of_low_battery
    state_not: "0"
  chip:
    type: template
    entity: sensor.count_of_v_low_battery
    content: "{{ states(entity) }}"
    icon: "{{ iif(is_state(entity,'0'),'mdi:battery-50','mdi:battery-20') }}"
    icon_color: "{{ iif(is_state(entity,'0'),'amber','red') }}"
    tap_action:
      action: navigate
      navigation_path: /lovelace/battery

[edited: typos and clarity and one small improvement I spotted]

Hi -

Thanks for the incredibly quick response! I am aware of doing it manually. I was wondering if there was a way of having it applied automatically. For example, my door lock has a battery and when I add the battery as an entity card the battery icon and color update automatically. Since I’m use to DRY coding, card coding the yaml feels very wrong to me, but if that is the only way I understand.

Thanks!

I just read the last sentence in your opening post - sorry for missing that.

I’m not sure what DRY coding means.
Also not sure what you mean by ‘automatically’.

Dry means Do Not Repeat.

For example, I would like to have some definition of state coding and icons for different entities (which I realize now is in HA and not necessarily in mushroom cards), that whenever I call an attribute or variable in yaml (for example state_color: true) it would apply the colors depending on the state.

This is more efficient/consistent vs. having to write the same yaml if statements across multiple cards.

Thanks!

agh, OK - so like some global state/colour rules? The closest you can get is maybe themed colours and using customize but not sure that will do what you want.