added Current Cost Smartmeter (thx to Roland: http://umweltsuende.wordpress.com/2010/09/16/klein-aber-fein/)
This commit is contained in:
parent
788684b3f3
commit
4a43fdc282
6 changed files with 145 additions and 0 deletions
5
controller/current_cost/README
Normal file
5
controller/current_cost/README
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
Koeln, 16.09.2010
|
||||||
|
Weitere Infos unter http://umweltsuen.de
|
||||||
|
oder bei
|
||||||
|
Roland Kletzing
|
||||||
|
devzero@web.de
|
30
controller/current_cost/create-rrd.sh
Executable file
30
controller/current_cost/create-rrd.sh
Executable file
|
@ -0,0 +1,30 @@
|
||||||
|
#!/bin/sh
|
||||||
|
rrdtool create /path/to/your/powertemp.rrd --step 5 \
|
||||||
|
DS:Power1:GAUGE:180:0:10000 \
|
||||||
|
DS:Power2:GAUGE:180:0:10000 \
|
||||||
|
DS:Power3:GAUGE:180:0:10000 \
|
||||||
|
DS:Temp:GAUGE:180:-50:100 \
|
||||||
|
RRA:AVERAGE:0.5:1:3200 \
|
||||||
|
RRA:AVERAGE:0.5:6:3200 \
|
||||||
|
RRA:AVERAGE:0.5:36:3200 \
|
||||||
|
RRA:AVERAGE:0.5:144:3200 \
|
||||||
|
RRA:AVERAGE:0.5:1008:3200 \
|
||||||
|
RRA:AVERAGE:0.5:4320:3200 \
|
||||||
|
RRA:AVERAGE:0.5:52560:3200 \
|
||||||
|
RRA:AVERAGE:0.5:525600:3200 \
|
||||||
|
RRA:MIN:0.5:1:3200 \
|
||||||
|
RRA:MIN:0.5:6:3200 \
|
||||||
|
RRA:MIN:0.5:36:3200 \
|
||||||
|
RRA:MIN:0.5:144:3200 \
|
||||||
|
RRA:MIN:0.5:1008:3200 \
|
||||||
|
RRA:MIN:0.5:4320:3200 \
|
||||||
|
RRA:MIN:0.5:52560:3200 \
|
||||||
|
RRA:MIN:0.5:525600:3200 \
|
||||||
|
RRA:MAX:0.5:1:3200 \
|
||||||
|
RRA:MAX:0.5:6:3200 \
|
||||||
|
RRA:MAX:0.5:36:3200 \
|
||||||
|
RRA:MAX:0.5:144:3200 \
|
||||||
|
RRA:MAX:0.5:1008:3200 \
|
||||||
|
RRA:MAX:0.5:4320:3200 \
|
||||||
|
RRA:MAX:0.5:52560:3200 \
|
||||||
|
RRA:MAX:0.5:525600:3200
|
14
controller/current_cost/crontab.example
Normal file
14
controller/current_cost/crontab.example
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
# Add these to your /etc/crontab. This is just an example. Change it to fit your needs
|
||||||
|
# make 15 minute graphs every minute
|
||||||
|
* * * * * root (touch /root/currentcost/15m.do)
|
||||||
|
# make hour graphs every 10 minutes
|
||||||
|
*/10 * * * * root (touch /root/currentcost/1h.do)
|
||||||
|
# make 12h graphs every half hour
|
||||||
|
*/30 * * * * root (touch /root/currentcost/12h.do)
|
||||||
|
# make day and week graph every full hour
|
||||||
|
0 * * * * root (touch /root/currentcost/1d.do)
|
||||||
|
0 * * * * root (touch /root/currentcost/1w.do)
|
||||||
|
# make month, quarter and year graphs once a day
|
||||||
|
0 0 * * * root (touch /root/currentcost/1m.do)
|
||||||
|
0 0 * * * root (touch /root/currentcost/3m.do)
|
||||||
|
0 0 * * * root (touch /root/currentcost/1y.do)
|
2
controller/current_cost/doall.sh
Executable file
2
controller/current_cost/doall.sh
Executable file
|
@ -0,0 +1,2 @@
|
||||||
|
#!/bin/bash
|
||||||
|
touch 15m.do 1h.do 12h.do 1d.do 1w.do 1m.do 3m.do 1y.do
|
34
controller/current_cost/fetchdata.pl
Executable file
34
controller/current_cost/fetchdata.pl
Executable file
|
@ -0,0 +1,34 @@
|
||||||
|
#!/usr/bin/perl -w
|
||||||
|
# This program reads data from a Current Cost device via serial port and puts it into an RRD database (also prints on console)
|
||||||
|
|
||||||
|
#Avoid Line buffering for stdout. Avoids problems when sending the script output to a pipe
|
||||||
|
local $| = 1;
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use Device::SerialPort qw( :PARAM :STAT 0.07 );
|
||||||
|
|
||||||
|
#USB (change into /dev/ttyS0 for Serial port)
|
||||||
|
my $PORT = "/dev/ttyUSB0";
|
||||||
|
|
||||||
|
my $ob = Device::SerialPort->new($PORT);
|
||||||
|
|
||||||
|
# change into appropriate baudrate. Envi classic needs $ob->baudrate(57600);
|
||||||
|
$ob->baudrate(57600);
|
||||||
|
$ob->write_settings;
|
||||||
|
|
||||||
|
open(SERIAL, "+>$PORT");
|
||||||
|
while (my $line = <SERIAL>) {
|
||||||
|
|
||||||
|
# Envi White old
|
||||||
|
# if ($line =~ m!<ch1><watts>0*(\d+)</watts></ch1>.*<ch2><watts>0*(\d+)</watts></ch2>.*<ch3><watts>0*(\d+)</watts></ch3><tmpr> *([\-\d.]+)</tmpr>!) {
|
||||||
|
|
||||||
|
#Envi Black >CC128-v0.12
|
||||||
|
if ($line =~ m!<tmpr> *([\-\d.]+)</tmpr>.*<ch1><watts>0*(\d+)</watts></ch1>.*<ch2><watts>0*(\d+)</watts></ch2>.*<ch3><watts>0*(\d+)</watts></ch3>!) {
|
||||||
|
my $watts1 = $2;
|
||||||
|
my $watts2 = $3;
|
||||||
|
my $watts3 = $4;
|
||||||
|
my $temp = $1;
|
||||||
|
print "$watts1, $watts2, $watts3, $temp\n";
|
||||||
|
system("rrdupdate","/path/to/your/powertemp.rrd","N:$watts1:$watts2:$watts3:$temp");
|
||||||
|
}
|
||||||
|
}
|
60
controller/current_cost/makegraphs.sh
Executable file
60
controller/current_cost/makegraphs.sh
Executable file
|
@ -0,0 +1,60 @@
|
||||||
|
#!/bin/bash
|
||||||
|
set -x
|
||||||
|
|
||||||
|
export LC_ALL=de_DE.UTF-8
|
||||||
|
|
||||||
|
export param1='--end now --width 880 --height 300 --slope-mode --vertical-label VoltAmpere --lower-limit 0 --alt-autoscale-max'
|
||||||
|
|
||||||
|
export param2='DEF:Power1=powertemp.rrd:Power1:AVERAGE
|
||||||
|
DEF:Power2=powertemp.rrd:Power2:AVERAGE
|
||||||
|
DEF:Power3=powertemp.rrd:Power3:AVERAGE
|
||||||
|
CDEF:Ln1=Power1,Power1,UNKN,IF
|
||||||
|
CDEF:Ln2=Power1,Power1,Power2,+,UNKN,IF
|
||||||
|
CDEF:Ln3=Power3,Power1,Power2,Power3,+,+,UNKN,IF
|
||||||
|
AREA:Power1#A0A0FF:Phase1
|
||||||
|
AREA:Power2#A0FFA0:Phase2:STACK
|
||||||
|
AREA:Power3#FFA0A0:Phase3\j:STACK
|
||||||
|
LINE1:Ln3#AA0000
|
||||||
|
LINE1:Ln2#00AA00
|
||||||
|
LINE1:Ln1#0000AA'
|
||||||
|
|
||||||
|
export param3='GPRINT:Power1:LAST:%2.1lf%sVA
|
||||||
|
GPRINT:Power2:LAST:%2.1lf%sVA
|
||||||
|
GPRINT:Power3:LAST:%2.1lf%sVA\j'
|
||||||
|
|
||||||
|
export basepath='/path/to/your/webserver/htdocs/asubdir'
|
||||||
|
|
||||||
|
get-ts () {
|
||||||
|
export ts=`date +"Graph vom %A, %d.%m.%Y um %H:%M Uhr"`
|
||||||
|
}
|
||||||
|
|
||||||
|
mvimg () {
|
||||||
|
rm $basepath/$1
|
||||||
|
mv $basepath/tmp.png $basepath/$1
|
||||||
|
}
|
||||||
|
|
||||||
|
mkimg () {
|
||||||
|
if [ -e "$1.do" ];then
|
||||||
|
rm $1.do
|
||||||
|
get-ts
|
||||||
|
title="Energieverbrauch $2 - $ts"
|
||||||
|
if [ $1 == "15m" ];then
|
||||||
|
rrdtool graph $basepath/tmp.png --title "$title" --start end-$1 $param1 $param2 $param3
|
||||||
|
else
|
||||||
|
rrdtool graph $basepath/tmp.png --title "$title" --start end-$1 $param1 $param2
|
||||||
|
fi
|
||||||
|
mvimg power-$1.png
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
while true;do
|
||||||
|
mkimg 15m "letzte 15 Minuten"
|
||||||
|
mkimg 1h "letzte Stunde"
|
||||||
|
mkimg 12h "letzte 12 Stunden"
|
||||||
|
mkimg 1d "letzter Tag"
|
||||||
|
mkimg 1w "letzte Woche"
|
||||||
|
mkimg 1m "letzter Monat"
|
||||||
|
mkimg 3m "letztes Quartal"
|
||||||
|
mkimg 1y "letztes Jahr"
|
||||||
|
sleep 10;
|
||||||
|
done
|
Loading…
Add table
Reference in a new issue