Blog2013 ≫ Step away from the computer now

Just done something stupid on my xbmc 1 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 api 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.

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

⬅️

Paulʼs blog - I live near Folkestone, Kent. Married + father to two, I am a full stack web engineer, + I do js / node, some ruby, python, php ect ect. My hobbies are pubbing, running, eating, home-automation 🤖 + other diy jiggery-pokery, history, family tree stuff, telly, squirrels, pirates, lego, + time travel.