[Answer] ZWaveAPI authentication via python
Posted: 04 Feb 2016 16:31
Hey, I just wanted to share this, because it took my some time to figure it out:
If you want to access the ZWaveAPI via python, but need authentification, you can use something like this:
(I'm using the requests module)
The r.json() is very neat, but for performance purposes you should use something like ijson, which iteratively parses the json.
BTW: If the user/password is wrong, I don't get something like 'Failed to login' but:
If you want to access the ZWaveAPI via python, but need authentification, you can use something like this:
(I'm using the requests module)
Code: Select all
r = requests.get("http://192.168.178.123/ZWaveAPI/Data/", auth=("admin", "PASSWORD"))
status_code = r.status_code # should be 200
content = r.content
parsed = r.json()
BTW: If the user/password is wrong, I don't get something like 'Failed to login' but:
I hope I will save some time for someone401 - Not logged in
