示例#1
0
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.
    lifx = LifxLAN(num_lights)

    # test power control
    print("Discovering lights...")
    original_powers = lifx.get_power_all_lights()

    print("Turning lights on...")
    lifx.set_power_all_lights("on")

    sleep(0.2)

    print("Toggling power of all lights...")
    toggle_all_lights_power(lifx, 0.2)

    print("Restoring power to all lights...")
    for light, power in original_powers:
        light.set_power(power)

    # test color control
    original_colors = lifx.get_color_all_lights()

    print("Turning lights on...")
    lifx.set_power_all_lights("on")

    sleep(1)

    print("Toggling color of all lights quickly...")
    toggle_all_lights_color(lifx, 0.2)

    print("Toggling color of all lights slowly...")
    toggle_all_lights_color(lifx, 1)

    print("Restoring original color to all lights...")
    for light, color in original_colors:
        light.set_color(color)

    sleep(1)

    print("Restoring original power to all lights...")
    for light, power in original_powers:
        light.set_power(power)
示例#2
0
def main():
    print("Discovering lights...")
    lifx = LifxLAN(num_lights)

    original_colors = lifx.get_color_all_lights()
    original_powers = lifx.get_power_all_lights()

    print("Turning on all lights...")
    lifx.set_power_all_lights(True)
    sleep(1)

    lan.set_color_all_lights(0, 0, True)
示例#3
0
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.
    lifx = LifxLAN(num_lights)

    # test power control
    print("Discovering lights...")
    original_powers = lifx.get_power_all_lights()

    print("Turning lights on...")
    lifx.set_power_all_lights("on")

    print("Toggling power of all lights...")
    toggle_all_lights_power(lifx, 0.2)

    print("Restoring power to all lights...")
    for light in original_powers:
        light.set_power(original_powers[light])

    # test color control
    original_colors = lifx.get_color_all_lights()

    print("Turning lights on...")
    lifx.set_power_all_lights("on")

    print("Toggling color of all lights quickly...")
    toggle_all_lights_color(lifx, 0.2)

    print("Toggling color of all lights slowly...")
    toggle_all_lights_color(lifx, 0.5)

    print("Restoring original color to all lights...")
    for light in original_colors:
        light.set_color(original_colors[light])

    sleep(0.2)

    print("Restoring original power to all lights...")
    for light in original_powers:
        light.set_power(original_powers[light])
def main():
    # Locate your light
    lifx = LifxLAN(1)

    # Turn on the light
    lifx.set_power_all_lights(True)

    # Change the colors of the light
    colors = [RED, ORANGE, YELLOW, GREEN, CYAN, BLUE, PURPLE, PINK]
    sleep_time_s = 0.1

    for color in colors:
        lifx.set_color_all_lights(color)
        sleep(sleep_time_s)

    lifx.set_power_all_lights(False)
示例#5
0
class Lifxservice():
    def __init__(self, location, debug=False):
        self._debug = debug
        self._lifxlan = LifxLAN()

        self._daytime = Daytime(location)

    def start(self):
        self._lifxlan.set_power_all_lights("off", rapid=False)

    def stop(self):
        # When coming home, turn on the lights if the sun has set
        if self._daytime.dark_outside():
            self._lifxlan.set_power_all_lights("on", rapid=False)            

    def generate_summary(self):
        # Not very interesting to show a summary for the sonos service
        return None
示例#6
0
def main():

  # Definitions for the Floral Bonnet extension   
  GPIO.setmode(GPIO.BCM)
  GPIO.setup(4, GPIO.IN, pull_up_down=GPIO.PUD_UP)

  # Object representation of the LAN network
  lan = LifxLAN()
  light = lan.get_device_by_name("Room")

  while True:
     input_state = GPIO.input(4)
     if input_state == False:
          try:
               state = light.get_power()
               if state == 65535:	
                    lan.set_power_all_lights(0)
               else:
                    lan.set_power_all_lights(65535)
          except:
               continue
