Template to pick up Zigbee Groups

I have a bunch of lights that are grouped in Z2M. This means I end up with both the group and individual lights as entities in HA.

I want to template something to allow me to turn off any groups that are on.

Looking at the devices I see that the group are under a device that has Zigbee2MQTT as manufacturer and Group as model but this is at device level (these devices only have a single entity under them.

I can list the groups that are on

    {{ expand(states.light)
    | selectattr('state', 'eq', 'on')
    | map(attribute='entity_id')
    | map('device_id')
    | select('is_device_attr','model','Group')
    | map('device_attr','name')
    | list }}

but this is giving me a list of device names not entities which I think I need for the light.turn_off action?

I can do entities with the following in my automation

metadata: {}
data: {}
target:
  entity_id: >
    {{ expand(states.light) | rejectattr('entity_id', 'in',  ['light.porch',
    'light.porch_downlighter', 'light.porch_wall', 'light.porch_wall_garage']) |
    selectattr('state', 'eq', 'on')  | map(attribute='entity_id')  | list }}
action: light.turn_off

but how can I do this only for the groups I can identify above?

I can just change the automation to device_id and not resolve the name can’t I…
Not sure how I missed that