Curl - pycurl vs browser

Discussions about Z-Way software and Z-Wave technology in general
Post Reply
fip
Posts: 1
Joined: 03 Dec 2017 19:34

Curl - pycurl vs browser

Post by fip » 03 Dec 2017 19:47

Hi,
I'm currently collecting information about z-wave devices via python and bash using pycurl and curl. Everything works fine and I get the correct response - convert it to json and everything is fine.
Only when I try to get the battery status - they all have as the last number 128 , it doesn't work via python or curl, but works fine entering the URL into a browser.

e.g.:
Using any browser
http://111.1111.111.111:8083/ZAutomatio ... ay_4-0-128 entered into the browser brings:
{"data":{"creationTime":1508670254,"creatorId":1,"customIcons":{},"deviceType":"battery","h":847214338,"hasHistory":false,"id":"ZWayVDev_zway_4-0-128","location":0,"metrics":{"probeTitle":"Battery","scaleTitle":"%","level":100,"icon":"battery","title":"Duwi Battery (#4)","isFailed":true,"modificationTime":1508870985,"lastLevel":100},"order":{"rooms":0,"elements":0,"dashboard":0},"permanently_hidden":false,"probeType":"","tags":[],"visibility":true,"updateTime":1512064133},"code":200,"message":"200 OK","error":null}

where entering on linux:
root@xxx:/mnt/c/Users/yyy# curl --include -u user:password "http://111.111.111.111:8083/ZAutomation ... ay_4-0-128"
HTTP/1.1 404 Not Found
Server: Mongoose/6.4
Content-Type: application/json; charset=utf-8
X-API-VERSION: 2.0.1
Date: Sun, 03 Dec 2017 16:41:12 GMT
Access-Control-Expose-Headers: Accept-Ranges, Content-Encoding, Content-Length, Content-Range, Content-Type, ETag, X-API-VERSION, Date, Cache-Control, If-None-Match, Content-Language, Accept-Language, ZWAYSession
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
Access-Control-Allow-Headers: Authorization
Connection: close
Content-Length: 103

{"data":null,"code":404,"message":"404 Not Found","error":"Device ZWayVDev_zway_4-0-128 doesn't exist"}

And it's the same 404-error in Python.
A positive result is completly browser independent - works on Chrome, Edge and Firefox.
And it ONLY effects the batteries, all other devices have no problems.
It's so straneg, does anyone have an idea???
thx in advance
fip

the wife
Posts: 12
Joined: 27 Oct 2015 21:02

Re: Curl - pycurl vs browser

Post by the wife » 06 Dec 2017 18:35

Looking at the code in opt/z-way-server/automation/ZAutomationAPIProvider.js I would say it is related to the profile that you are using.

If the user/profile has admin rights, then all devices are accessible. But if the user does not have admin rights then only devices allocated to a room are accessible (and only if that user has been allowed to see the room).

Maybe from the browser you have logged in via the SmartHome UI with admin rights which will allow access to all devices. But, from python you are using a different user profile which only has access to certain rooms?

I see that when you do get data back about the battery its "location" is set to 0, meaning no room allocated.

I tried this from python. If I login with admin rights I can see the batteries, but if I login with a different user profile I get a "<device> doesn't exist" error for batteries, but not for devices allocated to rooms.

Hope this helps.

Post Reply