Attempting to pull info for specific ID

Hello,

I’m working to develop Ezlo integration on the Savant platform and I ran into an issue that I can’t seem to figure out. I am attempting to use https://192.168.xxx.xxx:17000/v1/method/hub/items/list?_id=FULL_ID_HERE but it returns the items for ALL devices, even if I use curl in terminal rather than the Ruby script I’m working on. If I just want to poll a specific lock I’d like to be able to do that instead of pulling everything. I could also cache deviceIds for more targeted requests for updates. Can anyone offer any guidance? If I can get it to work in curl then I can get it to work in my script. Thanks so much.

A related thread may have some info

If you need to specifically poll a device, you can use this replacing the ID for that of the device you wish to poll:

{
“id”: “ID”,
“method”: “hub.device.check”,
“params”: {
“_id”:“XXXYYYZZZXXXYYYZZZ”,
“check”: “value”
}
}

The expected responses will be when it starts and when it finishes. If it doesn’t finish successfully, the response will be akin to:

{
“id”: “ui_broadcast”,
“msg_id”: “60c3b27d20f3402f679b5967”,
“msg_subclass”: “hub.device.checked”,
“result”: {
“deviceId”: “XXXYYYZZZXXXYYYZZZ”,
“status”: “failed”
}
}

If it does finish successfully, it will state finished instead.

Hi Leandro,

I was hoping to be able to do this like many of the commands via port 17000 can be utilized in URL format. I can’t find a URL combo that will work.

This is one of the ways I tried to get the value. I just want to allow Savant to poll a single device (or last cached value anyway) and get a response.

curl -k -X GET “https://192.168.xxx.xxx:17000/v1/method/hub/device/check?_id=60bdaf8a0778621fb7854830&check=value” -H 'Authorization: Basic XXXXDDFFD

or

curl -k -X GET “https://192.168.xxx.xxx:17000/v1/method/hub/device/check?value&_id=60bdaf8a0778621fb7854830” -H 'Authorization: Basic XXXXDDFFD

There does not (yet) appear to be a way to do so via an HTTP call to port 17000 as you note, at least not that I have found after hours of testing, poking around, etc.

What I ended up doing was to write a script that calls /v1/method/hub.items.list and and then iterate over it to find my device. It’s still only one API call to get all the devices so the overheard is not much more.

Example: http://192.168.1.176:17000/v1/method/hub.items.list

IMHO I think this product was rushed a bit…

  • I could never get HTTP requests to work over wireless, only wired.
  • The API documentation is poor. It does not always match what you actually get back in the JSON responses.
  • There are multiple device IDs to deal with (ex. _id and deviceId for example).
  • The web-based management tool needs a lot of work.
    You can only add devices via the
  • The API tool needs work too (I often get a “Something went wrong”) and have to log out and back in again to find my controller. The command drop down menu should populate with all the commands… etc., etc.

All that being said, I really like where the product is heading, and the APIs currently developed have a much more logical structure than the previous Vera devices, and are much “cleaner”, but there’s work to be done.

1 Like

Hi @m2avc,

You have to use the /v1/request POST command for most requests. The v1/method just handles some basic commands. With the POST put the request details in the post data. it has the exact same format as in the websocket requests or what you see in the API tool. Look at HTTP-Server - Ezlo API Documentation

Cheers Rene

That’s right. So far, I have been able to use API calls for most things, but not yet any kind of HTTP requests. It is new for us as well, and hopefully, it will only get better with time.

I want to amend my response to this question. While there is no way to do this via a simple HTTP call, it can be done with an HTTP POST, with the correct JSON parameters. Here’s the complete code for how to check a device’s status (in Python).

import requests
import json

# Get a device status
myJSONAsString = """
{
  "method": "hub.items.list",
  "id": "_ID_",
  "params": {
    "deviceIds": [
      "60aaef71077e903f4a354447"
    ]
  }
}
"""

myJSON = json.loads (myJSONAsString)

r = requests.post('http://192.168.1.176:17000/v1/method/hub.items.list', json=myJSON)
r.status_code
print (r.text)

Sample result:

{“api”:“1.0”,“error”:null,“id”:“ID”,“result”:{“items”:[{“_id”:“60aaef71077e903f4a354448”,“deviceId”:“60aaef71077e903f4a354447”,“hasGetter”:true,“hasSetter”:true,“name”:“switch”,“show”:true,“value”:true,“valueFormatted”:“true”,“valueType”:“bool”}]}}

(Note: value: true in this example shows that the light is on).

Hope this helps.

2 Likes

Here is an example command in curl to get a temp sensor value:

curl --insecure --http1.1 https://192.168.0.11:17000/v1/request -d '{"method": "hub.data.list", "id": "608801a4120bab172e9c4f66", "params": {"items":{"ids":["608801a4120bab172e9c4f67"],"fields":{"include":["valueFormatted"]}}}}'

“608801a4120bab172e9c4f66” is the devices ID number

“608801a4120bab172e9c4f67” is the item ID number

18.6 degrees was the devices current value.

image

2 Likes