I am using rrd4j to persist the readings (power and energy) from my “home energy meter”. The persistence seems to work OK since I can pull up nice-looking graphs in HABmin. I am using an “everyminute” strategy.
I am working on some “clever” rules to display maximum/minimum/average power consumption for different periods of time. At present I have defined the following two periods:
- last 24 hours
- since dawn of times (or more correctly; since I started measuring which is really not that long ago)
I am using the maximuSince/minimumSince/averageSince methods from the persistence extensions.
What puzzles me is that currently the minimumSince() method for the last 24 hours is reporting a value that is less than what is reported by the minimumSince() method since “the dawn of times”! This is not logical since clearly the 24 hour period is a subset of the “since dawn of times” period.
Has anyone seen anything similar?
I’m not an expert on this, but rrd doesn’t retain ‘exact’ values. It keeps an ‘average’ value for each time period - rrd then keeps a number of time periods - 1 minute and 1 hour I think. So, for short periods, it probably uses the 1 minute data, and the minimum is therefore the minimum of the 1 minute average over the time period you’re after. If you ask for a longer period, then you get the minimum of the hourly average over the timer period - this could be higher, or lower, than the 1 minute average…
Does that make sense
This is the problem (in my opinion) with rrd - it’s not keeping the real data, so what you get back is not quite reality… The positive side of rrd is that the memory size remains constant - but personally, I prefer not to use it for this reason…
What you write certainly makes sense and gives a logical explanation of what might be the reason for the “funny values” I retrieve.
I knew that rrd did som magic tricks to achieve the constant memory (or disk) size requirement, but I was not aware that it was done in the way you describe (by not storing “real” data)! I thought it simply threw away “sample points” so that the granularity of the data was getting coarser over time.
With this information in mind I will definitely review my decision to use rrd as persistence service for this type of data.
Would you mind sharing what service you have ended up using? I have used Influx before and was happy with that, but have since moved to Raspberry Pi and Influx is not supported on this platform (yet at least).
I normally use mySQL, but have recently been trialling an h2sql database which is quite nice for embedded systems. I do however have a suspicion that it has a stability problem, so I wouldn’t currently recommend it…