Hello<div><br></div><div>I&#39;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&#39;m lost:</div>
<div><br></div><div>1. make a difference peak-hour / offpeak hours as electricity costs are cheaper between 19h00 &amp; 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&#39;s still the time, as I&#39;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, &quot;$dir_img/$_[6]-$_[2].png&quot;;</div>
<div><span class="" style="white-space:pre">        </span>push @rrd, &quot;--start=end-$_[2]&quot;;</div><div><span class="" style="white-space:pre">        </span>push @rrd, &quot;--end=now&quot;;</div><div><span class="" style="white-space:pre">        </span>push @rrd, &quot;--width=500&quot;;</div>
<div><span class="" style="white-space:pre">        </span>push @rrd, &quot;--height=200 -j&quot;;</div><div><span class="" style="white-space:pre">        </span>push @rrd, &quot;--slope-mode&quot;;</div><div><span class="" style="white-space:pre">        </span>push @rrd, &quot;--title=$_[1]&quot;;</div>
<div><span class="" style="white-space:pre">        </span>push @rrd, &quot;--vertical-label=Watt&quot;;</div><div><span class="" style="white-space:pre">        </span>push @rrd, &quot;--lower-limit=0&quot;;</div><div><span class="" style="white-space:pre">        </span>push @rrd, &quot;--alt-autoscale-max&quot;;</div>
<div><span class="" style="white-space:pre">        </span>push @rrd, &quot;--watermark=$TimeStamp&quot;;</div><div><span class="" style="white-space:pre">        </span>push @rrd, &quot;--imgformat=PNG&quot;;</div><div><span class="" style="white-space:pre">        </span>push @rrd, &quot;DEF:energy=$rrd_file:$_[0]:AVERAGE&quot;;<br>
</div><div><span class="" style="white-space:pre">        </span>push @rrd, &quot;CDEF:Watt=energy,3600,*&quot;;</div><div><span class="" style="white-space:pre">        </span>push @rrd, &quot;AREA:Watt#00FF00:&quot;;</div><div><span class="" style="white-space:pre">        </span>push @rrd, &quot;VDEF:WattHour=energy,TOTAL&quot;;</div>
<div><span class="" style="white-space:pre">        </span>push @rrd, &quot;CDEF:mean=Watt,$_[4],TREND&quot;;<br></div><div><span class="" style="white-space:pre">        </span>push @rrd, &quot;COMMENT:\\n&quot;;</div><div><span class="" style="white-space:pre">        </span>push @rrd, &quot;COMMENT:\\n&quot;;</div>
<div><span class="" style="white-space:pre">        </span>push @rrd, &quot;LINE2:Watt#0000FF:Puissance instantanee&quot;;</div><div><span class="" style="white-space:pre">        </span>push @rrd, &quot;LINE1:mean#A00000:Puissance moyenne $_[5]:&quot;;</div>
<div><span class="" style="white-space:pre">        </span>push @rrd, &quot;COMMENT:\\n&quot;;<br></div><div><span class="" style="white-space:pre">        </span>push @rrd, &quot;COMMENT:\\n&quot;;</div><div><span class="" style="white-space:pre">        </span>push @rrd, &quot;GPRINT:WattHour:Energie totale\\:%3.2lf%sWh&quot;;</div>
<div><span class="" style="white-space:pre">        </span>push @rrd, &quot;GPRINT:eurotot:Argent\\:%3.2lfeuro&quot;;</div><div><span class="" style="white-space:pre">        </span>push @rrd, &quot;GPRINT:Watt:LAST:      Puissance Instantanee\\:%3.2lf%sW\\j&quot;;</div>
<div><span class="" style="white-space:pre">        </span>push @rrd, &quot;COMMENT:\\n&quot;;</div><div><span class="" style="white-space:pre">        </span>push @rrd, &quot;COMMENT:\\n&quot;;</div><div><span class="" style="white-space:pre">        </span>push @rrd, &quot;GPRINT:Watt:MIN:Min\\:%3.2lf%sW&quot;;</div>
<div><span class="" style="white-space:pre">        </span>push @rrd, &quot;GPRINT:Watt:AVERAGE:Moyenne\\:%3.2lf%sW&quot;;</div><div><span class="" style="white-space:pre">        </span>push @rrd, &quot;GPRINT:Watt:MAX:Max\\:%3.2lf%sW\\j&quot;;</div>
<div><span class="" style="white-space:pre">        </span>push @rrd, &quot;COMMENT:\\n&quot;;</div><div><span class="" style="white-space:pre">        </span>push @rrd, &quot;COMMENT:\\n&quot;;</div><div><span class="" style="white-space:pre">        </span></div>
<div><span class="" style="white-space:pre">        </span>print &quot;@rrd\n\n&quot; 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 &quot;$0: failed to generate graph $_[0] data into rrd: $ERROR\n&quot;; }</div>
<div><span class="" style="white-space:pre">        </span>} </div></div><div><br></div><div><br></div>