mirror of
https://github.com/node-red/node-red-nodes.git
synced 2025-03-01 10:37:43 +00:00
Adding extra error checking for response from devices (#672)
This commit is contained in:
@@ -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')) {
|
||||
|
Reference in New Issue
Block a user