diff --git a/lib/controller.js b/lib/controller.js index eefa97428..f60aedf7c 100644 --- a/lib/controller.js +++ b/lib/controller.js @@ -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}'`); }