Decluttering Card Plus Contents ↓ GitHub ↗

Repeating Sections and Badges (v1.11.0+)

for_each repeats a template inside one card, and one card only ever fills the slot it was given. A repeat over the rooms of the house therefore lands in a single section: it never reflows on a narrow screen, and the rooms cannot have a heading or a background of their own.

The card can also write a whole view. Give a view a strategy of custom:decluttering-card-plus and its sections: and badges: can repeat: one section, or one badge, per item. Home Assistant then lays the view out like any other sections view.

views:
  - title: Rooms
    path: rooms
    strategy:
      type: custom:decluttering-card-plus
      max_columns: 3
      badges:
        - for_each_from: { domain: light }
          badge:
            type: entity
            entity: '[[entity]]'
            show_name: true
      sections:
        - for_each_from: { areas: true }
          section:
            type: grid
            background: true
            cards:
              - type: heading
                heading: '[[area]]'
              - type: custom:decluttering-card-plus
                template: room_entities

with a template that tiles whatever the area holds:

decluttering_templates:
  room_entities:
    card:
      type: custom:decluttering-card-plus
      template: entity_tile
      for_each_from:
        area: '[[area_id]]'
  entity_tile:
    card:
      type: tile
      entity: '[[entity]]'

One section per area, each with its own heading and background, and a badge per light

A section per area and a badge per light, from one view definition.

On a phone the same view drops to a single column, which a repeat inside one card cannot do:

The same view on a phone, one section under another


How an entry repeats

Each entry of sections: or badges: is either a section or badge as you would normally write it, or a repeat:

Key Description
for_each A written-out list. Each item is that copy’s values, exactly as in Repeating a Template
for_each_from What Home Assistant knows: entities, areas, devices, floors, labels, with every filter, sort, limit and group_by the card’s own repeat takes. See Repeating over what Home Assistant knows and Repeat Reference
section / badge What each copy is, with [[placeholders]] filled from that copy’s values. Required: a repeat entry without it produces nothing, and says nothing
variables Values every copy of this entry gets. A copy’s own values win
empty A section or badge to show instead when the repeat matches nothing. It is used exactly as written, with no placeholders filled

A for_each_from here also takes the v2.0.0 sources and filters: a Jinja list, the dashboard’s views, category:, unit: and state_class:. A Jinja list is rendered once each time the view is written out.

An entry without for_each or for_each_from goes through exactly as written, so ordinary sections and badges sit among the repeated ones in the order you list them. An entry with one of them is a repeat, whatever else it holds, so it needs its section: or badge:: if that key is missing or misspelt, the entry quietly disappears from the view.

Every copy also gets index, index0, count, first and last, so '[[area]] ([[index]] of [[count]])' works as a heading.

Which value wins

When a copy, its entry and the strategy set the same name, the first of these wins:

  1. the copy’s own values, such as an area copy’s area and area_id
  2. the entry’s variables:
  3. the strategy’s variables:
  4. the position values, index to last

So, as on a card, an entry’s variables: [{name: Lounge}] does not rename an area copy, because the copy carries its own name; use the source’s overrides: for that.

Unlike a repeating card, there is no template here to declare required: true, so every copy the source gives becomes a section or badge. Use the source’s require: to drop the ones missing a value.

Values handed to templated cards

A custom:decluttering-card-plus card inside a repeated section is handed that copy’s values, after its own. In the example, room_entities uses [[area_id]] without the card passing it: the area being repeated over supplies it. Anything the card sets in its own variables still wins.

The health panel counts those values as set, so it does not report them as missing.

Values for the whole view

variables: at the top of the strategy go to every repeated entry, underneath each entry’s own. decluttering_defaults works too, written inside the strategy:

strategy:
  type: custom:decluttering-card-plus
  decluttering_defaults:
    colour: amber
  sections: ...

Everything else is the view’s

Any other key in the strategy (max_columns, dense_section_placement, background, top_margin) is passed through to the view. Asking for sections: makes it a sections view unless the strategy says otherwise.


A view per item: the dashboard strategy (v2.0.0+)

A dashboard whose tabs are Home and one view per room, with the Kitchen view showing that room's tiles

