How to evaluate historic states of items using rrd4j?

I want to evaluate historic maximum values of items, e.g. max. temperature yesterday, max. temperature last week, … last month, and so on. The same with power consumption and so on, …

I tried that like this:

postUpdate(Solar_DayMinusOne, Solar_Tagesenergie.maximumSince(now.minusDays(0).withTimeAtStartOfDay).state)
postUpdate(Solar_DayMinusTwo, Solar_Tagesenergie.maximumSince(now.minusDays(1).withTimeAtStartOfDay).state)
postUpdate(Solar_DayMinusThree, Solar_Tagesenergie.maximumSince(now.minusDays(2).withTimeAtStartOfDay).state)
postUpdate(Solar_WeekMax, Solar_Tagesenergie.maximumSince(now.withTimeAtStartOfDay.getDayOfWeek(-1)).state)
postUpdate(Solar_MonthMax, Solar_Tagesenergie.historicState(now.withDayOfMonth(1)).state)

but the values are either wrong or equal for all days (both happened).
The charts are correct, so the items values in rrd4j are correct, too.

Any idea who to solve that? I did some research also in the joda documentation, but I do not unterstand joda at all.

When you say the values are ‘wrong’ - how wrong are they? I believe RRD doesn’t (always) store ‘real’ values - the values can be slightly different as it uses the AVERAGE function. So if you store more than one value per time period, then the data will be the average of the two (a time period being 60 seconds).

Someone with better knowledge of RRD might correct me on this :smile: but if the values you get are ‘nearly correct but not what you expected’ this might explain it…

“wrong” means completely different values, not only slightly different. But mostly the values are all equal, especially after I changed something in my *.items file and it is being reloaded.

But my question is more related to what is the best way to figure out persistence handling (e.g. maximumSince(now.minusDays(2).withTimeAtStartOfDay).state) and so on.
How do I retreive historic data from rrd4j using OH methods?

I’m not completely sure I understand the question, however the persistence extensions, which are used to query data from the persistence stores are documented here. I suspect you already know that though since you’re using them, so I’ve probably not understood the question - sorry.

The other thing to do is to use HABmin to graph out the data to see what’s actually in the store - it looks like what you’re doing is correct, so this might mean that the RRD data is not being stored as you think it should be…

Is it possible to evaluate sums in a period?
E.g. the sum of generated energy per week or per month or do I have to do the calculation on my own?

I’m not sure how you would do that since I don’t think you can get a time series list and then aggregate them.

You would probably be better to produce a rule that does this each time a new value is received rather than trying to process it later.