mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2026-10-22 05:52:20 +00:00
Update controller.js
ADD "remove" MQTT Topic with "message" - Check
This commit is contained in:
1 parent
0328ad7cb6
commit
34feef6cf4
1 file changed
+14
@@ -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