Skip to content

Instantly share code, notes, and snippets.

@ethanrusz
Forked from benrules2/flicker.py
Created September 29, 2019 00:48
Show Gist options
  • Save ethanrusz/8179bc11f8546a60151a5ae99790c78b to your computer and use it in GitHub Desktop.
Save ethanrusz/8179bc11f8546a60151a5ae99790c78b to your computer and use it in GitHub Desktop.
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