LastUpdate of Group


I have a large number of Hue lights that are each in a set of groups e.g.

Group                       gLivingRoomLights              "Living Room Lights"      (gLights)
Group:Switch:OR(ON,OFF)     gLivingRoomLightsToggle        "Toggle [(%d)]"     (gLivingRoomLights)
Group:Dimmer                gLivingRoomLightsDimmer        "Dimmer"                          (gLivingRoomLights)
Group:Color                 gLivingRoomLightsColor     "Color"                          (gLivingRoomLights)

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"
  Member of gLivingRoomLights changed or
  Member of gLivingRoomLamps            changed or

  Member of gAtticLights                changed or
  val lastUpdate = ScriptServiceUtil.getItemRegistry.getItem("_LastUpdate")
  sendCommand( lastUpdate, new DateTimeType())

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

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.