1
0
mirror of https://github.com/node-red/node-red-nodes.git synced 2023-10-10 13:36:58 +02:00

Adding extra error checking for response from devices (#672)

This commit is contained in:
Ben Hardill 2020-08-17 21:43:12 +01:00 committed by GitHub
parent 4ed0cb84d9
commit 34262e2fb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -336,10 +336,12 @@ WeMoNG.prototype.getSocketStatus = function getSocketStatus(socket) {
res.on('end', function(){
xml2js.parseString(data, function(err, result){
if (!err) {
if (!err && result["s:Envelope"]) {
var status = result["s:Envelope"]["s:Body"][0]["u:GetBinaryStateResponse"][0]["BinaryState"][0];
status = parseInt(status);
def.resolve(status);
} else {
def.reject();
}
});
});
@ -401,12 +403,14 @@ WeMoNG.prototype.getLightStatus = function getLightStatus(light) {
};
def.resolve(obj);
} else {
def.reject();
console.log("err");
}
});
}
} else {
console.log("err");
def.reject();
}
});
});
@ -489,6 +493,8 @@ WeMoNG.prototype.parseEvent = function parseEvent(evt) {
msg.capabilityName = capabilityMap[msg.capability];
msg.value = res['StateEvent']['Value'][0];
def.resolve(msg);
} else {
def.reject();
}
});
} else if (prop.hasOwnProperty('BinaryState')) {

View File

@ -1,6 +1,6 @@
{
"name": "node-red-node-wemo",
"version": "0.1.17",
"version": "0.1.18",
"description": "Input and Output nodes for Belkin WeMo devices",
"repository": "https://github.com/node-red/node-red-nodes/tree/master/hardware",
"main": "WeMoNG.js",