From 6dd2926a1d61e95eab1c248a609f8d40d22ed629 Mon Sep 17 00:00:00 2001 From: Simon Rasmussen Date: Tue, 22 Jan 2019 20:08:57 +0100 Subject: [PATCH] Refactored light specific transtime to generic readAfterWriteTime value (#910) * Refactored light specific transtime value to generic readAfterWriteTime value * Added line break --- lib/extension/devicePublish.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/extension/devicePublish.js b/lib/extension/devicePublish.js index 9aa213945..1dbb3fe3f 100644 --- a/lib/extension/devicePublish.js +++ b/lib/extension/devicePublish.js @@ -175,10 +175,11 @@ 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 && entity.type === 'device') { - const time = converted.zclData.transtime * 100; + // It's possible for devices to get out of sync when writing an attribute that's not reportable. + // So here we re-read the value after a specified timeout, this timeout could for example be the + // transition time of a color change. + if (topic.type === 'set' && entity.type === 'device' + && converted.hasOwnProperty('readAfterWriteTime') && converted.readAfterWriteTime !== 0) { const getConverted = converter.convert(key, json[key], json, 'get'); setTimeout(() => { // Add job to queue @@ -188,7 +189,7 @@ class DevicePublish { getConverted.zclData, getConverted.cfg, endpoint, () => queueCallback() ); }); - }, time); + }, converted.readAfterWriteTime); } });