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?
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:
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.
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… Eventually I have to tackle this task.