diff --git a/README.txt b/README.txt index b447084..36f4e76 100644 --- a/README.txt +++ b/README.txt @@ -9,6 +9,7 @@ P0:2345:respawn:/root/pidor/scripts/lockbutton.sh P1:2345:respawn:/root/pidor/scripts/beamerdetect.sh P2:2345:respawn:/root/pidor/scripts/ws4beamer_status.py P3:2345:respawn:/root/pidor/scripts/peoplecounter-realtime.sh +P4:2345:respawn:/root/pidor/scripts/caststatus.py put the beamer IP into beamerip.txt put the peoplecounter ip into peoplecounterip.txt @@ -20,4 +21,11 @@ fill in the crontab needs an apache, for some silly historic reason, and for the lights commander cd ~/pidor/www && ./intallwebsite.sh +If you have a chromecast, script to switch off if chromecast is iddle: +cd ~/pidor +git clone git@github.com:balloob/pychromecast.git +cd pychromecast +sudo apt-get install python-dev python-pip +sudo pip install --upgrade pip +sudo pip install -r requirements.txt diff --git a/scripts/beamerdetect.sh b/scripts/beamerdetect.sh index 695d66b..0499556 100755 --- a/scripts/beamerdetect.sh +++ b/scripts/beamerdetect.sh @@ -27,8 +27,12 @@ then fi signalsource="$(wget -qO - 'http://'"$projip"'/tgi/return.tgi?query=info' |awk -F'[<>]' '//{print substr($3,33,2)}')" #if [ "$signalsource" = "00" ] || [ "$signalsource" = "15" ] || [ "$signalsource" = "" ] - if [ "$signalsource" = "00" ] || [ "$signalsource" = "02" ] || [ "$signalsource" = "" ] - then + if [ "$signalsource" = "00" ] || + [ "$signalsource" = "02" ] || + [ "$signalsource" = "" ] || + ( [ "$signalsource" = "15" ] && + [ "$(cat /var/run/caststatus)" = "Backdrop" ] ) + then # port 15 is hdmi1 (chromecast) raisescreen echo "wget http://$projip/tgi/return.tgi?command=2a3102fd0660 #projector off" wget -qO - 'http://'"$projip"'/tgi/return.tgi?command=2a3102fd0660' 2>&1 diff --git a/scripts/caststatus.py b/scripts/caststatus.py new file mode 100755 index 0000000..5a1391b --- /dev/null +++ b/scripts/caststatus.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python2.7 +from __future__ import print_function +import time,sys,os +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) +cast.wait() +print(cast.device.friendly_name) +offlinetime=0 +while True: + caststatus=cast.status.display_name + print(caststatus) + text_file = open("/var/run/caststatus", "w") + text_file.write("%s" % caststatus) + text_file.close() + if(caststatus == "Backdrop"): + offlinetime+=1 + else: + offlinetime=0 + if(offlinetime>10): + #print("Chromecast not streaming, switching to slideshow") + offlinetime=0 + time.sleep(10) +cast.quit_app() diff --git a/scripts/phone_notification.sh b/scripts/phone_notification.sh index 3c9da25..ffae095 100755 --- a/scripts/phone_notification.sh +++ b/scripts/phone_notification.sh @@ -1,8 +1,9 @@ #!/bin/bash -url=http://10.2.113.137 +url=http://$(cat $(dirname "$0")"/phoneip.txt") run_file="/var/run/phone_ringing_status" - +new_status=0 +old_status=0 while true do sleep 1 diff --git a/scripts/ws4beamer_status.py b/scripts/ws4beamer_status.py index 3fcb4b6..1ef1c45 100755 --- a/scripts/ws4beamer_status.py +++ b/scripts/ws4beamer_status.py @@ -2,13 +2,17 @@ import requests import flask import re +import os + +with open( os.path.dirname(os.path.realpath(__file__)) + "/beamerip.txt", 'r') as f: + beamerip = f.readline() app = flask.Flask(__name__) @app.route("/") def status(): try: - res = requests.get("http://10.2.113.7/tgi/return.tgi?query=info", timeout=1) + res = requests.get("http://"+beamerip+"/tgi/return.tgi?query=info", timeout=1) if "NG" in res.content: return "0" reg_res = re.findall(b"([^<]*)", res.content) diff --git a/systemfiles/inittab b/systemfiles/inittab index 33ce8df..2547494 100644 --- a/systemfiles/inittab +++ b/systemfiles/inittab @@ -76,4 +76,4 @@ P0:2345:respawn:/root/pidor/scripts/lockbutton.sh P1:2345:respawn:/root/pidor/scripts/beamerdetect.sh P2:2345:respawn:/root/pidor/scripts/ws4beamer_status.py P3:2345:respawn:/root/pidor/scripts/peoplecounter-realtime.sh - +P4:2345:respawn:/root/pidor/scripts/caststatus.py