-
Notifications
You must be signed in to change notification settings - Fork 1
/
setEcobeeTemp.py
executable file
·55 lines (45 loc) · 1.7 KB
/
setEcobeeTemp.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
#!/usr/bin/env python
import sys
import argparse
import datetime
import ecobeelib
def openEcobee():
myecobee = ecobeelib.MyEcobee()
myecobee.setLogger()
myecobee.readThermostatDefs()
myecobee.openConnection()
return myecobee
def setEcobee(args):
adjustTemp = round(args.temp, 0)
print("Final Adjusted Temp Setting: {0:.1f}F".format(adjustTemp))
endtime = datetime.datetime.now()
endtime = endtime.replace(hour=args.hour, second=30, microsecond=0)
if args.minute is not None:
endtime = endtime.replace(minute=args.minute)
print("Selected time is:")
print(endtime.strftime("%I:%M %p <=> %H:%M on %Y-%m-%d"))
myecobee = openEcobee()
if args.heat is True:
print("Request: Turn ON furnace")
print(("Set HEAT to {0:.1f} F".format(adjustTemp)))
myecobee.setHoldTemperature(heattemp=adjustTemp, endtime=endtime)
if args.cool is True:
print("Request: Turn ON air conditioner")
print(("Set A/C to {0:.1f} F".format(adjustTemp)))
myecobee.setHoldTemperature(cooltemp=adjustTemp, endtime=endtime)
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('-T', '--temp', type=float, required=True,
help="temperature in degrees Fahrenheit", dest="temp",)
parser.add_argument('-H', '--hour', type=int, required=True,
help="end hour in military time", dest="hour")
parser.add_argument('-M', '--minute', type=int, required=False,
help="end minutes at the hour", dest="minute", default=0)
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument('--heat', action='store_true')
group.add_argument('--cool', action='store_true')
args = parser.parse_args()
if args.hour < datetime.datetime.now().hour:
print("USE MILITARY TIME")
sys.exit(1)
setEcobee(args)