From 1f91e592c0b97dc315335417f323d31ca028782a Mon Sep 17 00:00:00 2001 From: James <31272717+gpd-pocket-hacker@users.noreply.github.com> Date: Mon, 25 Jan 2021 16:28:27 +0000 Subject: fish --- piano-alarm/mt300-v2/usr/bin/piano_alarm | 50 ++++++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 6 deletions(-) (limited to 'piano-alarm/mt300-v2/usr/bin/piano_alarm') diff --git a/piano-alarm/mt300-v2/usr/bin/piano_alarm b/piano-alarm/mt300-v2/usr/bin/piano_alarm index de5677c..b82f147 100755 --- a/piano-alarm/mt300-v2/usr/bin/piano_alarm +++ b/piano-alarm/mt300-v2/usr/bin/piano_alarm @@ -9,47 +9,85 @@ echo -e "Subject: 41hpa piano alarm: ${STATE} \n\nPiano alarm at 41hpa says ${ST TL=17000 TH=22000 -HL=450 +HL=400 HH=700 T=`sensor.pl -t -i` H=`sensor.pl -h -i` - -exit 0 +TANK="$(mosquitto_sub -h 10.32.136.1 -p 1883 -t stat/music_room_humidifier/var3 -W 1 -C 1 )" BAD=0 +M="" + if [ -z "$T" ]; then + if [ ! -z "$M" ]; then + M="${M}, " + fi + M="${M}failed to read temperature" BAD=1 fi + if [ -z "$H" ]; then + if [ ! -z "$M" ]; then + M="${M}, " + fi + M="${M}failed to read humidity" BAD=1 fi if [ "$T" -lt "$TL" ]; then + if [ ! -z "$M" ]; then + M="${M}, " + fi + M="${M}temperature too low $T<$TL" BAD=1 fi if [ "$T" -gt "$TH" ]; then + if [ ! -z "$M" ]; then + M="${M}, " + fi + M="${M}temperature too high $T>$TH" BAD=1 fi if [ "$H" -lt "$HL" ]; then + if [ ! -z "$M" ]; then + M="${M}, " + fi + M="${M}air too dry $H<$HL" BAD=1 fi if [ "$H" -gt "$HH" ]; then + if [ ! -z "$M" ]; then + M="${M}, " + fi + M="${M}air too wet $H>$HH" BAD=1 fi if [ "$1" == "test" ]; then + if [ ! -z "$M" ]; then + M="${M}, " + fi + M="${M}test" + BAD=1 +fi + +if [ $TANK -eq 0 ]; then + if [ ! -z "$M" ]; then + M="${M}, " + fi + M="${M}humidifier tank is empty" BAD=1 fi if [ "$BAD" -eq 1 ]; then - message "T=$T (should be $TL-$TH) H=$H (should be $HL-$HH)" + message "$M" fi -echo "piano_alarm T=$T H=$H" -logger "piano_alarm T=$T H=$H" +echo "piano_alarm T=$T H=$H TANK=$TANK M=$M" +logger "piano_alarm T=$T H=$H TANK=$TANK M=$M" -- cgit v1.2.3