Grouping items in rules - customer data structures like pojo

I have 9 Eurotronic Spirit Z-Wave valves. Each of them has 5 Channels binded to an Item. This Items are controlled with a cron-rule, based on temperature, time and state of a window. Actually the code in the rule is duplicated for each valve :slight_smile:
Now I would like to iterate through all valves and in the first tries, I’ve created a group for all valves, for each valve another group and for each type of channel (valve-mode, setpoint temperature, actual temperature etc) also a group. The business logic (code for controlling) is realized in lambda and for calling this, I need the items per valve. To get these values, I’ve created nested loops with 3 levels… not really sophisticated.

Maybe I didn’t unterstand the Design Pattern but is there another possibilty for grouping items without GroupItem (static data with members of type Item, own pojo something like that)?

for explaining some sample code:

val Functions$Function3<GenericItem, GenericItem, Boolean, Boolean> someLogic

rule “control valve”

groupAll.forEach |
groupValve.forEach |
groupItemsperValve |
var Number tempActual = Item.getState as Number
var Number valveMode = Item.getState as Number

]
someLogic.apply(tempActual, valveMode …)
]
]

Not :slightly_smiling_face:, :confused:

I recommend reviewing

There is no need to have separate rules. There is probably no need for the lambda. And there is likely no need for the nested loops.

Another approach is to put the static values in a .map file and access them by a key using the transform Action similar to documented in Design Pattern: Human Readable Names in Messages.

thx Rich
The hint with DP Associated Items helps me perfect!