🔹 Auto-entities - Automatically fill cards with entities

How to define Markdown cards in auto-entities

If a markdown card is used to show a static content:

  - type: custom:auto-entities
    card_param: cards
    card:
      type: vertical-stack
    filter:
      include:
        - entity_id: input_boolean.test_boolean_*         ### define your own mask
          options:
            type: conditional
            conditions:
              - entity: this.entity_id
                state_not: 'off'
            card:
              type: markdown
              content: some content

Note: to make the task a bit more complex, a Conditional card is used here ))).

Same when the content is dynamic (i.e. some jinja templates used) & does NOT depend of the currently processing entity_id:

            ...
            card:
              type: markdown
              content: >-
                {{ .... }}

or when the processed entity_id is NOT a part of a template:

            ...
            card:
              type: markdown
              content: >-
                {{ ... }}
                xxx: this.entity_id
                {{ ... }}

The problem is that that this.entity_id variable is not resolved inside these templates.

If your templates DO depend on the currently processed entity_id (as you have in your case) - then you need to use the template option:

  - type: custom:auto-entities
    card_param: cards
    card:
      type: vertical-stack
    filter:
      template: >-
        {% for entity in states.input_boolean|selectattr('entity_id','search','input_boolean.test_boolean_') -%}
          {%- if (entity.entity_id.split('test_boolean_')[1])|int(0) > 4 -%}
            {%- set CONTENT = 'xx: ' + entity.entity_id -%}
          {%- else -%}
            {%- set CONTENT = 'yy: ' + entity.entity_id -%}
          {%- endif -%}
          {{
            {
              'type': 'conditional',
              'conditions': [
                {
                  'entity': entity.entity_id,
                  'state_not': 'off'
                }
              ],
              'card': {
                'type': 'markdown',
                'content': CONTENT
              }
            }
          }},
        {%- endfor %}

That part simulates a dynamically defined content:

          {%- if .... -%}
            {%- set CONTENT = ... -%}
          {%- else -%}
            {%- set CONTENT = ... -%}
          {%- endif -%}