As far as triggers are concerned, a Group is like any other Item. So all of the triggers supported by an Item will work for a Group. There are no special triggers for a Group.
I know this is written up somewhere in the docs but I couldn’t find it in a quick scan so I’ll point you to Design Pattern: Working with Groups in Rules where I know it is written up.
I’ll augment your description on received update a little: “Will trigger potentially multiple times for any command or update sent to the Group or any of its members.” This is because the aggregation function calculates the new state of the Group incrementally and this causes an update on the Group at each increment.
There is no way to do this with a Group trigger at this time.
There is now a triggeringItem implicit variable (since with 2.2 released) that gets set to the Item that triggered a Rule. But this does not yet work with Groups. But if you list each Item as a Trigger you can make the Rule generic without the need for the persistence hack.
So I would suggest, until such time that triggeringItem is updated to also work with Group triggers (in work I believe) to have the two rules, one triggered by the Group receiving a command to capture that case, and the other with received command triggers for each of the Items listed separately. Inside this Rule you can then use triggeringItem to discover which Item triggered the Rule and drop the Persistence hack to figure out what Item triggered the Rule.
Then I would file a feature request issue to request addition of a way to trigger a Rule using a Group that:
- triggers the Rule once when one of the Group’s members receives a command
- populates triggeringItem with the Item that caused the Rule to trigger, if the Group itself received the command, triggeringItem will be set to the Group Item.
rule "Member pressed"
when
Item member_1 received command or
Item member_2 received command or
Item member_3 received command or
Item member_4 received command
then
logInfo("GroupTest", "Member " + triggeringItem.name + " to " + triggeringItem.state)
end
rule "Group pressed"
when
Item group received command
then
logInfo("GroupTest", "Group received command " + receivedCommand)
end
It isn’t as pretty as it could be, but like I said, work is underway to let us replace the triggers on the first Rule with the Group.