reciever control via IR

move maxfile to a world accessible place
add peoplecounter in doorbuzz ssh wrapper
master
Level2 Pidor 2016-04-18 22:06:28 +02:00
parent f9228f07b4
commit 6d525f7e9a
8 changed files with 86 additions and 5 deletions

View File

@ -26,8 +26,11 @@ 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"
@ -37,6 +40,36 @@ function vga2() {
echo "Switching to vga2"
wget -qO/dev/null http://$projip/tgi/return.tgi?command=2a3109f6070263 #switch to vga2
}
function receiveron() {
echo "switching receiver on"
ssh pi@doorbuzz '/usr/bin/irsend SEND_ONCE pioneer "KEY_POWER"'
}
function receiveroff() {
echo "switching receiver off"
ssh pi@doorbuzz '/usr/bin/irsend SEND_ONCE pioneer "KEY_POWER2"'
}
function receiverhdmi() {
echo "Switching receiver to hdmi"
ssh pi@doorbuzz '/usr/bin/irsend SEND_ONCE pioneer "KEY_DVD"'
}
function receiverjack1() {
echo "Switching receiver to jack1"
ssh pi@doorbuzz '/usr/bin/irsend SEND_ONCE pioneer "KEY_VCR"'
}
function receiverjack2() {
echo "Switching receiver to jack2"
ssh pi@doorbuzz '/usr/bin/irsend SEND_ONCE pioneer "KEY_VCR2"'
}
function receiveroptical() {
echo "Switching receiver to optical"
ssh pi@doorbuzz '/usr/bin/irsend SEND_ONCE pioneer "KEY_TAPE"'
}
function receivertuner() {
echo "Switching receiver to tuner"
ssh pi@doorbuzz '/usr/bin/irsend SEND_ONCE pioneer "KEY_TUNER"'
}
function usage() {
echo "Usage: $0 (beamer|screen) (on|dvi|hdmi1|hdmi2|vga|off|down|up)"
exit
@ -69,10 +102,29 @@ case $1 in
*) usage
esac
;;
receiver)
case $2 in
on) receiveron
;;
off) receiveroff
;;
hdmi) receiverhdmi
;;
jack1) receiverjack1
;;
jack2) receiverjack2
;;
optical) receiveroptical
;;
tuner) receivertuner
;;
*) usage
esac
;;
*)
usage
;;
esac
esac 2>&1 | logger -t $0
exit
if [ "$1" = "off" ]
then

View File

@ -23,7 +23,7 @@ do
n=$((n+1))
fi
else
logger -t $(basename $0) "dhcp $i is not pingable anymore"
#logger -t $(basename $0) "dhcp $i is not pingable anymore"
if [ $(stat -c %Y /run/dhcp-leases/$i) -lt $(date --date "1 hour ago" +%s) ]
then
logger -t $(basename $0) "removing dhcp $i after one hour"

View File

@ -8,6 +8,10 @@ do
then
cat /var/run/spacestatus
fi
if [ "$cmd" = "peoplecounter" ]
then
tail -1 /run/peoplecounter
fi
if [ "$cmd" = "flashon" ]
then

View File

@ -3,6 +3,7 @@ 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}"
exit 1
fi
function dolight() {
@ -32,6 +33,8 @@ function dolight() {
;;
projector) sudo /root/pidor/scripts/beamercontrol.sh beamer "$2"
;;
receiver) sudo /root/pidor/scripts/beamercontrol.sh receiver "$2"
;;
esac
# type (2=10bit)
# | house 1-16 (the dial thingie)

View File

@ -0,0 +1,5 @@
#!/bin/bash
if [ "$1" = "pushed" ]
then
$(dirname $0)/../lightcommander receiver off
fi

View File

@ -11,7 +11,7 @@ fi
STATSFILE="/run/peoplecounter$DEV"
SAMPLES=20 # how many records to keep in file
INTERVAL=10 # how long to wait between polls
MAXFILE="/root/var/peoplecountermax$DEV"
MAXFILE="/var/cache/peoplecountermax$DEV"
PRESENCY="/run/presency$DEV" # value shown on website
# /run/peoplecounter lists all recent reads, newest at end
# let's have some management functions instead of a database
@ -72,6 +72,7 @@ do
then
logger $(basename $0) setting max to $curmax because bigger than ${oldmax:-}
echo "$curmax" > "$MAXFILE"
chmod a+rw "$MAXFILE"
fi
fi
oldaverage="$(cat "$PRESENCY")"

View File

@ -50,9 +50,9 @@ if ( $currentStatus != $previousStatus ) {
case 'closed':
$peopleMax="";
if($peopleMax=file_get_contents("/var/run/peoplecountermax")) {
if($peopleMax=file_get_contents("/var/spool/peoplecountermax")) {
$peopleMax=str_replace("\n", '', $peopleMax);
file_put_contents("/var/run/peoplecountermax","0");
file_put_contents("/var/spool/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

@ -80,6 +80,22 @@
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class=" well">
<h1>Amplifier</h1>
<p><a class="btn btn-success btn-lg btn-block" data-area="receiver" data-status="on" >On</a></p>
<p><a class="btn btn-success btn-lg btn-block" data-area="receiver" data-status="jack1" >Jack 1</a></p>
<p><a class="btn btn-success btn-lg btn-block" data-area="receiver" data-status="jack2" >Jack 2</a></p>
<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>
</div>
</div>
</div>
</div> <!-- /container -->
<div class="jumbotron hidden-xs">