示例#7
0
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)

    original_colors = lifx.get_color_all_lights()
    original_powers = lifx.get_power_all_lights()

    print("Turning on all lights...")
    lifx.set_power_all_lights(True)
    sleep(1)

    print("Flashy fast rainbow")
    rainbow(lifx, 0.1)

    print("Smooth slow rainbow")
    rainbow(lifx, 1, smooth=True)

    print("Restoring original color to all lights...")
    for light, color in original_colors:
        light.set_color(color)

    sleep(1)

    print("Restoring original power to all lights...")
    for light, power in original_powers:
        light.set_power(power)
示例#8
0
def scene_two():
    num_lights = None
    if len(sys.argv) != 2:
        print()
    else:
        num_lights = int(sys.argv[1])

    lifx = LifxLAN(num_lights)
    original_colors = lifx.get_color_all_lights()
    original_powers = lifx.get_power_all_lights()
    lifx.set_power_all_lights(True)
    sleep(1)
    earth(lifx, 5, smooth=True)

    #print("Restoring original color to all lights...")
    for light in original_colors:
        light.set_color(original_colors[light])

    sleep(1)

    #print("Restoring original power to all lights...")
    for light in original_powers:
        light.set_power(original_powers[light])
示例#9
0
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)

    original_colors = lifx.get_color_all_lights()
    original_powers = lifx.get_power_all_lights()

    print("Turning on all lights...")
    lifx.set_power_all_lights(True)
    sleep(1)

    print("Flashy fast rainbow")
    rainbow(lifx, 0.1)

    print("Smooth slow rainbow")
    rainbow(lifx, 1, smooth=True)

    print("Restoring original color to all lights...")
    for light in original_colors:
        light.set_color(original_colors[light])

    sleep(1)

    print("Restoring original power to all lights...")
    for light in original_powers:
        light.set_power(original_powers[light])
示例#10
0
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])

    print("Discovering lights...")
    lifx = LifxLAN(num_lights)

    original_colors = lifx.get_color_all_lights()
    original_powers = lifx.get_power_all_lights()

    print("Turning on all lights...")
    lifx.set_power_all_lights(True)
    sleep(1)
    print("Discovering lights...")

    half_period_ms = 2500
    duration_mins = 20
    duration_secs = duration_mins * 60

    #60000 =red
    for bulb in original_colors:
        color = original_colors[bulb]
        dim = list(copy(color))
        i = 0
        dim[0] = 38000
        bulb.set_color(dim, 0, rapid=True)
        while True:
            text = raw_input("Color = ")
            dim[0] = int(text)
            bulb.set_color(dim, 0, rapid=True)
示例#11
0
文件: light.py 项目: KoalaV2/K.A.I
def setlightcolor(color):

    print("Discovering lights...")
    lifx = LifxLAN(1)

    devices = lifx.get_lights()
    print(f"Found light: {devices}")

    original_colors = lifx.get_color_all_lights()

    color_up = str(color.upper())

    if color_up == "OFF":
        lifx.set_power_all_lights("off")
        print("Turned off the light..")
        return ()

    color_name = {
        "RED": RED,
        "BLUE": BLUE,
        "CYAN": CYAN,
        "GREEN": GREEN,
        "ORANGE": ORANGE,
        "PURPLE": PURPLE,
        "YELLOW": YELLOW
    }

    print("Turning on the light...")
    lifx.set_power_all_lights("on")

    if color_up in color_name:
        print(f"Setting color to {color_up}")
        lifx.set_color_all_lights(color_name[color_up])
    else:
        print("Color not found, defaulting to pink")
        lifx.set_color_all_lights(PINK)
