Index: de.wigbels.ruby/hothotread/archiv/hothotread.rb
===================================================================
--- de.wigbels.ruby/hothotread/archiv/hothotread.rb	(revision c22952c4202a07f37011af02109e36879aa94a21)
+++ de.wigbels.ruby/hothotread/archiv/hothotread.rb	(revision c22952c4202a07f37011af02109e36879aa94a21)
@@ -0,0 +1,79 @@
+#!/usr/bin/env ruby
+#
+# Author: Norbert Wigbels - foobla.wigbels.de/uber-foobla
+#
+# HotHotRead continously reads the status of a
+# reed contact attached to the avr-net-io
+#
+# The reed measures gas usage.
+#
+# A magig URL is formed and called; the url
+# stores the sensor-data to wigbels.net
+#
+# todo: status-led
+# 
+
+#------------------------------------------
+# Tainted mode 0-4
+$SAFE=0
+
+
+#------------------------------------------
+require 'logger'
+require 'socket'
+require 'net/http'
+
+#------------------------------------------
+class HotHotRead < Logger::Application
+  attr_accessor :socket, :socketaddr
+
+  def initialize(application_name)
+    super(application_name)
+    @socket = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
+    @sockaddr = Socket.sockaddr_in(2701, '192.168.14.42')
+  end
+
+  def run
+    begin
+      @socket.connect(@sockaddr)
+      high2low = false;
+      while true do
+        @socket.print "io get pin 0\r\n"
+        rawdata = @socket.recvfrom(128)
+        # data contains "port 0: 0xfe"; extract last part
+        data = rawdata.to_s.split(" ")[2]
+        # we are only interested in the changes from high to low of the reed sensor
+        if (data=="0xff")
+          high2low = true
+        else
+          if (high2low==true)
+            high2low = false
+            Net::HTTP.get(URI.parse('http://www.wigbels.net/cgi-bin/hhw.rb?sensorid=1&data=10'))
+            # fixme: response.body auswerten
+            # bei fehler, lokales backlog schreibe 
+            log(INFO, 'added 100 liter of gas to sensor-database')
+          end
+        end
+        sleep(0.2)
+      end
+      # and terminate the connection when we're done
+    rescue => msg
+      log(ERROR, "error: #{msg}")
+      retry
+    ensure
+      @socket.close
+    end
+    #puts "Filename: "+__FILE__.to_s
+    #puts "Linenumber: "+__LINE__.to_s
+    #log(WARN, 'warning',  'mymethod' )
+    #@log.error('my_method2') { 'Error!' }
+  end
+end
+
+
+#------------------------------------------
+status = HotHotRead.new("HotHotRead").start
+
+#if status != 0
+#  puts "Some error occured."
+#end
Index: de.wigbels.ruby/hothotread/archiv/sockconnect.rb
===================================================================
--- de.wigbels.ruby/hothotread/archiv/sockconnect.rb	(revision c22952c4202a07f37011af02109e36879aa94a21)
+++ de.wigbels.ruby/hothotread/archiv/sockconnect.rb	(revision c22952c4202a07f37011af02109e36879aa94a21)
@@ -0,0 +1,16 @@
+require 'socket'
+
+s = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
+sockaddr = Socket.sockaddr_in(2701, '192.168.14.42')
+begin
+s.connect(sockaddr)
+rescue
+    puts "error: #{$!}"
+else
+    s.print "version\r\n"
+    data = s.recvfrom(1024)
+    puts data
+    # and terminate the connection when we're done
+    s.close
+end
+
Index: de.wigbels.ruby/hothotread/bla.rb
===================================================================
--- de.wigbels.ruby/hothotread/bla.rb	(revision 53aed1c15da58c982558a390c0ef178f64c0c16e)
+++ 	(revision )
@@ -1,16 +1,0 @@
-require 'socket'
-
-s = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
-sockaddr = Socket.sockaddr_in(2701, '192.168.14.42')
-begin
-s.connect(sockaddr)
-rescue
-    puts "error: #{$!}"
-else
-    s.print "version\r\n"
-    data = s.recvfrom(1024)
-    puts data
-    # and terminate the connection when we're done
-    s.close
-end
-
Index: de.wigbels.ruby/hothotread/draw_graphs.sh
===================================================================
--- de.wigbels.ruby/hothotread/draw_graphs.sh	(revision 53aed1c15da58c982558a390c0ef178f64c0c16e)
+++ de.wigbels.ruby/hothotread/draw_graphs.sh	(revision c22952c4202a07f37011af02109e36879aa94a21)
@@ -11,5 +11,5 @@
 CDEF:gash=gas,120,* \
 VDEF:gastotal=gas,TOTAL \
