# [rrd-users] Question about averaging daily ; but with 5 min. steps

Jean-Yves Avenard jyavenard at gmail.com
Tue Dec 15 00:04:08 CET 2009

```Hi

Okay, it looks we started on the wrong foot so I'm going to explain
the problem differently...

I am measuring two things.
One is the power usage of all my electrical appliances ; the other is
the wattage output of my solar panel.

Say my electrical appliances are using 500W of power ; 24/7. So that
makes it 500 * 24 / 1000 = 12kWh per day.

Now my solar generates 1000W for 10 minutes every hour on the hour...
So that makes it 1000 * 10 / 60 * 24 / 1000 = 4kWh per day.

If I was to calculate how much energy I put back in the grid ; using
daily average ; it would show as 0 ; as 12kWh > 4kWh

However, if I use 5 minutes average (the same calculation as performed
by the electric meter) the amount of energy put back in the grid is:
(1000 - 500) * 10 / 60 * 24 / 1000 = 2kWh per day.

Going back to RRD ;

If I do:
DEF:total=currentcost3.rrd:total:AVERAGE \
DEF:total30=currentcost3.rrd:total:AVERAGE:step=300 \
DEF:solar=solarprod3.rrd:total:AVERAGE \
DEF:solar30=solarprod3.rrd:total:AVERAGE:step=300 \
CDEF:totalw=total,3600,/ CDEF:total30w=total30,3600,/ \
CDEF:ctotal=totalw,\$res,* \
CDEF:ctotal30=total30w,\$res,* \
CDEF:ctotaltot=total30w,UN,0,total30w,IF,\$duration,* \
CDEF:csolar=solar,\$res,* \
CDEF:csolar30=solar30,\$res,* \
CDEF:csolartot=solar30,UN,0,solar30,IF,\$duration,* \
CDEF:cimport=ctotal,csolar,UN,0,csolar,IF,-,0,MAX \
CDEF:cimport30=ctotal30,csolar30,UN,0,csolar30,IF,-,0,MAX \
CDEF:cimporttot=total30w,UN,0,total30w,IF,solar30,UN,0,solar30,IF,-,0,MAX,\$duration,*
\
CDEF:cexport=csolar,UN,0,csolar,IF,ctotal,-,0,MAX \
CDEF:cexport30=csolar30,UN,0,csolar30,IF,ctotal30,-,0,MAX \
CDEF:cexporttot=solar30,UN,0,solar30,IF,total30w,UN,0,total30w,IF,-,0,MAX,\$duration,*
\
VDEF:vimportmax=cimport,MAXIMUM \
VDEF:vimportavg=cimport30,AVERAGE \
VDEF:vimportmin=cimport,MINIMUM \
VDEF:vimporttot=cimporttot,AVERAGE \
VDEF:vexportmax=cexport,MAXIMUM \
VDEF:vexportavg=cexport30,AVERAGE \
VDEF:vexportmin=cexport,MINIMUM \
VDEF:vexporttot=cexporttot,AVERAGE \
COMMENT:'            ' \
COMMENT:'Maximum    ' \
COMMENT:'Average    ' \
COMMENT:'Minimum    '  \
COMMENT:'Total View\l'  \
AREA:cimport#ff4500:'Import  ' \
GPRINT:vimportmax:'%6.1lf %sWh ' \
GPRINT:vimportavg:'%6.1lf %sWh ' \
GPRINT:vimportmin:'%6.1lf %sWh  ' \
GPRINT:vimporttot:'%7.2lf %sWh\l' \
AREA:cexport#FFd700a0:'Export  ' \
GPRINT:vexportmax:'%6.1lf %sWh ' \
GPRINT:vexportavg:'%6.1lf %sWh ' \
GPRINT:vexportmin:'%6.1lf %sWh  ' \
GPRINT:vexporttot:'%7.2lf %sWh\l' \

With this ; the average and total output are calculated properly;
because I'm using a 5 minutes interval at all times
DEF:solar30=solarprod3.rrd:total:AVERAGE:step=300

However, this isn't giving me the graph I want (it would show a 5
minutes average graph, and not a daily average graph) and same for
maximum and minimum : those would be the maximum of a 5 minutes
average and not the maximum of a daily average...

So back to my original question:
How do I graph with RRD ; a daily average made on a 5 minutes average
of a substraction of 2 values of two different RRD input.
And is this even possible currently ?

Thanks !
Jean-Yves

```