lastUpdate someway drifting (OH 3.01)

I have written a small rule to test the “lastUpdate” function

rule "lastTest"
when 
    Time cron "0 0/2 9-16 ? 4-10 * *" 
then
    gEast.members.forEach [item | 
    logInfo("shader", "--")
    logInfo("shader", "item {}", item )
    logInfo("shader", "last update  {}", item.lastUpdate())
    
    logInfo("shader", "difference {}", now.toInstant.toEpochMilli - item.lastUpdate.toInstant.toEpochMilli)
    
    ]
end

and this is what the log looks like

2021-06-01 12:58:00.165 [INFO ] [org.openhab.core.model.script.shader] - --

2021-06-01 12:58:00.179 [INFO ] [org.openhab.core.model.script.shader] - item Bathroom_Shutter (Type=RollershutterItem, State=69, Label=Rollade Badezimmer, Category=null, Groups=[gBathRoom, gShutter, gUpperFloor, gEast])

2021-06-01 12:58:00.186 [INFO ] [org.openhab.core.model.script.shader] - last update  2021-06-01T12:57+02:00[Europe/Berlin]

2021-06-01 12:58:00.195 [INFO ] [org.openhab.core.model.script.shader] - difference 60191

2021-06-01 12:58:00.199 [INFO ] [org.openhab.core.model.script.shader] - --

2021-06-01 12:58:00.203 [INFO ] [org.openhab.core.model.script.shader] - item LeonEast_Shutter (Type=RollershutterItem, State=67, Label=Rollade Leon Osten, Category=null, Groups=[gLeon, gShutter, gUpperFloor, gEast])

2021-06-01 12:58:00.209 [INFO ] [org.openhab.core.model.script.shader] - last update  2021-06-01T12:57+02:00[Europe/Berlin]

2021-06-01 12:58:00.217 [INFO ] [org.openhab.core.model.script.shader] - difference 60213

2021-06-01 12:58:00.224 [INFO ] [org.openhab.core.model.script.shader] - --

2021-06-01 12:58:00.232 [INFO ] [org.openhab.core.model.script.shader] - item Bedroom_Shutter (Type=RollershutterItem, State=69, Label=Rollade Schlafzimmer, Category=null, Groups=[gBedRoom, gShutter, gUpperFloor, gEast])

2021-06-01 12:58:00.241 [INFO ] [org.openhab.core.model.script.shader] - last update  2021-06-01T12:57+02:00[Europe/Berlin]

2021-06-01 12:58:00.249 [INFO ] [org.openhab.core.model.script.shader] - difference 60245

2021-06-01 13:00:00.163 [INFO ] [org.openhab.core.model.script.shader] - current temperature localCurrentTemperature (Type=NumberItem, State=23.97 °C, Label=Aktuelle Temperatur, Category=temperature)

2021-06-01 13:00:00.165 [INFO ] [org.openhab.core.model.script.shader] - --

2021-06-01 13:00:00.179 [INFO ] [org.openhab.core.model.script.shader] - item Bathroom_Shutter (Type=RollershutterItem, State=69, Label=Rollade Badezimmer, Category=null, Groups=[gBathRoom, gShutter, gUpperFloor, gEast])

2021-06-01 13:00:00.185 [INFO ] [org.openhab.core.model.script.shader] - last update  2021-06-01T12:59+02:00[Europe/Berlin]

2021-06-01 13:00:00.192 [INFO ] [org.openhab.core.model.script.shader] - difference 60188

2021-06-01 13:00:00.195 [INFO ] [org.openhab.core.model.script.shader] - --

2021-06-01 13:00:00.199 [INFO ] [org.openhab.core.model.script.shader] - item LeonEast_Shutter (Type=RollershutterItem, State=67, Label=Rollade Leon Osten, Category=null, Groups=[gLeon, gShutter, gUpperFloor, gEast])

2021-06-01 13:00:00.204 [INFO ] [org.openhab.core.model.script.shader] - last update  2021-06-01T12:59+02:00[Europe/Berlin]

2021-06-01 13:00:00.211 [INFO ] [org.openhab.core.model.script.shader] - difference 60208

2021-06-01 13:00:00.215 [INFO ] [org.openhab.core.model.script.shader] - --

2021-06-01 13:00:00.218 [INFO ] [org.openhab.core.model.script.shader] - item Bedroom_Shutter (Type=RollershutterItem, State=69, Label=Rollade Schlafzimmer, Category=null, Groups=[gBedRoom, gShutter, gUpperFloor, gEast])

2021-06-01 13:00:00.223 [INFO ] [org.openhab.core.model.script.shader] - last update  2021-06-01T12:59+02:00[Europe/Berlin]

2021-06-01 13:00:00.230 [INFO ] [org.openhab.core.model.script.shader] - difference 60227

2021-06-01 13:02:00.164 [INFO ] [org.openhab.core.model.script.shader] - --

All RollershutterItems did not change but the lastUpdate timestamp seems to be changed by the call of lastUpdate. What am I doing / understanding wrong?

<item>.lastUpdate is a call to your default persistence service. What’s that? When did it last persist that Item?
i.e, it is not necessarily when the Item itself was last updated, it’s when the database updated.

If you’ve got everything default, you’re probably looking at RRD4J persisting every minute.

1 Like

thank you for the quick answer. I changed to a call of item.changedSince() to get some hysteresis and I did not realise that this was a function of Persistence.