remove some logging

receiver volume reset
semaphore on lightcommander
master
pidor 2019-01-24 22:42:03 +01:00
parent 539125f2e5
commit 2ff6641898
9 changed files with 91 additions and 18 deletions

View File

@ -118,11 +118,11 @@ function receivercd() {
ssh pi@doorbuzz '/usr/bin/irsend SEND_ONCE pioneer "KEY_CD"' ssh pi@doorbuzz '/usr/bin/irsend SEND_ONCE pioneer "KEY_CD"'
} }
function receivervolumeup() { function receivervolumeup() {
echo "Turning reciever volume up" #echo "Turning reciever volume up"
ssh pi@doorbuzz '/usr/bin/irsend SEND_ONCE pioneer "KEY_VOLUMEUP"' ssh pi@doorbuzz '/usr/bin/irsend SEND_ONCE pioneer "KEY_VOLUMEUP"'
} }
function receivervolumedown() { function receivervolumedown() {
echo "Turning reciever volume down" #echo "Turning reciever volume down"
ssh pi@doorbuzz '/usr/bin/irsend SEND_ONCE pioneer "KEY_VOLUMEDOWN"' ssh pi@doorbuzz '/usr/bin/irsend SEND_ONCE pioneer "KEY_VOLUMEDOWN"'
} }
function bluray() { function bluray() {
@ -188,6 +188,29 @@ case $1 in
;; ;;
off) receiveroff off) receiveroff
;; ;;
shutdown)
echo "Receiver shutdown initiated..."
for i in {1..90}
do
if [ "$(cat /run/spacestatus)" = "open" ]
then
echo "space open, stopping receiver shutdown"
exit
fi
receivervolumedown
done
for i in {1..50}
do
if [ "$(cat /run/spacestatus)" = "open" ]
then
echo "space open, stopping receiver shutdown"
exit
fi
receivervolumeup
done
receiveroff
echo "Receiver shutdown finished."
;;
hdmi) receiverhdmi hdmi) receiverhdmi
;; ;;
jack1) receiverjack1 jack1) receiverjack1

View File

@ -18,6 +18,8 @@ do
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"
$(dirname "$0")/lightcommander alarm on >&2 $(dirname "$0")/lightcommander alarm on >&2
sleep 20 # make sure it switches off some time
$(dirname "$0")/lightcommander alarm off >&2
#/usr/local/bin/433send 2 15 1 1 >&2 #/usr/local/bin/433send 2 15 1 1 >&2
fi fi

View File

@ -8,6 +8,34 @@ then
# echo "usage: $0 {maindoor} {open}" # echo "usage: $0 {maindoor} {open}"
exit 1 exit 1
fi fi
LockDir="/run/lock/$(basename "$0").run"
P() {
while ! mkdir "$LockDir" 2>/dev/null
do
LockDirStamp=$(stat -c %Y "$LockDir" 2>/dev/null)
if [ "$LockDirStamp" != "" ] && [ "$LockDirStamp" -lt $(date --date "300 seconds ago" +%s) ]
then
rmdir "$LockDir"
logger -t $(basename $0) "$$ deleting stale semaphore dir $LockDir"
fi
sleep 1
done
}
V() {
rmdir "$LockDir" 2>/dev/null
if [ $? -ne 0 ]
then
logger -t $(basename $0) "$$ semaphore dir $LockDir disappeared while running"
fi
}
function IRcmd() {
P
sudo /root/pidor/rcswitch-pi/send "$1" "$2" "$3" "$4"
V
}
# v---- group A=1, B=2, G=7 # v---- group A=1, B=2, G=7
# v---- number # v---- number
# /root/pidor/rcswitch-pi/send 2 7 3 1 <-- 0=off 1=on # /root/pidor/rcswitch-pi/send 2 7 3 1 <-- 0=off 1=on
@ -25,23 +53,23 @@ function dolight() {
dolight "3dprinter" $2 dolight "3dprinter" $2
dolight "alarm" $2 dolight "alarm" $2
;; ;;
main) sudo /root/pidor/rcswitch-pi/send 2 1A 1 "$setvalue" main) IRcmd 2 1A 1 "$setvalue"
if [ "$setvalue" = "0" ] # switch off alarm light when switching off all lights if [ "$setvalue" = "0" ] # switch off alarm light when switching off all lights
then then
sudo /root/pidor/rcswitch-pi/send 2 15A 1 "$setvalue" IRcmd2 15A 1 "$setvalue"
fi fi
;; ;;
chill) sudo /root/pidor/rcswitch-pi/send 2 1A 2 "$setvalue" chill) IRcmd 2 1A 2 "$setvalue"
;; ;;
status) sudo /root/pidor/rcswitch-pi/send 2 2A 1 "$setvalue" status) IRcmd 2 2A 1 "$setvalue"
;; ;;
labsocket) sudo /root/pidor/rcswitch-pi/send 2 15A 6 "$setvalue" labsocket) IRcmd 2 15A 6 "$setvalue"
;; ;;
alarm) ( sudo /root/pidor/rcswitch-pi/send 2 15A 1 "$setvalue" alarm) ( IRcmd 2 15A 1 "$setvalue"
sleep 1 sleep 1
sudo /root/pidor/rcswitch-pi/send 2 15A 1 "$setvalue" ) & IRcmd 2 15A 1 "$setvalue" ) &
;; ;;
3dprinter) sudo /root/pidor/rcswitch-pi/send 2 7 3 "$setvalue" 3dprinter) IRcmd 2 7 3 "$setvalue"
;; ;;
screen) sudo /root/pidor/scripts/beamercontrol.sh screen "$2" screen) sudo /root/pidor/scripts/beamercontrol.sh screen "$2"
;; ;;

