Beispiel #1
0
    print 'Scanning...'
    found = False

    mac = network.check_macs()
    
    if mac and not startup:
        print 'MAC: %s' % mac
        found = True
        print "Found"
        not_home_counter = 0

        if home_counter < 0:
            home_counter = 0

        elif home_counter == 0:
            state = player.get_state()
            if state == 'paused' or state == 'stopped' and not startup:
                subprocess.check_output('wemo switch "light" on', shell=True)
                player.play_new_playlist()
                subprocess.check_output('wemo switch "main" on', shell=True)

        home_counter += 1

    if not found:
        print "NOT Found"

        if home_counter > 0 and not_home_counter == 0:
            home_counter = OFF_COUNTER
        elif home_counter > 0 and not_home_counter > 0:
            home_counter -= 1
Beispiel #2
0
    if play_input_prev != play_input and not play_input:
        print("Play Button Pressed")
        GPIO.output(LIGHT_PIN, GPIO.HIGH)

    elif not play_input:
        timer += 1
        if timer == 25:
            player.shuffle(shuffle)
            shuffle = not shuffle

    elif play_input_prev != play_input and play_input:
        print("Play Button Released")
        GPIO.output(LIGHT_PIN, GPIO.LOW)

        if timer < 25:
            state = player.get_state()
            if state == 'paused' or state == 'stopped':
                player.resume()
            else:
                player.pause()

        timer = 0

    play_input_prev = play_input

    #####################
    ## NEXT
    #####################
    next_input = GPIO.input(NEXT_PIN)

    if next_input_prev != next_input and not next_input: