Update zigbee-shepherd-converters to 9.0.0.

This commit is contained in:
Koen Kanters
2019-05-01 21:50:01 +02:00
parent 1f6e64b4c0
commit a3d26ceeb2
5 changed files with 61 additions and 53 deletions
+8 -6
View File
@@ -120,12 +120,14 @@ class DeviceAvailability {
});
converters.forEach((converter) => {
const converted = converter.convert(null, null, null, 'get');
if (converted) {
this.zigbee.publish(
ieeeAddr, 'device', converted.cid, converted.cmd, converted.cmdType,
converted.zclData, converted.cfg, null, () => {}
);
const convertedResults = converter.convert(null, null, null, 'get');
if (convertedResults && convertedResults.length) {
convertedResults.forEach((converted) => {
this.zigbee.publish(
ieeeAddr, 'device', converted.cid, converted.cmd, converted.cmdType,
converted.zclData, converted.cfg, null, () => {}
);
});
}
});
}
+41 -37
View File
@@ -168,49 +168,53 @@ class DevicePublish {
}
// Converter didn't return a result, skip
const converted = converter.convert(key, json[key], json, topic.type, topic.postfix);
if (!converted) {
const convertedResults = converter.convert(key, json[key], json, topic.type, topic.postfix);
if (!convertedResults || !convertedResults.length) {
return;
}
this.zigbee.publish(
entity.ID,
entity.type,
converted.cid,
converted.cmd,
converted.cmdType,
converted.zclData,
converted.cfg,
endpoint,
(error, rsp) => {
if (!error) {
this.handlePublished(entity, topic, converter, converted, key, json[key]);
} else {
this.handlePublishError(entity, message, error);
convertedResults.forEach((converted) => {
this.zigbee.publish(
entity.ID,
entity.type,
converted.cid,
converted.cmd,
converted.cmdType,
converted.zclData,
converted.cfg,
endpoint,
(error, rsp) => {
if (!error) {
this.handlePublished(entity, topic, converter, converted, key, json[key]);
} else {
this.handlePublishError(entity, message, error);
}
}
);
// 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 or for forcing a state read for devices that don't
// automatically report a new state when set.
// When reporting is requested for a device (report: true in device-specific settings) we won't
// ever issue a read here, as we assume the device will properly report changes.
// Only do this when the retrieve_state option is enabled for this device.
const deviceSettings = settings.getDevice(entity.ID);
if (topic.type === 'set' && entity.type === 'device' &&
converted.hasOwnProperty('readAfterWriteTime') && deviceSettings && deviceSettings.retrieve_state) {
const getConvertedResults = converter.convert(key, json[key], json, 'get');
getConvertedResults.forEach((getConverted) => {
setTimeout(() => {
this.zigbee.publish(
entity.ID, entity.type, getConverted.cid, getConverted.cmd, getConverted.cmdType,
getConverted.zclData, getConverted.cfg, endpoint, () => {}
);
}, converted.readAfterWriteTime);
});
}
);
// 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 or for forcing a state read for devices that don't
// automatically report a new state when set.
// When reporting is requested for a device (report: true in device-specific settings) we won't
// ever issue a read here, as we assume the device will properly report changes.
// Only do this when the retrieve_state option is enabled for this device.
const deviceSettings = settings.getDevice(entity.ID);
if (topic.type === 'set' && entity.type === 'device' && converted.hasOwnProperty('readAfterWriteTime') &&
deviceSettings && deviceSettings.retrieve_state) {
const getConverted = converter.convert(key, json[key], json, 'get');
setTimeout(() => {
this.zigbee.publish(
entity.ID, entity.type, getConverted.cid, getConverted.cmd, getConverted.cmdType,
getConverted.zclData, getConverted.cfg, endpoint, () => {}
);
}, converted.readAfterWriteTime);
}
usedConverters.push(converter);
usedConverters.push(converter);
});
});
return true;
+6 -6
View File
@@ -6601,9 +6601,9 @@
"integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c="
},
"uglify-js": {
"version": "3.5.9",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.5.9.tgz",
"integrity": "sha512-WpT0RqsDtAWPNJK955DEnb6xjymR8Fn0OlK4TT4pS0ASYsVPqr5ELhgwOwLCP5J5vHeJ4xmMmz3DEgdqC10JeQ==",
"version": "3.5.10",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.5.10.tgz",
"integrity": "sha512-/GTF0nosyPLbdJBd+AwYiZ+Hu5z8KXWnO0WCGt1BQ/u9Iamhejykqmz5o1OHJ53+VAk6xVxychonnApDjuqGsw==",
"dev": true,
"optional": true,
"requires": {
@@ -7071,9 +7071,9 @@
}
},
"zigbee-shepherd-converters": {
"version": "8.1.5",
"resolved": "https://registry.npmjs.org/zigbee-shepherd-converters/-/zigbee-shepherd-converters-8.1.5.tgz",
"integrity": "sha512-jx3/foSlnMuMAQvzNA+L3ZF/1b/NnNXnCyhentdVfLm5bQDOA+by50xHKw8az2JU70NwJvKvXk0swXzpy9nJqA==",
"version": "9.0.0",
"resolved": "https://registry.npmjs.org/zigbee-shepherd-converters/-/zigbee-shepherd-converters-9.0.0.tgz",
"integrity": "sha512-eeAAfpkrLAUj1cGyKaRPKS44cK7mcQDRyBbMEiW4B4jdkJZUzNfsRMe1553/E6l/uGJcHbLFBf3wT8Ts8zCbiw==",
"requires": {
"chai": "*",
"debounce": "*",
+1 -1
View File
@@ -46,7 +46,7 @@
"zcl-id": "git+https://github.com/Koenkk/zcl-id.git#4fa75c92424cd070a3bf6e1f4640b1e3ad8f802d",
"ziee": "*",
"zigbee-shepherd": "git+https://github.com/Koenkk/zigbee-shepherd.git#566cba295119cb334a7a7d939b4741e59415ed80",
"zigbee-shepherd-converters": "8.1.5",
"zigbee-shepherd-converters": "9.0.0",
"deep-diff": "*",
"zive": "*"
},
+5 -3
View File
@@ -926,11 +926,13 @@ describe('DevicePublish', () => {
expect(zigbee.publish.mock.calls[1][2]).toBe('lightingColorCtrl');
expect(zigbee.publish.mock.calls[1][3]).toBe('moveToColor');
await wait(10);
expect(zigbee.publish).toHaveBeenCalledTimes(4);
expect(zigbee.publish.mock.calls[2][2]).toBe('genLevelCtrl');
expect(zigbee.publish).toHaveBeenCalledTimes(5);
expect(zigbee.publish.mock.calls[2][2]).toBe('genOnOff');
expect(zigbee.publish.mock.calls[2][3]).toBe('read');
expect(zigbee.publish.mock.calls[3][2]).toBe('lightingColorCtrl');
expect(zigbee.publish.mock.calls[3][2]).toBe('genLevelCtrl');
expect(zigbee.publish.mock.calls[3][3]).toBe('read');
expect(zigbee.publish.mock.calls[4][2]).toBe('lightingColorCtrl');
expect(zigbee.publish.mock.calls[4][3]).toBe('read');
expect(publishEntityState).toHaveBeenCalledTimes(2);
expect(publishEntityState).toHaveBeenNthCalledWith(1,
'0x00000020',