Hello<div><br></div><div>I've photovoltaic pannels installed on my roof. I also install an energy counter (1 pulse = 1 Wh) to measure my own electricity production.</div><div><br></div><div>I finally succeed to use RRDtool to graph my solar production: <a href="http://nas.parvais.com/domotique/electricite-prod_pv.php">http://nas.parvais.com/domotique/electricite-prod_pv.php</a></div>
<div><br></div><div>I also use the same principle to measure the electricity I need to buy from my supplier.: <a href="http://nas.parvais.com/domotique/electricite-conso.php">http://nas.parvais.com/domotique/electricite-conso.php</a></div>
<div><br></div><div>Here is below the subroutine (perl) used to chart my production or my consumption(RRD file with 2 DS conso / prod)</div><div><br></div><div>I would like to to two new improvements, for which I'm lost:</div>
<div><br></div><div>1. make a difference peak-hour / offpeak hours as electricity costs are cheaper between 19h00 & 7H00 and during week end. Make clear color distrinction on graphs</div><div>2. print on the same graph (second right axis) a new line with the correspondance between energy prodution / consumption (W*h) an EURO (we know i.e 1kWh costs 0.15€ off peak and 0.25€ peak)</div>
<div><br></div><div><br></div><div>Can you make me some suggestion ? should I reword my RRD file structure ? (it's still the time, as I'm not yet in production)</div><div><br></div><div>Thank you for any idea and web reference</div>
<div><br></div><div>Thomas</div><div><br></div><div><br></div><div><div>sub CreateGraph</div><div><span class="" style="white-space:pre">        </span># inputs:<span class="" style="white-space:pre">        </span>$_[0]: sensor_rrd_name</div>
<div><span class="" style="white-space:pre">        </span>#<span class="" style="white-space:pre">                        </span>$_[1]: chart title</div><div><span class="" style="white-space:pre">        </span>#<span class="" style="white-space:pre">                        </span>$_[2]: interval period (1h,24h,7d,1m,1y,10y)</div>
<div><span class="" style="white-space:pre">        </span>#<span class="" style="white-space:pre">                        </span>$_[3]: Display Puissance instantanee (1/0)</div><div><span class="" style="white-space:pre">        </span>#<span class="" style="white-space:pre">                        </span>$_[4]: Moving average timeperiod</div>
<div><span class="" style="white-space:pre">        </span>#<span class="" style="white-space:pre">                        </span>$_[5]: Moving average Timeperiod unit</div><div><span class="" style="white-space:pre">        </span>#<span class="" style="white-space:pre">                        </span>$_[6]: picture prefix-filename</div>
<div><span class="" style="white-space:pre">        </span>{</div><div><span class="" style="white-space:pre">        </span>my @rrd=();</div><div><span class="" style="white-space:pre">        </span>push @rrd, "$dir_img/$_[6]-$_[2].png";</div>
<div><span class="" style="white-space:pre">        </span>push @rrd, "--start=end-$_[2]";</div><div><span class="" style="white-space:pre">        </span>push @rrd, "--end=now";</div><div><span class="" style="white-space:pre">        </span>push @rrd, "--width=500";</div>
<div><span class="" style="white-space:pre">        </span>push @rrd, "--height=200 -j";</div><div><span class="" style="white-space:pre">        </span>push @rrd, "--slope-mode";</div><div><span class="" style="white-space:pre">        </span>push @rrd, "--title=$_[1]";</div>
<div><span class="" style="white-space:pre">        </span>push @rrd, "--vertical-label=Watt";</div><div><span class="" style="white-space:pre">        </span>push @rrd, "--lower-limit=0";</div><div><span class="" style="white-space:pre">        </span>push @rrd, "--alt-autoscale-max";</div>
<div><span class="" style="white-space:pre">        </span>push @rrd, "--watermark=$TimeStamp";</div><div><span class="" style="white-space:pre">        </span>push @rrd, "--imgformat=PNG";</div><div><span class="" style="white-space:pre">        </span>push @rrd, "DEF:energy=$rrd_file:$_[0]:AVERAGE";<br>
</div><div><span class="" style="white-space:pre">        </span>push @rrd, "CDEF:Watt=energy,3600,*";</div><div><span class="" style="white-space:pre">        </span>push @rrd, "AREA:Watt#00FF00:";</div><div><span class="" style="white-space:pre">        </span>push @rrd, "VDEF:WattHour=energy,TOTAL";</div>
<div><span class="" style="white-space:pre">        </span>push @rrd, "CDEF:mean=Watt,$_[4],TREND";<br></div><div><span class="" style="white-space:pre">        </span>push @rrd, "COMMENT:\\n";</div><div><span class="" style="white-space:pre">        </span>push @rrd, "COMMENT:\\n";</div>
<div><span class="" style="white-space:pre">        </span>push @rrd, "LINE2:Watt#0000FF:Puissance instantanee";</div><div><span class="" style="white-space:pre">        </span>push @rrd, "LINE1:mean#A00000:Puissance moyenne $_[5]:";</div>
<div><span class="" style="white-space:pre">        </span>push @rrd, "COMMENT:\\n";<br></div><div><span class="" style="white-space:pre">        </span>push @rrd, "COMMENT:\\n";</div><div><span class="" style="white-space:pre">        </span>push @rrd, "GPRINT:WattHour:Energie totale\\:%3.2lf%sWh";</div>
<div><span class="" style="white-space:pre">        </span>push @rrd, "GPRINT:eurotot:Argent\\:%3.2lfeuro";</div><div><span class="" style="white-space:pre">        </span>push @rrd, "GPRINT:Watt:LAST: Puissance Instantanee\\:%3.2lf%sW\\j";</div>
<div><span class="" style="white-space:pre">        </span>push @rrd, "COMMENT:\\n";</div><div><span class="" style="white-space:pre">        </span>push @rrd, "COMMENT:\\n";</div><div><span class="" style="white-space:pre">        </span>push @rrd, "GPRINT:Watt:MIN:Min\\:%3.2lf%sW";</div>
<div><span class="" style="white-space:pre">        </span>push @rrd, "GPRINT:Watt:AVERAGE:Moyenne\\:%3.2lf%sW";</div><div><span class="" style="white-space:pre">        </span>push @rrd, "GPRINT:Watt:MAX:Max\\:%3.2lf%sW\\j";</div>
<div><span class="" style="white-space:pre">        </span>push @rrd, "COMMENT:\\n";</div><div><span class="" style="white-space:pre">        </span>push @rrd, "COMMENT:\\n";</div><div><span class="" style="white-space:pre">        </span></div>
<div><span class="" style="white-space:pre">        </span>print "@rrd\n\n" if ($verbose==1);</div><div><span class="" style="white-space:pre">        </span></div><div><span class="" style="white-space:pre">        </span>RRDs::graph(@rrd);</div>
<div><span class="" style="white-space:pre">                                        </span></div><div><span class="" style="white-space:pre">        </span>if ($ERROR = RRDs::error) { print "$0: failed to generate graph $_[0] data into rrd: $ERROR\n"; }</div>
<div><span class="" style="white-space:pre">        </span>} </div></div><div><br></div><div><br></div>