Fix crash on MQTT message device model not known.

This commit is contained in:
Koenkk
2018-06-14 20:00:57 +02:00
parent d86aa10875
commit 7a13626da7
+13 -1
View File
@@ -412,7 +412,19 @@ class Controller {
}
// Find ep for this device
const mappedModel = zigbeeShepherdConverters.findByZigbeeModel(this.zigbee.getDevice(deviceID).modelId);
const device = this.zigbee.getDevice(deviceID);
if (!device) {
logger.error(`Failed to find device with deviceID ${deviceID}`);
return;
}
const mappedModel = zigbeeShepherdConverters.findByZigbeeModel(device.modelId);
if (!mappedModel) {
logger.warn(`Device with modelID '${device.modelId}' is not supported.`);
logger.warn(`Please see: https://github.com/Koenkk/zigbee2mqtt/wiki/How-to-support-new-devices`);
return;
}
const ep = mappedModel.ep && mappedModel.ep[topicPrefix] ? mappedModel.ep[topicPrefix] : null;
const published = [];