I would like to create an item to hold the last update time of the group. e.g.
DateTime gLivingRoomLights_LastUpdate
I can create a rule that triggers on update of any member of gLivingRoomLights and then record the time into the Last Update time and this works fine. I am trying to extend this to apply to each individual group of lights
I was hoping to do something like this but cant see a way of making it work;
rule "Record Last Update for Light Groups"
when
Member of gLivingRoomLights changed or
Member of gLivingRoomLamps changed or
...
Member of gAtticLights changed or
then
val lastUpdate = ScriptServiceUtil.getItemRegistry.getItem(triggeringItem.name+"_LastUpdate")
sendCommand( lastUpdate, new DateTimeType())
end
but the triggeringItem is naturally the actual item and not the group it was a member of. Is there a way of getting the group name?
Or is there different way of doing this in a generic way that doesn’t need a rule for each group.
Take care that update and changed are two different things in openHAB triggers.
The example rule you’ve shown will only log timestamp on change, and ignore updates-to-same-value.
Profile timestamp-update might appear to have uses here, but a caution that it currently has a bug meaning that you cannot link multiple channels to the same DateTime Item.
So, Groups and Rules it is.
In your rule you can enquire what Groups an Item (the triggeringItem here) is a member of