Refactored light specific transtime to generic readAfterWriteTime value (#910)

* Refactored light specific transtime value to generic readAfterWriteTime
value

* Added line break
This commit is contained in:
Simon Rasmussen 2019-01-22 20:08:57 +01:00 committed by Koen Kanters
parent 5970e498f3
commit 6dd2926a1d

View File

@ -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);
}
});