#!/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)" ] ) [ "$(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 # for j in {1..16} # do $(dirname "$0")/../lightcommander all off # /usr/local/bin/433send 2 $j $i 0 #off # done # done curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "OFF" "http://10.2.113.102:8080/rest/items/engineering_table_lamps" curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "OFF" "http://10.2.113.102:8080/rest/items/engineering_ceiling_lamps" logger -t $(basename $0) "all lights should be off now" fi if [ "$1" = "released" ] then # switch status lights on, in any case $(dirname "$0")/../lightcommander status on # /usr/local/bin/433send 2 2A 1 1 #on 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 +%s)" -gt $(/root/pidor/scripts/sunset) ] || [ "$(date +%s)" -lt $(/root/pidor/scripts/sunrise) ] ) then #( [ "$(date +%H)" -gt 18 ] || [ "$(date +%H)" -lt 8 ] ) logger -t $(basename $0) "switching some lights on" curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "ON" "http://10.2.113.102:8080/rest/items/engineering_table_lamps" curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "ON" "http://10.2.113.102:8080/rest/items/engineering_ceiling_lamps" $(dirname "$0")/../lightcommander main on # /usr/local/bin/433send 2 1A 1 1 #on fi # 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