-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
door_proto.py
47 lines (39 loc) · 1.59 KB
/
door_proto.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
#!/usr/bin/env python3
# *****************************************
# Garage Zero Interface Library
# *****************************************
#
# Description: This library supports
# controlling the outputs and observing inputs.
#
# *****************************************
# *****************************************
# Imported Libraries
# *****************************************
import time
from door_base import DoorObj
# *****************************************
# Child Class for Prototyping (test)
# *****************************************
class ProtoDoorObj(DoorObj):
def __init__(self, name, id, outpins, inpins, triggerlevel, sensorlevel, notifyevents, notify_objects_list):
super().__init__(name, id, outpins, inpins, triggerlevel, sensorlevel, notifyevents, notify_objects_list)
for item in self.inpins:
self.currentinputs[item] = self.SENSOR_OFF
self.lastinputs[item] = self.SENSOR_OFF
for item in self.outpins:
self.currentoutputs[item] = self.RELAY_OFF
for item, value in self.currentinputs.items():
print({f'Door {self.name} Input Item: {item} Value: {value}'})
self.cmdsts.hset('doorobj:' + self.id, item, value)
def toggle_output(self, outputname):
self.currentoutputs[outputname] = self.RELAY_ON
time.sleep(0.5)
self.currentoutputs[outputname] = self.RELAY_OFF
def get_input_status(self):
# For each of the relays, check key / value pair
for item, value in self.inpins.items():
self.currentinputs[item] = int(self.cmdsts.hget('doorobj:' + self.id, item))
return self.currentinputs
def set_input(self, input, value):
self.currentinputs[input] = value