Blog2013 ≫ Step away from the computer now

Just done something stupid on my xbmc setup - the style of music that is playing now controls the lights.

Well, I am left in on my own this evening.

If the song has "pop" in the ID3 tags then the lights go up, if it has "goth" then the lights go off. I'm going to stop now. Here's the code that I butchered into the scrobbler.py plugin:

headers = { "Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain" }
path = '/room/lounge/light'      
params = { 'status': '50', 'key': 'foo' }
if '[Goth](/wiki/#goth)' in data['tags']:
  params['status'] = 'off'
elif 'Pop' in data['tags']:
  params['status'] = '90'
conn = httplib.HTTPConnection( "192.168.1.98:80" )
conn.request( "PUT", path, urllib.urlencode( params ), headers )

Relies on having my lightwaverf api1 installed on that address, and a stack of other hardware going on of course.

Not very sophisticated, and not really the "lights in sync with music" Bellagio effect I am ultimately planning, but something I'd been thinking about. Pleased it worked first time.

Really happy new year now, I'm turning the computer off.

xbmc: XBox Media Centre, some software that would run on an old X-box or other computer hardware to play movies and music etc. I used to talk about this a lot...

⬅️

Paul Clarke's weblog - I live in Hythe in the far South. Wed to Clare and dad to two, I'm a full-stack web engineer, + I do mostly js / Node, some ruby, other languages etc. I like pubbing, running, restaurants, home-automation and other diy stuff, history, tree stuff, Television, squirrels, pirates, lego, + time travel.