Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Causes Philips Hue lights to flicker
from qhue import Bridge
import time
import random
import sys
bridge_ip = "<hue_ip_address>"
username = "<username>"
my_lights = [light_id_1, light_id_2]
def flicker(bridge, elapsed_time, lights_list = [], transition = 10):
start_time= time.time()
while (time.time() - start_time < elapsed_time):
for light in lights_list:
bridge.lights[light].state(bri=random.randint(50,130),on=True)
time.sleep(random.uniform(0,0.5))
for light in lights_list:
bridge.lights[light].state(transitiontime=random.randint(0, transiti
on), on=False)
time.sleep(random.uniform(0,0.5))
b = Bridge(bridge_ip_address, username)
flicker(b, float(sys.argv[1]), my_lights, transition = 1)
for light in light_list:
b.lights[light].state(bri=255,on=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.