Lovelace: Decluttering Card

Ah, I see now that I had an extra ’ in there. Will try removing that.

@RomRider no luck unfortunately, the background-color property is omitted from the html output altogether, so it seems it doesn’t receive the default value or something. Looks like this atm:

<decluttering-card class="element" style="top: 53.3406%; left: 3.0976%; width: 78.7843%; height: auto;"></decluttering-card>

Does that work? Isn’t it supposed to be:
state_attr('[[entity]]', 'color_temp')

If you run your template in the template parser from the dev tools replacing just [[entity]] with the real entity, does it work?

When running it in the template parser, I get the following back:

Result type: string
'[[color7]]'

So it seems to send it back, but it doesn’t pick up the default value as it seems

@RomRider When setting it as:

background-color: '#000000'

directly it seems to work, so I think the problem lies with the

background-color: |

Have tried the following four variants:

|, |-, >, >- without success

Got a question regarding card-mod.
I cannot use card-mod INSIDE a decluttering-card if the card represents entity row, like ‘multiple-entity-row’ or ‘hui-element + sensor-entity’.
Of course I would use decluttering-card with a simple entity row (like in “Entity card”) but it is not possible unfortunately.
For ‘multiple-entity-row’ or ‘hui-element + sensor-entity’ I can use card-mod - but inside a decluttering-card it stops working.

Example:

  1. With “:host” - doesn’t work:
decluttering_templates:
  decl_test_entity_row:
    card:
      type: 'custom:multiple-entity-row'
      entity: '[[SENSOR]]'
      style: |
        :host {
          color: red !important;
        }
  1. Tried a longer way - doesn’t work:
decluttering_templates:
  decl_test_entity_row:
    card:
      type: 'custom:multiple-entity-row'
      entity: '[[SENSOR]]'
      style:
        decluttering-card:
          $:
            multiple-entity-row:
              $:
                hui-generic-entity-row: |
                  .entities-row .state-entity {
                    color: red !important;
                  }

Code:

The second one might work with:

decluttering_templates:
  decl_test_entity_row:
    card:
      type: 'custom:multiple-entity-row'
      entity: '[[SENSOR]]'
      style:
        multiple-entity-row:
          $:
            hui-generic-entity-row: |
              .entities-row .state-entity {
                color: red !important;
              }

Is it possible to add a list of entities into the decluttering card?
Would like to pass specific entities into the decluttering to make use in e.g. custom:auto-entities

This example gives me the error “Entities need to be an array”. Also tried to remove - before [[list]] but that results in broken yaml format.

example:

decluttering_templates:
  
  list_of_things:
    card:
      type: entities
    entities:
      - entity: input_select.mode_room_[[mode]]
      - [[list]]

Then to fill the list

- type: custom:decluttering-card
  template: list_of_things
  variables:
    - mode: livingroom
    - list:
        - light.livingroom_footlamp
        - light.vardagsrum_tak

Tried this version too - did not work unfortunately.

Thank you so much for your effort. As I want to continue working with UI Lovelace mode I think you card is the way to reduce and reuse my code. However, it is not working and I am looking for same help. My piece of code is the following:

decluttering_templates:
  title:
    element:
      type: state-label
      prefix: Salón
      entity: sensor.placeholder
      tap_action:
              action: none
      hold_action:
              action: none
      style:
         top: 9.15%
         left: 25.4%
         color: '#bcbebf'
         font-family: SF Text
         font-size: 2.4vw
         font-weight: 500
         max-width: 1px
         cursor: default
...
title: Casa
views:
  - title: test
    path: test
    panel: true
    badges: []
    cards:
      - type: picture-elements
        image: /local/background.png
        elements:
        ...
        - type: 'custom:decluttering-card'
          template: title
...

Am I doing sth wrong?

Can you please explain what is not working? :slight_smile:

PS:

    cards:
      type: picture-elements

this above should be an array:

    cards:
      - type: picture-elements

Sorry. Copy&paste trouble. I defined as array and I edited my original post. My “not working” means I cannot see “Salón” text as expected (color, position, style). If don’t use your card, it works. The code is:

title: Casa
views:
  - title: test
    path: test
    panel: true
    badges: []
    cards:
      - type: picture-elements
        image: /local/background.png
        elements:
        ...
        - type: state-label 
          prefix: Salón
          entity: sensor.placeholder
          tap_action:
            action: none
          hold_action:
            action: none     
          style:
            top: 9.15%
            left: 25.4%
            color: '#bcbebf'
            font-family: SF Text
            font-size: 2.4vw
            font-weight: 500
            max-width: 1px
            cursor: default
...

I had a similar error when using it within picture-elements. The problem for me was the style attribute. It does not work when this is whithin the template of the decluttering card. So remove this from the template and add the style tag where you would use the decluttering card.

If I do it as you said, I have to copy&paste this style in each decluttering card I would use and that is what I want to avoid

I need to correct myself. It might be a bug in the decluttering card, but for me it works also with style, but only if I define a default value even if I do not use this variable later. Without the default, I get the same error.

You should do a minimal working example and increase it iteratively. I have this:

decluttering_templates: !include decluttering.yaml

And in the decluttering.yaml:

lcars_button_engineering:
  default:
    opacity: 0.6
  element:
    type: image
    image: /local/lcars/engineeringButton.svg
    tap_action:
      action: navigate
      navigation_path: "/lcars-ui/1"
    style:
      top: 12%
      left: 76.5%
      width: 15%
      opacity: "[[opacity]]"

In one lovelace yaml file, I use it as follows:

type: picture-elements
image: /local/lcars/engineeringInterfaceSmall.svg
elements:
  - type: custom:decluttering-card
    template: lcars_button_engineering

Again, the key for me was to add the default section, although it should be optional. Hope that helps.

1 Like

Yeah! Thx you so much. It is working right now!

Interesting, I’m going to look into that but I’m surprised :blush:

Thanks @RomRider! I really appreciate your work! :slight_smile: Be aware that this happens only when using it in picture elements.

I am using Lovelace in GUI editor mode (not sure if I am using a correct definition).

Have a lot of decluttering templates.
I want to split these templates into separate files.
Is it possible to do something like this:

decluttering_templates:
  !include name_of_template_1.yaml
  !include name_of_template_2.yaml
  !include name_of_template_3.yaml


title: Home
views:
  - path: default_view
    title: Home
    icon: 'mdi:home'
...

Tried it in a raw editor but got an error.

Including files is only supported in yaml mode.