Skip message when definition is undefined and still interviewing instead of modelID. https://github.com/Koenkk/zigbee2mqtt/issues/3947

This commit is contained in:
Koen Kanters
2020-07-22 14:00:27 +02:00
parent 93cae0b09a
commit 28d48f3d96
2 changed files with 14 additions and 10 deletions
+7 -7
View File
@@ -97,14 +97,14 @@ class Receive extends Extension {
return false;
}
if (!data.device.modelID && data.device.interviewing) {
logger.debug(`Skipping message, modelID is undefined and still interviewing`);
return false;
}
if (!resolvedEntity.definition) {
logger.warn(`Received message from unsupported device with Zigbee model '${data.device.modelID}'`);
logger.warn(`Please see: https://www.zigbee2mqtt.io/how_tos/how_to_support_new_devices.html.`);
if (data.device.interviewing) {
logger.debug(`Skipping message, definition is undefined and still interviewing`);
} else {
logger.warn(`Received message from unsupported device with Zigbee model '${data.device.modelID}'`);
logger.warn(`Please see: https://www.zigbee2mqtt.io/how_tos/how_to_support_new_devices.html.`);
}
return false;
}
+7 -3
View File
@@ -366,23 +366,27 @@ describe('Receive', () => {
expect(MQTT.publish).toHaveBeenCalledTimes(0);
});
it('Should not handle messages from unsupported devices', async () => {
it('Should not handle messages from unsupported devices and link to docs', async () => {
const device = zigbeeHerdsman.devices.unsupported;
const data = {onOff: 1};
logger.warn.mockClear();
const payload = {data, cluster: 'genOnOff', device, endpoint: device.getEndpoint(1), type: 'attributeReport', linkquality: 10};
await zigbeeHerdsman.events.message(payload);
await flushPromises();
expect(logger.warn).toHaveBeenCalledWith(`Received message from unsupported device with Zigbee model 'notSupportedModelID'`);
expect(logger.warn).toHaveBeenCalledWith(`Please see: https://www.zigbee2mqtt.io/how_tos/how_to_support_new_devices.html.`);
expect(MQTT.publish).toHaveBeenCalledTimes(0);
});
it('Should not handle messages from still interviewing devices with unknown modelID', async () => {
it('Should not handle messages from still interviewing devices with unknown definition', async () => {
const device = zigbeeHerdsman.devices.interviewing;
const data = {onOff: 1};
logger.debug.mockClear();
const payload = {data, cluster: 'genOnOff', device, endpoint: device.getEndpoint(1), type: 'attributeReport', linkquality: 10};
await zigbeeHerdsman.events.message(payload);
await flushPromises();
expect(MQTT.publish).toHaveBeenCalledTimes(0);
expect(logger.debug).toHaveBeenCalledWith(`Skipping message, modelID is undefined and still interviewing`);
expect(logger.debug).toHaveBeenCalledWith(`Skipping message, definition is undefined and still interviewing`);
});
it('Should handle a command', async () => {