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

Can someone show me the way to the chip iconā€¦??

this is my code

type: custom:mushroom-chips-card
chips:
  - type: conditional
    conditions:
      - entity: switch.all_power_strips_group
        state: 'on'
    chip:
      type: template
      entity: sensor.powerstrips_on_count
      icon: mdi:lightbulb-on
      icon_color: |
        {% if is_state(entity, '0') %}
          disabled
        {% else %}
          orange
        {% endif %}
      tap_action:
        action: more-info
      card_mod:
        style: |
          .content {
            background-color: red;
            {{ 'animation: illumination 1.75s infinite;' if states('sensor.powerstrips_on_count') != '0' }}
          }
          @keyframes illumination {
            0%, 100% { -webkit-clip-path: inset(0 0 0 0);}
            80% { -webkit-clip-path: polygon(0% 99%, 20% 55%, 22% 37%, 39% 20%, 61% 21%, 77% 35%, 79% 57%, 99% 100%);}
          }
          ha-card:after {
            content: '{{ states('sensor.powerstrips_on_count') }}';
            position: absolute;
            display: flex;
            justify-content: center;
            align-items: center;
            background: rgb(var(--rgb-orange));
            color: var(--card-background-color);
            font-weight: bolder;
            border-radius: 50%;
            top: -7px;
            right: -2px;
            width: 17px;
            height: 17px;
            font-size: 13px;
          } 
  - type: conditional
    conditions:
      - entity: switch.all_fans_group
        state: 'on'
    chip:
      type: template
      entity: sensor.fans_on_count
      icon: mdi:fan
      icon_color: |
        {% if is_state(entity, '0') %}
          disabled
        {% else %}
          teal
        {% endif %}
      tap_action:
        action: more-info
      card_mod:
        style: |
          .content {
            background-color: red;
            {{ 'animation: spin 2s ease-in, spin 1.25s linear 2s infinite;' if states('sensor.fans_on_count') != '0' }}
          }
          @keyframes spin {
            0% { transform: rotate(0deg);}
            100% { transform: rotate(360deg); }
          }
          ha-card:after {
            content: "{{ expand(states.switch.all_fans_group) | selectattr( 'state', 'eq', 'on') | list | count }}";
            position: absolute;
            display: flex;
            justify-content: center;
            align-items: center;
            background: rgb(var(--rgb-orange));
            color: var(--card-background-color);
            font-weight: bolder;
            border-radius: 50%;
            top: -7px;
            right: -2px;
            width: 17px;
            height: 17px;
            font-size: 13px;
          }

I am trying to animate the two chips ā€¦ I have done it before directly in chips cardsā€¦ lots of examples posted by @rhysb and many others.

Now i am changing my chip arrangement and hiding the whole chip when the chip condition is false. I couldnt find any code before where a chip icon is animated when it is inside a conditional card.

I tried using the default code which has mushroom-template-chip:nth-child(x) but didnt work.

Then tried with

mushroom-conditional-chip:nth-child(1):
      mushroom-template-chip:nth-child(1)$: |

after many tries, i got it ot work, but it creates a big space at the bottom areaā€¦ i tried to adjust margins and padding, but even though it gets corrected in the computer, in mobile, it becomes a mess.

So finally decided to add css on each individual chipā€¦ and the spacing issues are solved. but the animation picking the correct element. Eventhough the fan icon in the button rotates, the nothing happens in bulb animation.

I believe finally i am half way thereā€¦ but need that final pushā€¦ i donā€™t know much of css to locate or manipulate exactly the chip icon.

NB: I have added an extra line in the animations ( to identify the correct element for trial and errors)

background-color: red;

Can someone help meā€¦

Editā€¦ Adding current state of the animation. This is picking the wrong item and adding aniimation

Recording 2023-04-08 003358

If the icon element is selected correctly, animation will look like this

Recording 2023-04-08 003358 (1)

Can you share this one please. Nice job with sticky player

you mean all these lines?

{% if is_state('media_player.ytube_music_player', ['playing', 'paused']) %}
   -album-art-color: {{ states('sensor.muted_color') }};
{% else %}
   display: none !important;
{% endif %}

Sure, which one? Each television card has slight differences based on the devices it supports.

Hello there ā€¦
i want to make a sensor, timer or reminder to get notified before it finishes , on MONTHLY basis ā€¦ like a reminder for renewing monthly subscription of internet ā€¦
but i want to control of starting and ending day and time
anyone can help me on thisā€¦Screenshot 2023-04-08 021701

type: custom:mushroom-template-card
icon: mdi:calendar-end
primary: Month End Countdown
icon_color: orange
secondary: >
  {% set month_days = (31 if now().month == 12 else
  (now().replace(month=now().month+1, day=1) - timedelta(days=1)).day) %}

  {{ now().day }}/{{ month_days }} Days | {{ ((month_days - now().day) /
  month_days * 100) | round(2) }}%
