Groups and Appending to template in NodeRed

I currently have a flow which checks the windows around the house are shut and notifies me (on Alexa) if there is one open

This uses a group currently which has all contact sensors in, but problem is that I can’t easily identify which window is open

My assumption is that I need to basically run through each individually and append that info to the template so it can say “X and Y and Z windows are open”

Maybe I’m not going about this the right way (so open to ideas!) but assuming I am I’m struggling with actually making this happen - anyone got any advice on how best to do this?
Thanks

Home Assistant group integration neatly adds a new entity (of the group type) with an array of the group member entities in the attributes.entity_id

Using a current state node, for the group, it only requires a bit of JSONata to pull the friendly names of the entities in the group with state “on” (or whatever your window contacts use).

Example JSONata code

(
    $group:=$entity().attributes.entity_id;
    $names:=$entities().*[entity_id in $group and state="on"].attributes.friendly_name;
    $yes:="The " & $join($names, ", ") & " group plugs are on";
    $no:="No group plugs are currently on";
    $count($names)>0 ? $yes : $no
)

If you don’t have a ‘group entity’ to work from, an example of pulling a list of friendly names from several entities is given in the WebSocket nodes documentation.

https://zachowj.github.io/node-red-contrib-home-assistant-websocket/cookbook/jsonata/call-service.html#notification-of-lights-left-on-when-leaving-home

That’s amazing. Thank you - works perfectly!