Variables
Variables are the holes in a template. You write [[name]] in the template, and pass a
value for name when you use it.
decluttering_templates:
room_light:
card:
type: tile
entity: '[[light]]'
name: '[[room]]'
type: custom:decluttering-card-plus
template: room_light
variables:
- light: light.kitchen
- room: Kitchen
To see what any placeholder on this page gives back, step by step, paste it into Try a placeholder - more in Trying It Out.
On this page:
- Writing placeholders
- Passing values
- Default values:
default: - Defaults that reference other variables
- Values the template works out for itself:
let: - Values worked out for a whole dashboard, view or section:
decluttering_let - Asking for a variable in a different shape
- Asking Home Assistant for a value
- Following an entity’s state:
rebuild_on - Times:
relative,format:andage - Standing in for what nothing set:
|default: - Putting a mapping in on purpose
- What a choose selector picked:
.chosen - Switching an option on and off:
bool - A variable the template can do without
- Keeping a value only while another variable says so:
if: - Building list entries:
with:andrepeat: - Which template is building:
__template_name__and its family - Writing
[[and meaning it - Value types
- Unresolved placeholders
- Reference
Writing placeholders
A placeholder is a name in double square brackets: [[light]], [[room]], [[accent]].
When a placeholder is the whole value, quote it.
entity: '[[light]]' # ✅
entity: [[light]] # ❌ not valid YAML - "[" starts a list
Inside a longer string, quotes are optional but harmless.
name: '[[room]] light'
title: Lights in [[room]]
Placeholders work anywhere in the content — values, nested mappings, list items, the
keys themselves, even inside CSS in a style block. They are substituted
throughout the whole template body, so '[[metric]]_colour': red with metric: humidity
becomes humidity_colour: red.
Passing values
variables: on the card can be written either way. A list, one name per entry:
variables:
- light: light.kitchen
- room: Kitchen
or a single mapping:
variables:
light: light.kitchen
room: Kitchen
Both are read the same way, here and in a template’s default:. The list form is what the
visual editor writes, so a card edited there comes out as a list whichever
way you typed it.
Default values: default:
default: on the template supplies fallbacks, so callers only pass what differs.
decluttering_templates:
area_sensor:
card:
type: tile
entity: '[[entity]]'
name: '[[label]]'
icon: '[[icon]]'
default:
- label: '[[area]] temperature'
- area: Living Room
- entity: sensor.living_room_temperature
- icon: mdi:thermometer
Used with no variables at all, it renders entirely from the defaults. Override one, and only that one changes:
# 1. nothing passed - pure defaults
- type: custom:decluttering-card-plus
template: area_sensor
# 2. override the area, and the label follows
- type: custom:decluttering-card-plus
template: area_sensor
variables:
- area: Bedroom
- entity: sensor.bedroom_temperature
# 3. override the label outright
- type: custom:decluttering-card-plus
template: area_sensor
variables:
- label: Solar output right now
- entity: sensor.solar_power
- icon: mdi:solar-power

default: uses the same shape as variables: — a list, or a single mapping.
The default values are also what the visual editor uses to draw its
preview, so giving every variable a sensible default makes templates much nicer to work on.
Written as defaults: (v2.0.0+)
The dashboard-wide key is decluttering_defaults, so defaults: on a template is an easy
thing to write. It used to be ignored without a word, leaving the brackets on the card. Now
both spellings mean the same thing, on a template and inside a
declaration:
decluttering_templates:
area_sensor:
defaults:
- label: '[[area]] temperature'
- area: Living Room
- entity: sensor.living_room_temperature
card:
type: tile
entity: '[[entity]]'
name: '[[label]]'
icon: mdi:thermometer

A template that writes both has the two lists merged, and default: wins a name they both
set. In a declaration, default: wins too. Everything that reads a template’s defaults reads
either spelling: extends, inherit_variables, debug, the editors and the health panel.
An exported template has defaults: folded into default:, so whoever imports it gets the
values whichever version they run. (From discussion #175.)
A template can go further and describe each variable — a label, a helper line and a Home Assistant selector — so that cards using it get a real entity picker or dropdown instead of a YAML box, and so the editors can warn about variables that are missing or unused. See Describing Variables.
Defaults that reference other variables
A default can contain placeholders of its own. Above, label defaults to
'[[area]] temperature', so changing area changes the label without the caller ever
mentioning label.
Substitution repeats until nothing is left to replace, and a value you pass always beats a default — including when the placeholder only appears because of an earlier substitution.
For a chain of a few links the order you list them in makes no difference. Each pass works down the list once, though, so a chain listed in the order it is used settles in one pass, and a chain listed backwards settles one link per pass. That only matters past ten links, where the backwards chain runs out of passes (see Loops).
This also gives you “fall back to another variable”:
default:
- title: '[[name]]' # if no title is given, use the name
- name: Sensor
Looking a value up by another variable (v1.15.1+)
A placeholder can sit inside another placeholder’s name. [[colours.[[level]]]] reads
level first, then picks that key out of the colours mapping - which is how a template
keeps a table of options in one place and lets each card choose a row from it:
decluttering_templates:
status_tile:
default:
- colours: { error: red, warning: amber, good: green }
- modes:
live: { provider: go2rtc, link: 'http://cam/[[name]]' }
image: { provider: image }
card:
type: tile
entity: '[[entity]]'
color: '[[colours.[[level]]|default:grey]]' # level: error -> red; level: meh -> grey
camera: '[[modes.[[mode]]]]' # mode: live -> the whole live mapping
A key the mapping does not have is an unset variable like any other: |default: stands in,
? takes the option out, and anything else is
left visible. A looked-up mapping goes in
whole, with its own placeholders filled. (From discussion #192.)
(v3.2.0+) The mapping can itself come from a placeholder, such as one joined with
|merge:: [[m3.[[cat_txt]]]] picks the key out of m3 once it is built. Before v3.2.0 only a
key written out, [[m3.cat]], reached into it.
Loops
A variable that refers to itself can never be resolved. Substitution gives up after 10 passes and logs a warning to the browser console rather than hanging:
decluttering-card-plus: gave up substituting variables after 10 passes.
Check whether a variable refers to itself.
The placeholder that refers to itself is then also reported as one nothing gives a value
to, in a second message. (v2.11.0+) The warning instead names the template, the placeholders
left, and the loop, such as [[a]] → [[b]] → [[a]], and the second message is gone. See
Troubleshooting. Ten passes is plenty for ordinary templates; a chain longer than
ten links needs listing in the order it is used, as above. The other limits — how deep a
dotted name reaches, how far with: and repeat: nest, how many copies one card makes —
are on Placeholder Reference.
Values the template works out for itself: let: (v1.7.0+)
let: is for a value the template needs in several places and nobody outside it should
have to know about. Write the chain once, use the name everywhere:
my_room_card:
let:
room_slug: '[[room|slug]]'
motion: 'binary_sensor.[[room_slug]]_motion'
card:
type: tile
entity: 'light.[[room_slug]]'
name: '[[room]]'
A card using this passes room: Living Room and gets light.living_room and
binary_sensor.living_room_motion without either of them appearing in its configuration.
One let: can build on another, as motion does above. The difference from a default: is
who owns it: a card cannot override a let:. A default is a fallback the caller may
replace, while a let: is template internals — passing room_slug: from a card changes
nothing, which is the point of it.
Values worked out for a whole dashboard, view or section: decluttering_let (v2.0.0+)
A let: lives in one template. When the same worked-out value is wanted by every template
on a dashboard, a view or a section, write it once there instead, anywhere
decluttering_defaults can go:
decluttering_let:
room_slug: '[[room|slug]]'
decluttering_templates:
room_pair:
card:
type: grid
columns: 2
square: false
cards:
- type: tile
entity: '[[light]]'
name: '[[room]]'
color: '[[accent]]'
- type: tile
entity: '[[temperature]]'
name: Temperature
color: '[[accent]]'
views:
- type: sections
decluttering_let:
light: 'light.[[room_slug]]'
temperature: 'sensor.[[room_slug]]_temperature'
sections:
- type: grid
decluttering_let:
accent: indigo
cards:
- type: heading
heading: Downstairs
- type: custom:decluttering-card-plus
template: room_pair
variables:
- room: Living Room
- type: custom:decluttering-card-plus
template: room_pair
variables:
- room: Kitchen
- type: grid
decluttering_let:
accent: amber
cards:
- type: heading
heading: Upstairs
- type: custom:decluttering-card-plus
template: room_pair
variables:
- room: Bedroom
- accent: red # changes nothing: the section's let wins

Each card passes only room. The dashboard works out the slug, the view builds the two
entity ids from it, and the section picks the colour. The values are worked out per card,
from that card’s own variables, exactly as a template’s let: is, and a card cannot
override them: the bedroom passes accent: red and still comes out amber.
When more than one level sets a name, the template’s own let: wins, then the section’s,
then the view’s, then the dashboard’s. They also work inside the
view strategy. inherit_variables does not hand them down, the same as
let:; a nested card works them out again where it sits. A template borrowed from another
dashboard gets this dashboard’s decluttering_let first and its own dashboard’s underneath.
Every place a value can come from, lets and defaults together, is ranked in one list on
Placeholder Reference.
The card editor, its preview and the health panel build each card for the view and section
it sits in, so they see these values too, rather than showing [[light]] or warning that it
has no value. debug: console names the level each value came from. (From discussion #162.)
Asking for a variable in a different shape
A placeholder can ask for its value written differently, which lets one variable serve both a room’s name and the entity id built from it:
decluttering_templates:
room_tile:
card:
type: tile
entity: 'light.[[room|slug]]'
name: '[[room|title]]'
default:
- room: Back Garden
light.[[room|slug]] becomes light.back_garden, and [[room|title]] becomes
Back Garden. Pass room: John's Shed and you get light.john_s_shed without the caller
ever mentioning the entity id.
| Transform | Does | John's Back Garden becomes |
|---|---|---|
slug |
Lower case; every run of anything but a letter a to z or a digit becomes one _, trimmed from the ends |
john_s_back_garden |
upper |
Upper case | JOHN'S BACK GARDEN |
lower |
Lower case | john's back garden |
title |
Capitalises each word | John's Back Garden |
kebab (v1.1.0+) |
As slug, with - |
john-s-back-garden |
Transforms chain, left to right: [[room|slug|upper]] gives JOHN_S_BACK_GARDEN. Order
matters, since slug lower-cases first — [[room|upper|slug]] gives john_s_back_garden.
Only the letters a to z count as letters, so slug and kebab replace an accented one like
any other character: Café Bar becomes caf_bar, and Café on its own becomes caf, the
_ at the end trimmed.
kebab is for the places Home Assistant wants hyphens, a view’s path above all. A button
that opens a room’s own view can build the link from the room’s name:
decluttering_templates:
room_button:
card:
type: button
entity: '[[light]]'
name: '[[room]]'
tap_action:
action: navigate
navigation_path: '/lovelace/[[room|kebab]]'
With room: Living Room the button goes to /lovelace/living-room.
Tidying up text somebody typed (v1.3.0+)
Two more are for values that came from a person rather than from Home Assistant — an
input_text, a name filled in by hand, something pasted from elsewhere.
| Transform | Does | ` living room ` becomes |
|---|---|---|
trim |
Removes the whitespace at both ends | living room |
capitalize |
Upper-cases the first character and leaves the rest alone | ` living room ` |
capitalize looks like it does nothing there, and on its own it does: the first character
is a space. That is why the two are usually chained — [[room|trim|capitalize]] gives
Living room.
capitalize is not title. title capitalises every word, which is what a label wants
and a sentence does not: [[room|trim|title]] gives Living Room, and
[[room|trim|capitalize]] gives Living room.
Transforms that take an argument (v1.4.0+)
The transforms above each do one fixed thing. Five more take an argument, written after a
colon the way attr: is:
| Transform | Does | Written | living_room_lamp becomes |
|---|---|---|---|
replace |
Swaps every occurrence of one piece of text for another | replace:_: |
living room lamp |
prefix |
Puts text in front | prefix:light. |
light.living_room_lamp |
suffix |
Puts text after | suffix: 2 |
living_room_lamp 2 |
max |
Shortens a long value, ending it with … |
max:12 |
living_room… |
map |
Looks the value up in a list of pairs | map:lamp=Lamp |
see below |
The argument runs to the end of the step, so it can hold spaces and colons of its own —
[[room|replace:_: ]] reads as “underscores to spaces”, trailing space included. It cannot
hold a bar or a closing bracket, because those end the step and the placeholder.
replace takes from:to. Leave the to off and it deletes rather than swaps, so
[[room|replace:_]] turns living_room into livingroom. The from is whatever comes
before the first colon of the argument, which means it cannot itself be a colon.
prefix and suffix decorate a value rather than supply one, so a gap stays a gap. An
empty name under [[name|suffix: sensors?]] is still empty, so the optional marker drops
the key rather than leaving a stray ` sensors behind, and default:` still sees nothing to
stand in for.
max keeps a long name from wrapping a tile. The … takes the last kept character’s place,
so the result is never longer than the number asked for: [[name|max:10]] on
Kitchen temperature gives Kitchen t…, ten characters, ellipsis included. A length that is
not a positive number leaves the value alone.
map turns a value into something a card option will actually accept — a colour, a label, an
icon name:
decluttering_templates:
level_tile:
card:
type: tile
entity: '[[entity]]'
color: '[[level|map:low=green,high=red]]'
Pairs are from=to, separated by commas. A value no pair names leaves the placeholder
visible rather than passing something through that color would choke on — write *=grey
to say “and anything else”. A named pair beats the star wherever it is written, so
map:*=grey,low=green still gives green for low.
These chain like any other transform, and run in the order written:
[[room|replace:_:-|upper]] gives LIVING-ROOM.
One thing to know about the optional marker. Because the argument runs to the end of the
step, a ? written against the closing brackets is read as the marker rather than as the
last character of the argument — [[who|prefix:Mr ?]] is an optional who with Mr in
front, not a prefix of Mr ?. The marker wins everywhere, which is the reading that keeps
? meaning one thing throughout.
The same variable can be used raw and transformed in the same template.
A transform is a way of writing a value out, not a way of choosing it, so a transformed
placeholder is always text. That makes it a tool for scalars: a number transforms as its
digits and a null as the word null ([[room|upper]] gives NULL), but a mapping or a
list under a transform is left unsubstituted — slugging or uppercasing its JSON would only
garble it, so the placeholder stays visible instead. The
sums and
list steps below are the exceptions.
Only those twelve are transforms, alongside the steps covered further down and on Placeholder Reference: the sums, list, colour and time steps,
json,raw,yaml,bool,if:,unless:,switch:,exists,contains:,find:,default:,or:,with:,repeat:and the ones that ask Home Assistant. A word after the bar that is none of those is not recognised, so nothing is substituted and you are left looking at[[room|shout]]in the card. That is deliberate: a silent empty string would be far harder to spot. The same goes for a chain: one unknown word in it leaves the whole placeholder alone rather than applying half of it.
Sums: add, sub, mul, div, mod, round and pad (v2.0.0+)
A placeholder can do a little arithmetic, which saves a helper entity or a Jinja template for something as small as placing the nth icon of a row or showing a reading to two places:
decluttering_templates:
row_icon:
element:
type: state-icon
entity: '[[entity]]'
style:
top: 50%
left: '[[index|sub:1|mul:12|add:4]]%' # 4%, 16%, 28%...

| Step | Does | 21.456 becomes |
|---|---|---|
add:n, sub:n |
Adds or takes away a number | add:1 gives 22.456 |
mul:n, div:n |
Multiplies or divides | mul:2 gives 42.912 |
mod:n |
The remainder after dividing | mod:5 gives 1.456 |
round |
Rounds to a whole number | 21 |
round:n |
Rounds to that many places | round:2 gives 21.46 |
pad:n |
Writes a whole number with zeros in front, to that many digits | 7 with pad:2 gives 07 |
They chain with each other and with every other step, left to right, so
[[reading|mul:9|div:5|add:32|round:1]] turns Celsius into Fahrenheit. When a chain ends in
a sum and the placeholder is the whole value, the card gets a real number, the way bool
puts in a real true or false, so columns: '[[size|mul:3]]' works in grid_options.
Inside a longer string the number is written as text. That makes a difference to
round:n: inside text it writes every place, so '[[t|round:2]] °C' with t: 2.5 gives
2.50 °C, but as the whole value it is a number, and a number has no trailing zeros, so
'[[t|round:2]]' gives 2.5. pad always gives text, since the leading zeros are the point
of it. Results are tidied to fifteen significant digits, so
0.1 with add:0.2 is 0.3.
The number after the colon can come from another variable: [[index|add:[[offset]]]] waits
for offset and then adds what it became.
pad: is for numbering. A repeat’s index runs 1, 2, 3, and pad:2 writes it 01, 02,
03, so the names line up and sort:
decluttering_templates:
numbered_lamp:
card:
type: tile
entity: '[[entity]]'
name: 'Lamp [[index|pad:2]]'
type: custom:decluttering-card-plus
template: numbered_lamp
for_each:
- entity: light.living_room
- entity: light.kitchen
- entity: light.bedroom
The three tiles are Lamp 01, Lamp 02 and Lamp 03. A tenth would be Lamp 10: pad:
only adds zeros to a number shorter than asked.
mod: is the remainder, which is how a repeat gives every other copy a different look.
[[index|mod:2]] is 1 for the first, third and fifth copy and 0 for the rest, and a
map: after it turns that into a colour:
decluttering_templates:
striped_tile:
card:
type: tile
entity: '[[entity]]'
color: '[[index|mod:2|map:1=teal,0=amber]]'
features:
- type: toggle
type: custom:decluttering-card-plus
template: striped_tile
for_each:
- entity: light.living_room
- entity: light.kitchen
- entity: light.bedroom
- entity: light.hallway

A value that is not a number, a decimal handed to pad, or an argument that cannot be used
(div:0, mod:0, round beyond 15 places, a word where a number should be) leaves the
value exactly as it was, and the browser console says why. A null is not a number either,
so [[n|add:1]] with n: null gives the text null and a warning. A number written as
text works: n: '3' adds up the same as n: 3.
Lists: join, split, first, last and count (v2.0.0+)
A list variable could only go into a card whole, or as JSON through json. These steps
show it as words, pick one item out, count it, or turn comma-separated text into a real
list:
| Step | Does | [Kitchen, Living Room, Hall] becomes |
|---|---|---|
join |
Writes the items as text, with , between them |
Kitchen, Living Room, Hall |
join:<sep> |
The same with your own separator; join: alone runs them together |
join: / gives Kitchen / Living Room / Hall |
split |
Turns text into a list, on commas | (text in, list out) |
split:<sep> |
Splits on your own separator | |
first, last |
One item | Kitchen, Hall |
count |
How many | 3 |

Text is read as a comma-separated list wherever a list is wanted, with each item trimmed and
empty ones dropped, so these mesh with labels, which
gives the label names joined by commas: [[entity|labels|count]]. A step that shapes text,
put after split, shapes every item: [[rooms|split|slug|join:,]] turns
Back Garden, Front Door into back_garden,front_door.
split as the whole value puts a real list in the card, which is how a comma-separated
string becomes an option that wants a list:
decluttering_templates:
light_list:
default:
- lights: light.living_room, light.kitchen, light.bedroom
card:
type: entities
title: Lights
entities: '[[lights|split]]'
first and last pick the two ends of a list, which is enough for a heading that names a
range without listing it:
decluttering_templates:
room_span:
card:
type: heading
heading: '[[rooms|split|first]] to [[rooms|split|last]]'
icon: mdi:home-group
With rooms: Living Room, Kitchen, Hallway the heading reads Living Room to Hallway.
A default: or or: reached after a split is split the same way, so
[[rows|split|or:name]] splits name when rows is not set, and the result is always a
list. count as the whole value is a real number. It also counts a mapping’s keys, and an
unset variable, a null or an empty string counts as 0, so count never leaves its
placeholder showing. join, first and last of an empty list give the empty string, so a
default: after them can stand in. first and last always give text, even from a list of
numbers: [[sizes|first]] with sizes: [1, 2] gives "1".
Counting and numbers in the viewer’s language: plural: and format_number (v2.9.0+)
A heading that counts things wants the right word for the number, and a big number wants the separators the person reading it is used to. Both depend on who is looking, so both follow the language and number format set in their Home Assistant profile:
decluttering_templates:
lights_on:
card:
type: markdown
content: |-
**[[lights|count]] [[lights|count|plural:light,lights]] on**
Energy this year: [[energy|format_number:1]] kWh
Tariff: [[price|format_number:currency=GBP]] per kWh
type: custom:decluttering-card-plus
template: lights_on
variables:
- lights:
- light.bedroom
- light.hallway
- energy: 12345.678
- price: 0.28

plural:light,lights picks a word by the number in front of it: the first for one, the
second for anything else, 0 included. Languages with more than two forms list more words,
in the order the language uses (one, two, few, many, other, keeping only the ones
it has), so Polish takes three: plural:światło,światła,świateł reads 1, 3 and 5 right. A
number past the last word you wrote takes the last one.
format_number writes the number with the viewer’s separators: 12345.678 is 12,345.678
in English and 12.345,678 for someone whose profile uses a decimal comma. After the colon
it takes a number of decimal places, format_number:1, or a currency,
format_number:currency=GBP, which also settles the decimals. With the number format set to None in the profile, the
number is written without grouping.
Both work on numbers, or text that is one. Anything else is left as it was and the console
says why, and so is a plural: with fewer than two words or a format_number: given an
argument it cannot use. format_number gives text, not a number, because its commas are
for reading: put it last.
Colours worked out from one: lighten:, darken:, alpha:, mix: and contrast (v2.9.0+)
A template given one colour can work out the rest of its scheme from it, so a card picks a colour once and the border, the wash behind it and the text on top follow:
decluttering_templates:
swatch:
card:
type: markdown
content: |-
**[[name]]** on [[colour]]
border [[colour|lighten:40]], text [[colour|contrast]]
style: |
:host {
--ha-card-background: [[colour]];
--primary-text-color: [[colour|contrast]];
--ha-card-border-color: [[colour|lighten:40]];
--ha-card-border-width: 4px;
}
- type: custom:decluttering-card-plus
template: swatch
variables:
- name: Blue
- colour: '#1565c0'
- type: custom:decluttering-card-plus
template: swatch
variables:
- name: Amber
- colour: '#ffc107'
- type: custom:decluttering-card-plus
template: swatch
variables:
- name: Tomato
- colour: tomato

The template’s own style: block does the colouring, through the custom properties every
card reads (see Styling); nothing else needs installing. The steps work anywhere
a colour is written.
| Step | Gives | #1565c0 becomes |
|---|---|---|
lighten:N |
The colour N percent of the way to white | lighten:20 gives #4484cd |
darken:N |
N percent of the way to black | darken:20 gives #11519a |
alpha:N |
The same colour, see-through, N from 0 to 1, as rgba() |
alpha:0.12 gives rgba(21,101,192,0.12) |
mix:other,N |
N percent of the way to another colour; half way without N | mix:#ff9800,50 gives #8a7f60 |
contrast |
#ffffff or #000000, whichever reads better on it |
#ffffff |
They read a hex colour (#1565c0, #fff, with or without an alpha), rgb() and rgba(),
and the CSS colour names, and they write hex back (alpha: writes rgba()), so they chain:
[[colour|lighten:40|contrast]] is the text colour for the lighter shade.
A theme variable such as var(--primary-color) has no value until the page is drawn, long
after the card was built, so it passes through unchanged and the console says the step
could not work on it. A value that is not a colour is left as written, with a word in the
console, and so is an argument the step cannot use, such as alpha:2.
Each step earns its place on an ordinary tile. darken: gives the border a shade deeper
than the tile’s own colour, so the two read as one:
decluttering_templates:
tinted_tile:
card:
type: tile
entity: '[[entity]]'
color: '[[colour]]'
features:
- type: toggle
style: |
:host {
--ha-card-border-color: [[colour|darken:20]];
--ha-card-border-width: 2px;
}

colour: '#1565c0' and colour: '#ffc107'; the borders come out #11519a and #cc9a06.
alpha: is the wash behind it: the same colour at twelve percent, as rgba(), so the
card’s background takes the tint without hiding the text:
decluttering_templates:
washed_tile:
card:
type: tile
entity: '[[entity]]'
color: '[[colour]]'
features:
- type: toggle
style: |
:host {
--ha-card-background: [[colour|alpha:0.12]];
}
With colour: '#1565c0' the background is rgba(21,101,192,0.12).
mix: is for a colour between two others. A heading over a pair of rooms that each have a
colour can take the one half way between them, the second colour coming from another
variable, which is filled in first:
decluttering_templates:
pair_heading:
card:
type: heading
heading: '[[title]]'
heading_style: title
style: |
:host {
--primary-text-color: [[left|mix:[[right]]]];
}
With left: '#1565c0' and right: '#ff9800' the heading is written in #8a7f60.
mix:[[right]],25 stays nearer the first colour, #507290.
Asking Home Assistant for a value (v1.1.0+)
A placeholder can also ask Home Assistant about the entity it names, which is what lets a template default a name to the entity’s own name rather than making every card pass one:
decluttering_templates:
room_tile:
card:
type: tile
entity: '[[entity]]'
name: '[[entity|friendly_name]]'
| Asks for | Gives | Read from |
|---|---|---|
friendly_name |
What the entity is called | Its friendly_name, then the name you gave it, then its original name |
area |
The name of the area it is in | Its own area, or its device’s |
floor (v1.2.0+) |
The name of the floor that area is on | The area’s floor |
device |
The name of its device | The name you gave the device, then the device’s own |
area_id (v1.2.0+) |
The area’s id rather than its name | Its own area, or its device’s |
device_id (v1.2.0+) |
The device’s id | The entity’s registry entry |
attr:<name> |
One named attribute; (v2.9.0+) only for an entity the card lists in rebuild_on, like state |
The entity’s current attributes |
domain (v1.7.0+) |
The half before the dot — light, sensor |
The entity id itself |
object_id (v1.7.0+) |
The half after the dot | The entity id itself |
labels (v1.7.0+) |
The labels it carries, comma separated | The entity’s own labels only; its device’s are not read |
icon (v2.0.0+) |
The icon it shows, or the empty string when it has none of its own | The icon set on it, then its state’s icon attribute |
manufacturer (v2.0.0+) |
Who made its device | Its device |
model (v2.0.0+) |
Its device’s model | Its device |
area_icon (v2.0.0+) |
The icon of its area, or the empty string | Its own area, or its device’s |
floor_icon (v2.0.0+) |
The icon of that area’s floor, or the empty string | The area’s floor |
device_class (v2.0.0+) |
What kind of sensor it is — temperature, motion |
Its state, then its registry entry |
translate (v2.0.0+) |
Home Assistant’s own word for it, in the dashboard’s language | Home Assistant’s translations. See below |
state (v2.0.0+) |
Its state, for an entity the card lists in rebuild_on only |
See Following an entity’s state |
last_changed (v2.9.0+) |
When its state last changed, for an entity the card lists in rebuild_on only |
Its state. See Times |
last_updated (v2.9.0+) |
When its state or an attribute last changed, likewise | Its state |
What Home Assistant gives back is text, never template code (v1.15.1+). A device,
entity or attribute whose name happens to contain [[...]] is shown with those brackets in
it, exactly as written: it is not read as a placeholder on the next pass, cannot take an
optional option out, and cannot change the card. The same goes for every value a
for_each_from copy is given.
Attributes that carry a token are refused rather than handed out, and the placeholder is
left: access_token, entity_picture and entity_picture_local (v1.4.0+), and any
attribute whose value has token= in it (v1.15.1+).
It cannot start another card’s code either (v2.3.1+): a name shaped like button-card’s
[[[ ... ]]], Jinja’s {{ ... }} or {% ... %}, or config-template-card’s ${ ... } reaches
that card with an invisible word joiner inside the opening brackets, so it is shown and not
run. Inside card_mod:, button-card’s styles: or a style:, the characters that would let a
name end a CSS rule are taken out. The one thing it cannot do is quote a name inside a string
in code you wrote yourself, [[[ return '[[name]]' ]]]: write [[name|json]] there, which puts
it in as a quoted, escaped string.
The two _id ones are for building rather than showing. A name is what you put on a card;
an id is what you put in another entity id:
card:
type: tile
entity: 'binary_sensor.[[entity|area_id]]_motion'
name: 'Motion in [[entity|area]]'
device is the name of the device the entity belongs to, which is the natural title for a
card listing that device’s entities:
decluttering_templates:
device_card:
card:
type: entities
title: '[[entity|device]]'
entities:
- '[[entity]]'
- '[[other]]'
With entity: sensor.sun_next_rising and other: sensor.sun_next_setting the card is
titled Sun, the device both sensors belong to, and the rows keep their own names.
device_id is for a link. Home Assistant’s page for a device is at
/config/devices/device/<id>, so a tile can open it:
decluttering_templates:
device_link:
card:
type: tile
entity: '[[entity]]'
icon: mdi:cog
tap_action:
action: navigate
navigation_path: '/config/devices/device/[[entity|device_id]]'
With entity: sensor.sun_next_rising the path is
/config/devices/device/6f6df03cc7e404eb4b621e6f0a66cb6f, the Sun device’s own page.
domain, object_id and labels (v1.7.0+)

domain and object_id split an entity id without any string handling:
[[entity|domain]] on light.kitchen_ceiling is light, and [[entity|object_id]] is
kitchen_ceiling. Both chain like any other step, so [[entity|object_id|upper]] reads
KITCHEN_CEILING, and [[entity|object_id|replace:_: |title]] reads “Kitchen Ceiling” —
title on its own capitalises the first letter and leaves the underscores where they are.
Anything that is not an entity id — a bare word, an empty value — resolves to nothing, and
the placeholder is left alone rather than filled with rubbish.
labels gives the labels on the entity itself, comma separated and in the order Home
Assistant lists them. Labels put on its device are not included, so label the entity when a
template is going to read them. An entity with no labels of its own resolves to nothing, so
pair it with a default when it is going on a card:
card:
type: markdown
content: '[[entity|object_id|title]] — [[entity|labels|default:unlabelled]]'
These chain with the transforms above and run in the order written, so
[[entity|friendly_name|slug]] is the entity’s name slugged. The value a resolver reads is
an entity id, so it has to come first: [[entity|slug|friendly_name]] would slug the id
and then go looking for an entity by that name.
The entity’s state is deliberately not here. A card’s configuration is built once, so resolving state would mean rebuilding the whole card every time anything changed. What is here comes from the registry, which changes about as often as the dashboard does — and a template that uses it is rebuilt when it does, so a name that was not known yet when the page first painted still turns up. The one way to read a state is to name the entity in
rebuild_on(v2.0.0+).
When Home Assistant has nothing to give — an entity that does not exist, an attribute it does not carry, no area on it — the placeholder is left in the card and the browser console says which and why.
icon, manufacturer, model, area_icon, floor_icon and device_class (v2.0.0+)
More of what people write into templates by hand comes straight from the registry: the icon an entity shows, what its device is, the icon of the room or floor it is in, and what kind of sensor it is.
decluttering_templates:
room_tile:
card:
type: tile
entity: '[[entity]]'
icon: '[[entity|area_icon|default:mdi:home]]'
name: '[[entity|manufacturer]] [[entity|model]]'

icon is the icon chosen for the entity in Home Assistant, else the one its state carries.
An entity with neither shows its domain’s icon, which is not something to write in, so it
gives the empty string and a default: can stand in. area_icon and floor_icon find the
area the way area does, the entity’s own or else its device’s, and an area or floor with no
icon chosen also gives the empty string. manufacturer and model are the device’s.
device_class reads the state first and the registry after.
An entity Home Assistant does not know, one with no device, or one in no area leaves the placeholder visible like every other resolver here.
icon lets a heading borrow the icon chosen for a helper, with a fallback for one that has
none:
decluttering_templates:
entity_heading:
card:
type: heading
heading: '[[entity|friendly_name]]'
icon: '[[entity|icon|default:mdi:toggle-switch]]'
For input_boolean.guest_mode, given mdi:account-group when it was made, the heading
shows that icon. For light.hallway, which has no icon of its own, icon is the empty
string and the default stands in.
floor_icon does the same for the floor, so a heading for a whole floor is two placeholders
on any entity that lives there:
decluttering_templates:
floor_heading:
card:
type: heading
heading: '[[entity|floor]]'
icon: '[[entity|floor_icon|default:mdi:home]]'
entity: light.kitchen gives Ground floor with mdi:home-floor-g, the icon chosen for
that floor.
device_class names what a sensor measures, which beside area makes a name nobody had to
type:
decluttering_templates:
reading_tile:
card:
type: tile
entity: '[[entity]]'
name: '[[entity|area]] [[entity|device_class]]'
sensor.kitchen_temperature comes out as Kitchen temperature and
sensor.living_room_humidity as Living Room humidity.
Home Assistant’s own words: translate (v2.0.0+)
A template that shows an integration’s name or a weather attribute had to hard-code the
English word. translate asks Home Assistant for its own word, in the language the
dashboard is being shown in:
decluttering_templates:
weather_line:
default:
- key: ui.card.weather.attributes.humidity
card:
type: markdown
content: >-
[[entity|domain|translate]]:
[[key|translate]] [[entity|attr:humidity]] %

From v2.9.0 the card using this lists its weather entity in rebuild_on:, or the humidity
keeps its brackets: attr: reads only what the card follows. See
Attributes follow the same rule.
A value with no dot in it is an integration, light or met, and gives the integration’s
name as Home Assistant’s own interface shows it. A value with a dot is a whole translation
key, such as ui.card.weather.attributes.humidity. Whatever Home Assistant has no
translation for gives the value back exactly as written, never an empty string. A whole
entity id has a dot in it too, so [[entity|translate]] reads it as a translation key and
gives it back unchanged: take the domain first, as above.
Integration names are not always loaded on a dashboard, so the first card that translates asks Home Assistant for them, once per page and language, and the cards that translate are built again when they arrive. Change your language in your profile and they are asked for again in the new one. Like everything else here, the word is the one in use when the card was built.
Following an entity’s state: rebuild_on (v2.0.0+)
A card’s configuration is built once, which is what keeps a dashboard full of these cheap,
and it is why a placeholder cannot simply read a state: the card would have to be rebuilt on
every state change in the house. Some cards do want to change shape with something, a layout
picked from an input_select say, so a card can name the entities it follows:
decluttering_templates:
layout_tile:
default:
- layout: '[[input_select.layout|state]]'
- looks:
compact: []
full:
- type: light-brightness
card:
type: tile
entity: '[[light]]'
name: '[[light|friendly_name]] ([[layout]])'
features: '[[looks.[[layout]]]]'
type: custom:decluttering-card-plus
template: layout_tile
rebuild_on: input_select.layout
variables:
- light: light.kitchen

Pick full and the card builds itself again with the slider; pick compact and it goes.
rebuild_on: takes one entity or a list. The card builds again whenever the state of one
of them changes, and only then: every other entity is ignored, and so are their attributes,
unless the template reads one with attr: (v2.9.0+). A burst of changes waits a quarter of
a second and builds once. (v2.10.0+) A build that comes out the same as the last one keeps
the card inside as it is, rather than making it again, so a camera card is not reconnected
when nothing it shows has changed.
|state reads the state of those entities and no others, and from v2.9.0 so do |attr:,
|last_changed and |last_updated. The placeholder can name a variable holding the entity
id, [[layout_entity|state]], or the entity itself, [[input_select.layout|state]], which
stands for itself unless a variable has that name.
For any entity the card does not list, |state keeps its brackets and the console says it
has to be in rebuild_on. A default: after it does not cover that up on purpose: a state
read once and never again would be worse than a placeholder you can see.
This is opt-in on purpose. A card without rebuild_on behaves exactly as it always has, and
a card with it says in its own configuration exactly what it reacts to. The card editor’s
Result preview reads the listed states too, and the editors do not call a listed entity an
unset variable. Anything in rebuild_on that is not an entity id is never followed, and the
console says so.
Attributes follow the same rule (v2.9.0+)
Until v2.9.0, |attr: read an attribute of any entity, once, when the card was built, and
never again. An attribute is as live as a state, so it now works the way |state does:
[[entity|attr:brightness]] reads the attribute only of an entity the card lists in
rebuild_on, and a card whose template reads an attribute builds again when an attribute of
a listed entity changes, not only its state. A card that reads no attribute still ignores
attribute changes, so a busy media player costs nothing to cards that only want its state.
This changes cards that work today. From v2.9.0, a card using attr: on an entity it
does not list shows the placeholder’s brackets, and the console says the entity has to be in
rebuild_on. When the placeholder names the entity itself, the card editor points at the
field too, under Advanced. The fix is a line on the card naming the entity it reads, here
sun.sun beside the sensor the card already followed:
type: custom:decluttering-card-plus
template: sun_times
rebuild_on:
- sensor.sun_next_setting
- sun.sun
variables:
- setting: sensor.sun_next_setting
An entity listed there can be named straight in the placeholder, the way |state allows:
[[sun.sun|attr:next_rising]]. Listing it is also what keeps the value true: before
v2.9.0 an attribute was read once and went stale until the card happened to be built again.
What it looks like, and the other ways brackets turn up, is under Troubleshooting.
Placeholders in rebuild_on, and rebuild_on on the template (v2.10.0+)
A template that reads [[blind|attr:current_position]] already knows which entity it needs.
It can say so once, on the template, instead of every card using it listing the entity by
hand:
decluttering_templates:
blind_tile:
rebuild_on: '[[blind]]'
card:
type: tile
entity: '[[blind]]'
name: '[[blind|friendly_name]], [[blind|attr:current_position]]% open'
type: custom:decluttering-card-plus
template: blind_tile
variables:
- blind: cover.dcp_store_cover
The card reads Blind, 60% open, and when the blind moves to 40 it builds again and reads Blind, 40% open, though the card itself lists nothing.
A placeholder in rebuild_on is filled from the card’s variables, its template’s defaults
and the dashboard’s, like anything else the card builds, but never from a state: |state and
|attr: find nothing there, so an entry using them is dropped. What a card may read is
decided by this list, and a state cannot be allowed to widen it. A variable holding a list of
entities gives each of them, and one left empty names nothing and is not a mistake. A
placeholder that fills to something other than an entity id is not followed, and the console
says so, as it does for any other entry.
The template’s rebuild_on and the card’s are added together, so a card can still list an
entity of its own beside the ones the template names. A card that repeats with for_each
fills these placeholders once, with the card’s own variables, not each copy’s, so an entity
that differs from copy to copy still has to be listed by id.
Watching only what the card reads: rebuild_on_watch (v2.10.0+)
A card whose template reads an attribute builds again whenever any attribute of a listed
entity changes, including ones it never reads. sun.sun moves its elevation and azimuth
every few minutes, so a card showing only the time of sunset builds every few minutes for
nothing. A camera refreshes its access_token about every five minutes, and a card reading
its name with attr: builds that often. rebuild_on_watch narrows what counts as a change:
decluttering_templates:
sunset_tile:
card:
type: tile
entity: sun.sun
name: 'Sunset at [[sun.sun|attr:next_setting|format:HH:mm]]'
type: custom:decluttering-card-plus
template: sunset_tile
rebuild_on: sun.sun
rebuild_on_watch: read
read compares only the state and the attributes the template reads with attr:, here
next_setting, and last_updated as well when it reads |last_updated. The card above
reads Sunset at 16:13 and builds again when the sun rises or sets, or when next_setting
moves, and not when only the elevation does. A template that names an attribute through a
placeholder, |attr:[[which]], cannot be read ahead of the build, so read on it compares
everything, as if nothing had been said.
To name the parts yourself, write the entry as a mapping with watch::
type: custom:decluttering-card-plus
template: sunset_tile
rebuild_on:
- entity: sun.sun
watch: [state, next_setting]
The list can hold state, last_changed, last_updated and attribute names, and only what
it names counts. With watch: [state] the card builds again when the state changes and
ignores every attribute, so an attribute it shows stays as it was until the state moves. The
entity can be a placeholder, {entity: '[[blind]]', watch: read}, on a card or a template.
An entry’s own watch: beats the card’s rebuild_on_watch, and the card’s beats the
template’s. all says compare everything, which a card can use to undo its template’s
read. An entity named twice, say by the card with watch: [state] and by the template with
nothing, watches the wider of the two. Plain entity ids on a card and template that say
nothing compare exactly as before. In the card editor this is What counts as a change,
under Advanced.
Times: relative, format: and age (v2.9.0+)
Home Assistant keeps a lot of times: when a state last changed, a sensor whose state is a
date, an attribute such as next_rising. Written out as they are,
2026-11-07T16:17:14+00:00 is not something to put on a card. Three steps read a time and
write it the way a person would:
| Step | Gives | For 2026-11-07T16:17:14+00:00 |
|---|---|---|
relative |
How long ago, or how long until, in the viewer’s language | in 10 hours; vor 18 Minuten in German |
format:<pattern> |
The time written to a pattern | format:HH:mm gives 16:17; format:dddd D MMMM gives Saturday 7 November |
age / age:<unit> |
How long ago, as a real number: in seconds, or minutes, hours, days or weeks |
age:hours gives -9.9, since it has not happened yet |
Two more steps read the times Home Assistant keeps on every entity, for an entity the card
lists in rebuild_on, like |state:
| Step | Gives |
|---|---|
last_changed |
When its state last changed |
last_updated |
When its state or one of its attributes last changed |
decluttering_templates:
sun_times:
card:
type: markdown
content: |-
**Sunset** [[setting|state|relative]], at [[setting|state|format:HH:mm]] on [[setting|state|format:dddd D MMMM]]
**Next sunrise** [[sun.sun|attr:next_rising|format:h:mm a]]
**The sun went [[sun.sun|state|replace:_: ]]** [[sun.sun|last_changed|relative]] ([[sun.sun|last_changed|age:hours|round:1]] hours)
type: custom:decluttering-card-plus
template: sun_times
rebuild_on:
- sensor.sun_next_setting
- sun.sun
variables:
- setting: sensor.sun_next_setting

A time is read from an ISO date, 2026-11-07 or with a time after it, or from a number of
seconds since 1970 (milliseconds work too, told apart by size). Anything else, such as a
state of unknown, is left as it was and the console says the step wanted a date.
The letters format: knows are YYYY YY MMMM MMM MM M DD D dddd ddd HH H
hh h mm m ss s, and A or a for AM or am. Month and day names are in the
viewer’s language, and the time is in the browser’s own time zone. Anything else in the
pattern is written as it is, but because the letters above are read wherever they appear,
words belong outside the step: at [[t|format:HH:mm]], not format:at HH:mm, which would
turn the a into am. A format: with nothing after the colon leaves the time as it was.
age is a number, so the number steps go on from it, age:hours|round:1 above. A time
still to come gives a negative age. An age: unit it does not know, such as age:fortnights,
leaves the value as it was.
The words do not tick. A card is built once, so “11 hours ago” stays that until the card
builds again, which happens when the state of an entity in its rebuild_on changes. Reading
a time from an entity that changes often keeps it close; a card with relative or age and
nothing in rebuild_on gets a note in the console saying its words will not keep up.
Standing in for what nothing set: |default: (v1.2.0+)
A placeholder can say what to do when nothing gives it a value, rather than rendering its own brackets:
name: '[[name|default:Unnamed]]' # this text instead
name: '[[name|or:label]]' # try another variable
name: '[[name|or:label|default:Unnamed]]' # try, then give up gracefully
default: supplies the text itself. or: names another variable to try. Both chain with
each other and with the transforms, so the last word is always something:
# The name you passed, or the entity's own name, or the word Unnamed - titled either way.
name: '[[name|or:entity|friendly_name|default:Unnamed|title]]'
A gap is unset, null, or an empty string. A 0 and a false are values and keep
their place — [[count|default:none]] with count: 0 gives 0, not none.
A stand-in also rescues a resolver that found nothing, which is the tidiest way to handle an entity that is not in an area:
content: 'In [[entity|area|default:no area]]'
When the placeholder is the whole value, or: can stand in with a mapping or a list (v2.6.0+): the one it names goes in whole, as if the card had set it. Inside longer text it supplies words only, so a mapping or list there is not used; reach for json if that is what you want.
default:
- standard_size: { columns: 6, rows: 2 }
card:
type: tile
entity: '[[entity]]'
grid_options: '[[size|or:standard_size]]' # the card's size, or the standard one
or: takes a variable name, not text, so words of your own belong in a default:. The name
can be dotted, to borrow one key of a mapping: [[name|or:room.label]]. Put or: first and
default: last: a default: with text in it always fills the gap, so an or: after it never
gets a turn. none is text, not a gap.
An empty default: is still a gap (v1.13.0+). With the ? marker the option goes, the
same as when an or: finds nothing:
name: '[[name|default:?]]' # no name passed: the key is taken out
name: '[[name|or:label?]]' # neither set: the key is taken out
How this differs from ?
They answer different questions. [[name?]] removes the key from the card entirely, which
is right for an option that should not be there at all. default: puts something in its
place, which is right when the card should still show something.
Putting a mapping in on purpose (v1.2.0+)
Every transform shapes text and refuses anything else, so a variable holding a mapping or a
list normally cannot go through one at all. json is the exception — it is the one step
that takes the value as it is:
default:
- tap: { action: toggle }
card:
type: markdown
content: 'Tapping does `[[tap|json]]`' # Tapping does {"action":"toggle"}
Without it, [[tap|upper]] is left visible and
says why in the console — uppercasing a
mapping’s JSON would only garble its keys.
As written, or as YAML: raw and yaml (v2.9.0+)
json gives a mapping as one line of JSON. Two more steps write a value out for a person to
read, which is mostly for a markdown card or a message that shows what a template was given:
yamlwrites the value as YAML, the way a dashboard is written: a mapping or a list as its lines, text as itself. Placeholders inside the value are filled in first.rawwrites the value exactly as it was set, before its own placeholders were filled in. A mapping or a list comes out as its JSON.
decluttering_templates:
camera_info:
default:
- cam_name: porch
- camera_entity: camera.[[cam_name]]
- tap:
action: more-info
entity: '[[camera_entity]]'
card:
type: markdown
content: |-
camera_entity is written as `[[camera_entity|raw]]` and works out to `[[camera_entity]]`.
The tap action, as YAML:
```yaml
[[tap|yaml]]
```
![A markdown card: camera_entity is written as camera.[[cam_name]] and works out to camera.porch, then the tap action as two lines of YAML](/decluttering-card-plus/images/v290-raw-yaml.png)
raw is not the same as [[!camera_entity]]. The ! writes the placeholder itself,
brackets and all, and never looks at the value; raw looks the value up and writes it
unfilled, so the brackets it shows are the ones inside the value. What raw gives is never
filled in later either, so the brackets reach the card as they are.
Like json, both read the variable’s own value, so they only work as the first step:
[[name|raw]] and [[name|yaml]], never [[name|upper|raw]]. Anywhere else the
placeholder is left as written and the console says why. Steps after them work on the text
they give. An unset variable has nothing to write out, so the placeholder stays, or a
default: after it stands in.
What a choose selector picked: .chosen (v2.6.0+)
Home Assistant’s choose selector offers a set of alternatives and keeps whatever was filled in for each, along with which one is picked:
variables:
- name: dims
selector:
choose:
choices:
Dimensions: { selector: { object: {} } }
Ratio: { selector: { text: {} } }
# a card then holds
# dims: { active_choice: Ratio, Dimensions: { width: 4, height: 3 }, Ratio: '16:9' }
[[dims.chosen]] is the value of the picked one, here 16:9, so the template does not have to spell out each choice. Nothing is added when active_choice names a key that is not there, and a real key called chosen wins. It is a dotted name like any other, so it works in if:, or: and the rest.
To put a different block in for each choice, gate the picked value with if: and let or: stand in with the other, each dropping out with ? when nothing was entered:
default:
- ratio_block: '[[ratio_dim_block|if:dims.active_choice=Ratio|if:dims.Ratio?]]'
- ratio_dim_block: { aspect_ratio: '[[dims.Ratio]]' }
card:
type: custom:advanced-camera-card
cameras:
- camera_entity: '[[camera]]'
dimensions: '[[dims.chosen|if:dims.active_choice=Dimensions|or:ratio_block?]]'
With Dimensions picked, dimensions is the mapping entered for it. With Ratio picked, it is ratio_dim_block with the ratio in it. With nothing entered for the picked one, the key goes. An empty {} counts as nothing here, because of the ?.
Switching an option on and off: bool (v1.12.0+)
Some card options want a real true or false, and a word will not do: a card reads the
text "false" as switched on, because it is not empty. bool turns a variable into a yes
or a no:
decluttering_templates:
quiet_tile:
card:
type: tile
entity: '[[light]]'
hide_state: '[[compact|bool]]'
- type: custom:decluttering-card-plus
template: quiet_tile
variables:
- light: light.living_room
- compact: 'yes'
- type: custom:decluttering-card-plus
template: quiet_tile
variables:
- light: light.kitchen

The kitchen card never mentions compact, and that is a no too: bool has an answer for a
variable nothing sets, so it counts as a stand-in the way default: does, and the
placeholder is never left showing.
| Reads as no | Reads as yes |
|---|---|
unset, null, false, 0, the empty string |
anything else |
the words false, no, off, 0 in any case, spaces ignored |
yes, on, true, 1, light.kitchen, … |
| an empty list or mapping | a list or mapping with something in it |
Only a whole value at the end of the chain becomes a real boolean. Inside a longer string
bool writes the words true or false, and steps after it shape that word, so
[[compact|bool|map:true=on,false=off]] works. Placed first it reads the raw value, which
is why it accepts a list or a mapping as json does.
A variable the template can do without (v1.1.0+)
A placeholder written [[name?]] is one the card can manage without. When nothing gives it
a value, the option it stands for is taken out of the card altogether rather than left
showing the brackets:
decluttering_templates:
room_tile:
card:
type: tile
entity: '[[entity]]'
name: '[[name?]]'
Pass a name and the tile uses it. Leave it out and the tile has no name key at all, so
Home Assistant falls back to the entity’s own name — usually what you wanted.
Empty means unset, null, or the empty string. A 0 and a false are values and stay.
Inside a longer piece of text it simply leaves quietly, and an item of a list that is
nothing but an empty option is dropped rather than leaving a hole. It is not a mistake, so
nothing is said about it in the console.
The marker goes at the end, after any transform: [[room|slug?]]. That holds for a
transform that takes an argument too — a ? written against the closing brackets is the
marker, not the last character of the argument.
A block left empty goes too (v1.12.0+)
Taking an option out can leave the block it was in with nothing in it. That block goes as well, and so on upward, so a whole section of a card can hang on one variable:
decluttering_templates:
light_tile:
card:
type: tile
entity: '[[light]]'
features:
- type: '[[control?]]'
Pass control: toggle and the tile gets its toggle. Leave it out and type goes, which
leaves the list item empty, so the item goes, which leaves features empty, so features
goes too. Before, the card got features: [{}].

Only blocks that an optional placeholder emptied are removed:
- A block written empty in the template,
[]or{}, never had an option in it and stays as written. - A block with anything else left in it stays, minus the option.
- Text emptied inside a longer string (
/[[path?]]gives/) is still a value, so its block stays. - The card itself is never removed, however little is left of it.
Keeping a value only while another variable says so: if: (v1.12.0+)
if: makes one variable depend on another. The value is kept only while the condition
holds:
| Written | Keeps the value while |
|---|---|
[[name|if:other]] |
other is a yes, read the way bool reads it |
[[name|if:other=text]] |
other is exactly that text |
[[name|if:!other]] (v2.0.0+) |
other is a no, or not set |
[[name|if:other!=text]] (v2.0.0+) |
other is anything but that text, an unset other included |
When the condition fails, the value is treated as though nothing had set it. That means
? drops it, and a default: or or: after it still gets its turn:
decluttering_templates:
room_tile:
default:
- toggle: { type: toggle }
card:
type: tile
entity: '[[light]]'
color: '[[colour|if:mode=night|default:amber]]'
features:
- '[[toggle|if:controls?]]'
- type: custom:decluttering-card-plus
template: room_tile
variables:
- light: light.living_room
- controls: 'yes'
- mode: night
- colour: indigo
- type: custom:decluttering-card-plus
template: room_tile
variables:
- light: light.kitchen
- mode: day
- colour: indigo

Both cards pass colour: indigo, but only the living room is in night mode, so the
kitchen falls through to amber. Only the living room asks for controls, so the kitchen’s
list item goes, and with it features (see above).
if: decides whether there is a value, it does not reshape it, so unlike the text
transforms it lets a mapping or a list through whole. That is what makes it useful for
whole list items like the toggle above. Several conditions in one chain must all hold, and
where they sit in it makes no difference.
The variable a condition reads can be dotted, if:room.night, and is read as it will end
up, so a let: value built from other variables is worked out first. if:name=text compares
as text, so if:floors=2 holds for floors: 2 whether the 2 was written as a number or as
text. Without ? or a stand-in, a failed condition leaves
the placeholder visible, and the console says it was the condition, since the variable
itself is set.
Turned round, and three more questions: exists, contains: and find: (v2.0.0+)
if: can be turned round with a !, as in the last two rows of the table above.
[[toggle|if:!compact?]] keeps the toggle unless the card asks to be compact, and
[[colour|if:mode!=off|default:grey]] keeps the colour in every mode but off.
Three more steps ask a question about a value:
| Step | Asks | Gives |
|---|---|---|
exists |
Whether Home Assistant knows the entity the value names | true or false |
contains:text |
Whether the text is in the value. For a list, whether one of its items is exactly that | true or false |
find:text |
Where the text starts in the value, counting from 0 | a number, -1 when it is not there |
exists and contains: work like bool: as the whole value they put a real true or
false in the card, and a variable nothing sets is a no. exists counts an entity Home
Assistant has a state for or has in its entity registry, so a disabled entity still exists.
Before Home Assistant has arrived it has nothing to ask, so a set value leaves the
placeholder until it does. find: as the whole value is a real
number. The most useful pairing is exists in a let: with if: reading it, which leaves out
a sensor some rooms do not have:
decluttering_templates:
room_entities:
let:
has_motion: '[[motion|exists]]'
card:
type: entities
title: '[[light|friendly_name]]'
entities:
- '[[light]]'
- '[[motion|if:has_motion?]]'
- type: custom:decluttering-card-plus
template: room_entities
variables:
- light: light.hallway
- motion: binary_sensor.hallway_motion
- type: custom:decluttering-card-plus
template: room_entities
variables:
- light: light.bedroom
- motion: binary_sensor.bedroom_motion # no such sensor

find: is for text that holds several things, such as the zones a camera watches written
garden,driveway,porch. It gives where a zone starts in that text, or -1 when it is not
there, and a map: turns that into an icon. The zone to look for is another variable,
filled in before find: runs:
decluttering_templates:
zone_tile:
card:
type: tile
entity: '[[sensor]]'
name: '[[zone|title]]'
icon: 'mdi:[[zones|find:[[zone]]|map:-1=cctv-off,*=cctv]]'
- type: custom:decluttering-card-plus
template: zone_tile
variables:
- sensor: binary_sensor.hallway_motion
- zones: garden,driveway,porch
- zone: driveway
- type: custom:decluttering-card-plus
template: zone_tile
variables:
- sensor: binary_sensor.hallway_motion
- zones: garden,driveway,porch
- zone: garage

find:driveway is 7 and find:garage is -1. find:garden would be 0, the very start,
which is why the test is for -1 rather than for a yes or no. When yes or no is all that is
wanted, contains: says it directly.
Keeping an entity only while it exists: if_exists (v2.5.0+)
if_exists folds the let: and the if: above into one step. It keeps an entity id while
Home Assistant knows it and makes the value missing otherwise, so ? drops it and
default: or or: can stand in. Because a step’s argument can now hold a placeholder, the
id can be built in the same placeholder:
decluttering_templates:
room_sensors:
default:
- kind: motion
card:
type: entities
title: '[[room]]'
entities:
- 'light.[[room|lower]]'
- '[[room|lower|prefix:binary_sensor.|suffix:_[[kind]]|if_exists?]]'
- type: custom:decluttering-card-plus
template: room_sensors
variables:
- room: Hallway
- type: custom:decluttering-card-plus
template: room_sensors
variables:
- room: Bedroom # there is no binary_sensor.bedroom_motion

Without the ? the placeholder stays on the card and the console names the entity id it
looked for. Before Home Assistant has arrived there is nothing to ask, so the card is built
again once it has.
contains: on text looks for a piece of it, so [[name|contains:door]] is a yes for
Outdoor Lights. On a list it wants a whole item: [[tags|contains:Garden]] is a yes for
[Outdoor, Garden] and contains:Gar is a no. Put split in front to ask the same of
comma-separated text, [[entity|labels|split|contains:Outdoor]]. There are no pattern
steps: a step’s argument cannot hold | or ], and a pattern from a shared template could
hang the browser. (From issue #210.)
unless: and switch: (v2.9.0+)
unless: is if: the other way round, written so that it reads as it is meant:
[[name|unless:compact]] keeps the name unless compact is a yes, and
[[name|unless:mode=away]] keeps it in every mode but away. It takes everything if:
does, the ! included (unless:!compact is if:compact), and when it does not hold the
value is missing in the same way, so ? drops it and default: or or: stand in.
switch: picks one value by what the input is, in one step instead of a map: or a row of
if:s. Each match=value pair is an arm, and default= catches everything no arm names:
decluttering_templates:
contact_tile:
card:
type: tile
entity: '[[sensor]]'
name: '[[name|unless:compact?]]'
icon: '[[sensor|state|switch:on=mdi:alert-circle,default=mdi:check-circle]]'
- type: custom:decluttering-card-plus
template: contact_tile
rebuild_on: binary_sensor.front_door
variables:
- sensor: binary_sensor.front_door
- name: Front door
- type: custom:decluttering-card-plus
template: contact_tile
rebuild_on: binary_sensor.hallway_motion
variables:
- sensor: binary_sensor.hallway_motion
- name: Hall
- compact: true

The front door is off, so it falls through to the tick. The hall card asks to be compact,
so its name goes and the tile shows the sensor’s own name instead.
The arms match the value exactly, as text, and are split at commas, so neither side can hold
a comma, and the part before the first = cannot hold one either. *= works as default=
does, so a map: can be renamed switch: without rewriting it. With no arm matching and no
default=, the value is missing: a |default: or or: after it still has its say, and
without one the placeholder stays on the card, like a map: with no match.
Building list entries: with: and repeat: (v2.3.0+)
Every other step writes one value. with: and repeat: fill in a whole block of
configuration from a variable that holds a mapping, or from an
item template: with: once,
with the values you give it, and repeat: once per item of a list, the copies spliced into
the list the placeholder stands in.
decluttering_templates:
room_lights:
default:
- row:
entity: '[[entity]]'
name: '[[name?]]'
secondary_info: last-changed
card:
type: entities
entities:
- '[[row|with:entity=light.kitchen_ceiling,name=Ceiling]]'
- '[[row|repeat:lights]]'
type: custom:decluttering-card-plus
template: room_lights
variables:
- lights:
- entity: light.kitchen_spots
- entity: light.kitchen_pendant
name: Pendant
The entities card gets three rows: the ceiling light, then one row per item of lights.
Each copy is filled from its item’s keys, plus index, index0, count, first and
last; a plain item such as light.kitchen_spots is given as item, and as entity too
when it is an entity id.
Either must be the only step in its placeholder, and ? can follow it. A bare
[[row]] puts the block in with only the card’s own values; [[row|with:]] fills it with
nothing extra but does use an item template’s default: list. How the values inside a fill
rank is on Placeholder Reference, and the whole story,
with registry sources for repeat:, is on List Entries.
Which template is building: __template_name__ and its family (v2.9.0+)
Every build is handed four values about where it is, so a message or a title can say which template made it without writing the name in by hand:
| Name | Holds |
|---|---|
__template_name__ |
The template being built: the one the card names, whatever it extends |
__parent_template_name__ |
The template whose card holds this one, for a template card inside another; empty at the top |
__root_template_name__ |
The outermost template; the same as __template_name__ at the top |
__template_path__ |
A list of the templates, from the outermost down to this one |
decluttering_templates:
room_panel:
card:
type: vertical-stack
cards:
- type: markdown
content: 'This is **[[__template_name__]]**, the outermost: [[__root_template_name__]]'
- type: custom:decluttering-card-plus
template: room_line
room_line:
card:
type: markdown
content: 'This is **[[__template_name__]]**, inside [[__parent_template_name__]]. Path: [[__template_path__|join: > ]]'

__template_path__ is a real list, so join, count, first and last work on it. Inside
text without a step it is written as its JSON, ["room_panel","room_line"]. A variable you
set with one of these names wins, as a variable named like an entity does.
A fifth name, __alerts__, holds the template’s failed checks. It is on
Checks and Strict.
Writing [[ and meaning it (v1.1.0+)
A placeholder written [[!name]] is not a variable: it renders as the literal text
[[name]]. That is the only way to put those brackets in a template — worth knowing if
yours holds markdown, or Jinja that uses them.
card:
type: markdown
content: 'Write [[!entity]] to use a variable.'
The bang is dropped only once every other substitution is done, so an escaped placeholder
can never be turned back into a real one. The editors know about it too, and will not tell
you that [[!entity]] is a variable you forgot to set.
Value types
How a value is substituted depends on where the placeholder sits.
The placeholder is the entire value
The type is preserved. Numbers stay numbers, booleans stay booleans, and mappings and lists are inserted as structure.
decluttering_templates:
sized_tile:
card:
type: tile
entity: '[[entity]]'
name: '[[name]]'
grid_options:
columns: '[[cols]]' # whole value
rows: 1
variables:
- cols: 12 # inserted as the number 12, not "12"

This matters: columns: "12" would be a string and Home Assistant would ignore it.
The type is the one the value was given with, not the one it looks like. cols: '12',
quoted, is text, and a whole-value placeholder puts in the text "12". Write numbers
unquoted when they are meant as numbers.
The same applies to structures:
card:
type: tile
entity: '[[entity]]'
features: '[[features]]'
variables:
- features:
- type: toggle
- type: light-brightness
and to booleans and null:
variables:
- show_name: true
- icon: null
The placeholder is part of a longer string
The value is inserted as text.
name: '[[room]] light'
With room: Kitchen this becomes Kitchen light. A mapping or list used this way is
inserted as its JSON text, which is occasionally useful and usually not what you want. A
null inside text is written as the word null, so '[[room]] light' with room: null
gives null light: use [[room?]] or a default: when the value may be missing.
Steps turn the value into text
Once a placeholder has steps, what comes out is text, even as the whole value. That is
right for slug or friendly_name, but it catches out default: and or:: with
cols: 12, '[[cols|default:4]]' gives the text "12", and '[[show|default:false]]' gives
the text "true" or "false", which a card reads as switched on.
When the value has to stay a number or a boolean, leave the step off and put the fallback in
the template’s default: list instead. A plain [[cols]] keeps its type whichever place the
value came from:
decluttering_templates:
sized_tile:
default:
- cols: 6 # a real number when the card passes nothing
card:
type: tile
entity: '[[entity]]'
grid_options:
columns: '[[cols]]'
A few steps do give a real value as the whole value: bool, exists and contains: give
true or false; the sums (except pad), count, find: and age (v2.9.0+) give a
number; split gives a list; with: and repeat: give the block they fill in; and a chain
of nothing but if: passes the value through untouched. The full table is on
Placeholder Reference.
Awkward characters are handled
Values containing quotes, backslashes, newlines or tabs are escaped correctly. So multi-line values and Jinja templates work:
variables:
- message: >-
Line one
Line two
- jinja: "{{ states('sensor.x') | float * 2 }}"
Values containing $& or $1 are inserted literally rather than being interpreted as
replacement patterns, and variable names containing regex characters are matched
literally too.
Unresolved placeholders
If a placeholder has no matching variable and no default, it is left in place. You will
see the literal text [[light]] in the rendered card, or Home Assistant complaining about
an unknown entity called [[light]].
That is the number one symptom of a typo in a variable name. See Troubleshooting.
The card says so in the browser console (v1.1.0+), naming the template and every variable still standing:
decluttering-card-plus: template "room_tile" uses [[light]], which nothing gives a value
to, so it is rendered as written. Set it on the card, or give it a default in the
template. To write those brackets on purpose, escape it as [[!light]].
An escaped [[!light]] and an optional [[light?]] are not mistakes, so neither is
reported.
You will also see this in the visual editor while editing a template — the card editor there is looking at the raw template, so it reports
[[light]]as an unknown entity. That is expected and harmless.
Reference
Every step, with an example, the release it arrived in and what it does with an empty value, is listed on Placeholder Reference. That page is the one to keep open while writing a template; this one explains why you would reach for each step.
| Looking for | Steps | On Placeholder Reference |
|---|---|---|
How a placeholder is written: ?, !, dotted names |
[[name?]], [[!name]], [[a.b]], [[a.[[b]]]] |
How a placeholder is written |
| Reshaping text | slug upper lower title kebab trim capitalize |
Text |
| Text with an argument | replace: prefix: suffix: max: map: switch: find: |
Text with an argument |
| Lists | join split first last count |
Lists |
| Sums | add: sub: mul: div: mod: round pad: |
Sums |
| Numbers and words in the viewer’s language | plural: format_number |
In the viewer’s language |
| Times | relative format: age |
Times |
| Colours | lighten: darken: alpha: mix: contrast |
Colours |
| Nothing set, and writing a value out | default: or: json raw yaml |
When there is no value |
| Yes or no | bool if: unless: exists if_exists contains: and the _exists steps |
Yes or no |
| Home Assistant | friendly_name area device attr: floor area_id device_id domain object_id labels icon manufacturer model area_icon floor_icon device_class translate state last_changed last_updated |
Asking Home Assistant |
| Whole blocks | with: repeat: slot |
List entries |
| Whether a mapping is repeated entry by entry or asks Home Assistant (v2.10.0+) | entries registry, after repeat: |
List Entries |
| Looking an entry up, and a mapping as a list or back (v2.10.0+) | pick: to_list to_map |
pick:, to_list and to_map |
| Names every build is given | __template_name__ __parent_template_name__ __root_template_name__ __template_path__ __alerts__ |
Names every build is given |
| Text or a real value | — | What comes out |
| Which value wins when several places set a name | — | Which value wins |
| Passes, depth and copy limits | — | Limits |
variables: and default: are read the same way in either shape:
| Shape | Read as |
|---|---|
- light: light.kitchen per line |
one variable per entry |
light: light.kitchen in a mapping |
one variable per key |
| An entry with several keys | one variable per key |
Next
→ Describing Variables to give them labels, pickers and warnings → Repeating a Template to render one template once per item → Cards · Badges · Rows · Elements → Recipes for finished examples