summaryrefslogtreecommitdiffstats
path: root/piano-alarm/mt300-v2/usr/bin/piano_alarm
diff options
context:
space:
mode:
Diffstat (limited to 'piano-alarm/mt300-v2/usr/bin/piano_alarm')
-rwxr-xr-xpiano-alarm/mt300-v2/usr/bin/piano_alarm55
1 files changed, 55 insertions, 0 deletions
diff --git a/piano-alarm/mt300-v2/usr/bin/piano_alarm b/piano-alarm/mt300-v2/usr/bin/piano_alarm
new file mode 100755
index 0000000..de5677c
--- /dev/null
+++ b/piano-alarm/mt300-v2/usr/bin/piano_alarm
@@ -0,0 +1,55 @@
+#!/bin/sh
+
+message()
+{
+STATE="$1"
+echo -e "Subject: 41hpa piano alarm: ${STATE} \n\nPiano alarm at 41hpa says ${STATE}.\n" | /usr/sbin/sendmail -f "Piano Alarm <piano-alarm@ourano.org>" monitoring@madingley.org
+}
+
+TL=17000
+TH=22000
+
+HL=450
+HH=700
+
+T=`sensor.pl -t -i`
+H=`sensor.pl -h -i`
+
+exit 0
+
+BAD=0
+
+if [ -z "$T" ]; then
+ BAD=1
+fi
+if [ -z "$H" ]; then
+ BAD=1
+fi
+
+if [ "$T" -lt "$TL" ]; then
+ BAD=1
+fi
+if [ "$T" -gt "$TH" ]; then
+ BAD=1
+fi
+
+if [ "$H" -lt "$HL" ]; then
+ BAD=1
+fi
+
+if [ "$H" -gt "$HH" ]; then
+ BAD=1
+fi
+
+if [ "$1" == "test" ]; then
+ BAD=1
+fi
+
+if [ "$BAD" -eq 1 ]; then
+ message "T=$T (should be $TL-$TH) H=$H (should be $HL-$HH)"
+fi
+
+echo "piano_alarm T=$T H=$H"
+logger "piano_alarm T=$T H=$H"
+
+