-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreadapi.py
52 lines (43 loc) · 1.76 KB
/
readapi.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
#!/usr/bin/python3
# python3 program getting information from honeywell wifi thermostat
# thru honeywell api
# not for Lyric or round types -> developer.honeywell.com
# (c) 2017 by martin schlatter, schwetzingen, germany
####################### Fill in settings below #######################
USERNAME="[email protected]"
PASSWORD="V123"
DOMAIN="mytotalconnectcomfort.com"
APPLID="91db1612-73fd-4500-91b2-e63b069b185c"
############################ End settings ############################
import urllib
import json
import datetime
import http.client
import pprint
headers={"Content-Type":"application/json",
"Accept":"application/json",
"User-Agent":"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.36"
}
body='{"username": "'+USERNAME+'", "password": "'+PASSWORD+'", "applicationId":"'+APPLID+'"}'
conn = http.client.HTTPSConnection(DOMAIN)
conn.request("POST", "/WebApi/api/session",body=body,headers=headers)
r = conn.getresponse()
if r.status==200:
dict=json.loads(r.read().decode("utf-8"))
sessionId=dict["sessionId"]
userID=dict["userInfo"]["userID"]
headers={"Content-Type":"application/json",
"Accept":"application/json",
"sessionId":sessionId,
"User-Agent":"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.36"
}
conn.request("GET", "/WebApi/api/locations?userId="+str(userID)+"&allData=True",headers=headers)
r = conn.getresponse()
if r.status==200:
dict=json.loads(r.read().decode("utf-8"))
pprint.pprint(dict)
else:
print("could not get locations: ",r.status,r.reason)
else:
print("could not acquire session id: ",r.status,r.reason)
conn.close()