Created
January 14, 2017 18:44
-
-
Save cruor99/1a0fea7d92dd2a9c76069e864f76af16 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import pusherclient | |
import sys | |
import json | |
import plyer | |
from httprequests import * | |
#import the GPIO and time package | |
import RPi.GPIO as GPIO | |
GPIO.setmode(GPIO.BOARD) | |
GPIO.setup(7, GPIO.OUT) | |
# start GPIO with False | |
GPIO.output(7, False) | |
TIMEOPEN = 10 # time in sec door is open | |
# Add a logging handler so we can see the raw communication data | |
import logging | |
root = logging.getLogger() | |
root.setLevel(logging.INFO) | |
ch = logging.StreamHandler(sys.stdout) | |
root.addHandler(ch) | |
global pusher | |
def connect_handler(data): | |
channel = pusher.subscribe('test_channel') ## change to deviceid? | |
channel.bind('my_event', doDoorUnlock) | |
pusher = pusherclient.Pusher('') | |
#pusher = pusherclient.Pusher('') | |
pusher.connection.bind('pusher:connection_established', connect_handler) | |
pusher.connect() | |
print pusher | |
def doDoorUnlock(*args): | |
GPIO.output(7, True) | |
time.sleep(TIMEOPEN) | |
GPIO.output(7, False) | |
while True: | |
time.sleep(1) | |
GPIO.cleanup() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment