@zwave-js/cc 15.15.3 → 15.16.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.
Files changed (108) hide show
  1. package/build/cjs/cc/BatteryCC.js +4 -0
  2. package/build/cjs/cc/BatteryCC.js.map +2 -2
  3. package/build/cjs/cc/ConfigurationCC.d.ts +6 -0
  4. package/build/cjs/cc/ConfigurationCC.js +49 -1
  5. package/build/cjs/cc/ConfigurationCC.js.map +2 -2
  6. package/build/cjs/cc/EntryControlCC.d.ts +2 -2
  7. package/build/cjs/cc/EntryControlCC.js.map +2 -2
  8. package/build/cjs/cc/FirmwareUpdateMetaDataCC.d.ts +4 -4
  9. package/build/cjs/cc/FirmwareUpdateMetaDataCC.js.map +2 -2
  10. package/build/cjs/cc/ManufacturerProprietaryCC.d.ts +4 -4
  11. package/build/cjs/cc/ManufacturerProprietaryCC.js.map +2 -2
  12. package/build/cjs/cc/MeterCC.js.map +2 -2
  13. package/build/cjs/cc/MultiChannelAssociationCC.js.map +2 -2
  14. package/build/cjs/cc/NodeNamingCC.js.map +2 -2
  15. package/build/cjs/cc/NotificationCC.d.ts +3 -3
  16. package/build/cjs/cc/NotificationCC.js.map +2 -2
  17. package/build/cjs/cc/Security2CC.d.ts +14 -14
  18. package/build/cjs/cc/Security2CC.js.map +2 -2
  19. package/build/cjs/cc/SecurityCC.d.ts +10 -10
  20. package/build/cjs/cc/SecurityCC.js.map +2 -2
  21. package/build/cjs/cc/ThermostatModeCC.d.ts +6 -6
  22. package/build/cjs/cc/ThermostatModeCC.js.map +2 -2
  23. package/build/cjs/cc/TransportServiceCC.d.ts +7 -7
  24. package/build/cjs/cc/TransportServiceCC.js.map +2 -2
  25. package/build/cjs/cc/UserCodeCC.d.ts +6 -6
  26. package/build/cjs/cc/UserCodeCC.js.map +2 -2
  27. package/build/cjs/cc/VersionCC.js.map +2 -2
  28. package/build/cjs/cc/ZWaveProtocolCC.d.ts +3 -3
  29. package/build/cjs/cc/ZWaveProtocolCC.js.map +2 -2
  30. package/build/cjs/lib/CommandClass.d.ts +4 -4
  31. package/build/cjs/lib/CommandClass.js.map +2 -2
  32. package/build/cjs/lib/NotificationEventPayload.d.ts +2 -1
  33. package/build/cjs/lib/NotificationEventPayload.js.map +2 -2
  34. package/build/cjs/lib/Security2/Extension.d.ts +12 -12
  35. package/build/cjs/lib/Security2/Extension.js.map +2 -2
  36. package/build/cjs/lib/_Types.d.ts +2 -1
  37. package/build/cjs/lib/_Types.js.map +2 -2
  38. package/build/cjs/lib/serializers.d.ts +4 -4
  39. package/build/cjs/lib/serializers.js.map +2 -2
  40. package/build/cjs/lib/traits.d.ts +5 -0
  41. package/build/esm/cc/BatteryCC.d.ts.map +1 -1
  42. package/build/esm/cc/BatteryCC.js +3 -0
  43. package/build/esm/cc/BatteryCC.js.map +1 -1
  44. package/build/esm/cc/ConfigurationCC.d.ts +6 -0
  45. package/build/esm/cc/ConfigurationCC.d.ts.map +1 -1
  46. package/build/esm/cc/ConfigurationCC.js +62 -1
  47. package/build/esm/cc/ConfigurationCC.js.map +1 -1
  48. package/build/esm/cc/EntryControlCC.d.ts +2 -2
  49. package/build/esm/cc/EntryControlCC.d.ts.map +1 -1
  50. package/build/esm/cc/EntryControlCC.js.map +1 -1
  51. package/build/esm/cc/FirmwareUpdateMetaDataCC.d.ts +4 -4
  52. package/build/esm/cc/FirmwareUpdateMetaDataCC.d.ts.map +1 -1
  53. package/build/esm/cc/FirmwareUpdateMetaDataCC.js.map +1 -1
  54. package/build/esm/cc/ManufacturerProprietaryCC.d.ts +4 -4
  55. package/build/esm/cc/ManufacturerProprietaryCC.d.ts.map +1 -1
  56. package/build/esm/cc/ManufacturerProprietaryCC.js.map +1 -1
  57. package/build/esm/cc/MeterCC.d.ts.map +1 -1
  58. package/build/esm/cc/MeterCC.js.map +1 -1
  59. package/build/esm/cc/MultiChannelAssociationCC.d.ts.map +1 -1
  60. package/build/esm/cc/MultiChannelAssociationCC.js.map +1 -1
  61. package/build/esm/cc/NodeNamingCC.d.ts.map +1 -1
  62. package/build/esm/cc/NodeNamingCC.js.map +1 -1
  63. package/build/esm/cc/NotificationCC.d.ts +3 -3
  64. package/build/esm/cc/NotificationCC.d.ts.map +1 -1
  65. package/build/esm/cc/NotificationCC.js.map +1 -1
  66. package/build/esm/cc/Security2CC.d.ts +14 -14
  67. package/build/esm/cc/Security2CC.d.ts.map +1 -1
  68. package/build/esm/cc/Security2CC.js +1 -1
  69. package/build/esm/cc/Security2CC.js.map +1 -1
  70. package/build/esm/cc/SecurityCC.d.ts +10 -10
  71. package/build/esm/cc/SecurityCC.d.ts.map +1 -1
  72. package/build/esm/cc/SecurityCC.js +1 -1
  73. package/build/esm/cc/SecurityCC.js.map +1 -1
  74. package/build/esm/cc/ThermostatModeCC.d.ts +6 -6
  75. package/build/esm/cc/ThermostatModeCC.d.ts.map +1 -1
  76. package/build/esm/cc/ThermostatModeCC.js +1 -1
  77. package/build/esm/cc/ThermostatModeCC.js.map +1 -1
  78. package/build/esm/cc/TransportServiceCC.d.ts +7 -7
  79. package/build/esm/cc/TransportServiceCC.d.ts.map +1 -1
  80. package/build/esm/cc/TransportServiceCC.js.map +1 -1
  81. package/build/esm/cc/UserCodeCC.d.ts +6 -6
  82. package/build/esm/cc/UserCodeCC.d.ts.map +1 -1
  83. package/build/esm/cc/UserCodeCC.js.map +1 -1
  84. package/build/esm/cc/VersionCC.d.ts.map +1 -1
  85. package/build/esm/cc/VersionCC.js +1 -1
  86. package/build/esm/cc/VersionCC.js.map +1 -1
  87. package/build/esm/cc/ZWaveProtocolCC.d.ts +3 -3
  88. package/build/esm/cc/ZWaveProtocolCC.d.ts.map +1 -1
  89. package/build/esm/cc/ZWaveProtocolCC.js.map +1 -1
  90. package/build/esm/lib/CommandClass.d.ts +4 -4
  91. package/build/esm/lib/CommandClass.d.ts.map +1 -1
  92. package/build/esm/lib/CommandClass.js.map +1 -1
  93. package/build/esm/lib/NotificationEventPayload.d.ts +2 -1
  94. package/build/esm/lib/NotificationEventPayload.d.ts.map +1 -1
  95. package/build/esm/lib/NotificationEventPayload.js.map +1 -1
  96. package/build/esm/lib/Security2/Extension.d.ts +12 -12
  97. package/build/esm/lib/Security2/Extension.d.ts.map +1 -1
  98. package/build/esm/lib/Security2/Extension.js +1 -1
  99. package/build/esm/lib/Security2/Extension.js.map +1 -1
  100. package/build/esm/lib/_Types.d.ts +2 -1
  101. package/build/esm/lib/_Types.d.ts.map +1 -1
  102. package/build/esm/lib/_Types.js.map +1 -1
  103. package/build/esm/lib/serializers.d.ts +4 -4
  104. package/build/esm/lib/serializers.d.ts.map +1 -1
  105. package/build/esm/lib/serializers.js.map +1 -1
  106. package/build/esm/lib/traits.d.ts +5 -0
  107. package/build/esm/lib/traits.d.ts.map +1 -1
  108. package/package.json +10 -10
@@ -1,6 +1,6 @@
1
1
  import type { CCEncodingContext, CCParsingContext } from "@zwave-js/cc";
2
2
  import { CommandClasses, type GetValueDB, type MaybeNotKnown, type MessageOrCCLogEntry, type SecurityManager, type WithAddress } from "@zwave-js/core";
3
- import { Bytes } from "@zwave-js/shared";
3
+ import { Bytes, type BytesView } from "@zwave-js/shared";
4
4
  import { PhysicalCCAPI } from "../lib/API.js";
5
5
  import { type CCRaw, CommandClass, type InterviewContext } from "../lib/CommandClass.js";
6
6
  import { SecurityCommand } from "../lib/_Types.js";
