Help with Z-way API

Discussions about RaZberry - Z-Wave board for Raspberry computer
Post Reply
Matus
Posts: 3
Joined: 01 Jan 2018 17:07

Help with Z-way API

Post by Matus » 02 Jan 2018 22:34

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.

micky1500
Posts: 50
Joined: 07 Feb 2016 16:29

Re: Help with Z-way API

Post by micky1500 » 02 Jan 2018 23:07

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 ?

Matus
Posts: 3
Joined: 01 Jan 2018 17:07

Re: Help with Z-way API

Post by Matus » 02 Jan 2018 23:28

Thanks for reply, I try it and it dont work, Is it possible to get data to my server from Z-wave server?

micky1500
Posts: 50
Joined: 07 Feb 2016 16:29

Re: Help with Z-way API

Post by micky1500 » 02 Jan 2018 23:56

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);

Matus
Posts: 3
Joined: 01 Jan 2018 17:07

Re: Help with Z-way API

Post by Matus » 03 Jan 2018 01:09

Thanks, but if I create another user anonymous, will I have to authorisate to get data or I only GET data without login. Thanks

micky1500
Posts: 50
Joined: 07 Feb 2016 16:29

Re: Help with Z-way API

Post by micky1500 » 03 Jan 2018 20:06

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

Post Reply