[SOLVED] Unable to iterate over members of a group

I’m trying to do some fine tuning of my lighting rules and have hit a roadblock that I don’t quite understand.

I’ve created a very simplified version of my rule that demonstrates the problem.

First, here are my items;

Switch KitchenDining_Motion_Sensor "Dining Room Motion Sensor [%s]" <motiondetector> (MotionSensors) {channel="zwave:device:46feb3ec:node35:sensor_binary"}
Dimmer DiningDown_Light "Dining Room Downlights [%d %%]" <light> (KitchenDining_Light) {channel="zwave:device:46feb3ec:node5:switch_dimmer"}
Dimmer KitchenDown_Light "Kitchen Downlights [%d %%]" <light> (KitchenDining_Light) {channel="zwave:device:46feb3ec:node4:switch_dimmer"}
Group:Dimmer:AVG KitchenDining_Light (MotionLights)
Group MotionSensors
Group MotionLights

And here is my rule

rule "Test group iteration"
    Member of MotionSensors received update ON
    val room = triggeringItem.name.split("_").get(0)
    val lightGroup = MotionLights.members.findFirst[ grp | grp.name == room + "_" + "Light" ]
    lightGroup.members.forEach[ light |

What I’m expecting to happen is that when the KitchenDining_Motion_Sensor is triggered, the rule will set lightGroup to be the KitchenDining_Light Dimmer Group and then iterate over its members turning each to ON in its turn.
lightGroup is definitely being set correctly as if I replace my loop with lightGroup.sendCommand(ON) it turns the lights on. (In my real rule I need to set different lights in the group to different levels as the light output differs dramatically between them)
The error that I am getting is;

[ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Test group iteration': 'members' is not a member of 'org.eclipse.smarthome.core.items.GroupItem'; line 7, column 5, length 18

I have seen Groups iterated over like this in other examples so I’m a bit lost as to what I am doing wrong here. Does anyone have any ideas?


val GroupItem light group = ...

You are not giving the Rules DSL enough of a hint to tell it what type you want the result to be so it is probably either choosing Item or just Object and neither of those have a members method.

That worked!

Thanks (yet again)