Skip to content

Instantly share code, notes, and snippets.

Last active Dec 31, 2015
What would you like to do?
Code for make blink sticks talk to cheer lights. More info at and
Download this script and run it as
chmod 755
and run it
It will run forever checking and changing the colour every 30 seconds.
import requests, json, time
from blinkstick import blinkstick
# url to fetch from
cheer_lights_url = ""
def fetch_current_colour():
# grab the colour
r = requests.get(cheer_lights_url)
# anything else than 200 from the HTTP request means it failed
if (r.status_code != 200):
print "Unable to fetch current colour, quitting"
# reply from cheer lights looks like
# {
# created_at: "2013-12-22T15:37:40Z",
# entry_id: 10323,
# field1: "purple"
# }
raw_json = json.loads(r.content)
# return the colour from the loaded json
return raw_json.get('field1')
except Exception as e:
print "Unable to fetch current colour, quitting because %s" % (e)
def light_up():
# get the colour
colour = fetch_current_colour()
print "setting to %s" % (colour)
# cycle over all the blinksticks setting the colour
for bstick in blinkstick.find_all():
if __name__ == '__main__':
# loop forever
while (True):
# set the colour
# wait for a bit
Copy link

Ciemon commented Dec 24, 2013

At line 25 there is a call to import requests. Requests "is an elegant and simple HTTP library for Python" and can be installed with:

$ pip install requests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment