Update controller.js

ADD "remove" MQTT Topic with "message" - Check
This commit is contained in:
tb-killa
2018-06-06 21:45:36 +03:00
committed by Marius Ciotlos
parent 0328ad7cb6
commit 34feef6cf4
+14
View File
@@ -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}'`);
}