Skip to content

Instantly share code, notes, and snippets.

@phred
Created December 31, 2013 02:54
Show Gist options
  • Save phred/8191801 to your computer and use it in GitHub Desktop.
Save phred/8191801 to your computer and use it in GitHub Desktop.
2012–2013 Python/Raspberry Pi-powered cheerlights hack. See http://www.cheerlights.com/
#!/usr/bin/python
import zlib, base64, requests, time, os
known_colors = "red green blue cyan white warmwhite purple magenta yellow orange purple".split(" ")
def ho_ho_ho():
return zlib.decompress(base64.b64decode('eJzj0gUBWxBQAAMPR2fvSAUPfx9PF8fIYAW3IANfh'
'ZKMVOec0qSM/FK94lQFGADpAevmggsp6Onq6sWDCBCNhwEi4NriNeKhjEgiGJrxMI3R8fHxsSQxYDr1r'
'dQVYkhiQHXWWFmBSJIYUK0xVlZ6QMNIYgC1ZqUXQ7j6MEOIYsADV91WnSQGFwBnQmi8'))
def color_generator():
etag = ''
while True:
r = requests.get('http://api.thingspeak.com/channels/1417/field/1/last.txt', headers={'if-none-match': etag})
etag = r.headers['etag']
if r.status_code == 200:
yield r.content
elif r.status_code == 304:
time.sleep(30)
pass # no change
else:
print r.status_code, r.content, r.headers
raise StopIteration()
if __name__ == "__main__":
print ho_ho_ho()
color_stream = color_generator()
for color in color_stream:
print color
if color in known_colors:
code = os.system("irsend send_once sylvania.conf %s" % color)
# else:
# time.sleep(60)
time.sleep(60)
# /etc/lirc/lircd.conf
#
# this config file was automatically generated
# using lirc-0.9.0-pre1(default) on Thu Dec 6 09:25:46 2012
#
# contributed by phred
#
# brand: sylvania.conf
# model no. of remote control:
# devices being controlled by this remote:
#
begin remote
name sylvania.conf
bits 24
flags SPACE_ENC|CONST_LENGTH
eps 30
aeps 100
header 8994 4432
one 587 1647
zero 587 535
ptrail 591
repeat 8998 2199
pre_data_bits 8
pre_data 0x0
gap 107538
toggle_bit_mask 0x0
begin codes
red 0xFB9867
blue 0xFB8877
green 0xFFD827
off 0xFBF807
on 0xFBB04F
brightness+ 0xFB906F
brightness- 0xFB906F ## WRONG, argh.
flash 0xFBB24D
strobe 0xFF00FF
fade 0xFF58A7
smooth 0xFB30CF
violet 0xFBF00F
purple1 0xFB708F
purple 0xFF20DF
warmwhite 0xFF50AF
lightorange 0xFF02FD
cyan 0xFF32CD
darkcyan 0xFF7887
bluegreen 0xFF28D7
magenta 0xFFF00F
yellow 0xFF38C7
white 0xFFA857
orange 0xFFE817
end codes
end remote
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment