コード例 #1
0
ファイル: ulfire.py プロジェクト: HeatfanJohn/ulfire
    DEBUG = True

# Set up our singleton for polling the sockets for data ready
p = poller()

# Set up our singleton listener for UPnP broadcasts
u = upnp_broadcast_responder()
u.init_socket()

# Add the UPnP broadcast listener to the poller so we can respond
# when a broadcast is received.
p.add(u)

hue = None

bulbs = lazylights.find_bulbs(timeout=1)
if len(bulbs) > 0:
    hue = fauxhue("Fauxhue", u, p, None, 0)
    bulbstate = lazylights.get_state(bulbs)
    for bulb in bulbstate:
        bulbname = str(bulb.label)
        bulbname = bulbname.rstrip('\x00')
        hue.add_bulb(bulbname, state=bool(bulb.power), brightness=(255 * bulb.brightness / 255), action_handler = lifx_api_handler(), private=bulb)

env = Environment()
env.start()
env.discover(10)
for bridgename in env.list_bridges():
    bridge = env.get_bridge(bridgename)
    if len(bridge.Lights) > 0 and hue == None:
        hue = fauxhue("Fauxhue", u, p, None, 0) 
コード例 #2
0
    import Tkinter as tk
    import Queue as queue
except ImportError:
    import tkinter as tk
    import queue as queue

LIFX_CONNECT = True

global top
global LAST_UPDATE

MIN_REFRESH_INTERVAL = 0.5
LAST_UPDATE = 0
lastUpdateTimestamp = 0

bulbs = lazylights.find_bulbs(expected_bulbs=1, timeout=10)
print "Found bulb(s): ", bulbs, "\nState", lazylights.get_state(bulbs,
                                                                timeout=5)

MAXIMUM = 40.0
buffSize = 30

top = tk.Tk()
#top.attributes("-fullscreen", True)
top.configure(background='black')
w, h = top.winfo_screenwidth() / 1.25, top.winfo_screenheight() / 2.
#top.overrideredirect(1)
top.geometry("%dx%d+0+0" % (w, h))
top.focus_set()

top.bind('<Escape>', lambda e: e.widget.quit())  # top.destroy())
コード例 #3
0
ファイル: handy.py プロジェクト: Apophenian/handylights
 def __init__(self):
     self.bulbs = lazylights.find_bulbs()
     states = lazylights.get_state(self.bulbs)
     if states:
         self.initial_state = BulbState(states[0])  # being lazy, we'll just use the first bulb's state
         self.current_state = BulbState(states[0])
コード例 #4
0
ファイル: begin.py プロジェクト: balicaf/theater-automation
import lazylights
import time

#to power on every bulbs connected to your router
bulbs = lazylights.find_bulbs(expected_bulbs=3, timeout=5)
lazylights.set_power(bulbs, True)

#If you want to light on only a few of your bulbs:
#bulbs_by_name = {state.label.strip(" \x00"): state.bulb
#		for state in lazylights.get_state(bulbs)}
#print (bulbs_by_name)
#lazylights.set_power([bulbs_by_name['Nice']], True)
#lazylights.set_power([bulbs_by_name['Right']], True)

コード例 #5
0
    DEBUG = True

# Set up our singleton for polling the sockets for data ready
p = poller()

# Set up our singleton listener for UPnP broadcasts
u = upnp_broadcast_responder()
u.init_socket()

# Add the UPnP broadcast listener to the poller so we can respond
# when a broadcast is received.
p.add(u)

hue = None

bulbs = lazylights.find_bulbs(timeout=1)
if len(bulbs) > 0:
    hue = fauxhue("Fauxhue", u, p, None, 0)
    bulbstate = lazylights.get_state(bulbs)
    for bulb in bulbstate:
        bulbname = str(bulb.label)
        bulbname = bulbname.rstrip('\x00')
        hue.add_bulb(bulbname,
                     state=bool(bulb.power),
                     brightness=(255 * bulb.brightness / 255),
                     action_handler=lifx_api_handler(),
                     private=bulb)

env = Environment()
env.start()
env.discover(10)