View File

@ -1,6 +1,7 @@
#!/bin/bash #!/bin/bash
# changes level2 state by the state of the main door # changes level2 state by the state of the main door
# i.e. people have to leave it open to keep status open # i.e. people have to leave it open to keep status open
logger -t $(basename $0) "$1 starting"
sleep 1 # silly way to debounce sleep 1 # silly way to debounce
if [ ! -f /run/spacestatus ] # needed to init after boot if [ ! -f /run/spacestatus ] # needed to init after boot
then then
@ -9,6 +10,7 @@ fi
if [ "$1" = "pushed" ] && if [ "$1" = "pushed" ] &&
[ "$(cat /run/spacestatus)" = "open" ] [ "$(cat /run/spacestatus)" = "open" ]
then then
logger -t $(basename $0) "$1 set state to closed"
FORM_action="close" /root/pidor/webserver/cgi-bin/pidor.sh FORM_action="close" /root/pidor/webserver/cgi-bin/pidor.sh
/root/pidor/scripts/upd_status.sh /root/pidor/scripts/upd_status.sh
fi fi
@ -16,8 +18,18 @@ if [ "$1" = "released" ] && # if switch was released (the door opened, or
[ "$(cat /run/spacestatus)" = "closed" ] # the status was closed [ "$(cat /run/spacestatus)" = "closed" ] # the status was closed
# [ $(stat -c "%Y" /run/spacestatus) -lt $(date --date "1 hour ago" +%s) ] # since at least one hour # [ $(stat -c "%Y" /run/spacestatus) -lt $(date --date "1 hour ago" +%s) ] # since at least one hour
then then
logger -t $(basename $0) "$1 waiting 60s"
sleep 60 # wait a bit, to avoid false triggers (wind blowing, people playing with door
nowstate="$(gpio -g read 11)"
if [ "$nowstate" -eq 1 ]
then
logger -t $(basename $0) "$1 Door was closed again ($nowstate) before 60s elapsed, not setting space to open"
exit
fi
logger -t $(basename $0) "$1 set state to open"
FORM_action="open" /root/pidor/webserver/cgi-bin/pidor.sh FORM_action="open" /root/pidor/webserver/cgi-bin/pidor.sh
/root/pidor/scripts/upd_status.sh /root/pidor/scripts/upd_status.sh
# echo "intrusion detected: space was closed since some time and locked, but now is still closed but unlocked" | wall # echo "intrusion detected: space was closed since some time and locked, but now is still closed but unlocked" | wall
# logger -t $(basename $0) "INTRUSION ALARM. door was opened while status is closed" # logger -t $(basename $0) "INTRUSION ALARM. door was opened while status is closed"
fi fi
logger -t $(basename $0) "$1 done"

View File

@ -1,5 +0,0 @@
#!/bin/bash
if [ "$1" = "pushed" ]
then
$(dirname $0)/../lightcommander receiver off
fi

View File

@ -0,0 +1,5 @@
#!/bin/bash
if [ "$1" = "pushed" ]
then
$(dirname $0)/../lightcommander receiver shutdown &
fi

View File

@ -1,4 +1,5 @@
#!/bin/bash #!/bin/bash
set -x
sleep 5 sleep 5
IGNORE_DOORLOCKBUTTON="no" IGNORE_DOORLOCKBUTTON="no"
LockDir="/run/$(basename "$0").run" LockDir="/run/$(basename "$0").run"
@ -55,8 +56,11 @@ do
if [ -x "$0".d/"$plugin" ] if [ -x "$0".d/"$plugin" ]
then then
"$0".d/"$plugin" "$status" "$oldstatus" "$0".d/"$plugin" "$status" "$oldstatus"
if [ "$status" != "$oldstatus" ]
then
logger -t $(basename $0) "$$ called $plugin '$status' '$oldstatus'. ret=$?" logger -t $(basename $0) "$$ called $plugin '$status' '$oldstatus'. ret=$?"
fi fi
fi
done done
if [ "$status" = "closed" ] && ( if [ "$status" = "closed" ] && (
@ -109,6 +113,6 @@ then
fi fi
fi fi
else else
rm -f /run/var/netdown.txt # reset rm -f /run/netdown.txt # reset
fi fi
V V

View File

@ -24,7 +24,7 @@ then # switch status lights on, in any case
$(dirname "$0")/../lightcommander status on $(dirname "$0")/../lightcommander status on
# /usr/local/bin/433send 2 2A 1 1 #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
# [ "$(stat -c %Y /run/spacestatus)" -gt "$(date --date "50 minutes ago" +%s)" ] && # since less than 5 minutes # [ "$(stat -c %Y /run/spacestatus)" -gt "$(date --date "50 minutes ago" +%s)" ] && # since less than 5 minutes
# ( [ "$(date +%s)" -gt $(/root/pidor/scripts/sunset) ] || [ "$(date +%s)" -lt $(/root/pidor/scripts/sunrise) ] ) # ( [ "$(date +%s)" -gt $(/root/pidor/scripts/sunset) ] || [ "$(date +%s)" -lt $(/root/pidor/scripts/sunrise) ] )
@ -35,6 +35,10 @@ then
# /usr/local/bin/433send 2 1A 1 1 #on # /usr/local/bin/433send 2 1A 1 1 #on
fi fi
if [ "$1" = "open" ] && [ "$2" = "open" ]
then
$(dirname "$0")/../lightcommander status on
fi
# type (2=10bit) # type (2=10bit)
# | house 1-16 (the dial thingie) # | house 1-16 (the dial thingie)
# | |group A-P (the dial thingie) # | |group A-P (the dial thingie)