-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRelayFRB.py
63 lines (42 loc) · 1.14 KB
/
RelayFRB.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import RPi.GPIO as GPIO
import time
import pyrebase
from time import sleep
GPIO.setmode(GPIO.BCM)
GPIO.setup(21, GPIO.OUT)
config = {
"apiKey": "AIzaSyAD_n2A5-R0yguKbVG87PvCmVvwGejg5m0",
"authDomain": "smart-door-3ab68",
"databaseURL": "https://smart-door-3ab68.firebaseio.com",
"storageBucket": "smart-door-3ab68.appspot.com"
}
firebase = pyrebase.initialize_app(config)
global count
global mininterval
global starttime
global flow
global runtime
global db
starttime = 0
SleepTimeL = 10
def stream_handler(post):
print(post["data"])
global db
global status
dat = db.child("Users").child("Door").child("fypjun2020").child("solenoid").get()
print (dat.val())
status = dat.val()
if(status == "LOCK"):
print ("Door Lock")
GPIO.output(21, GPIO.HIGH)
elif(status == "UNLOCK"):
print ("Door Un-Lock!!!")
GPIO.output(21, GPIO.LOW)
sleep(10)
else:
print ("Error")
def main():
global db
db = firebase.database()
test = db.child("Users").child("Door").child("fypjun2020").child("solenoid").stream(stream_handler)
main()