Hi all!
I am a bit lost in terms of how exactly rrd4j works and what the default configuration is. Maybe someone can help me out. I’m on a very recent (this week) snapshot build of OH2 and have set up rrd4j persistence. I installed the binding via PeperUI and configured rrd4j.persist in the following way:
Strategies {
everyMinute : "0 * * * * ?"
}
Items {
PersistEveryMinute* : strategy = everyMinute
}
I did not touch rrd4j.cfg which looks like this:
# configure specific rrd properties for given items in this file.
# please refer to the documentation available at
# https://www.openhab.org/addons/persistence/rrd4j/
#
# default_numeric and default_other are internally defined defnames and are used as
# defaults when no other defname applies
#<defname>.def=[ABSOLUTE|COUNTER|DERIVE|GAUGE],<heartbeat>,[<min>|U],[<max>|U],<step>
#<defname>.archives=[AVERAGE|MIN|MAX|LAST|FIRST|TOTAL],<xff>,<steps>,<rows>
#<defname>.items=<comma separated list of items for this defname>
My items file looks like this:
Group PersistEveryMinute "Persist Every Minute"
...
Number WashingMachinePower "Leistung Waschmaschine" (PersistEveryMinute) {channel="avmfritz:FRITZ_DECT_200:<...some_id...>:power"}
This basically works. I can see a WashingMachinePower.rrd file in /userdata/persistence/rrd4j/. I can also query the persistence object in rules, e.g.:
val Number avgPower5min = WashingMachinePower.averageSince(now.minusMinutes(5), "rrd4j");
This gives me numbers that seem sensible (so not 0 and not always the same value and about what would be expected).
However, I noticed that if I query the history of my samle item using the REST API I am getting unexpected results.
http://<oh2>:<port>/rest/persistence/items/WashingMachinePower?serviceId=rrd4j
Results:
{
"name": "WashingMachinePower",
"datapoints": "360",
"data": [
{
"time": 1540466640000,
"state": "0.0"
},
{
"time": 1540466880000,
"state": "0.0"
},
// ... many more "0.0" values ...
{
"time": 1540539360000,
"state": "0.0"
},
// followed by about 50 values that make sense
// ...
{
"time": 1540552320000,
"state": "57.43000000000001"
},
{
"time": 1540552560000,
"state": "72.345"
},
{
"time": 1540552800000,
"state": "110.07000000000001"
}
]
}
I noticed that a newly created .rrd file contains 0 (zero) datapoints and then grows gradually. (1, 2, 3… etc.). But it does not grow by one datapoint per minute (as configured) but at a lower frequency. How can this be? Is this depending on the update frequency of the item? So - no update for 5 minutes, no new entry persisted for 5 minutes?
I suspect WashingMachinePower.rrd grew to 360 datapoints and then stopped, because it is no longer growing. Why? 360 cannot possibly be the correct number for the documented total amount of datapoints as can be found here. Is this outdated in terms of the default datapoint strategy and if yes, what is the default in OH2?
From what I understand by reading the docs, there should be one value every minute for 4 to 8 (depending on what doc I read ;-)) hours. But looking at the API output (360 datapoints), this cannot be.
Furthermore, the values persisted are not what I would expect. The item WashingMachinePower changes about every two minutes according to the logs (ItemStateChangedEvent). I would have expected to see the logged values in the rrd4j data file because (as I understand it) a snapshot of the current value of WashingMachinePower is taken every minute and persisted. Not every value would be persisted, of course, but those that are persisted on a minute-by-minute basis should be found in the logs. (At least that’s what I assumed.) But the values persisted slightly differ from what I can see in the logs. Does rrd4j somehow record averages even for the most recent values recorded on a minute-by-minute basis?
It would be great if someone could shed some light on how exactly rrd4j in OH2 is supposed to behave (by default). Is there a file that contains the default configuration, or is this hardcoded?
Thanks a lot in advance!
Jens