diff --git a/lib/extension/report.js b/lib/extension/report.js index 20d787a2..e80c5264 100644 --- a/lib/extension/report.js +++ b/lib/extension/report.js @@ -195,8 +195,14 @@ class Report extends Extension { // This message is typically send when a device comes online after being powered off // Ikea TRADFRI tend to forget their reporting after powered off. // Re-setup reporting. + // Only resetup reporting if configuredReportings was not populated yet, + // else reconfigure is done in zigbee-herdsman-converters ikea.js/bulbOnEvent + // configuredReportings are saved since Zigbee2MQTT 1.17.0 // https://github.com/Koenkk/zigbee2mqtt/issues/966 - if (this.enabled && messageType === 'deviceAnnounce' && utils.isIkeaTradfriDevice(device)) return true; + if (this.enabled && messageType === 'deviceAnnounce' && utils.isIkeaTradfriDevice(device) && + device.endpoints.filter((e) => e.configuredReportings.length === 0).length === device.endpoints.length) { + return true; + } // These do not support reproting. // https://github.com/Koenkk/zigbee-herdsman/issues/110 diff --git a/test/report.test.js b/test/report.test.js index 65f5079a..ec6b39d2 100644 --- a/test/report.test.js +++ b/test/report.test.js @@ -195,7 +195,7 @@ describe('Report', () => { }); it('Should configure reporting when deviceAnnounce message from IKEA device', async () => { - const device = zigbeeHerdsman.devices.bulb; + const device = zigbeeHerdsman.devices.bulb_2; const endpoint = device.getEndpoint(1); mockClear(device); const payload = {device}; @@ -287,6 +287,8 @@ describe('Report', () => { const device = zigbeeHerdsman.devices.bulb; const coordinatorEndpoint = zigbeeHerdsman.devices.coordinator.getEndpoint(1); const endpoint = device.getEndpoint(1); + const configuredReportings = endpoint.configuredReportings; + endpoint.configuredReportings = []; delete device.meta.reporting; mockClear(device); endpoint.getClusterAttributeValue = jest.fn(); @@ -308,5 +310,6 @@ describe('Report', () => { expect(endpoint.read).toHaveBeenCalledWith('lightingColorCtrl', ['colorCapabilities']) expect(endpoint.configureReporting).toHaveBeenCalledWith('lightingColorCtrl', [{"attribute": "colorTemperature", "maximumReportInterval": 300, "minimumReportInterval": 3, "reportableChange": 1}]); expect(endpoint.configureReporting).toHaveBeenCalledTimes(3); + endpoint.configuredReportings = configuredReportings; }); }); diff --git a/test/stub/zigbeeHerdsman.js b/test/stub/zigbeeHerdsman.js index fa6a488c..3faf5a9b 100644 --- a/test/stub/zigbeeHerdsman.js +++ b/test/stub/zigbeeHerdsman.js @@ -122,7 +122,7 @@ const returnDevices = []; const bulb_color = new Device('Router', '0x000b57fffec6a5b3', 40399, 4107, [new Endpoint(1, [0,3,4,5,6,8,768,2821,4096], [5,25,32,4096], '0x000b57fffec6a5b3', [], {lightingColorCtrl: {colorCapabilities: 254}})], true, "Mains (single phase)", "LLC020"); const bulb_color_2 = new Device('Router', '0x000b57fffec6a5b4', 401292, 4107, [new Endpoint(1, [0,3,4,5,6,8,768,2821,4096], [5,25,32,4096], '0x000b57fffec6a5b4')], true, "Mains (single phase)", "LLC020", false, 'Philips', '2019.09', '5.127.1.26581'); -const bulb_2 = new Device('Router', '0x000b57fffec6a5b7', 40369, 4476, [new Endpoint(1, [0,3,4,5,6,8,768,2821,4096], [5,25,32,4096], '0x000b57fffec6a5b7')], true, "Mains (single phase)", "TRADFRI bulb E27 WS opal 980lm"); +const bulb_2 = new Device('Router', '0x000b57fffec6a5b7', 40369, 4476, [new Endpoint(1, [0,3,4,5,6,8,768,2821,4096], [5,25,32,4096], '0x000b57fffec6a5b7', [], {lightingColorCtrl: {colorCapabilities: 17}})], true, "Mains (single phase)", "TRADFRI bulb E27 WS opal 980lm"); const TS0601_thermostat = new Device('EndDevice', '0x0017882104a44559', 6544,4151, [new Endpoint(1, [], [], '0x0017882104a44559')], true, "Mains (single phase)", 'kud7u2l'); const devices = {