Decluttering Card Plus Contents ↓ GitHub ↗

Rows

A row template holds a single row of an Entities card — an entity row, a button row, a conditional row, a divider, a section header, or a custom row.

decluttering_templates:
  temperature_row:
    row:
      entity: '[[entity]]'
      name: '[[name]]'
      icon: '[[icon]]'
    default:
      - icon: mdi:thermometer

Use it inside an Entities card’s entities: list:

- type: entities
  title: Temperatures
  entities:
    - type: custom:decluttering-card-plus
      template: temperature_row
      variables:
        - entity: sensor.living_room_temperature
        - name: Living Room
    - type: custom:decluttering-card-plus
      template: temperature_row
      variables:
        - entity: sensor.kitchen_temperature
        - name: Kitchen
    - type: custom:decluttering-card-plus
      template: temperature_row
      variables:
        - entity: sensor.bedroom_temperature
        - name: Bedroom
    - type: custom:decluttering-card-plus
      template: temperature_row
      variables:
        - entity: sensor.living_room_humidity
        - name: Living Room humidity
        - icon: mdi:water-percent

An Entities card whose four rows all come from one template

The last row overrides the default icon; the others take mdi:thermometer.


Adding one through the UI

There is no row picker entry for this — add an Entities card, switch to Show code editor, and add the row by hand as above. Everything else about the Entities card continues to work normally.

Only where rows are drawn

A row template goes where Home Assistant draws entity rows: an Entities card’s entities: list, or another card that uses the same row code. It does not work in another card’s own settings lists, such as Advanced Camera Card’s cameras:, because that card reads the list itself and nothing draws it as rows. To vary a list like that, pass it into a card template as a variable instead. See In other cards’ elements: lists for an example.

Row types

row: takes any Entities card row. A plain entity row needs no type: at all — just an entity. Anything else names its type:

decluttering_templates:
  # plain entity row
  plain_row:
    row:
      entity: '[[entity]]'
      name: '[[name]]'

  # button row
  action_row:
    row:
      type: button
      entity: '[[entity]]'
      name: '[[name]]'
      action_name: '[[action]]'
      tap_action:
        action: toggle
    default:
      - action: Toggle

  # conditional row
  when_on_row:
    row:
      type: conditional
      conditions:
        - entity: '[[entity]]'
          state: 'on'
      row:
        entity: '[[entity]]'
        name: '[[name]]'

  # divider
  line:
    row:
      type: divider

In an Entities card, one of each:

- type: entities
  title: Bedroom
  entities:
    - type: custom:decluttering-card-plus
      template: plain_row
      variables:
        - entity: sensor.bedroom_temperature
        - name: Temperature
    - type: custom:decluttering-card-plus
      template: action_row
      variables:
        - entity: light.bedroom
        - name: Bedside lamp
    - type: custom:decluttering-card-plus
      template: line
    - type: custom:decluttering-card-plus
      template: when_on_row
      variables:
        - entity: light.reading_lamp
        - name: Reading lamp is on
    - type: custom:decluttering-card-plus
      template: when_on_row
      variables:
        - entity: switch.cd_heater_switch
        - name: Heater is on

An Entities card titled Bedroom: a temperature row, a Bedside lamp row with a Toggle button, a divider, and a Reading lamp is on row with its toggle

The heater is off, so its conditional row is not drawn; the reading lamp is on, so its row is.

A row template, or repeat: inside one card

Two ways give an Entities card a row per thing, and they suit different cards. A row template is for a row that is reused across different cards, or placed by hand between rows written out, as above: each card names the template and gives it values. repeat: inside a card template is for one card that lists many of the same thing, every light in the house say: the template holds the row once, as an item, and the card writes '[[row|repeat:lights]]' where the rows go. A row template can repeat too, with for_each on its entry (below), which is the middle ground: a hand-placed entry that becomes several rows.

Editing rows visually

The template editor offers a Row tab when the template’s content type is set to Row, giving you Home Assistant’s own row editor for the body. See Visual Editors.


One entry, many rows (v2.9.0+)

A row template can repeat. One entry with for_each or for_each_from becomes a row per item, in place, between whatever is written before and after it in the entities card:

type: entities
entities:
  - sun.sun
  - type: custom:decluttering-card-plus
    template: light_row
    for_each_from:
      domain: light
  - type: divider

Each row is given index, count, first and last, and the template’s own visibility: can leave rows out. See Repeating a Template.


Reference

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

Key Where Description
row: template The row configuration, with [[variables]]
default: template Fallback variable values, as a list (- name: value) or a mapping
style: template or instance CSS to inject — see Styling
on_error: (v2.0.0+) template or instance A row 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
row: (v1.12.0+) instance Laid over what the template builds, as written — see Using Templates
for_each:, for_each_from: (v2.9.0+) instance A row per item, in place; see One entry, many rows

visibility: on the instance does nothing on a row: Home Assistant only applies it around cards and badges. Use a type: conditional row, as above, instead. A template’s own visibility: (v2.9.0+) is different: it reads variables, not state, and does work on rows.

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


→ Cards · Badges · Elements