Design Pattern: Working with Groups in Rules

Just updated to 2.3 release, and I’m using the new “Member of” syntax as a trigger.

this seems to work well for groups which are composed solely of Items, however I have found that if a group consists of other groups, then the triggeringItem contains the group that triggered the action, not the item that triggered the action, and only groups that have types associated with them.

This makes the trigger less useful, as you can only trigger on groups of items, and not groups of groups.

for example, if you have groups:

Group All
Group gGF 	        "Ground Floor"  <groundfloor>	(All)
Group GF_Family 	"Family Room" 	<television> 	(gGF)
Group GF_Kitchen  	"Kitchen" 		<kitchen> 	    (gGF)
Group GF_Washroom 	"Washroom" 		<toilet> 	    (gGF)
Group:Number:MAX    Max_Temperature "Max Temperature [%.2f °C]" <temperature> (All)

You could trigger a rule on “GF_Family” (if GF_Family consists of Items), but not on “All” like this:

rule "Test Item Changed"
when
    Member of All changed
then
    logDebug("Test", "Test Item Changed: " + triggeringItem.name)
end

As this gives you the name of the sub group that changed, not the item that triggered the change, and in this case only the group “Max_Temperature” gets reported - presumably as it’s the only group that has a type.

So the output of this rule is always:

Test Item Changed: Max_Temperature

This seems inconsistent, as you can trigger on a group of items that does not have a type, but not on a group that has subgroups that do not have a type. In the above example, you could trigger on “GF_Family”, but not on “gGF”. By requiring subgroups to have a type, this means that all the items in that group would have to be the same type, which in many cases is not realistic.

Just wondering is this intentional for this new trigger? or just an unintended consequence of the way triggers are designed?

Is there documentation somewhere of the behavior of the new “Member of” trigger?

Thanks.