From bede1032e6146cca4a0fa83aeed9fe738cc94dee Mon Sep 17 00:00:00 2001 From: Koen Kanters Date: Mon, 3 Dec 2018 17:48:21 +0100 Subject: [PATCH] Refresh state after transition. https://github.com/Koenkk/zigbee-shepherd-converters/issues/155 --- lib/extension/devicePublish.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/extension/devicePublish.js b/lib/extension/devicePublish.js index 7c15c09d..2907c1cf 100644 --- a/lib/extension/devicePublish.js +++ b/lib/extension/devicePublish.js @@ -150,6 +150,22 @@ class DevicePublish { } ); }); + + // When there is a transition in the message the state of the device gets out of sync. + // Therefore; at the end of the transition, read the new state from the device. + if (topic.type === 'set' && converted.zclData.transtime) { + const time = converted.zclData.transtime * 100; + const getConverted = converter.convert(json[key], json, 'get'); + setTimeout(() => { + // Add job to queue + this.queue.push((queueCallback) => { + this.zigbee.publish( + ieeeAddr, getConverted.cid, getConverted.cmd, getConverted.cmdType, + getConverted.zclData, getConverted.cfg, endpoint, () => queueCallback() + ); + }); + }, time); + } }); return true;