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:
parent
4ed0cb84d9
commit
34262e2fb0
@ -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')) {
|
||||
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user