diff --git a/power.py b/pi/power.py similarity index 72% rename from power.py rename to pi/power.py index 944dc0a..ad6ce92 100755 --- a/power.py +++ b/pi/power.py @@ -1,4 +1,4 @@ -#/usr/bin/python +#!/usr/bin/python import RPi.GPIO as GPIO import time @@ -26,12 +26,12 @@ while True: #write into logfile - if (power < lpower + 3500): - out = str(current) + ";" + str(round(power,0)) - else: - out = str(current) + ";0" + #if (power < lpower + 1800): + out = str(current) + ";" + str(round(power,0)) + #else: + # out = str(current) + ";" + str(round(lpower,0)) payload = {"val": out} - r = requests.post("https://strom.ccc-ffm.de/test.php", data=payload, verify=False) + r = requests.post("https://strom.ccc-ffm.de/get.php", data=payload, verify=False) lpower = power last = current GPIO.cleanup() diff --git a/powerpi b/pi/powerpi similarity index 100% rename from powerpi rename to pi/powerpi diff --git a/powertrans b/powertrans deleted file mode 100755 index 403929c..0000000 --- a/powertrans +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/sh - -### BEGIN INIT INFO -# Provides: powertrans -# Required-Start: $remote_fs $syslog -# Required-Stop: $remote_fs $syslog -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: Put a short description of the service here -# Description: Put a long description of the service here -### END INIT INFO - -# Change the next 3 lines to suit where you install your script and what you want to call it -DIR=/srv/powerpi -DAEMON=$DIR/transfer.sh -DAEMON_NAME=PowerTrans - -# Add any command line options for your daemon here -DAEMON_OPTS="" - -# This next line determines what user the script runs as. -# Root generally not recommended but necessary if you are using the Raspberry Pi GPIO from Python. -DAEMON_USER=pi - -# The process ID of the script when it runs is stored here: -PIDFILE=/var/run/$DAEMON_NAME.pid - -. /lib/lsb/init-functions - -do_start () { -log_daemon_msg "Starting system $DAEMON_NAME daemon" -start-stop-daemon --start --background --pidfile $PIDFILE --make-pidfile --user $DAEMON_USER --chuid $DAEMON_USER --startas $DAEMON -- $DAEMON_OPTS -log_end_msg $? -} -do_stop () { -log_daemon_msg "Stopping system $DAEMON_NAME daemon" -start-stop-daemon --stop --pidfile $PIDFILE --retry 10 -log_end_msg $? -} - -case "$1" in - -start|stop) -do_${1} -;; - -restart|reload|force-reload) -do_stop -do_start -;; - -status) -status_of_proc "$DAEMON_NAME" "$DAEMON" && exit 0 || exit $? -;; -*) -echo "Usage: /etc/init.d/$DAEMON_NAME {start|stop|restart|status}" -exit 1 -;; - -esac -exit 0 diff --git a/server/create_rrd b/server/create_rrd new file mode 100644 index 0000000..7a9f708 --- /dev/null +++ b/server/create_rrd @@ -0,0 +1,7 @@ +rrdtool create power2.rrd \ +--step '5' \ +'DS:power:GAUGE:90:U:U' \ +'RRA:AVERAGE:0.5:1:720' \ +'RRA:AVERAGE:0.5:6:1440' \ +'RRA:AVERAGE:0.5:6:2880' \ +'RRA:AVERAGE:0.5:12:10080' diff --git a/server/get.php b/server/get.php new file mode 100644 index 0000000..c1a8295 --- /dev/null +++ b/server/get.php @@ -0,0 +1,14 @@ +update(array("power" => $val[1]), $val[0]); + $fileh = fopen("power.log", "w+"); + fwrite($fileh, $_POST['val']); + fclose($fileh); + echo "0"; + } else { + echo "1"; + } + +?> diff --git a/server/index.php b/server/index.php new file mode 100644 index 0000000..584f83e --- /dev/null +++ b/server/index.php @@ -0,0 +1,65 @@ + + + + + Stromverbrauch HQ + + + + + + +

Aktueller Stromverbrauch im HQ

+ +
+
Zeitpunkt:
+
+
Leistung:
+
Watt
+ +
+
+
+ Plot der letzten Stunde
+ Leistung geplottet über die Zeit
+ Plot der letzten 12 Stunden
+ Leistung geplottet über die Zeit
+ Plot der letzten 24 Stunden
+ Leistung geplottet über die Zeit
+ Plot der letzten Woche
+ Leistung geplottet über die Zeit
+ Plot des letzten Monats
+ Leistung geplottet über die Zeit
+ Plot des letzten Quartals
+ Leistung geplottet über die Zeit
+ Plot des letzten Jahres
+ Leistung geplottet über die Zeit
+ + diff --git a/server/power.log b/server/power.log new file mode 100644 index 0000000..78600a2 --- /dev/null +++ b/server/power.log @@ -0,0 +1 @@ +1427048612.32;421.0 \ No newline at end of file diff --git a/server/power.rrd b/server/power.rrd new file mode 100644 index 0000000..31e04b5 Binary files /dev/null and b/server/power.rrd differ diff --git a/transfer.sh b/transfer.sh deleted file mode 100755 index e50b357..0000000 --- a/transfer.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -host="http://datengammelstelle.de/hq_strom" - -while true; do - sleep 5; - wget $host/get.php?val=$(tail -1 /srv/powerpi/power.out) -O /dev/null -q -done