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

Hey

I have this code, I want to integrate the activation code using the wake_on_lan.send_magic_packet service, can someone help me please?

type: custom:layout-card
layout_type: grid
layout_options:
  grid-template-columns: 1fr
  grid-template-rows: auto
  grid-gap: 0px 2px
  mediaquery:
    '(max-width: 450px)':
      grid-template-columns: 1fr
cards:
  - type: custom:vertical-stack-in-card
    cards:
      - type: custom:mushroom-template-card
        entity: media_player.salon_lg_webosv
        primary: LG-75 TV
        secondary: |
          {% if is_state('media_player.salon_lg_webos', 'on') %} On
          {%else%} 
          Av
          {% endif %}
        icon: mdi:television
        icon_color: |
          {% if is_state('media_player.salon_lg_webos', 'on') %} indigo
          {%else%} 
          grey
          {% endif %}
        tap_action:
          action: more-info
      - type: custom:layout-card
        layout_type: masonry
        layout:
          width: 106
          max_cols: 1
          height: auto
          padding: 0px
          card_margin: var(--masonry-view-card-margin, -10px 8px 15px)
        cards: null
      - type: custom:mushroom-chips-card
        chips:
          - type: entity
            entity: media_player.salon_lg_webos
            icon: mdi:power
            icon_color: black
            content_info: none
            tap_action:
              action: more-info
        alignment: center
        card_mod:
          style: |
            ha-card {
              margin: -4px 0px 11px;
              --chip-background: rgba(var(--rgb-disabled), 0.15);
              --chip-border-width: 0;
              --chip-border-radius: 12px;
              --chip-height: 43px;
              --chip-padding: 62px;
              --chip-spacing: 10px;
            }

service: wake_on_lan.send_magic_packet
data:
  mac: 14:12:11:14:16:12

When I copy paste the code and ad my own entities I get this

image

a smaller button. When an entity gets active, the part below comes active

Do you know if that color flow can be made with HA (without NR) in any way?

EDIT: Maybe with ColorExtractor? Or no, that is for lightsā€¦ damn

Go on, take the plunge. Install NR, you know you want to :grin:.

Haha yeah I had it for a while but then I was like ā€œHey! I need a projectā€ and remade all my HA automations to NR but then after a while I was like ā€œHEY!1! I want HA automations backā€ and redid everyā€¦ singleā€¦automationā€¦ Iā€™m so trigger happy with these things lolā€¦ well yes now Iā€™m back with NR but it will have only just this automation NOTHING MORE :rofl:

Have tried this one, but getting node red issues. Havenā€™t played with node red before so this is new ground for me but looks like it isnā€™t finding the colours? Have I missed a step to get the colour values?

You will need to install the Node-Red companion from HACS.

As always, worked a treat, thank you!!

1 Like

I havenā€™t forgotten the other thing BTWā€¦ :grinning_face_with_smiling_eyes:

ha never in doubt :wink:

Hi @Mattia2399 could you share your config for the ā€œarea cardsā€ ?

i donā€™t understand. which do you say?

After some changes almost all your animations works perfect with custom:button-card! Soon as i have some spare time i will share them in the ā€œFun with button cardsā€ topic. Thanks for any help you provided and sharing all your knowledge with this community! :slight_smile:

PS: Have you any idea how the keyframes will look for the mdi:garage-variant icon because now this clip-paths are styled for the mdi:garage icon. :slight_smile:

  @keyframes door {
    0% { clip-path: inset(0 0 0 0); }
    25%  { clip-path: polygon(0 0, 100% 0, 100% 100%, 68% 100%, 69% 73%, 32% 73%, 31% 100%, 0 100%); }
    50%  { clip-path: polygon(0 0, 100% 0, 100% 100%, 68% 100%, 69% 61%, 32% 61%, 31% 100%, 0 100%); }
    75% { clip-path: polygon(0 0, 100% 0, 100% 100%, 68% 100%, 69% 48%, 32% 48%, 31% 100%, 0 100%); }
  }
1 Like

Is there any way to reverse this to make the sticky card appear at the bottom of the page instead of the top?

Iā€™ve tried a bunch of different changes and while they seem to take place while the UI editor is open (the background bar appears at the bottom of my screen) as soon as I save it the card layout seems to take over and it moves back up again.

How do i use a display:none css command for layout card.??

I just started my dashboard. Below is my code which has chips.

type: custom:stack-in-card
cards:
  - type: custom:layout-card
    layout_type: custom:grid-layout
    layout:
      grid-template-columns: 120px auto 120px
      grid-template-rows: auto
    cards:
      - type: custom:mushroom-chips-card
        chips:
          - type: menu
          - type: alarm-control-panel
            entity: alarm_control_panel.home_212_alarm
            content_info: none
            name: Alarm
        alignment: start
      - type: custom:mushroom-chips-card
        chips:
          - type: template
            icon: mdi:washing-machine
            icon_color: |
              {% if is_state(entity, 'off') %}
                disabled
              {% else %}
                teal
              {% endif %}
            entity: switch.gf_br01_fan1
          - type: template
            icon: mdi:washing-machine
            icon_color: |
              {% if is_state(entity, 'off') %}
                disabled
              {% else %}
                brown
              {% endif %}
            entity: switch.washing_machine
            tap_action:
              action: none
        alignment: center
        card_mod:
          style:
            mushroom-template-chip:nth-child(1)$: |
              ha-icon {
                {{ 'animation: shake 400ms ease-in-out infinite;' if is_state('switch.washing_machine', 'on') }}
                transform-origin: 50% 58%;
                -webkit-clip-path: polygon(0 0, 0 100%, 35% 100%, 34% 68%, 60% 41%, 71% 56%, 65% 74%, 47% 79%, 32% 69%, 35% 100%, 100% 100%, 100% 0);
              }
              @keyframes shake {
                0%, 100% { transform: translate(0, 0) rotate(0); }
                20%  { transform: translate(0.4px, -0.4px) rotate(-4deg); }
                40%  { transform: translate(-0.4px, 0.4px) rotate(4deg); }
                60%  { transform: translate(0.4px, 0.4px) rotate(-4deg); }
                80%  { transform: translate(-0.4px, -0.4px) rotate(4deg); }
              }
            mushroom-template-chip:nth-child(2)$: |
              mushroom-chip {
                cursor: default !important;
              }
              ha-icon {
                position: absolute;
                left: -31.5px;
                bottom: 6px;
                {{ 'animation: spin 1s linear infinite;' if is_state('switch.washing_machine', 'on') }}
                transform-origin: 50% 58%;
                -webkit-clip-path: circle(21.7% at 50% 58%);
              }
              @keyframes spin {
                100% { transform: rotate(360deg); }
              }
            .: |
              .chip-container :nth-child(2) {
                --chip-background: none;
                --chip-box-shadow: none;
                --chip-border-width: 0;
                width: 0px;
                margin-left: calc(-1 * var(--chip-spacing));
              }
      - type: custom:mushroom-chips-card
        chips:
          - type: template
            entity: sensor.persons_home_count
            icon: mdi:account-group
            icon_color: |
              {% if is_state(entity, '0') %}
                red
              {% else %}
                blue
              {% endif %}
            tap_action:
              action: more-info
            card_mod:
              style: |
                ha-card:after {
                  content: "{{ states('sensor.persons_home_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: template
            entity: lock.front_door
            icon: >-
              {{ 'mdi:lock' if is_state('lock.front_door', 'locked') else
              'mdi:lock-open' }}
            icon_color: '{{ ''green'' if is_state(''lock.front_door'', ''locked'') else ''red'' }}'
            content: null
            tap_action:
              action: more-info
        alignment: end
  - type: custom:layout-card
    layout_type: custom:grid-layout
    layout:
      grid-template-columns: auto
      grid-template-rows: auto
    cards:
      - 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;
                  }
        alignment: start
        card_mod:
          style:
            mushroom-conditional-chip:nth-child(1):
              mushroom-template-chip$: |
                ha-icon {
                  {% if states('sensor.powerstrips_on_count') != '0' %}
                    {{ 'animation: illumination 1.75s infinite;' }}
                  {% endif %}
                }
                @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 {
                  {% if states('sensor.fans_on_count') != '0' %}
                    {{ 'animation: spin 2s ease-in, spin 1s linear 2s infinite, spin ease-out;' }}
                  {% endif %}
                }
                @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);
              }

The first row is all permanent chips inside a layout card
The second row has conditional chips inside a layout card.
image

When all the conditions are false, there are no chips in the second row.
But it causes the gap to increase at the bottom part of the card.
image
image

if i use the developer option in the browser and add a display:none to the layout card, then the problem is solved.

how can i add this css with a conditional checkā€¦ Like if there are no visible conditional chips, then the css display:none should be applied to the layout card. If any one chip is active, then the layout card should be visible.

I tried lot of thingsā€¦ went through the dense dark forests :thinking:ā€¦ butā€¦ :unamused: :zipper_mouth_face:

