Item Last Update

Apologies for reviving an old thread, but I found that the above solutions can now be significantly simplified. I think this may be due to the ‘new’ Rule features Member of and triggeringItem available in 2.3.

In a groups.items:

// Apply the Group gRecordLastUpdate to any Item you want to track the last update of
Group:Number:AVG		gRecordLastUpdate "Record Last Update" <time>

// Apply the Group gLastUpdate to virtual DateTime Items created to store those last updates
Group:DateTime			gLastUpdate		"Last Updated [%1$tH:%1$tM:%1$tS]"

and in lastupdates.rules:

// This Rule triggers when any Item in the gRecordLastUpdate Group is updated, and
// updates a virtual DateTime item with the same name as the Item but with _LUD as
// a suffix, setting it to the current date and time.
rule "Record Last Update"
when
  Member of gRecordLastUpdate received update
then
  // post an update to the item with the same name and _LUD suffix
  sendCommand( triggeringItem.name+"_LUD", now.toString)
end

Finally, any of your .items files you can add some Items and their corresponding _LUD suffix virtual DateTime Items which will be updated by the Rule whenever the real Item is changed:

Switch 		My_Test		 "Test Switch"								<smiley>	(gRecordLastUpdate)
DateTime 	My_Test_LUD	 "Test Last Update [%1$tH:%1$tM:%1$tS]" 	<time>		(gLastUpdate)
Number 		My_Test2	 "Test Number"								<smiley>	(gRecordLastUpdate)
DateTime 	My_Test2_LUD "Test Last Update [%1$tH:%1$tM:%1$tS]" 	<time>		(gLastUpdate)
6 Likes