Skip to content

Commit c41b3c2

Browse files
committed
fix: user code CC tests
1 parent ff35866 commit c41b3c2

6 files changed

Lines changed: 118 additions & 68 deletions

File tree

dut/zwave-js/handlers/behaviors/capabilities.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,11 @@ const dutCapabilityResponses: Record<
2525
CONTROLS_UNLISTED_CCS: "No",
2626
ALL_DOCUMENTED_AS_CONTROLLED: "Yes",
2727
PARTIAL_CONTROL_DOCUMENTED: (ctx) => {
28-
// Entry Control CC is marked as partial control in the certification portal
29-
if (ctx.testName.includes("CCR_EntryControlCC")) {
28+
// Entry Control CC and User Code CC is marked as partial control in the certification portal
29+
if (
30+
ctx.testName.includes("CCR_EntryControlCC") ||
31+
ctx.testName.includes("CCR_UserCodeCC")
32+
) {
3033
return "Yes";
3134
}
3235
return "No";
@@ -103,7 +106,9 @@ registerHandler(/.*/, {
103106
const key: CCCapabilityKey = `${commandClass}:${capabilityId}`;
104107
const response = ccCapabilityResponses[key];
105108
if (response !== undefined) {
106-
return typeof response === "function" ? response(ctx.message) : response;
109+
return typeof response === "function"
110+
? response(ctx.message)
111+
: response;
107112
}
108113
}
109114

dut/zwave-js/handlers/tests/CCR_UserCodeCC_Rev04.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { UserIDStatus, KeypadMode } from "zwave-js";
22
import { registerHandler } from "../../prompt-handlers.ts";
3-
import type { SendCommandMessage } from "../../../../src/ctt-message-types.ts";
3+
import type {
4+
SendCommandMessage,
5+
QueryUserCodesMessage,
6+
} from "../../../../src/ctt-message-types.ts";
47

58
const statusNameToEnum: Record<string, UserIDStatus> = {
69
enabled: UserIDStatus.Enabled,
@@ -69,5 +72,17 @@ registerHandler("CCR_UserCodeCC_Rev04", {
6972
return true;
7073
}
7174
}
75+
76+
// Handle QUERY_USER_CODES - query specific user codes without full re-interview
77+
if (ctx.message?.type === "QUERY_USER_CODES") {
78+
const msg = ctx.message as QueryUserCodesMessage;
79+
const userCodeCC = node.commandClasses["User Code"];
80+
81+
// Query each user ID in sequence
82+
for (const userId of msg.userIds) {
83+
await userCodeCC.get(userId);
84+
}
85+
return true;
86+
}
7287
},
7388
});

dut/zwave-js/package-lock.json

Lines changed: 63 additions & 63 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dut/zwave-js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"@zwave-js/server": "^3.5.0",
1414
"alcalzone-shared": "^5.0.0",
1515
"ws": "^8.18.0",
16-
"zwave-js": "^15.18.0"
16+
"zwave-js": "^15.19.0"
1717
},
1818
"devDependencies": {
1919
"@types/node": "^22.10.2",

src/ctt-message-types.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,15 @@ export interface TriggerReInterviewMessage {
607607
nodeId: number;
608608
}
609609

610+
// =============================================================================
611+
// QUERY_USER_CODES - Query specific user codes without full re-interview
612+
// =============================================================================
613+
614+
export interface QueryUserCodesMessage {
615+
type: "QUERY_USER_CODES";
616+
userIds: number[];
617+
}
618+
610619
// =============================================================================
611620
// VERIFY_INDICATOR_IDENTIFY - Check if identify event was received
612621
// =============================================================================
@@ -637,6 +646,7 @@ export type DUTMessage =
637646
| TrySetConfigParameterMessage
638647
| ShouldDisregardRecommendationMessage
639648
| TriggerReInterviewMessage
649+
| QueryUserCodesMessage
640650
| VerifyIndicatorIdentifyMessage;
641651

642652
// =============================================================================

src/ctt-parser.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import type {
1818
TrySetConfigParameterMessage,
1919
ShouldDisregardRecommendationMessage,
2020
TriggerReInterviewMessage,
21+
QueryUserCodesMessage,
2122
VerifyIndicatorIdentifyMessage,
2223
OrchestratorState,
2324
DUTCapabilityId,
@@ -925,6 +926,25 @@ export function parsePrompt(
925926
return { action: "send_to_dut", message, answer: "Ok" };
926927
}
927928

929+
// QUERY_USER_CODES - Request specific user codes without full re-interview
930+
// Matches: "trigger an interview...without deleting user codes...User IDs = '1', '50' and '11111'"
931+
if (/trigger an interview.+without deleting user codes.+from User IDs/i.test(promptText)) {
932+
// Extract all user IDs from the prompt (e.g., '1', '50', '11111')
933+
const userIdPattern = /'(\d+)'/g;
934+
const userIds: number[] = [];
935+
let match;
936+
while ((match = userIdPattern.exec(promptText)) !== null) {
937+
userIds.push(parseInt(match[1]!));
938+
}
939+
if (userIds.length > 0) {
940+
const message: QueryUserCodesMessage = {
941+
type: "QUERY_USER_CODES",
942+
userIds,
943+
};
944+
return { action: "send_to_dut", message, answer: "Ok" };
945+
}
946+
}
947+
928948
// VERIFY_INDICATOR_IDENTIFY
929949
if (/did .+ indicator .+ blink \w+ times/i.test(promptText)) {
930950
const message: VerifyIndicatorIdentifyMessage = {

0 commit comments

Comments
 (0)