-
Notifications
You must be signed in to change notification settings - Fork 0
/
pump.py
executable file
·39 lines (34 loc) · 1.24 KB
/
pump.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
#!/usr/bin/env python
# sudo gpiod
import os
import time
import pigpio
from web import *
pump_log = 'Started.<br>'
UpdateWeb(pump_log)
StartWebServer()
pi = pigpio.pi()
while True:
localtime = time.localtime(time.time())
if localtime.tm_hour >= 8 and localtime.tm_hour < 21:
pi.write(2, 0) # lamps
else:
pi.write(2, 1) # lamps
if localtime.tm_sec < 60 and localtime.tm_min % 5 == 0 and (localtime.tm_hour >= 0 or localtime.tm_hour == 0): # day and night
message = str(localtime.tm_hour) + ':' + str(localtime.tm_min) + ':' + str(localtime.tm_sec) + ' pump on'
print(message)
pump_log = pump_log + message + '<br>'
UpdateWeb(pump_log)
pi.write(3, 0)
time.sleep(40)
print(str(localtime.tm_hour) + ':' + str(localtime.tm_min) + ':' + str(localtime.tm_sec) + ' pump off')
pi.write(3, 1)
else:
print(str(localtime.tm_hour) + ':' + str(localtime.tm_min) + ':' + str(localtime.tm_sec) + ' nop')
if localtime.tm_min == 0 and localtime.tm_sec < 30:
message = '' # os.popen("./mif.sh").read().strip()
print(message)
pump_log = pump_log + message + '<br>'
for i in range(30):
WebServerIterate()
time.sleep(1) # seconds