diff --git a/hardware/wemo/WeMoNG.js b/hardware/wemo/WeMoNG.js index 211db2ce..e5627687 100644 --- a/hardware/wemo/WeMoNG.js +++ b/hardware/wemo/WeMoNG.js @@ -503,9 +503,13 @@ module.exports = function(RED) { 'sid': req.headers.sid }; //console.log("Incoming Event %s", req.body.toString()); - wemo.parseEvent(req.body.toString()).then(function(evt) { + wemo.parseEvent(req.body.toString()) + .then(function(evt) { evt.sid = notification.sid; wemo.emit('event',evt); + }) + .catch(err => { + console.log(err) }); res.send(''); }); diff --git a/hardware/wemo/lib/wemo.js b/hardware/wemo/lib/wemo.js index ba1f7fe5..523c4c18 100644 --- a/hardware/wemo/lib/wemo.js +++ b/hardware/wemo/lib/wemo.js @@ -413,7 +413,7 @@ WeMoNG.prototype.getSocketStatus = function getSocketStatus(socket) { status = parseInt(status); def.resolve(status); } else { - def.reject(); + def.reject(err); } }); }); @@ -422,12 +422,12 @@ WeMoNG.prototype.getSocketStatus = function getSocketStatus(socket) { post_request.on('error', function (e) { console.log(e); console.log("%j", postoptions); - def.reject(); + def.reject(e); }); post_request.on('timeout', function(){ post_request.abort(); - def.reject(); + def.reject("timeout"); }); post_request.write(getSocketState.body); @@ -473,12 +473,12 @@ WeMoNG.prototype.getInsightParams = function getInsightParams(socket) { post_request.on('error', function (e) { console.log(e); console.log("%j", postoptions); - def.reject(); + def.reject(e); }); post_request.on('timeout', function(){ post_request.abort(); - def.reject(); + def.reject("timeout"); }); post_request.write(getInsightParameters.body); @@ -526,14 +526,14 @@ WeMoNG.prototype.getLightStatus = function getLightStatus(light) { }; def.resolve(obj); } else { - def.reject(); + def.reject(err); console.log("err"); } }); } } else { console.log("err"); - def.reject(); + def.reject(err); } }); }); @@ -542,12 +542,12 @@ WeMoNG.prototype.getLightStatus = function getLightStatus(light) { post_request.on('error', function (e) { console.log(e); console.log("%j", postoptions); - def.reject(); + def.reject(e); }); post_request.on('timeout', function () { console.log("Timeout"); - post_request.abort(); + post_request.abort("timeout"); def.reject(); }); @@ -617,7 +617,7 @@ WeMoNG.prototype.parseEvent = function parseEvent(evt) { msg.value = res['StateEvent']['Value'][0]; def.resolve(msg); } else { - def.reject(); + def.reject(err); } }); } else if (prop.hasOwnProperty('BinaryState')) { @@ -634,7 +634,7 @@ WeMoNG.prototype.parseEvent = function parseEvent(evt) { } } else { //error - def.reject(); + def.reject(err); } });