forked from watchforstock/evohome-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
chris_logger_v1.py
49 lines (38 loc) · 1.3 KB
/
chris_logger_v1.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
#!/usr/bin/python
# Log the 8 Horn Lane Evohome temperatures regularly
from evohomeclient2 import EvohomeClient
import time
import sys
import datetime
# Connect to Honeywell servers
client = EvohomeClient('[email protected]', 'toasty2015Y')
# Open log file
f = open("evohome_log.csv","a+",buffering=1)
f.write("\n\nNew logging session at " + datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") + ".\nDevice_list,")
first = True
for device in client.temperatures():
if first:
first = False
else:
f.write(",")
f.write(device["name"] + "_setpoint," + device["name"] + "_temp")
f.write("\n")
while True:
time.sleep(30)
f.write(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")+",")
sys.stdout.write(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")+",")
try:
first = True
for device in client.temperatures():
if first:
first = False
else:
f.write(",")
sys.stdout.write(",")
f.write(str(device["setpoint"]) + "," + str(device["temp"]))
sys.stdout.write(str(device["setpoint"]) + "," + str(device["temp"]))
except Exception as err:
print(err)
finally:
f.write( "\n" )
sys.stdout.write( "\n" )