pidor/scripts/lockbutton.sh.d/lights

43 lines
1.7 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" ] &&
2014-10-01 16:31:55 +02:00
[ "$(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)" ] )
[ "$(stat -c %Y /run/doorlockbutton)" -gt "$(date --date "5 minutes ago" +%s)" ]
2014-10-01 16:31:55 +02:00
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
2014-10-01 16:31:55 +02:00
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
fi
2014-10-01 16:31:55 +02:00
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 +%s)" -gt $(/root/pidor/scripts/sunset) ] || [ "$(date +%s)" -lt $(/root/pidor/scripts/sunrise) ] )
2014-10-01 16:31:55 +02:00
then
#( [ "$(date +%H)" -gt 18 ] || [ "$(date +%H)" -lt 8 ] )
2014-10-01 16:31:55 +02:00
logger -t $(basename $0) "switching some lights on"
/usr/local/bin/433send 2 1A 1 1 #on
fi
# type (2=10bit)
# | house 1-16 (the dial thingie)
2014-10-01 16:31:55 +02:00
# | |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