-
Notifications
You must be signed in to change notification settings - Fork 1
/
boostduration.py
46 lines (33 loc) · 1.39 KB
/
boostduration.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
boostdur_url = login.api+"hillview/boostduration/"
boostrem_url = login.api+"hillview/boosttime/"
def get_boostTime (cookie,id):
# request the boost time remaining
headers={'accept':'application/json','Content-Type':'application/json','Cookie':'ZWAYSession='+cookie}
r = requests.get(boostrem_url+str(id),headers=headers)
return r
def get_boostDuration (cookie,id):
# request the boost duration
headers={'accept':'application/json','Content-Type':'application/json','Cookie':'ZWAYSession='+cookie}
r = requests.get(boostdur_url+str(id),headers=headers)
return r
def set_boostDuration (cookie,id,payload):
headers={'accept':'application/json','Content-Type':'application/json','Cookie':'ZWAYSession='+cookie}
# now set the boost duration
r = requests.post(boostdur_url+str(id),data=json.dumps(payload),headers=headers)
return r
if __name__ == "__main__":
print ("BoostDuration get/set test")
roomid = int(input ("Enter id of room: "))
cookie = login.send()
s = get_boostDuration(cookie,roomid)
print (s)
boostDuration = s.json()['data']
print (boostDuration)
boostDuration = int(input("Enter new boost duration: "))
payload = {'data':boostDuration}
s = set_boostDuration(cookie,roomid,payload)
print (s)