Mushroom Cards - Build a beautiful dashboard easily šŸ„ (Part 2)

Thanks for that quick one. I guess Iā€™m still doing something wrong. Adding that in does nothing and breaks my other formatting for the chip.

EDIT: Added my relatively more complex chip template card code

type: custom:mushroom-chips-card
chips:
  - type: template
    entity: light.den
    icon: |-
      {% if is_state(entity, 'on') %}
        mdi:sofa-single
      {% else %}
        mdi:sofa-single
      {% endif %}
    icon_color: |-
      {% if is_state(entity, 'on') %}
        #F97B22
      {% else %}
        #B4B4B8
      {% endif %}
    content: >-
      Den: {{ expand(state_attr(entity, 'entity_id'))|
      selectattr('state','eq','on')|map(attribute='entity_id')|list|count}} / {{
      expand(state_attr(entity,
      'entity_id'))|map(attribute='entity_id')|list|count }}
    card_mod:
      style: |
        ha-card {
          --chip-background: {{ 'lime' if is_state(light.den, 'on') else 'red' }};
          box-shadow: none !important;
          justify-content: right;
          --chip-height: 35px;
          --chip-border-radius: 0px;
          --chip-icon-size: 18px;
          --chip-font-size: 12px;
          font-style: bold;
          font-variant: small-caps;
          padding-right: 0px;
          padding-left: 0px;
          font-family: "Roboto";
          font-weight: bolder;
          min-width: 70px !important;       
        }

If you a specifying the entity, you need single quotes around the entity.

--chip-background: {{ 'lime' if is_state('light.pine', 'on') else 'red' }};

  - type: entity
    entity: light.pine
    tap_action:
      action: toggle
    hold_action:
      action: more-info
    icon: mdi:lamp
    icon_color: green
    content_info: none
    card_mod:
      style: |
        ha-card {
          --chip-background: {{ 'lime' if is_state('light.pine', 'on') else 'red' }};
          justify-content: center;
          --chip-height: 35px;
          --chip-border-radius: 10px;
          --chip-icon-size: 20px;
          --chip-font-size: 9px;
          font-style: bold;
          font-variant: small-caps;
          padding-right: 0px;
          padding-left: 0px;
          font-family: "Roboto";
          font-weight: bolder;
          min-width: 20px !important;       
        }

THANK YOU! Works like a charm! Also learned something new!

Iā€™ll have another look at the Config guide. I just canā€™t seem to wrap my head around how to use .: | , or > or $

Iā€™m just going to piggyback on your kind availability for another follow-up which Iā€™ve been struggling with for days now.

If I were to add any sort of icon animation to this card, how would I go about formatting it into card-mod? Can you please draft an example code

Chips arenā€™t the best to start with. They are the most difficult to mod of the Mushroom Cards.

type: custom:mushroom-chips-card
chips:
  - type: entity
    entity: light.pc_lights
    tap_action:
      action: toggle
    hold_action:
      action: more-info
    icon: mdi:lamp
    icon_color: green
    content_info: none
    card_mod:
      style: |
        ha-card {
          --chip-background: {{ 'lime' if is_state('light.pine', 'on') else 'red' }};
          justify-content: center;
          --chip-height: 35px;
          --chip-border-radius: 10px;
          --chip-icon-size: 20px;
          --chip-font-size: 9px;
          font-style: bold;
          font-variant: small-caps;
          padding-right: 0px;
          padding-left: 0px;
          font-family: "Roboto";
          font-weight: bolder;
          min-width: 20px !important;       
        }
card_mod:
  style:
    mushroom-entity-chip:nth-child(1)$: |
      ha-state-icon {
      animation: blink 2s linear infinite;
       }
      @keyframes blink { 50% {opacity: 0;} }

Thanks! What do you suggest I use as a card/template? Iā€™m not yet there to use YAML for a complete card from scratch and mushroom chips offered some flexibility.

I see youā€™ve added a card-mod at the parent chip level - so if if I have multiple chips, Iā€™d have to use child(2), child(3)ā€¦?

Iā€™m assuming since you did it this way, there is no way of including this under style we used for the entity chip card?

Correct, Dimitriā€™s guide lays that out here. Understanding a template card is a good way to start.

There is also a section on understanding the shadow-root

If you are on Chrome, the Dev Tool helps layout the CSS structure as well. Right click and inspect or F12 will get you to the tool.

1 Like

Thank you. Iā€™m going to do that now.

For some reason, your animation code didnā€™t seem to work for me. Iā€™ve gone ahead and attempted to have it change based on state as well - I know itā€™s wrong, but if you will help me with figuring out the code.

