Using templates in Lovelace and custom auto-entities card in Home Assistant Container

I am running HA Container 2025.10.1 and trying to use templates in Lovelace. In my raw editor I have a very simple card:

                cards:
                  - type: entities
                    entities:
                      - entity: sun.sun
                      - entity: sensor.sunrise_time
                      - entity: sensor.sunset_time
    

The card renders perfectly happily. This is a test card to just check if template rendering works.

If I change the code to:

                cards:
                  - type: entities
                    entities:
                      - entity: sun.sun
                        name: "{{ 'Test' }}"
                      - entity: sensor.sunrise_time
                      - entity: sensor.sunset_time

I was hoping the text displayed for the sun would turn to Test. Instead it renders as {{ ā€˜Test’ }}

I’m pulling my hair out here trying to understand what’s not working. I’ve searched for hours and can find nothing. Or are Jinja2 templates not allowed in the Lovelace?

Only one stock card - Markdown - accepts jinja templates for ā€œcontentā€ option. There are custom cards which can work with templates.

Thanks. I didn’t realise it was card specific. The one I am trying to use it on the custom auto-entities from HACS (GitHub - thomasloven/lovelace-auto-entities: šŸ”¹Automatically populate the entities-list of lovelace cards) which looks like it should accept this according to the documentation. In that I have:


      - type: custom:auto-entities
        card:
          - type: entities
            title: Zigbee Devices (Last Seen)
        filter:
          include:
            - entity_id: '*last_seen'
              options:
                name: '{{ "Test" }}'
                icon: mdi:zigbee
          exclude:
            - state: unavailable
        sort:
          method: state
          reverse: true

This just renders {{ ā€œTestā€ }} as well.

Templates are only allowed for ā€œfilter::templateā€ option, not where you tried. You will need to build a list in that ā€œtemplateā€ option, check examples in the main a-e thread.

1 Like

Thanks very much for clarifying. My first foray into Jinja2 in HA…

The simplest example:

type: custom:auto-entities
card:
  type: entities
filter:
  template: >-
    {% for entity in states.zone|selectattr('entity_id','search','home') -%}
      {{
        {
          'entity': entity.entity_id,
          'secondary_info': 'last-changed',
          'name': states('sun.sun')
        }
      }},
    {%- endfor %}

which shows one line (define own any filtering criteria).
image

1 Like

Ahhh. That lit the lightbulb in my head. Thanks again!

1 Like