lastUpdate only ever shows current time

I am trying to get the last update times of items in a rule, but it always returns the current minute.
I’m using rrd4j, and can successfully display charts using the items, so I know it is persisting correctly.

Here’s the rule:

rule "Test1"
    Item Test changed
    logDebug("heatingRule", "TemperatureThermostat is: " + TemperatureThermostat.state)
    logDebug("heatingRule", "TemperatureThermostat lastUpdate is: " + TemperatureThermostat.lastUpdate)
    logDebug("heatingRule", "RoomStatRelay is: " + RoomStatRelay.state)
    logDebug("heatingRule", "RoomStatRelay lastUpdate is: " + RoomStatRelay.lastUpdate)

and the output from it:

2017-11-13 11:29:50.459 [DEBUG] [e.smarthome.model.script.heatingRule] - TemperatureThermostat is: 21
2017-11-13 11:29:50.484 [DEBUG] [e.smarthome.model.script.heatingRule] - TemperatureThermostat lastUpdate is: 2017-11-13T11:29:00.000Z
2017-11-13 11:29:50.494 [DEBUG] [e.smarthome.model.script.heatingRule] - RoomStatRelay is: OFF
2017-11-13 11:29:50.503 [DEBUG] [e.smarthome.model.script.heatingRule] - RoomStatRelay lastUpdate is: 2017-11-13T11:29:00.000Z

and rrd4j.persist:

Strategies {
        // for rrd charts, we need a cron strategy
        everyMinute : "0 * * * * ?"
        default = everyChange

Items {
    gHistory* : strategy = everyChange, everyMinute
    gChart*   : strategy = everyChange, everyMinute
    gMotion*  : strategy = everyUpdate, everyMinute

Item Test is just a number I can change to trigger the test.
TemperatureThermostat is updated about every fifteen minutes.

I know from looking at many examples that this is working for other people, but I’m now at a loss as to find out why it doesn’t for my setup.
Can anyone offer a pointer?

  • Platform information:
    • Hardware: RPI 3
    • OS: OpenHABian
    • openHAB version: 2.2.0~20171109111930-1 (Build #1075)

So there is a bit of a disconnect between how one would expect lastUpdate to work and how it actually works. lastUpdate will only return the time of the most recent entry in the DB. There is nothing in the database to help distinguish between a value that was saved because of a change, an update, or a time based strategy so it would have no way to do otherwise.

Consequently, becuase you are using an everyMinute strategy, which is required for rrd4j to work correctly, your lastUpdate will never return a value older than one minute ago.

I recommend adding in MapDB with only an everyUpdate or everyChange strategy and then you can specify to get the lastUpdate from MapDB using


Thank you Rich. It’s obvious now you point it out! I’ll do as you suggest.