示例#12
0
class LifxProjectionStatusBarApp(rumps.App):
    ICON = 'eye.png'

    def __init__(self, **kwargs):
        menu = [
            'Enable/disable LIFX color projection',
            'Status',
        ]
        # click provides us with ability to set command line options,
        # here we convert those options into UI elements in the menu.
        self.opts = kwargs

        def set_opt_from_ui(opt):
            def inner(_):
                previous_value = str(self.opts[opt.name])
                response = rumps.Window("Set value for '%s'..." % (opt.name),
                                        opt.help,
                                        dimensions=(200, 20),
                                        default_text=previous_value).run()
                if response.text:
                    self.opts[opt.name] = opt.type(response.text)

            return inner

        for opt in main.params:
            menu.append(
                rumps.MenuItem('Preference: set %s' % opt.name,
                               callback=set_opt_from_ui(opt)), )

        use_icon = self.ICON if os.path.exists(self.ICON) else None
        super(LifxProjectionStatusBarApp, self).__init__("LIFX",
                                                         icon=use_icon,
                                                         menu=menu)

        # defaults
        self.enable_lifx_projection = False
        self.lifx_found_any_lights = False

        # lifx
        self.lifx = LifxLAN(None, verbose=False)
        self.lifx.set_power_all_lights("on", rapid=False)

    def _project_screenshot_to_lifx(self):
        color = average_color_from_screenshot()
        color_scaled = (
            color[0],
            # TODO: We might want to use gamma/power instead of multiplication
            min(1.0, color[1] * self.opts['saturation']),
            min(1.0, color[2] * self.opts['brightness']),
        )
        print('Hue: %.3f Sat: %.3f Bri: %.3f' % color_scaled)

        color_lifx = [
            int(color_scaled[0] * 65535),
            int(color_scaled[1] * 65535),
            int(color_scaled[2] * 65535), self.opts['temperature']
        ]
        self.lifx.set_color_all_lights(color_lifx,
                                       duration=TRANSITION_DURATION * 0.9,
                                       rapid=True)

    @rumps.clicked('Enable/disable LIFX color projection')
    def menu_enable_lifx_projection(self, sender):
        sender.state = not sender.state
        self.enable_lifx_projection = sender.state

    @rumps.timer(TRANSITION_DURATION)
    def projection_timer(self, timer):
        if self.enable_lifx_projection and self.lifx_found_any_lights:
            self._project_screenshot_to_lifx()

    @rumps.timer(10)
    def reconfiguration_timer(self, timer):
        print('Reconfiguration')
        self.lifx_found_any_lights = bool(self.lifx.get_lights())

    @rumps.clicked('Status')
    def menu_status(self, _):
        lights = []
        try:
            for light in self.lifx.get_power_all_lights():
                lights.append(str(light[0]))
        except Exception as e:
            lights.append('Caught an exception: %s' % str(e))

        status = ('Enable projection: %d\n'
                  'Found any lights: %d\n'
                  'Scale brightness: %.3f\n'
                  'Scale saturation: %.3f\n'
                  'Use temperature when changing colors: %d K\n'
                  '\nList of lights (%d): \n\n%s' %
                  (self.enable_lifx_projection, self.lifx_found_any_lights,
                   self.opts['brightness'], self.opts['saturation'],
                   self.opts['temperature'], len(lights),
                   '\n'.join(lights) if lights else 'No lights found'))
        window = rumps.Window('',
                              'Status',
                              default_text=status,
                              dimensions=(700, 600))
        window.run()
示例#13
0
def lightDiscovery():
    # Discover lights
    print("Discovering lights...")
    lifx = LifxLAN(None, False)
    lifx.set_power_all_lights("on", duration=1000, rapid=True)

    # Get devices
    multizone_lights = lifx.get_multizone_lights()

    if len(multizone_lights) > 0:
        strip = multizone_lights[0]
        print("Selected {}".format(strip.get_label()))

        # Light Stuff
        all_zones = strip.get_color_zones()
        original_zones = deepcopy(all_zones)
        zone_count = len(all_zones)

        # Options
        colour_options = [
            BLUE, COLD_WHITE, CYAN, GOLD, GREEN, ORANGE, PINK, PURPLE, RED,
            WARM_WHITE, WHITE, YELLOW
        ]
        starting_color = YELLOW
        current_color = starting_color
        background_color = WHITE
        user_triggered_transition_duration = 100

        # User Stuff
        user_zone_size = zone_count / 6  # length of snake in zones
        current_user_zone_start = (zone_count / 2) - (user_zone_size / 2)
        current_user_zone_end = current_user_zone_start + user_zone_size

        try:
            while True:
                strip.set_color(background_color)
                strip.set_zone_color(current_user_zone_start,
                                     current_user_zone_end, current_color, 500)

                def on_press(
                        key
                ):  # The function that's called when a key is released
                    nonlocal current_user_zone_start
                    nonlocal current_user_zone_end
                    nonlocal current_color
                    nonlocal background_color
                    nonlocal user_zone_size

                    print("-- key: {0}.".format(key))

                    # Get new colour
                    new_color = random.choice(colour_options)
                    while new_color == current_color:
                        new_color = random.choice(colour_options)

                    # If up key is pressed increase the snake size by 1
                    if key == Key.up:
                        user_zone_size = min(user_zone_size + 1,
                                             zone_count - 1)
                        current_user_zone_end = current_user_zone_start + user_zone_size
                        strip.set_zone_color(
                            current_user_zone_start, current_user_zone_end,
                            current_color, user_triggered_transition_duration)
                        strip.set_zone_color(
                            0, current_user_zone_start - 1, background_color,
                            user_triggered_transition_duration)
                        strip.set_zone_color(
                            current_user_zone_end + 1, zone_count,
                            background_color,
                            user_triggered_transition_duration)

                    # If down key is pressed decrease the snake size by 1
                    if key == Key.down:
                        user_zone_size = max(user_zone_size - 1, 1)
                        current_user_zone_end = current_user_zone_start + user_zone_size
                        strip.set_zone_color(
                            current_user_zone_start, current_user_zone_end,
                            current_color, user_triggered_transition_duration)
                        strip.set_zone_color(
                            0, current_user_zone_start - 1, background_color,
                            user_triggered_transition_duration)
                        strip.set_zone_color(
                            current_user_zone_end + 1, zone_count,
                            background_color,
                            user_triggered_transition_duration)

                    # If left arrow key is pressed move the snake left 1
                    if key == Key.left:
                        current_user_zone_start = min(
                            current_user_zone_start + 1, zone_count)
                        current_user_zone_end = min(current_user_zone_end + 1,
                                                    zone_count)
                        strip.set_zone_color(
                            current_user_zone_start, current_user_zone_end,
                            current_color, user_triggered_transition_duration)
                        strip.set_zone_color(
                            0, max(current_user_zone_start - 1,
                                   0), background_color,
                            user_triggered_transition_duration)
                        strip.set_zone_color(
                            current_user_zone_end + 1, zone_count,
                            background_color,
                            user_triggered_transition_duration)

                    # If right arrow key is pressed move the snake right 1
                    if key == Key.right:
                        current_user_zone_start = max(
                            current_user_zone_start - 1, 0)
                        current_user_zone_end = max(current_user_zone_end - 1,
                                                    0)
                        strip.set_zone_color(
                            current_user_zone_start, current_user_zone_end,
                            current_color, user_triggered_transition_duration)
                        strip.set_zone_color(
                            0, max(current_user_zone_start - 1,
                                   0), background_color,
                            user_triggered_transition_duration)
                        strip.set_zone_color(
                            current_user_zone_end + 1, zone_count,
                            background_color,
                            user_triggered_transition_duration)

                def on_release(
                        key
                ):  # The function that's called when a key is pressed
                    nonlocal current_user_zone_start
                    nonlocal current_user_zone_end
                    nonlocal current_color
                    nonlocal background_color

                    # Get new colour
                    new_color = random.choice(colour_options)
                    while new_color == current_color:
                        new_color = random.choice(colour_options)

                    # If space key is pressed change the snake colour
                    if key == Key.space:
                        print(
                            "Space pressed, new color: {0}".format(new_color))
                        strip.set_zone_color(current_user_zone_start,
                                             current_user_zone_end, new_color,
                                             500)
                        current_color = new_color
                        # strip.set_color(new_color)

                    # If down right shift key is pressed change the background colour
                    if key == Key.shift_r:
                        strip.set_zone_color(0, current_user_zone_start,
                                             new_color, 1000)
                        strip.set_zone_color(current_user_zone_end, zone_count,
                                             new_color, 1000)
                        background_color = new_color

                with Listener(on_press=on_press, on_release=on_release
                              ) as listener:  # Create an instance of Listener
                    listener.join(
                    )  # Join the listener thread to the main thread to keep waiting for keys

                # 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)

                #         sleep(delay)

        except KeyboardInterrupt:
            # Reset colours to original when the script is stopped
            strip.set_zone_colors(original_zones, 500, True)
