From 84017889b2e03895e9d90c9b896cf86d48abd0c0 Mon Sep 17 00:00:00 2001 From: Koen Kanters Date: Tue, 21 Jan 2020 20:55:04 +0100 Subject: [PATCH] Debounce SA-003-Zigbee on zclTransactionSequenceNumber. https://github.com/Koenkk/zigbee2mqtt/issues/2565 --- converters/fromZigbee.js | 13 +++++++++++++ devices.js | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/converters/fromZigbee.js b/converters/fromZigbee.js index 8882bcbfdab44..f8ed84447cbee 100644 --- a/converters/fromZigbee.js +++ b/converters/fromZigbee.js @@ -2373,6 +2373,19 @@ const converters = { }; }, }, + SA003_on_off: { + cluster: 'genOnOff', + type: ['attributeReport', 'readResponse'], + convert: (model, msg, publish, options, meta) => { + const last = store[msg.device.ieeeAddr]; + const current = msg.meta.zclTransactionSequenceNumber; + + if (last !== current && msg.data.hasOwnProperty('onOff')) { + store[msg.device.ieeeAddr] = last; + return {state: msg.data['onOff'] === 1 ? 'ON' : 'OFF'}; + } + }, + }, tint404011_scene: { cluster: 'genBasic', type: 'write', diff --git a/devices.js b/devices.js index de2403a8e19be..60c6bb69194f7 100755 --- a/devices.js +++ b/devices.js @@ -7015,7 +7015,7 @@ const devices = [ vendor: 'eWeLink', description: 'Zigbee smart plug', supports: 'on/off', - fromZigbee: [fz.on_off], + fromZigbee: [fz.SA003_on_off], toZigbee: [tz.on_off], meta: {configureKey: 1}, configure: async (device, coordinatorEndpoint) => {