correct relative path for lightcommander

master
Level2 Pidor 2015-07-19 22:30:46 +02:00
parent 9c40e21619
commit 9e41065af5
5 changed files with 74 additions and 22 deletions

View File

@ -13,13 +13,15 @@ do
then then
logger -t $(basename $0) "phone status change detected" logger -t $(basename $0) "phone status change detected"
logger -t $(basename $0) "phone ring light on" 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 fi
if [ "$cmd" = "flashoff" ] if [ "$cmd" = "flashoff" ]
then then
logger -t $(basename $0) "phone status change detected" logger -t $(basename $0) "phone status change detected"
logger -t $(basename $0) "phone ring light off" 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 fi
done done

42
scripts/lightcommander Executable file
View File

@ -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"

View File

@ -9,18 +9,20 @@ if ( [ "$1" = "pushed" ] || [ "$1" = "closed" ] ) &&
[ "$(stat -c %Y /run/doorlockbutton)" -gt "$(date --date "5 minutes ago" +%s)" ] [ "$(stat -c %Y /run/doorlockbutton)" -gt "$(date --date "5 minutes ago" +%s)" ]
then then
logger -t $(basename $0) "switching all lights off" logger -t $(basename $0) "switching all lights off"
for i in {1..16} # for i in {1..16}
do # do
for j in {1..16} # for j in {1..16}
do # do
/usr/local/bin/433send 2 $j $i 0 #off $(dirname "$0")/../lightcommander all off
done # /usr/local/bin/433send 2 $j $i 0 #off
done # done
# done
logger -t $(basename $0) "all lights should be off now" logger -t $(basename $0) "all lights should be off now"
fi fi
if [ "$1" = "released" ] if [ "$1" = "released" ]
then # switch status lights on, in any case 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 fi
if [ "$1" = "released" ] && # the door has been opened if [ "$1" = "released" ] && # the door has been opened
# [ "$(cat /run/spacestatus)" = "open" ] && # status is open # [ "$(cat /run/spacestatus)" = "open" ] && # status is open
@ -29,7 +31,8 @@ if [ "$1" = "released" ] && # the door has been opened
then then
#( [ "$(date +%H)" -gt 18 ] || [ "$(date +%H)" -lt 8 ] ) #( [ "$(date +%H)" -gt 18 ] || [ "$(date +%H)" -lt 8 ] )
logger -t $(basename $0) "switching some lights on" 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 fi
# type (2=10bit) # type (2=10bit)

View File

@ -23,10 +23,12 @@ do
logger -t $(basename $0) "phone status change detected" logger -t $(basename $0) "phone status change detected"
if [ "$new_status" -eq 0 ]; then if [ "$new_status" -eq 0 ]; then
logger -t $(basename $0) "phone ring light on" 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 else
logger -t $(basename $0) "phone ring light off" 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 fi
echo $new_status > ${run_file} echo $new_status > ${run_file}
fi fi

View File

@ -9,18 +9,20 @@ if ( [ "$1" = "pushed" ] || [ "$1" = "closed" ] ) &&
[ "$(stat -c %Y /run/doorlockbutton)" -gt "$(date --date "5 minutes ago" +%s)" ] [ "$(stat -c %Y /run/doorlockbutton)" -gt "$(date --date "5 minutes ago" +%s)" ]
then then
logger -t $(basename $0) "switching all lights off" logger -t $(basename $0) "switching all lights off"
for i in {1..16} # for i in {1..16}
do # do
for j in {1..16} # for j in {1..16}
do # do
/usr/local/bin/433send 2 $j $i 0 #off $(dirname "$0")/../lightcommander all off
done # /usr/local/bin/433send 2 $j $i 0 #off
done # done
# done
logger -t $(basename $0) "all lights should be off now" logger -t $(basename $0) "all lights should be off now"
fi fi
if [ "$1" = "released" ] if [ "$1" = "released" ]
then # switch status lights on, in any case 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 fi
if [ "$1" = "released" ] && # the door has been opened if [ "$1" = "released" ] && # the door has been opened
# [ "$(cat /run/spacestatus)" = "open" ] && # status is open # [ "$(cat /run/spacestatus)" = "open" ] && # status is open
@ -29,7 +31,8 @@ if [ "$1" = "released" ] && # the door has been opened
then then
#( [ "$(date +%H)" -gt 18 ] || [ "$(date +%H)" -lt 8 ] ) #( [ "$(date +%H)" -gt 18 ] || [ "$(date +%H)" -lt 8 ] )
logger -t $(basename $0) "switching some lights on" 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 fi
# type (2=10bit) # type (2=10bit)