Handling with Groups

hello,
its me again with a question. First let me explain what im trying to do. At the moment iam using the innogy system and binding for a lot of items like doors and windows, temperatur and so on.
Inside innogy are scripts where i can select than when a window is open the temp inside this room should set to a low level. But cause of the problem that innogy(Livisi the new owner) might close their system i want to implement all this stuff in openhab.
Now the rule im trying to make:

rule "Absenkung"
when 
	Member of OSen changed 
then 
	tim = now.toString("HH:mm") + " "
	woFOffen = triggeringItem.groupNames.get(0).toString
	if (triggeringItem.state == OPEN && rweVariablefbfa6f.state == ON) {
		haa.postUpdate(tim + "Raum "+woFOffen+" offen im Winter, Heizung aus")	
		val GroupItem myTemp = woFOffen.members.filter[ i | i.name.contains("Settemp") ]
		if (!myTemp.empty)
    		myTemp.members.forEach(i | i.sendCommand(10.0))
	}
	if (triggeringItem.state == CLOSED && rweVariablefbfa6f.state == ON) {
		haa.postUpdate(tim + "Raum "+woFOffen+" geschlossen, Heizung an")
		val GroupItem myTemp = woFOffen.members.filter[ i | i.name.contains("Settemp") ] 
		if (!myTemp.empty)
    		myTemp.members.forEach(i | i.sendCommand(i.lastState))
	}
end

OSen is the group of all windows
rweVariablefbfa6f.state is ON if its winter
In the first step i try to find out in which room the window was opened. This works fine, but now
the name of this Group (of the room) is in a string. how can i change it to a real Group?
thanks for your help

Thank u it helps me a lot to understand but maybe i am blind or only too old to see. I have the name of a Group in a string val and i want to access the members of this Group. How must i define this in a rule ???

Look at the Image Registry example in the link posted.

Thanks I looked at this example but it doesn’t fir for my needs.Maybe I didn’t explained correctly where my problem is. I made a little test rule:

var String tim = now.toString("HH:mm") + " "

rule "Test1"
when
	Item Test received update
then
	var String woFOffen = "Kueche"
	//var GroupItem x = x.getItem(woFOffen).members as GroupItem
	val myTemp = Kueche.members.filter[ i | i.name.contains("Settemp") ]
	logInfo("Test","Msg="+myTemp+woFOffen)
	if (!myTemp.empty)
    	myTemp.forEach(i | i.sendCommand(22.0))
end
`
This test rule works perfectly. But in the real rule I don't have the name of the group like "Kueche" in the test rule I only have a string called woFOffen which contains the name of the group for ex. "Kueche". But I found no way to access this . I can create a new group with the same name but that's not helpfull. So may I could explain better

Now I’m confused because you said

and now you are saying

Do you have the name or not? If not you need to get the name.

Once you have the name of the Group (i.e. a String with the name of the rule), as shown in the link above

val groupItem = ScriptServiceUtil.getItemRegistry.getItem("Kueche")

will put the actual Group Item in the groupItem variable. So you can then do something like

groupItem.members.forEach[ i | logger.info("Test", "In group " + groupItem.name + " Item  " + i.name + " is " + i.state ]

You are my hero!!! After a little fix u forgot it works now like a charm.
val groupItem = ScriptServiceUtil.getItemRegistry.getItem(“Kueche”) as GroupItem
Thanks a lot and Merry Christmas to u.