-
Notifications
You must be signed in to change notification settings - Fork 1
/
mode.py
46 lines (34 loc) · 1.24 KB
/
mode.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
import requests
import json
import login
import zwaveapi
mode_url = login.api+"hillview/mode/"
def get_mode (cookie,id):
# request the mode
headers={'accept':'application/json','Content-Type':'application/json','Cookie':'ZWAYSession='+cookie}
r = requests.get(mode_url+str(id),headers=headers)
return r
def set_mode (cookie,id,payload):
headers={'accept':'application/json','Content-Type':'application/json','Cookie':'ZWAYSession='+cookie}
# now set the mode
r = requests.post(mode_url+str(id),data=json.dumps(payload),headers=headers)
if __name__ == "__main__":
print ("Mode get/set test")
roomid = int(input ("Enter id of room: "))
cookie = login.send()
s = get_mode(cookie,roomid)
print (s)
mode = s.json()['data']
print (mode)
mode = int(input("Enter new mode: "))
payload = {'data':mode}
s = set_mode(cookie,roomid,payload)
print (s)
#print ("device id name owner")
#for i in devices.keys():
# msg = "" + str(i) + " "+str(devices[i]['data']['givenName']['value'])+" "
# for j in range(len(roomData)):
# if int(i) in roomData[j]['nodes']:
# msg += str(j)
# print (msg)
#