adapted to new pychromecast api

make projector volume zero when powering off
master
pidor 2017-03-15 22:32:36 +00:00
parent 70c1e1becf
commit 1a79d0c8b2
4 changed files with 41 additions and 6 deletions

View File

@ -18,6 +18,25 @@ function beamerquery() {
fi fi
echo "$signalsource" echo "$signalsource"
} }
# vv-- volume
# 2a3140bf1c150a3230072a0101050300010001000001000100010185</control>
# 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'[<>]' '/<control>/{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() { function beameroff() {
echo "Switching beamer off" echo "Switching beamer off"
wget -qO/dev/null http://$projip/tgi/return.tgi?command=2a3102fd0660 #projector 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"' ssh pi@doorbuzz '/usr/bin/irsend SEND_ONCE pioneer "KEY_VOLUMEDOWN"'
} }
function usage() { 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 exit
} }
projip="$(cat $(dirname "$0")"/beamerip.txt")" projip="$(cat $(dirname "$0")"/beamerip.txt")"
@ -121,6 +140,8 @@ case $1 in
;; ;;
vga1) vga1 ; beameron && vga1 vga1) vga1 ; beameron && vga1
;; ;;
"vol-") beamervolumedown
;;
*) usage *) usage
esac esac
;; ;;

View File

@ -34,8 +34,10 @@ then
[ "$(cat /var/run/caststatus)" = "Backdrop" ] ) [ "$(cat /var/run/caststatus)" = "Backdrop" ] )
then # port 15 is hdmi1 (chromecast) then # port 15 is hdmi1 (chromecast)
raisescreen raisescreen
lightcommander projector vol-
echo "wget http://$projip/tgi/return.tgi?command=2a3102fd0660 #projector off" 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 $? echo $?
else else
echo "not disabling projector because source is at $signalsource" 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 # 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 # we only test if 01, because if off, it can also give no response
# but seems to be bytes 32-33 more accurate # 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)}')" signalsource="$(wget -qO - 'http://'"$projip"'/tgi/return.tgi?query=info'|awk -F'[<>]' '/<info>/{print substr($3,31,2)}')"
if [ "$statusbyte" = "01" ] if [ "$signalsource" = "01" ]
then then
if [ "$prevstatus" != "on" ] if [ "$prevstatus" != "on" ]
then then
@ -74,5 +76,16 @@ do
prevstatus="off" prevstatus="off"
fi fi
fi fi
# logger -t "$(basename $0) $$" "source=$signalsource cast=$(cat /var/run/caststatus)"
sleep 10 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 done

View File

@ -5,7 +5,8 @@ sys.path.append(os.path.dirname(__file__) + "/../pychromecast/")
import pychromecast import pychromecast
#mycastname=pychromecast.get_chromecasts_as_dict().keys()[0] #mycastname=pychromecast.get_chromecasts_as_dict().keys()[0]
mycastname="Level2 Chillcast DVI1" 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() cast.wait()
print(cast.device.friendly_name) print(cast.device.friendly_name)
offlinetime=0 offlinetime=0

View File

@ -2,7 +2,7 @@
if [ "$1" = "" ] if [ "$1" = "" ]
then then
echo "usage: $0 {main|chill|status|labsocket|alarm|screen} {on|off}" 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 {receiver} {on|off|hdmi|jack1|jack2|optical|tuner|cd|vol-|vol+}"
# echo "usage: $0 {maindoor} {open}" # echo "usage: $0 {maindoor} {open}"
exit 1 exit 1