I still suffer sometimes from failing zwave nodes, that I need to heal in the Developper Tools. The cause I think being interference on the Zwave frequency of other devices, I have discovered that my Harman Kardonn wireless soundbar is interfering with Zwave. They were quite close togehther, after creating a few meters space, my issues are less. Also turning the soundbar off helps. I am nog sure it is electronic interference, or just the big magnet in the subwoover.
Anyway, regurarly healing the network is something I would like te automate via a script/flow.
To get started, I copied some code I found on this forum, as starting point, being a bit of a nitwit I always need examples.
I used the Homey.zwave.runCommand({ command: “getNetworkTopology”}). When testing the .js code in homeyscript it fires without errors, but it does nothing. I added a few debug console messages, but it does not even seem to get to the .then step: console.log (“nodes”) is not reached. But no output no error, I am lost what is going on in this code.
My thougt was, knowing the failed nodes would be a good starting point for healing.
Anyone would like to give me a push in the right direction ?
The code I copied and added some debug logs is below :
// try to get failed nodes
console.log (“start”)
Homey.zwave.runCommand({ command: “getNetworkTopology”})
.then(async function(nodes)
{
console.log (“nodes”)
var txt=‘aa’;
var stats;
await Homey.zwave.getState().then(function (s) { stats = s.zw_state.stats; });
.forEach(nodes, function (node, key) {
txt += ‘\n’ + key + ’ ’ + node.name;
if (node.props.route != undefined && node.base == undefined) {
txt += ‘\n\troute: ’ + key + ‘=>’;
for (var r = node.props.route.shift(); r != undefined; r = node.props.route.shift())
if (r != 0) txt += r + ‘=>’;
txt += ’ 1’;
}
var stat = stats['node’ + key + ‘_network’];
if (stat != undefined && stat.tx != 0) {
txt += ‘\n\ttx: ’ + stat.tx + ’ err: ’ + stat.tx_err + ’ (’ + Math.round(100*stat.tx_err/stat.tx) + '%) rx: ’ + stat.rx;
}
}
.catch(error=>{ console.log(`FinalError:`, error);
})
);
console.log(txt);
});