diff --git a/scripts/beamercontrol.sh b/scripts/beamercontrol.sh index c208845..1864df4 100755 --- a/scripts/beamercontrol.sh +++ b/scripts/beamercontrol.sh @@ -18,6 +18,25 @@ function beamerquery() { fi echo "$signalsource" } +# vv-- volume +# 2a3140bf1c150a3230072a0101050300010001000001000100010185 +# 1111111111222 +# 1234567890123456789012 +function beamervolumedown() { + curvol="ff" + rept=20 + while [ "$curvol" != "00" ] && [ $rept -gt 0 ] + do + curvol="$(wget -qO - 'http://'"$projip"'/tgi/return.tgi?query=control' |awk -F'[<>]' '//{print substr($3,13,2)}')" + echo "beamervolume was: $curvol" + if [ "$curvol" != "00" ] + then + wget -qO - 'http://'"$projip"'/tgi/return.tgi?command=2a310bf4070263' + fi + rept=$((rept-1)) + done +} + function beameroff() { echo "Switching beamer off" wget -qO/dev/null http://$projip/tgi/return.tgi?command=2a3102fd0660 #projector off @@ -98,7 +117,7 @@ function receivervolumedown() { 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)" + echo "Usage: $0 (beamer|screen|receiver) (on|dvi|hdmi1|hdmi2|vga|off|down|up|vol-|vol+)" exit } projip="$(cat $(dirname "$0")"/beamerip.txt")" @@ -121,6 +140,8 @@ case $1 in ;; vga1) vga1 ; beameron && vga1 ;; + "vol-") beamervolumedown + ;; *) usage esac ;; diff --git a/scripts/beamerdetect.sh b/scripts/beamerdetect.sh index 0499556..efdfdbe 100755 --- a/scripts/beamerdetect.sh +++ b/scripts/beamerdetect.sh @@ -34,8 +34,10 @@ then [ "$(cat /var/run/caststatus)" = "Backdrop" ] ) then # port 15 is hdmi1 (chromecast) raisescreen + lightcommander projector vol- echo "wget http://$projip/tgi/return.tgi?command=2a3102fd0660 #projector off" - wget -qO - 'http://'"$projip"'/tgi/return.tgi?command=2a3102fd0660' 2>&1 + lightcommander projector off + #wget -qO - 'http://'"$projip"'/tgi/return.tgi?command=2a3102fd0660' 2>&1 echo $? else echo "not disabling projector because source is at $signalsource" @@ -58,8 +60,8 @@ do # 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'[<>]' '//{print substr($3,31,2)}')" - if [ "$statusbyte" = "01" ] + signalsource="$(wget -qO - 'http://'"$projip"'/tgi/return.tgi?query=info'|awk -F'[<>]' '//{print substr($3,31,2)}')" + if [ "$signalsource" = "01" ] then if [ "$prevstatus" != "on" ] then @@ -74,5 +76,16 @@ do prevstatus="off" fi fi +# logger -t "$(basename $0) $$" "source=$signalsource cast=$(cat /var/run/caststatus)" sleep 10 + caststatus="$(cat /var/run/caststatus)" + if [ "$caststatus" != "Backdrop" ] && + ( [ "$signalsource" = "" ] || + [ "$signalsource" = "00" ] || + [ "$signalsource" = "02" ] ) + then + logger -t $(basename $0) "$$ signal on chromecast: $caststatus" + lightcommander projector hdmi2 + sleep 3 + fi done diff --git a/scripts/caststatus.py b/scripts/caststatus.py index 5a1391b..1aebe42 100755 --- a/scripts/caststatus.py +++ b/scripts/caststatus.py @@ -5,7 +5,8 @@ sys.path.append(os.path.dirname(__file__) + "/../pychromecast/") import pychromecast #mycastname=pychromecast.get_chromecasts_as_dict().keys()[0] mycastname="Level2 Chillcast DVI1" -cast = pychromecast.get_chromecast(friendly_name=mycastname) +chromecasts = pychromecast.get_chromecasts() +cast=next(cc for cc in chromecasts if cc.device.friendly_name == mycastname) cast.wait() print(cast.device.friendly_name) offlinetime=0 diff --git a/scripts/lightcommander b/scripts/lightcommander index 62ee53b..a04f6ea 100755 --- a/scripts/lightcommander +++ b/scripts/lightcommander @@ -2,7 +2,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 {projector} {on|hdmi1|hdmi2|dvi|vga1|off|vol-}" echo "usage; $0 {receiver} {on|off|hdmi|jack1|jack2|optical|tuner|cd|vol-|vol+}" # echo "usage: $0 {maindoor} {open}" exit 1