Example #1
0
def send_light_commands(bulbs, rgb, dark_ratio, party=False):
    screen = get_screen_object()

    bulb_states = {}
    for bulb in bulbs:
        bulb_settings = screen.bulb_settings[unicode(bulb)]
        bulb_max_bri = bulb_settings['max_bri']
        bulb_min_bri = bulb_settings['min_bri']
        bri = utility.get_brightness(screen, bulb_max_bri, bulb_min_bri,
                                     dark_ratio)

        if party:
            rgb = utility.party_rgb()
            try:
                bri = random.randrange(int(screen.min_bri), int(bri) + 1)
            except ValueError:
                continue

        try:
            bulb_settings = screen.bulb_settings[str(bulb)]
            bulb_state = hue_interface.get_bulb_state(bulb_settings, rgb, bri,
                                                      screen.update)
            bulb_states[bulb] = bulb_state
        except Exception as e:
            print e.message
            continue

    for bulb in bulb_states:
        hue_interface.update_light(screen.ip, screen.devicename, bulb,
                                   bulb_states[bulb])
Example #2
0
def run():
    sleep(float(_screen.update_buffer))

    if _screen.party_mode:
        update_bulb_party()
        sleep(float(_screen.update))
    else:
        results = img_proc.screen_avg(_screen)

        try:
            print '\n'
            if 'zones' in results:
                print 'Parse Method: zones | Color Mode: %s' % _screen.color_mode
                for zone in results['zones']:

                    for bulb in zone['bulbs']:
                        bulb_settings = _screen.bulb_settings[unicode(bulb)]
                        bulb_max_bri = bulb_settings['max_bri']
                        bulb_min_bri = bulb_settings['min_bri']
                        bri = utility.get_brightness(_screen, bulb_max_bri,
                                                     bulb_min_bri,
                                                     zone['dark_ratio'])
                        hue_interface.send_rgb_to_bulb(bulb, zone['rgb'], bri)
            else:
                print 'Parse Method: standard | Color Mode: %s' % _screen.color_mode
                rgb = results['rgb']
                dark_ratio = results['dark_ratio']
                update_bulbs(rgb, dark_ratio)
        except urllib2.URLError:
            print 'Connection timed out, continuing...'
            pass
Example #3
0
def re_initialize():
    config = ConfigParser.RawConfigParser()
    config.read(utility.get_config_path())

    # Attributes
    at = initialize()

    global _screen
    _screen = Screen(*at)

    # Update bulbs with new settings
    results = img_proc.screen_avg(_screen)

    try:
        # Update Hue bulbs to avg color of screen
        if 'zones' in results:
            for zone in results['zones']:
                brightness = utility.get_brightness(_screen,
                                                    int(_screen.max_bri),
                                                    int(_screen.min_bri),
                                                    zone['dark_ratio'])

                for bulb in zone['bulbs']:
                    hue_interface.send_rgb_to_bulb(bulb, zone['rgb'],
                                                   brightness)
        else:
            update_bulbs(results['rgb'], results['dark_ratio'])
    except urllib2.URLError:
        print 'Connection timed out, continuing...'
        pass
Example #4
0
def send_light_commands(bulbs, rgb, dark_ratio, party=False):
    screen = get_screen_object()
    for bulb in bulbs:
        bulb_settings = screen.bulb_settings[unicode(bulb)]
        bulb_max_bri = bulb_settings['max_bri']
        bulb_min_bri = bulb_settings['min_bri']
        bri = utility.get_brightness(screen, bulb_max_bri, bulb_min_bri, dark_ratio)

        if party:
            rgb = utility.party_rgb()
            try:
                bri = random.randrange(int(screen.min_bri), int(bri) + 1)
            except ValueError:
                continue

        hue_interface.send_rgb_or_xy_to_bulb(bulb, rgb, bri)
Example #5
0
def send_light_commands(bulbs, rgb, dark_ratio, party=False):
    screen = get_screen_object()

    for bulb in bulbs:
        bulb_settings = screen.bulb_settings[unicode(bulb)]
        bulb_max_bri = bulb_settings['max_bri']
        bulb_min_bri = bulb_settings['min_bri']
        bri = utility.get_brightness(screen, bulb_max_bri, bulb_min_bri, dark_ratio)

        if party:
            rgb = utility.party_rgb()
            try:
                bri = random.randrange(int(screen.min_bri), int(bri) + 1)
            except ValueError:
                continue

        hue_interface.send_rgb_or_xy_to_bulb(bulb, rgb, bri)
Example #6
0
def send_light_commands(rgb, dark_ratio, party=False):
    global _screen

    active_bulbs = [bulb for bulb in _screen.bulbs if bulb]
    for bulb in active_bulbs:
        bulb_settings = _screen.bulb_settings[unicode(bulb)]
        bulb_max_bri = bulb_settings['max_bri']
        bulb_min_bri = bulb_settings['min_bri']
        bri = utility.get_brightness(_screen, bulb_max_bri, bulb_min_bri,
                                     dark_ratio)

        if party:
            rgb = utility.party_rgb()
            try:
                bri = random.randrange(int(_screen.min_bri), int(bri) + 1)
            except ValueError as e:
                print e
                continue
        hue_interface.send_rgb_to_bulb(bulb, rgb, bri)