Refactored handling retry timer

This commit is contained in:
Harald Rietman
2017-07-15 10:15:07 +02:00
parent 735b48d4df
commit 77b765e8f0

View File

@@ -164,8 +164,15 @@ module.exports = function(RED) {
}
RED.nodes.registerType("xiaomi-plug-wifi", XiaomiPlugWifiNode);
process.on('unhandledRejection', function(reason, p){
console.log("Possibly Unhandled Rejection at: Promise ", p, " reason: ", reason);
// application specific logging here
process.on('unhandledRejection', function(reason, p) {
// console.log("Possibly Unhandled Rejection at: Promise ", p, " reason: ", reason);
var message = reason + "";
if (message.indexOf("Call to device timed out") >= 0) {
if (this.plug) {
console.log("Issue with miio package; discard plug and reconnect.");
this.plug.destroy();
this.plug = null;
}
}
});
}