type: custom:mushroom-chips-card
chips:
  - type: template
    entity: light.den
    icon: |-
      {% if is_state(entity, 'on') %}
        mdi:sofa-single
      {% else %}
        mdi:sofa-single
      {% endif %}
    icon_color: |-
      {% if is_state(entity, 'on') %}
        #F97B22
      {% else %}
        red
      {% endif %}
    content: >-
      Den: {{ expand(state_attr(entity, 'entity_id'))|
      selectattr('state','eq','on')|map(attribute='entity_id')|list|count}} / {{
      expand(state_attr(entity,
      'entity_id'))|map(attribute='entity_id')|list|count }}
    card_mod:
      style: |
        ha-card {
          --chip-background: {{ 'lime' if is_state('light.den', 'on') else 'yellow' }};
          box-shadow: none !important;
          justify-content: right;
          --chip-height: 35px;
          --chip-border-radius: 0px;
          --chip-icon-size: 18px;
          --chip-font-size: 12px;
          font-style: bold;
          font-variant: small-caps;
          padding-right: 0px;
          padding-left: 0px;
          font-family: "Roboto";
          font-weight: bolder;
          min-width: 70px !important;       
        }
card_mod:
  style:
    mushroom-entity-chip:nth-child(1)$: |
      {% if is_state(entity, 'on') %}
        ha-state-icon {
        animation: blink 2s linear infinite;
         }
        @keyframes blink { 50% {opacity: 0;} }
      {% else %}
        ha-state-icon {
        animation: blink 0s linear infinite;
         }
        @keyframes blink { 50% {opacity: 0;} }
      {% endif %}        

You switched to a template card so it not matching up.

image

image

card_mod:
  style:
    mushroom-template-chip:nth-child(1)$: |
      ha-state-icon {
      animation: blink 2s linear infinite;
       }
      @keyframes blink { 50% {opacity: 0;} }

Your If statement is also an issue.

If you just use

card_mod:
  style:
    mushroom-template-chip:nth-child(1)$: |
      
        ha-state-icon {
        animation: blink 2s linear infinite;
         }
        @keyframes blink { 50% {opacity: 0;} }

the animation works

card_mod:
  style:
    mushroom-template-chip:nth-child(1)$: >
      ha-state-icon { animation: {{ 'blink 2s linear infinite;' if
      is_state('light.den','on') else 'blink 0s linear infinite;' }}
          }
      @keyframes blink { 50% {opacity: 0;} }

Thanks a bunch! Itā€™s 8:30AM where I live so off to work. Iā€™m going to try this out in a few hours.

Thanks for the guidance - Youā€™ve been awesome!

No problem! Happy to assist and have a good dayā€¦

Iā€™m back only because for some reason the text color change code works for everyone but me!

Below is what was suggested by Dimitri and many others online:

card_mod:
  style: |
    ha-card {
      --primary-text-color: blue;
    }

This is me:

type: custom:mushroom-chips-card
chips:
  - type: template
    entity: light.den
    icon: |-
      {% if is_state(entity, 'on') %}
        mdi:sofa-single
      {% else %}
        mdi:sofa-single
      {% endif %}
    icon_color: |-
      {% if is_state(entity, 'on') %}
        #F97B22
      {% else %}
        #D8AE7E
      {% endif %}
    content: >-
      Den: {{ expand(state_attr(entity, 'entity_id'))|
      selectattr('state','eq','on')|map(attribute='entity_id')|list|count}} / {{
      expand(state_attr(entity,
      'entity_id'))|map(attribute='entity_id')|list|count }}
    card_mod:
      style: |
        ha-card {
          --chip-background: {{ 'lime' if is_state('light.den', 'on') else '#FFF2D7' }};
          box-shadow: none !important;
          justify-content: right;
          --chip-height: 35px;
          --chip-border-radius: 10px;
          --chip-icon-size: 18px;
          --chip-font-size: 12px;
          --primary-text-color: blue;
          font-style: bold;
          font-variant: small-caps;
          padding-right: 0px;
          padding-left: 0px;
          font-family: "Roboto";
          font-weight: bolder;
          min-width: 70px !important;       
        }
card_mod:
  style:
    mushroom-template-chip:nth-child(1)$: >
      ha-state-icon { animation: {{ 'blink 2s linear infinite;' if
      is_state('light.den','on') else 'blink 0s linear infinite;' }}
          }
      @keyframes blink { 50% {opacity: 0;} }

Also, if I apply you background color conditional formatting to this, will it work? Something like the below?

--primary-text-color: {{ 'lime' if is_state('light.den', 'on') else '#FFF2D7' }};

try --text-color: blue; It should resolve your issue.

image

THANK YOU - AGAIN! Works like a charm - even with the conditional

How do I go about figuring this on my own without going crazy?

It can be frustrating at first, but it was actually in Dimitriā€™s guide :slightly_smiling_face:

This is also a good source for a better understanding of custom card modding

1 Like

Thanks again,

I have multiple lights and realized I need to change the specific entity name in like 3-4 places for each light (see below)

--chip-background: {{ 'FFF2D7' if is_state('light.yeelight_bslamp1_0x31b3710', 'on') else '#F6F5F2' }};

--text-color: {{ 'lime' if is_state('light.yeelight_bslamp1_0x31b3710', 'on') else '#D8AE7E' }};

