Created
October 26, 2023 05:29
Revisions
-
tomasinouk created this gist
Oct 26, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,87 @@ PHONE1=+61423207744 PHONE2=+6141038##### BIN0_TEXT_OUT_OFF="OUT_0 is set to 1" BIN0_TEXT_OUT_ON="OUT_0 is set to 0" for i in $PHONE1 $PHONE2; do logger -t "SMS_COMMAND" "Have these phone no $i" done GO="no" case $2 in $PHONE1 | $PHONE2) echo yes GO="yes" ;; *) echo no ;; esac logger -t "SMS_COMMAND" "GO var is $GO" echo $GO logger -t "SMS_COMMAND" "Got sms from $2 with text:$3" # for i in $PHONE1 $PHONE2; # do # echo $i # logger -t "SMS_COMMAND" "doing $i" if [ "$1" = "1" ] || [ "$GO" = "yes" ]; then logger -t "SMS_COMMAND" "passed 1st if" # this if statement pulses the out0 to a 1 for 5 seconds then back to a 0 if [ "$3" = "IMPULSE" ]; then logger -t "SMS_COMMAND" "Set out0 to 1" /usr/bin/io set out0 1 for i in $PHONE1 $PHONE2 do /usr/bin/sms "$i" "$BIN0_TEXT_OUT_ON" done # /usr/bin/sms "io st to 1" logger -t "SMS_COMMAND" "Sleeping for 5 sec" sleep 5 /usr/bin/io set out0 0 for i in $PHONE1 $PHONE2 do sms "$i" "$BIN0_TEXT_OUT_OFF" done # /usr/bin/sms "io st to 0" logger -t "SMS_COMMAND" "Done sleeping for 5 sec out0 to 0" elif [ "$3" = "ON" ]; then logger -t "SMS_COMMAND" "ALARM TURNING ON" /usr/bin/io set out0 0 for i in $PHONE1 $PHONE2 do /usr/bin/sms "$i" "PIR ALARM TURNED ON - out0 = 0" done # /usr/bin/sms $i "PIR ALARM TURNED ON - out0 = 0" logger -t "SMS_COMMAND" "ALARM TURNED ON" # this statement sets the output to a 1 elif [ "$3" = "OFF" ]; then /usr/bin/io set out0 1 for i in $PHONE1 $PHONE2 do /usr/bin/sms "$i" "PIR ALARM TURNED OFF - out0 = 1" done # /usr/bin/sms $i "PIR ALARM TURNED OFF - out0 = 1" logger -t "SMS_COMMAND" "ALARM TURNED OFF" # gets system voltage elif [ "$3" = "VOLT" ]; then svolt=$(status -v sys | grep Supply) volt=$(status -v sys | grep Supply | grep -Eo '[+-]?[0-9]+([.][0-9]+)?') pvolt=$(printf “%f” $volt) # /usr/bin/sms $i “\${volt}” for i in $PHONE1 $PHONE2 do /usr/bin/sms "$i" "${svolt}" done logger -t "SMS_COMMAND" "System Voltage ${svolt}" fi fi