card_mod:
  style:
    mushroom-shape-icon$: |
      .shape {
        {% set month_days = (31 if now().month == 12 else (now().replace(month=now().month+1, day=1) - timedelta(days=1)).day) %}
        
        background: radial-gradient(var(--card-background-color) 60%, transparent calc(60% + 1px)), 
                    conic-gradient(rgb(var(--rgb-{{ config.icon_color }})) 
                    {{ ((month_days - now().day) / month_days * 100) | round(2) }}% 0%, 
                    var(--card-background-color) 0% 100%);
      }
      .shape:after {
        content: "";
        height: 100%;
        width: 100%;
        position: absolute;
        border-radius: var(--icon-border-radius);
        background: rgba(var(--rgb-{{ config.icon_color }}), 0.2);
      }

@rhysb Could you please help me :slight_smile:

This should be fixed in the next release:

Have a look here:

Time to show off your Camera cards. Iā€™m using Reolink and the update has heaps of new entities. What have ppl designed??

1 Like

Thank you @rhysb ā€¦ you are awesome !!
Works perfectlyā€¦!!!

here is the full code ā€¦ in case if someone needs it

Conditional chips with animation
type: custom:mushroom-chips-card
chips:
  - type: conditional
    conditions:
      - entity: switch.all_power_strips_group
        state: 'on'
    chip:
      type: template
      entity: sensor.powerstrips_on_count
      icon: mdi:lightbulb-on
      icon_color: |
        {% if is_state(entity, '0') %}
          disabled
        {% else %}
          orange
        {% endif %}
      tap_action:
        action: more-info
      card_mod:
        style: |
          ha-card:after {
            content: '{{ states('sensor.powerstrips_on_count') }}';
            position: absolute;
            display: flex;
            justify-content: center;
            align-items: center;
            background: rgb(var(--rgb-orange));
            color: var(--card-background-color);
            font-weight: bolder;
            border-radius: 50%;
            top: -7px;
            right: -2px;
            width: 17px;
            height: 17px;
            font-size: 13px;
          }
  - type: conditional
    conditions:
      - entity: switch.all_fans_group
        state: 'on'
    chip:
      type: template
      entity: sensor.fans_on_count
      icon: mdi:fan
      icon_color: |
        {% if is_state(entity, '0') %}
          disabled
        {% else %}
          teal
        {% endif %}
      tap_action:
        action: more-info
      card_mod:
        style: |
          ha-card:after {
            content: "{{ expand(states.switch.all_fans_group) | selectattr( 'state', 'eq', 'on') | list | count }}";
            position: absolute;
            display: flex;
            justify-content: center;
            align-items: center;
            background: rgb(var(--rgb-orange));
            color: var(--card-background-color);
            font-weight: bolder;
            border-radius: 50%;
            top: -7px;
            right: -2px;
            width: 17px;
            height: 17px;
            font-size: 13px;
          }
card_mod:
  style:
    mushroom-conditional-chip:nth-child(1):
      mushroom-template-chip$: |
        ha-icon {
          {{ 'animation: illumination 1.75s infinite;' if states('sensor.powerstrips_on_count') != '0' }}
        }
        @keyframes illumination {
          0%, 100% { -webkit-clip-path: inset(0 0 0 0);}
          80% { -webkit-clip-path: polygon(0% 99%, 20% 55%, 22% 37%, 39% 20%, 61% 21%, 77% 35%, 79% 57%, 99% 100%);}
        }
    mushroom-conditional-chip:nth-child(2):
      mushroom-template-chip$: |
        ha-icon {
          {{ 'animation: spin 2s ease-in, spin 1.25s linear 2s infinite;' if states('sensor.fans_on_count') != '0' }}
        }
        @keyframes spin {
          0% { transform: rotate(0deg);}
          100% { transform: rotate(360deg); }
        }
    .: |
      mushroom-conditional-chip {
        height: calc(var(--chip-height));
      }
      :host {
        --ha-card-background: var(--card-background-color);
      }

2 Likes

Part 2 manual is ready.

1 Like

just pc please. I found television above. Thanks. What integration are you using for pc?

-album-art-color: {{ states('sensor.muted_color') }};
1 Like

I need to do some modifications. I will share when is done.

Big fan of Mushroom cards here!

Just came across something I donā€™t seem to be able to fix: up until now, Iā€™d been using the state of a group of Hue lights to define the color of an icon on my dashboard. All worked very well, and in general, the CPU load on my oldish mini-PC is tin the order of magnitude of 1-2%.

Now today, I added the state of a shelly plug in there, with this expression to define the color of the icon:

{% set l = is_state('light.living', 'on') %}
{% set m = is_state('switch.shellypluglivingmultimedia', 'on') %}
{% if l and m %} green
{% elif l %} orange
{% elif m %} blue
{% else %} none
{% endif %}

This works well, however CPU load is now constantly at around 23-24% which seems excessive for such an easy logic.

Can anyone give me any pointers to bring this back down please?

@rhysb
maybe you can help me?

I get "custom element doesnā€™t exist : stack in card

I added the stack in in hacs. And refreshed and reloaded sources ā€¦ What can it be ?

Hi,

Thanks to everyone for their tips above - this has been amazingly helpful.

I have managed to get my person card up and running and it looks awesome so far.

image

Iā€™m certainly no expert in coding and I feel like Iā€™m possibly doing unnecessary things. So I was just wondering if anyone has some tips for me to simplify what I have done before I go ahead and replicate it for three other people in my house?

type: custom:stack-in-card
cards:
  - type: custom:stack-in-card
    cards:
      - type: custom:stack-in-card
        cards:
          - type: custom:mushroom-chips-card
            chips:
              - type: entity
                entity: person.PERSON
                content_info: none
                use_entity_picture: true
                tap_action:
                  action: fire-dom-event
                  browser_mod:
                    service: browser_mod.popup
                    data:
                      title: PERSON
                      content:
                        type: vertical-stack
                        cards:
                          - type: custom:mushroom-person-card
                            entity: person.PERSON
                            icon_type: entity-picture
                card_mod:
                  style:
                    .: |
                      /* Color border around avatar to show person status */
                      ha-card {
                        --chip-background:
                        {% if is_state(config.entity, ['home', 'not_home', 'unknown']) %}
                          rgb(var(--rgb-state-person-{{ states(config.entity) | replace('_', '-') }} ))
                        {% else %}
                          rgb(var(--rgb-state-person-zone))
                        {% endif %};

                        --chip-avatar-padding: 2.5px;
                        
                        /* https://community.home-assistant.io/t/mushroom-cards-build-a-beautiful-dashboard-easily/388590/951 */
                        --chip-height: 40px;
                        
                        /* Position the person in the centre */
                        position: absolute;
                        left: 4px;
                        top: 12px;
                      } 
                      /* Slightly enlarge & bring to front on hover */
                      ha-card:hover {
                        transform: scale(1.3);
                        transform-origin: top center;
                        z-index: 1;
                        transition: all 1s;
                      }
          - type: custom:stack-in-card
            cards:
              - type: custom:mushroom-chips-card
                chips:
                  - type: template
                    entity: sensor.PERSON_phone_battery_level
                    content: |
                      {{ states(entity) }}%
                    icon: >
                      {% set battery_level = (states(entity) | int / 10) |
                      round(0) | int * 10 %}  {% set charging =
                      states.sensor.PERSON_phone_battery_state.state %} {% if
                      battery_level == 100 %}
                        mdi:battery{%if charging == 'charging' %}-charging{% endif %}
                      {% elif battery_level > 0 %}
                        mdi:battery{%if charging == 'charging' %}-charging{% endif %}-{{ battery_level }}
                      {% else %}
                        mdi:battery-outline
                      {% endif %}
                    icon_color: |-
                      {% set battery_level = states(entity) | int %}
                      {% if battery_level > 90 %} 
                        green
                      {% elif battery_level > 60 %}
                        light-green
                      {% elif battery_level > 50 %}
                        lime
                      {% elif battery_level > 40 %}
                        amber
                      {% elif battery_level > 30 %}
                        amber
                      {% elif battery_level > 20 %}
                        orange
                      {% elif battery_level > 10 %}
                        deep-orange
                      {% else %}
                        red
                      {% endif %} 
                card_mod:
                  style: |
                    .chip-container { 
                      flex-flow: column !important;
                      --chip-spacing: 0px;
                      --chip-background: none;
                      --chip-box-shadow: none;
                      transition: all 0s;  

                      /* Set icon height */
                      --chip-height: 36px;

                    }
            card_mod:
              style: |
                ha-card {
                  position: absolute;
                  left: -7px;
                  bottom: -8px;
                  background: rgba(var(--rgb-card-background-color), 0.0);
                  box-shadow: none;
                  border-radius: 1px;
                  transition: all 0s; 

                  /* Remove border */
                  --ha-card-border-width: 0;
                }
        card_mod:
          style: |
            ha-card {
              min-height: 70px;
              max-width: 52px;
              no-repeat center 0px;
              background-size: cover;
              position: relative;
              background-position: center;
              background-repeat: no-repeat;
              border-radius: 15px 15px 0 0;
            }
      - type: custom:stack-in-card
        cards:
          - type: custom:mushroom-chips-card
            chips:
              - type: template
                entity: person.PERSON
                icon: >-
                  {% set z = state_attr( 'zone.' + states(entity), 'icon') %} {%
                  if z == 'None' %}
                    mdi:home-export-outline
                  {% else %}
                    {{ z }}
                  {% endif %}
                icon_color: |-
                  {% if is_state(entity,'home') %}
                    green
                  {% elif is_state(entity,'band') %}
                    orange
                  {% elif is_state(entity,'office') %}
                    blue
                  {% elif is_state(entity,'hospital') %}
                    blue
                  {% elif is_state(entity,'hospital') %}
                    purple
                  {% else %}
                    red
                  {% endif %}
            card_mod:
              style: |
                .chip-container { 
                  flex-flow: column !important;
                  --chip-spacing: 0px;
                  --chip-background: none;
                  --chip-box-shadow: none;
                  transition: all 0s;  

                  /* Set icon height */
                  --chip-height: 36px;
                }
        card_mod:
          style: |
            ha-card {
              position: absolute;
              left: -7px;
              top: -8px;
              background: rgba(var(--rgb-card-background-color), 0.0);
              box-shadow: none;
              border-radius: 1px;
              transition: all 0s; 

              /* Remove border */
              --ha-card-border-width: 0;
            }
    card_mod:
      style: |
        ha-card {
          min-height: 68px;
          max-width: 52px;
          no-repeat center 0px;
          background-size: cover;
          position: relative;
          background-position: center;
          background-repeat: no-repeat;
          border-radius: 15px 15px 0 0;

          /* Remove border */
          --ha-card-border-width: 0;
        }
  - type: custom:stack-in-card
    cards:
      - type: custom:mushroom-chips-card
        chips:
          - type: template
            icon: >-
              {% if is_state('binary_sensor.PERSON_phone_wifi_state','offhook') %}
                mdi:phone-in-talk
              {% elif is_state('binary_sensor.PERSON_phone_wifi_state','ringing')
              %}
                mdi:phone-ring
              {% elif not
              is_state('sensor.PERSON_phone_do_not_disturb_sensor','off') %}
                mdi:minus-circle
              {% elif is_state('binary_sensor.PERSON_phone_bluetooth_state','on')
              %}
                mdi:bluetooth
              {% endif %}
            icon_color: >-
              {% if is_state('binary_sensor.PERSON_phone_wifi_state','offhook') %}
                green
              {% elif is_state('binary_sensor.PERSON_phone_wifi_state','ringing')
              %}
                green
              {% elif not
              is_state('sensor.PERSON_phone_do_not_disturb_sensor','off') %}
                red
              {% elif is_state('binary_sensor.PERSON_phone_bluetooth_state','on')
              %}
                blue
              {% endif %}
        card_mod:
          style: |
            .chip-container { 
              flex-flow: column !important;
              --chip-spacing: 0px;
              --chip-background: none;
              --chip-box-shadow: none;
              transition: all 0s;  
              
              /* Set icon height */
              --chip-height: 36px;
            }
    card_mod:
      style: |
        ha-card {
          position: absolute;
          right: -5px;
          top: -8px;
          background: rgba(var(--rgb-card-background-color), 0.0);
          box-shadow: none;
          border-radius: 1px;
          transition: all 0s; 

          /* Remove border */
          --ha-card-border-width: 0;
        }
