Created
December 3, 2017 23:05
-
-
Save annthurium/ebabf764a41d789f85b2c5c68d0920f0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import time | |
from phue import Bridge | |
class LightColor: | |
def __init__(self, name, xy): | |
self.name = name | |
self.xy = xy | |
red = LightColor("red", [0.674, 0.322]) | |
orange = LightColor("orange", [0.6295, 0.3605]) | |
yellow = LightColor("yellow", [0.5071, 0.4712]) | |
green = LightColor("green", [0.1439, 0.7999]) | |
blue = LightColor("blue", [0.238, 0.1798]) | |
dark_blue = LightColor("dark blue", [0.1568, 0.0223]) | |
fuckin_amethyst = LightColor("fuckin' amethyst", [0.2065, 0.0391]) | |
true_purple = LightColor("true purple", [0.2845, 0.0725]) | |
rose_quartz = LightColor("rose quartz", [0.356, 0.103]) | |
pink_red = LightColor("pink red", [0.356, 0.103]) | |
RAINBOW = [ | |
red, | |
orange, | |
yellow, | |
green, | |
blue, | |
dark_blue, | |
fuckin_amethyst, | |
true_purple, | |
rose_quartz, | |
pink_red] | |
# sleep time is in seconds. | |
# Sleep time is longer than transition time, so we can enjoy | |
# the color for a bit and also deal with Zigby's shitty throughput | |
# (it takes time for the bulbs to receive their commands.) | |
SLEEP_TIME = 240 | |
# transition time is in deca seconds | |
TRANSITION_TIME = 1800 | |
MAX_BRIGHTNESS = 254 | |
BRIDGE_IP_ADDRESS = "10.110.0.214" | |
def set_up_lights(lights): | |
for light in lights: | |
light.on = True | |
light.transitiontime = TRANSITION_TIME | |
light.brightness = MAX_BRIGHTNESS | |
def main(): | |
bridge = Bridge(BRIDGE_IP_ADDRESS) | |
bridge.connect() | |
lights = bridge.lights | |
set_up_lights(lights) | |
while True: | |
for color in RAINBOW: | |
for light in lights: | |
light.xy = color.xy | |
print "%s has started transitioning to %s" % (light.name, color.name) | |
time.sleep(SLEEP_TIME) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment