[rrd-users] Question about averaging daily ; but with 5 min. steps
Jean-Yves Avenard
jyavenard at gmail.com
Mon Dec 14 12:11:23 CET 2009
Hi
Putting the final touch to my energy monitoring.
I have pretty much everything up and running as it should ; except for
one type of calculation.
the aim of my calculations is to monitor how much energy I output to
the electricity grid via solar panels.
The calculation is done as a *net* feed ; you receive a discount from
the electrical company for any electricity you output ; with a
premium.
The calculation is made over 5 minutes average.
I have two RRD files ; one containing my power usage ; stored as GAUGE
; as watts . As we get charge in Watt/Hour (Wh) I perform the
calculation using CDEF to transform watts over time into Wh.
The 2nd one is for the solar output, this one is a DERIVE counter of a
Wh value reported by the solar inverter that converts DC to AC.
To calculate what the feed-in value is, I use a RPN calculation in a CDEF..
I create the graph using:
$res = resolution
$timestamp = end period
$start = begin period
$duration = $timestamp - $start
$timestamp and $start are always multiple of $res.
$RRDTOOL graph $name -l 0 \
-t '$title' \
-x $legend --slope-mode \
--step $res --start $start --end $timestamp \
-w $width -h $height \
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=csolar,UN,0,csolar,IF,ctotal,-,0,MIN \
CDEF:cimport2=cimport,ABS \
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=ctotal,csolar,UN,0,csolar,IF,-,0,MIN \
CDEF:cexport2=cexport,ABS \
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:vtotalmax=ctotal,MAXIMUM \
VDEF:vtotalavg=ctotal,AVERAGE \
VDEF:vtotalmin=ctotal,MINIMUM \
VDEF:vtotaltot=ctotaltot,AVERAGE \
VDEF:vsolarmax=csolar,MAXIMUM \
VDEF:vsolaravg=csolar,AVERAGE \
VDEF:vsolarmin=csolar,MINIMUM \
VDEF:vsolartot=csolartot,AVERAGE \
VDEF:vimportmax=cimport2,MAXIMUM \
VDEF:vimportavg=cimport30,AVERAGE \
VDEF:vimportmin=cimport2,MINIMUM \
VDEF:vimporttot=cimporttot,AVERAGE \
VDEF:vexportmax=cexport2,MAXIMUM \
VDEF:vexportavg=cexport30,AVERAGE \
VDEF:vexportmin=cexport2,MINIMUM \
VDEF:vexporttot=cexporttot,AVERAGE \
COMMENT:' ' \
COMMENT:'Maximum ' \
COMMENT:'Average ' \
COMMENT:'Minimum ' \
COMMENT:'Total View\l' \
AREA:ctotal#ff4500:'Total ' \
GPRINT:vtotalmax:'%6.1lf %sWh ' \
GPRINT:vtotalavg:'%6.1lf %sWh ' \
GPRINT:vtotalmin:'%6.1lf %sWh ' \
GPRINT:vtotaltot:'%7.2lf %sWh\l' \
AREA:csolar#FFd700a0:'Solar ' \
GPRINT:vsolarmax:'%6.1lf %sWh ' \
GPRINT:vsolaravg:'%6.1lf %sWh ' \
GPRINT:vsolarmin:'%6.1lf %sWh ' \
GPRINT:vsolartot:'%7.2lf %sWh\l' \
COMMENT:'-----------------------------------------------------------------\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' \
> /dev/null", $output2, $status2);
The basic calculation is pretty much:
CDEF:cexport=ctotal,csolar,-,0,MAX
so the value is discarded if negative (at those time, I import power)
and kept if positive.
It works well if I'm showing a daily view with 5 minutes average...
However, what I would like, is draw/print of a daily average ; but all
internal calculations are done still using 5 minutes average...
I can do this for calculating the average displayed and the total kWh
; but for the graph, maximum and minimum values ; those aren't daily.
Is this something possible?
The issue with daily average is that with res = 86400 ; as long as my
overal usage is more than what my solar panels output (and that will
always be the case) , the amount exported will always show as 0...
Thanks in advance for your help
Jean-Yves
More information about the rrd-users
mailing list