From 3fcc8278d8ff8c2c7cb371f88e0b69803c7304cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joa=CC=83o=20Paulo=20Barraca?= Date: Wed, 27 Sep 2017 23:08:29 +0100 Subject: [PATCH] Fixed bug --- index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 2b9b501fc..35cb9977d 100644 --- a/index.js +++ b/index.js @@ -24,8 +24,11 @@ shepherd.on('permitJoining', function(joinTimeLeft) { }); shepherd.on('ind', function(msg) { var pl = null; - topic = 'xiaomiZb/' + msg.endpoints[0].device.ieeeAddr.substr(2); - + var topic = 'xiaomiZb/'; + + if(msg.endpoints.length > 0 && typeof msg.endpoints[0].device !== "undefined") + topic += msg.endpoints[0].device.ieeeAddr.substr(2); + switch (msg.type) { case 'devIncoming': console.log('Device: ' + msg.data + ' joining the network!');