@@ -10,7 +10,7 @@ export declare class SecurityCCAPI extends PhysicalCCAPI {
10
10
  /**
11
11
  * Requests a new nonce for Security CC encapsulation which is not directly linked to a specific command.
12
12
  */
13
- getNonce(): Promise<Uint8Array | undefined>;
13
+ getNonce(): Promise<BytesView | undefined>;
14
14
  /**
15
15
  * Responds to a NonceGet request. The message is sent without any retransmission etc.
16
16
  * The return value indicates whether a nonce was successfully sent
@@ -19,7 +19,7 @@ export declare class SecurityCCAPI extends PhysicalCCAPI {
19
19
  getSecurityScheme(): Promise<[0]>;
20
20
  reportSecurityScheme(encapsulated: boolean): Promise<void>;
21
21
  inheritSecurityScheme(): Promise<void>;
22
- setNetworkKey(networkKey: Uint8Array): Promise<void>;
22
+ setNetworkKey(networkKey: BytesView): Promise<void>;
23
23
  verifyNetworkKey(): Promise<void>;
24
24
  getSupportedCommands(): Promise<Pick<SecurityCCCommandsSupportedReport, "supportedCCs" | "controlledCCs"> | undefined>;
25
25
  reportSupportedCommands(supportedCCs: CommandClasses[], controlledCCs: CommandClasses[]): Promise<void>;
@@ -34,23 +34,23 @@ export declare class SecurityCC extends CommandClass {
34
34
  static encapsulate(ownNodeId: number, securityManager: SecurityManager, cc: CommandClass): SecurityCCCommandEncapsulation;
35
35
  }
36
36
  interface SecurityCCNonceReportOptions {
37
- nonce: Uint8Array;
37
+ nonce: BytesView;
38
38
  }
39
39
  export declare class SecurityCCNonceReport extends SecurityCC {
40
40
  constructor(options: WithAddress<SecurityCCNonceReportOptions>);
41
41
  static from(raw: CCRaw, ctx: CCParsingContext): SecurityCCNonceReport;
42
- nonce: Uint8Array;
42
+ nonce: BytesView;
43
43
  serialize(ctx: CCEncodingContext): Promise<Bytes>;
44
44
  toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry;
45
45
  }
46
46
  export declare class SecurityCCNonceGet extends SecurityCC {
47
47
  }
48
48
  export type SecurityCCCommandEncapsulationOptions = {
49
- alternativeNetworkKey?: Uint8Array;
49
+ alternativeNetworkKey?: BytesView;
50
50
  } & ({
51
51
  encapsulated: CommandClass;
52
52
  } | {
53
- decryptedCCBytes: Uint8Array;
53
+ decryptedCCBytes: BytesView;
54
54
  sequenced: boolean;
55
55
  secondFrame: boolean;
56
56
  sequenceCounter: number;
@@ -65,7 +65,7 @@ export declare class SecurityCCCommandEncapsulation extends SecurityCC {
65
65
  encapsulated: CommandClass;
66
66
  private alternativeNetworkKey?;
67
67
  get nonceId(): number | undefined;
68
- nonce: Uint8Array | undefined;
68
+ nonce: BytesView | undefined;
69
69
  private iv?;
70
70
  private authData?;
71
71
  private authCode?;
@@ -97,12 +97,12 @@ export declare class SecurityCCSchemeInherit extends SecurityCC {
97
97
  export declare class SecurityCCNetworkKeyVerify extends SecurityCC {
98
98
  }
99
99
  export interface SecurityCCNetworkKeySetOptions {
100
- networkKey: Uint8Array;
100
+ networkKey: BytesView;
101
101
  }
102
102
  export declare class SecurityCCNetworkKeySet extends SecurityCC {
103
103
  constructor(options: WithAddress<SecurityCCNetworkKeySetOptions>);
104
104
  static from(raw: CCRaw, ctx: CCParsingContext): SecurityCCNetworkKeySet;
105
- networkKey: Uint8Array;
105
+ networkKey: BytesView;
106
106
  serialize(ctx: CCEncodingContext): Promise<Bytes>;
107
107
  toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry;
108
108
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/cc/SecurityCC.ts"],
4
- "sourcesContent": ["import type { CCEncodingContext, CCParsingContext } from \"@zwave-js/cc\";\nimport {\n\tCommandClasses,\n\tEncapsulationFlags,\n\ttype GetValueDB,\n\ttype MaybeNotKnown,\n\ttype MessageOrCCLogEntry,\n\tMessagePriority,\n\ttype MessageRecord,\n\tSecurityClass,\n\ttype SecurityManager,\n\tTransmitOptions,\n\ttype WithAddress,\n\tZWaveError,\n\tZWaveErrorCodes,\n\tcomputeMAC,\n\tdecryptAES128OFB,\n\tencodeCCList,\n\tencryptAES128OFB,\n\tgenerateAuthKey,\n\tgenerateEncryptionKey,\n\tgetCCName,\n\tisTransmissionError,\n\tparseCCList,\n\trandomBytes,\n\tvalidatePayload,\n} from \"@zwave-js/core\";\nimport { Bytes, buffer2hex, num2hex, pick } from \"@zwave-js/shared\";\nimport { wait } from \"alcalzone-shared/async\";\nimport { CCAPI, PhysicalCCAPI } from \"../lib/API.js\";\nimport {\n\ttype CCRaw,\n\tCommandClass,\n\ttype InterviewContext,\n} from \"../lib/CommandClass.js\";\nimport {\n\tAPI,\n\tCCCommand,\n\tcommandClass,\n\texpectedCCResponse,\n\timplementedVersion,\n} from \"../lib/CommandClassDecorators.js\";\nimport { SecurityCommand } from \"../lib/_Types.js\";\nimport { CRC16CC } from \"./CRC16CC.js\";\nimport { Security2CC } from \"./Security2CC.js\";\nimport { TransportServiceCC } from \"./TransportServiceCC.js\";\n\n// @noSetValueAPI This is an encapsulation CC\n\nfunction getAuthenticationData(\n\tsenderNonce: Uint8Array,\n\treceiverNonce: Uint8Array,\n\tccCommand: SecurityCommand,\n\tsendingNodeId: number,\n\treceivingNodeId: number,\n\tencryptedPayload: Uint8Array,\n): Uint8Array {\n\treturn Bytes.concat([\n\t\tsenderNonce,\n\t\treceiverNonce,\n\t\tBytes.from([\n\t\t\tccCommand,\n\t\t\tsendingNodeId,\n\t\t\treceivingNodeId,\n\t\t\tencryptedPayload.length,\n\t\t]),\n\t\tencryptedPayload,\n\t]);\n}\n\nfunction throwNoNonce(reason?: string): never {\n\tlet message = `Security CC requires a nonce to be sent!`;\n\tif (reason) message += ` Reason: ${reason}`;\n\tthrow new ZWaveError(message, ZWaveErrorCodes.SecurityCC_NoNonce);\n}\n\nconst HALF_NONCE_SIZE = 8;\n\nfunction assertSecurityRX(\n\tctx: CCParsingContext,\n): asserts ctx is CCParsingContext & { securityManager: SecurityManager } {\n\tif (!ctx.ownNodeId) {\n\t\tthrow new ZWaveError(\n\t\t\t`Secure commands (S0) can only be decoded when the controller's node id is known!`,\n\t\t\tZWaveErrorCodes.Driver_NotReady,\n\t\t);\n\t}\n\n\tif (!ctx.securityManager) {\n\t\tthrow new ZWaveError(\n\t\t\t`Secure commands (S0) can only be decoded when the security manager is set up!`,\n\t\t\tZWaveErrorCodes.Driver_NoSecurity,\n\t\t);\n\t}\n}\n\nfunction assertSecurityTX(\n\tctx: CCEncodingContext,\n): asserts ctx is CCEncodingContext & { securityManager: SecurityManager } {\n\tif (!ctx.ownNodeId) {\n\t\tthrow new ZWaveError(\n\t\t\t`Secure commands (S0) can only be sent when the controller's node id is known!`,\n\t\t\tZWaveErrorCodes.Driver_NotReady,\n\t\t);\n\t}\n\n\tif (!ctx.securityManager) {\n\t\tthrow new ZWaveError(\n\t\t\t`Secure commands (S0) can only be sent when the security manager is set up!`,\n\t\t\tZWaveErrorCodes.Driver_NoSecurity,\n\t\t);\n\t}\n}\n\n// TODO: Ignore commands if received via multicast\n\n// Encapsulation CCs are used internally and too frequently that we\n// want to pay the cost of validating each call\n/* eslint-disable @zwave-js/ccapi-validate-args */\n\n@API(CommandClasses.Security)\nexport class SecurityCCAPI extends PhysicalCCAPI {\n\tpublic supportsCommand(_cmd: SecurityCommand): MaybeNotKnown<boolean> {\n\t\t// All commands are mandatory\n\t\treturn true;\n\t}\n\n\tpublic async sendEncapsulated(\n\t\tencapsulated: CommandClass,\n\t\trequestNextNonce: boolean = false,\n\t): Promise<void> {\n\t\tif (requestNextNonce) {\n\t\t\tthis.assertSupportsCommand(\n\t\t\t\tSecurityCommand,\n\t\t\t\tSecurityCommand.CommandEncapsulation,\n\t\t\t);\n\t\t} else {\n\t\t\tthis.assertSupportsCommand(\n\t\t\t\tSecurityCommand,\n\t\t\t\tSecurityCommand.CommandEncapsulationNonceGet,\n\t\t\t);\n\t\t}\n\n\t\tconst cc = new (\n\t\t\trequestNextNonce\n\t\t\t\t? SecurityCCCommandEncapsulationNonceGet\n\t\t\t\t: SecurityCCCommandEncapsulation\n\t\t)({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tencapsulated,\n\t\t});\n\t\tawait this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\t/**\n\t * Requests a new nonce for Security CC encapsulation which is not directly linked to a specific command.\n\t */\n\tpublic async getNonce(): Promise<Uint8Array | undefined> {\n\t\tthis.assertSupportsCommand(SecurityCommand, SecurityCommand.NonceGet);\n\n\t\tconst cc = new SecurityCCNonceGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tconst response = await this.host.sendCommand<SecurityCCNonceReport>(\n\t\t\tcc,\n\t\t\t{\n\t\t\t\t...this.commandOptions,\n\t\t\t\t// Only try getting a nonce once\n\t\t\t\tmaxSendAttempts: 1,\n\t\t\t},\n\t\t);\n\t\tif (!response) return;\n\n\t\tconst nonce = response.nonce;\n\t\tconst secMan = this.host.securityManager!;\n\t\tsecMan.setNonce(\n\t\t\t{\n\t\t\t\tissuer: this.endpoint.nodeId,\n\t\t\t\tnonceId: secMan.getNonceId(nonce),\n\t\t\t},\n\t\t\t{ nonce, receiver: this.host.ownNodeId },\n\t\t\t{ free: true },\n\t\t);\n\t\treturn nonce;\n\t}\n\n\t/**\n\t * Responds to a NonceGet request. The message is sent without any retransmission etc.\n\t * The return value indicates whether a nonce was successfully sent\n\t */\n\tpublic async sendNonce(): Promise<boolean> {\n\t\tthis.assertSupportsCommand(\n\t\t\tSecurityCommand,\n\t\t\tSecurityCommand.NonceReport,\n\t\t);\n\n\t\tif (!this.host.securityManager) {\n\t\t\tthrow new ZWaveError(\n\t\t\t\t`Nonces can only be sent if secure communication is set up!`,\n\t\t\t\tZWaveErrorCodes.Driver_NoSecurity,\n\t\t\t);\n\t\t}\n\n\t\tconst nonce = this.host.securityManager.generateNonce(\n\t\t\tthis.endpoint.nodeId,\n\t\t\tHALF_NONCE_SIZE,\n\t\t);\n\t\tconst nonceId = this.host.securityManager.getNonceId(nonce);\n\n\t\tconst cc = new SecurityCCNonceReport({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tnonce,\n\t\t});\n\n\t\ttry {\n\t\t\tawait this.host.sendCommand(cc, {\n\t\t\t\t...this.commandOptions,\n\t\t\t\t// Seems we need these options or some nodes won't accept the nonce\n\t\t\t\ttransmitOptions: TransmitOptions.ACK\n\t\t\t\t\t| TransmitOptions.AutoRoute,\n\t\t\t\t// Only try sending a nonce once\n\t\t\t\tmaxSendAttempts: 1,\n\t\t\t\t// Nonce requests must be handled immediately\n\t\t\t\tpriority: MessagePriority.Immediate,\n\t\t\t\t// We don't want failures causing us to treat the node as asleep or dead\n\t\t\t\tchangeNodeStatusOnMissingACK: false,\n\t\t\t});\n\t\t} catch (e) {\n\t\t\tif (isTransmissionError(e)) {\n\t\t\t\t// The nonce could not be sent, invalidate it\n\t\t\t\tthis.host.securityManager.deleteNonce(nonceId);\n\t\t\t\treturn false;\n\t\t\t} else {\n\t\t\t\t// Pass other errors through\n\t\t\t\tthrow e;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\tpublic async getSecurityScheme(): Promise<[0]> {\n\t\tthis.assertSupportsCommand(SecurityCommand, SecurityCommand.SchemeGet);\n\n\t\tconst cc = new SecurityCCSchemeGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tawait this.host.sendCommand(cc, this.commandOptions);\n\t\t// There is only one scheme, so we hardcode it\n\t\treturn [0];\n\t}\n\n\tpublic async reportSecurityScheme(encapsulated: boolean): Promise<void> {\n\t\tthis.assertSupportsCommand(\n\t\t\tSecurityCommand,\n\t\t\tSecurityCommand.SchemeReport,\n\t\t);\n\n\t\tlet cc: CommandClass = new SecurityCCSchemeReport({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tif (encapsulated) {\n\t\t\tcc = new SecurityCCCommandEncapsulation({\n\t\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\t\tendpointIndex: this.endpoint.index,\n\t\t\t\tencapsulated: cc,\n\t\t\t});\n\t\t}\n\t\tawait this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\tpublic async inheritSecurityScheme(): Promise<void> {\n\t\tthis.assertSupportsCommand(\n\t\t\tSecurityCommand,\n\t\t\tSecurityCommand.SchemeInherit,\n\t\t);\n\n\t\tconst cc = new SecurityCCSchemeInherit({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tawait this.host.sendCommand(cc, this.commandOptions);\n\t\t// There is only one scheme, so we don't return anything here\n\t}\n\n\tpublic async setNetworkKey(networkKey: Uint8Array): Promise<void> {\n\t\tthis.assertSupportsCommand(\n\t\t\tSecurityCommand,\n\t\t\tSecurityCommand.NetworkKeySet,\n\t\t);\n\n\t\tconst keySet = new SecurityCCNetworkKeySet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tnetworkKey,\n\t\t});\n\t\tconst cc = new SecurityCCCommandEncapsulation({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tencapsulated: keySet,\n\t\t\talternativeNetworkKey: new Uint8Array(16).fill(0),\n\t\t});\n\t\tawait this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\tpublic async verifyNetworkKey(): Promise<void> {\n\t\tthis.assertSupportsCommand(\n\t\t\tSecurityCommand,\n\t\t\tSecurityCommand.NetworkKeyVerify,\n\t\t);\n\n\t\tconst cc = new SecurityCCNetworkKeyVerify({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tawait this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n\tpublic async getSupportedCommands() {\n\t\tthis.assertSupportsCommand(\n\t\t\tSecurityCommand,\n\t\t\tSecurityCommand.CommandsSupportedGet,\n\t\t);\n\n\t\tconst cc = new SecurityCCCommandsSupportedGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tconst response = await this.host.sendCommand<\n\t\t\tSecurityCCCommandsSupportedReport\n\t\t>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\tif (response) {\n\t\t\treturn pick(response, [\"supportedCCs\", \"controlledCCs\"]);\n\t\t}\n\t}\n\n\tpublic async reportSupportedCommands(\n\t\tsupportedCCs: CommandClasses[],\n\t\tcontrolledCCs: CommandClasses[],\n\t): Promise<void> {\n\t\tthis.assertSupportsCommand(\n\t\t\tSecurityCommand,\n\t\t\tSecurityCommand.CommandsSupportedReport,\n\t\t);\n\n\t\tconst cc = new SecurityCCCommandsSupportedReport({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tsupportedCCs,\n\t\t\tcontrolledCCs,\n\t\t\treportsToFollow: 0,\n\t\t});\n\t\tawait this.host.sendCommand(cc, this.commandOptions);\n\t}\n}\n\n@commandClass(CommandClasses.Security)\n@implementedVersion(1)\nexport class SecurityCC extends CommandClass {\n\tdeclare ccCommand: SecurityCommand;\n\t// Force singlecast for the Security CC\n\tdeclare nodeId: number;\n\n\tpublic async interview(\n\t\tctx: InterviewContext,\n\t): Promise<void> {\n\t\tconst node = this.getNode(ctx)!;\n\t\tconst endpoint = this.getEndpoint(ctx)!;\n\t\tconst api = CCAPI.create(\n\t\t\tCommandClasses.Security,\n\t\t\tctx,\n\t\t\tendpoint,\n\t\t).withOptions({\n\t\t\tpriority: MessagePriority.NodeQuery,\n\t\t});\n\n\t\tctx.logNode(node.id, {\n\t\t\tmessage: \"Querying securely supported commands (S0)...\",\n\t\t\tdirection: \"outbound\",\n\t\t});\n\n\t\tlet supportedCCs: CommandClasses[] | undefined;\n\t\tlet controlledCCs: CommandClasses[] | undefined;\n\n\t\t// Try up to 3 times on the root device. We REALLY don't want a spurious timeout or collision to cause us to discard a known good security class\n\t\tconst MAX_ATTEMPTS = this.endpointIndex === 0 ? 3 : 1;\n\t\tfor (let attempts = 1; attempts <= MAX_ATTEMPTS; attempts++) {\n\t\t\tconst resp = await api.getSupportedCommands();\n\t\t\tif (resp) {\n\t\t\t\tsupportedCCs = resp.supportedCCs;\n\t\t\t\tcontrolledCCs = resp.controlledCCs;\n\t\t\t\tbreak;\n\t\t\t} else if (attempts < MAX_ATTEMPTS) {\n\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\t\tmessage:\n\t\t\t\t\t\t`Querying securely supported commands (S0), attempt ${attempts}/${MAX_ATTEMPTS} failed. Retrying in 500ms...`,\n\t\t\t\t\tlevel: \"warn\",\n\t\t\t\t});\n\t\t\t\tawait wait(500);\n\t\t\t}\n\t\t}\n\n\t\tif (!supportedCCs || !controlledCCs) {\n\t\t\tif (node.hasSecurityClass(SecurityClass.S0_Legacy) === true) {\n\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\t\tmessage: \"Querying securely supported commands (S0) failed\",\n\t\t\t\t\tlevel: \"warn\",\n\t\t\t\t});\n\t\t\t\t// TODO: Abort interview?\n\t\t\t} else {\n\t\t\t\t// We didn't know if the node was secure and it didn't respond,\n\t\t\t\t// assume that it doesn't have the S0 security class\n\t\t\t\tctx.logNode(\n\t\t\t\t\tnode.id,\n\t\t\t\t\t`The node was not granted the S0 security class. Continuing interview non-securely.`,\n\t\t\t\t);\n\t\t\t\tnode.setSecurityClass(SecurityClass.S0_Legacy, false);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tconst logLines: string[] = [\n\t\t\t\"received secure commands (S0)\",\n\t\t\t\"supported CCs:\",\n\t\t];\n\t\tfor (const cc of supportedCCs) {\n\t\t\tlogLines.push(`\u00B7 ${getCCName(cc)}`);\n\t\t}\n\t\tlogLines.push(\"controlled CCs:\");\n\t\tfor (const cc of controlledCCs) {\n\t\t\tlogLines.push(`\u00B7 ${getCCName(cc)}`);\n\t\t}\n\t\tctx.logNode(node.id, {\n\t\t\tmessage: logLines.join(\"\\n\"),\n\t\t\tdirection: \"inbound\",\n\t\t});\n\n\t\t// Remember which commands are supported securely\n\t\tfor (const cc of supportedCCs) {\n\t\t\t// Basic CC has special rules for when it is considered supported\n\t\t\t// Therefore we mark all other CCs as supported, but not Basic CC,\n\t\t\t// for which support is determined later.\n\t\t\tif (cc === CommandClasses.Basic) {\n\t\t\t\tendpoint.addCC(cc, { secure: true });\n\t\t\t} else {\n\t\t\t\tendpoint.addCC(cc, {\n\t\t\t\t\tisSupported: true,\n\t\t\t\t\tsecure: true,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\tfor (const cc of controlledCCs) {\n\t\t\t// Basic CC has special rules for when it is considered supported\n\t\t\t// Therefore we mark all other CCs as supported, but not Basic CC,\n\t\t\t// for which support is determined later.\n\t\t\tif (cc === CommandClasses.Basic) {\n\t\t\t\tendpoint.addCC(cc, { secure: true });\n\t\t\t} else {\n\t\t\t\tendpoint.addCC(cc, {\n\t\t\t\t\tisControlled: true,\n\t\t\t\t\tsecure: true,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t// We know for sure that the node is included securely\n\t\tif (node.hasSecurityClass(SecurityClass.S0_Legacy) !== true) {\n\t\t\tnode.setSecurityClass(SecurityClass.S0_Legacy, true);\n\t\t\tctx.logNode(\n\t\t\t\tnode.id,\n\t\t\t\t`The node was granted the S0 security class`,\n\t\t\t);\n\t\t}\n\n\t\t// Remember that the interview is complete\n\t\tthis.setInterviewComplete(ctx, true);\n\t}\n\n\t/** Tests if a command should be sent secure and thus requires encapsulation */\n\tpublic static requiresEncapsulation(cc: CommandClass): boolean {\n\t\t// No security flag -> no encapsulation\n\t\tif (!(cc.encapsulationFlags & EncapsulationFlags.Security)) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// S2, CRC16, Transport Service -> no S2 encapsulation\n\t\tif (\n\t\t\tcc instanceof Security2CC\n\t\t\t|| cc instanceof CRC16CC\n\t\t\t|| cc instanceof TransportServiceCC\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// S0: check command\n\t\tif (cc instanceof SecurityCC) {\n\t\t\tswitch (cc.ccCommand) {\n\t\t\t\t// Already encapsulated\n\t\t\t\tcase SecurityCommand.CommandEncapsulation:\n\t\t\t\tcase SecurityCommand.CommandEncapsulationNonceGet:\n\t\t\t\t// Cannot be sent encapsulated:\n\t\t\t\tcase SecurityCommand.NonceGet:\n\t\t\t\tcase SecurityCommand.NonceReport:\n\t\t\t\tcase SecurityCommand.SchemeGet:\n\t\t\t\tcase SecurityCommand.SchemeReport:\n\t\t\t\t\treturn false;\n\n\t\t\t\tdefault:\n\t\t\t\t\t// All other commands must be encapsulated\n\t\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\t// Everything else needs to be encapsulated if the CC is secure\n\t\treturn true;\n\t}\n\n\t/** Encapsulates a command that should be sent encrypted */\n\tpublic static encapsulate(\n\t\townNodeId: number,\n\t\tsecurityManager: SecurityManager,\n\t\tcc: CommandClass,\n\t): SecurityCCCommandEncapsulation {\n\t\t// TODO: When to return a SecurityCCCommandEncapsulationNonceGet?\n\t\tconst ret = new SecurityCCCommandEncapsulation({\n\t\t\tnodeId: cc.nodeId,\n\t\t\tencapsulated: cc,\n\t\t});\n\n\t\t// Copy the encapsulation flags from the encapsulated command\n\t\t// but omit Security, since we're doing that right now\n\t\tret.encapsulationFlags = cc.encapsulationFlags\n\t\t\t& ~EncapsulationFlags.Security;\n\n\t\treturn ret;\n\t}\n}\n\ninterface SecurityCCNonceReportOptions {\n\tnonce: Uint8Array;\n}\n\n@CCCommand(SecurityCommand.NonceReport)\nexport class SecurityCCNonceReport extends SecurityCC {\n\tconstructor(\n\t\toptions: WithAddress<SecurityCCNonceReportOptions>,\n\t) {\n\t\tsuper(options);\n\t\tif (options.nonce.length !== HALF_NONCE_SIZE) {\n\t\t\tthrow new ZWaveError(\n\t\t\t\t`Nonce must have length ${HALF_NONCE_SIZE}!`,\n\t\t\t\tZWaveErrorCodes.Argument_Invalid,\n\t\t\t);\n\t\t}\n\t\tthis.nonce = options.nonce;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): SecurityCCNonceReport {\n\t\tvalidatePayload.withReason(\"Invalid nonce length\")(\n\t\t\traw.payload.length === HALF_NONCE_SIZE,\n\t\t);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tnonce: raw.payload,\n\t\t});\n\t}\n\n\tpublic nonce: Uint8Array;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.view(this.nonce);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: { nonce: buffer2hex(this.nonce) },\n\t\t};\n\t}\n}\n\n@CCCommand(SecurityCommand.NonceGet)\n@expectedCCResponse(SecurityCCNonceReport)\nexport class SecurityCCNonceGet extends SecurityCC {}\n\n// @publicAPI\nexport type SecurityCCCommandEncapsulationOptions =\n\t& {\n\t\talternativeNetworkKey?: Uint8Array;\n\t}\n\t& ({\n\t\tencapsulated: CommandClass;\n\t} | {\n\t\tdecryptedCCBytes: Uint8Array;\n\t\tsequenced: boolean;\n\t\tsecondFrame: boolean;\n\t\tsequenceCounter: number;\n\t});\n\nfunction getCCResponseForCommandEncapsulation(\n\tsent: SecurityCCCommandEncapsulation,\n) {\n\tif (sent.encapsulated.expectsCCResponse()) {\n\t\treturn SecurityCCCommandEncapsulation;\n\t}\n}\n\n@CCCommand(SecurityCommand.CommandEncapsulation)\n@expectedCCResponse(\n\tgetCCResponseForCommandEncapsulation,\n\t() => \"checkEncapsulated\",\n)\nexport class SecurityCCCommandEncapsulation extends SecurityCC {\n\tpublic constructor(\n\t\toptions: WithAddress<SecurityCCCommandEncapsulationOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\tif (\"encapsulated\" in options) {\n\t\t\tthis.encapsulated = options.encapsulated;\n\t\t\tthis.encapsulated.encapsulatingCC = this as any;\n\t\t} else {\n\t\t\tthis.decryptedCCBytes = options.decryptedCCBytes;\n\t\t\tthis.sequenced = options.sequenced;\n\t\t\tthis.secondFrame = options.secondFrame;\n\t\t\tthis.sequenceCounter = options.sequenceCounter;\n\t\t}\n\t\tthis.alternativeNetworkKey = options.alternativeNetworkKey;\n\t}\n\n\tpublic static async from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): Promise<SecurityCCCommandEncapsulation> {\n\t\tassertSecurityRX(ctx);\n\n\t\t// HALF_NONCE_SIZE bytes iv, 1 byte frame control, at least 1 CC byte, 1 byte nonce id, 8 bytes auth code\n\t\tvalidatePayload(\n\t\t\traw.payload.length >= HALF_NONCE_SIZE + 1 + 1 + 1 + 8,\n\t\t);\n\t\tconst iv = raw.payload.subarray(0, HALF_NONCE_SIZE);\n\t\tconst encryptedPayload = raw.payload.subarray(HALF_NONCE_SIZE, -9);\n\t\tconst nonceId = raw.payload.at(-9)!;\n\t\tconst authCode = raw.payload.subarray(-8);\n\n\t\t// Retrieve the used nonce from the nonce store\n\t\tconst nonce = ctx.securityManager.getNonce(nonceId);\n\t\t// Only accept the message if the nonce hasn't expired\n\t\tif (!nonce) {\n\t\t\tvalidatePayload.fail(\n\t\t\t\t`Nonce ${\n\t\t\t\t\tnum2hex(\n\t\t\t\t\t\tnonceId,\n\t\t\t\t\t)\n\t\t\t\t} expired, cannot decode security encapsulated command.`,\n\t\t\t);\n\t\t}\n\t\t// and mark the nonce as used\n\t\tctx.securityManager.deleteNonce(nonceId);\n\n\t\t// Validate the encrypted data\n\t\tconst authData = getAuthenticationData(\n\t\t\tiv,\n\t\t\tnonce,\n\t\t\tSecurityCommand.CommandEncapsulation,\n\t\t\tctx.sourceNodeId,\n\t\t\tctx.ownNodeId,\n\t\t\tencryptedPayload,\n\t\t);\n\t\tconst expectedAuthCode = await computeMAC(\n\t\t\tauthData,\n\t\t\tawait ctx.securityManager.getAuthKey(),\n\t\t);\n\t\t// Only accept messages with a correct auth code\n\t\tvalidatePayload.withReason(\n\t\t\t\"Invalid auth code, won't accept security encapsulated command.\",\n\t\t)(authCode.equals(expectedAuthCode));\n\n\t\t// Decrypt the encapsulated CC\n\t\tconst frameControlAndDecryptedCC = await decryptAES128OFB(\n\t\t\tencryptedPayload,\n\t\t\tawait ctx.securityManager.getEncryptionKey(),\n\t\t\tBytes.concat([iv, nonce]),\n\t\t);\n\t\tconst frameControl = frameControlAndDecryptedCC[0];\n\t\tconst sequenceCounter = frameControl & 0b1111;\n\t\tconst sequenced = !!(frameControl & 0b1_0000);\n\t\tconst secondFrame = !!(frameControl & 0b10_0000);\n\t\tconst decryptedCCBytes: Uint8Array | undefined =\n\t\t\tframeControlAndDecryptedCC\n\t\t\t\t.subarray(1);\n\n\t\tconst ret = new SecurityCCCommandEncapsulation({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tsequenceCounter,\n\t\t\tsequenced,\n\t\t\tsecondFrame,\n\t\t\tdecryptedCCBytes,\n\t\t});\n\n\t\tret.authData = authData;\n\t\tret.authCode = authCode;\n\t\tret.iv = iv;\n\n\t\treturn ret;\n\t}\n\n\tprivate sequenced: boolean | undefined;\n\tprivate secondFrame: boolean | undefined;\n\tprivate sequenceCounter: number | undefined;\n\n\tprivate decryptedCCBytes: Uint8Array | undefined;\n\tpublic encapsulated!: CommandClass;\n\n\tprivate alternativeNetworkKey?: Uint8Array;\n\n\tpublic get nonceId(): number | undefined {\n\t\treturn this.nonce?.[0];\n\t}\n\tpublic nonce: Uint8Array | undefined;\n\n\t// Only used testing/for debugging purposes\n\tprivate iv?: Uint8Array;\n\tprivate authData?: Uint8Array;\n\tprivate authCode?: Uint8Array;\n\tprivate ciphertext?: Uint8Array;\n\n\tpublic getPartialCCSessionId(): Record<string, any> | undefined {\n\t\tif (this.sequenced) {\n\t\t\treturn {\n\t\t\t\t// Treat Encapsulation and EncapsulationNonceGet as one\n\t\t\t\tccCommand: undefined,\n\t\t\t\tsequence: this.sequenceCounter,\n\t\t\t};\n\t\t} else {\n\t\t\treturn {\n\t\t\t\t// Treat Encapsulation and EncapsulationNonceGet as one\n\t\t\t\tccCommand: undefined,\n\t\t\t};\n\t\t}\n\t}\n\n\tpublic expectMoreMessages(): boolean {\n\t\treturn !!this.sequenced && !this.secondFrame;\n\t}\n\n\tpublic async mergePartialCCs(\n\t\tpartials: SecurityCCCommandEncapsulation[],\n\t\tctx: CCParsingContext,\n\t): Promise<void> {\n\t\t// Concat the CC buffers\n\t\tthis.decryptedCCBytes = Bytes.concat(\n\t\t\t[...partials, this].map((cc) => cc.decryptedCCBytes!),\n\t\t);\n\t\t// make sure this contains a complete CC command that's worth splitting\n\t\tvalidatePayload(this.decryptedCCBytes.length >= 2);\n\t\t// and deserialize the CC\n\t\tthis.encapsulated = await CommandClass.parse(\n\t\t\tthis.decryptedCCBytes,\n\t\t\tctx,\n\t\t);\n\t\tthis.encapsulated.encapsulatingCC = this as any;\n\t}\n\n\tpublic async serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tif (!this.nonce) throwNoNonce();\n\t\tif (this.nonce.length !== HALF_NONCE_SIZE) {\n\t\t\tthrowNoNonce(\"Invalid nonce size\");\n\t\t}\n\t\tassertSecurityTX(ctx);\n\n\t\tlet authKey: Uint8Array;\n\t\tlet encryptionKey: Uint8Array;\n\t\tif (this.alternativeNetworkKey) {\n\t\t\tauthKey = await generateAuthKey(this.alternativeNetworkKey);\n\t\t\tencryptionKey = await generateEncryptionKey(\n\t\t\t\tthis.alternativeNetworkKey,\n\t\t\t);\n\t\t} else {\n\t\t\tauthKey = await ctx.securityManager.getAuthKey();\n\t\t\tencryptionKey = await ctx.securityManager.getEncryptionKey();\n\t\t}\n\n\t\tconst serializedCC = await this.encapsulated.serialize(ctx);\n\t\tconst plaintext = Bytes.concat([\n\t\t\tBytes.from([0]), // TODO: frame control\n\t\t\tserializedCC,\n\t\t]);\n\t\t// Encrypt the payload\n\t\tconst senderNonce = randomBytes(HALF_NONCE_SIZE);\n\t\tconst iv = Bytes.concat([senderNonce, this.nonce]);\n\t\tconst ciphertext = await encryptAES128OFB(\n\t\t\tplaintext,\n\t\t\tencryptionKey,\n\t\t\tiv,\n\t\t);\n\t\t// And generate the auth code\n\t\tconst authData = getAuthenticationData(\n\t\t\tsenderNonce,\n\t\t\tthis.nonce,\n\t\t\tthis.ccCommand,\n\t\t\tctx.ownNodeId,\n\t\t\tthis.nodeId,\n\t\t\tciphertext,\n\t\t);\n\t\tconst authCode = await computeMAC(authData, authKey);\n\n\t\t// Remember for debugging purposes\n\t\tthis.iv = iv;\n\t\tthis.authData = authData;\n\t\tthis.authCode = authCode;\n\t\tthis.ciphertext = ciphertext;\n\n\t\tthis.payload = Bytes.concat([\n\t\t\tsenderNonce,\n\t\t\tciphertext,\n\t\t\tBytes.from([this.nonceId!]),\n\t\t\tauthCode,\n\t\t]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tprotected computeEncapsulationOverhead(): number {\n\t\t// Security CC adds 8 bytes IV, 1 byte frame control, 1 byte nonce ID, 8 bytes MAC\n\t\treturn super.computeEncapsulationOverhead() + 18;\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\tconst message: MessageRecord = {};\n\t\tif (this.nonceId != undefined) {\n\t\t\tmessage[\"nonce id\"] = this.nonceId;\n\t\t}\n\t\tif (this.sequenced != undefined) {\n\t\t\tmessage.sequenced = this.sequenced;\n\t\t\tif (this.sequenced) {\n\t\t\t\tif (this.secondFrame != undefined) {\n\t\t\t\t\tmessage[\"second frame\"] = this.secondFrame;\n\t\t\t\t}\n\t\t\t\tif (this.sequenceCounter != undefined) {\n\t\t\t\t\tmessage[\"sequence counter\"] = this.sequenceCounter;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Log the plaintext in integration tests and development mode\n\t\tif (\n\t\t\tprocess.env.NODE_ENV === \"test\"\n\t\t\t|| process.env.NODE_ENV === \"development\"\n\t\t) {\n\t\t\tif (this.iv) {\n\t\t\t\tmessage.IV = buffer2hex(this.iv);\n\t\t\t}\n\t\t\tif (this.ciphertext) {\n\t\t\t\tmessage.ciphertext = buffer2hex(this.ciphertext);\n\t\t\t} else if (this.decryptedCCBytes) {\n\t\t\t\tmessage.plaintext = buffer2hex(this.decryptedCCBytes);\n\t\t\t}\n\t\t\tif (this.authData) {\n\t\t\t\tmessage[\"auth data\"] = buffer2hex(this.authData);\n\t\t\t}\n\t\t\tif (this.authCode) {\n\t\t\t\tmessage[\"auth code\"] = buffer2hex(this.authCode);\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage,\n\t\t};\n\t}\n}\n\n// This is the same message, but with another CC command\n@CCCommand(SecurityCommand.CommandEncapsulationNonceGet)\nexport class SecurityCCCommandEncapsulationNonceGet\n\textends SecurityCCCommandEncapsulation\n{}\n\n@CCCommand(SecurityCommand.SchemeReport)\nexport class SecurityCCSchemeReport extends SecurityCC {\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): SecurityCCSchemeReport {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\t// The including controller MUST NOT perform any validation of the Supported Security Schemes byte\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t});\n\t}\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\t// Since it is unlikely that any more schemes will be added to S0, we hardcode the default scheme here (bit 0 = 0)\n\t\tthis.payload = Bytes.from([0]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\t// Hide the default payload line\n\t\t\tmessage: undefined,\n\t\t};\n\t}\n}\n\n@CCCommand(SecurityCommand.SchemeGet)\n@expectedCCResponse(SecurityCCSchemeReport)\nexport class SecurityCCSchemeGet extends SecurityCC {\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): SecurityCCSchemeGet {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\t// The joining node MUST NOT perform any validation of the Supported Security Schemes byte\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t});\n\t}\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\t// Since it is unlikely that any more schemes will be added to S0, we hardcode the default scheme here (bit 0 = 0)\n\t\tthis.payload = Bytes.from([0]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\t// Hide the default payload line\n\t\t\tmessage: undefined,\n\t\t};\n\t}\n}\n\n@CCCommand(SecurityCommand.SchemeInherit)\n@expectedCCResponse(SecurityCCSchemeReport)\nexport class SecurityCCSchemeInherit extends SecurityCC {\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): SecurityCCSchemeInherit {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\t// The joining node MUST NOT perform any validation of the Supported Security Schemes byte\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t});\n\t}\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\t// Since it is unlikely that any more schemes will be added to S0, we hardcode the default scheme here (bit 0 = 0)\n\t\tthis.payload = Bytes.from([0]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\t// Hide the default payload line\n\t\t\tmessage: undefined,\n\t\t};\n\t}\n}\n\n@CCCommand(SecurityCommand.NetworkKeyVerify)\nexport class SecurityCCNetworkKeyVerify extends SecurityCC {}\n\n// @publicAPI\nexport interface SecurityCCNetworkKeySetOptions {\n\tnetworkKey: Uint8Array;\n}\n\n@CCCommand(SecurityCommand.NetworkKeySet)\n@expectedCCResponse(SecurityCCNetworkKeyVerify)\nexport class SecurityCCNetworkKeySet extends SecurityCC {\n\tpublic constructor(\n\t\toptions: WithAddress<SecurityCCNetworkKeySetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tif (options.networkKey.length !== 16) {\n\t\t\tthrow new ZWaveError(\n\t\t\t\t`The network key must have length 16!`,\n\t\t\t\tZWaveErrorCodes.Argument_Invalid,\n\t\t\t);\n\t\t}\n\t\tthis.networkKey = options.networkKey;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): SecurityCCNetworkKeySet {\n\t\tvalidatePayload(raw.payload.length >= 16);\n\t\tconst networkKey: Uint8Array = raw.payload.subarray(0, 16);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tnetworkKey,\n\t\t});\n\t}\n\n\tpublic networkKey: Uint8Array;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.view(this.networkKey);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\t// The network key shouldn't be logged, so users can safely post their logs online\n\t\tconst { message, ...log } = super.toLogEntry(ctx);\n\t\treturn log;\n\t}\n}\n\n// @publicAPI\nexport interface SecurityCCCommandsSupportedReportOptions {\n\treportsToFollow?: number;\n\tsupportedCCs: CommandClasses[];\n\tcontrolledCCs: CommandClasses[];\n}\n\n@CCCommand(SecurityCommand.CommandsSupportedReport)\nexport class SecurityCCCommandsSupportedReport extends SecurityCC {\n\tpublic constructor(\n\t\toptions: WithAddress<SecurityCCCommandsSupportedReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\tthis.supportedCCs = options.supportedCCs;\n\t\tthis.controlledCCs = options.controlledCCs;\n\t\t// TODO: properly split the CCs into multiple reports\n\t\tthis.reportsToFollow = options.reportsToFollow ?? 0;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): SecurityCCCommandsSupportedReport {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst reportsToFollow = raw.payload[0];\n\t\tconst list = parseCCList(raw.payload.subarray(1));\n\t\tconst supportedCCs: CommandClasses[] = list.supportedCCs;\n\t\tconst controlledCCs: CommandClasses[] = list.controlledCCs;\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\treportsToFollow,\n\t\t\tsupportedCCs,\n\t\t\tcontrolledCCs,\n\t\t});\n\t}\n\n\tpublic reportsToFollow: number;\n\tpublic supportedCCs: CommandClasses[];\n\tpublic controlledCCs: CommandClasses[];\n\n\tpublic getPartialCCSessionId(): Record<string, any> | undefined {\n\t\t// Nothing special we can distinguish sessions with\n\t\treturn {};\n\t}\n\n\tpublic expectMoreMessages(): boolean {\n\t\treturn this.reportsToFollow > 0;\n\t}\n\n\tpublic mergePartialCCs(\n\t\tpartials: SecurityCCCommandsSupportedReport[],\n\t): Promise<void> {\n\t\t// Concat the lists of CCs\n\t\tthis.supportedCCs = [...partials, this]\n\t\t\t.map((report) => report.supportedCCs)\n\t\t\t.reduce((prev, cur) => prev.concat(...cur), []);\n\t\tthis.controlledCCs = [...partials, this]\n\t\t\t.map((report) => report.controlledCCs)\n\t\t\t.reduce((prev, cur) => prev.concat(...cur), []);\n\t\treturn Promise.resolve();\n\t}\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.concat([\n\t\t\tBytes.from([this.reportsToFollow]),\n\t\t\tencodeCCList(this.supportedCCs, this.controlledCCs),\n\t\t]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: {\n\t\t\t\treportsToFollow: this.reportsToFollow,\n\t\t\t\tsupportedCCs: this.supportedCCs\n\t\t\t\t\t.map((cc) => getCCName(cc))\n\t\t\t\t\t.map((cc) => `\\n\u00B7 ${cc}`)\n\t\t\t\t\t.join(\"\"),\n\t\t\t\tcontrolledCCs: this.controlledCCs\n\t\t\t\t\t.map((cc) => getCCName(cc))\n\t\t\t\t\t.map((cc) => `\\n\u00B7 ${cc}`)\n\t\t\t\t\t.join(\"\"),\n\t\t\t},\n\t\t};\n\t}\n}\n\n@CCCommand(SecurityCommand.CommandsSupportedGet)\n@expectedCCResponse(SecurityCCCommandsSupportedReport)\nexport class SecurityCCCommandsSupportedGet extends SecurityCC {}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,kBAyBO;AACP,oBAAiD;AACjD,mBAAqB;AACrB,iBAAqC;AACrC,0BAIO;AACP,oCAMO;AACP,mBAAgC;AAChC,qBAAwB;AACxB,yBAA4B;AAC5B,gCAAmC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAInC,SAAS,sBACR,aACA,eACA,WACA,eACA,iBACA,kBAA4B;AAE5B,SAAO,oBAAM,OAAO;IACnB;IACA;IACA,oBAAM,KAAK;MACV;MACA;MACA;MACA,iBAAiB;KACjB;IACD;GACA;AACF;AAnBS;AAqBT,SAAS,aAAa,QAAe;AACpC,MAAI,UAAU;AACd,MAAI;AAAQ,eAAW,YAAY,MAAM;AACzC,QAAM,IAAI,uBAAW,SAAS,4BAAgB,kBAAkB;AACjE;AAJS;AAMT,MAAM,kBAAkB;AAExB,SAAS,iBACR,KAAqB;AAErB,MAAI,CAAC,IAAI,WAAW;AACnB,UAAM,IAAI,uBACT,oFACA,4BAAgB,eAAe;EAEjC;AAEA,MAAI,CAAC,IAAI,iBAAiB;AACzB,UAAM,IAAI,uBACT,iFACA,4BAAgB,iBAAiB;EAEnC;AACD;AAhBS;AAkBT,SAAS,iBACR,KAAsB;AAEtB,MAAI,CAAC,IAAI,WAAW;AACnB,UAAM,IAAI,uBACT,iFACA,4BAAgB,eAAe;EAEjC;AAEA,MAAI,CAAC,IAAI,iBAAiB;AACzB,UAAM,IAAI,uBACT,8EACA,4BAAgB,iBAAiB;EAEnC;AACD;AAhBS;IAyBI,iBAAa,MAAA;8BADzB,mCAAI,2BAAe,QAAQ,CAAC;;;;oBACM;qCAAA,YAAa;WAAA;;;;;;;;AAAhD,mBAAA,MAAA,mBAAA,EAAA,OAAA,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I,CAAC,WAAO,uBAAU,EAAE,CAAC,EACzB,IAAI,CAAC,OAAO;OAAO,EAAE,EAAE,EACvB,KAAK,EAAE;;;IAGZ;;;;IAKY,kCAA8B,MAAA;8BAF1C,yCAAU,6BAAgB,oBAAoB,OAC9C,kDAAmB,iCAAiC,CAAC;;;;oBACF;sDAAA,YAAU;WAAA;;;;;;;;AAA9D,mBAAA,MAAA,mBAAA,EAAA,OAAA,WAAA,GAAA,kBAAA,EAAA,MAAA,SAAA,MAAA,WAAA,MAAA,UAAA,UAAA,GAAA,MAAA,uBAAA;;;AAAa,wBAAA,YAAA,uBAAA;;;;;",
4
+ "sourcesContent": ["import type { CCEncodingContext, CCParsingContext } from \"@zwave-js/cc\";\nimport {\n\tCommandClasses,\n\tEncapsulationFlags,\n\ttype GetValueDB,\n\ttype MaybeNotKnown,\n\ttype MessageOrCCLogEntry,\n\tMessagePriority,\n\ttype MessageRecord,\n\tSecurityClass,\n\ttype SecurityManager,\n\tTransmitOptions,\n\ttype WithAddress,\n\tZWaveError,\n\tZWaveErrorCodes,\n\tcomputeMAC,\n\tdecryptAES128OFB,\n\tencodeCCList,\n\tencryptAES128OFB,\n\tgenerateAuthKey,\n\tgenerateEncryptionKey,\n\tgetCCName,\n\tisTransmissionError,\n\tparseCCList,\n\trandomBytes,\n\tvalidatePayload,\n} from \"@zwave-js/core\";\nimport {\n\tBytes,\n\ttype BytesView,\n\tbuffer2hex,\n\tnum2hex,\n\tpick,\n} from \"@zwave-js/shared\";\nimport { wait } from \"alcalzone-shared/async\";\nimport { CCAPI, PhysicalCCAPI } from \"../lib/API.js\";\nimport {\n\ttype CCRaw,\n\tCommandClass,\n\ttype InterviewContext,\n} from \"../lib/CommandClass.js\";\nimport {\n\tAPI,\n\tCCCommand,\n\tcommandClass,\n\texpectedCCResponse,\n\timplementedVersion,\n} from \"../lib/CommandClassDecorators.js\";\nimport { SecurityCommand } from \"../lib/_Types.js\";\nimport { CRC16CC } from \"./CRC16CC.js\";\nimport { Security2CC } from \"./Security2CC.js\";\nimport { TransportServiceCC } from \"./TransportServiceCC.js\";\n\n// @noSetValueAPI This is an encapsulation CC\n\nfunction getAuthenticationData(\n\tsenderNonce: BytesView,\n\treceiverNonce: BytesView,\n\tccCommand: SecurityCommand,\n\tsendingNodeId: number,\n\treceivingNodeId: number,\n\tencryptedPayload: BytesView,\n): BytesView {\n\treturn Bytes.concat([\n\t\tsenderNonce,\n\t\treceiverNonce,\n\t\tBytes.from([\n\t\t\tccCommand,\n\t\t\tsendingNodeId,\n\t\t\treceivingNodeId,\n\t\t\tencryptedPayload.length,\n\t\t]),\n\t\tencryptedPayload,\n\t]);\n}\n\nfunction throwNoNonce(reason?: string): never {\n\tlet message = `Security CC requires a nonce to be sent!`;\n\tif (reason) message += ` Reason: ${reason}`;\n\tthrow new ZWaveError(message, ZWaveErrorCodes.SecurityCC_NoNonce);\n}\n\nconst HALF_NONCE_SIZE = 8;\n\nfunction assertSecurityRX(\n\tctx: CCParsingContext,\n): asserts ctx is CCParsingContext & { securityManager: SecurityManager } {\n\tif (!ctx.ownNodeId) {\n\t\tthrow new ZWaveError(\n\t\t\t`Secure commands (S0) can only be decoded when the controller's node id is known!`,\n\t\t\tZWaveErrorCodes.Driver_NotReady,\n\t\t);\n\t}\n\n\tif (!ctx.securityManager) {\n\t\tthrow new ZWaveError(\n\t\t\t`Secure commands (S0) can only be decoded when the security manager is set up!`,\n\t\t\tZWaveErrorCodes.Driver_NoSecurity,\n\t\t);\n\t}\n}\n\nfunction assertSecurityTX(\n\tctx: CCEncodingContext,\n): asserts ctx is CCEncodingContext & { securityManager: SecurityManager } {\n\tif (!ctx.ownNodeId) {\n\t\tthrow new ZWaveError(\n\t\t\t`Secure commands (S0) can only be sent when the controller's node id is known!`,\n\t\t\tZWaveErrorCodes.Driver_NotReady,\n\t\t);\n\t}\n\n\tif (!ctx.securityManager) {\n\t\tthrow new ZWaveError(\n\t\t\t`Secure commands (S0) can only be sent when the security manager is set up!`,\n\t\t\tZWaveErrorCodes.Driver_NoSecurity,\n\t\t);\n\t}\n}\n\n// TODO: Ignore commands if received via multicast\n\n// Encapsulation CCs are used internally and too frequently that we\n// want to pay the cost of validating each call\n/* eslint-disable @zwave-js/ccapi-validate-args */\n\n@API(CommandClasses.Security)\nexport class SecurityCCAPI extends PhysicalCCAPI {\n\tpublic supportsCommand(_cmd: SecurityCommand): MaybeNotKnown<boolean> {\n\t\t// All commands are mandatory\n\t\treturn true;\n\t}\n\n\tpublic async sendEncapsulated(\n\t\tencapsulated: CommandClass,\n\t\trequestNextNonce: boolean = false,\n\t): Promise<void> {\n\t\tif (requestNextNonce) {\n\t\t\tthis.assertSupportsCommand(\n\t\t\t\tSecurityCommand,\n\t\t\t\tSecurityCommand.CommandEncapsulation,\n\t\t\t);\n\t\t} else {\n\t\t\tthis.assertSupportsCommand(\n\t\t\t\tSecurityCommand,\n\t\t\t\tSecurityCommand.CommandEncapsulationNonceGet,\n\t\t\t);\n\t\t}\n\n\t\tconst cc = new (\n\t\t\trequestNextNonce\n\t\t\t\t? SecurityCCCommandEncapsulationNonceGet\n\t\t\t\t: SecurityCCCommandEncapsulation\n\t\t)({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tencapsulated,\n\t\t});\n\t\tawait this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\t/**\n\t * Requests a new nonce for Security CC encapsulation which is not directly linked to a specific command.\n\t */\n\tpublic async getNonce(): Promise<BytesView | undefined> {\n\t\tthis.assertSupportsCommand(SecurityCommand, SecurityCommand.NonceGet);\n\n\t\tconst cc = new SecurityCCNonceGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tconst response = await this.host.sendCommand<SecurityCCNonceReport>(\n\t\t\tcc,\n\t\t\t{\n\t\t\t\t...this.commandOptions,\n\t\t\t\t// Only try getting a nonce once\n\t\t\t\tmaxSendAttempts: 1,\n\t\t\t},\n\t\t);\n\t\tif (!response) return;\n\n\t\tconst nonce = response.nonce;\n\t\tconst secMan = this.host.securityManager!;\n\t\tsecMan.setNonce(\n\t\t\t{\n\t\t\t\tissuer: this.endpoint.nodeId,\n\t\t\t\tnonceId: secMan.getNonceId(nonce),\n\t\t\t},\n\t\t\t{ nonce, receiver: this.host.ownNodeId },\n\t\t\t{ free: true },\n\t\t);\n\t\treturn nonce;\n\t}\n\n\t/**\n\t * Responds to a NonceGet request. The message is sent without any retransmission etc.\n\t * The return value indicates whether a nonce was successfully sent\n\t */\n\tpublic async sendNonce(): Promise<boolean> {\n\t\tthis.assertSupportsCommand(\n\t\t\tSecurityCommand,\n\t\t\tSecurityCommand.NonceReport,\n\t\t);\n\n\t\tif (!this.host.securityManager) {\n\t\t\tthrow new ZWaveError(\n\t\t\t\t`Nonces can only be sent if secure communication is set up!`,\n\t\t\t\tZWaveErrorCodes.Driver_NoSecurity,\n\t\t\t);\n\t\t}\n\n\t\tconst nonce = this.host.securityManager.generateNonce(\n\t\t\tthis.endpoint.nodeId,\n\t\t\tHALF_NONCE_SIZE,\n\t\t);\n\t\tconst nonceId = this.host.securityManager.getNonceId(nonce);\n\n\t\tconst cc = new SecurityCCNonceReport({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tnonce,\n\t\t});\n\n\t\ttry {\n\t\t\tawait this.host.sendCommand(cc, {\n\t\t\t\t...this.commandOptions,\n\t\t\t\t// Seems we need these options or some nodes won't accept the nonce\n\t\t\t\ttransmitOptions: TransmitOptions.ACK\n\t\t\t\t\t| TransmitOptions.AutoRoute,\n\t\t\t\t// Only try sending a nonce once\n\t\t\t\tmaxSendAttempts: 1,\n\t\t\t\t// Nonce requests must be handled immediately\n\t\t\t\tpriority: MessagePriority.Immediate,\n\t\t\t\t// We don't want failures causing us to treat the node as asleep or dead\n\t\t\t\tchangeNodeStatusOnMissingACK: false,\n\t\t\t});\n\t\t} catch (e) {\n\t\t\tif (isTransmissionError(e)) {\n\t\t\t\t// The nonce could not be sent, invalidate it\n\t\t\t\tthis.host.securityManager.deleteNonce(nonceId);\n\t\t\t\treturn false;\n\t\t\t} else {\n\t\t\t\t// Pass other errors through\n\t\t\t\tthrow e;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\tpublic async getSecurityScheme(): Promise<[0]> {\n\t\tthis.assertSupportsCommand(SecurityCommand, SecurityCommand.SchemeGet);\n\n\t\tconst cc = new SecurityCCSchemeGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tawait this.host.sendCommand(cc, this.commandOptions);\n\t\t// There is only one scheme, so we hardcode it\n\t\treturn [0];\n\t}\n\n\tpublic async reportSecurityScheme(encapsulated: boolean): Promise<void> {\n\t\tthis.assertSupportsCommand(\n\t\t\tSecurityCommand,\n\t\t\tSecurityCommand.SchemeReport,\n\t\t);\n\n\t\tlet cc: CommandClass = new SecurityCCSchemeReport({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tif (encapsulated) {\n\t\t\tcc = new SecurityCCCommandEncapsulation({\n\t\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\t\tendpointIndex: this.endpoint.index,\n\t\t\t\tencapsulated: cc,\n\t\t\t});\n\t\t}\n\t\tawait this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\tpublic async inheritSecurityScheme(): Promise<void> {\n\t\tthis.assertSupportsCommand(\n\t\t\tSecurityCommand,\n\t\t\tSecurityCommand.SchemeInherit,\n\t\t);\n\n\t\tconst cc = new SecurityCCSchemeInherit({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tawait this.host.sendCommand(cc, this.commandOptions);\n\t\t// There is only one scheme, so we don't return anything here\n\t}\n\n\tpublic async setNetworkKey(networkKey: BytesView): Promise<void> {\n\t\tthis.assertSupportsCommand(\n\t\t\tSecurityCommand,\n\t\t\tSecurityCommand.NetworkKeySet,\n\t\t);\n\n\t\tconst keySet = new SecurityCCNetworkKeySet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tnetworkKey,\n\t\t});\n\t\tconst cc = new SecurityCCCommandEncapsulation({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tencapsulated: keySet,\n\t\t\talternativeNetworkKey: new Uint8Array(16).fill(0),\n\t\t});\n\t\tawait this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\tpublic async verifyNetworkKey(): Promise<void> {\n\t\tthis.assertSupportsCommand(\n\t\t\tSecurityCommand,\n\t\t\tSecurityCommand.NetworkKeyVerify,\n\t\t);\n\n\t\tconst cc = new SecurityCCNetworkKeyVerify({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tawait this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n\tpublic async getSupportedCommands() {\n\t\tthis.assertSupportsCommand(\n\t\t\tSecurityCommand,\n\t\t\tSecurityCommand.CommandsSupportedGet,\n\t\t);\n\n\t\tconst cc = new SecurityCCCommandsSupportedGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tconst response = await this.host.sendCommand<\n\t\t\tSecurityCCCommandsSupportedReport\n\t\t>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\tif (response) {\n\t\t\treturn pick(response, [\"supportedCCs\", \"controlledCCs\"]);\n\t\t}\n\t}\n\n\tpublic async reportSupportedCommands(\n\t\tsupportedCCs: CommandClasses[],\n\t\tcontrolledCCs: CommandClasses[],\n\t): Promise<void> {\n\t\tthis.assertSupportsCommand(\n\t\t\tSecurityCommand,\n\t\t\tSecurityCommand.CommandsSupportedReport,\n\t\t);\n\n\t\tconst cc = new SecurityCCCommandsSupportedReport({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tsupportedCCs,\n\t\t\tcontrolledCCs,\n\t\t\treportsToFollow: 0,\n\t\t});\n\t\tawait this.host.sendCommand(cc, this.commandOptions);\n\t}\n}\n\n@commandClass(CommandClasses.Security)\n@implementedVersion(1)\nexport class SecurityCC extends CommandClass {\n\tdeclare ccCommand: SecurityCommand;\n\t// Force singlecast for the Security CC\n\tdeclare nodeId: number;\n\n\tpublic async interview(\n\t\tctx: InterviewContext,\n\t): Promise<void> {\n\t\tconst node = this.getNode(ctx)!;\n\t\tconst endpoint = this.getEndpoint(ctx)!;\n\t\tconst api = CCAPI.create(\n\t\t\tCommandClasses.Security,\n\t\t\tctx,\n\t\t\tendpoint,\n\t\t).withOptions({\n\t\t\tpriority: MessagePriority.NodeQuery,\n\t\t});\n\n\t\tctx.logNode(node.id, {\n\t\t\tmessage: \"Querying securely supported commands (S0)...\",\n\t\t\tdirection: \"outbound\",\n\t\t});\n\n\t\tlet supportedCCs: CommandClasses[] | undefined;\n\t\tlet controlledCCs: CommandClasses[] | undefined;\n\n\t\t// Try up to 3 times on the root device. We REALLY don't want a spurious timeout or collision to cause us to discard a known good security class\n\t\tconst MAX_ATTEMPTS = this.endpointIndex === 0 ? 3 : 1;\n\t\tfor (let attempts = 1; attempts <= MAX_ATTEMPTS; attempts++) {\n\t\t\tconst resp = await api.getSupportedCommands();\n\t\t\tif (resp) {\n\t\t\t\tsupportedCCs = resp.supportedCCs;\n\t\t\t\tcontrolledCCs = resp.controlledCCs;\n\t\t\t\tbreak;\n\t\t\t} else if (attempts < MAX_ATTEMPTS) {\n\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\t\tmessage:\n\t\t\t\t\t\t`Querying securely supported commands (S0), attempt ${attempts}/${MAX_ATTEMPTS} failed. Retrying in 500ms...`,\n\t\t\t\t\tlevel: \"warn\",\n\t\t\t\t});\n\t\t\t\tawait wait(500);\n\t\t\t}\n\t\t}\n\n\t\tif (!supportedCCs || !controlledCCs) {\n\t\t\tif (node.hasSecurityClass(SecurityClass.S0_Legacy) === true) {\n\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\t\tmessage: \"Querying securely supported commands (S0) failed\",\n\t\t\t\t\tlevel: \"warn\",\n\t\t\t\t});\n\t\t\t\t// TODO: Abort interview?\n\t\t\t} else {\n\t\t\t\t// We didn't know if the node was secure and it didn't respond,\n\t\t\t\t// assume that it doesn't have the S0 security class\n\t\t\t\tctx.logNode(\n\t\t\t\t\tnode.id,\n\t\t\t\t\t`The node was not granted the S0 security class. Continuing interview non-securely.`,\n\t\t\t\t);\n\t\t\t\tnode.setSecurityClass(SecurityClass.S0_Legacy, false);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tconst logLines: string[] = [\n\t\t\t\"received secure commands (S0)\",\n\t\t\t\"supported CCs:\",\n\t\t];\n\t\tfor (const cc of supportedCCs) {\n\t\t\tlogLines.push(`\u00B7 ${getCCName(cc)}`);\n\t\t}\n\t\tlogLines.push(\"controlled CCs:\");\n\t\tfor (const cc of controlledCCs) {\n\t\t\tlogLines.push(`\u00B7 ${getCCName(cc)}`);\n\t\t}\n\t\tctx.logNode(node.id, {\n\t\t\tmessage: logLines.join(\"\\n\"),\n\t\t\tdirection: \"inbound\",\n\t\t});\n\n\t\t// Remember which commands are supported securely\n\t\tfor (const cc of supportedCCs) {\n\t\t\t// Basic CC has special rules for when it is considered supported\n\t\t\t// Therefore we mark all other CCs as supported, but not Basic CC,\n\t\t\t// for which support is determined later.\n\t\t\tif (cc === CommandClasses.Basic) {\n\t\t\t\tendpoint.addCC(cc, { secure: true });\n\t\t\t} else {\n\t\t\t\tendpoint.addCC(cc, {\n\t\t\t\t\tisSupported: true,\n\t\t\t\t\tsecure: true,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\tfor (const cc of controlledCCs) {\n\t\t\t// Basic CC has special rules for when it is considered supported\n\t\t\t// Therefore we mark all other CCs as supported, but not Basic CC,\n\t\t\t// for which support is determined later.\n\t\t\tif (cc === CommandClasses.Basic) {\n\t\t\t\tendpoint.addCC(cc, { secure: true });\n\t\t\t} else {\n\t\t\t\tendpoint.addCC(cc, {\n\t\t\t\t\tisControlled: true,\n\t\t\t\t\tsecure: true,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t// We know for sure that the node is included securely\n\t\tif (node.hasSecurityClass(SecurityClass.S0_Legacy) !== true) {\n\t\t\tnode.setSecurityClass(SecurityClass.S0_Legacy, true);\n\t\t\tctx.logNode(\n\t\t\t\tnode.id,\n\t\t\t\t`The node was granted the S0 security class`,\n\t\t\t);\n\t\t}\n\n\t\t// Remember that the interview is complete\n\t\tthis.setInterviewComplete(ctx, true);\n\t}\n\n\t/** Tests if a command should be sent secure and thus requires encapsulation */\n\tpublic static requiresEncapsulation(cc: CommandClass): boolean {\n\t\t// No security flag -> no encapsulation\n\t\tif (!(cc.encapsulationFlags & EncapsulationFlags.Security)) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// S2, CRC16, Transport Service -> no S2 encapsulation\n\t\tif (\n\t\t\tcc instanceof Security2CC\n\t\t\t|| cc instanceof CRC16CC\n\t\t\t|| cc instanceof TransportServiceCC\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// S0: check command\n\t\tif (cc instanceof SecurityCC) {\n\t\t\tswitch (cc.ccCommand) {\n\t\t\t\t// Already encapsulated\n\t\t\t\tcase SecurityCommand.CommandEncapsulation:\n\t\t\t\tcase SecurityCommand.CommandEncapsulationNonceGet:\n\t\t\t\t// Cannot be sent encapsulated:\n\t\t\t\tcase SecurityCommand.NonceGet:\n\t\t\t\tcase SecurityCommand.NonceReport:\n\t\t\t\tcase SecurityCommand.SchemeGet:\n\t\t\t\tcase SecurityCommand.SchemeReport:\n\t\t\t\t\treturn false;\n\n\t\t\t\tdefault:\n\t\t\t\t\t// All other commands must be encapsulated\n\t\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\t// Everything else needs to be encapsulated if the CC is secure\n\t\treturn true;\n\t}\n\n\t/** Encapsulates a command that should be sent encrypted */\n\tpublic static encapsulate(\n\t\townNodeId: number,\n\t\tsecurityManager: SecurityManager,\n\t\tcc: CommandClass,\n\t): SecurityCCCommandEncapsulation {\n\t\t// TODO: When to return a SecurityCCCommandEncapsulationNonceGet?\n\t\tconst ret = new SecurityCCCommandEncapsulation({\n\t\t\tnodeId: cc.nodeId,\n\t\t\tencapsulated: cc,\n\t\t});\n\n\t\t// Copy the encapsulation flags from the encapsulated command\n\t\t// but omit Security, since we're doing that right now\n\t\tret.encapsulationFlags = cc.encapsulationFlags\n\t\t\t& ~EncapsulationFlags.Security;\n\n\t\treturn ret;\n\t}\n}\n\ninterface SecurityCCNonceReportOptions {\n\tnonce: BytesView;\n}\n\n@CCCommand(SecurityCommand.NonceReport)\nexport class SecurityCCNonceReport extends SecurityCC {\n\tconstructor(\n\t\toptions: WithAddress<SecurityCCNonceReportOptions>,\n\t) {\n\t\tsuper(options);\n\t\tif (options.nonce.length !== HALF_NONCE_SIZE) {\n\t\t\tthrow new ZWaveError(\n\t\t\t\t`Nonce must have length ${HALF_NONCE_SIZE}!`,\n\t\t\t\tZWaveErrorCodes.Argument_Invalid,\n\t\t\t);\n\t\t}\n\t\tthis.nonce = options.nonce;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): SecurityCCNonceReport {\n\t\tvalidatePayload.withReason(\"Invalid nonce length\")(\n\t\t\traw.payload.length === HALF_NONCE_SIZE,\n\t\t);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tnonce: raw.payload,\n\t\t});\n\t}\n\n\tpublic nonce: BytesView;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.view(this.nonce);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: { nonce: buffer2hex(this.nonce) },\n\t\t};\n\t}\n}\n\n@CCCommand(SecurityCommand.NonceGet)\n@expectedCCResponse(SecurityCCNonceReport)\nexport class SecurityCCNonceGet extends SecurityCC {}\n\n// @publicAPI\nexport type SecurityCCCommandEncapsulationOptions =\n\t& {\n\t\talternativeNetworkKey?: BytesView;\n\t}\n\t& ({\n\t\tencapsulated: CommandClass;\n\t} | {\n\t\tdecryptedCCBytes: BytesView;\n\t\tsequenced: boolean;\n\t\tsecondFrame: boolean;\n\t\tsequenceCounter: number;\n\t});\n\nfunction getCCResponseForCommandEncapsulation(\n\tsent: SecurityCCCommandEncapsulation,\n) {\n\tif (sent.encapsulated.expectsCCResponse()) {\n\t\treturn SecurityCCCommandEncapsulation;\n\t}\n}\n\n@CCCommand(SecurityCommand.CommandEncapsulation)\n@expectedCCResponse(\n\tgetCCResponseForCommandEncapsulation,\n\t() => \"checkEncapsulated\",\n)\nexport class SecurityCCCommandEncapsulation extends SecurityCC {\n\tpublic constructor(\n\t\toptions: WithAddress<SecurityCCCommandEncapsulationOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\tif (\"encapsulated\" in options) {\n\t\t\tthis.encapsulated = options.encapsulated;\n\t\t\tthis.encapsulated.encapsulatingCC = this as any;\n\t\t} else {\n\t\t\tthis.decryptedCCBytes = options.decryptedCCBytes;\n\t\t\tthis.sequenced = options.sequenced;\n\t\t\tthis.secondFrame = options.secondFrame;\n\t\t\tthis.sequenceCounter = options.sequenceCounter;\n\t\t}\n\t\tthis.alternativeNetworkKey = options.alternativeNetworkKey;\n\t}\n\n\tpublic static async from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): Promise<SecurityCCCommandEncapsulation> {\n\t\tassertSecurityRX(ctx);\n\n\t\t// HALF_NONCE_SIZE bytes iv, 1 byte frame control, at least 1 CC byte, 1 byte nonce id, 8 bytes auth code\n\t\tvalidatePayload(\n\t\t\traw.payload.length >= HALF_NONCE_SIZE + 1 + 1 + 1 + 8,\n\t\t);\n\t\tconst iv = raw.payload.subarray(0, HALF_NONCE_SIZE);\n\t\tconst encryptedPayload = raw.payload.subarray(HALF_NONCE_SIZE, -9);\n\t\tconst nonceId = raw.payload.at(-9)!;\n\t\tconst authCode = raw.payload.subarray(-8);\n\n\t\t// Retrieve the used nonce from the nonce store\n\t\tconst nonce = ctx.securityManager.getNonce(nonceId);\n\t\t// Only accept the message if the nonce hasn't expired\n\t\tif (!nonce) {\n\t\t\tvalidatePayload.fail(\n\t\t\t\t`Nonce ${\n\t\t\t\t\tnum2hex(\n\t\t\t\t\t\tnonceId,\n\t\t\t\t\t)\n\t\t\t\t} expired, cannot decode security encapsulated command.`,\n\t\t\t);\n\t\t}\n\t\t// and mark the nonce as used\n\t\tctx.securityManager.deleteNonce(nonceId);\n\n\t\t// Validate the encrypted data\n\t\tconst authData = getAuthenticationData(\n\t\t\tiv,\n\t\t\tnonce,\n\t\t\tSecurityCommand.CommandEncapsulation,\n\t\t\tctx.sourceNodeId,\n\t\t\tctx.ownNodeId,\n\t\t\tencryptedPayload,\n\t\t);\n\t\tconst expectedAuthCode = await computeMAC(\n\t\t\tauthData,\n\t\t\tawait ctx.securityManager.getAuthKey(),\n\t\t);\n\t\t// Only accept messages with a correct auth code\n\t\tvalidatePayload.withReason(\n\t\t\t\"Invalid auth code, won't accept security encapsulated command.\",\n\t\t)(authCode.equals(expectedAuthCode));\n\n\t\t// Decrypt the encapsulated CC\n\t\tconst frameControlAndDecryptedCC = await decryptAES128OFB(\n\t\t\tencryptedPayload,\n\t\t\tawait ctx.securityManager.getEncryptionKey(),\n\t\t\tBytes.concat([iv, nonce]),\n\t\t);\n\t\tconst frameControl = frameControlAndDecryptedCC[0];\n\t\tconst sequenceCounter = frameControl & 0b1111;\n\t\tconst sequenced = !!(frameControl & 0b1_0000);\n\t\tconst secondFrame = !!(frameControl & 0b10_0000);\n\t\tconst decryptedCCBytes: BytesView | undefined =\n\t\t\tframeControlAndDecryptedCC\n\t\t\t\t.subarray(1);\n\n\t\tconst ret = new SecurityCCCommandEncapsulation({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tsequenceCounter,\n\t\t\tsequenced,\n\t\t\tsecondFrame,\n\t\t\tdecryptedCCBytes,\n\t\t});\n\n\t\tret.authData = authData;\n\t\tret.authCode = authCode;\n\t\tret.iv = iv;\n\n\t\treturn ret;\n\t}\n\n\tprivate sequenced: boolean | undefined;\n\tprivate secondFrame: boolean | undefined;\n\tprivate sequenceCounter: number | undefined;\n\n\tprivate decryptedCCBytes: BytesView | undefined;\n\tpublic encapsulated!: CommandClass;\n\n\tprivate alternativeNetworkKey?: BytesView;\n\n\tpublic get nonceId(): number | undefined {\n\t\treturn this.nonce?.[0];\n\t}\n\tpublic nonce: BytesView | undefined;\n\n\t// Only used testing/for debugging purposes\n\tprivate iv?: BytesView;\n\tprivate authData?: BytesView;\n\tprivate authCode?: BytesView;\n\tprivate ciphertext?: BytesView;\n\n\tpublic getPartialCCSessionId(): Record<string, any> | undefined {\n\t\tif (this.sequenced) {\n\t\t\treturn {\n\t\t\t\t// Treat Encapsulation and EncapsulationNonceGet as one\n\t\t\t\tccCommand: undefined,\n\t\t\t\tsequence: this.sequenceCounter,\n\t\t\t};\n\t\t} else {\n\t\t\treturn {\n\t\t\t\t// Treat Encapsulation and EncapsulationNonceGet as one\n\t\t\t\tccCommand: undefined,\n\t\t\t};\n\t\t}\n\t}\n\n\tpublic expectMoreMessages(): boolean {\n\t\treturn !!this.sequenced && !this.secondFrame;\n\t}\n\n\tpublic async mergePartialCCs(\n\t\tpartials: SecurityCCCommandEncapsulation[],\n\t\tctx: CCParsingContext,\n\t): Promise<void> {\n\t\t// Concat the CC buffers\n\t\tthis.decryptedCCBytes = Bytes.concat(\n\t\t\t[...partials, this].map((cc) => cc.decryptedCCBytes!),\n\t\t);\n\t\t// make sure this contains a complete CC command that's worth splitting\n\t\tvalidatePayload(this.decryptedCCBytes.length >= 2);\n\t\t// and deserialize the CC\n\t\tthis.encapsulated = await CommandClass.parse(\n\t\t\tthis.decryptedCCBytes,\n\t\t\tctx,\n\t\t);\n\t\tthis.encapsulated.encapsulatingCC = this as any;\n\t}\n\n\tpublic async serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tif (!this.nonce) throwNoNonce();\n\t\tif (this.nonce.length !== HALF_NONCE_SIZE) {\n\t\t\tthrowNoNonce(\"Invalid nonce size\");\n\t\t}\n\t\tassertSecurityTX(ctx);\n\n\t\tlet authKey: BytesView;\n\t\tlet encryptionKey: BytesView;\n\t\tif (this.alternativeNetworkKey) {\n\t\t\tauthKey = await generateAuthKey(this.alternativeNetworkKey);\n\t\t\tencryptionKey = await generateEncryptionKey(\n\t\t\t\tthis.alternativeNetworkKey,\n\t\t\t);\n\t\t} else {\n\t\t\tauthKey = await ctx.securityManager.getAuthKey();\n\t\t\tencryptionKey = await ctx.securityManager.getEncryptionKey();\n\t\t}\n\n\t\tconst serializedCC = await this.encapsulated.serialize(ctx);\n\t\tconst plaintext = Bytes.concat([\n\t\t\tBytes.from([0]), // TODO: frame control\n\t\t\tserializedCC,\n\t\t]);\n\t\t// Encrypt the payload\n\t\tconst senderNonce = randomBytes(HALF_NONCE_SIZE);\n\t\tconst iv = Bytes.concat([senderNonce, this.nonce]);\n\t\tconst ciphertext = await encryptAES128OFB(\n\t\t\tplaintext,\n\t\t\tencryptionKey,\n\t\t\tiv,\n\t\t);\n\t\t// And generate the auth code\n\t\tconst authData = getAuthenticationData(\n\t\t\tsenderNonce,\n\t\t\tthis.nonce,\n\t\t\tthis.ccCommand,\n\t\t\tctx.ownNodeId,\n\t\t\tthis.nodeId,\n\t\t\tciphertext,\n\t\t);\n\t\tconst authCode = await computeMAC(authData, authKey);\n\n\t\t// Remember for debugging purposes\n\t\tthis.iv = iv;\n\t\tthis.authData = authData;\n\t\tthis.authCode = authCode;\n\t\tthis.ciphertext = ciphertext;\n\n\t\tthis.payload = Bytes.concat([\n\t\t\tsenderNonce,\n\t\t\tciphertext,\n\t\t\tBytes.from([this.nonceId!]),\n\t\t\tauthCode,\n\t\t]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tprotected computeEncapsulationOverhead(): number {\n\t\t// Security CC adds 8 bytes IV, 1 byte frame control, 1 byte nonce ID, 8 bytes MAC\n\t\treturn super.computeEncapsulationOverhead() + 18;\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\tconst message: MessageRecord = {};\n\t\tif (this.nonceId != undefined) {\n\t\t\tmessage[\"nonce id\"] = this.nonceId;\n\t\t}\n\t\tif (this.sequenced != undefined) {\n\t\t\tmessage.sequenced = this.sequenced;\n\t\t\tif (this.sequenced) {\n\t\t\t\tif (this.secondFrame != undefined) {\n\t\t\t\t\tmessage[\"second frame\"] = this.secondFrame;\n\t\t\t\t}\n\t\t\t\tif (this.sequenceCounter != undefined) {\n\t\t\t\t\tmessage[\"sequence counter\"] = this.sequenceCounter;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Log the plaintext in integration tests and development mode\n\t\tif (\n\t\t\tprocess.env.NODE_ENV === \"test\"\n\t\t\t|| process.env.NODE_ENV === \"development\"\n\t\t) {\n\t\t\tif (this.iv) {\n\t\t\t\tmessage.IV = buffer2hex(this.iv);\n\t\t\t}\n\t\t\tif (this.ciphertext) {\n\t\t\t\tmessage.ciphertext = buffer2hex(this.ciphertext);\n\t\t\t} else if (this.decryptedCCBytes) {\n\t\t\t\tmessage.plaintext = buffer2hex(this.decryptedCCBytes);\n\t\t\t}\n\t\t\tif (this.authData) {\n\t\t\t\tmessage[\"auth data\"] = buffer2hex(this.authData);\n\t\t\t}\n\t\t\tif (this.authCode) {\n\t\t\t\tmessage[\"auth code\"] = buffer2hex(this.authCode);\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage,\n\t\t};\n\t}\n}\n\n// This is the same message, but with another CC command\n@CCCommand(SecurityCommand.CommandEncapsulationNonceGet)\nexport class SecurityCCCommandEncapsulationNonceGet\n\textends SecurityCCCommandEncapsulation\n{}\n\n@CCCommand(SecurityCommand.SchemeReport)\nexport class SecurityCCSchemeReport extends SecurityCC {\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): SecurityCCSchemeReport {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\t// The including controller MUST NOT perform any validation of the Supported Security Schemes byte\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t});\n\t}\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\t// Since it is unlikely that any more schemes will be added to S0, we hardcode the default scheme here (bit 0 = 0)\n\t\tthis.payload = Bytes.from([0]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\t// Hide the default payload line\n\t\t\tmessage: undefined,\n\t\t};\n\t}\n}\n\n@CCCommand(SecurityCommand.SchemeGet)\n@expectedCCResponse(SecurityCCSchemeReport)\nexport class SecurityCCSchemeGet extends SecurityCC {\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): SecurityCCSchemeGet {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\t// The joining node MUST NOT perform any validation of the Supported Security Schemes byte\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t});\n\t}\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\t// Since it is unlikely that any more schemes will be added to S0, we hardcode the default scheme here (bit 0 = 0)\n\t\tthis.payload = Bytes.from([0]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\t// Hide the default payload line\n\t\t\tmessage: undefined,\n\t\t};\n\t}\n}\n\n@CCCommand(SecurityCommand.SchemeInherit)\n@expectedCCResponse(SecurityCCSchemeReport)\nexport class SecurityCCSchemeInherit extends SecurityCC {\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): SecurityCCSchemeInherit {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\t// The joining node MUST NOT perform any validation of the Supported Security Schemes byte\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t});\n\t}\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\t// Since it is unlikely that any more schemes will be added to S0, we hardcode the default scheme here (bit 0 = 0)\n\t\tthis.payload = Bytes.from([0]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\t// Hide the default payload line\n\t\t\tmessage: undefined,\n\t\t};\n\t}\n}\n\n@CCCommand(SecurityCommand.NetworkKeyVerify)\nexport class SecurityCCNetworkKeyVerify extends SecurityCC {}\n\n// @publicAPI\nexport interface SecurityCCNetworkKeySetOptions {\n\tnetworkKey: BytesView;\n}\n\n@CCCommand(SecurityCommand.NetworkKeySet)\n@expectedCCResponse(SecurityCCNetworkKeyVerify)\nexport class SecurityCCNetworkKeySet extends SecurityCC {\n\tpublic constructor(\n\t\toptions: WithAddress<SecurityCCNetworkKeySetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tif (options.networkKey.length !== 16) {\n\t\t\tthrow new ZWaveError(\n\t\t\t\t`The network key must have length 16!`,\n\t\t\t\tZWaveErrorCodes.Argument_Invalid,\n\t\t\t);\n\t\t}\n\t\tthis.networkKey = options.networkKey;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): SecurityCCNetworkKeySet {\n\t\tvalidatePayload(raw.payload.length >= 16);\n\t\tconst networkKey: BytesView = raw.payload.subarray(0, 16);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tnetworkKey,\n\t\t});\n\t}\n\n\tpublic networkKey: BytesView;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.view(this.networkKey);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\t// The network key shouldn't be logged, so users can safely post their logs online\n\t\tconst { message, ...log } = super.toLogEntry(ctx);\n\t\treturn log;\n\t}\n}\n\n// @publicAPI\nexport interface SecurityCCCommandsSupportedReportOptions {\n\treportsToFollow?: number;\n\tsupportedCCs: CommandClasses[];\n\tcontrolledCCs: CommandClasses[];\n}\n\n@CCCommand(SecurityCommand.CommandsSupportedReport)\nexport class SecurityCCCommandsSupportedReport extends SecurityCC {\n\tpublic constructor(\n\t\toptions: WithAddress<SecurityCCCommandsSupportedReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\tthis.supportedCCs = options.supportedCCs;\n\t\tthis.controlledCCs = options.controlledCCs;\n\t\t// TODO: properly split the CCs into multiple reports\n\t\tthis.reportsToFollow = options.reportsToFollow ?? 0;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): SecurityCCCommandsSupportedReport {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst reportsToFollow = raw.payload[0];\n\t\tconst list = parseCCList(raw.payload.subarray(1));\n\t\tconst supportedCCs: CommandClasses[] = list.supportedCCs;\n\t\tconst controlledCCs: CommandClasses[] = list.controlledCCs;\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\treportsToFollow,\n\t\t\tsupportedCCs,\n\t\t\tcontrolledCCs,\n\t\t});\n\t}\n\n\tpublic reportsToFollow: number;\n\tpublic supportedCCs: CommandClasses[];\n\tpublic controlledCCs: CommandClasses[];\n\n\tpublic getPartialCCSessionId(): Record<string, any> | undefined {\n\t\t// Nothing special we can distinguish sessions with\n\t\treturn {};\n\t}\n\n\tpublic expectMoreMessages(): boolean {\n\t\treturn this.reportsToFollow > 0;\n\t}\n\n\tpublic mergePartialCCs(\n\t\tpartials: SecurityCCCommandsSupportedReport[],\n\t): Promise<void> {\n\t\t// Concat the lists of CCs\n\t\tthis.supportedCCs = [...partials, this]\n\t\t\t.map((report) => report.supportedCCs)\n\t\t\t.reduce((prev, cur) => prev.concat(...cur), []);\n\t\tthis.controlledCCs = [...partials, this]\n\t\t\t.map((report) => report.controlledCCs)\n\t\t\t.reduce((prev, cur) => prev.concat(...cur), []);\n\t\treturn Promise.resolve();\n\t}\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.concat([\n\t\t\tBytes.from([this.reportsToFollow]),\n\t\t\tencodeCCList(this.supportedCCs, this.controlledCCs),\n\t\t]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: {\n\t\t\t\treportsToFollow: this.reportsToFollow,\n\t\t\t\tsupportedCCs: this.supportedCCs\n\t\t\t\t\t.map((cc) => getCCName(cc))\n\t\t\t\t\t.map((cc) => `\\n\u00B7 ${cc}`)\n\t\t\t\t\t.join(\"\"),\n\t\t\t\tcontrolledCCs: this.controlledCCs\n\t\t\t\t\t.map((cc) => getCCName(cc))\n\t\t\t\t\t.map((cc) => `\\n\u00B7 ${cc}`)\n\t\t\t\t\t.join(\"\"),\n\t\t\t},\n\t\t};\n\t}\n}\n\n@CCCommand(SecurityCommand.CommandsSupportedGet)\n@expectedCCResponse(SecurityCCCommandsSupportedReport)\nexport class SecurityCCCommandsSupportedGet extends SecurityCC {}\n"],
5
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;8BAF1C,yCAAU,6BAAgB,oBAAoB,OAC9C,kDAAmB,iCAAiC,CAAC;;;;oBACF;sDAAA,YAAU;WAAA;;;;;;;;AAA9D,mBAAA,MAAA,mBAAA,EAAA,OAAA,WAAA,GAAA,kBAAA,EAAA,MAAA,SAAA,MAAA,WAAA,MAAA,UAAA,UAAA,GAAA,MAAA,uBAAA;;;AAAa,wBAAA,YAAA,uBAAA;;;;;",
6
6
  "names": ["SecurityCC", "SecurityCCCommandEncapsulation"]
7
7
  }
@@ -1,6 +1,6 @@
1
1
  import type { CCEncodingContext, CCParsingContext } from "@zwave-js/cc";
2
2
  import { CommandClasses, type GetValueDB, type MaybeNotKnown, type MessageOrCCLogEntry, type SupervisionResult, type WithAddress } from "@zwave-js/core";
3
- import { Bytes } from "@zwave-js/shared";
3
+ import { Bytes, type BytesView } from "@zwave-js/shared";
4
4
  import { CCAPI, POLL_VALUE, type PollValueImplementation, SET_VALUE, type SetValueImplementation } from "../lib/API.js";
5
5
  import { type CCRaw, CommandClass, type InterviewContext, type PersistValuesContext, type RefreshValuesContext } from "../lib/CommandClass.js";
6
6
  import { ThermostatMode, ThermostatModeCommand } from "../lib/_Types.js";
@@ -92,7 +92,7 @@ export declare class ThermostatModeCCAPI extends CCAPI {
92
92
  protected get [POLL_VALUE](): PollValueImplementation;
93
93
  get(): Promise<Pick<ThermostatModeCCReport, "mode" | "manufacturerData"> | undefined>;
94
94
  set(mode: Exclude<ThermostatMode, (typeof ThermostatMode)["Manufacturer specific"]>): Promise<SupervisionResult | undefined>;
95
- set(mode: (typeof ThermostatMode)["Manufacturer specific"], manufacturerData: Uint8Array | string): Promise<SupervisionResult | undefined>;
95
+ set(mode: (typeof ThermostatMode)["Manufacturer specific"], manufacturerData: BytesView | string): Promise<SupervisionResult | undefined>;
96
96
  getSupportedModes(): Promise<MaybeNotKnown<readonly ThermostatMode[]>>;
97
97
  }
98
98
  export declare class ThermostatModeCC extends CommandClass {
@@ -104,13 +104,13 @@ export type ThermostatModeCCSetOptions = {
104
104
  mode: Exclude<ThermostatMode, (typeof ThermostatMode)["Manufacturer specific"]>;
105
105
  } | {
106
106
  mode: (typeof ThermostatMode)["Manufacturer specific"];
107
- manufacturerData: Uint8Array;
107
+ manufacturerData: BytesView;
108
108
  };
109
109
  export declare class ThermostatModeCCSet extends ThermostatModeCC {
110
110
  constructor(options: WithAddress<ThermostatModeCCSetOptions>);
111
111
  static from(raw: CCRaw, ctx: CCParsingContext): ThermostatModeCCSet;
112
112
  mode: ThermostatMode;
113
- manufacturerData?: Uint8Array;
113
+ manufacturerData?: BytesView;
114
114
  serialize(ctx: CCEncodingContext): Promise<Bytes>;
115
115
  toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry;
116
116
  }
@@ -119,14 +119,14 @@ export type ThermostatModeCCReportOptions = {
119
119
  manufacturerData?: undefined;
120
120
  } | {
121
121
  mode: (typeof ThermostatMode)["Manufacturer specific"];
122
- manufacturerData?: Uint8Array;
122
+ manufacturerData?: BytesView;
123
123
  };
124
124
  export declare class ThermostatModeCCReport extends ThermostatModeCC {
125
125
  constructor(options: WithAddress<ThermostatModeCCReportOptions>);
126
126
  static from(raw: CCRaw, ctx: CCParsingContext): ThermostatModeCCReport;
127
127
  persistValues(ctx: PersistValuesContext): boolean;
128
128
  readonly mode: ThermostatMode;
129
- readonly manufacturerData: Uint8Array | undefined;
129
+ readonly manufacturerData: BytesView | undefined;
130
130
  serialize(ctx: CCEncodingContext): Promise<Bytes>;
131
131
  toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry;
132
132
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/cc/ThermostatModeCC.ts"],
4
- "sourcesContent": ["import type { CCEncodingContext, CCParsingContext } from \"@zwave-js/cc\";\nimport {\n\tCommandClasses,\n\ttype GetValueDB,\n\ttype MaybeNotKnown,\n\ttype MessageOrCCLogEntry,\n\tMessagePriority,\n\ttype MessageRecord,\n\ttype SupervisionResult,\n\tValueMetadata,\n\ttype WithAddress,\n\tZWaveError,\n\tZWaveErrorCodes,\n\tencodeBitMask,\n\tenumValuesToMetadataStates,\n\tparseBitMask,\n\tsupervisedCommandSucceeded,\n\tvalidatePayload,\n} from \"@zwave-js/core\";\nimport { Bytes, buffer2hex, getEnumMemberName, pick } from \"@zwave-js/shared\";\nimport { validateArgs } from \"@zwave-js/transformers\";\nimport {\n\tCCAPI,\n\tPOLL_VALUE,\n\ttype PollValueImplementation,\n\tSET_VALUE,\n\ttype SetValueImplementation,\n\tthrowUnsupportedProperty,\n\tthrowWrongValueType,\n} from \"../lib/API.js\";\nimport {\n\ttype CCRaw,\n\tCommandClass,\n\ttype InterviewContext,\n\ttype PersistValuesContext,\n\ttype RefreshValuesContext,\n} from \"../lib/CommandClass.js\";\nimport {\n\tAPI,\n\tCCCommand,\n\tccValueProperty,\n\tccValues,\n\tcommandClass,\n\texpectedCCResponse,\n\timplementedVersion,\n\tuseSupervision,\n} from \"../lib/CommandClassDecorators.js\";\nimport { V } from \"../lib/Values.js\";\nimport { ThermostatMode, ThermostatModeCommand } from \"../lib/_Types.js\";\n\nexport const ThermostatModeCCValues = V.defineCCValues(\n\tCommandClasses[\"Thermostat Mode\"],\n\t{\n\t\t...V.staticPropertyWithName(\n\t\t\t\"thermostatMode\",\n\t\t\t\"mode\",\n\t\t\t{\n\t\t\t\t...ValueMetadata.UInt8,\n\t\t\t\tstates: enumValuesToMetadataStates(ThermostatMode),\n\t\t\t\tlabel: \"Thermostat mode\",\n\t\t\t} as const,\n\t\t),\n\t\t...V.staticProperty(\n\t\t\t\"manufacturerData\",\n\t\t\t{\n\t\t\t\t...ValueMetadata.ReadOnlyBuffer,\n\t\t\t\tlabel: \"Manufacturer data\",\n\t\t\t} as const,\n\t\t),\n\t\t...V.staticProperty(\"supportedModes\", undefined, { internal: true }),\n\t},\n);\n\n@API(CommandClasses[\"Thermostat Mode\"])\nexport class ThermostatModeCCAPI extends CCAPI {\n\tpublic supportsCommand(cmd: ThermostatModeCommand): MaybeNotKnown<boolean> {\n\t\tswitch (cmd) {\n\t\t\tcase ThermostatModeCommand.Get:\n\t\t\tcase ThermostatModeCommand.SupportedGet:\n\t\t\t\treturn this.isSinglecast();\n\t\t\tcase ThermostatModeCommand.Set:\n\t\t\t\treturn true; // This is mandatory\n\t\t}\n\t\treturn super.supportsCommand(cmd);\n\t}\n\n\tprotected override get [SET_VALUE](): SetValueImplementation {\n\t\treturn async function(this: ThermostatModeCCAPI, { property }, value) {\n\t\t\tif (property !== \"mode\") {\n\t\t\t\tthrowUnsupportedProperty(this.ccId, property);\n\t\t\t}\n\t\t\tif (typeof value !== \"number\") {\n\t\t\t\tthrowWrongValueType(\n\t\t\t\t\tthis.ccId,\n\t\t\t\t\tproperty,\n\t\t\t\t\t\"number\",\n\t\t\t\t\ttypeof value,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst result = await this.set(value);\n\n\t\t\t// Verify the current value after a delay, unless the command was supervised and successful\n\t\t\tif (this.isSinglecast() && !supervisedCommandSucceeded(result)) {\n\t\t\t\t// TODO: Ideally this would be a short delay, but some thermostats like Remotec ZXT-600\n\t\t\t\t// aren't able to handle the GET this quickly.\n\t\t\t\tthis.schedulePoll({ property }, value);\n\t\t\t}\n\n\t\t\treturn result;\n\t\t};\n\t}\n\n\tprotected get [POLL_VALUE](): PollValueImplementation {\n\t\treturn async function(this: ThermostatModeCCAPI, { property }) {\n\t\t\tswitch (property) {\n\t\t\t\tcase \"mode\":\n\t\t\t\t\treturn (await this.get())?.[property];\n\n\t\t\t\tdefault:\n\t\t\t\t\tthrowUnsupportedProperty(this.ccId, property);\n\t\t\t}\n\t\t};\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n\tpublic async get() {\n\t\tthis.assertSupportsCommand(\n\t\t\tThermostatModeCommand,\n\t\t\tThermostatModeCommand.Get,\n\t\t);\n\n\t\tconst cc = new ThermostatModeCCGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tconst response = await this.host.sendCommand<\n\t\t\tThermostatModeCCReport\n\t\t>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\tif (response) {\n\t\t\treturn pick(response, [\"mode\", \"manufacturerData\"]);\n\t\t}\n\t}\n\n\tpublic async set(\n\t\tmode: Exclude<\n\t\t\tThermostatMode,\n\t\t\t(typeof ThermostatMode)[\"Manufacturer specific\"]\n\t\t>,\n\t): Promise<SupervisionResult | undefined>;\n\tpublic async set(\n\t\tmode: (typeof ThermostatMode)[\"Manufacturer specific\"],\n\t\tmanufacturerData: Uint8Array | string,\n\t): Promise<SupervisionResult | undefined>;\n\n\t@validateArgs({ strictEnums: true })\n\tpublic async set(\n\t\tmode: ThermostatMode,\n\t\tmanufacturerData?: Uint8Array | string,\n\t): Promise<SupervisionResult | undefined> {\n\t\tthis.assertSupportsCommand(\n\t\t\tThermostatModeCommand,\n\t\t\tThermostatModeCommand.Set,\n\t\t);\n\n\t\tif (typeof manufacturerData === \"string\") {\n\t\t\t// We accept the manufacturer data as a hex string. Make sure it's valid\n\t\t\tif (\n\t\t\t\tmanufacturerData.length % 2 !== 0\n\t\t\t\t|| !/^[0-9a-f]+$/i.test(manufacturerData)\n\t\t\t) {\n\t\t\t\tthrow new ZWaveError(\n\t\t\t\t\t`Manufacturer data must be represented as hexadecimal when passed as a string!`,\n\t\t\t\t\tZWaveErrorCodes.Argument_Invalid,\n\t\t\t\t);\n\t\t\t}\n\t\t\tmanufacturerData = Bytes.from(manufacturerData, \"hex\");\n\t\t}\n\n\t\tconst cc = new ThermostatModeCCSet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tmode,\n\t\t\tmanufacturerData: manufacturerData as any,\n\t\t});\n\t\treturn this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\tpublic async getSupportedModes(): Promise<\n\t\tMaybeNotKnown<readonly ThermostatMode[]>\n\t> {\n\t\tthis.assertSupportsCommand(\n\t\t\tThermostatModeCommand,\n\t\t\tThermostatModeCommand.SupportedGet,\n\t\t);\n\n\t\tconst cc = new ThermostatModeCCSupportedGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tconst response = await this.host.sendCommand<\n\t\t\tThermostatModeCCSupportedReport\n\t\t>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\treturn response?.supportedModes;\n\t}\n}\n\n@commandClass(CommandClasses[\"Thermostat Mode\"])\n@implementedVersion(3)\n@ccValues(ThermostatModeCCValues)\nexport class ThermostatModeCC extends CommandClass {\n\tdeclare ccCommand: ThermostatModeCommand;\n\n\tpublic async interview(\n\t\tctx: InterviewContext,\n\t): Promise<void> {\n\t\tconst node = this.getNode(ctx)!;\n\t\tconst endpoint = this.getEndpoint(ctx)!;\n\t\tconst api = CCAPI.create(\n\t\t\tCommandClasses[\"Thermostat Mode\"],\n\t\t\tctx,\n\t\t\tendpoint,\n\t\t).withOptions({\n\t\t\tpriority: MessagePriority.NodeQuery,\n\t\t});\n\n\t\tctx.logNode(node.id, {\n\t\t\tendpoint: this.endpointIndex,\n\t\t\tmessage: `Interviewing ${this.ccName}...`,\n\t\t\tdirection: \"none\",\n\t\t});\n\n\t\t// First query the possible modes to set the metadata\n\t\tctx.logNode(node.id, {\n\t\t\tendpoint: this.endpointIndex,\n\t\t\tmessage: \"querying supported thermostat modes...\",\n\t\t\tdirection: \"outbound\",\n\t\t});\n\n\t\tconst supportedModes = await api.getSupportedModes();\n\t\tif (supportedModes) {\n\t\t\tconst logMessage = `received supported thermostat modes:${\n\t\t\t\tsupportedModes\n\t\t\t\t\t.map((mode) =>\n\t\t\t\t\t\t`\\n\u00B7 ${getEnumMemberName(ThermostatMode, mode)}`\n\t\t\t\t\t)\n\t\t\t\t\t.join(\"\")\n\t\t\t}`;\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\tmessage: logMessage,\n\t\t\t\tdirection: \"inbound\",\n\t\t\t});\n\t\t} else {\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\tmessage:\n\t\t\t\t\t\"Querying supported thermostat modes timed out, skipping interview...\",\n\t\t\t\tlevel: \"warn\",\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tawait this.refreshValues(ctx);\n\n\t\t// Remember that the interview is complete\n\t\tthis.setInterviewComplete(ctx, true);\n\t}\n\n\tpublic async refreshValues(\n\t\tctx: RefreshValuesContext,\n\t): Promise<void> {\n\t\tconst node = this.getNode(ctx)!;\n\t\tconst endpoint = this.getEndpoint(ctx)!;\n\t\tconst api = CCAPI.create(\n\t\t\tCommandClasses[\"Thermostat Mode\"],\n\t\t\tctx,\n\t\t\tendpoint,\n\t\t).withOptions({\n\t\t\tpriority: MessagePriority.NodeQuery,\n\t\t});\n\n\t\t// Query the current status\n\t\tctx.logNode(node.id, {\n\t\t\tendpoint: this.endpointIndex,\n\t\t\tmessage: \"querying current thermostat mode...\",\n\t\t\tdirection: \"outbound\",\n\t\t});\n\t\tconst currentStatus = await api.get();\n\t\tif (currentStatus) {\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\tmessage: \"received current thermostat mode: \"\n\t\t\t\t\t+ getEnumMemberName(ThermostatMode, currentStatus.mode),\n\t\t\t\tdirection: \"inbound\",\n\t\t\t});\n\t\t}\n\t}\n}\n\n// @publicAPI\nexport type ThermostatModeCCSetOptions =\n\t| {\n\t\tmode: Exclude<\n\t\t\tThermostatMode,\n\t\t\t(typeof ThermostatMode)[\"Manufacturer specific\"]\n\t\t>;\n\t}\n\t| {\n\t\tmode: (typeof ThermostatMode)[\"Manufacturer specific\"];\n\t\tmanufacturerData: Uint8Array;\n\t};\n\n@CCCommand(ThermostatModeCommand.Set)\n@useSupervision()\nexport class ThermostatModeCCSet extends ThermostatModeCC {\n\tpublic constructor(\n\t\toptions: WithAddress<ThermostatModeCCSetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.mode = options.mode;\n\t\tif (\"manufacturerData\" in options) {\n\t\t\tthis.manufacturerData = options.manufacturerData;\n\t\t}\n\t}\n\n\tpublic static from(raw: CCRaw, ctx: CCParsingContext): ThermostatModeCCSet {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst mode: ThermostatMode = raw.payload[0] & 0b11111;\n\t\tif (mode !== ThermostatMode[\"Manufacturer specific\"]) {\n\t\t\treturn new this({\n\t\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\t\tmode,\n\t\t\t});\n\t\t}\n\n\t\tconst manufacturerDataLength = (raw.payload[0] >>> 5) & 0b111;\n\t\tvalidatePayload(\n\t\t\traw.payload.length >= 1 + manufacturerDataLength,\n\t\t);\n\t\tconst manufacturerData = raw.payload.subarray(\n\t\t\t1,\n\t\t\t1 + manufacturerDataLength,\n\t\t);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tmode,\n\t\t\tmanufacturerData,\n\t\t});\n\t}\n\n\tpublic mode: ThermostatMode;\n\tpublic manufacturerData?: Uint8Array;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tconst manufacturerData =\n\t\t\tthis.mode === ThermostatMode[\"Manufacturer specific\"]\n\t\t\t\t&& this.manufacturerData\n\t\t\t\t? this.manufacturerData\n\t\t\t\t: new Uint8Array();\n\t\tconst manufacturerDataLength = manufacturerData.length;\n\t\tthis.payload = Bytes.concat([\n\t\t\tBytes.from([\n\t\t\t\t((manufacturerDataLength & 0b111) << 5) + (this.mode & 0b11111),\n\t\t\t]),\n\t\t\tmanufacturerData,\n\t\t]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\tconst message: MessageRecord = {\n\t\t\tmode: getEnumMemberName(ThermostatMode, this.mode),\n\t\t};\n\t\tif (this.manufacturerData != undefined) {\n\t\t\tmessage[\"manufacturer data\"] = buffer2hex(this.manufacturerData);\n\t\t}\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage,\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport type ThermostatModeCCReportOptions =\n\t| {\n\t\tmode: Exclude<\n\t\t\tThermostatMode,\n\t\t\t(typeof ThermostatMode)[\"Manufacturer specific\"]\n\t\t>;\n\t\tmanufacturerData?: undefined;\n\t}\n\t| {\n\t\tmode: (typeof ThermostatMode)[\"Manufacturer specific\"];\n\t\tmanufacturerData?: Uint8Array;\n\t};\n\n@CCCommand(ThermostatModeCommand.Report)\n@ccValueProperty(\"mode\", ThermostatModeCCValues.thermostatMode)\n@ccValueProperty(\"manufacturerData\", ThermostatModeCCValues.manufacturerData)\nexport class ThermostatModeCCReport extends ThermostatModeCC {\n\tpublic constructor(\n\t\toptions: WithAddress<ThermostatModeCCReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\tthis.mode = options.mode;\n\t\tthis.manufacturerData = options.manufacturerData;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): ThermostatModeCCReport {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst mode: ThermostatMode = raw.payload[0] & 0b11111;\n\n\t\tif (mode !== ThermostatMode[\"Manufacturer specific\"]) {\n\t\t\treturn new this({\n\t\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\t\tmode,\n\t\t\t});\n\t\t}\n\n\t\t// V3+\n\t\tconst manufacturerDataLength = raw.payload[0] >>> 5;\n\t\tvalidatePayload(\n\t\t\traw.payload.length >= 1 + manufacturerDataLength,\n\t\t);\n\t\tconst manufacturerData = raw.payload.subarray(\n\t\t\t1,\n\t\t\t1 + manufacturerDataLength,\n\t\t);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tmode,\n\t\t\tmanufacturerData,\n\t\t});\n\t}\n\n\tpublic persistValues(ctx: PersistValuesContext): boolean {\n\t\tif (!super.persistValues(ctx)) return false;\n\n\t\t// Update the supported modes if a mode is used that wasn't previously\n\t\t// reported to be supported. This shouldn't happen, but well... it does anyways\n\t\tconst thermostatModeValue = ThermostatModeCCValues.thermostatMode;\n\t\tconst supportedModesValue = ThermostatModeCCValues.supportedModes;\n\n\t\tconst supportedModes = this.getValue<ThermostatMode[]>(\n\t\t\tctx,\n\t\t\tsupportedModesValue,\n\t\t);\n\n\t\tif (\n\t\t\tsupportedModes\n\t\t\t&& this.mode in ThermostatMode\n\t\t\t&& !supportedModes.includes(this.mode)\n\t\t) {\n\t\t\tsupportedModes.push(this.mode);\n\t\t\tsupportedModes.sort();\n\n\t\t\tthis.setMetadata(ctx, thermostatModeValue, {\n\t\t\t\t...thermostatModeValue.meta,\n\t\t\t\tstates: enumValuesToMetadataStates(\n\t\t\t\t\tThermostatMode,\n\t\t\t\t\tsupportedModes,\n\t\t\t\t),\n\t\t\t});\n\t\t\tthis.setValue(ctx, supportedModesValue, supportedModes);\n\t\t}\n\t\treturn true;\n\t}\n\n\tpublic readonly mode: ThermostatMode;\n\n\tpublic readonly manufacturerData: Uint8Array | undefined;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tconst manufacturerDataLength =\n\t\t\tthis.mode === ThermostatMode[\"Manufacturer specific\"]\n\t\t\t\t&& this.manufacturerData\n\t\t\t\t? Math.min(0b111, this.manufacturerData.length)\n\t\t\t\t: 0;\n\t\tthis.payload = new Bytes(1 + manufacturerDataLength);\n\t\tthis.payload[0] = (manufacturerDataLength << 5) + (this.mode & 0b11111);\n\t\tif (manufacturerDataLength && this.manufacturerData) {\n\t\t\tthis.payload.set(\n\t\t\t\tthis.manufacturerData.subarray(0, manufacturerDataLength),\n\t\t\t\t1,\n\t\t\t);\n\t\t}\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\tconst message: MessageRecord = {\n\t\t\tmode: getEnumMemberName(ThermostatMode, this.mode),\n\t\t};\n\t\tif (this.manufacturerData != undefined) {\n\t\t\tmessage[\"manufacturer data\"] = buffer2hex(this.manufacturerData);\n\t\t}\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage,\n\t\t};\n\t}\n}\n\n@CCCommand(ThermostatModeCommand.Get)\n@expectedCCResponse(ThermostatModeCCReport)\nexport class ThermostatModeCCGet extends ThermostatModeCC {}\n\n// @publicAPI\nexport interface ThermostatModeCCSupportedReportOptions {\n\tsupportedModes: ThermostatMode[];\n}\n\n@CCCommand(ThermostatModeCommand.SupportedReport)\n@ccValueProperty(\"supportedModes\", ThermostatModeCCValues.supportedModes)\nexport class ThermostatModeCCSupportedReport extends ThermostatModeCC {\n\tpublic constructor(\n\t\toptions: WithAddress<ThermostatModeCCSupportedReportOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.supportedModes = options.supportedModes;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): ThermostatModeCCSupportedReport {\n\t\tconst supportedModes: ThermostatMode[] = parseBitMask(\n\t\t\traw.payload,\n\t\t\tThermostatMode.Off,\n\t\t);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tsupportedModes,\n\t\t});\n\t}\n\n\tpublic persistValues(ctx: PersistValuesContext): boolean {\n\t\tif (!super.persistValues(ctx)) return false;\n\n\t\t// Use this information to create the metadata for the mode property\n\t\tconst thermostatModeValue = ThermostatModeCCValues.thermostatMode;\n\t\tthis.setMetadata(ctx, thermostatModeValue, {\n\t\t\t...thermostatModeValue.meta,\n\t\t\tstates: enumValuesToMetadataStates(\n\t\t\t\tThermostatMode,\n\t\t\t\tthis.supportedModes,\n\t\t\t),\n\t\t});\n\n\t\treturn true;\n\t}\n\n\tpublic readonly supportedModes: ThermostatMode[];\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = encodeBitMask(\n\t\t\tthis.supportedModes,\n\t\t\tThermostatMode[\"Manufacturer specific\"],\n\t\t\tThermostatMode.Off,\n\t\t);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: {\n\t\t\t\t\"supported modes\": this.supportedModes\n\t\t\t\t\t.map(\n\t\t\t\t\t\t(mode) =>\n\t\t\t\t\t\t\t`\\n\u00B7 ${getEnumMemberName(ThermostatMode, mode)}`,\n\t\t\t\t\t)\n\t\t\t\t\t.join(\"\"),\n\t\t\t},\n\t\t};\n\t}\n}\n\n@CCCommand(ThermostatModeCommand.SupportedGet)\n@expectedCCResponse(ThermostatModeCCSupportedReport)\nexport class ThermostatModeCCSupportedGet extends ThermostatModeCC {}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,kBAiBO;AACP,oBAA2D;AAE3D,iBAQO;AACP,0BAMO;AACP,oCASO;AACP,oBAAkB;AAClB,mBAAsD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA0BzC,uBAAmB,MAAA;8BAD/B,mCAAI,2BAAe,iBAAiB,CAAC,CAAC;;;;oBACE;;;2CAAA,YAAK;WAAA;;;;;;;;yBAmF5C,qCAAa,EAAE,aAAa,KAAI,CAAE,CAAC;AACpC,mBAAA,MAAA,MAAA,iBAAA,EAAA,MAAA,UAAA,MAAA,OAAA,QAAA,OAAA,SAAA,OAAA,QAAA,EAAA,KAAA,gCAAA,SAAA,KAAA,QAAA,KAAA,gCAAA,IAAa,KAAb,OAAgB,GAAA,UAAA,UAAA,GAAA,MAAA,0BAAA;AApFjB,mBAAA,MAAA,mBAAA,EAAA,OAAA,WAAA,GAAA,kBAAA,EAAA,MAAA,SAAA,MAAA,WAAA,MAAA,UAAA,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IAAI;QACZ;OACA;IACF;IAEO,cAAc,KAAyB;AAC7C,UAAI,CAAC,MAAM,cAAc,GAAG;AAAG,eAAO;AAGtC,YAAM,sBAAsB,iDAAuB;AACnD,WAAK,YAAY,KAAK,qBAAqB;QAC1C,GAAG,oBAAoB;QACvB,YAAQ,wCACP,6BACA,KAAK,cAAc;OAEpB;AAED,aAAO;IACR;IAEgB;IAET,UAAU,KAAsB;AACtC,WAAK,cAAU,2BACd,KAAK,gBACL,4BAAe,uBAAuB,GACtC,4BAAe,GAAG;AAEnB,aAAO,MAAM,UAAU,GAAG;IAC3B;IAEO,WAAW,KAAgB;AACjC,aAAO;QACN,GAAG,MAAM,WAAW,GAAG;QACvB,SAAS;UACR,mBAAmB,KAAK,eACtB,IACA,CAAC,SACA;WAAO,iCAAkB,6BAAgB,IAAI,CAAC,EAAE,EAEjD,KAAK,EAAE;;;IAGZ;;;;IAKY,gCAA4B,MAAA;8BAFxC,yCAAU,mCAAsB,YAAY,OAC5C,kDAAmB,+BAA+B,CAAC;;;;oBACF;oDAAA,YAAgB;WAAA;;;;;;;;AAAlE,mBAAA,MAAA,mBAAA,EAAA,OAAA,WAAA,GAAA,kBAAA,EAAA,MAAA,SAAA,MAAA,WAAA,MAAA,UAAA,UAAA,GAAA,MAAA,uBAAA;;;AAAa,wBAAA,YAAA,uBAAA;;;;;",
4
+ "sourcesContent": ["import type { CCEncodingContext, CCParsingContext } from \"@zwave-js/cc\";\nimport {\n\tCommandClasses,\n\ttype GetValueDB,\n\ttype MaybeNotKnown,\n\ttype MessageOrCCLogEntry,\n\tMessagePriority,\n\ttype MessageRecord,\n\ttype SupervisionResult,\n\tValueMetadata,\n\ttype WithAddress,\n\tZWaveError,\n\tZWaveErrorCodes,\n\tencodeBitMask,\n\tenumValuesToMetadataStates,\n\tparseBitMask,\n\tsupervisedCommandSucceeded,\n\tvalidatePayload,\n} from \"@zwave-js/core\";\nimport {\n\tBytes,\n\ttype BytesView,\n\tbuffer2hex,\n\tgetEnumMemberName,\n\tpick,\n} from \"@zwave-js/shared\";\nimport { validateArgs } from \"@zwave-js/transformers\";\nimport {\n\tCCAPI,\n\tPOLL_VALUE,\n\ttype PollValueImplementation,\n\tSET_VALUE,\n\ttype SetValueImplementation,\n\tthrowUnsupportedProperty,\n\tthrowWrongValueType,\n} from \"../lib/API.js\";\nimport {\n\ttype CCRaw,\n\tCommandClass,\n\ttype InterviewContext,\n\ttype PersistValuesContext,\n\ttype RefreshValuesContext,\n} from \"../lib/CommandClass.js\";\nimport {\n\tAPI,\n\tCCCommand,\n\tccValueProperty,\n\tccValues,\n\tcommandClass,\n\texpectedCCResponse,\n\timplementedVersion,\n\tuseSupervision,\n} from \"../lib/CommandClassDecorators.js\";\nimport { V } from \"../lib/Values.js\";\nimport { ThermostatMode, ThermostatModeCommand } from \"../lib/_Types.js\";\n\nexport const ThermostatModeCCValues = V.defineCCValues(\n\tCommandClasses[\"Thermostat Mode\"],\n\t{\n\t\t...V.staticPropertyWithName(\n\t\t\t\"thermostatMode\",\n\t\t\t\"mode\",\n\t\t\t{\n\t\t\t\t...ValueMetadata.UInt8,\n\t\t\t\tstates: enumValuesToMetadataStates(ThermostatMode),\n\t\t\t\tlabel: \"Thermostat mode\",\n\t\t\t} as const,\n\t\t),\n\t\t...V.staticProperty(\n\t\t\t\"manufacturerData\",\n\t\t\t{\n\t\t\t\t...ValueMetadata.ReadOnlyBuffer,\n\t\t\t\tlabel: \"Manufacturer data\",\n\t\t\t} as const,\n\t\t),\n\t\t...V.staticProperty(\"supportedModes\", undefined, { internal: true }),\n\t},\n);\n\n@API(CommandClasses[\"Thermostat Mode\"])\nexport class ThermostatModeCCAPI extends CCAPI {\n\tpublic supportsCommand(cmd: ThermostatModeCommand): MaybeNotKnown<boolean> {\n\t\tswitch (cmd) {\n\t\t\tcase ThermostatModeCommand.Get:\n\t\t\tcase ThermostatModeCommand.SupportedGet:\n\t\t\t\treturn this.isSinglecast();\n\t\t\tcase ThermostatModeCommand.Set:\n\t\t\t\treturn true; // This is mandatory\n\t\t}\n\t\treturn super.supportsCommand(cmd);\n\t}\n\n\tprotected override get [SET_VALUE](): SetValueImplementation {\n\t\treturn async function(this: ThermostatModeCCAPI, { property }, value) {\n\t\t\tif (property !== \"mode\") {\n\t\t\t\tthrowUnsupportedProperty(this.ccId, property);\n\t\t\t}\n\t\t\tif (typeof value !== \"number\") {\n\t\t\t\tthrowWrongValueType(\n\t\t\t\t\tthis.ccId,\n\t\t\t\t\tproperty,\n\t\t\t\t\t\"number\",\n\t\t\t\t\ttypeof value,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst result = await this.set(value);\n\n\t\t\t// Verify the current value after a delay, unless the command was supervised and successful\n\t\t\tif (this.isSinglecast() && !supervisedCommandSucceeded(result)) {\n\t\t\t\t// TODO: Ideally this would be a short delay, but some thermostats like Remotec ZXT-600\n\t\t\t\t// aren't able to handle the GET this quickly.\n\t\t\t\tthis.schedulePoll({ property }, value);\n\t\t\t}\n\n\t\t\treturn result;\n\t\t};\n\t}\n\n\tprotected get [POLL_VALUE](): PollValueImplementation {\n\t\treturn async function(this: ThermostatModeCCAPI, { property }) {\n\t\t\tswitch (property) {\n\t\t\t\tcase \"mode\":\n\t\t\t\t\treturn (await this.get())?.[property];\n\n\t\t\t\tdefault:\n\t\t\t\t\tthrowUnsupportedProperty(this.ccId, property);\n\t\t\t}\n\t\t};\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n\tpublic async get() {\n\t\tthis.assertSupportsCommand(\n\t\t\tThermostatModeCommand,\n\t\t\tThermostatModeCommand.Get,\n\t\t);\n\n\t\tconst cc = new ThermostatModeCCGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tconst response = await this.host.sendCommand<\n\t\t\tThermostatModeCCReport\n\t\t>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\tif (response) {\n\t\t\treturn pick(response, [\"mode\", \"manufacturerData\"]);\n\t\t}\n\t}\n\n\tpublic async set(\n\t\tmode: Exclude<\n\t\t\tThermostatMode,\n\t\t\t(typeof ThermostatMode)[\"Manufacturer specific\"]\n\t\t>,\n\t): Promise<SupervisionResult | undefined>;\n\tpublic async set(\n\t\tmode: (typeof ThermostatMode)[\"Manufacturer specific\"],\n\t\tmanufacturerData: BytesView | string,\n\t): Promise<SupervisionResult | undefined>;\n\n\t@validateArgs({ strictEnums: true })\n\tpublic async set(\n\t\tmode: ThermostatMode,\n\t\tmanufacturerData?: BytesView | string,\n\t): Promise<SupervisionResult | undefined> {\n\t\tthis.assertSupportsCommand(\n\t\t\tThermostatModeCommand,\n\t\t\tThermostatModeCommand.Set,\n\t\t);\n\n\t\tif (typeof manufacturerData === \"string\") {\n\t\t\t// We accept the manufacturer data as a hex string. Make sure it's valid\n\t\t\tif (\n\t\t\t\tmanufacturerData.length % 2 !== 0\n\t\t\t\t|| !/^[0-9a-f]+$/i.test(manufacturerData)\n\t\t\t) {\n\t\t\t\tthrow new ZWaveError(\n\t\t\t\t\t`Manufacturer data must be represented as hexadecimal when passed as a string!`,\n\t\t\t\t\tZWaveErrorCodes.Argument_Invalid,\n\t\t\t\t);\n\t\t\t}\n\t\t\tmanufacturerData = Bytes.from(manufacturerData, \"hex\");\n\t\t}\n\n\t\tconst cc = new ThermostatModeCCSet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tmode,\n\t\t\tmanufacturerData: manufacturerData as any,\n\t\t});\n\t\treturn this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\tpublic async getSupportedModes(): Promise<\n\t\tMaybeNotKnown<readonly ThermostatMode[]>\n\t> {\n\t\tthis.assertSupportsCommand(\n\t\t\tThermostatModeCommand,\n\t\t\tThermostatModeCommand.SupportedGet,\n\t\t);\n\n\t\tconst cc = new ThermostatModeCCSupportedGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tconst response = await this.host.sendCommand<\n\t\t\tThermostatModeCCSupportedReport\n\t\t>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\treturn response?.supportedModes;\n\t}\n}\n\n@commandClass(CommandClasses[\"Thermostat Mode\"])\n@implementedVersion(3)\n@ccValues(ThermostatModeCCValues)\nexport class ThermostatModeCC extends CommandClass {\n\tdeclare ccCommand: ThermostatModeCommand;\n\n\tpublic async interview(\n\t\tctx: InterviewContext,\n\t): Promise<void> {\n\t\tconst node = this.getNode(ctx)!;\n\t\tconst endpoint = this.getEndpoint(ctx)!;\n\t\tconst api = CCAPI.create(\n\t\t\tCommandClasses[\"Thermostat Mode\"],\n\t\t\tctx,\n\t\t\tendpoint,\n\t\t).withOptions({\n\t\t\tpriority: MessagePriority.NodeQuery,\n\t\t});\n\n\t\tctx.logNode(node.id, {\n\t\t\tendpoint: this.endpointIndex,\n\t\t\tmessage: `Interviewing ${this.ccName}...`,\n\t\t\tdirection: \"none\",\n\t\t});\n\n\t\t// First query the possible modes to set the metadata\n\t\tctx.logNode(node.id, {\n\t\t\tendpoint: this.endpointIndex,\n\t\t\tmessage: \"querying supported thermostat modes...\",\n\t\t\tdirection: \"outbound\",\n\t\t});\n\n\t\tconst supportedModes = await api.getSupportedModes();\n\t\tif (supportedModes) {\n\t\t\tconst logMessage = `received supported thermostat modes:${\n\t\t\t\tsupportedModes\n\t\t\t\t\t.map((mode) =>\n\t\t\t\t\t\t`\\n\u00B7 ${getEnumMemberName(ThermostatMode, mode)}`\n\t\t\t\t\t)\n\t\t\t\t\t.join(\"\")\n\t\t\t}`;\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\tmessage: logMessage,\n\t\t\t\tdirection: \"inbound\",\n\t\t\t});\n\t\t} else {\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\tmessage:\n\t\t\t\t\t\"Querying supported thermostat modes timed out, skipping interview...\",\n\t\t\t\tlevel: \"warn\",\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tawait this.refreshValues(ctx);\n\n\t\t// Remember that the interview is complete\n\t\tthis.setInterviewComplete(ctx, true);\n\t}\n\n\tpublic async refreshValues(\n\t\tctx: RefreshValuesContext,\n\t): Promise<void> {\n\t\tconst node = this.getNode(ctx)!;\n\t\tconst endpoint = this.getEndpoint(ctx)!;\n\t\tconst api = CCAPI.create(\n\t\t\tCommandClasses[\"Thermostat Mode\"],\n\t\t\tctx,\n\t\t\tendpoint,\n\t\t).withOptions({\n\t\t\tpriority: MessagePriority.NodeQuery,\n\t\t});\n\n\t\t// Query the current status\n\t\tctx.logNode(node.id, {\n\t\t\tendpoint: this.endpointIndex,\n\t\t\tmessage: \"querying current thermostat mode...\",\n\t\t\tdirection: \"outbound\",\n\t\t});\n\t\tconst currentStatus = await api.get();\n\t\tif (currentStatus) {\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\tmessage: \"received current thermostat mode: \"\n\t\t\t\t\t+ getEnumMemberName(ThermostatMode, currentStatus.mode),\n\t\t\t\tdirection: \"inbound\",\n\t\t\t});\n\t\t}\n\t}\n}\n\n// @publicAPI\nexport type ThermostatModeCCSetOptions =\n\t| {\n\t\tmode: Exclude<\n\t\t\tThermostatMode,\n\t\t\t(typeof ThermostatMode)[\"Manufacturer specific\"]\n\t\t>;\n\t}\n\t| {\n\t\tmode: (typeof ThermostatMode)[\"Manufacturer specific\"];\n\t\tmanufacturerData: BytesView;\n\t};\n\n@CCCommand(ThermostatModeCommand.Set)\n@useSupervision()\nexport class ThermostatModeCCSet extends ThermostatModeCC {\n\tpublic constructor(\n\t\toptions: WithAddress<ThermostatModeCCSetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.mode = options.mode;\n\t\tif (\"manufacturerData\" in options) {\n\t\t\tthis.manufacturerData = options.manufacturerData;\n\t\t}\n\t}\n\n\tpublic static from(raw: CCRaw, ctx: CCParsingContext): ThermostatModeCCSet {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst mode: ThermostatMode = raw.payload[0] & 0b11111;\n\t\tif (mode !== ThermostatMode[\"Manufacturer specific\"]) {\n\t\t\treturn new this({\n\t\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\t\tmode,\n\t\t\t});\n\t\t}\n\n\t\tconst manufacturerDataLength = (raw.payload[0] >>> 5) & 0b111;\n\t\tvalidatePayload(\n\t\t\traw.payload.length >= 1 + manufacturerDataLength,\n\t\t);\n\t\tconst manufacturerData = raw.payload.subarray(\n\t\t\t1,\n\t\t\t1 + manufacturerDataLength,\n\t\t);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tmode,\n\t\t\tmanufacturerData,\n\t\t});\n\t}\n\n\tpublic mode: ThermostatMode;\n\tpublic manufacturerData?: BytesView;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tconst manufacturerData =\n\t\t\tthis.mode === ThermostatMode[\"Manufacturer specific\"]\n\t\t\t\t&& this.manufacturerData\n\t\t\t\t? this.manufacturerData\n\t\t\t\t: new Uint8Array();\n\t\tconst manufacturerDataLength = manufacturerData.length;\n\t\tthis.payload = Bytes.concat([\n\t\t\tBytes.from([\n\t\t\t\t((manufacturerDataLength & 0b111) << 5) + (this.mode & 0b11111),\n\t\t\t]),\n\t\t\tmanufacturerData,\n\t\t]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\tconst message: MessageRecord = {\n\t\t\tmode: getEnumMemberName(ThermostatMode, this.mode),\n\t\t};\n\t\tif (this.manufacturerData != undefined) {\n\t\t\tmessage[\"manufacturer data\"] = buffer2hex(this.manufacturerData);\n\t\t}\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage,\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport type ThermostatModeCCReportOptions =\n\t| {\n\t\tmode: Exclude<\n\t\t\tThermostatMode,\n\t\t\t(typeof ThermostatMode)[\"Manufacturer specific\"]\n\t\t>;\n\t\tmanufacturerData?: undefined;\n\t}\n\t| {\n\t\tmode: (typeof ThermostatMode)[\"Manufacturer specific\"];\n\t\tmanufacturerData?: BytesView;\n\t};\n\n@CCCommand(ThermostatModeCommand.Report)\n@ccValueProperty(\"mode\", ThermostatModeCCValues.thermostatMode)\n@ccValueProperty(\"manufacturerData\", ThermostatModeCCValues.manufacturerData)\nexport class ThermostatModeCCReport extends ThermostatModeCC {\n\tpublic constructor(\n\t\toptions: WithAddress<ThermostatModeCCReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\tthis.mode = options.mode;\n\t\tthis.manufacturerData = options.manufacturerData;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): ThermostatModeCCReport {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst mode: ThermostatMode = raw.payload[0] & 0b11111;\n\n\t\tif (mode !== ThermostatMode[\"Manufacturer specific\"]) {\n\t\t\treturn new this({\n\t\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\t\tmode,\n\t\t\t});\n\t\t}\n\n\t\t// V3+\n\t\tconst manufacturerDataLength = raw.payload[0] >>> 5;\n\t\tvalidatePayload(\n\t\t\traw.payload.length >= 1 + manufacturerDataLength,\n\t\t);\n\t\tconst manufacturerData = raw.payload.subarray(\n\t\t\t1,\n\t\t\t1 + manufacturerDataLength,\n\t\t);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tmode,\n\t\t\tmanufacturerData,\n\t\t});\n\t}\n\n\tpublic persistValues(ctx: PersistValuesContext): boolean {\n\t\tif (!super.persistValues(ctx)) return false;\n\n\t\t// Update the supported modes if a mode is used that wasn't previously\n\t\t// reported to be supported. This shouldn't happen, but well... it does anyways\n\t\tconst thermostatModeValue = ThermostatModeCCValues.thermostatMode;\n\t\tconst supportedModesValue = ThermostatModeCCValues.supportedModes;\n\n\t\tconst supportedModes = this.getValue<ThermostatMode[]>(\n\t\t\tctx,\n\t\t\tsupportedModesValue,\n\t\t);\n\n\t\tif (\n\t\t\tsupportedModes\n\t\t\t&& this.mode in ThermostatMode\n\t\t\t&& !supportedModes.includes(this.mode)\n\t\t) {\n\t\t\tsupportedModes.push(this.mode);\n\t\t\tsupportedModes.sort();\n\n\t\t\tthis.setMetadata(ctx, thermostatModeValue, {\n\t\t\t\t...thermostatModeValue.meta,\n\t\t\t\tstates: enumValuesToMetadataStates(\n\t\t\t\t\tThermostatMode,\n\t\t\t\t\tsupportedModes,\n\t\t\t\t),\n\t\t\t});\n\t\t\tthis.setValue(ctx, supportedModesValue, supportedModes);\n\t\t}\n\t\treturn true;\n\t}\n\n\tpublic readonly mode: ThermostatMode;\n\n\tpublic readonly manufacturerData: BytesView | undefined;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tconst manufacturerDataLength =\n\t\t\tthis.mode === ThermostatMode[\"Manufacturer specific\"]\n\t\t\t\t&& this.manufacturerData\n\t\t\t\t? Math.min(0b111, this.manufacturerData.length)\n\t\t\t\t: 0;\n\t\tthis.payload = new Bytes(1 + manufacturerDataLength);\n\t\tthis.payload[0] = (manufacturerDataLength << 5) + (this.mode & 0b11111);\n\t\tif (manufacturerDataLength && this.manufacturerData) {\n\t\t\tthis.payload.set(\n\t\t\t\tthis.manufacturerData.subarray(0, manufacturerDataLength),\n\t\t\t\t1,\n\t\t\t);\n\t\t}\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\tconst message: MessageRecord = {\n\t\t\tmode: getEnumMemberName(ThermostatMode, this.mode),\n\t\t};\n\t\tif (this.manufacturerData != undefined) {\n\t\t\tmessage[\"manufacturer data\"] = buffer2hex(this.manufacturerData);\n\t\t}\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage,\n\t\t};\n\t}\n}\n\n@CCCommand(ThermostatModeCommand.Get)\n@expectedCCResponse(ThermostatModeCCReport)\nexport class ThermostatModeCCGet extends ThermostatModeCC {}\n\n// @publicAPI\nexport interface ThermostatModeCCSupportedReportOptions {\n\tsupportedModes: ThermostatMode[];\n}\n\n@CCCommand(ThermostatModeCommand.SupportedReport)\n@ccValueProperty(\"supportedModes\", ThermostatModeCCValues.supportedModes)\nexport class ThermostatModeCCSupportedReport extends ThermostatModeCC {\n\tpublic constructor(\n\t\toptions: WithAddress<ThermostatModeCCSupportedReportOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.supportedModes = options.supportedModes;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): ThermostatModeCCSupportedReport {\n\t\tconst supportedModes: ThermostatMode[] = parseBitMask(\n\t\t\traw.payload,\n\t\t\tThermostatMode.Off,\n\t\t);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tsupportedModes,\n\t\t});\n\t}\n\n\tpublic persistValues(ctx: PersistValuesContext): boolean {\n\t\tif (!super.persistValues(ctx)) return false;\n\n\t\t// Use this information to create the metadata for the mode property\n\t\tconst thermostatModeValue = ThermostatModeCCValues.thermostatMode;\n\t\tthis.setMetadata(ctx, thermostatModeValue, {\n\t\t\t...thermostatModeValue.meta,\n\t\t\tstates: enumValuesToMetadataStates(\n\t\t\t\tThermostatMode,\n\t\t\t\tthis.supportedModes,\n\t\t\t),\n\t\t});\n\n\t\treturn true;\n\t}\n\n\tpublic readonly supportedModes: ThermostatMode[];\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = encodeBitMask(\n\t\t\tthis.supportedModes,\n\t\t\tThermostatMode[\"Manufacturer specific\"],\n\t\t\tThermostatMode.Off,\n\t\t);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: {\n\t\t\t\t\"supported modes\": this.supportedModes\n\t\t\t\t\t.map(\n\t\t\t\t\t\t(mode) =>\n\t\t\t\t\t\t\t`\\n\u00B7 ${getEnumMemberName(ThermostatMode, mode)}`,\n\t\t\t\t\t)\n\t\t\t\t\t.join(\"\"),\n\t\t\t},\n\t\t};\n\t}\n}\n\n@CCCommand(ThermostatModeCommand.SupportedGet)\n@expectedCCResponse(ThermostatModeCCSupportedReport)\nexport class ThermostatModeCCSupportedGet extends ThermostatModeCC {}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,kBAiBO;AACP,oBAMO;AAEP,iBAQO;AACP,0BAMO;AACP,oCASO;AACP,oBAAkB;AAClB,mBAAsD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA0BzC,uBAAmB,MAAA;8BAD/B,mCAAI,2BAAe,iBAAiB,CAAC,CAAC;;;;oBACE;;;2CAAA,YAAK;WAAA;;;;;;;;yBAmF5C,qCAAa,EAAE,aAAa,KAAI,CAAE,CAAC;AACpC,mBAAA,MAAA,MAAA,iBAAA,EAAA,MAAA,UAAA,MAAA,OAAA,QAAA,OAAA,SAAA,OAAA,QAAA,EAAA,KAAA,gCAAA,SAAA,KAAA,QAAA,KAAA,gCAAA,IAAa,KAAb,OAAgB,GAAA,UAAA,UAAA,GAAA,MAAA,0BAAA;AApFjB,mBAAA,MAAA,mBAAA,EAAA,OAAA,WAAA,GAAA,kBAAA,EAAA,MAAA,SAAA,MAAA,WAAA,MAAA,UAAA,UAAA,GAAA,MAAA,uBAAA;;;AAAa,wBAAA,YAAA,uBAAA;;IACL,gBAAgB,KAA0B;AAChD,cAAQ,KAAK;QACZ,KAAK,mCAAsB;QAC3B,KAAK,mCAAsB;AAC1B,iBAAO,KAAK,aAAY;QACzB,KAAK,mCAAsB;AAC1B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P,6BACA,KAAK,cAAc;OAEpB;AAED,aAAO;IACR;IAEgB;IAET,UAAU,KAAsB;AACtC,WAAK,cAAU,2BACd,KAAK,gBACL,4BAAe,uBAAuB,GACtC,4BAAe,GAAG;AAEnB,aAAO,MAAM,UAAU,GAAG;IAC3B;IAEO,WAAW,KAAgB;AACjC,aAAO;QACN,GAAG,MAAM,WAAW,GAAG;QACvB,SAAS;UACR,mBAAmB,KAAK,eACtB,IACA,CAAC,SACA;WAAO,iCAAkB,6BAAgB,IAAI,CAAC,EAAE,EAEjD,KAAK,EAAE;;;IAGZ;;;;IAKY,gCAA4B,MAAA;8BAFxC,yCAAU,mCAAsB,YAAY,OAC5C,kDAAmB,+BAA+B,CAAC;;;;oBACF;oDAAA,YAAgB;WAAA;;;;;;;;AAAlE,mBAAA,MAAA,mBAAA,EAAA,OAAA,WAAA,GAAA,kBAAA,EAAA,MAAA,SAAA,MAAA,WAAA,MAAA,UAAA,UAAA,GAAA,MAAA,uBAAA;;;AAAa,wBAAA,YAAA,uBAAA;;;;;",
6
6
  "names": []
7
7
  }
@@ -1,6 +1,6 @@
1
1
  import type { CCEncodingContext, CCParsingContext } from "@zwave-js/cc";
2
2
  import { type GetValueDB, type MessageOrCCLogEntry, type SinglecastCC, type WithAddress } from "@zwave-js/core";
3
- import { Bytes } from "@zwave-js/shared";
3
+ import { Bytes, type BytesView } from "@zwave-js/shared";
4
4
  import { type CCRaw, CommandClass } from "../lib/CommandClass.js";
5
5
  import { TransportServiceCommand } from "../lib/_Types.js";
6
6
  export declare const MAX_SEGMENT_SIZE = 39;
@@ -27,8 +27,8 @@ export declare class TransportServiceCC extends CommandClass implements Singleca
27
27
  export interface TransportServiceCCFirstSegmentOptions {
28
28
  datagramSize: number;
29
29
  sessionId: number;
30
- headerExtension?: Uint8Array | undefined;
31
- partialDatagram: Uint8Array;
30
+ headerExtension?: BytesView | undefined;
31
+ partialDatagram: BytesView;
32
32
  }
33
33
  /** @publicAPI */
34
34
  export declare function isTransportServiceEncapsulation(command: CommandClass): command is TransportServiceCCFirstSegment | TransportServiceCCSubsequentSegment;
@@ -37,8 +37,8 @@ export declare class TransportServiceCCFirstSegment extends TransportServiceCC {
37
37
  static from(raw: CCRaw, ctx: CCParsingContext): TransportServiceCCFirstSegment;
38
38
  datagramSize: number;
39
39
  sessionId: number;
40
- headerExtension: Uint8Array | undefined;
41
- partialDatagram: Uint8Array;
40
+ headerExtension: BytesView | undefined;
41
+ partialDatagram: BytesView;
42
42
  encapsulated: CommandClass;
43
43
  serialize(ctx: CCEncodingContext): Promise<Bytes>;
44
44
  expectMoreMessages(): boolean;
@@ -55,8 +55,8 @@ export declare class TransportServiceCCSubsequentSegment extends TransportServic
55
55
  datagramSize: number;
56
56
  datagramOffset: number;
57
57
  sessionId: number;
58
- headerExtension: Uint8Array | undefined;
59
- partialDatagram: Uint8Array;
58
+ headerExtension: BytesView | undefined;
59
+ partialDatagram: BytesView;
60
60
  private _encapsulated;
61
61
  get encapsulated(): CommandClass;
62
62
  expectMoreMessages(session: [