Hi all,
Simple question: Is there a way to query the zwave neighbor list for a node and display in basic UI?
Thanks,
Ramon
Hi all,
Simple question: Is there a way to query the zwave neighbor list for a node and display in basic UI?
Thanks,
Ramon
In a rule, you could use the REST API to query the things, then extract the neighbor property from the JSON response. Then postUpdate the neighbor list to an item for display in your sitemap.
Edit: I should add that the neighbor information is only as current as the last heal.
Hi Mark,
Thank you for the answer. I had a quick look into this and I guess I have to execute this in the rule:
curl -X GET --header "Accept: application/json" "http://192.168.15.100:8080/rest/things"
In the results I do get the neighbours. Can anybody give a simple example how to extract the zwave_neighbours and “UID” items for the entire list?
Thanks,
Ramon
[
{
"properties": {
"zwave_class_basic": "BASIC_TYPE_ROUTING_SLAVE",
"zwave_class_generic": "GENERIC_TYPE_SWITCH_BINARY",
"zwave_neighbours": "1,4,6,7,8,10,14,15,16,18,19",
…
}
"UID": "zwave:device:7358337f:node2",
…
},
{
next thing
You likely want the JSONPATH transform. There are some examples in the doc that should get you started with the syntax. Unfortunately, I can’t remember how to iterate through an array of JSON objects, which is what you get in the response to the things query.
Hi all,
I never got round to posting my solution, so here is it (see below). In this example I just log it in the logfile. Hope it helps somebody.
Ramon
rule "update at 03:00" when
Time cron "0 0 3 ? * *"
then
// rest api: https://www.openhab.org/docs/configuration/restdocs.html#rest-api-documentation
var curlout= sendHttpGetRequest("http://127.0.0.1:8080/rest/things",5000)
var numThings = transform("JSONPATH", "$.length()", curlout)
var String totallist=""
var i = 0
while(i < Integer.parseInt(numThings)) {
var String bridgeUID = transform("JSONPATH", "$.["+i+"].bridgeUID", curlout)
var String UID = transform("JSONPATH", "$.["+i+"].UID", curlout)
if (( bridgeUID=="zwave:serial_zstick:7843337f") || (UID=="zwave:serial_zstick:7843337f")) {
var String newValue = transform("JSONPATH", "$.["+i+"].properties.zwave_neighbours", curlout)
var String nodeid = transform("JSONPATH", "$.["+i+"].properties.zwave_nodeid", curlout)
var String nodelabel = transform("JSONPATH", "$.["+i+"].label", curlout)
totallist=totallist+ "Thing: " + i +" id "+ nodeid+ " List: "+ newValue+" "+nodelabel+"\n"
}
i=i+1
}
logInfo("rule", "neighborlist : \n"+totallist)
end