card_mod:
  style:
    mushroom-template-chip:nth-child(2)$: >
      ha-state-icon { animation: {{ 'blink 2s linear infinite;' if
      is_state('light.yeelight_bslamp1_0x31b3710','on') else 'blink 0s linear infinite;' }}
          }
      @keyframes blink { 50% {opacity: 0;} }

Without creating a template in the config.yaml file, is there a way to replace all references to the entity with just an ā€˜entityā€™ or ā€˜enitity_idā€™?

Similar to the way they use for icon and icon_color:

  - type: template
    entity: light.yeelight_bslamp1_0x31b3710
    icon: |-
      {% if is_state(entity, 'on') %}
        mdi:lamp
      {% else %}
        mdi:lamp-outline
      {% endif %}
    icon_color: |-
      {% if is_state(entity, 'on') %}
        #F97300
      {% else %}
        #B4B4B8
      {% endif %}

config.entity or entity works most of the time unless the mod is using the nth-child

This works and will reduce the number of changes.

    card_mod:
      style: |
        ha-card {
          --chip-background: {{ 'lime' if is_state(config.entity, 'on') else 'yellow' }};
          --text-color: {{ 'lime' if is_state(config.entity, 'on') else '#D8AE7E' }};
1 Like

I spent ages trying to get that to work on a chip template before I realised it just didnā€™t work, I thought it was me lol

Hi,
Currently I have this template card:

But I want to change the word ā€œTemperatureā€ and ā€œHumidityā€ to an MDI icon. Is this possible?

Example:

secondary: >-
  mdi:thermometer: {{ states('sensor.living_room_temperature') }}Ā°  |  mdi:water-percent: {{
  states('sensor.living_room_humidity')}}%

This is my full code:

type: custom:mushroom-template-card
primary: 'Inside Feels Like: {{ states(''sensor.living_room_feels_like_temperature'') }}Ā°'
secondary: >-
  Temperature: {{ states('sensor.living_room_temperature') }}Ā°  |  Humidity: {{
  states('sensor.living_room_humidity')}}%
icon: mdi:home-import-outline
multiline_secondary: true
entity: sensor.living_room_feels_like_temperature
tap_action:
  action: more-info
fill_container: false

I donā€™t think itā€™s possible with mushroom template cardā€¦ I maybe wrong.
only way I know would be to use markdown card, stack-in-card and card_mod

type: custom:stack-in-card
cards:
  - type: vertical-stack
    cards:
      - type: custom:mushroom-template-card
        card_mod:
          style: 
            mushroom-shape-icon$: |
             .shape {
               margin-top: 20px;
             }
            .: |
              ha-card {
                margin-top: -20px;
                border: none;
                box-shadow: none;
              }
        primary: >-
          Inside Feels Like: {{
          states('sensor.living_room_feels_like_temperature') }}Ā°
        icon: mdi:home-import-outline
        multiline_secondary: true
        entity: sensor.living_room_feels_like_temperature
        tap_action:
          action: more-info
        fill_container: false
      - type: markdown
        card_mod:
          style: |
            ha-card {
              border: none;
              box-shadow: none;
              margin-left: 40px;
              margin-top: -50px;
            }
        content: >
          <ha-icon icon="mdi:thermometer"></ha-icon>{{
          states('sensor.living_room_temperature') }}Ā°  |  <ha-icon
          icon="mdi:water-percent"></ha-icon> {{
          states('sensor.living_room_humidity')}}%

Iā€™m back with another query - and happy if you can point me at a source to learn the syntax.

Iā€™m trying to get my mushroom ā€˜templateā€™ chip card to show the state (on/off) of the entity within the card. Is there a way to combine multiple attributes in a card, say state + brightness level? Something like ā€œON | 95%ā€

My failed code below:

type: custom:mushroom-chips-card
chips:
  - type: template
    entity: light.pine
    icon: |-
      {% if is_state(entity, 'on') %}
        mdi:lamp
      {% else %}
        mdi:lamp-outline
      {% endif %}
    icon_color: |-
      {% if is_state(entity, 'on') %}
        #FF9130
      {% else %}
        #B4B4B8
      {% endif %}
    content: {{state_attr(config.entity, 'state')
    card_mod:
      style: |
        ha-card {
          --chip-background: {{ '#FFF2D7' if is_state(config.entity, 'on') else '#F6F5F2' }};
          box-shadow: none !important;
          justify-content: center;
          --chip-height: 35px;
          --chip-border-radius: 10px;
          --chip-icon-size: 20px;
          --chip-font-size: 12px;
          --text-color: {{ 'lime' if is_state(config.entity, 'on') else '#D8AE7E' }};
          font-style: bold;
          font-variant: small-caps;
          padding-right: 0px;
          padding-left: 0px;
          font-family: "Roboto";
          font-weight: bolder;
          width: 0px !important;
          min-width: 88px !important;
        }

Iā€™m being ambitious with a chip card, but can we by any chance have the content/attributes across lines? To look something like this?

11