class LightsController:
    WARM_WHITE = [58275, 0, 65535, 3000]
    MAX_VALUE = 65535
    SCALE = [MAX_VALUE / 360, MAX_VALUE / 100, MAX_VALUE / 100, 1]

    ROTATE_CHANGE_COLOR_DELTA = 1 * config.ChangeColorSpeed['value']
    DIM_DELTA = 5.0

    def __init__(self, number_of_devices=1):
        self.device_controller = LifxLAN(number_of_devices)
        self.colour = None
        self.power = None
        self.reset_color()
        self.turn_on()
        if config.PrintLog:
            print "Light switched on with warm white"

    def reset_color(self):
        self.colour = [49, 0, 50.0, 3000]
        self.set_colour()

    def put_colour_in_loop(self):
        if self.colour[1] == 0:
            self.colour[1] = 80

    def take_colour_out_of_loop(self):
        self.colour[1] = 0

    def roll_forward(self):
        if not self.power:
            return
        self.put_colour_in_loop()
        self.colour[0] = (self.colour[0] + self.ROTATE_CHANGE_COLOR_DELTA) % 360
        self.set_colour()

    def roll_backward(self):
        if not self.power:
            return
        self.put_colour_in_loop()
        self.colour[0] = (self.colour[0] - self.ROTATE_CHANGE_COLOR_DELTA) % 360
        self.set_colour()

    def location_on_circle(self, x, y):
        degrees = math.degrees(math.atan(y/x))
        if x > 0 and y < 0:
            degrees += 180
        elif x > 0 and y > 0:
            degrees += 180
        elif x < 0 and y > 0:
            degrees += 360
        length = min(100, math.sqrt(x*x + y*y))
        self.colour[0] = degrees
        self.colour[1] = length
        self.set_colour()

    def increase_brightness(self):
        self.colour[2] = min(100.0, self.colour[2] + self.DIM_DELTA)
        self.set_colour()

    def decrease_brightness(self):
        self.colour[2] = max(0.2, self.colour[2] - self.DIM_DELTA)
        self.set_colour()

    def switch_power(self):
        self.power = not self.power
        if self.power:
            self.reset_color()
        self.set_power()

    def turn_off(self):
        if not self.power:
            return
        self.power = False
        self.set_power()

    def turn_on(self):
        if self.power:
            return
        self.power = True
        self.reset_color()
        self.set_power()

    def set_colour(self):
        if config.PrintLog:
            print "Setting colours: ", [self.SCALE[i] * self.colour[i] for i in range(4)]
        self.device_controller.set_color_all_lights([self.SCALE[i] * self.colour[i] for i in range(4)])

    def set_power(self):
        self.device_controller.set_power_all_lights(self.power)
