How do Expand Groups for Lovelace Entities Card with Jinja?

I’m trying to create a lovelace entities card with a list of entities derived from a group.

I have looked at ~10 posts in Search results for 'group expand' - Home Assistant Community and I still am stumped. Below is what I’ve tried, based on those posts, but nothing is working. What am I missing?

I’m also aware of some plugins like Lovelace: Group card and

Filter:

type: entities
entities: {{ expand('group.common_area_lights')
| map(attribute='entity_id')
| map("format")
| list()
}}
title: Common Area Lights
show_header_toggle: true

For Loop:

type: entities
entities:
{% for light in expand('group.common_area_lights') -%}
{{ "\n - {}".format(light.entity_id) -}}
{% endfor -%}
title: Common Area Lights
show_header_toggle: true

Using namespaced list

Based on Expand group select attr includes unavailable sensors - #7 by laxarus

type: entities
entities: >-
{% set ns = namespace(entity_list=[]) %}
{% set entity_list = expand('group.common_area_lights') | list %}
{% for entity in entity_list %}
  {% set ns.entity_list = [entity.entity_id] + ns.entity_list %}
{%endfor%}
{{ns.entity_list | join(', ')}}

Using something else

based on Jinja / Template Sensor Question - #20 by RonJ103

type: entities
entities: >
{% set entities = expand('group.common_area_lights') %}
{% for x in entities %}
{%- if not loop.first %}, {% endif -%}
{{- x.entity_id -}}
{% endfor %}
title: Common Area Lights
show_header_toggle: true

Again, none of these worked, so would love a pointer to what I’m missing.

Use the auto-entities custom card

type: custom:auto-entities
card:
  type: entities
  title: Common Area Lights
filter:
  template: |
    {{ expand('group.common_area_lights')| map(attribute='entity_id')| list }}
3 Likes

Core Lovelace cards do not support templates.

You have to use a third party solution as suggested by Didgeridrew above.

k. Thank you for confirming gents!

If you’re going to use auto-entities, it’ll handle groups for you

type: custom:auto-entities
card:
  type: entities
  title: Common Area Lights
filter:
  include:
    - group: group.common_area_lights
4 Likes

Yep, I ended up using auto-entities and it works great.