sumSince and rrd4j

Hi

I already read a lot about the rrd4j persistence and it is also clear to me that the service does “compress” the data…the older the less accurate.

Therefore I played the last days with these settings here:

power1min.def=GAUGE,3600,0,U,60
power1min.archives=TOTAL,0.5,1,45000
power1min.items=PHouseDay

This should persist the data per minute for approx. 1 month (31 days)

At the end I would like to have a sum of kWh over last month. The persisted data is kWh per day and looks like this:

So…a fundamental question: Is it even possible to get the sum out of that graph with something like that:

var Number temp = PHouseDay.sumSince(now.minusMonth(1))
PHouseMonth.postUpdate(temp)

Thanks & BR
Michael

No. The only way this would work would be to only sum the value at midnight just before it resets to zero. You could do this in a Rule.

when
    Item DailyKWH changed
then
    if(DailyKWH.state == 0) {
        // code to deal with change of the month
        MonthlyKWH.postUpdate(MonthlyKWH.state + previousState)
    }
end

How is this item updated in the first place. I would think that those daily values are summed up already, can’t you use the same technique for a month
.

Thanks @rlkoshak @opus

Yes, the daily values are already summed up:

var Number nHausTag = (PV_Tag.state as DecimalType) - (D0_Abgabe_Tag.state as DecimalType) - (LG_Resus_Charge_Day.state as DecimalType) 
								  + (D0_Bezug_Tag.state as DecimalType) + (LG_Resus_Discharge_Day.state as DecimalType) // Hausverbrauch Tag

It is possible to get all these items per month as well…was just thinking/trying to do something in the most effiicient and easiest way. And for sure to learn :slight_smile: But I already expected that my first idea does not work. So I will follow the way to have the value for every item per month and then do the calculations.