mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2026-07-11 14:18:50 +00:00
Added force remove
This commit is contained in:
+1
-1
@@ -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
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user