The view strategy writes one view. The same strategy written on the dashboard writes the whole dashboard, and its views: can repeat: one view per item, the way the view strategy repeats sections. A dashboard of rooms is the same view over and over with a different area in it, and now it is written once.

On a dashboard of your own, open the pencil, then ⋮ → Raw configuration editor, and replace what is there with a strategy:

strategy:
  type: custom:decluttering-card-plus
  decluttering_templates:
    entity_tile:
      card:
        type: tile
        entity: '[[entity]]'
  views:
    - title: Home
      path: home
      type: sections
      sections: ...                    # an ordinary view, passed through as written
    - for_each_from:
        areas: true
        with:
          domain: light
      view:
        title: '[[area]]'
        path: '[[area_id]]'
        type: sections
        sections:
          - type: grid
            cards:
              - type: heading
                heading: '[[area]]'
              - type: custom:decluttering-card-plus
                template: entity_tile
                for_each_from:
                  area: '[[area_id]]'

A repeat entry in views: takes the same keys as a repeated section, with view: in place of section::

Key Description
for_each / for_each_from What to repeat over, as for a section, including categories and Jinja lists. A views: source gives nothing here, since the dashboard is still being written
view What each copy is, with [[placeholders]] filled from that copy’s values. Required, as section: is for a section
variables Values every copy of this entry gets
empty A view to show instead when the repeat matches nothing

variables: at the top of the strategy go to every repeated view.

Values for the whole dashboard (v2.3.0+)

variables: at the top of the strategy now fill in the whole dashboard, not only the repeated views: an ordinary view written beside them, and settings at the dashboard’s own level that another card reads, such as a wallpanel: block. One value switches a kiosk on for every view at once.

strategy:
  type: custom:decluttering-card-plus
  variables:
    - kiosk: true
    - house: The Old Barn
  wallpanel:
    enabled: '[[kiosk|bool]]'
    hide_toolbar: true
  views:
    - title: '[[house]]'
      cards: ...

A dashboard whose title, first view and card text all come from the strategy's house variable

A placeholder nothing sets is left as written and nothing is said about it, so a button-card’s [[[ ... ]]] JavaScript and a [[name]] meant for a templated card further in pass through untouched. The decluttering_* keys are copied as they are. A strategy without variables: writes exactly what it wrote before.

Home Assistant only ever sees the dashboard this writes, so the cards in it look for their templates there. decluttering_templates, decluttering_defaults, decluttering_variables, decluttering_templates_from, and anything else the strategy holds besides type, variables and views, are copied to the written dashboard’s root. A library dashboard is borrowed from as usual.

A view’s path is part of its address, so a filled-in path is made fit for one: “Living Room” becomes living-room, a path that comes out the same as another gets -2 on the end, and a path of only digits gets view- in front, since Home Assistant would read a number as a view’s position. A path you write by hand on an ordinary view is kept as written, and a generated one makes way for it.

A repeated view can carry a view strategy of its own. What that inner strategy repeats over is filled in from the outer copy, so a view per area can repeat a section per light in that area with area: '[[area_id]]'; what it repeats is left for its own items to fill.

The dashboard is written out again when the entity, device, area or floor registry changes, like a generated view. To change the strategy itself, edit the dashboard’s raw configuration. If Home Assistant offers to take control of the dashboard, saying yes swaps the strategy for the views it last wrote, and those stop following the registry.

(v2.9.0+) A whole dashboard can also come from one template, kept on the strategy or borrowed from another dashboard: see Page Templates.


One section from a template: the section strategy (v2.9.0+)

Three sections in a sections view: Kitchen and Living Room built from one template, Bedroom written out

The view strategy repeats sections across a whole view. Sometimes you want one section, in an ordinary sections view you otherwise lay out by hand, that is a template: a room’s heading, its lights and its temperature, the same shape for every room. Give that one section a strategy:

decluttering_templates:
  room_section:
    description: A heading, a tile per light and the temperature, for one area
    default:
      - area: Kitchen
      - temperature: sensor.kitchen_temperature
    group:
      - type: heading
        heading: '[[area]]'
        icon: mdi:sofa
      - type: custom:decluttering-card-plus
        template: light_tile
        for_each_from:
          area: '[[area]]'
          domain: light
      - type: tile
        entity: '[[temperature]]'
        name: Temperature
  light_tile:
    card:
      type: tile
      entity: '[[entity]]'
      features:
        - type: toggle
