mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2026-08-28 13:34:24 +00:00
Update controller.js
ADD "remove" MQTT Topic with "message" - Check
This commit is contained in:
@@ -309,6 +309,20 @@ class Controller {
|
||||
});
|
||||
|
||||
this.mqtt.log('devices', devices);
|
||||
} else if (option === 'remove'){
|
||||
if(message.toString() !== null && message.toString() !== '' && message.toString().length > 0) {
|
||||
const deviceID = Object.keys(settings.get().devices).find((id) =>
|
||||
settings.getDevice(id).friendly_name === message.toString()
|
||||
);
|
||||
if (!deviceID) {
|
||||
logger.error(`Cannot handle '${topic}' because deviceID of '${message.toString()}' cannot be found`);
|
||||
return;
|
||||
}
|
||||
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;
|
||||
}
|
||||
} else {
|
||||
logger.warn(`Cannot handle MQTT config option '${option}' with message '${message}'`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user