-GPRINT:gastotal:"Total %6.0lf m3 Gas" \
+GPRINT:gastotal:"Total %6.0lf Liter Gas" \
 LINE2:gash#c17d11:"Gasverbrauch"
 
@@ -22,5 +22,5 @@
 CDEF:gasd=gas,2880,* \
 VDEF:gastotal=gas,TOTAL \
-GPRINT:gastotal:"Total %6.0lf m3 Gas" \
+GPRINT:gastotal:"Total %6.0lf Liter Gas" \
 LINE2:gasd#c17d11:"Gasverbrauch/Tag"
 
@@ -33,5 +33,25 @@
 CDEF:gasd=gas,2880,* \
 VDEF:gastotal=gas,TOTAL \
-GPRINT:gastotal:"Total %6.0lf m3 Gas" \
+GPRINT:gastotal:"Total %6.0lf Liter Gas" \
 LINE2:gasd#c17d11:"Gasverbrauch/Tag"
 
+rrdtool graph web/gas_1jahr.png \
+-w 800 -h 500 \
+-s 'now - 1 year' -e 'now' \
+--title "Gasverbrauch im Jahresverlauf" \
+--font TITLE:12 --vertical-label="Liter/Tag" \
+DEF:gas=gas.rrd:gas:AVERAGE \
+CDEF:gasd=gas,2880,* \
+VDEF:gastotal=gas,TOTAL \
+GPRINT:gastotal:"Total %6.0lf Liter Gas" \
+LINE2:gasd#c17d11:"Gasverbrauch/Tag"
+
+
+
+rrdtool graph web/consum_1day.png   -s 'now -1 day' -e 'now'   -Y -A   DEF:consum=power.rrd:consum:AVERAGE   LINE2:consum#00FF00:"Verbrauch [W]"
+rrdtool graph web/consum_1week.png   -s 'now -1 week' -e 'now'   -Y -A   DEF:consum=power.rrd:consum:AVERAGE   LINE2:consum#00FF00:"Verbrauch [W]"
+rrdtool graph web/consum_1month.png   -s 'now -1 month' -e 'now'   -Y -A   DEF:consum=power.rrd:consum:AVERAGE   LINE2:consum#00FF00:"Verbrauch [W]"
+rrdtool graph web/consum_1year.png   -s 'now -1 year' -e 'now'   -Y -A   DEF:consum=power.rrd:consum:AVERAGE   LINE2:consum#00FF00:"Verbrauch [W]"
+
+rrdtool 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]"
+rrdtool 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]"
Index: de.wigbels.ruby/hothotread/hothotpiper.rb
===================================================================
--- de.wigbels.ruby/hothotread/hothotpiper.rb	(revision 53aed1c15da58c982558a390c0ef178f64c0c16e)
+++ de.wigbels.ruby/hothotread/hothotpiper.rb	(revision c22952c4202a07f37011af02109e36879aa94a21)
@@ -19,7 +19,5 @@
 
 #------------------------------------------
-require 'net/http'
 require 'pi_piper'
-
 include PiPiper
 
@@ -27,9 +25,32 @@
 
 
+def last_rrd_count
+  val = 0.0
+  handle = IO.popen("rrdtool lastupdate #{$mypath}/power.rrd")
+  handle.each_line do |line|
+    m = line.match("^[0-9]*: ([0-9.]*) [0-9.]*")
+    if m
+      val = m[1].to_f
+      break
+    end
+  end
+  return val
+end
+
+
 watch :pin => 4, :trigger => :falling do 
   puts('added 10 liter of gas to sensor-database')
-  Net::HTTP.get(URI.parse('http://www.wigbels.net/cgi-bin/hhw.rb?sensorid=1&data=10'))
   system("rrdtool update #{$mypath}/gas.rrd N:10")
 end
 
+watch :pin => 11, :trigger => :falling  do
+  puts('updated power consumption')
+  $counter = $counter + $trigger_step
+  trigger_update = $trigger_step * 3600000.0
+  system("rrdtool update #{$mypath}/power.rrd N:#{$counter}:#{trigger_update}")
+end
+
+$trigger_step = 1.0 / 96
+$counter = last_rrd_count
+
 PiPiper.wait
