Skip to content

Template variables

Template variables are values that differ between instances of the same card design.

Define placeholders

Use a descriptive placeholder wherever the template needs a supplied value:

template:
  type: card
  defaults:
    - name: Temperature
    - unit: °C

card:
  entities:
    - entity: "[[entity]]"
      name: "[[name]]"
      unit: "[[unit]]"

A default makes the variable optional for the card instance. A placeholder without a default must be supplied.

Supply values

1
2
3
4
5
template:
  name: room_temperature
  variables:
    - entity: sensor.bedroom_temperature
    - name: Bedroom

The instance uses the default unit and supplies its own entity and name.

Pass lists and configuration blocks

A variable can also contain a list or map:

1
2
3
4
5
6
7
template:
  name: room_overview
  variables:
    - rooms:
        - Living room
        - Bedroom
        - Study

Use variables for meaningful differences between card instances. Keep state-dependent values in JavaScript templates.