How to Use a helpers group in a automation or script

Hi, I made in helpers a group with all the lamps of my living room. So if 1 or more lamps are on, then the group is on. If all the lamps are off, then the group is off.

Now I like to use that group status in a script, to detect if all the lamps in my living room are off. But I don’t find a way to do that.
Can somebody point me in the right direction how to do it.
Many thanks

How do you want to display the result of the script?

You can show it as a button on a dashboard by just creating a button with the group entity.

So, I like to test that group status in a script or automation and if all the lights are off => then put a scene of lights on. If there is 1 or more lights on => put all the lights off.

I use the group status on dashboard, that is not the problem.
I like to use it in a script, If that is possible !

OK got you now.

What you need is something like a simple automation.

Trigger on the state of the group changing.

then action choose with
option 1
condition group on and the action you want
option 2
condition group off and the action you want

if you want to press a button to run the script then setup a helper button to to trigger on state change instead of using the group status.

Thanks, it is working.