From 6ff6d2e5ca0714ca2328d6b4b83d2012e980aa24 Mon Sep 17 00:00:00 2001 From: pidor Date: Fri, 12 Apr 2019 01:05:22 +0200 Subject: [PATCH] integrate OpenHab --- scripts/beamercontrol.sh | 2 ++ scripts/beamerdetect.sh | 1 + scripts/lightcommander | 15 ++++++++++++++- scripts/lockbutton.sh.d/01lights | 8 ++++++++ 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/scripts/beamercontrol.sh b/scripts/beamercontrol.sh index d1de377..6f54b34 100755 --- a/scripts/beamercontrol.sh +++ b/scripts/beamercontrol.sh @@ -5,10 +5,12 @@ BEAMERIP=$(cat $(dirname "$0")"/beamerip.txt") function raisescreen() { echo "Rolling projection screen up" ssh pi@doorbuzz 'doorbuzz/projectionscreen.sh up' + curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "ON" "http://10.2.113.102:8080/rest/items/chill_zone_screen_button_up" } function lowerscreen() { echo "Rolling projection screen down" ssh pi@doorbuzz 'doorbuzz/projectionscreen.sh down' + curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "ON" "http://10.2.113.102:8080/rest/items/chill_zone_screen_button_down" } function beamerquery() { signalsource="$(wget -qO - 'http://'"$projip"'/tgi/return.tgi?query=info' |awk -F'[<>]' '//{print substr($3,33,2)}')" diff --git a/scripts/beamerdetect.sh b/scripts/beamerdetect.sh index c219a7d..b00ac43 100755 --- a/scripts/beamerdetect.sh +++ b/scripts/beamerdetect.sh @@ -3,6 +3,7 @@ BEAMERIP=$(cat $(dirname "$0")"/beamerip.txt") function raisescreen() { echo "Rolling projection screen up" ssh pi@doorbuzz 'doorbuzz/projectionscreen.sh up' + curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "ON" "http://10.2.113.102:8080/rest/items/chill_zone_screen_button_up" } function pingall() { i=1 diff --git a/scripts/lightcommander b/scripts/lightcommander index 0b266f7..d36e162 100755 --- a/scripts/lightcommander +++ b/scripts/lightcommander @@ -43,8 +43,10 @@ function dolight() { if [ "$2" = "on" ] then setvalue=1 + mqtt_command=ON else setvalue=0 + mqtt_command=OFF fi case "$1" in all) dolight "main" $2 @@ -52,16 +54,27 @@ function dolight() { dolight "labsocket" $2 dolight "3dprinter" $2 dolight "alarm" $2 + + curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "$mqtt_command" "http://10.2.113.102:8080/rest/items/engineering_table_lamps" + curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "$mqtt_command" "http://10.2.113.102:8080/rest/items/engineering_ceiling_lamps" + curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "$mqtt_command" "http://10.2.113.102:8080/rest/items/engineering_status_lamp" + curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "$mqtt_command" "http://10.2.113.102:8080/rest/items/chill_zone_lamps" + curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "$mqtt_command" "http://10.2.113.102:8080/rest/items/entrance_ceiling_lamps" + ;; main) IRcmd 2 1A 1 "$setvalue" + curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "$mqtt_command" "http://10.2.113.102:8080/rest/items/entrance_ceiling_lamps" + curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "$mqtt_command" "http://10.2.113.102:8080/rest/items/chill_zone_lamps" if [ "$setvalue" = "0" ] # switch off alarm light when switching off all lights then IRcmd2 15A 1 "$setvalue" fi ;; chill) IRcmd 2 1A 2 "$setvalue" + curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "$mqtt_command" "http://10.2.113.102:8080/rest/items/chill_zone_lamps" ;; status) IRcmd 2 2A 1 "$setvalue" + curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "$mqtt_command" "http://10.2.113.102:8080/rest/items/engineering_status_lamp" ;; labsocket) IRcmd 2 15A 6 "$setvalue" ;; @@ -94,5 +107,5 @@ function dolight() { #/usr/local/bin/433send 2 1A 1 0 #off } -logger -t $(basename $0) "$$ $1 $2" +logger -t $(basename $0) "do $$ $1 $2" dolight "$1" "$2" diff --git a/scripts/lockbutton.sh.d/01lights b/scripts/lockbutton.sh.d/01lights index 38bc4a3..c5d2b6c 100755 --- a/scripts/lockbutton.sh.d/01lights +++ b/scripts/lockbutton.sh.d/01lights @@ -17,6 +17,10 @@ then # /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" ] @@ -31,6 +35,10 @@ if [ "$1" = "released" ] # && # the door has been opened 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