-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimer.py
More file actions
32 lines (22 loc) · 815 Bytes
/
timer.py
File metadata and controls
32 lines (22 loc) · 815 Bytes
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
#! /usr/bin/python
import datetime
import time
"""This is a test module for the heater control. The function timerCheck returns the programmed temperature
based on the settings in onTime, offTime, tempOn and tempOff this return value can then be used with temp.py
module to determine whether the heater should be turned on."""
onTime = 8
offTime = 21
tempOn = 18.5 # sets the on temperature
tempOff = 5 # sets the off temperature
def timerCheck(onTime, offTime):
"Gets the time and sets temperature according to schedule"
now = datetime.datetime.now() # get the current time
hour = now.hour # extract the hour
if onTime <= hour<= offTime: # decide temperature to use
tempRqd = tempOn
else:
tempRqd = tempOff
return (tempRqd)
while(1):
tempRqd = timerCheck(onTime, offTime)
print tempRqd