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).
(
$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.