-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelay_control.py
68 lines (66 loc) · 2.55 KB
/
relay_control.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
63
64
65
66
67
68
import httplib2
import re
from setuptools.package_index import ContentChecker
from __builtin__ import int, str
def Get(b):
if b == ('turn on relay 1'):
h = httplib2.Http('.cache')
content = h.request('http://relay01/Relay1_H')
elif b == ('turn off relay 1'):
h = httplib2.Http('.cache')
content = h.request('http://relay01/Relay1_L')
elif b == ('turn on relay 2'):
h = httplib2.Http('.cache')
content = h.request('http://relay01/Relay2_H')
elif b == ('turn off relay 2'):
h = httplib2.Http('.cache')
content = h.request('http://relay01/Relay2_L')
elif b == ('turn on relay 3'):
h = httplib2.Http('.cache')
content = h.request('http://relay01/Relay3_H')
elif b == ('turn off relay 3'):
h = httplib2.Http('.cache')
content = h.request('http://relay01/Relay3_L')
elif b == ('turn on relay 4'):
h = httplib2.Http('.cache')
content = h.request('http://relay01/Relay4_H')
elif b == ('turn off relay 4'):
h = httplib2.Http('.cache')
content = h.request('http://relay01/Relay4_L')
elif b == ('turn on relay 5'):
h = httplib2.Http('.cache')
content = h.request('http://relay01/Relay5_H')
elif b == ('turn off relay 5'):
h = httplib2.Http('.cache')
content = h.request('http://relay01/Relay5_L')
elif b == ('turn on relay 6'):
h = httplib2.Http('.cache')
content = h.request('http://relay01/Relay6_H')
elif b == ('turn off relay 6'):
h = httplib2.Http('.cache')
content = h.request('http://relay01/Relay6_L')
elif b == ('turn on relay 7'):
h = httplib2.Http('.cache')
content = h.request('http://relay01/Relay7_H')
elif b == ('turn off relay 7'):
h = httplib2.Http('.cache')
content = h.request('http://relay01/Relay7_L')
elif b == ('turn on relay 8'):
h = httplib2.Http('.cache')
content = h.request('http://relay01/Relay8_H')
elif b == ('turn off relay 8'):
h = httplib2.Http('.cache')
content = h.request('http://relay01/Relay8_L')
elif b == ('check status'):
h = httplib2.Http('.cache')
content = h.request('http://relay01/status.html')
a = content[1].split(' ')
for str in a:
print 'relay '+str+' is on'
else:
print('please enter turn on/off relay (number between 1-8) or check status')
while True:
b = raw_input('Do you want to check status or turn on or off relays?: ')
Get(b)
if b == ('quit'):
break