This is the best that i could findā€¦
https://stackoverflow.com/questions/12206935/is-there-a-css-haschildren-selector

can you help me do this.

1 Like

how do i install the vibrating node?

@rhysb So this is my card. Simple change of icon and colour based on the state:

type: custom:mushroom-template-card
primary: >-
  {% set ct = states('sensor.ev_car_remaining_charging_time') | int %}

  {% if ct > 60 %}{{ ct // 60 }}:{{ '{:0>2d}'.format(ct%60) }} Hours{% else
  %}{{ct}} Minutes{% endif %}
secondary: Charge Time
icon: |
  {% set state=states(entity) %}
  {% if state<='1' %}
  mdi:battery
  {% elif state>='1' %}
  mdi:battery-clock
  {% else %}
  mdi:battery
  {% endif %}
entity: sensor.ev_car_remaining_charging_time
icon_color: |-
  {% set state = states(entity) %}
  {% if state >= '1' %}
  green
  {% else %}
  grey
  {% endif %}
hold_action:
  action: none
double_tap_action:
  action: none
tap_action:
  action: none
fill_container: false

What I would like it to do is if state>=ā€˜1ā€™ then to display the animated battery I mentioned earlier in green.

So here is another issue i am trying to solve, I have an input boolean button that I created that triggers either an off or on automation (2 separate automations).

Is there a way to check the state of an entity to automaticaly display the button is either off or on because some times the function is triggered by another app.

type: custom:mushroom-template-card
primary: |2-
   {% set d ={
    'on': 'On',
    'off': 'Off'
    } %}
    {{ d.get(states(entity)) }}
secondary: Climate
icon: |
  {% set state=states(entity) %}
  {% if state =='on' %}
  mdi:fan
  {% else %}
  mdi:fan-off
  {% endif %}
entity: input_boolean.vw_id_climate
tap_action:
  action: toggle
icon_color: |-
  {% set state = states(entity) %}
  {% if state =='on' %}
  blue
  {% else %}
  grey
  {% endif %}
fill_container: false

Hi sorry for the confusion, I was wondering if you could share the code for these?
image

    type: custom:stack-in-card
    cards:
      - type: custom:mushroom-template-card
        primary: Giardino
        secondary: '{{ states(''sensor.wupws_temp'') | round (0) }} Ā°C'
        icon: mdi:tree
        entity: switch.garden
        tap_action:
          action: toggle
        icon_color: '{{ ''teal'' if is_state(entity, ''on'') else ''disabled'' }}'
        fill_container: true
        layout: horizontal
        multiline_secondary: false
        card_mod:
          style: |
            :host {
              --mush-icon-size: 76px;
              height: 66px;
              margin-left: -18px !important;
            }
      - type: custom:mushroom-chips-card
        chips:
          - type: conditional
            conditions:
              - entity: switch.garden
                state: 'on'
            chip:
              type: template
              icon_color: disabled
              icon: null
              entity: switch.garden
              content: '{{ ''Irrig. in corso..'' if is_state(entity, ''on'') else  '''' }}'
              tap_action:
                action: none
              hold_action:
                action: none
          - type: conditional
            conditions:
              - entity: switch.garden
                state: 'on'
            chip:
              type: template
              icon_color: cyan
              icon: mdi:sprinkler
              entity: switch.garden
        alignment: start
        card_mod:
          style:
            mushroom-conditional-chip:nth-child(2):
              mushroom-template-chip$: |
                ha-icon {
                  {% if is_state('switch.garden', 'on') %}
                  animation: clip 1s linear infinite;
                  {% endif %}
                }
                @keyframes clip {
                  0% { clip-path: inset(0 0 0 0); }
                  52% { clip-path: inset(0% 50% 0 0)}
                  100% { clip-path: inset(0 0 0 0); }
                }
              .: |
                ha-card {
                  --chip-box-shadow: none;
                  --chip-background: none;
                  --chip-spacing: 0;
                }
    card_mod:
      style: |
        ha-card {
          height: 102px;
          background: url('/local/giardino.jpg') center;
          background-size: cover;
          background-blend-mode: overlay;
          background-color: rgba(var(--rgb-card-background-color), 0.8);
          {% if is_state('group.outside_lights', 'on') %}
              box-shadow: 0 0 20px rgba(0, 150, 136, 0.6);
          {% endif %}
        }

SWITCH SPRINKLER GARDEN ON:

ImmagineA

SWITCH SPRINKLER GARDEN OFF:

ImmagineB

3 Likes