Please Expose %lastActivity% Device Property

It would useful to be able to reference Last Activity via %lastActivity% for Devices.

image

I saw and read the following posts but they are dashboard focused:

2 Likes

You, more or less, can already do that with a local variable.

1 Like

The example rule I provided was intended to test if the %lastActivity% and %lastUpdated% Device properties were already available and not indicative of my intended use.

Then what is your intended use?

I am requesting the use %lastActivity% in a Log or Notification from any App, not just Rules triggering on a Device change.

For example, the Notifications App Battery Level Text Notification.

My existing Notification contains %device% and %value%. I would like to add %lastActivity%.

1 Like

I will look into this.

Everything is event based though. Inherently, the last activity time for the event you're monitoring would be the event time. %time% is already available for event time. That event time will be the last activity time...in that moment at least. For example, the notifications app for battery level goes like this:

  1. Device sends battery report event.
  2. Notification App instance is subscribed to that event as the trigger. The device report triggers the rule.
  3. Notification is pushed.

This all happens in fractions of a second. So %time% would be equal (with a fraction second margin of error) to Last Activity. I suppose you could have issues if you have a rule trigger for device A and you wanted to see last activity for device B, but that's a different ball of wax.

Not always... "Last Activity" should be the last time the device's parse() routine was called (at least IMHO :wink: ) Just calling parse() does NOT always result in a new Event being generated. Without a new Event, Rule Machine and any other subscribed Apps will not be called.

So, if a device transmits its status periodically, whether or not the status has changed, then the Last Activity of that device 'should' be updated, IMHO. Only new status values, however, will result in a new Event being generated. The Hubitat Platform typically performs this deduplication, unless specified otherwise by the driver's programmer. Some devices, like Buttons, need an event generated every time there is a status update, as the user might push the same button number multiple times in a row.

But with respect to the OP's request, where a notification is going to be sent, that's going to happen in response to an event on this device, so that will be it's Last Activity, as @FriedCheese2006 points out. Both RM and Notifier only send notifications for the last triggering device, not any other device. So there will only be milliseconds of difference between %time% and %lastActivity%, and hence this as a feature makes no sense.

In a custom app there are certainly situations where looking at lastActivity for some other device makes perfect sense.

2 Likes

Understood, thank you.

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