def main(): num_lights = None if len(sys.argv) != 2: print( "\nDiscovery will go much faster if you provide the number of lights on your LAN:" ) print(" python {} <number of lights on LAN>\n".format(sys.argv[0])) else: num_lights = int(sys.argv[1]) # instantiate LifxLAN client, num_lights may be None (unknown). # In fact, you don't need to provide LifxLAN with the number of bulbs at all. # lifx = LifxLAN() works just as well. Knowing the number of bulbs in advance # simply makes initial bulb discovery faster. print("Discovering lights...") lifx = LifxLAN(num_lights, verbose=True) # get devices devices = lifx.lights labels = [] for device in devices: labels.append(device.label) print("Found Bulbs:") for label in labels: print(" " + str(label))
def __main(): lifx = LifxLAN() group = lifx['guest'] + lifx['guest_floor'] cycle_themes(group, Themes.xmas, rotate_secs=3, duration_mins=1, transition_secs=1) return # lifx = lifx['living_room'] + lifx['kitchen'] # lifx.set_color(Colors.DEFAULT) # blink_color(lifx, blink_time_secs=3) # rainbow(lifx, duration_secs=4, smooth=True) # breathe(lifx, colors=(Colors.SNES_LIGHT_PURPLE, Colors.SNES_DARK_PURPLE), min_brightness_pct=20) # themes = Themes.xmas, Themes.snes, Themes.copilot # themes = [(Colors.SNES_DARK_PURPLE, Colors.SNES_LIGHT_PURPLE), # (Colors.COPILOT_BLUE, Colors.COPILOT_DARK_BLUE), # (Colors.RED, Colors.GREEN)] # lifx = lifx['creative_space'] # cycle_themes(lifx, Themes.xmas, rotate_secs=60, duration_mins=60, transition_secs=60) # with lifx.reset_to_orig(): # lifx.turn_on() # breathe(lifx, colors=Colors.YALE_BLUE, min_brightness_pct=20, max_brightness_pct=70) # fireworks(lifx) # waveforms(lifx, Waveform.pulse, Colors.SNES_DARK_PURPLE, Colors.PYTHON_LIGHT_BLUE, skew_ratio=.3) # lifx = lifx['living_room'] + lifx['kitchen'] + lifx['dining_room'] group = lifx['guest'] + lifx['guest_floor'] fireworks(group) # lifx.turn_on() # sleep(3) # lifx.turn_off() print(group.off_lights)
def main(): num_lights = None if len(sys.argv) != 2: print("\nDiscovery will go much faster if you provide the number of lights on your LAN:") print(" python {} <number of lights on LAN>\n".format(sys.argv[0])) else: num_lights = int(sys.argv[1]) # instantiate LifxLAN client, num_lights may be None (unknown). # In fact, you don't need to provide LifxLAN with the number of bulbs at all. # lifx = LifxLAN() works just as well. Knowing the number of bulbs in advance # simply makes initial bulb discovery faster. print("Discovering lights...") lifx = LifxLAN(num_lights,False) # get devices multizone_lights = lifx.multizone_lights if len(multizone_lights) > 0: strip = multizone_lights[0] print("Selected {}".format(strip.label)) all_zones = strip.get_color_zones() original_zones = deepcopy(all_zones) zone_count = len(all_zones) delay = 0.06 snake_color = RED background_color = GREEN snake_size = zone_count/2 # length of snake in zones tail = 0 head = snake_size - 1 try: while True: # Case 1: Snake hasn't wrapped around yet if head > tail: if tail > 0: strip.set_zone_color(0, tail-1, background_color, 0, True, 0) strip.set_zone_color(tail, head, snake_color, 0, True, 0) if head < zone_count - 1: strip.set_zone_color(head+1, zone_count-1, background_color, 0, True, 1) # Case 2: Snake has started to wrap around else: if head > 0: strip.set_zone_color(0, head-1, snake_color, 0, True, 0) strip.set_zone_color(head, tail, background_color, 0, True, 0) if tail < zone_count - 1: strip.set_zone_color(tail+1, zone_count-1, snake_color, 0, True, 1) # update indices for the snake's head and tail tail = (tail+1) % zone_count head = (head+1) % zone_count sleep(delay) except KeyboardInterrupt: strip.set_zone_colors(original_zones, 500, True)
def __main(): # return getch_test() lifx = LifxLAN() # lifx.set_color(Colors.DEFAULT) print(lifx.on_lights) lifx = lifx['kitchen'] + lifx['living_room'] # lifx = lifx['master'] # lifx = lifx['living room 1'] # control(lifx, [Colors.SNES_DARK_PURPLE, Colors.SNES_LIGHT_PURPLE]) light_eq(lifx, Themes.copilot)
def test_powers(): group = LifxLAN().color_lights with group.reset_to_orig(5000): group.set_power(0, 1000) time.sleep(1) for _ in range(5): group.refresh_power() print(group.power) time.sleep(.5)
def main(): num_lights = None if len(sys.argv) != 2: print("\nDiscovery will go much faster if you provide the number of lights on your LAN:") print(" python {} <number of lights on LAN>\n".format(sys.argv[0])) else: num_lights = int(sys.argv[1]) # instantiate LifxLAN client, num_lights may be None (unknown). # In fact, you don't need to provide LifxLAN with the number of bulbs at all. # lifx = LifxLAN() works just as well. Knowing the number of bulbs in advance # simply makes initial bulb discovery faster. print("Discovering lights...") lifx = LifxLAN(num_lights,False) # get devices multizone_lights = lifx.multizone_lights if len(multizone_lights) > 0: strip = multizone_lights[0] print("Selecting " + strip.label) all_zones = strip.get_color_zones() original_zones = deepcopy(all_zones) zone_buff = all_zones ignore = [-1] try: while True: for i in range(12): z = -1 while z in ignore: z = randrange(0,len(zone_buff)) ignore.append(z) h, s, v, k = zone_buff[z] zone_buff[z] = h, s, 2000, k strip.set_zone_color(z, z, [h, s, 40000, k], 500, True) sleep(0.01) #l.set_zone_colors(zone_buff, 2000, True) for i in range(12): z = -1 while z in ignore: z = randrange(0,len(zone_buff)) ignore.append(z) h, s, v, k = zone_buff[z] zone_buff[z] = h, s, 65535, k strip.set_zone_color(z, z, [h, s, 65535, k], 500, True) sleep(0.01) #l.set_zone_colors(zone_buff, 2000, True) #sleep(0.25) ignore = [-1] except KeyboardInterrupt: strip.set_zone_colors(original_zones, 1000, True)
def main(): num_lights = None if len(sys.argv) != 2: print( "\nDiscovery will go much faster if you provide the number of lights on your LAN:" ) print(" python {} <number of lights on LAN>\n".format(sys.argv[0])) else: num_lights = int(sys.argv[1]) # instantiate LifxLAN client, num_lights may be None (unknown). # In fact, you don't need to provide LifxLAN with the number of bulbs at all. # lifx = LifxLAN() works just as well. Knowing the number of bulbs in advance # simply makes initial bulb discovery faster. print("Discovering lights...") lifx = LifxLAN(num_lights, False) # get devices multizone_lights = lifx.multizone_lights if len(multizone_lights) > 0: strip = multizone_lights[0] print("Selecting " + strip.label) all_zones = strip.get_color_zones() original_zones = all_zones dim_zones = [] bright_zones = [] for [h, s, v, k] in all_zones: dim_zones.append((h, s, 20000, k)) bright_zones.append((h, s, 65535, k)) try: print("Breathing...") while True: strip.set_zone_colors(bright_zones, 2000, True) sleep(2) strip.set_zone_colors(dim_zones, 2000, True) sleep(2) except KeyboardInterrupt: strip.set_zone_colors(original_zones, 1000, True) else: print("No lights with Multizone capability detected.")
def __main(): # import routines # print(help(routines.core)) # print(help(routines.morse_code)) # print(help(routines.light_eq)) from lifxlan3.settings import global_settings print(global_settings.items()) global_settings.preserve_brightness = False print(global_settings.items()) return t = LifxLAN() l = t.multizone_lights[0] print(l.zones) l.set_theme(Themes.rainbow) return print(default_override.get('library')) print(default_override.get('library')) print(default_override.get('library')) print(default_override.get('library')) print(default_override.get('library')) return lifx = LifxLAN() lr1 = lifx.get_device_by_name('living room 1') return print(Themes.xmas.color_str('xmas')) print((Themes.xmas + Theme.from_colors()).color_str('snth')) return print(Themes.xmas.get_colors(6)) lifx = LifxLAN() # lifx.set_color(Colors.DEFAULT) with lifx.reset_to_orig(): lifx.turn_on() lifx.set_theme(Themes.xmas) time.sleep(15) return return test_powers() return grid_test() print(Colors) c = Colors.YALE_BLUE print(c.offset_hue(60)) exhaust(map(print, Themes.snes)) # exhaust(map(print, c.get_complements(1))) # exhaust(map(print, c.get_complements(1))) comps = c.get_complements(.2) # print(len(comps)) lan = LifxLAN() print(lan.lights) ag = lan.auto_group() m = ag['master'] print(m + ag['living_room'] + m) print(isinstance(m, Iterable)) cs, vs = zip(*Colors) c = vs[0] print(len(c.get_complements(20))) print(c) c += vs[1] print(c, vs[0] + vs[1]) print('JEB', Colors.sum(*vs)) return print(m) print(lan.on_lights) print(lan.off_lights) return exhaust(map(print, m.color_power.items())) return m.set_color(Colors.DEFAULT) return for c in Themes.snes: m.set_color(c) time.sleep(5) return c = Color.mean(*(c for _, c in Colors)) print(c) m.set_color(c) time.sleep(4) m.set_color(Colors.DEFAULT) return # for _ in range(20): # t = get_vals(1300) # t.sort() # gb = groupby(t) # for k, v in gb: # print(k, sum(1 for _ in v)) # print() # # return for _ in range(20): t = Themes.xmas.get_colors(27) t.sort() gb = groupby(t) for k, v in gb: print(k, sum(1 for _ in v)) print() return lan = LifxLAN() print(lan.auto_group()) print(lan.color_lights) return l1 = lan.get_device_by_name('test') # l2 = lan.get_device_by_name('master 2') labels = [l.label for l in lan.lights] for lab in sorted(labels): print(lab) print(l1.color) duration = 4 orig = l1.color l2.set_color(Color.from_hex(0xf4d92, l2.color.kelvin), duration=duration * 1000) time.sleep(duration) l2.set_color(orig, duration=duration * 1000) return print(len(lan.lights)) print(l.color) print(l.power_level) print(lan.get_color_all_lights())
from lifxlan3 import LifxLAN, Device, Color as LColor from rich import print from rich.color import Color from utils.core import take def _from_hsv(cls, color: LColor): cls: Color return cls.from_rgb(*take(3, color.rgb)) Color.from_hsv = classmethod(_from_hsv) t = LifxLAN()['guest'] l = t[0] vals = {attr: val for attr in dir(l) if not attr.startswith('_') and not callable(val := getattr(l, attr))} print(vals) class LightDisp: def __init__(self, device: Device): self._device = device def __getattr__(self, item): return getattr(self._device, item) def __rich_repr__(self): c = Color.from_hsv(self.color)
def get_tile_chain() -> Optional[TileChain]: with suppress(IndexError): lifx = LifxLAN() return lifx.tilechain_lights[0]
def __main(): lan = LifxLAN() g = lan.auto_group()['master'] exhaust(map(print, (light.power for light in g))) morse_code('s', g)
def __getattribute__(self, item): lights = super().__getattribute__('_lights') if lights is None: lights = self._lights = LifxLAN() return getattr(lights, item)
def __main(): lifx = LifxLAN() point_control(lifx['living_room'] + lifx['buffet'] + lifx['floor'] + lifx['dining_room'] + lifx['kitchen'], Colors.SNES_DARK_PURPLE, Colors.CYAN, tail_delay_secs=2)