THIS GUIDE IS INACTIVE. Changes to streaming services will require updated instructions which we don’t have yet.
The “On Air” software can be downloaded from Github, or just copy and paste this line in a terminal window to download the single file that’s needed:
wget https://raw.githubusercontent.com/adafruit/Adafruit_Learning_System_Guides/master/Raspberry_Pi_On_Air_Sign/onair.py
No additional packages should need to be installed — the current release of Raspbian Wheezy has all prerequisites installed.
Edit the file “onair.py” to set up your developer account keys and a polling schedule:
Edit the file “onair.py” to set up your developer account keys and a polling schedule:
nano onair.py
Look for this section near the beginning of the code:
# Ustream settings ----------------------------------------------------------- # 'uKey' is your Developer API key (request one at developer.ustream.tv). # 'uChannel' is Ustream channel to monitor. uKey = 'PUT_USTREAM_DEVELOPER_API_KEY_KERE' uChannel = 'adafruit-industries' # Google+ settings ----------------------------------------------------------- # 'gKey' is your API key from the Google APIs API Access page (need to switch # on G+ on API Services page first). 'gId' is the account ID to monitor (can # find this in the URL of your profile page, mild nuisance but ID is used # because user name is not guaranteed unique. gKey = 'PUT_GOOGLE_API_KEY_HERE' gId = '112526208786662512291' # Adafruit account ID
uKey and gKey are your developer API keys that we previously set up on Ustream and Google+, respectively. uChannel and gId are the Ustream channel name and the Google+ account ID to monitor, respectively. These steps were explained on the Account Setup page.
A little further down, you’ll see a table like this:
A little further down, you’ll see a table like this:
times = [ ("06:00", 60), # 6am, office hours starting, poll once per minute ("21:25", 10), # 9:25pm, Show & Tell starting soon, poll 6X/minute ("21:35", 30), # S&T underway, reduce polling to 2X per minute ("21:55", 10), # 9:55pm, AAE starting soon, poll 6X/minute again ("22:05", 30), # AAE underway, slow polling to 2X per minute ("23:10", 60), # AAE over (plus extra), return to once per minute ("00:00", 900) ] # After midnight, gone home, poll every 15 minutes
The developer APIs permit a limited number of queries per day. In order to provide good response times without blowing past those limits, the software allows you to set up different time periods and polling frequencies within those periods. For example, you might want to poll only once per minute most of the time, but then go into a very fast polling mode (every 5 or 10 seconds) for short periods when you know streams are likely to begin or end, giving the appearance of a much more responsive, interactive system.
Each item in the table consists of two values, surrounded by parenthesis. The first, a string (in quotes), is the start of a time period, expressed in 24-hour local time (e.g. "20:15" is 8:15 pm in your time zone, which may be different than the broadcaster’s time zone). The second is a number (no quotes) indicating the polling frequency, in seconds (e.g. 60 = once per minute).
Once everything’s configured to your liking, try running the software manually:
Each item in the table consists of two values, surrounded by parenthesis. The first, a string (in quotes), is the start of a time period, expressed in 24-hour local time (e.g. "20:15" is 8:15 pm in your time zone, which may be different than the broadcaster’s time zone). The second is a number (no quotes) indicating the polling frequency, in seconds (e.g. 60 = once per minute).
Once everything’s configured to your liking, try running the software manually:
sudo python onair.py
The light still probably won’t do anything, unless the monitored channel(s) are streaming at the time. This is mostly an opportunity to check for any error messages. Syntactical errors (missing quotes, etc.) will usually prevent the script from running at all. Or if you see an error message like this:
Error: : ('items',)
This probably means your developer key or channel ID are missing or improperly formatted.
Once the software is running smoothly without errors, we’ll configure the system to run the script automatically at startup. To abort the program in the terminal window, you’ll need to tap Control+C a few times…it’s a little funny that way.
Error: : ('items',)
This probably means your developer key or channel ID are missing or improperly formatted.
Once the software is running smoothly without errors, we’ll configure the system to run the script automatically at startup. To abort the program in the terminal window, you’ll need to tap Control+C a few times…it’s a little funny that way.
sudo nano /etc/rc.local
Before the final “exit 0” line, insert these two lines:
cd /home/pi python onair.py &
If you placed the onair.py script in a different location, the first line should be changed accordingly. “sudo” isn’t necessary here because the rc.local script is already run as root.
Reboot the system to test the startup function:
Reboot the system to test the startup function:
sudo reboot
After rebooting, log in and type:
ps -e | grep onair
You should see some numbers and a mention of python. That’s good, the code is running. Keyboard and monitor are no longer needed.
Left to its own devices, the light should now come on when either the Ustream or Google+ accounts are broadcasting.
Left to its own devices, the light should now come on when either the Ustream or Google+ accounts are broadcasting.
Page last edited March 08, 2024
Text editor powered by tinymce.