card_mod:
  style: |
    ha-card {
      min-height: 68px;
      max-width: 52px;
      no-repeat center 0px;
      background-size: cover;
      position: relative;
      background-position: center;
      background-repeat: no-repeat;
      border-radius: 15px 15px 0 0;

      /* Remove border */
      --ha-card-border-width: 0;
    }

Donā€™t think we can do 1, but 2 & 3 can be done like this:

type: custom:mushroom-climate-card
entity: climate.air_conditioner
hvac_modes:
  - 'off'
  - heat
  - heat_cool
show_temperature_control: true
primary_info: state
secondary_info: name
card_mod:
  style:
    mushroom-state-info$: |
      .primary:after {
        content: " | {{ states('sensor.lounge_sensor_humidity') | round(1) }} %";
      }
    .: |
      mushroom-climate-hvac-modes-control {
        transform: scalex(-1);
      }
2 Likes

Have a look here:

You can customize the Mushroom Number Card like this.

Mushroom Number Card

type: custom:mushroom-number-card
entity: input_number.dummy_fan
card_mod:
  style:
    mushroom-state-info$: |
      .secondary:after {
        content: " %";
      }
    .: |
      ha-card {
        {% set value = states(config.entity) | int %}
        --rgb-state-number: var(--rgb-
        {%- if value > 66 -%}
          red
        {%- elif value > 33 -%}
          green
        {%- else -%}
          blue
        {%- endif -%});
      }
5 Likes