🔹 Auto-entities - Automatically fill cards with entities

I’ve been playing around with this a bit (with the help of ChatGPT, this post and this post) and ended up with this:

[
{% set entities_str = states('sensor.individual_lights') %}
{% set entities = entities_str[1:-1].replace("'", '"').split(', ') %}
{% for e in entities %}
  {
    "type": "custom:decluttering-card",
    "template": "illumination_light-card-single",
    "variables": "{
      '- Light': {{ e.strip('"') }} }",
  },
{% endfor %}
]

the reason for all the code at the beginning is because state_attr('sensor.individual_lights') is None.

the outcome in developer tools Template looks very similar to yours:

But when I put this into my card, auto-entities sees each line as a separate entity.

My Auto entities card
type: custom:auto-entities
filter:
  template: |
    [
    {% set entities_str = states('sensor.individual_lights') %}
    {% set entities = entities_str[1:-1].replace("'", '"').split(', ') %}
    {% for e in entities %}
      {
        "type": "custom:decluttering-card",
        "template": "illumination_light-card-single",
        "variables": "{
          '- Light': {{ e.strip('"') }} }",
      },
    {% endfor %}
    ]
  include: []
  exclude: []
show_empty: false
card:
  type: custom:layout-card
  layout_type: custom:grid-layout

I feel like we’re suuuuper close, but something isn’t working out yet :confused: