better beamer and reciver control with volume keys

bug corrections
master
Level2 Pidor 2016-06-27 21:50:45 +02:00
parent 15ef5188d5
commit 4707c10209
8 changed files with 59 additions and 80 deletions

1
scripts/.gitignore vendored
View File

@ -1,3 +1,4 @@
spaceapikey.txt
beamerip.txt
peoplecounterip.txt
secret.txt

View File

@ -1,4 +1,5 @@
#!/bin/bash
# this is called by lightcommander
logger $0 1=$1 2=$2
BEAMERIP=$(cat $(dirname "$0")"/beamerip.txt")
function raisescreen() {
@ -9,13 +10,30 @@ function lowerscreen() {
echo "Rolling projection screen down"
ssh pi@doorbuzz 'doorbuzz/projectionscreen.sh down'
}
function beamerquery() {
signalsource="$(wget -qO - 'http://'"$projip"'/tgi/return.tgi?query=info' |awk -F'[<>]' '/<info>/{print substr($3,33,2)}')"
if [ "$signalsource" = "" ]
then
signalsource="off" # I know bash can do this in 1 line, but this should still be readable
fi
echo "$signalsource"
}
function beameroff() {
echo "Switching beamer off"
wget -qO/dev/null http://$projip/tgi/return.tgi?command=2a3102fd0660 #projector off
}
function beameron() {
echo "Switching beamer on"
currstatus="$(beamerquery)"
echo "Switching beamer on (input was $currstatus)"
wget -qO/dev/null http://$projip/tgi/return.tgi?command=2a3101fe0660 #projector on
if [ "$currstatus" = "off" ]
then
echo "Waiting for beamer to boot..."
sleep 15
echo "... is now booted"
return 0
fi
return 1
}
function dvi() {
echo "Switching to dvi"
@ -26,11 +44,8 @@ function hdmi1() {
wget -qO/dev/null http://$projip/tgi/return.tgi?command=2a3109f6071475 #switch to hdmi1
}
function hdmi2() {
receiveron
echo "Switching to hdmi2"
wget -qO/dev/null http://$projip/tgi/return.tgi?command=2a3109f6071576 #switch to hdmi2
sleep 4
receiverhdmi
}
function vga1() {
echo "Switching to vga1"
@ -70,6 +85,14 @@ function receivertuner() {
echo "Switching receiver to tuner"
ssh pi@doorbuzz '/usr/bin/irsend SEND_ONCE pioneer "KEY_TUNER"'
}
function receivervolumeup() {
echo "Turning reciever volume up"
ssh pi@doorbuzz '/usr/bin/irsend SEND_ONCE pioneer "KEY_VOLUMEUP"'
}
function receivervolumedown() {
echo "Turning reciever volume down"
ssh pi@doorbuzz '/usr/bin/irsend SEND_ONCE pioneer "KEY_VOLUMEDOWN"'
}
function usage() {
echo "Usage: $0 (beamer|screen) (on|dvi|hdmi1|hdmi2|vga|off|down|up)"
exit
@ -82,13 +105,17 @@ case $1 in
;;
off) beameroff
;;
dvi) beameron; dvi
dvi) dvi ; beameron && dvi
;;
hdmi1) beameron; hdmi1
hdmi1) hdmi1 ; beameron && hdmi1
;;
hdmi2) beameron; hdmi2
hdmi2) hdmi2
( receiveron
sleep 4
receiverhdmi ) &
beameron && hdmi2
;;
vga1) beameron; vga1
vga1) vga1 ; beameron && vga1
;;
*) usage
esac
@ -118,6 +145,10 @@ case $1 in
;;
tuner) receivertuner
;;
"vol+") receivervolumeup
;;
"vol-") receivervolumedown
;;
*) usage
esac
;;
@ -125,62 +156,3 @@ case $1 in
usage
;;
esac 2>&1 | logger -t $0
exit
if [ "$1" = "off" ]
then
(
echo "called with parameter $1"
projip="$BEAMERIP"
if [ "$projip" = "" ]
then
echo "no projector IP found"
arp -a
raisescreen
exit
fi
signalsource="$(wget -qO - 'http://'"$projip"'/tgi/return.tgi?query=info' |awk -F'[<>]' '/<info>/{print substr($3,33,2)}')"
if [ "$signalsource" = "00" ] || [ "$signalsource" = "15" ] || [ "$signalsource" = "" ]
then
raisescreen
echo "wget http://$projip/tgi/return.tgi?command=2a3102fd0660 #projector off"
wget -qO - 'http://'"$projip"'/tgi/return.tgi?command=2a3102fd0660' 2>&1
echo $?
else
echo "not disabling projector because source is at $signalsource"
fi
) | logger -t "$(basename $0) $$"
exit
fi &
if [ "$1" = "off" ]
then
exit # because the if before is in background
fi
prevstatus="unknown"
while true
do
if [ $(date +%H) -eq 23 ]
then
pingall
fi
projip="$BEAMERIP"
# from the acer webpage we read that bytes 30-31 contain 00 if power off and 01 if power on
# we only test if 01, because if off, it can also give no response
# but seems to be bytes 32-33 more accurate
statusbyte="$(wget -qO - 'http://'"$projip"'/tgi/return.tgi?query=info'|awk -F'[<>]' '/<info>/{print substr($3,31,2)}')"
if [ "$statusbyte" = "01" ]
then
if [ "$prevstatus" != "on" ]
then
logger -t $(basename $0) "$$ Projector is on"
ssh pi@doorbuzz 'doorbuzz/projectionscreen.sh down'
prevstatus="on"
fi
else
if [ "$prevstatus" != "off" ]
then
logger -t $(basename $0) "$$ Projector is off"
prevstatus="off"
fi
fi
sleep 10
done

View File

@ -26,7 +26,8 @@ then
exit
fi
signalsource="$(wget -qO - 'http://'"$projip"'/tgi/return.tgi?query=info' |awk -F'[<>]' '/<info>/{print substr($3,33,2)}')"
if [ "$signalsource" = "00" ] || [ "$signalsource" = "15" ] || [ "$signalsource" = "" ]
#if [ "$signalsource" = "00" ] || [ "$signalsource" = "15" ] || [ "$signalsource" = "" ]
if [ "$signalsource" = "00" ] || [ "$signalsource" = "02" ] || [ "$signalsource" = "" ]
then
raisescreen
echo "wget http://$projip/tgi/return.tgi?command=2a3102fd0660 #projector off"

View File

@ -3,8 +3,8 @@ if [ "$1" = "" ]
then
echo "usage: $0 {main|chill|status|labsocket|alarm|screen} {on|off}"
echo "usage: $0 {projector} {on|hdmi1|hdmi2|dvi|vga1|off}"
echo "usage; $0 {receiver} {on|off|hdmi|jack1|jack2|optical}"
echo "usage: $0 {maindoor} {open}"
echo "usage; $0 {receiver} {on|off|hdmi|jack1|jack2|optical|vol-|vol+}"
# echo "usage: $0 {maindoor} {open}"
exit 1
fi
function dolight() {
@ -36,8 +36,8 @@ function dolight() {
;;
receiver) sudo /root/pidor/scripts/beamercontrol.sh receiver "$2"
;;
maindoor) sudo /root/pidor/scripts/opendoor.sh
;;
# maindoor) sudo /root/pidor/scripts/opendoor.sh
# ;;
esac
# type (2=10bit)
# | house 1-16 (the dial thingie)

View File

@ -1,3 +1,3 @@
#!/bin/bash
BUZZERURL="$(cat "$(dirname "$0")"/secret.txt)/state.xml?relay1State=2&pulseTime1=5"
wget -O - --timeout=1 --tries=1 $BUZZERSTATUSURL
RELAYURL="$(cat "$(dirname "$0")"/secret.txt)/state.xml?relay1State=2&pulseTime1=5"
wget -O - --timeout=1 --tries=1 $RELAYURL

View File

@ -42,7 +42,7 @@ doorlockbutton="$(cat /run/doorlockbutton)"
nai=$(stat -c "%Y" /run/spacestatus) # get mtime as status change time
if [ "$status" = "open" ]
then
/usr/bin/curl --max-time 1 --silent --data key="$spaceapikey" --data-urlencode sensors='{"state":{"open":true,"lastchange":'"$nai"'}}' http://spaceapi.syn2cat.lu/sensor/set
/usr/bin/curl --max-time 1 --silent --insecure --data key="$spaceapikey" --data-urlencode sensors='{"state":{"open":true,"lastchange":'"$nai"'}}' http://spaceapi.syn2cat.lu/sensor/set
#logger -t $(basename $0) "$$ sending status $status to spacapi ret=$?"
fi
for plugin in $(ls "$0".d)
@ -60,7 +60,7 @@ then
# problem: if closing state but not actually shuting door for a longer time, the status in spaceapi
# will be the time of closing but not that of actually shutting the door
# but the status will only be updated once the door is shut
/usr/bin/curl --max-time 1 --silent --data key="$spaceapikey" --data-urlencode sensors='{"state":{"open":false,"lastchange":'"$nai"'}}' http://spaceapi.syn2cat.lu/sensor/set
/usr/bin/curl --max-time 1 --silent --insecure --data key="$spaceapikey" --data-urlencode sensors='{"state":{"open":false,"lastchange":'"$nai"'}}' http://spaceapi.syn2cat.lu/sensor/set
#logger -t $(basename $0) "$$ sending status $status to spacapi ret=$?"
fi
@ -74,5 +74,5 @@ if [ "$status" = "closed" ]
then
presency=0
fi
/usr/bin/curl --max-time 1 --silent --data key="$spaceapikey" --data-urlencode sensors='{"sensors":{"people_now_present":[{"value":'"$presency"'}]}}' http://spaceapi.syn2cat.lu/sensor/set
/usr/bin/curl --max-time 1 --silent --insecure --data key="$spaceapikey" --data-urlencode sensors='{"sensors":{"people_now_present":[{"value":'"$presency"'}]}}' http://spaceapi.syn2cat.lu/sensor/set
V

View File

@ -50,9 +50,9 @@ if ( $currentStatus != $previousStatus ) {
case 'closed':
$peopleMax="";
if($peopleMax=file_get_contents("/var/spool/peoplecountermax")) {
if($peopleMax=file_get_contents("/var/cache/peoplecountermax")) {
$peopleMax=str_replace("\n", '', $peopleMax);
file_put_contents("/var/spool/peoplecountermax","0");
file_put_contents("/var/cache/peoplecountermax","0");
if($peopleMax>8) { // only write this info if the place has been quite busy
$peopleMax="There were up to $peopleMax hackers today.\n";
} else {

View File

@ -90,15 +90,20 @@
<p><a class="btn btn-success btn-lg btn-block" data-area="receiver" data-status="hdmi" >HDMI (projector) 2.0</a></p>
<p><a class="btn btn-success btn-lg btn-block" data-area="receiver" data-status="optical" >Optical (BluRay) 5.1</a></p>
<p><a class="btn btn-success btn-lg btn-block" data-area="receiver" data-status="tuner" >Tuner</a></p>
<p><a class="btn btn-danger btn-lg btn-block" data-area="receiver" data-status="off" >Off</a></p>
<p><a class="btn btn-success btn-lg btn-block" data-area="receiver" data-status="vol-" >Vol-</a></p>
<p><a class="btn btn-success btn-lg btn-block" data-area="receiver" data-status="vol+" >Vol+</a></p>
<p><a class="col-md-3 btn btn-danger btn-lg btn-block" data-area="receiver" data-status="off" >Off</a></p>
</div>
</div>
</div>
<!--
<div class="col-md-6">
<div class=" well">
<h1>Main Door</h1>
<p><a class="btn btn-success btn-lg btn-block" data-area="maindoor" data-status="open" >Open door</a></p>
</div>
</div>
-->
</div>