diff --git a/lib/zigbee.ts b/lib/zigbee.ts index 8907507aa..5ee9723ed 100644 --- a/lib/zigbee.ts +++ b/lib/zigbee.ts @@ -98,7 +98,9 @@ export default class Zigbee { const device = this.resolveDevice(data.device.ieeeAddr); logger.debug(`Received Zigbee message from '${device.name}', type '${data.type}', ` + `cluster '${data.cluster}', data '${stringify(data.data)}' from endpoint ${data.endpoint.ID}` + - (data.hasOwnProperty('groupID') ? ` with groupID ${data.groupID}` : ``)); + (data.hasOwnProperty('groupID') ? ` with groupID ${data.groupID}` : ``) + + (device.zh.type === 'Coordinator' ? `, ignoring since it is from coordinator` : ``)); + if (device.zh.type === 'Coordinator') return; this.eventBus.emitDeviceMessage({...data, device}); }); diff --git a/test/controller.test.js b/test/controller.test.js index 99ee9fd9e..bfb67bd22 100644 --- a/test/controller.test.js +++ b/test/controller.test.js @@ -659,4 +659,14 @@ describe('Controller', () => { await zigbeeHerdsman.events.lastSeenChanged({device, reason: 'messageEmitted'}); expect(MQTT.publish).toHaveBeenCalledTimes(0); }); + + it('Ignore messages from coordinator', async () => { + // https://github.com/Koenkk/zigbee2mqtt/issues/9218 + await controller.start(); + const device = zigbeeHerdsman.devices.coordinator; + const payload = {device, endpoint: device.getEndpoint(1), type: 'attributeReport', linkquality: 10, cluster: 'genBasic', data: {modelId: device.modelID}}; + await zigbeeHerdsman.events.message(payload); + await flushPromises(); + expect(logger.debug).toHaveBeenCalledWith(`Received Zigbee message from 'Coordinator', type 'attributeReport', cluster 'genBasic', data '{"modelId":null}' from endpoint 1, ignoring since it is from coordinator`); + }); });