Detecting, that restoring items on startup is finished

Hi,

I have some Items with old meter values that can only be used for further updates with new values after restoring the items on startup has been finished.

As restoring the items takes some time: Is there a way to detect, that all items have been restored eg. a variable or an item that could be checked?

Thanks for your help!

Juelicher

Reading through this site, it appears the timing of persistence vs. (first) rule execution is a rather tricky issue.
Some general tricks/workarounds are described here:


I have some items to that need to be initialised for the rules to work. Most of the time, persistence kicks first, then the rule executes. But not all the time. Therefore, in the rule, i have a section that check’s the items states for “Uninitialised” and sets them to a “reasonable” value(as found in this great presence detection script: https://github.com/openhab/openhab/wiki/Samples-Tricks#check-presence-by-detecting-wifi-phonestablets).
I guess you could ammend this to set it to the last perisited state. AFAIK the function is "< item >.lastUpdate"
Here’s what i use:

if (Presence.state == Undefined || Presence.state == Uninitialized) {
        
      sendCommand(Presence, ON)
      }

Something like: sendCommand(Presence, Presence.lastUpdate) should do the trick. Come to think of it, why am i not doing this…? :slight_smile:

Be aware: If you use OH2, “Undefined” and “Uninitialiesed” have been replaced by NULL

HTH,
-OLI

That gives you the time of the last update. You want <item>.previusState

Also, this shouldn’t be as much of a problem with OH 2 as persistence gets loaded well before rules so the items should have had time to recurve their must recent values.

Sounds like One more good reason to Upgrade then…:slight_smile:

Thanks booth of you!

Booth ideas seems to be a good workaround, I will try which one works best for my Problem. Upgrading to OH2 is probably a task for a long and cold winter weekend… :wink: Eventually I have to tackle this task.