Decluttering Card Plus Contents ↓ GitHub ↗

Badges

Badges are the small pills across the top of a sections view. A badge template makes them reusable in exactly the way card does for cards.

Badges need the sections view type, so Home Assistant 2024.8 or newer.

decluttering_templates:
  power_badge:
    badge:
      type: entity
      entity: '[[entity]]'
      name: '[[name]]'
      color: '[[color]]'
      show_name: true
    default:
      - color: blue

Use it in a view’s badges: list:

views:
  - type: sections
    badges:
      - type: custom:decluttering-card-plus
        template: power_badge
        variables:
          - entity: sensor.solar_power
          - name: Solar
          - color: yellow
      - type: custom:decluttering-card-plus
        template: power_badge
        variables:
          - entity: sensor.house_power
          - name: House
          - color: red
      - type: custom:decluttering-card-plus
        template: power_badge
        variables:
          - entity: sensor.living_room_temperature
          - name: Living Room
          - color: green
    sections:
      - type: grid
        cards: []

Three badges built from one template, in yellow, red and green

Three badges, one template, one variable each for the bit that differs.


Adding one through the UI

While editing a sections view, click + Add badge, then By card, and search for declutter. Pick Decluttering Card Plus — the same card serves badges and cards, and it works out which you meant from the template you choose.

How it sits in the layout

Badges live in a flex row, so the wrapper gets out of the way completely rather than boxing the badge — it does not add a box, spacing, or a layout level of its own. Your badge sits in the row exactly as a normal one would.

One consequence: style reaches the badge itself, but there is no wrapper to paint on, so selectors aimed at the host have nothing to style. See Styling.

A badge per item (v1.11.0+)

A badge fills one slot, so a badge template cannot repeat by itself. A view can repeat it instead: one badge per person, per light, per anything Home Assistant knows about. See Repeating Sections and Badges.

views:
  - title: Home
    strategy:
      type: custom:decluttering-card-plus
      badges:
        - for_each_from: { domain: person }
          badge:
            type: custom:decluttering-card-plus
            template: person_badge
      sections: ...

The template gets each person’s entity and name without being passed them.

A set of badges as one badge (v1.15.0+)

A group: template put in a view’s badges builds its cards as badges, side by side in the row with the others. Nothing changes in the template: the same group: is a set of cards in a section and a set of badges in the badges row.

decluttering_templates:
  lights:
    group:
      cards:
        - type: custom:decluttering-card-plus
          template: light_badge
          variables:
            - entity: light.kitchen
        - type: custom:decluttering-card-plus
          template: light_badge
          variables:
            - entity: light.living_room
        - type: entity
          entity: light.bedroom
          show_name: true
badges:
  - type: entity
    entity: sun.sun
  - type: custom:decluttering-card-plus
    template: lights
  - type: entity
    entity: sensor.living_room_temperature

The badges row: the sun, then the kitchen, living room and bedroom lights from one group template, then the temperature

Everything in the group has to be something that works as a badge, the same as anything else in the badges row; a card that is not a badge gets Home Assistant’s own badge error. A badge with visibility hides on its own and the row closes up around it, and a group whose badges are all hidden takes no room at all. The group still wraps as one: when it does not fit at the end of a line, the whole set moves to the next. In edit mode it is one badge, dragged and edited as a whole.

Any badge type

badge: takes any badge configuration Home Assistant supports, including custom badges from other integrations:

decluttering_templates:
  person_badge:
    badge:
      type: entity
      entity: '[[person]]'
      show_state: true
      show_name: true
      tap_action:
        action: more-info
badges:
  - type: custom:decluttering-card-plus
    template: person_badge
    variables:
      - person: person.john

When a badge cannot be built

A card that cannot be built shows the error card (v2.9.0+), with the line that failed and buttons to fix it. A badge has no room for that, so it keeps Home Assistant’s red alert with the message, as before. The message is the same one the error card would give, and the editor’s dashboard health lists it too.

A badge for the dashboard’s health (v2.9.0+)

The health badge: an amber exclamation mark, 4 to look at, Templates

The health card is a badge as well: put it in a view’s badges and it says how many templated cards need a look, or All fine. Click it for the full health panel. With hide_when_clean: true it is only there on a bad day:

badges:
  - type: custom:decluttering-card-plus-health-card
    hide_when_clean: true

It counts the view’s templated badges as well as its cards. See The Health Card and Badge.


Reference

The keys this page uses, and the common ones beside them.

Key Where Description
badge: template The badge configuration, with [[variables]]
group: (v1.15.0+) template In a view’s badges, a set of badges in one slot, written under cards: or as a bare list — see above
default: template Fallback variable values, as a list (- name: value) or a mapping
style: template or instance CSS to inject. There is no wrapper box to paint on, so use custom properties — see Styling
on_error: (v2.0.0+) template or instance A badge to show, or hide, when building fails — see Using Templates
template: instance Name of the template
variables: instance Values to substitute, as a list (- name: value) or a mapping
badge: (v1.12.0+) instance Laid over what the template builds, as written — see Using Templates
visibility: instance Home Assistant’s own conditions, applied around the badge — see Visibility

Every key, with an example of each, is in the Configuration Reference.


→ Cards · Rows · Elements