diff --git a/hardware/wemo/WeMoNG.js b/hardware/wemo/WeMoNG.js index 9d808022..a2d41e25 100644 --- a/hardware/wemo/WeMoNG.js +++ b/hardware/wemo/WeMoNG.js @@ -229,12 +229,21 @@ module.exports = function(RED) { node.status({fill: 'green',shape: 'dot',text: 'found'}); } - node.on('input', function(msg) { + node.on('input', function(msg, send, done){ var dev = wemo.get(node.dev); + send = send || function() { node.send.apply(node,arguments) } + if (!dev) { //need to show that dev not currently found - console.log('no device found'); + // console.log('no device found'); + + if (done) { + done("Device not discovered yet") + } else { + node.error("Device not discovered yet", msg) + } + return; } diff --git a/hardware/wemo/lib/wemo.js b/hardware/wemo/lib/wemo.js index 523c4c18..05d9ba68 100644 --- a/hardware/wemo/lib/wemo.js +++ b/hardware/wemo/lib/wemo.js @@ -273,7 +273,7 @@ WeMoNG.prototype.start = function start() { post_request.on('error', function(err){ // should log err - console.log(err); + //console.log(err); }) post_request.write(util.format(getenddevs.body, udn)); @@ -363,12 +363,12 @@ WeMoNG.prototype.toggleSocket = function toggleSocket(socket, on) { }); post_request.on('error', function (e) { - console.log(e); - console.log("%j", postoptions); + // console.log(e); + // console.log("%j", postoptions); }); post_request.on('timeout', function () { - console.log("Timeout"); + // console.log("Timeout"); post_request.abort(); }); @@ -420,8 +420,8 @@ WeMoNG.prototype.getSocketStatus = function getSocketStatus(socket) { }); post_request.on('error', function (e) { - console.log(e); - console.log("%j", postoptions); + // console.log(e); + // console.log("%j", postoptions); def.reject(e); }); @@ -471,8 +471,8 @@ WeMoNG.prototype.getInsightParams = function getInsightParams(socket) { }); post_request.on('error', function (e) { - console.log(e); - console.log("%j", postoptions); + // console.log(e); + // console.log("%j", postoptions); def.reject(e); }); @@ -527,12 +527,12 @@ WeMoNG.prototype.getLightStatus = function getLightStatus(light) { def.resolve(obj); } else { def.reject(err); - console.log("err"); + // console.log("err"); } }); } } else { - console.log("err"); + // console.log("err"); def.reject(err); } }); @@ -540,13 +540,13 @@ WeMoNG.prototype.getLightStatus = function getLightStatus(light) { }); post_request.on('error', function (e) { - console.log(e); - console.log("%j", postoptions); + // console.log(e); + // console.log("%j", postoptions); def.reject(e); }); post_request.on('timeout', function () { - console.log("Timeout"); + // console.log("Timeout"); post_request.abort("timeout"); def.reject(); }); @@ -583,12 +583,12 @@ WeMoNG.prototype.setStatus = function setStatus(light, capability, value) { }); post_request.on('error', function (e) { - console.log(e); - console.log("%j", postoptions); + // console.log(e); + // console.log("%j", postoptions); }); post_request.on('timeout', function () { - console.log("Timeout"); + // console.log("Timeout"); post_request.abort(); });