I’ve got an openHAB development system on an old laptop; this does not run 24/7
I’m generating simulated numeric meter readings and use RRD4J persistence, with the usual everyMinute settings and default consolidation strategy.
Because the system is not 24/7, I have gaps in the persisted data, naturally enough. Here’s a sample from rrdInspector, 2nd archive where it’s been consolidated to every 4 minutes.
No surprises so far.
If I now try to recover values using historicState() in rules, I get into trouble.
Yes, I realise the older data may have accuracy compromises because it has been averaged over time, not the problem here.
I don’t really know how historicState() decides which archives to look in, but tested here with a target time that is not in the first every-minute archive, but is in the second 4-minute archive.
Requesting historicData() for 11:59 gives me the expected object with state 3806.75, and timestamp 11:56
I say expected, because what I would expect is for searching for 11:59 exactly to “fail”, but then look for preceding data instead.
Likewise, seeking for 12:02 returns data stamped 12;00
Requesting historicState() for 12:10 returns null.
That’s not what I expect. As I understand it, if there is no record at the specified time instant, historicState() should grope back in time until it finds a record, making the assumption that data persisted until the given time.
In short, return the next-oldest data.
It’s arguable that the NaN records do represent “the next-oldest data”.
But those NaN records have been created, synthesized, by the rrd4j aggregation process. No data was actually recorded for those times at all.
Note that whatever it is that the BasicUI simple Chart widget does to access the same gappy dataset, it does not choke on it and draws a chart using the “ignore NaN and assume last value remains valid” strategy.
I think this is a bug, but welcome discussion. @opus perhaps?