-
Notifications
You must be signed in to change notification settings - Fork 0
/
server_v1.4.py
207 lines (194 loc) · 5.94 KB
/
server_v1.4.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
import RPi.GPIO as GPIO
import os
import time
import sys
from flask import Flask, render_template
app = Flask(__name__, static_url_path='/static')
#app.run(host='0.0.0.0')
sys.stdout = open('poolboy_web.log', 'w')
print ('Poolboy webapp started')
GPIO.setmode(GPIO.BOARD)
@app.route('/')
def index():
GPIO.setmode(GPIO.BOARD)
filterstat = 31
heaterstat = 29
buttonSts = GPIO.LOW
heaterSts = GPIO.LOW
# Read Sensors Status
GPIO.setup(filterstat, GPIO.IN)
GPIO.setup(heaterstat, GPIO.IN)
buttonSts = GPIO.input(filterstat)
filterSts = GPIO.input(heaterstat)
templateData = {
'filterbutton' : buttonSts, 'heaterbutton' : filterSts,
}
with open('temp_water.txt', 'r') as f:
with open('temp_air.txt', 'r') as g:
with open('temp_wish.txt', 'r') as w:
return render_template('index.html', wishtemp=w.read(), roomtemp=g.read(), temp=f.read(), **templateData)
GPIO.cleanup()
@app.route('/my-link1/')
def my_link1():
print ('Main Power got clicked!')
GPIO.setmode(GPIO.BOARD)
GPIO.setup(38,GPIO.OUT)
GPIO.output(38,GPIO.LOW)
print("Relais 1 ON !")
time.sleep(0.5)
GPIO.output(38,GPIO.HIGH)
print("Relais 1 OFF !")
filterstat = 31
heaterstat = 29
buttonSts = GPIO.LOW
heaterSts = GPIO.LOW
# Read Sensors Status
GPIO.setup(filterstat, GPIO.IN)
GPIO.setup(heaterstat, GPIO.IN)
buttonSts = GPIO.input(filterstat)
filterSts = GPIO.input(heaterstat)
templateData = {
'filterbutton' : buttonSts, 'heaterbutton' : filterSts,
}
with open('temp_water.txt', 'r') as f:
with open('temp_air.txt', 'r') as g:
with open('temp_wish.txt', 'r') as w:
return render_template('index.html', wishtemp=w.read(), roomtemp=g.read(), temp=f.read(), **templateData)
GPIO.cleanup()
@app.route('/my-link2/')
def my_link2():
print ('Filtern got clicked!')
GPIO.setmode(GPIO.BOARD)
GPIO.setup(36,GPIO.OUT)
GPIO.output(36,GPIO.LOW)
print("Relais 2 ON !")
time.sleep(0.5)
GPIO.output(36,GPIO.HIGH)
print("Relais 2 OFF !")
filterstat = 31
heaterstat = 29
buttonSts = GPIO.LOW
heaterSts = GPIO.LOW
# Read Sensors Status
GPIO.setup(filterstat, GPIO.IN)
GPIO.setup(heaterstat, GPIO.IN)
buttonSts = GPIO.input(filterstat)
filterSts = GPIO.input(heaterstat)
templateData = {
'filterbutton' : buttonSts, 'heaterbutton' : filterSts,
}
with open('temp_water.txt', 'r') as f:
with open('temp_air.txt', 'r') as g:
with open('temp_wish.txt', 'r') as w:
return render_template('index.html', wishtemp=w.read(), roomtemp=g.read(), temp=f.read(), **templateData)
GPIO.cleanup()
@app.route('/my-link3/')
def my_link3():
print ('Heizen got clicked!')
GPIO.setmode(GPIO.BOARD)
GPIO.setup(32,GPIO.OUT)
GPIO.output(32,GPIO.LOW)
print("Relais 3 ON !")
time.sleep(0.5)
GPIO.output(32,GPIO.HIGH)
print("Relais 3 OFF !")
filterstat = 31
heaterstat = 29
buttonSts = GPIO.LOW
heaterSts = GPIO.LOW
# Read Sensors Status
GPIO.setup(filterstat, GPIO.IN)
GPIO.setup(heaterstat, GPIO.IN)
buttonSts = GPIO.input(filterstat)
filterSts = GPIO.input(heaterstat)
templateData = {
'filterbutton' : buttonSts, 'heaterbutton' : filterSts,
}
with open('temp_water.txt', 'r') as f:
with open('temp_air.txt', 'r') as g:
with open('temp_wish.txt', 'r') as w:
return render_template('index.html', wishtemp=w.read(), roomtemp=g.read(), temp=f.read(), **templateData)
GPIO.cleanup()
@app.route('/my-link4/')
def my_link4():
print ('Bubbles got clicked!')
GPIO.setmode(GPIO.BOARD)
GPIO.setup(40,GPIO.OUT)
GPIO.output(40,GPIO.LOW)
print("Relais 4 ON !")
time.sleep(0.5)
GPIO.output(40,GPIO.HIGH)
print("Relais 4 OFF !")
filterstat = 31
heaterstat = 29
buttonSts = GPIO.LOW
heaterSts = GPIO.LOW
# Read Sensors Status
GPIO.setup(filterstat, GPIO.IN)
GPIO.setup(heaterstat, GPIO.IN)
buttonSts = GPIO.input(filterstat)
filterSts = GPIO.input(heaterstat)
templateData = {
'filterbutton' : buttonSts, 'heaterbutton' : filterSts,
}
with open('temp_water.txt', 'r') as f:
with open('temp_air.txt', 'r') as g:
with open('temp_wish.txt', 'r') as w:
return render_template('index.html', wishtemp=w.read(), roomtemp=g.read(), temp=f.read(), **templateData)
GPIO.cleanup()
@app.route('/my-link5/')
def my_link5():
print ('Temp high got clicked!')
GPIO.setmode(GPIO.BOARD)
GPIO.setup(35,GPIO.OUT)
GPIO.output(35,GPIO.LOW)
print("Relais 5 ON !")
time.sleep(0.5)
GPIO.output(35,GPIO.HIGH)
print("Relais 5 OFF !")
filterstat = 31
heaterstat = 29
buttonSts = GPIO.LOW
heaterSts = GPIO.LOW
# Read Sensors Status
GPIO.setup(filterstat, GPIO.IN)
GPIO.setup(heaterstat, GPIO.IN)
buttonSts = GPIO.input(filterstat)
filterSts = GPIO.input(heaterstat)
templateData = {
'filterbutton' : buttonSts, 'heaterbutton' : filterSts,
}
with open('temp_water.txt', 'r') as f:
with open('temp_air.txt', 'r') as g:
with open('temp_wish.txt', 'r') as w:
return render_template('index.html', wishtemp=w.read(), roomtemp=g.read(), temp=f.read(), **templateData)
GPIO.cleanup()
@app.route('/my-link6/')
def my_link6():
print ('Temp low got clicked!')
GPIO.setmode(GPIO.BOARD)
GPIO.setup(37,GPIO.OUT)
GPIO.output(37,GPIO.LOW)
print("Relais 6 ON !")
time.sleep(0.5)
GPIO.output(37,GPIO.HIGH)
print("Relais 6 OFF !")
filterstat = 31
heaterstat = 29
buttonSts = GPIO.LOW
heaterSts = GPIO.LOW
# Read Sensors Status
GPIO.setup(filterstat, GPIO.IN)
GPIO.setup(heaterstat, GPIO.IN)
buttonSts = GPIO.input(filterstat)
filterSts = GPIO.input(heaterstat)
templateData = {
'filterbutton' : buttonSts, 'heaterbutton' : filterSts,
}
with open('temp_water.txt', 'r') as f:
with open('temp_air.txt', 'r') as g:
with open('temp_wish.txt', 'r') as w:
return render_template('index.html', wishtemp=w.read(), roomtemp=g.read(), temp=f.read(), **templateData)
GPIO.cleanup()
if __name__ == '__main__':
app.run(host='0.0.0.0', port=80, debug=True)