Make template cards (so multiple sets of cards can be reused)

I constantly find myself adding basically the same set of cards or entities to something …
For example I have several Xiaomi vacuums… and I want this for each one:
image

… It would be great if I could just set it up 1x then have some parameters that I can change each time I want to use it

… I am thinking that something like this could be done (eg here is a cut down version of my vac pictured above):
You can set a card_templates in the lovelace root (same place you set resources) as follows:

card_templates:
  name: XiaomiVac
  parameters:
    - name: VacSwitchTemplate
    - name: VacEntity
  card:
    entities:
      - entity: '{$ VacSwitchTemplate $}'
        icon: 'mdi:broom'
        name: Clean
      - entity: sensor.none
        icon: 'mdi:trash-can-outline'
        name: Consumables
        primary:
          attribute: main_brush_left
          entity: '{$ VacEntity $}'
          name: Main Brush
          unit: / 300 h
        secondary:
          attribute: side_brush_left
          entity: '{$ VacEntity $}'
          name: Side Brush
          unit: /200 h
        type: 'custom:multiple-entity-row'
      - entity: sensor.none
        icon: ' '
        name: ' '
        primary:
          attribute: filter_left
          entity: '{$ VacEntity $}'
          name: Filter
          unit: / 150 h
        secondary:
          attribute: sensor_dirty_left
          entity: '{$ VacEntity $}'
          name: Sensor Cleaning
          unit: / 30 h
        tertiary:
          attribute: battery_level
          entity: '{$ VacEntity $}'
          name: Battery
          unit: '%'
        type: 'custom:multiple-entity-row'
    head:
      icon: 'mdi:robot-vacuum'
      name: Vacuum
      entity: '{$ VacEntity $}'
    type: 'custom:fold-entity-row'

Then when you want to use it you can just have a card like:

entities:
  - entity: input_number.cleaning_interval
  - entity: custom:card_template
    name: XiaomiVac
    parameters:
      - name: VacSwitchTemplate
        value: switch.living_room_vacuum_state
      - name: VacEntity
        value: vacuum.living_room_vacuum
type: entities

This is already possible, take a look at decluttering-card and/or lovelace gen

1 Like

decluttering-card is perfect thanks :slight_smile: