Passing groups to multiple entity fields

I have a script field entity type with multiple entities selected. I am passing in two groups (each group contains one or more light entities) into the script field. In the script when I expand the field I get a list of all the lights.

alias: test Automation
description: ""
trigger: []
condition: []
action:
  - service: script.test_script
    data:
      light_groups:
        - group.fr_z1_lights_group
        - group.fr_z2_lights_group
mode: single
alias: test script
sequence:
  - repeat:
      sequence:
        - service: logbook.log
          metadata: {}
          data:
            name: testx for each
            message: "{{ repeat.item }}"
      for_each: "{{ expand(light_groups) | map(attribute='entity_id') | list }}"
fields:
  light_groups:
    selector:
      entity:
        multiple: true
    name: Light groups
    required: true

Log result:

light 1
light 2
light 3...

However, I want a list of the groups not the lights. How do I get a list of the groups?

For anyone looking: I don’t think this is possible. It seems the expand filter can only be recursive, and will always return the group member entities.

I did manage to get the groups by passing in to a field of multiple text types (instead of the entity).