Cross-posted on Konnected's site, but it's been a couple of days with no response, so posting here.
I have a dashboard that uses the lastActivity variable to show the last time a konnected contact sensor was open. I noticed the time was wrong, so I dug in a little. Current status is closed, and on the Hubitat events tab, the time is correct:

However, when I go to the logs tab, it displays a bunch of random times that apparently polled the device or something? So the most recent time stamp there is a few days later:

Thus, if I look at the device details, the lastActivity matches the log, not the event:

And thus, my dashboard displays the 2/17 time, when the last time the contact sensor changed status was actually on 2/12:

I'm trying to figure out:
- What is creating the entries in the "log" that seemingly poll the device. I've dug thru the drivers & app code and see nothing, and these devices are not "in use" by anything which checks status
- How can I get the lastActivity time to simply reflect the last time the contact sensor's open/close status changed?
On the commands tab for this device, what does it show on the right hand side under "Current States" or "State Variables"? Is the last activity displayed there as well?
You are not using last Activity for its intended purpose.
lastActivity updates any time the driver posts an event, even if it is a duplicated event. However duplicate events are filtered from the event log and do not trigger rules (unless a special flag is sent in the driver code).
I suspect when the driver is polling to be sure the states are correct, it is just posting all the events it gets back and letting the hub sort out what is changed and what isn't. That is actually the proper and correct way to handle it.
The best way to do what you want would be for the driver itself to post a timestamp to a Current state or state variable only when the state changes.
Or instead of modifying the driver code you could create a Hub Variable to track the time, and then a rule that updates that time when the state changes.
2 Likes
maybe I should just do lastOpened. I guess it really accomplishes the same thing if I am also displaying an indicator to say whether or not it's closed.
1 Like