arad85
October 10, 2025, 6:43pm
1
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.
arad85
October 10, 2025, 6:58pm
3
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
arad85
October 10, 2025, 9:41pm
5
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).
1 Like
arad85
October 10, 2025, 11:45pm
7
Ahhh. That lit the lightbulb in my head. Thanks again!
1 Like