Added force remove

This commit is contained in:
Marius Ciotlos
2018-06-06 22:13:32 +03:00
parent 34feef6cf4
commit 0f2f7462a5
2 changed files with 19 additions and 12 deletions
+1 -1
View File
@@ -318,7 +318,7 @@ class Controller {
logger.error(`Cannot handle '${topic}' because deviceID of '${message.toString()}' cannot be found`);
return;
}
this.zigbee.removedevice(deviceID)
this.zigbee.removedevice(deviceID);
} else {
logger.error(`Cannot handle MQTT config option '${option}' with Payload is null - we need the friendly_name to proceed`);
return;
+18 -11
View File
@@ -109,19 +109,26 @@ class Zigbee {
}
removedevice(deviceID) {
if (deviceID) {
logger.info(`Found Device with ID ${deviceID}`);
this.shepherd.remove('deviceID', function (err) {
if (err) {
console.log(`Failed to removed ${deviceID}`);
} else {
console.log(`Successfully removed ${deviceID}`);
}
});
this.shepherd.remove('deviceID', (err) => {
if (err) {
logger.warn(`Failed to remove ${deviceID}`);
this.forceRemove(deviceID);
} else {
logger.error('removedevice function need deviceID to proceed');
return;
logger.info(`Successfully removed ${deviceID}`);
}
});
}
forceRemove(deviceID) {
const device = this.shepherd._findDevByAddr(deviceID);
// force
return this.shepherd._unregisterDev(device, (err) => {
if (err) {
logger.warn(`Failed to force remove ${deviceID}`);
} else {
logger.info(`Successfully removed by force ${deviceID}`);
}
});
}
ping(deviceID) {