Looping through attributes of a sensor with auto-entities

I got this working now:

type: custom:auto-entities
card:
  type: entities
  title: VM/VS v4 template
filter:
  template: |-
    {% set SENSOR = 'sensor.machine' -%}
    {%- for attr in states[SENSOR].attributes['virtual_machines'] -%}
      {{
        {
          'type': 'attribute',
          'entity': SENSOR,
          'attribute': attr,
          'name': attr,
        }
      }},
    {%- endfor %}
sort:
  method: state
  reverse: true

The solution was found at Custom Secondary Info for Entites Card