@zwave-js/cc 15.17.0 → 15.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/cc/ConfigurationCC.js +8 -1
- package/build/cjs/cc/ConfigurationCC.js.map +2 -2
- package/build/cjs/cc/EntryControlCC.js +0 -3
- package/build/cjs/cc/EntryControlCC.js.map +2 -2
- package/build/cjs/cc/SoundSwitchCC._validateArgs.js +1 -1
- package/build/cjs/cc/SoundSwitchCC._validateArgs.js.map +1 -1
- package/build/cjs/cc/SoundSwitchCC.d.ts +7 -3
- package/build/cjs/cc/SoundSwitchCC.js +12 -8
- package/build/cjs/cc/SoundSwitchCC.js.map +2 -2
- package/build/cjs/cc/UserCodeCC.d.ts +1 -1
- package/build/cjs/cc/UserCodeCC.js +78 -33
- package/build/cjs/cc/UserCodeCC.js.map +2 -2
- package/build/cjs/cc/index.js +546 -66
- package/build/cjs/cc/index.js.map +2 -2
- package/build/cjs/lib/API.d.ts +2 -2
- package/build/cjs/lib/API.js.map +2 -2
- package/build/cjs/lib/utils.d.ts +7 -1
- package/build/cjs/lib/utils.js +21 -17
- package/build/cjs/lib/utils.js.map +2 -2
- package/build/esm/cc/ConfigurationCC.d.ts.map +1 -1
- package/build/esm/cc/ConfigurationCC.js +10 -1
- package/build/esm/cc/ConfigurationCC.js.map +1 -1
- package/build/esm/cc/EntryControlCC.d.ts.map +1 -1
- package/build/esm/cc/EntryControlCC.js +1 -3
- package/build/esm/cc/EntryControlCC.js.map +1 -1
- package/build/esm/cc/SoundSwitchCC._validateArgs.js +1 -1
- package/build/esm/cc/SoundSwitchCC._validateArgs.js.map +1 -1
- package/build/esm/cc/SoundSwitchCC.d.ts +7 -3
- package/build/esm/cc/SoundSwitchCC.d.ts.map +1 -1
- package/build/esm/cc/SoundSwitchCC.js +12 -8
- package/build/esm/cc/SoundSwitchCC.js.map +1 -1
- package/build/esm/cc/UserCodeCC.d.ts +1 -1
- package/build/esm/cc/UserCodeCC.d.ts.map +1 -1
- package/build/esm/cc/UserCodeCC.js +111 -41
- package/build/esm/cc/UserCodeCC.js.map +1 -1
- package/build/esm/cc/index.d.ts.map +1 -1
- package/build/esm/cc/index.js +546 -527
- package/build/esm/cc/index.js.map +1 -1
- package/build/esm/lib/API.d.ts +2 -2
- package/build/esm/lib/API.d.ts.map +1 -1
- package/build/esm/lib/API.js.map +1 -1
- package/build/esm/lib/utils.d.ts +7 -1
- package/build/esm/lib/utils.d.ts.map +1 -1
- package/build/esm/lib/utils.js +25 -21
- package/build/esm/lib/utils.js.map +1 -1
- package/package.json +9 -9
|
@@ -361,7 +361,7 @@ let UserCodeCCAPI = (() => {
|
|
|
361
361
|
}
|
|
362
362
|
/** Configures a single user code */
|
|
363
363
|
async set(userId, userIdStatus, userCode) {
|
|
364
|
-
if (userId > 255) {
|
|
364
|
+
if (this.version >= 2 || userId > 255) {
|
|
365
365
|
return this.setMany([{ userId, userIdStatus, userCode }]);
|
|
366
366
|
}
|
|
367
367
|
this.assertSupportsCommand(import_Types.UserCodeCommand, import_Types.UserCodeCommand.Set);
|
|
@@ -425,7 +425,7 @@ let UserCodeCCAPI = (() => {
|
|
|
425
425
|
* @param userId The user code to clear. If none or 0 is given, all codes are cleared
|
|
426
426
|
*/
|
|
427
427
|
async clear(userId = 0) {
|
|
428
|
-
if (this.version
|
|
428
|
+
if (this.version >= 2 || userId > 255) {
|
|
429
429
|
return this.setMany([
|
|
430
430
|
{ userId, userIdStatus: import_Types.UserIDStatus.Available }
|
|
431
431
|
]);
|
|
@@ -597,12 +597,10 @@ let UserCodeCC = (() => {
|
|
|
597
597
|
for (let userId = 1; userId <= supportedUsers; userId++) {
|
|
598
598
|
setUserCodeMetadata.call(this, ctx, userId);
|
|
599
599
|
}
|
|
600
|
-
|
|
601
|
-
await this.refreshValues(ctx);
|
|
602
|
-
}
|
|
600
|
+
await this.refreshValues(ctx, ctx.getInterviewOptions()?.queryAllUserCodes ?? false);
|
|
603
601
|
this.setInterviewComplete(ctx, true);
|
|
604
602
|
}
|
|
605
|
-
async refreshValues(ctx) {
|
|
603
|
+
async refreshValues(ctx, queryAllUserCodes = false) {
|
|
606
604
|
const node = this.getNode(ctx);
|
|
607
605
|
const endpoint = this.getEndpoint(ctx);
|
|
608
606
|
const api = import_API.CCAPI.create(import_core.CommandClasses["User Code"], ctx, endpoint).withOptions({
|
|
@@ -613,6 +611,7 @@ let UserCodeCC = (() => {
|
|
|
613
611
|
const supportedKeypadModes = this.getValue(ctx, import_CCValues_generated.UserCodeCCValues.supportedKeypadModes) ?? [];
|
|
614
612
|
const supportedUsers = this.getValue(ctx, import_CCValues_generated.UserCodeCCValues.supportedUsers) ?? 0;
|
|
615
613
|
const supportsMultipleUserCodeReport = !!this.getValue(ctx, import_CCValues_generated.UserCodeCCValues.supportsMultipleUserCodeReport);
|
|
614
|
+
const userCodeAction = !node.bootstrapped && !queryAllUserCodes ? "delete" : "query";
|
|
616
615
|
if (api.version >= 2) {
|
|
617
616
|
if (supportsAdminCode) {
|
|
618
617
|
ctx.logNode(node.id, {
|
|
@@ -637,39 +636,55 @@ let UserCodeCC = (() => {
|
|
|
637
636
|
});
|
|
638
637
|
currentUserCodeChecksum = await api.getUserCodeChecksum();
|
|
639
638
|
}
|
|
640
|
-
if (
|
|
639
|
+
if (userCodeAction === "delete") {
|
|
641
640
|
ctx.logNode(node.id, {
|
|
642
|
-
message: "
|
|
641
|
+
message: "Initial interview, clearing all user codes...",
|
|
643
642
|
direction: "outbound"
|
|
644
643
|
});
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
644
|
+
await api.clear();
|
|
645
|
+
} else if (userCodeAction === "query") {
|
|
646
|
+
if (!supportsUserCodeChecksum || currentUserCodeChecksum !== storedUserCodeChecksum) {
|
|
647
|
+
ctx.logNode(node.id, {
|
|
648
|
+
message: "checksum changed or is not supported, querying all user codes...",
|
|
649
|
+
direction: "outbound"
|
|
650
|
+
});
|
|
651
|
+
if (supportsMultipleUserCodeReport) {
|
|
652
|
+
let nextUserId = 1;
|
|
653
|
+
while (nextUserId > 0 && nextUserId <= supportedUsers) {
|
|
654
|
+
const response = await api.get(nextUserId, true);
|
|
655
|
+
if (response) {
|
|
656
|
+
nextUserId = response.nextUserId;
|
|
657
|
+
} else {
|
|
658
|
+
ctx.logNode(node.id, {
|
|
659
|
+
endpoint: this.endpointIndex,
|
|
660
|
+
message: `Querying user code #${nextUserId} timed out, skipping the remaining interview...`,
|
|
661
|
+
level: "warn"
|
|
662
|
+
});
|
|
663
|
+
break;
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
} else {
|
|
667
|
+
for (let userId = 1; userId <= supportedUsers; userId++) {
|
|
668
|
+
await api.get(userId);
|
|
658
669
|
}
|
|
659
|
-
}
|
|
660
|
-
} else {
|
|
661
|
-
for (let userId = 1; userId <= supportedUsers; userId++) {
|
|
662
|
-
await api.get(userId);
|
|
663
670
|
}
|
|
664
671
|
}
|
|
665
672
|
}
|
|
666
673
|
} else {
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
await api.
|
|
674
|
+
if (userCodeAction === "delete") {
|
|
675
|
+
ctx.logNode(node.id, {
|
|
676
|
+
message: "Initial interview, clearing all user codes...",
|
|
677
|
+
direction: "outbound"
|
|
678
|
+
});
|
|
679
|
+
await api.clear();
|
|
680
|
+
} else if (userCodeAction === "query") {
|
|
681
|
+
ctx.logNode(node.id, {
|
|
682
|
+
message: "querying all user codes...",
|
|
683
|
+
direction: "outbound"
|
|
684
|
+
});
|
|
685
|
+
for (let userId = 1; userId <= supportedUsers; userId++) {
|
|
686
|
+
await api.get(userId);
|
|
687
|
+
}
|
|
673
688
|
}
|
|
674
689
|
}
|
|
675
690
|
}
|
|
@@ -1532,8 +1547,38 @@ let UserCodeCCExtendedUserCodeSet = (() => {
|
|
|
1532
1547
|
super(options);
|
|
1533
1548
|
this.userCodes = options.userCodes;
|
|
1534
1549
|
}
|
|
1535
|
-
static from(
|
|
1536
|
-
|
|
1550
|
+
static from(raw, ctx) {
|
|
1551
|
+
(0, import_core.validatePayload)(raw.payload.length >= 1);
|
|
1552
|
+
const numCodes = raw.payload[0];
|
|
1553
|
+
let offset = 1;
|
|
1554
|
+
const userCodes = [];
|
|
1555
|
+
for (let i = 0; i < numCodes; i++) {
|
|
1556
|
+
(0, import_core.validatePayload)(raw.payload.length >= offset + 4);
|
|
1557
|
+
const userId = raw.payload.readUInt16BE(offset);
|
|
1558
|
+
const userIdStatus = raw.payload[offset + 2];
|
|
1559
|
+
const codeLength = raw.payload[offset + 3];
|
|
1560
|
+
(0, import_core.validatePayload)(raw.payload.length >= offset + 4 + codeLength);
|
|
1561
|
+
if (userIdStatus === import_Types.UserIDStatus.Available) {
|
|
1562
|
+
userCodes.push({
|
|
1563
|
+
userId,
|
|
1564
|
+
userIdStatus
|
|
1565
|
+
});
|
|
1566
|
+
} else {
|
|
1567
|
+
const userCodeBuffer = raw.payload.subarray(offset + 4, offset + 4 + codeLength);
|
|
1568
|
+
const userCodeString = userCodeBuffer.toString("utf8");
|
|
1569
|
+
const userCode = (0, import_shared.isPrintableASCII)(userCodeString) ? userCodeString : userCodeBuffer;
|
|
1570
|
+
userCodes.push({
|
|
1571
|
+
userId,
|
|
1572
|
+
userIdStatus,
|
|
1573
|
+
userCode
|
|
1574
|
+
});
|
|
1575
|
+
}
|
|
1576
|
+
offset += 4 + codeLength;
|
|
1577
|
+
}
|
|
1578
|
+
return new this({
|
|
1579
|
+
nodeId: ctx.sourceNodeId,
|
|
1580
|
+
userCodes
|
|
1581
|
+
});
|
|
1537
1582
|
}
|
|
1538
1583
|
userCodes;
|
|
1539
1584
|
serialize(ctx) {
|