[SOLVED] Trigger for changes in nested groups

How can I get a rule triggered when some contacts open that are members of nested groups?

Here is the scenario:

At the root there is one big group that contains everything:

Group gMotionSensors  (All)

and there are two subgroups of motion sensors:

Group gSubgroup1 (gMotionSensors)
Group gSubgroup2 (gMotionSensors)

And finally two (or more!) contacts in each subgroup:

Contact foo  (gSubgroup1) {}
Contact bar (gSubgroup2) {}

The goal is to have a rule run when one of the elements of the subgroups changes.

Experimentation indicates that this will not work:

rule "motion sensor tripped"
    Item gMotionSensors changed

even if the syntax of the gMotionSensors group is changed to:

Group:Contact:OR(OPEN,CLOSED) gMotionSensors   (All)

(a side question, although not central: where is this “reduction syntax” documented, and what does it do exactly?)



You need to use Item gMotionSensors received update, not changed. The problem is that the state of gMotionSensors is a rollup of all the members so it will only change when you go from all CLOSED to one OPEN but each subsequent contact that goes to OPEN will not trigger the rule.

Beware though, there is a “feature” in how the group’s state is calculated that causes multiple updates to be received for each change to a data member. A lot of times this doesn’t matter, especially with motion sensors, but it may in your case.

What little documentation there is for it is here.


Thanks much, this does the trick! I had a look at the code and now understand what you mean with rollup. Noticed the multiple-notifications as well but didn’t know what to make of them. Easy to filter out so no problem.