Lovelace: Decluttering Card

found another issue. variables this.entity_id in an auto-entities config not being handled by the decluttering card.

consider a regular entities with decluttering:

  - type: entities
    entities:

      - type: custom:decluttering-card
        template: event_date
        variables:
          - entity: sensor.verjaardag_me

and decluttering:

card:
  type: custom:template-entity-row
  entity: '[[entity]]'
  state: >
    {% if states[config.entity] is not none %}
    {{states(config.entity)}} {{state_attr(config.entity,'unit_of_measurement')}}
    {% else %} Not yet set
    {% endif %}
  secondary: >
    {% if states[config.entity] is not none %}
    {{state_attr('[[entity]]','type')}}: {{state_attr('[[entity]]','original_date')}}
    {% else %} Not yet set
    {% endif %}

showing perfectly in dashboard, including the secondary line based on config.entity (which is the template entity row translation of the cards entity_id.

now, setting this in an auto-entities, so I dont have to list all events manually, and, more importantly, can sort them based on state:

  - type: custom:auto-entities
    card:
      type: entities
    filter:
      include:
        - entity_id: sensor.verjaardag*
        - entity_id: sensor.ontmoetings*
        - entity_id: sensor.trouwdag
      options:
        type: custom:decluttering-card
        template: event_date
        variables:
          - entity: this.entity_id
    sort:
      method: state
      numeric: true

it works perfectly fine, and sorts all events. However, there is no secondary line!

Ofc I also tries to use

        variables:
          - entity: config.entity

but that has no result at all either.

to test the card setup itself, I also entered a true entity_id like in the verbose config. No secondary line either!

yet again a decluttering-card anomaly? How come it recognizes the entity in the auto-entities, even without setting the variables:

      options:
        type: custom:decluttering-card
        template: event_date
#         variables:
#           - entity: this.entity_id

but does not use it for the secondary_line…

Ive also changed the secondary line template to:

  secondary: >
    {% if states[config.entity] is not none %}
    {{state_attr(config.entity,'type')}}: {{state_attr(config.entity,'original_date')}}
    {% else %} Not yet set
    {% endif %}

and still, no result using the decluttering card

heck, it doesnt even consider the options with decluttering card, I can take that out completely, and the listing remains identical… huh?

UPDATE

it was a user error…
I missed an Asterix after sensor.trouwdag, and had to copy&paste the options section on all inured filters:

    - type: custom:auto-entities
      card:
        type: entities
      filter:
        include:
          - entity_id: sensor.verjaardag*
            <<: &options
              options:
                type: custom:decluttering-card
                template: event_date
                variables:
                  - entity: this.entity_id
          - entity_id: sensor.ontmoetings*
            <<: *options
          - entity_id: sensor.trouwdag*
            <<: *options
      sort:
        method: state
        numeric: true

now works as expected.

1 Like

I posted in a thread here that makes use of decluttering, not going to report everything you can read there if you like. I will likely put all this on Git as I do with other chunks of my HA interfaces.

I must say that decluttering-card is one of the best things I have ever encountered. I have nothing but respect for @RomRider and what this allows. One dashboard reduced by over 20 times the lines of code because of it.

1 Like

Is it possible to assign a value to “state” ?
Here is my template. The assignment of a to “label” work fine, but I get an error message for the assignment to “state”.
Is this a limitation of decluttering of Home Assistant?

decluttering_templates:
  flag_tile:
    card:
      type: custom:button-card
      entity: '[[v_ent]]'
      show_icon: false
      name: '[[v_name]]'
      show_state: true
      state: >-
        [[[
        var id =  states['[[v_from]]'].state;
        return id
        ]]]
      show_label: true
      label: >-
        [[[
        var id =  states['[[v_from]]'].state;
        return id + " my stuff"
        ]]]

I would take an in depth look at Lovelace: Decluttering Card - #395 by Ildar_Gabdullin

I find it invaluable information to understand things. I would think you pass in the whole template that makes the state and not try to pass in just the [[v_from]]. So (untested) like below, refer to example 2 in the link:

variables:
    - v_from_state: '{{states('your_v_from_entity_here').state }}'

And then in the decluttering template you just have

state: '[[v_from_state]]'

But it is possible that custom:button-card templates are colliding in Javascript, not sure. That example uses jinja and not javascript templates

Thank you your quick replay and suggestion. I tested it and could not get it to work.
However, looking at the link, I tough of a different solution; breaking the ‘label’ in two lines. First on having the from date and the second having the to date.
Thanks

The decluttering card appears to be broken with Core 2023.4.0.
There were some changes to the database. I wonder if that’s why.
At any rate all of my decluttering card - based buttons display error messages indicating a null entity.

did you update it? There was a fix released yesterday. Working perfectly here

Everything is updated as of today.
(Which “it” are you referring to?
the decluttering card?)

yes the decluttering card - updated yesterday

Indeed it did. I checked and I did indeed update it yesterday.

Is it decluttering or possibly the card you are decluttering?

Really, every post about “card XYZ is broken” should contain the MINIMAL code reproducing the issue, otherwise it is a waste of time.

I updated decluttering card javascript file to the version released 4 days ago and rebooted home assistant but the error is still there

if it’s not installed via HACS, did you remember to change the version number in the resource to be sure it loads the new version? Rebooting won’t do that.

1 Like

Indeed, to add the version helped very much. Thank you

Hi,

I need to change --masonry-view-card-margin in decluttering card. Can you help me?

thx

Hi,

I am trying to reference an object/entity by its name which is created from a string.
In code it works as shown below when I use states(…) and state_attr(…) but can I can’t figure it out how to replace the default valiable ‘shutter_window’ with the generated string.

default:
  shutter_entity: cover.office_shutter
  shutter_window: binary_sensor.office_shutter_window_input
card:
  - type: custom:mushroom-chips-card
    chips:
      - type: conditional
        conditions:
          - entity: '[shutter_window]'
            state: 'off'
        chip:
           type: template
           primary: ''
           entity:  '[[shutter_window]]'
           content: >-
              {% set state = states('binary_sensor.' + '[[shutter_entity]]'.split('.')[1] + '_window_input') %}
              {% if state == 'off' %}
                 closed
              {% else %}
                  open
              {% endif %}
            icon: >-
              {% set state = states('binary_sensor.' + '[[shutter_entity]]'.split('.')[1] + '_window_input') %}
              {% if state == 'off' %}
                 mdi:window-closed-variant
              {% else %}
                 mdi:window-open-variant
              {% endif %}
            icon_color: >-
              {% set state =  states('binary_sensor.' + '[[shutter_entity]]'.split('.')[1] + '_window_input') %}
              {% if state == 'off' %}
                 grey
              {% else %}
                 red
              {% endif %}

Has anyone an idea?

Cheers,
Chris

Hello together,

maybe someone can help me.
I’m trying to insert a condition weather a variable is not initial or has a default value.

Example:

- type: conditional
  conditions:
    - condition: template
      value_template: '{{ [[watch]] != "default" }}'
  card:
    type: vertical-stack

i want to only show the vertical-stack if the variable “watch” hasn’t the value “default” or maybe “” if its easier. :smiley:

cheers,
Miguel

The conventional Conditional card does NOT support templates - at least according to docs.
You may redesign this logics w/o using a template.

1 Like

exactly, as Ildar says, let me add to it:
just create a binary sensor for that and use the binary in the conditional.
.

1 Like