I was trying to figure out the method to log into the smart home portal but didn't find anyway using scripting.
If someone knows the method to log into the portal by using any language preferably python, please tell me with a small example.
Thanks
JSON login
Re: JSON login
Not sure this is what you are after, but here is a simple python script (python 3.5.1) that logs into my razberry pi (locally) running zway 2.1.1 and requests a list of locations and prints them out. Hope it helps.
Code: Select all
import requests
import json
# ip address of my raspberry pi
myip="192.168.1.154"
api = "http://"+myip+":8083/ZAutomation/api/v1/"
login_url = api+"login"
locations_url = api+"locations"
# post a login request
headers={'accept':'application/json','Content-Type':'application/json'}
payload = {'form': 'True','login':'admin','password':'admin','keepme':'false','default_ui':'1'}
r = requests.post(login_url,data=json.dumps(payload),headers=headers)
# extract the cookie from the response
cookie = r.json()['data']['sid']
print (cookie)
# request a list of locations - using the cookie supplied
headers={'Cookie':'ZWAYSession='+cookie}
r = requests.get(locations_url,headers=headers)
# display the locations
numLocations = len(r.json()['data'])
for i in range (0, numLocations):
print (r.json()['data'][i]['title'])