From d160efbde6f68320c0d3e82efdd99fd9a86d40b3 Mon Sep 17 00:00:00 2001 From: Andrew Linden Date: Sun, 24 Dec 2017 22:41:01 +0200 Subject: [PATCH] At startup list all currently joined deviced and set them to be "online" so shepherd wont try to query them for info (that would fail, because the devices go to sleep) --- index.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 07ac3381..d1a86c26 100644 --- a/index.js +++ b/index.js @@ -13,7 +13,13 @@ var shepherd = new ZShepherd('/dev/ttyACM0', { }); shepherd.on('ready', function() { - console.log('Server is ready.'); + console.log('Server is ready. Current devices:'); + shepherd.list().forEach(function(dev){ + if (dev.type === 'EndDevice') + console.log(dev.ieeeAddr + ' ' + dev.nwkAddr + ' ' + dev.modelId); + if (dev.manufId === 4151) // set all xiaomi devices to be online, so shepherd won't try to query info from devices (which would fail because they go tosleep) + shepherd.find(dev.ieeeAddr,1).getDevice().update({ status: 'online', joinTime: Math.floor(Date.now()/1000) }); + }); // allow devices to join the network within 60 secs shepherd.permitJoin(60, function(err) { if (err)