Skip to content

Using card templates

A card template stores a reusable card configuration. Each card instance supplies the entity and any values that differ.

Define a user template

Add the catalog to your Lovelace dashboard or view configuration:

fhs_user_templates:
  templates:
    room_temperature:
      template:
        type: card
        defaults:
          - name: Temperature
          - min: 0
          - max: 40

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

        layout:
          horseshoes:
            - entity_index: 0
              xpos: 50
              ypos: 50
              radius: 40
              horseshoe_scale:
                min: "[[min]]"
                max: "[[max]]"

          states:
            - entity_index: 0
              xpos: 50
              ypos: 50

Values between [[ and ]] are supplied by the card instance or by the template defaults.

Use the template

1
2
3
4
5
6
7
8
9
type: custom:flex-horseshoe-card

template:
  name: room_temperature
  variables:
    - entity: sensor.living_room_temperature
    - name: Living room
    - min: -10
    - max: 50

The instance only contains values that make this card different.

Reuse color stops

Templates can also store shared color stops:

fhs_user_templates:
  templates:
    temperature_colors:
      template:
        type: color_stops
      color_stops:
        colors:
          -10: "#1565c0"
          0: "#42a5f5"
          20: "#66bb6a"
          30: "#f9a825"
          40: "#d32f2f"

Use them in a tool:

1
2
3
color_stops:
  template:
    name: temperature_colors

Organize system and user templates

Keep distributed templates in fhs_sys_templates and personal templates in fhs_user_templates. Updates can then replace system templates without changing your own catalog.