Template a homeassistant card for an entity

I made a card for an entity.
I would now like to add more of these cards for this type of entity.


Is there a way i can template this so i can just specify "smartplug_n" and it will get voltage, current, power, ... without having to put it there manualy?

With this, yes: GitHub - thomasloven/lovelace-auto-entities: 🔹Automatically populate the entities-list of lovelace cards

As I see , the person needs to re-use the card which is a stack with 2 cards.
For this - use custom:decluttering-card.
Then you will only need to call a template with “smartplug_n”.

Thank’s! could you elaborate?
I extracted the text from the image, since my HA Corrupted and i had no Backup

type: vertical-stack  
cards:
  - type: entities  
    entities:
      - entity: switch.smart_plug_2
        state_color: true  # Enable state color for this entity.
        show_name: false  # Hide the entity name.
        show_icon: true   # Show the entity icon.
        show_state: true  # Show the entity state.

  - type: glance  
    entities:
      - entity: sensor.smart_plug_2_voltage
      - entity: sensor.smart_plug_2_current
      - entity: sensor.smart_plug_2_power
      - entity: sensor.smart_plug_2_energy
      - entity: sensor.smart_plug_2_total_daily_energy
  1. these options does not belong to Entities card:
show_name: false  # Hide the entity name.
        show_icon: true   # Show the entity icon.
        show_state: true  # Show the entity state.

they are a part of the Glance card.

  1. If you wish to create a decluttering template from your stack card:
    template:
my_super_template:
  card:
    type: vertical-stack  
    cards:
      - type: entities  
        entities:
          - entity: switch.[[DEVICE_NAME]]
            ...
    
      - type: glance  
        entities:
          - entity: sensor.[[DEVICE_NAME]]_voltage
          - entity: sensor.[[DEVICE_NAME]]_current
          - entity: sensor.[[DEVICE_NAME]]_power
          ...

using:

type: custom:decluttering-card
template: my_super_template
variables:
  - DEVICE_NAME: smart_plug_2

Check Github for the decluttering card & a dedicated Community thread for docs & examples.

2 Likes