Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions lights.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import asyncio
import logging
import datetime
# -*- coding: utf-8 -*-
from time import sleep
import csv
import logging

from phue import Bridge
import pychromecast
Expand Down Expand Up @@ -67,13 +67,17 @@ def change_light(bridge, color):
light.xy = HUE_COLORS[color]

def main():
loop = asyncio.get_event_loop()
start_video()
bridge = setup_hue()
for time, color in HUE_CUES:
loop.call_later(time + DELAY, change_light, bridge, color)
loop.run_forever()
loop.close()
sleep(DELAY)
for index, (time, color) in enumerate(HUE_CUES):
change_light(bridge, color)
try:
next_time = HUE_CUES[index + 1][0]
except IndexError: # At last iteration
continue
delta = next_time - time
sleep(delta)

if __name__ == "__main__":
logging.basicConfig(
Expand Down