Lovelace: Decluttering Card

Reverted card-mod to 3.4.4 and the following decluttering template works now:

decluttering_templates:
  decluttering_test:
    card:
      type: custom:vertical-stack-in-card
      cards:
        - type: custom:mod-card
          card_mod:
            style:
              hui-horizontal-stack-card $: |
                div#root hui-card > * {
                  display: flex;
                  flex-direction: column;
                  --ha-card-border-width: 0px !important;
                  margin-bottom: 5px !important;
                  margin-top: -5px !important;
                }
                div#root > :first-child > * {
                  margin-left: 4px !important;
                }
                div#root > :last-child > * {
                  margin-right: 4px !important;
                }
              .: |
                hui-horizontal-stack-card {
                  --horizontal-stack-card-gap: 2px;
                }
                ha-card {
                  box-shadow: var(--ha-card-box-shadow);
                  border: var(--ha-card-border-color,var(--divider-color,#e0e0e0)) solid var(--ha-card-border-width,1px);
                  background: var(--ha-card-background,var(--card-background-color,#fff));
                }
          card:
            type: horizontal-stack
            cards:
              - type: entity
                entity: sun.sun
              - type: entity
                entity: sun.sun
              - type: entity
                entity: sun.sun
              - type: entity
                entity: sun.sun
              - type: entity
                entity: sun.sun

Because you’re using the mod-card wrong.

I just got started using decluttering card and it’s working great. However, is it possible to use in a “sections” dashboard where the width of a card is specified? It’s a super-long sankey-card, so not posting the whole yaml, but I have the following embedded in the yaml for the decluttering template, but it’s not impacting the custom-decluttering card when deployed in a sections view. The same yaml when placed directly in a typical card works as intended. Thank you!

      grid_options:
        columns: 24
        rows: auto

Sorry - I think everyone can ignore this. I realized if I specify the grid options yaml in the custom-decluttering card (not the decluttering template), it works fine. Probably as it was intended!

Take a look at this, if you agree give it a thumbs up

1 Like

This has been discussed before, but I have seen some conflicting answers (or I have misinterpreted them). I have a card_mod that defines some variables. It uses variables to simplify the code of the card_mod, there is really no need to have them be variables. I can’t get this to work as a decluttering template, although the card works great as a standalone. The card_mod variable syntax is different than the decluttering card, so my hope was that there would be no confusion with the decluttering card.

mushroom_bar_card_template:
    card:
      type: custom:bar-card
      entities:
        - entity: sensor.climate_govee_sensor_temperature
          icon: mdi:bed-empty
          positions:
            icon: outside
            indicator: 'off'
            minmax: 'off'
            name: 'off'
            value: 'off'
          min: 50
          max: 80
          target: 71
          height: 15
      severity:
        - color: '#4b5d80'
          from: 40
          to: 69
        - color: '#4b8078'
          from: 69
          to: 75
        - color: '#9e5c4b'
          from: 75
          to: 95
      card_mod:
        style: >
          {% set entity = { 
            "state": states('sensor.climate_govee_sensor_temperature') | int(9999999999),
            "name": "Guest Room Temperature",
            "unit": "F"
            }
          %} {% set severity = { 
            "blue": 0,
            "green": 69,
            "orange": 75
            }
          %} {% set colors = { 
            "blue": "75,93,128",
            "green": "75,128,120",
            "orange": "158,92,75"
            }
          %}

          ha-card .card-content {
            padding: 12px!important;
            cursor: pointer;
          }

          ha-card {
            transition-duration: 0.05s;
          }

          ha-card:hover {
            {% if entity.state == 9999999999 %}
              background-color: rgba(200,200,200, 0.02);
            {% elif entity.state < severity.orange %}
              background-color: rgba({{colors.green}}, 0.02);
            {% elif entity.state < severity.green %}
              background-color: rgba({{colors.blue}}, 0.02);
            {%- else -%}
              background-color: rgba({{colors.orange}}, 0.02);
            {%- endif %}
          }

          bar-card-background {
            margin-left: 13px !important;
          }

          bar-card-backgroundbar, bar-card-currentbar, bar-card-contentbar, 
          bar-card-targetbar {
            border-radius: 8px;
          }

          bar-card-currentbar, bar-card-backgroundbar, bar-card-contentbar,
          bar-card-targetbar, bar-card-animationbar {
            {% if entity.state == 9999999999 %}
              left: 1.5em !important;
              width: calc(100% - 1.5em);
            {% else %}
              {% set state_width = 1 + (entity.state|string|count + entity.unit|count) * 0.4 %}
              left: {{state_width}}em !important;
              width: calc(100% - {{state_width}}em);
            {%- endif %}
          } 

          bar-card-markerbar {
            display: none;
          } 

          bar-card-background::before {
            content: "{{ entity.name }}";
            display: flex;
            font-family: Roboto, sans-serif;
            font-size: 14px;
            font-weight: 500;
            height: 20px;
            letter-spacing: 0.1px;
            line-height: 20px;
            margin-bottom: 6px;
          }

          bar-card-background::after {
            {% if entity.state == 9999999999 %}
              content: "N/A"
            {%- else %}
              content: "{{ entity.state }}{{ entity.unit}}";
            {%- endif %}
            font-family: Roboto, Noto, sans-serif;
            font-size: 12px;
            font-weight: 400;
            height: 16px;
            letter-spacing: 0.4px;
            line-height: 16px;
            display: inline-block;
            position: absolute;
            margin-top: -4px;
            width: fit-content;
          }

          bar-card-iconbar {
            {% if entity.state == 9999999999 %}
              color: rgba(200,200,200, 1);
              background-color: rgba(200,200,200, 0.2);
            {% elif entity.state < severity.green %}
              color: rgba({{colors.blue}}, 1);
              background-color: rgba({{colors.blue}}, 0.2);
            {% elif entity.state < severity.orange %}
              color: rgba({{colors.green}}, 1);
              background-color: rgba({{colors.green}}, 0.2);
            {%- else -%}
              color: rgba({{colors.orange}}, 1);
              background-color: rgba({{colors.orange}}, 0.2);
            {%- endif %}
            border-radius: 50%;
          }

@Ildar_Gabdullin

- type: custom:decluttering-card
        template: decl_test_var_template
        variables:
          - VALUE: >-
              {% if false -%}
                {{states('zone.home')}}
              {%- else -%}
                {{states('sun.sun')}}
              {%- endif %}

Hi Ildar,
great tutorial.
I can’t test and didn’t read this hole thread, maybe there was found a solution…
Maybe this would work:

- type: custom:decluttering-card
        template: decl_test_var_template
        variables:
          - VALUE: >-
              {% if false -%}
                {{- states('zone.home')}}
              {%- else -%}
                {{- states('sun.sun')}}
              {%- endif %}

so long
Pc

Can someone please explain plainly how to get this working… I installed using HACS (and rebooted) but the card is not showing up when I edit the dashboard.
I placed the template in the dashboard RAW YAML but that did not help?

Like for many custom cards - select “Manual” & type your code.

thank you… I didnt know, all the cards I’ve installed from HACS show up in the UI, except this one.

Trying this for the first time and my template is pulled from a fairly complex card. Even though I’m not completely done with it I wanted to give it a try to see how well it’s working, and the result is completely blank. I did try with one of the examples from the repo and that worked, so I know it’s a problem with my template.

decluttering_templates:
  popup_template:
    card:
      type: vertical-stack
      cards:
        - type: custom:bubble-card
          card_type: pop-up
          hash: '#[[hash]]'
          name: '[[area_name]]'
          icon: mdi:sofa
          entity: light.living_room_group
          state: sensor.living_room_group_temperature
          back_open: true
          button_type: slider
          tap_action:
            action: toggle
          hold_action:
            action: more-info
          sub_button: []
        - type: custom:bubble-card
          card_type: separator
          name: Lights
        - type: custom:auto-entities
          filter:
            include:
              - area: '[[area_name]]'
                domain: light
                options:
                  type: custom:bubble-card
                  card_type: button
                  button_type: slider
                  entity: this.entity_id
                  tap_action:
                    action: toggle
                  hold_action:
                    action: more-info
            exclude:
              - integration: wled
                state: unavailable
              - entity_id: light.[[entity_prefix]]
          card:
            square: false
            type: grid
            columns: 2
          card_param: cards
        - type: grid
          columns: 2
          square: false
          cards:
            - type: custom:bubble-card
              card_type: select
              entity: select.living_room_strip_preset
              show_icon: false
              scrolling_effect: true
              show_name: true
              show_state: true
              show_last_changed: false
              show_attribute: false
              name: Preset
            - type: custom:bubble-card
              card_type: select
              entity: select.living_room_strip_playlist
              show_icon: false
              scrolling_effect: true
              show_name: true
              show_state: true
              show_last_changed: false
              show_attribute: false
              name: Playlist
        - type: custom:bubble-card
          card_type: separator
          name: Oulets
        - type: custom:auto-entities
          filter:
            include:
              - area: '[[area_name]]'
                domain: switch
                options:
                  type: custom:bubble-card
                  card_type: button
                  entity: this.entity_id
                  styles: >
                    ${card.querySelector('.bubble-name').innerText =
                    hass.states['this.entity_id'].attributes.friendly_name.split('
                    Outlet')[0].split(' Switch')[0] }
            exclude:
              - entity_id: '*_led'
              - integration: wled
          card:
            square: false
            type: grid
          show_empty: true
          square: false
          card_param: cards
        - type: custom:bubble-card
          card_type: separator
          name: Media Players
        - type: custom:bubble-card
          card_type: media-player
          entity: media_player.[[entity_prefix]]_tv
          button_type: slider
          icon: mdi:television-classic
          name: TV
          show_attribute: true
          attribute: app_name
        - type: custom:bubble-card
          card_type: media-player
          entity: media_player.[[entity_prefix]]_speaker
          button_type: slider
          icon: mdi:speaker
          name: Speaker
          show_attribute: true
          attribute: app_name
        - type: custom:bubble-card
          card_type: separator
          name: Scenes
        - type: custom:auto-entities
          filter:
            include:
              - domain: scene
                area: '[[area_name]]'
                options:
                  type: custom:bubble-card
                  card_type: button
                  entity: this.entity_id
            exclude: []
          card:
            square: false
            type: grid
          show_empty: true
          card_param: cards
        - type: custom:bubble-card
          card_type: separator
          name: Scripts
        - type: custom:auto-entities
          filter:
            include:
              - area: '[[area_name]]'
                domain: script
                label: Display as script
                options:
                  type: custom:bubble-card
                  card_type: button
                  entity: this.entity_id
            exclude: []
          card:
            square: false
            type: grid
          show_empty: true
          card_param: cards
        - type: custom:bubble-card
          card_type: separator
          name: Thermostat
        - type: custom:bubble-card
          card_type: climate
          entity: climate.living_room_thermostat
          button_type: slider
          sub_button:
            - name: HVAC presets menu
              select_attribute: preset_modes
              state_background: false
              show_arrow: false
            - name: HVAC modes menu
              select_attribute: hvac_modes
              state_background: false
              show_arrow: false
          show_attribute: true
          attribute: current_temperature
type: custom:decluttering-card
template: popup_template
variables:
  - hash: bathroom
  - area_name: Bathroom
  - entity_prefix: bathroom

Anything glaringly wrong here, or should I start by adding things piece by piece until I can find out what’s wrong?

Absolutely!))
It is advised to create a complex card step-by-step, from a small skeleton.

Alright, seems that it hates the hash line. No matter what I put in there, even if I hardcode a value in the template, it won’t make the card. Everything else is good. And I know you’re not the developer of the Bubble card, but do you have any recommendations for that? Ever seen something similar?

Do you mean this line?
Does it work if some fixed value is used like

hash: '#SOME_FIXED_VALUE'

?
Yes, I am not using bubbles, no idea what this “hash” option does, but may be it is not about a particular option.

Correct. Even when I put in a fixed value it still doesn’t produce a card. The only way I get anything is to remove that line. Then the header part of the card shows me an error (because the Bubble card requires it), and the rest of the body is created. So unless I can find a solution to that line I will just have to make my template for the body. Not a huge deal, just hoping I can put everything into the template.

Just looking through some of my templates, I use ‘[[xxx]]’ when it is the whole value passed or I use like this:

entity: media_player.[[vizio]]

Without the quotes. You could try that or change what you pass from ‘bedroom’ to ‘#bedroom’ and test.

I am not getting.
Have you tried with a simple case?

decluttering_templates:
  popup_template:
    card:
      type: vertical-stack
      cards:
        - type: custom:bubble-card
          card_type: pop-up
          hash: '#WHATEVER_FIXED'
          name: '[[area_name]]'
          icon: mdi:sofa
          entity: light.living_room_group
          state: sensor.living_room_group_temperature
          back_open: true
          button_type: slider
          ...
          sub_button: []

Yeah that’s the last thing I tried and it still doesn’t work. The only thing that make it produce a card at all is when I delete the hash line.

Unfortunately that actually makes it worse. For some reason after closing and reopening the raw editor that converts it into

hash:
  - - hash

Maybe I am missing something, where is the button card that uses navigate to actually open the popup?

Note the second part in this video, first makes what’s 9in the popup … if you view then the page is empty (as expected). Then he adds a bubble card at the top of /before the popup that will open and close the popup.