Lovelace: Decluttering Card

can anyone spot the issue in my decluttering config… I must be overlooking the obvious, but can see it…

decluttering:

card:
  type: conditional
  conditions:
    - entity: media_player.googlehome_[[id]]
      state_not: unavailable
  row:
    entity: input_boolean.googlehome_[[id]]
    state_color: true

and card config, with the verbose conditional row, and the one using the decluttering:

      - type: custom:decluttering-card
        template: conditional_row_boolean
        variables:
          - id: library

      - type: conditional
        conditions:
          - entity: media_player.googlehome_library
            state_not: unavailable
        row:
          entity: input_boolean.googlehome_library
          state_color: true

somehow I keep getting:

even though I strictly followed (copied) the verbose row, and as yo can see the variables get replaced correctly…

can we not do this for a row?

edit

not without a trick, but with custom:hui-element, yes we can !

card:
  type: custom:hui-element
  row_type: conditional
  conditions:
    - entity: media_player.googlehome_[[id]]
      state_not: unavailable
  row:
    entity: input_boolean.googlehome_[[id]]
    state_color: true

thanks Thomas for the nudge!

i installed decluttering-card.js in www directory

in configuration.yaml

lovelace:
  mode: yaml
  resources:
    - url: /local/decluttering-card.js
      type: module

in ui-lovelace.yaml

decluttering_templates: !include decluttering_templates.yaml

in decluttering_templates.yaml

cover_button:
  type: custom:vertical-stack-in-card
  cards:
    - type: horizontal-stack
      cards:
        - type: custom:button-card
          size: '[[size]]'
          entity: '[[entity]]'
        - type: custom:button-card
          size: '[[size]]'
          entity: '[[entity]]'
          template: cover_stop
        - type: custom:button-card
          size: '[[size]]'
          entity: '[[entity]]'
    - type: custom:button-card
      name: '[[name]]'

my card

            - type: custom:decluttering-card
              template: cover_button
              variables:
                - entity_id: sensor.processor_use
                - vm_name: processor

my mistake

Cannot read properties of undefined (reading 'cover_button')

I ask for help

1 Like

Variables in call

and variables in a template

must have same names.

I wonder…is it possible above type of configuration if dashboad is not in yaml mode? I mean, to have one single file with all “declulttering templates” inside and then just call it from dashboard? I guess not, because i get an error when trying to save if i make that file and then try to call it with

decluttering_templates: !include decluttering_templates.yaml

at the beginning of selected dashboard (by edit dashboard → raw configuration editor, inserted before “view”)
It would be nice to work, though… i have same templates in three dashboards…

Imho most of experienced people are using yaml-mod.
Storage mode is basically for testing something.
And yes, for dashboards in storage mode I need to paste a particular decluttering template into a “raw” file - just for testing.

1 Like

Weah, welll, i like to have UI available. Many things can be done way quicker than write whole code for each and every little thing… apart that, i’m not exactly “experienced” guy, i’m still learning…

Nonetheless, HA owners tend to “force” all addon writers to comply their code with UI interface, so i guess running in UI is something which is prefferred.

Thanks!

I had to indent my decluttering card file. An entry looks like this:

# card with main entity and lock entity
  locking-thing:
    card:
      type: 'custom:button-card'
      entity: '[[thing_entity]]'
      name: '[[thing_name]]'
      template: standard-button
      triggers_update: all
      aspect_ratio: '[[aspect_ratio]]'
      styles:
      ... and so on

Also note that the first line after the defining name is “card:”

There’s actually a simple answer but you won’t like it. !include only works in yaml mode.

Yes, you’re correct. The reason i don’t like yaml mode (yet) is lack of my programming skills. Maybe some day…never say never, right?

you probably didn’t understand

you probably didn’t explain your issue

you probably can’t read

everything is written

if you don’t know the answer then don’t write nonsense

you probably cannot communicate in a polite way
and you probably cannot understand my answer about your error

Deleting post as I spotted my own stupid error! :slight_smile:

Hi, I’m looking at how to use this. I’m quite dumb, I’ve installed via hacs, and I don’t understand the rest:

Is this in my dash under here?
image

image

I don’t have anything to declutter yet, so I don’t even know how to start or test.

The “decluttering_templates” section must be on the top:

decluttering_templates:
  test_xxxx:
    default:
      - VALUE: xxx
    card:
      type: entities
      entities:
        - entity: sun.sun
          name: '[[VALUE]]'
views:
  - title: view_1
    path: view_1
    theme: ''
    badges: []
    cards:
      - ...
1 Like

Thanks that worked ok.
Is there a way to share templates across dashboards?

The only way is using dashboards in yaml mode.
Then you may use “!include”.

Do you mean not using the gui at all? As there’s no clear path for these configs.

image

So I guess there’s no way to use !include in this config and add my own yaml file only for decluttering_templates

You cannot use !include in storage mode.
In storage mode every dashboard (i.e. all views, all cards) is stored as one json file.
When using the Lovelace editor, this code is auto-converted to yaml; after saving again turns into json.
“Raw configuration editor” - when the whole dashboard is converted into yaml.
Trying to use “!include”, “!secret” here will cause an error on saving.
Means - all decluttering templates have to be added explicitly (not by “!include”).