pidor/scripts/lockbutton.sh.d/lights

34 lines
1.4 KiB
Plaintext
Raw Normal View History

2014-10-01 16:31:55 +02:00
#!/bin/bash
# called by upd_status and lockbutton, so that whatever
# sequence is used, the lights go off
if ( [ "$1" = "pushed" ] || [ "$1" = "closed" ] ) &&
[ "$(cat /run/spacestatus)" = "closed" ] &&
[ "$(cat /run/doorlockbutton)" = "pushed" ] &&
( [ "$(stat -c %Y /run/spacestatus)" -gt "$(date --date "5 minutes ago" +%s)" ] ||
[ "$(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
/usr/local/bin/433send 2 1A $i 0 #off
done
logger -t $(basename $0) "all lights should be off now"
fi
if [ "$1" = "released" ] && # the door has been opened
[ "$(cat /run/spacestatus)" = "open" ] && # status is open
[ "$(stat -c %Y /run/spacestatus)" -gt "$(date --date "50 minutes ago" +%s)" ] && # since less than 5 minutes
( [ "$(date +%H)" -gt 18 ] || [ "$(date +%H)" -lt 8 ] )
then
logger -t $(basename $0) "switching some lights on"
/usr/local/bin/433send 2 1A 1 1 #on
fi
# type (2=10bit)
# | house 1-16 (always 1 in our case)
# | |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