ZWave Route Mapping #7359
-
I was trying to get the route between the Controller and end devices by using the following FUNCTION function getZwaveRoutes() {
// Fetch all nodes from the Z-Wave network
const nodes = global.zw_socket.emit(inboundEvents.zwave, { "api": "getNodes" }, (response) => {
if (response.success) {
const nodeList = response.result;
let routes = {};
// Iterate over each node and fetch its neighbors
nodeList.forEach((node) => {
let nid = node.id; // Node ID
let apiData;
// // Checking the type or make of the device to create the appropriate API request
// if (global.zw_devStatus[nid].type == "implant" || global.zw_devStatus[nid].make == "switch") {
// apiData = {
// "api": "getNodeNeighbors",
// "args": [{ "nodeId": parseInt(nid), "commandClass": 37, "endpoint": 0 }]
// }
// } else {
apiData = {
"api": "discoverNodeNeighbors",
"args": [parseInt(nid)]
}
// }
// Emit request to fetch neighbors for the current node
global.zw_socket.emit(inboundEvents.zwave, apiData, (response) => {
if (response.success) {
console.log("Response", JSON.stringify(response));
routes[nid] = response.result; // Store the neighbors (routes)
console.log(`Node ${nid} neighbors: ` + JSON.stringify(routes[nid]));
} else {
console.error(`Failed to fetch neighbors for node ${nid}`);
}
});
});
// After processing all nodes, log the complete route structure
console.log("Z-Wave Network Routes: ", JSON.stringify(routes));
// You can then use the routes data for further processing or visualization
// For example, plot the routes in a tree structure
// plotRoutes(routes);
} else {
console.error("Failed to retrieve nodes from Z-Wave network");
}
});
} but due to this the device functionality is delayed can you suggest any other way to map the route between the end devices and the controller without affecting the device functionality? @robertsLando |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Using Z-Wave JS UI used to evaluate the Instead what we now do is listen to the |
Beta Was this translation helpful? Give feedback.
Using
discoverNodeNeighbors
isn't something you want to do frequently, as it instructs the node to ping all other nodes, waits for that to happen, and collects the results.Z-Wave JS UI used to evaluate the
neighbors
property of the nodes, which caches this information, but that isn't really reliable. Also it does not tell you which routes are used, just which nodes "see" which other nodes.Instead what we now do is listen to the
statistics updated
events, which contains information about the actual used routes and is updated every time a command was sent to a node. As a static fallback, you can usecontroller.getPriorityRoute(nodeId)
, which (as long as there is no priority route set) als…