Page 1 of 1

Help with Z-way API

Posted: 02 Jan 2018 22:34
by Matus
Hello, I have got a razberry 2 and raspberry pi 3 model B. I install everything by manual. If I write to my laptop browser RaspberryIP:8083 it will run zwave smarthome. I add my FIBARO sensor and set up configuration trought expert UI. And, If I am logged in smarthome and if I write to browser adress RaspberryIP:8083/ZAutomation/api/v1/devices, it will write me all data from sensor in JSON in firefox. But I want to send this data to my local server running on PC (XAMPP - apache, mySQL) or, if I want to GET this data with XMLHttpRequest(), with:

xhttp.open("GET", "http://192.168.1.19:8083/ZAutomation/api/v1/devices", true);
xhttp.send();

I cant, becouse it write only that I am not logged in, error 401:

{"data":null,"code":401,"message":"401 Unauthorized","error":"Not logged in"}

How I can log in from my local server and get this data to my server??? Thanks and sorry for my bad english.

Re: Help with Z-way API

Posted: 02 Jan 2018 23:07
by micky1500
xhttp.open("GET", "http://192.168.1.19:8083/ZAutomation/api/v1/devices", true);

Have you tried including your logon details:- http://username:password@yourip:8083/

Although I'm interested as I can't do this using Arduino. It will not accept the password.
I had to create an Anonymous user account in my raspberry/z-way and allow the Anonymous user access to the devices(rooms) I wanted to control.
Maybe a bit too un-secure though :(
but it does work.

Anyone else got a better solution ?

Re: Help with Z-way API

Posted: 02 Jan 2018 23:28
by Matus
Thanks for reply, I try it and it dont work, Is it possible to get data to my server from Z-wave server?

Re: Help with Z-way API

Posted: 02 Jan 2018 23:56
by micky1500
Yes it is possible.
For now. To make it easy. Create another user and make it Anonymous. click the box "Anonymous User"
Give the Anonymous user access to the room that has the device you are controlling.

Then your original request should work ... xhttp.open("GET", "http://192.168.1.19:8083/ZAutomation/api/v1/devices", true);

Re: Help with Z-way API

Posted: 03 Jan 2018 01:09
by Matus
Thanks, but if I create another user anonymous, will I have to authorisate to get data or I only GET data without login. Thanks

Re: Help with Z-way API

Posted: 03 Jan 2018 20:06
by micky1500
It will work without login.

An account setup with Role: Anonymous User
Allow access to all rooms, then your command will get the whole data
http://192.168.1.19:8083/ZAutomation/api/v1/devices
returns with the devices data, A password is not needed

But as you are running on a server you would be better off using the cookie option
Search this forum for "cookie"
viewtopic.php?f=3419&t=23944&p=64626&hi ... kie#p64626