Index: de.wigbels.ruby/hothotread/hothotread.rb
===================================================================
--- de.wigbels.ruby/hothotread/hothotread.rb	(revision 53aed1c15da58c982558a390c0ef178f64c0c16e)
+++ 	(revision )
@@ -1,79 +1,0 @@
-#!/usr/bin/env ruby
-#
-# Author: Norbert Wigbels - foobla.wigbels.de/uber-foobla
-#
-# HotHotRead continously reads the status of a
-# reed contact attached to the avr-net-io
-#
-# The reed measures gas usage.
-#
-# A magig URL is formed and called; the url
-# stores the sensor-data to wigbels.net
-#
-# todo: status-led
-# 
-
-#------------------------------------------
-# Tainted mode 0-4
-$SAFE=0
-
-
-#------------------------------------------
-require 'logger'
-require 'socket'
-require 'net/http'
-
-#------------------------------------------
-class HotHotRead < Logger::Application
-  attr_accessor :socket, :socketaddr
-
-  def initialize(application_name)
-    super(application_name)
-    @socket = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
-    @sockaddr = Socket.sockaddr_in(2701, '192.168.14.42')
-  end
-
-  def run
-    begin
-      @socket.connect(@sockaddr)
-      high2low = false;
-      while true do
-        @socket.print "io get pin 0\r\n"
-        rawdata = @socket.recvfrom(128)
-        # data contains "port 0: 0xfe"; extract last part
-        data = rawdata.to_s.split(" ")[2]
-        # we are only interested in the changes from high to low of the reed sensor
-        if (data=="0xff")
-          high2low = true
-        else
-          if (high2low==true)
-            high2low = false
-            Net::HTTP.get(URI.parse('http://www.wigbels.net/cgi-bin/hhw.rb?sensorid=1&data=10'))
-            # fixme: response.body auswerten
-            # bei fehler, lokales backlog schreibe 
-            log(INFO, 'added 100 liter of gas to sensor-database')
-          end
-        end
-        sleep(0.2)
-      end
-      # and terminate the connection when we're done
-    rescue => msg
-      log(ERROR, "error: #{msg}")
-      retry
-    ensure
-      @socket.close
-    end
-    #puts "Filename: "+__FILE__.to_s
-    #puts "Linenumber: "+__LINE__.to_s
-    #log(WARN, 'warning',  'mymethod' )
-    #@log.error('my_method2') { 'Error!' }
-  end
-end
-
-
-#------------------------------------------
-status = HotHotRead.new("HotHotRead").start
-
-#if status != 0
-#  puts "Some error occured."
-#end
Index: de.wigbels.ruby/hothotread/info/created_rrd_engergy_through
===================================================================
--- de.wigbels.ruby/hothotread/info/created_rrd_engergy_through	(revision c22952c4202a07f37011af02109e36879aa94a21)
+++ de.wigbels.ruby/hothotread/info/created_rrd_engergy_through	(revision c22952c4202a07f37011af02109e36879aa94a21)
@@ -0,0 +1,10 @@
+rrdtool create power.rrd --step 60 --no-overwrite \
+DS:counter:GAUGE:86400:0:1000000 \
+DS:consum:ABSOLUTE:86400:0:1000000 \
+RRA:LAST:0.5:1:4320 \
+RRA:AVERAGE:0.5:1:4320 \
+RRA:LAST:0.5:1440:30 \
+RRA:AVERAGE:0.5:1440:30 \
+RRA:LAST:0.5:10080:520 \
+RRA:AVERAGE:0.5:10080:520 
+
Index: de.wigbels.ruby/hothotread/lastupdate.rb
===================================================================
--- de.wigbels.ruby/hothotread/lastupdate.rb	(revision c22952c4202a07f37011af02109e36879aa94a21)
+++ de.wigbels.ruby/hothotread/lastupdate.rb	(revision c22952c4202a07f37011af02109e36879aa94a21)
@@ -0,0 +1,14 @@
+def last_rrd_count
+  val = 0.0
+  handle = IO.popen("rrdtool lastupdate power.rrd")
+  handle.each_line do |line|
+    m = line.match("^[0-9]*: ([0-9.]*) [0-9.]*")
+    if m
+      val = m[1].to_f
+      break
+    end
+  end
+  return val
+end
+
+puts last_rrd_count
Index: de.wigbels.ruby/hothotread/web/index.html
===================================================================
--- de.wigbels.ruby/hothotread/web/index.html	(revision 53aed1c15da58c982558a390c0ef178f64c0c16e)
+++ de.wigbels.ruby/hothotread/web/index.html	(revision c22952c4202a07f37011af02109e36879aa94a21)
@@ -7,4 +7,13 @@
 <img src="gas_1woche.png">
 <img src="gas_1monat.png">
+<img src="gas_1jahr.png">
+
+<h2>Strom</h2>
+<img src="consum_1day.png">
+<img src="consum_1week.png">
+<img src="consum_1month.png">
+<img src="consum_1year.png">
+<img src="counter_1month.png">
+<img src="counter_1week.png">
 
 </body>
