Skip to content

Instantly share code, notes, and snippets.

@bazwilliams
Created October 13, 2018 07:40
Show Gist options
  • Save bazwilliams/59566ae19d7222713b24afcd14dfc2db to your computer and use it in GitHub Desktop.
Save bazwilliams/59566ae19d7222713b24afcd14dfc2db to your computer and use it in GitHub Desktop.
The Williams' Family Disco!
#!/usr/bin/python
from phue import Bridge
from rgbxy import Converter
import random
import time
b = Bridge('philips-hue')
b.connect()
light_names = b.get_light_objects('name')
converter = Converter()
lights = [ light_names['Lounge Lamp'], light_names['Lounge Main'] ]
colours = [ 'FF0000', '00FF00', '0000FF', 'FF00FF' ]
while(True):
for colour in colours:
for light in lights:
light.on = True
light.transitiontime = 1
light.xy = converter.hex_to_xy(colour)
time.sleep(0.1)
FROM python:3.6
RUN pip3 install phue rgbxy
ADD app.py /app/
CMD python3 /app/app.py
@bazwilliams
Copy link
Author

bazwilliams commented Oct 13, 2018

Build

Rename the lights as appropriate for your house.

docker build -t disco .

Run

Press the button on your Hue bridge

docker run disco

Dance

spotify:user:barryjohnwilliams:playlist:1Ut5juChbYvoqSeUK56Fct

Improve

[ ] Use MQTT to turn disco mode on or off
[ ] Configurable lights
[ ] Configurable bridge or auto discovery
[ ] Use Spotify Web API to start music; or
[ ] Hook into HomeAssistant

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