diff --git a/scripts/doorbuzz_wrapper.sh b/scripts/doorbuzz_wrapper.sh index b8f2ad3..e4c0403 100755 --- a/scripts/doorbuzz_wrapper.sh +++ b/scripts/doorbuzz_wrapper.sh @@ -13,13 +13,15 @@ do then logger -t $(basename $0) "phone status change detected" logger -t $(basename $0) "phone ring light on" - /usr/local/bin/433send 2 15 1 1 >&2 + $(dirname "$0")/lightcommander alarm on >&2 + #/usr/local/bin/433send 2 15 1 1 >&2 fi if [ "$cmd" = "flashoff" ] then logger -t $(basename $0) "phone status change detected" logger -t $(basename $0) "phone ring light off" - /usr/local/bin/433send 2 15 1 0 >&2 + $(dirname "$0")/lightcommander alarm off >&2 + #/usr/local/bin/433send 2 15 1 0 >&2 fi done diff --git a/scripts/lightcommander b/scripts/lightcommander new file mode 100755 index 0000000..5c9edce --- /dev/null +++ b/scripts/lightcommander @@ -0,0 +1,42 @@ +#!/bin/bash +if [ "$1" = "" ] +then + echo "usage: $0 {main|chill|status|labsocket|alarm} {on|off}" + exit 1 +fi +function dolight() { + if [ "$2" = "on" ] + then + setvalue=1 + else + setvalue=0 + fi + case "$1" in + all) dolight "main" $2 + dolight "status" $2 + dolight "labsocket" $2 + dolight "alarm" $2 + ;; + main) /usr/local/bin/433send 2 1A 1 "$setvalue" + ;; + chill) /usr/local/bin/433send 2 1A 2 "$setvalue" + ;; + status) /usr/local/bin/433send 2 2A 1 "$setvalue" + ;; + labsocket) /usr/local/bin/433send 2 15A 6 "$setvalue" + ;; + alarm) /usr/local/bin/433send 2 15A 1 "$setvalue" + ;; + esac + # type (2=10bit) + # | house 1-16 (the dial thingie) + # | |group A-P (the dial thingie) + # | || unit (1-16) (the button, usually 1-4) + # | || | on/off + # | || | | + #/usr/local/bin/433send 2 1A 1 1 #on + #/usr/local/bin/433send 2 1A 1 0 #off +} + +logger -t $(basename $0) "$$ $1 $2" +dolight "$1" "$2" diff --git a/scripts/lockbutton.sh.d/lights b/scripts/lockbutton.sh.d/lights index bff8d7d..a8db602 100755 --- a/scripts/lockbutton.sh.d/lights +++ b/scripts/lockbutton.sh.d/lights @@ -9,18 +9,20 @@ if ( [ "$1" = "pushed" ] || [ "$1" = "closed" ] ) && [ "$(stat -c %Y /run/doorlockbutton)" -gt "$(date --date "5 minutes ago" +%s)" ] then logger -t $(basename $0) "switching all lights off" - for i in {1..16} - do - for j in {1..16} - do - /usr/local/bin/433send 2 $j $i 0 #off - done - done +# for i in {1..16} +# do +# for j in {1..16} +# do + $(dirname "$0")/../lightcommander all off + # /usr/local/bin/433send 2 $j $i 0 #off +# done +# done logger -t $(basename $0) "all lights should be off now" fi if [ "$1" = "released" ] then # switch status lights on, in any case - /usr/local/bin/433send 2 2A 1 1 #on + $(dirname "$0")/../lightcommander status on + # /usr/local/bin/433send 2 2A 1 1 #on fi if [ "$1" = "released" ] && # the door has been opened # [ "$(cat /run/spacestatus)" = "open" ] && # status is open @@ -29,7 +31,8 @@ if [ "$1" = "released" ] && # the door has been opened then #( [ "$(date +%H)" -gt 18 ] || [ "$(date +%H)" -lt 8 ] ) logger -t $(basename $0) "switching some lights on" - /usr/local/bin/433send 2 1A 1 1 #on + $(dirname "$0")/../lightcommander main on + # /usr/local/bin/433send 2 1A 1 1 #on fi # type (2=10bit) diff --git a/scripts/phone_notification.sh b/scripts/phone_notification.sh index e43b868..3c9da25 100755 --- a/scripts/phone_notification.sh +++ b/scripts/phone_notification.sh @@ -23,10 +23,12 @@ do logger -t $(basename $0) "phone status change detected" if [ "$new_status" -eq 0 ]; then logger -t $(basename $0) "phone ring light on" - /usr/local/bin/433send 2 15 1 1 + $(dirname "$0")/lightcommander alarm on + #/usr/local/bin/433send 2 15 1 1 else logger -t $(basename $0) "phone ring light off" - /usr/local/bin/433send 2 15 1 0 + $(dirname "$0")/lightcommander alarm off + #/usr/local/bin/433send 2 15 1 0 fi echo $new_status > ${run_file} fi diff --git a/scripts/upd_status.sh.d/lights b/scripts/upd_status.sh.d/lights index bff8d7d..a8db602 100755 --- a/scripts/upd_status.sh.d/lights +++ b/scripts/upd_status.sh.d/lights @@ -9,18 +9,20 @@ if ( [ "$1" = "pushed" ] || [ "$1" = "closed" ] ) && [ "$(stat -c %Y /run/doorlockbutton)" -gt "$(date --date "5 minutes ago" +%s)" ] then logger -t $(basename $0) "switching all lights off" - for i in {1..16} - do - for j in {1..16} - do - /usr/local/bin/433send 2 $j $i 0 #off - done - done +# for i in {1..16} +# do +# for j in {1..16} +# do + $(dirname "$0")/../lightcommander all off + # /usr/local/bin/433send 2 $j $i 0 #off +# done +# done logger -t $(basename $0) "all lights should be off now" fi if [ "$1" = "released" ] then # switch status lights on, in any case - /usr/local/bin/433send 2 2A 1 1 #on + $(dirname "$0")/../lightcommander status on + # /usr/local/bin/433send 2 2A 1 1 #on fi if [ "$1" = "released" ] && # the door has been opened # [ "$(cat /run/spacestatus)" = "open" ] && # status is open @@ -29,7 +31,8 @@ if [ "$1" = "released" ] && # the door has been opened then #( [ "$(date +%H)" -gt 18 ] || [ "$(date +%H)" -lt 8 ] ) logger -t $(basename $0) "switching some lights on" - /usr/local/bin/433send 2 1A 1 1 #on + $(dirname "$0")/../lightcommander main on + # /usr/local/bin/433send 2 1A 1 1 #on fi # type (2=10bit)