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" ] ) &&
|
2014-11-14 23:03:24 +01:00
|
|
|
# [ "$(cat /run/spacestatus)" = "closed" ] &&
|
2014-10-01 16:31:55 +02:00
|
|
|
[ "$(cat /run/doorlockbutton)" = "pushed" ] &&
|
2014-11-14 23:03:24 +01:00
|
|
|
# ( [ "$(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
|
2015-07-19 19:48:02 +02:00
|
|
|
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
|
2015-05-11 00:28:03 +02:00
|
|
|
if [ "$1" = "released" ]
|
|
|
|
then # switch status lights on, in any case
|
2015-07-19 19:48:02 +02:00
|
|
|
/usr/local/bin/433send 2 2A 1 1 #on
|
2015-05-11 00:28:03 +02:00
|
|
|
fi
|
2014-10-01 16:31:55 +02:00
|
|
|
if [ "$1" = "released" ] && # the door has been opened
|
2014-11-14 23:03:24 +01:00
|
|
|
# [ "$(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
|
2014-11-14 23:03:24 +01:00
|
|
|
#( [ "$(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)
|
2015-07-19 19:48:02 +02:00
|
|
|
# | 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
|