views:
  - title: Rooms
    type: sections
    sections:
      - strategy:
          type: custom:decluttering-card-plus
          template: room_section
      - strategy:
          type: custom:decluttering-card-plus
          template: room_section
          variables:
            - area: Living Room
            - temperature: sensor.living_room_temperature
      - strategy:
          type: custom:decluttering-card-plus
          variables:
            - area: Bedroom
          section:
            type: grid
            cards:
              - type: heading
                heading: '[[area]]'
              - type: custom:decluttering-card-plus
                template: light_tile
                for_each_from:
                  area: '[[area]]'
                  domain: light
              - type: markdown
                content: Written out here, filled in from [[area]].

The strategy comes in two shapes.

A template, with template: and anything else a custom:decluttering-card-plus card takes beside it: variables:, a repeat, on_error:. The section holds one card built from that template. A group: template is the natural fit, since its cards take their own places in the section’s grid; a card template gives a section of one card.

A section written out, under section:, with its placeholders filled from the strategy’s variables:, the way a repeated section is filled from each item, only once. A templated card inside it is handed those values, as in the bedroom above. Leave out the section’s type and it is a grid.

Home Assistant only ever asks a section strategy for one section, so there is nothing here to repeat over: a section per item is the view strategy’s job.

Adding one from the dashboard

This needs Home Assistant 2026.11 or later. In edit mode, Create section → Automatic section lists Decluttering Card Plus under Community sections:

The Community sections list in Home Assistant's add-section dialog, with a Decluttering Card Plus tile previewing the Kitchen section

The tile is drawn with the first group: template the dashboard can see, its own or a borrowed one, or failing that the first card template. It is built with the template’s defaults (and, for a template with suggest_for:, the first entity that matches), so a template with no defaults previews with its placeholders showing. Picking it opens the section’s editor, which is the card editor: choose the template, fill in its variables and save.

Editing one

In edit mode a strategy section is an Automatic section with a wand on its corner. Its pencil opens the card editor, with the same template picker, variables and preview as a card. One thing is missing on purpose: there is no Replace this card with what it builds, because the section is the strategy, not a card that could be swapped for its output.

To take a section over by hand, use Home Assistant’s own ⋮ → Convert to manual section. A template section becomes an ordinary section holding the one templated card, which you can then edit, move or add cards beside like any other.

A written-out section is written again when the entity, device, area or floor registry changes, so it follows a renamed area. A template section has nothing to write again: the card in it keeps itself up to date.


Keeping up to date

The view is written out again when Home Assistant’s entity, device, area or floor registry changes. An area added in Settings appears as a new section within a couple of seconds, without a reload.

Labels and categories are not on that list. They are read when the view is written, so a view repeating over labels:, or narrowing by label: names or category:, picks up a new or renamed label or category only when the view is written again: after one of the four registries above changes, or when the page is reloaded.

Like the card’s own repeat, it does not follow live state. A section per light that is currently on is not something this does. See Where this card is going.


Editing a generated view

Home Assistant shows a generated view in edit mode, but the sections and badges in it are not individually editable. The + in a generated section does nothing. Edit the view itself: the pencil beside the view’s name, then ⋮ → Edit in YAML.

From a card that already repeats

A card repeating inside a section can be converted from its editor with Give each copy its own section. It moves the view into the strategy for you: the card’s section is repeated once per copy, and everything else in the view goes along unchanged. Home Assistant’s undo button reverts it.


When to use which

You want Use
Copies side by side inside one card or section for_each on the card, with min_column_width so it narrows on a phone
A heading, a background or a reflowing block per copy A repeated section, here
A badge per person, per light, per anything A repeated badge, here. A badge template on its own cannot repeat
A whole view per room, per floor, per anything The dashboard strategy
One section, in a view you lay out by hand, built from a template (v2.9.0+) The section strategy
A whole dashboard written once and used on several (v2.9.0+) A page template

Next

→ Repeating a Template · Visual Editors → Configuration Reference