示例#15
0
def main():

    MAIN_MENU_COMMANDS = ("Enter a light name to select it\n"
                          "\tOR\n"
                          "Enter one of the commands:\n"
                          "\tAll lights on: 'all on', 'on'\n"
                          "\tAll lights off: 'all off' 'off'\n"
                          "\tQuit program: 'q'")
    LIGHT_COMMANDS = ("Commands:\n"
                      "\tPower On: 'on', '1'\n"
                      "\tPower Off: 'off', '0'\n"
                      "\tToggle Power: 'toggle', 't'\n"
                      "\tBrightness Up: 'b+', '+'\n"
                      "\tBrightness Down: 'b-', '-'\n"
                      "\tBack to main menu: 'q'")

    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)

    # get devices
    devices = lifx.get_lights()
    print("\nFound {} light(s):\n".format(len(devices)))
    for d in devices:
        try:
            print(d)
        except:
            pass

    print(MAIN_MENU_COMMANDS)
    while True:
        user_input = input("Enter your command: ")

        if user_input.lower() == 'q':
            sys.exit()
        elif user_input == "":
            continue
        elif user_input.lower() == "all on" or user_input.lower() == "on":
            lifx.set_power_all_lights("on")
            continue
        elif user_input.lower() == "all off" or user_input.lower() == "off":
            lifx.set_power_all_lights("off")
            continue

        light = get_light(devices, user_input)

        if light is None:
            print("Light not found")
            continue

        # Device command Loop
        print(LIGHT_COMMANDS)
        while True:
            command = input("Enter a command for {}: ".format(user_input))

            if command == 'on' or command == '1':
                light.set_power("on")
            elif command == 'off' or command == '0':
                light.set_power("off")
            elif command == 'toggle' or command == 't':
                curr_power = light.get_power()
                if curr_power > 0:
                    light.set_power("off")
                else:
                    light.set_power("on")
            elif command.lower() == 'b+' or command == '+':
                color = light.get_color()
                light.set_color((color[0], color[1],
                                 cap_brightness(color[2] + 10000), color[3]))
            elif command.lower() == 'b-' or command == '-':
                color = light.get_color()
                light.set_color((color[0], color[1],
                                 cap_brightness(color[2] - 10000), color[3]))
            elif command.lower() == 'q':
                break
示例#16
0

if __name__ == "__main__":
    global lifxlan
    global high_traffic
    global medium_traffic
    global low_traffic
    global half_period_ms

    half_period_ms = 2500
    high_traffic = RED
    medium_traffic = ORANGE
    low_traffic = GREEN

    lifxlan = LifxLAN()
    lifxlan.set_power_all_lights("on", rapid=True)
    breathe(WHITE)

    # starts monitor mode on wlan0
    os.system('airmon-ng start wlan0') 
    os.system('clear')

    # prints available interfaces
    os.system('iwconfig') 

    signal.signal(signal.SIGTSTP, signal.SIG_IGN)

    # welcome message
    interface = raw_input("Welcome, please enter the interface you wish to scan on: ") 

    # starts thread to scan all 2.4ghz channels
示例#17
0
#!/usr/bin/python2

import RPi.GPIO as GPIO
from lifxlan import LifxLAN, BLUE, CYAN, GREEN, ORANGE, PINK, PURPLE, RED, YELLOW
import time

GPIO.setmode(GPIO.BCM)
GPIO.setup(7, GPIO.IN)

lifx = LifxLAN(2)
lights = lifx.get_lights()

original_color = lights[0].get_color()
lifx.set_power_all_lights("on")

rainbow(lights[0], 5.0)

empty = True
count = 0

sleep(1)

print "-----------------------------------------"
print "-------------- LIFX Motion --------------"
print "-----------------------------------------"

if GPIO.input(7):
    ## lights[0].set_power("on", 1000)
    ## lights[1].set_power("on", 1000)
    lifx.set_color_all_lights(original_color)
    lifx.set_power_all_lights("on", 1000)
示例#18
0
#!/usr/bin/env python
# coding=utf-8

from lifxlan import LifxLAN

lifxlan = LifxLAN()

lifxlan.set_power_all_lights("on", rapid=True)