Webcore not updating Last Activity

If I go to the device info I can see the Last Activity field updating when I hit refresh. I made a piston that just sets last activity every time I flip a switch. Any time I edit and save the piston last activity is correct. Anytime after that it does not update when I flip the switch. I tested my code with amperage on an outlet and it updates fine. Same outlet with Last activity will not update.

I updated my c7 to 2.4.3.176 today.
Ive deleted and re-added webcore.
Ive deleted and re-added pistons.
Ive power cycled.
Ive tried lastactivity on 4 different devices.

When you say Last Activity Field, are you referring to the Last Activity At Device Detail? That is not something Webcore has access to. It can only update attributes via exposed commands in the driver.

You could subscribe to all events from a device, and make your own timestamp whenever the device updates an attribute based on activity.

Otherwise, I'm not sure what Last Activity field you are talking about.

This is the "last activity" I am using

image

Huh. I didn't know that is available, and you are right, it only gets it once when the piston starts.

Based on that, I tested restarting the piston from another piston, and that seems to pull in the new value after it restarts. I used 30 seconds for testing it.

image

Possibly a solution, if restarting the piston on a timer works for you so it will pull in the new value.

Edit:
Even better, instead of having a timer running constantly to restart the piston, only restart the piston when there is activity on the device, by subscribing to the events in the device that represent activity.

image

That's the most ridiculous solution. Its perfect. Thank you so much.

For my use case the timer is perfect. I check every 10 mins to see if last update is over 15mins old. If it is then I set offline and set a variable. Then when last update is less than 15 mins old, I set online I reset the variable which triggers the Thermostat scheduler to send an update incase it was offline at the time of the last temperature change.