Change icon color in mushroom-cover-card

I have been trying to change the icon color of my cover card based upon its state for several days now but with no success. I have read the articles and need some assistance if indeed this is even possible for the cover card. Below is one of the latest (not working) attempts:

- type: custom:mushroom-cover-card
    name: South Upstairs Garage Bay Door
    show_buttons_control: true
    entity: cover.smart_garage_door_opener_door
    icon: mdi:garage-variant
    icon_color: "{{ 'red' if is_state('cover.smart_garage_door_opener_door', 'closed') else 'green' }}"
    fill_container: true
    show_position_control: false
    show_tilt_position_control: false

only the mushroom template card supports templates. You’re trying to use a template in the mushroom-cover-card

If you want to use templates for the mushroom-cover-card, you need to use card-mod which is a separate custom card.

like @petro said you can only use that in a template card
but if you have card_mod this should work for you.

card_mod:
  style:
    mushroom-shape-icon$: |
      .shape {
      {% set state = states('cover.smart_garage_door_opener_door') %}
       {% if state == ('closed') %}
         --shape-color: rgba(255,0,0, .2) !important;
       (% else %)
         --shape-color: rgba(0,128,0, .2) !important; 
       {% endif %}  
      }
    .: |
      ha-state-icon {
       {% set state = states('cover.smart_garage_door_opener_door') %}
       {% if state == ('closed') %}
         color: var(--red-color) ;
       (% else %)
         color: var(--green-color) ;
       {% endif %}  
      }

1 Like

Awesome! Thank you so very much you saved me hours trying to figure out card-mod!!

1 Like