OH2: Minutes since last update of a certain sensor?

I’ve searched for a while now, but I didn’t find anything (or I overread it):
Is there a way to get the information when a sensor was updated the last time?

I don’t mean the absolute date/time; for this I found examples and they work - I mean the delta since the last update; an information which looks like this way: “17 Minutes since last update”. And the number of minutes should be calculated between current time and the last time the sensor got updated.

I tried different rules, but I failed in all my tries - because when I set up a rule “when received update”, it’s too late, because then the “last update” equals the current time.

Any ideas or hints for me how to solve this? Thanks!

You need to keep track of first update time is an item or a global variable. Then when you receive an update calculate the delta between now and the first update. Then do the math to convert that from what will likely be milliseconds to the format you want and put that into a String Item.

1 Like

Thanks, found the solution here:
https://community.openhab.org/t/calculation-times-with-datetime-items/2028/5?u=boby