Ignore:
Timestamp:
12/05/2015 09:53:28 PM (9 years ago)
Author:
Norbert Wigbels <njw@…>
Branches:
master
Children:
8cc14b9
Parents:
b342b88
Message:

Stromzaehler

Location:
de.wigbels.ruby/hothotread
Files:
2 added
6 edited
2 moved

Legend:

Unmodified
Added
Removed
  • de.wigbels.ruby/hothotread/draw_graphs.sh

    rb342b88 rc22952c  
    1111CDEF:gash=gas,120,* \
    1212VDEF:gastotal=gas,TOTAL \
    13 GPRINT:gastotal:"Total %6.0lf m3 Gas" \
     13GPRINT:gastotal:"Total %6.0lf Liter Gas" \
    1414LINE2:gash#c17d11:"Gasverbrauch"
    1515
     
    2222CDEF:gasd=gas,2880,* \
    2323VDEF:gastotal=gas,TOTAL \
    24 GPRINT:gastotal:"Total %6.0lf m3 Gas" \
     24GPRINT:gastotal:"Total %6.0lf Liter Gas" \
    2525LINE2:gasd#c17d11:"Gasverbrauch/Tag"
    2626
     
    3333CDEF:gasd=gas,2880,* \
    3434VDEF:gastotal=gas,TOTAL \
    35 GPRINT:gastotal:"Total %6.0lf m3 Gas" \
     35GPRINT:gastotal:"Total %6.0lf Liter Gas" \
    3636LINE2:gasd#c17d11:"Gasverbrauch/Tag"
    3737
     38rrdtool graph web/gas_1jahr.png \
     39-w 800 -h 500 \
     40-s 'now - 1 year' -e 'now' \
     41--title "Gasverbrauch im Jahresverlauf" \
     42--font TITLE:12 --vertical-label="Liter/Tag" \
     43DEF:gas=gas.rrd:gas:AVERAGE \
     44CDEF:gasd=gas,2880,* \
     45VDEF:gastotal=gas,TOTAL \
     46GPRINT:gastotal:"Total %6.0lf Liter Gas" \
     47LINE2:gasd#c17d11:"Gasverbrauch/Tag"
     48
     49
     50
     51rrdtool graph web/consum_1day.png   -s 'now -1 day' -e 'now'   -Y -A   DEF:consum=power.rrd:consum:AVERAGE   LINE2:consum#00FF00:"Verbrauch [W]"
     52rrdtool graph web/consum_1week.png   -s 'now -1 week' -e 'now'   -Y -A   DEF:consum=power.rrd:consum:AVERAGE   LINE2:consum#00FF00:"Verbrauch [W]"
     53rrdtool graph web/consum_1month.png   -s 'now -1 month' -e 'now'   -Y -A   DEF:consum=power.rrd:consum:AVERAGE   LINE2:consum#00FF00:"Verbrauch [W]"
     54rrdtool graph web/consum_1year.png   -s 'now -1 year' -e 'now'   -Y -A   DEF:consum=power.rrd:consum:AVERAGE   LINE2:consum#00FF00:"Verbrauch [W]"
     55
     56rrdtool graph web/counter_1week.png   -s 'now -1 week' -e 'now'   -X 0 -Y -A   DEF:counter=power.rrd:counter:LAST   LINE2:counter#000000:"ZÀhlerstand [kWh]"
     57rrdtool graph web/counter_1month.png   -s 'now -1 month' -e 'now'   -X 0 -Y -A   DEF:counter=power.rrd:counter:LAST   LINE2:counter#000000:"ZÀhlerstand [kWh]"
  • de.wigbels.ruby/hothotread/hothotpiper.rb

    rb342b88 rc22952c  
    1919
    2020#------------------------------------------
    21 require 'net/http'
    2221require 'pi_piper'
    23 
    2422include PiPiper
    2523
     
    2725
    2826
     27def last_rrd_count
     28  val = 0.0
     29  handle = IO.popen("rrdtool lastupdate #{$mypath}/power.rrd")
     30  handle.each_line do |line|
     31    m = line.match("^[0-9]*: ([0-9.]*) [0-9.]*")
     32    if m
     33      val = m[1].to_f
     34      break
     35    end
     36  end
     37  return val
     38end
     39
     40
    2941watch :pin => 4, :trigger => :falling do
    3042  puts('added 10 liter of gas to sensor-database')
    31   Net::HTTP.get(URI.parse('http://www.wigbels.net/cgi-bin/hhw.rb?sensorid=1&data=10'))
    3243  system("rrdtool update #{$mypath}/gas.rrd N:10")
    3344end
    3445
     46watch :pin => 11, :trigger => :falling  do
     47  puts('updated power consumption')
     48  $counter = $counter + $trigger_step
     49  trigger_update = $trigger_step * 3600000.0
     50  system("rrdtool update #{$mypath}/power.rrd N:#{$counter}:#{trigger_update}")
     51end
     52
     53$trigger_step = 1.0 / 96
     54$counter = last_rrd_count
     55
    3556PiPiper.wait
  • de.wigbels.ruby/hothotread/web/index.html

    rb342b88 rc22952c  
    77<img src="gas_1woche.png">
    88<img src="gas_1monat.png">
     9<img src="gas_1jahr.png">
     10
     11<h2>Strom</h2>
     12<img src="consum_1day.png">
     13<img src="consum_1week.png">
     14<img src="consum_1month.png">
     15<img src="consum_1year.png">
     16<img src="counter_1month.png">
     17<img src="counter_1week.png">
    918
    1019</body>
Note: See TracChangeset for help on using the changeset viewer.