@zwave-js/cc 14.0.0 → 14.1.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 (122) hide show
  1. package/build/cjs/cc/AssociationCC.js +1 -1
  2. package/build/cjs/cc/AssociationCC.js.map +1 -1
  3. package/build/cjs/cc/CentralSceneCC.js +2 -3
  4. package/build/cjs/cc/CentralSceneCC.js.map +2 -2
  5. package/build/cjs/cc/ClimateControlScheduleCC.js +5 -6
  6. package/build/cjs/cc/ClimateControlScheduleCC.js.map +2 -2
  7. package/build/cjs/cc/ClockCC.js +2 -3
  8. package/build/cjs/cc/ClockCC.js.map +2 -2
  9. package/build/cjs/cc/ColorSwitchCC.js +2 -2
  10. package/build/cjs/cc/ColorSwitchCC.js.map +1 -1
  11. package/build/cjs/cc/ConfigurationCC.js +4 -6
  12. package/build/cjs/cc/ConfigurationCC.js.map +2 -2
  13. package/build/cjs/cc/DoorLockCC.js +1 -1
  14. package/build/cjs/cc/DoorLockCC.js.map +1 -1
  15. package/build/cjs/cc/IndicatorCC.js +2 -2
  16. package/build/cjs/cc/IndicatorCC.js.map +1 -1
  17. package/build/cjs/cc/IrrigationCC.js +7 -8
  18. package/build/cjs/cc/IrrigationCC.js.map +2 -2
  19. package/build/cjs/cc/MultiChannelCC.js +1 -1
  20. package/build/cjs/cc/MultiChannelCC.js.map +1 -1
  21. package/build/cjs/cc/NotificationCC.js +1 -1
  22. package/build/cjs/cc/NotificationCC.js.map +1 -1
  23. package/build/cjs/cc/ProtectionCC.js +1 -2
  24. package/build/cjs/cc/ProtectionCC.js.map +2 -2
  25. package/build/cjs/cc/Security2CC.js +2 -2
  26. package/build/cjs/cc/Security2CC.js.map +1 -1
  27. package/build/cjs/cc/SecurityCC.js +1 -1
  28. package/build/cjs/cc/SecurityCC.js.map +1 -1
  29. package/build/cjs/cc/SoundSwitchCC.js +1 -1
  30. package/build/cjs/cc/SoundSwitchCC.js.map +1 -1
  31. package/build/cjs/cc/ThermostatSetbackCC.js +6 -8
  32. package/build/cjs/cc/ThermostatSetbackCC.js.map +2 -2
  33. package/build/cjs/cc/TimeCC.js +2 -3
  34. package/build/cjs/cc/TimeCC.js.map +2 -2
  35. package/build/cjs/cc/WakeUpCC.js +1 -1
  36. package/build/cjs/cc/WakeUpCC.js.map +1 -1
  37. package/build/cjs/cc/manufacturerProprietary/FibaroCC.js +1 -1
  38. package/build/cjs/cc/manufacturerProprietary/FibaroCC.js.map +1 -1
  39. package/build/cjs/index_browser.d.ts +8 -0
  40. package/build/cjs/index_browser.js +40 -0
  41. package/build/cjs/index_browser.js.map +7 -0
  42. package/build/cjs/lib/API.js +1 -1
  43. package/build/cjs/lib/API.js.map +1 -1
  44. package/build/cjs/lib/CommandClass.js +1 -1
  45. package/build/cjs/lib/CommandClass.js.map +1 -1
  46. package/build/cjs/lib/EncapsulatingCommandClass.js +1 -1
  47. package/build/cjs/lib/EncapsulatingCommandClass.js.map +1 -1
  48. package/build/cjs/lib/Values.d.ts +2 -2
  49. package/build/cjs/lib/Values.js +9 -9
  50. package/build/cjs/lib/Values.js.map +3 -3
  51. package/build/cjs/lib/serializers.d.ts +2 -2
  52. package/build/cjs/lib/serializers.js +19 -10
  53. package/build/cjs/lib/serializers.js.map +2 -2
  54. package/build/cjs/lib/utils.js +1 -1
  55. package/build/cjs/lib/utils.js.map +1 -1
  56. package/build/esm/cc/AssociationCC.js +1 -1
  57. package/build/esm/cc/AssociationCC.js.map +1 -1
  58. package/build/esm/cc/CentralSceneCC.d.ts.map +1 -1
  59. package/build/esm/cc/CentralSceneCC.js +2 -3
  60. package/build/esm/cc/CentralSceneCC.js.map +1 -1
  61. package/build/esm/cc/ClimateControlScheduleCC.d.ts.map +1 -1
  62. package/build/esm/cc/ClimateControlScheduleCC.js +7 -7
  63. package/build/esm/cc/ClimateControlScheduleCC.js.map +1 -1
  64. package/build/esm/cc/ClockCC.d.ts.map +1 -1
  65. package/build/esm/cc/ClockCC.js +2 -3
  66. package/build/esm/cc/ClockCC.js.map +1 -1
  67. package/build/esm/cc/ColorSwitchCC.js +2 -2
  68. package/build/esm/cc/ColorSwitchCC.js.map +1 -1
  69. package/build/esm/cc/ConfigurationCC.d.ts.map +1 -1
  70. package/build/esm/cc/ConfigurationCC.js +4 -6
  71. package/build/esm/cc/ConfigurationCC.js.map +1 -1
  72. package/build/esm/cc/DoorLockCC.js +1 -1
  73. package/build/esm/cc/DoorLockCC.js.map +1 -1
  74. package/build/esm/cc/IndicatorCC.js +2 -2
  75. package/build/esm/cc/IndicatorCC.js.map +1 -1
  76. package/build/esm/cc/IrrigationCC.d.ts.map +1 -1
  77. package/build/esm/cc/IrrigationCC.js +7 -8
  78. package/build/esm/cc/IrrigationCC.js.map +1 -1
  79. package/build/esm/cc/MultiChannelCC.js +1 -1
  80. package/build/esm/cc/MultiChannelCC.js.map +1 -1
  81. package/build/esm/cc/NotificationCC.js +1 -1
  82. package/build/esm/cc/NotificationCC.js.map +1 -1
  83. package/build/esm/cc/ProtectionCC.d.ts.map +1 -1
  84. package/build/esm/cc/ProtectionCC.js +1 -2
  85. package/build/esm/cc/ProtectionCC.js.map +1 -1
  86. package/build/esm/cc/Security2CC.js +2 -2
  87. package/build/esm/cc/Security2CC.js.map +1 -1
  88. package/build/esm/cc/SecurityCC.js +1 -1
  89. package/build/esm/cc/SecurityCC.js.map +1 -1
  90. package/build/esm/cc/SoundSwitchCC.js +1 -1
  91. package/build/esm/cc/SoundSwitchCC.js.map +1 -1
  92. package/build/esm/cc/ThermostatSetbackCC.d.ts.map +1 -1
  93. package/build/esm/cc/ThermostatSetbackCC.js +10 -12
  94. package/build/esm/cc/ThermostatSetbackCC.js.map +1 -1
  95. package/build/esm/cc/TimeCC.d.ts.map +1 -1
  96. package/build/esm/cc/TimeCC.js +2 -3
  97. package/build/esm/cc/TimeCC.js.map +1 -1
  98. package/build/esm/cc/WakeUpCC.js +1 -1
  99. package/build/esm/cc/WakeUpCC.js.map +1 -1
  100. package/build/esm/cc/manufacturerProprietary/FibaroCC.js +1 -1
  101. package/build/esm/cc/manufacturerProprietary/FibaroCC.js.map +1 -1
  102. package/build/esm/index_browser.d.ts +8 -0
  103. package/build/esm/index_browser.d.ts.map +1 -0
  104. package/build/esm/index_browser.js +8 -0
  105. package/build/esm/index_browser.js.map +1 -0
  106. package/build/esm/lib/API.js +1 -1
  107. package/build/esm/lib/API.js.map +1 -1
  108. package/build/esm/lib/CommandClass.js +1 -1
  109. package/build/esm/lib/CommandClass.js.map +1 -1
  110. package/build/esm/lib/EncapsulatingCommandClass.js +1 -1
  111. package/build/esm/lib/EncapsulatingCommandClass.js.map +1 -1
  112. package/build/esm/lib/Values.d.ts +2 -2
  113. package/build/esm/lib/Values.d.ts.map +1 -1
  114. package/build/esm/lib/Values.js +1 -1
  115. package/build/esm/lib/Values.js.map +1 -1
  116. package/build/esm/lib/serializers.d.ts +2 -2
  117. package/build/esm/lib/serializers.d.ts.map +1 -1
  118. package/build/esm/lib/serializers.js +20 -10
  119. package/build/esm/lib/serializers.js.map +1 -1
  120. package/build/esm/lib/utils.js +1 -1
  121. package/build/esm/lib/utils.js.map +1 -1
  122. package/package.json +8 -7
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/cc/SecurityCC.ts"],
4
- "sourcesContent": ["import {\n\tCommandClasses,\n\tEncapsulationFlags,\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\tvalidatePayload,\n} from \"@zwave-js/core\";\nimport { type MaybeNotKnown } from \"@zwave-js/core/safe\";\nimport type {\n\tCCEncodingContext,\n\tCCParsingContext,\n\tGetValueDB,\n} from \"@zwave-js/host/safe\";\nimport { Bytes } from \"@zwave-js/shared/safe\";\nimport { buffer2hex, num2hex, pick } from \"@zwave-js/shared/safe\";\nimport { wait } from \"alcalzone-shared/async/index.js\";\nimport { randomBytes } from \"node:crypto\";\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): 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 from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): 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 = computeMAC(\n\t\t\tauthData,\n\t\t\tctx.securityManager.authKey,\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 = decryptAES128OFB(\n\t\t\tencryptedPayload,\n\t\t\tctx.securityManager.encryptionKey,\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 mergePartialCCs(\n\t\tpartials: SecurityCCCommandEncapsulation[],\n\t\tctx: CCParsingContext,\n\t): 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 = CommandClass.parse(this.decryptedCCBytes, ctx);\n\t\tthis.encapsulated.encapsulatingCC = this as any;\n\t}\n\n\tpublic serialize(ctx: CCEncodingContext): 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 = generateAuthKey(this.alternativeNetworkKey);\n\t\t\tencryptionKey = generateEncryptionKey(\n\t\t\t\tthis.alternativeNetworkKey,\n\t\t\t);\n\t\t} else {\n\t\t\tauthKey = ctx.securityManager.authKey;\n\t\t\tencryptionKey = ctx.securityManager.encryptionKey;\n\t\t}\n\n\t\tconst serializedCC = 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 = encryptAES128OFB(plaintext, encryptionKey, iv);\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 = 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): 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 serialize(ctx: CCEncodingContext): 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 serialize(ctx: CCEncodingContext): 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): 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): 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}\n\n\tpublic serialize(ctx: CCEncodingContext): 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"],
4
+ "sourcesContent": ["import {\n\tCommandClasses,\n\tEncapsulationFlags,\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\tvalidatePayload,\n} from \"@zwave-js/core\";\nimport { type MaybeNotKnown } from \"@zwave-js/core/safe\";\nimport type {\n\tCCEncodingContext,\n\tCCParsingContext,\n\tGetValueDB,\n} from \"@zwave-js/host/safe\";\nimport { Bytes } from \"@zwave-js/shared/safe\";\nimport { buffer2hex, num2hex, pick } from \"@zwave-js/shared/safe\";\nimport { wait } from \"alcalzone-shared/async\";\nimport { randomBytes } from \"node:crypto\";\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): 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 from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): 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 = computeMAC(\n\t\t\tauthData,\n\t\t\tctx.securityManager.authKey,\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 = decryptAES128OFB(\n\t\t\tencryptedPayload,\n\t\t\tctx.securityManager.encryptionKey,\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 mergePartialCCs(\n\t\tpartials: SecurityCCCommandEncapsulation[],\n\t\tctx: CCParsingContext,\n\t): 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 = CommandClass.parse(this.decryptedCCBytes, ctx);\n\t\tthis.encapsulated.encapsulatingCC = this as any;\n\t}\n\n\tpublic serialize(ctx: CCEncodingContext): 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 = generateAuthKey(this.alternativeNetworkKey);\n\t\t\tencryptionKey = generateEncryptionKey(\n\t\t\t\tthis.alternativeNetworkKey,\n\t\t\t);\n\t\t} else {\n\t\t\tauthKey = ctx.securityManager.authKey;\n\t\t\tencryptionKey = ctx.securityManager.encryptionKey;\n\t\t}\n\n\t\tconst serializedCC = 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 = encryptAES128OFB(plaintext, encryptionKey, iv);\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 = 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): 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 serialize(ctx: CCEncodingContext): 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 serialize(ctx: CCEncodingContext): 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): 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): 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}\n\n\tpublic serialize(ctx: CCEncodingContext): 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
5
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kBAsBO;AAOP,kBAAsB;AACtB,IAAAA,eAA0C;AAC1C,mBAAqB;AACrB,yBAA4B;AAC5B,iBAAqC;AACrC,0BAIO;AACP,oCAMO;AACP,mBAAgC;AAChC,qBAAwB;AACxB,yBAA4B;AAC5B,gCAAmC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAInC,SAAS,sBACR,aACA,eACA,WACA,eACA,iBACA,kBAA4B;AAE5B,SAAO,kBAAM,OAAO;IACnB;IACA;IACA,kBAAM,KAAK;MACV;MACA;MACA;MACA,iBAAiB;KACjB;IACD;GACA;AACF;AAEA,SAAS,aAAa,QAAe;AACpC,MAAI,UAAU;AACd,MAAI;AAAQ,eAAW,YAAY,MAAM;AACzC,QAAM,IAAI,uBAAW,SAAS,4BAAgB,kBAAkB;AACjE;AAEA,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;AAEA,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;E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wBAAA,YAAA,uBAAA;;;;;",
6
6
  "names": ["import_safe", "SecurityCC", "SecurityCCCommandEncapsulation"]
7
7
  }
@@ -36,7 +36,7 @@ module.exports = __toCommonJS(SoundSwitchCC_exports);
36
36
  var import_safe = require("@zwave-js/core/safe");
37
37
  var import_safe2 = require("@zwave-js/shared/safe");
38
38
  var import_safe3 = require("@zwave-js/shared/safe");
39
- var import_math = require("alcalzone-shared/math/index.js");
39
+ var import_math = require("alcalzone-shared/math");
40
40
  var import_API = require("../lib/API.js");
41
41
  var import_CommandClass = require("../lib/CommandClass.js");
42
42
  var import_CommandClassDecorators = require("../lib/CommandClassDecorators.js");
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/cc/SoundSwitchCC.ts"],
4
- "sourcesContent": ["import {\n\tCommandClasses,\n\ttype MaybeNotKnown,\n\ttype MessageOrCCLogEntry,\n\tMessagePriority,\n\ttype MessageRecord,\n\ttype SupervisionResult,\n\tValueMetadata,\n\ttype WithAddress,\n\tZWaveError,\n\tZWaveErrorCodes,\n\tsupervisedCommandSucceeded,\n\tvalidatePayload,\n} from \"@zwave-js/core/safe\";\nimport type {\n\tCCEncodingContext,\n\tCCParsingContext,\n\tGetValueDB,\n} from \"@zwave-js/host/safe\";\nimport { Bytes } from \"@zwave-js/shared/safe\";\nimport { pick } from \"@zwave-js/shared/safe\";\nimport { validateArgs } from \"@zwave-js/transformers\";\nimport { clamp } from \"alcalzone-shared/math/index.js\";\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\ttype CCResponsePredicate,\n\tCommandClass,\n\ttype InterviewContext,\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 { SoundSwitchCommand, type ToneId } from \"../lib/_Types.js\";\n\nexport const SoundSwitchCCValues = Object.freeze({\n\t...V.defineStaticCCValues(CommandClasses[\"Sound Switch\"], {\n\t\t...V.staticProperty(\n\t\t\t\"volume\",\n\t\t\t{\n\t\t\t\t...ValueMetadata.UInt8,\n\t\t\t\tmin: 0,\n\t\t\t\tmax: 100,\n\t\t\t\tunit: \"%\",\n\t\t\t\tlabel: \"Volume\",\n\t\t\t\tallowManualEntry: true,\n\t\t\t\tstates: {\n\t\t\t\t\t0: \"default\",\n\t\t\t\t},\n\t\t\t} as const,\n\t\t),\n\n\t\t...V.staticProperty(\n\t\t\t\"toneId\",\n\t\t\t{\n\t\t\t\t...ValueMetadata.UInt8,\n\t\t\t\tlabel: \"Play Tone\",\n\t\t\t\tvalueChangeOptions: [\"volume\"],\n\t\t\t} as const,\n\t\t),\n\n\t\t...V.staticProperty(\n\t\t\t\"defaultVolume\",\n\t\t\t{\n\t\t\t\t...ValueMetadata.Number,\n\t\t\t\tmin: 0,\n\t\t\t\tmax: 100,\n\t\t\t\tunit: \"%\",\n\t\t\t\tlabel: \"Default volume\",\n\t\t\t} as const,\n\t\t),\n\n\t\t...V.staticProperty(\n\t\t\t\"defaultToneId\",\n\t\t\t{\n\t\t\t\t...ValueMetadata.Number,\n\t\t\t\tmin: 1,\n\t\t\t\tmax: 254,\n\t\t\t\tlabel: \"Default tone ID\",\n\t\t\t} as const,\n\t\t),\n\t}),\n});\n\n@API(CommandClasses[\"Sound Switch\"])\nexport class SoundSwitchCCAPI extends CCAPI {\n\tpublic supportsCommand(cmd: SoundSwitchCommand): MaybeNotKnown<boolean> {\n\t\tswitch (cmd) {\n\t\t\tcase SoundSwitchCommand.TonesNumberGet:\n\t\t\tcase SoundSwitchCommand.ToneInfoGet:\n\t\t\tcase SoundSwitchCommand.ConfigurationGet:\n\t\t\tcase SoundSwitchCommand.TonePlayGet:\n\t\t\t\treturn this.isSinglecast();\n\t\t\tcase SoundSwitchCommand.ConfigurationSet:\n\t\t\tcase SoundSwitchCommand.TonePlaySet:\n\t\t\t\treturn true; // This is mandatory\n\t\t}\n\t\treturn super.supportsCommand(cmd);\n\t}\n\n\tpublic async getToneCount(): Promise<MaybeNotKnown<number>> {\n\t\tthis.assertSupportsCommand(\n\t\t\tSoundSwitchCommand,\n\t\t\tSoundSwitchCommand.TonesNumberGet,\n\t\t);\n\n\t\tconst cc = new SoundSwitchCCTonesNumberGet({\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\tSoundSwitchCCTonesNumberReport\n\t\t>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\treturn response?.toneCount;\n\t}\n\n\t@validateArgs()\n\t// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n\tpublic async getToneInfo(toneId: number) {\n\t\tthis.assertSupportsCommand(\n\t\t\tSoundSwitchCommand,\n\t\t\tSoundSwitchCommand.ToneInfoGet,\n\t\t);\n\n\t\tconst cc = new SoundSwitchCCToneInfoGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\ttoneId,\n\t\t});\n\t\tconst response = await this.host.sendCommand<\n\t\t\tSoundSwitchCCToneInfoReport\n\t\t>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\tif (response) return pick(response, [\"duration\", \"name\"]);\n\t}\n\n\t@validateArgs()\n\tpublic async setConfiguration(\n\t\tdefaultToneId: number,\n\t\tdefaultVolume: number,\n\t): Promise<SupervisionResult | undefined> {\n\t\tthis.assertSupportsCommand(\n\t\t\tSoundSwitchCommand,\n\t\t\tSoundSwitchCommand.ConfigurationSet,\n\t\t);\n\n\t\tconst cc = new SoundSwitchCCConfigurationSet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tdefaultToneId,\n\t\t\tdefaultVolume,\n\t\t});\n\t\treturn this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n\tpublic async getConfiguration() {\n\t\tthis.assertSupportsCommand(\n\t\t\tSoundSwitchCommand,\n\t\t\tSoundSwitchCommand.ConfigurationGet,\n\t\t);\n\n\t\tconst cc = new SoundSwitchCCConfigurationGet({\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\tSoundSwitchCCConfigurationReport\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, [\"defaultToneId\", \"defaultVolume\"]);\n\t\t}\n\t}\n\n\t@validateArgs()\n\tpublic async play(\n\t\ttoneId: number,\n\t\tvolume?: number,\n\t): Promise<SupervisionResult | undefined> {\n\t\tthis.assertSupportsCommand(\n\t\t\tSoundSwitchCommand,\n\t\t\tSoundSwitchCommand.TonePlaySet,\n\t\t);\n\n\t\tif (toneId === 0) {\n\t\t\tthrow new ZWaveError(\n\t\t\t\t`Tone ID must be > 0. Use stopPlaying to stop the tone.`,\n\t\t\t\tZWaveErrorCodes.Argument_Invalid,\n\t\t\t);\n\t\t}\n\n\t\tconst cc = new SoundSwitchCCTonePlaySet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\ttoneId,\n\t\t\tvolume,\n\t\t});\n\t\treturn this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\tpublic async stopPlaying(): Promise<SupervisionResult | undefined> {\n\t\tthis.assertSupportsCommand(\n\t\t\tSoundSwitchCommand,\n\t\t\tSoundSwitchCommand.TonePlaySet,\n\t\t);\n\n\t\tconst cc = new SoundSwitchCCTonePlaySet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\ttoneId: 0x00,\n\t\t\tvolume: 0x00,\n\t\t});\n\t\treturn this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n\tpublic async getPlaying() {\n\t\tthis.assertSupportsCommand(\n\t\t\tSoundSwitchCommand,\n\t\t\tSoundSwitchCommand.TonePlayGet,\n\t\t);\n\n\t\tconst cc = new SoundSwitchCCTonePlayGet({\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\tSoundSwitchCCTonePlayReport\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, [\"toneId\", \"volume\"]);\n\t\t}\n\t}\n\n\tprotected override get [SET_VALUE](): SetValueImplementation {\n\t\treturn async function(\n\t\t\tthis: SoundSwitchCCAPI,\n\t\t\t{ property },\n\t\t\tvalue,\n\t\t\toptions,\n\t\t) {\n\t\t\tif (property === \"defaultToneId\") {\n\t\t\t\tif (typeof value !== \"number\") {\n\t\t\t\t\tthrowWrongValueType(\n\t\t\t\t\t\tthis.ccId,\n\t\t\t\t\t\tproperty,\n\t\t\t\t\t\t\"number\",\n\t\t\t\t\t\ttypeof value,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn this.setConfiguration(\n\t\t\t\t\tvalue,\n\t\t\t\t\t0xff, /* keep current volume */\n\t\t\t\t);\n\t\t\t} else if (property === \"defaultVolume\") {\n\t\t\t\tif (typeof value !== \"number\") {\n\t\t\t\t\tthrowWrongValueType(\n\t\t\t\t\t\tthis.ccId,\n\t\t\t\t\t\tproperty,\n\t\t\t\t\t\t\"number\",\n\t\t\t\t\t\ttypeof value,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn this.setConfiguration(\n\t\t\t\t\t0x00, /* keep current tone */\n\t\t\t\t\tvalue,\n\t\t\t\t);\n\t\t\t} else if (property === \"volume\") {\n\t\t\t\tif (typeof value !== \"number\") {\n\t\t\t\t\tthrowWrongValueType(\n\t\t\t\t\t\tthis.ccId,\n\t\t\t\t\t\tproperty,\n\t\t\t\t\t\t\"number\",\n\t\t\t\t\t\ttypeof value,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\t// Allow playing a tone by first setting the volume, then the tone ID\n\t\t\t\tthis.tryGetValueDB()?.setValue(\n\t\t\t\t\tSoundSwitchCCValues.volume.endpoint(\n\t\t\t\t\t\tthis.endpoint.index,\n\t\t\t\t\t),\n\t\t\t\t\tvalue,\n\t\t\t\t\t{ source: \"driver\", updateTimestamp: false },\n\t\t\t\t);\n\t\t\t} else if (property === \"toneId\") {\n\t\t\t\tif (typeof value !== \"number\") {\n\t\t\t\t\tthrowWrongValueType(\n\t\t\t\t\t\tthis.ccId,\n\t\t\t\t\t\tproperty,\n\t\t\t\t\t\t\"number\",\n\t\t\t\t\t\ttypeof value,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tlet result: SupervisionResult | undefined;\n\t\t\t\tif (value > 0) {\n\t\t\t\t\t// Use provided volume or try to use the current volume if it exists\n\t\t\t\t\tconst volume = options?.volume !== undefined\n\t\t\t\t\t\t? options.volume\n\t\t\t\t\t\t: this.tryGetValueDB()?.getValue<number>(\n\t\t\t\t\t\t\tSoundSwitchCCValues.volume.endpoint(\n\t\t\t\t\t\t\t\tthis.endpoint.index,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\tresult = await this.play(value, volume);\n\t\t\t\t} else {\n\t\t\t\t\tresult = await this.stopPlaying();\n\t\t\t\t}\n\t\t\t\tif (\n\t\t\t\t\tthis.isSinglecast()\n\t\t\t\t\t&& !supervisedCommandSucceeded(result)\n\t\t\t\t) {\n\t\t\t\t\t// Verify the current value after a (short) delay, unless the command was supervised and successful\n\t\t\t\t\tthis.schedulePoll({ property }, value, {\n\t\t\t\t\t\ttransition: \"fast\",\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\treturn result;\n\t\t\t} else {\n\t\t\t\tthrowUnsupportedProperty(this.ccId, property);\n\t\t\t}\n\t\t};\n\t}\n\n\tprotected get [POLL_VALUE](): PollValueImplementation {\n\t\treturn async function(this: SoundSwitchCCAPI, { property }) {\n\t\t\tswitch (property) {\n\t\t\t\tcase \"defaultToneId\":\n\t\t\t\tcase \"defaultVolume\":\n\t\t\t\t\treturn (await this.getConfiguration())?.[property];\n\n\t\t\t\tcase \"toneId\":\n\t\t\t\tcase \"volume\":\n\t\t\t\t\treturn (await this.getPlaying())?.[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\n@commandClass(CommandClasses[\"Sound Switch\"])\n@implementedVersion(2)\n@ccValues(SoundSwitchCCValues)\nexport class SoundSwitchCC extends CommandClass {\n\tdeclare ccCommand: SoundSwitchCommand;\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[\"Sound Switch\"],\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\tctx.logNode(node.id, {\n\t\t\tmessage: \"requesting tone count...\",\n\t\t\tdirection: \"outbound\",\n\t\t});\n\t\tconst toneCount = await api.getToneCount();\n\t\tif (toneCount != undefined) {\n\t\t\tconst logMessage = `supports ${toneCount} tones`;\n\t\t\tctx.logNode(node.id, {\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: \"Querying tone count timed out, skipping interview...\",\n\t\t\t\tlevel: \"warn\",\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tctx.logNode(node.id, {\n\t\t\tmessage: \"requesting current sound configuration...\",\n\t\t\tdirection: \"outbound\",\n\t\t});\n\t\tconst config = await api.getConfiguration();\n\t\tif (config) {\n\t\t\tconst logMessage = `received current sound configuration:\ndefault tone ID: ${config.defaultToneId}\ndefault volume: ${config.defaultVolume}`;\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tmessage: logMessage,\n\t\t\t\tdirection: \"inbound\",\n\t\t\t});\n\t\t}\n\n\t\tconst metadataStates: Record<number, string> = {};\n\t\tfor (let toneId = 1; toneId <= toneCount; toneId++) {\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tmessage: `requesting info for tone #${toneId}`,\n\t\t\t\tdirection: \"outbound\",\n\t\t\t});\n\t\t\tconst info = await api.getToneInfo(toneId);\n\t\t\tif (!info) continue;\n\t\t\tconst logMessage = `received info for tone #${toneId}:\nname: ${info.name}\nduration: ${info.duration} seconds`;\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tmessage: logMessage,\n\t\t\t\tdirection: \"inbound\",\n\t\t\t});\n\t\t\tmetadataStates[toneId] = `${info.name} (${info.duration} sec)`;\n\t\t}\n\n\t\t// Remember tone count and info on the default tone ID metadata\n\t\tthis.setMetadata(ctx, SoundSwitchCCValues.defaultToneId, {\n\t\t\t...SoundSwitchCCValues.defaultToneId.meta,\n\t\t\tmin: 1,\n\t\t\tmax: toneCount,\n\t\t\tstates: metadataStates,\n\t\t});\n\n\t\t// Remember tone count and info on the tone ID metadata\n\t\tthis.setMetadata(ctx, SoundSwitchCCValues.toneId, {\n\t\t\t...SoundSwitchCCValues.toneId.meta,\n\t\t\tmin: 0,\n\t\t\tmax: toneCount,\n\t\t\tstates: {\n\t\t\t\t0: \"off\",\n\t\t\t\t...metadataStates,\n\t\t\t\t[0xff]: \"default\",\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\n// @publicAPI\nexport interface SoundSwitchCCTonesNumberReportOptions {\n\ttoneCount: number;\n}\n\n@CCCommand(SoundSwitchCommand.TonesNumberReport)\nexport class SoundSwitchCCTonesNumberReport extends SoundSwitchCC {\n\tpublic constructor(\n\t\toptions: WithAddress<SoundSwitchCCTonesNumberReportOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.toneCount = options.toneCount;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): SoundSwitchCCTonesNumberReport {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst toneCount = raw.payload[0];\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\ttoneCount,\n\t\t});\n\t}\n\n\tpublic toneCount: number;\n\n\tpublic serialize(ctx: CCEncodingContext): Bytes {\n\t\tthis.payload = Bytes.from([this.toneCount]);\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: { \"# of tones\": this.toneCount },\n\t\t};\n\t}\n}\n\n@CCCommand(SoundSwitchCommand.TonesNumberGet)\n@expectedCCResponse(SoundSwitchCCTonesNumberReport)\nexport class SoundSwitchCCTonesNumberGet extends SoundSwitchCC {}\n\n// @publicAPI\nexport interface SoundSwitchCCToneInfoReportOptions {\n\ttoneId: number;\n\tduration: number;\n\tname: string;\n}\n\n@CCCommand(SoundSwitchCommand.ToneInfoReport)\nexport class SoundSwitchCCToneInfoReport extends SoundSwitchCC {\n\tpublic constructor(\n\t\toptions: WithAddress<SoundSwitchCCToneInfoReportOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.toneId = options.toneId;\n\t\tthis.duration = options.duration;\n\t\tthis.name = options.name;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): SoundSwitchCCToneInfoReport {\n\t\tvalidatePayload(raw.payload.length >= 4);\n\t\tconst toneId = raw.payload[0];\n\t\tconst duration = raw.payload.readUInt16BE(1);\n\t\tconst nameLength = raw.payload[3];\n\n\t\tvalidatePayload(raw.payload.length >= 4 + nameLength);\n\t\tconst name = raw.payload.subarray(4, 4 + nameLength).toString(\n\t\t\t\"utf8\",\n\t\t);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\ttoneId,\n\t\t\tduration,\n\t\t\tname,\n\t\t});\n\t}\n\n\tpublic readonly toneId: number;\n\tpublic readonly duration: number;\n\tpublic readonly name: string;\n\n\tpublic serialize(ctx: CCEncodingContext): Bytes {\n\t\tthis.payload = Bytes.concat([\n\t\t\tBytes.from([this.toneId, 0, 0, this.name.length]),\n\t\t\tBytes.from(this.name, \"utf8\"),\n\t\t]);\n\t\tthis.payload.writeUInt16BE(this.duration, 1);\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\"tone id\": this.toneId,\n\t\t\t\tduration: `${this.duration} seconds`,\n\t\t\t\tname: this.name,\n\t\t\t},\n\t\t};\n\t}\n}\n\nconst testResponseForSoundSwitchToneInfoGet: CCResponsePredicate<\n\tSoundSwitchCCToneInfoGet,\n\tSoundSwitchCCToneInfoReport\n> = (sent, received) => {\n\treturn received.toneId === sent.toneId;\n};\n\n// @publicAPI\nexport interface SoundSwitchCCToneInfoGetOptions {\n\ttoneId: number;\n}\n\n@CCCommand(SoundSwitchCommand.ToneInfoGet)\n@expectedCCResponse(\n\tSoundSwitchCCToneInfoReport,\n\ttestResponseForSoundSwitchToneInfoGet,\n)\nexport class SoundSwitchCCToneInfoGet extends SoundSwitchCC {\n\tpublic constructor(\n\t\toptions: WithAddress<SoundSwitchCCToneInfoGetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.toneId = options.toneId;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): SoundSwitchCCToneInfoGet {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst toneId = raw.payload[0];\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\ttoneId,\n\t\t});\n\t}\n\n\tpublic toneId: number;\n\n\tpublic serialize(ctx: CCEncodingContext): Bytes {\n\t\tthis.payload = Bytes.from([this.toneId]);\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: { \"tone id\": this.toneId },\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport interface SoundSwitchCCConfigurationSetOptions {\n\tdefaultVolume: number;\n\tdefaultToneId: number;\n}\n\n@CCCommand(SoundSwitchCommand.ConfigurationSet)\n@useSupervision()\nexport class SoundSwitchCCConfigurationSet extends SoundSwitchCC {\n\tpublic constructor(\n\t\toptions: WithAddress<SoundSwitchCCConfigurationSetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.defaultVolume = options.defaultVolume;\n\t\tthis.defaultToneId = options.defaultToneId;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): SoundSwitchCCConfigurationSet {\n\t\tvalidatePayload(raw.payload.length >= 2);\n\t\tconst defaultVolume = raw.payload[0];\n\t\tconst defaultToneId = raw.payload[1];\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tdefaultVolume,\n\t\t\tdefaultToneId,\n\t\t});\n\t}\n\n\tpublic defaultVolume: number;\n\tpublic defaultToneId: number;\n\n\tpublic serialize(ctx: CCEncodingContext): Bytes {\n\t\tthis.payload = Bytes.from([this.defaultVolume, this.defaultToneId]);\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\"default volume\": `${this.defaultVolume} %`,\n\t\t\t\t\"default tone id\": this.defaultToneId,\n\t\t\t},\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport interface SoundSwitchCCConfigurationReportOptions {\n\tdefaultVolume: number;\n\tdefaultToneId: number;\n}\n\n@CCCommand(SoundSwitchCommand.ConfigurationReport)\n@ccValueProperty(\"defaultVolume\", SoundSwitchCCValues.defaultVolume)\n@ccValueProperty(\"defaultToneId\", SoundSwitchCCValues.defaultToneId)\nexport class SoundSwitchCCConfigurationReport extends SoundSwitchCC {\n\tpublic constructor(\n\t\toptions: WithAddress<SoundSwitchCCConfigurationReportOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.defaultVolume = options.defaultVolume;\n\t\tthis.defaultToneId = options.defaultToneId;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): SoundSwitchCCConfigurationReport {\n\t\tvalidatePayload(raw.payload.length >= 2);\n\t\tconst defaultVolume = clamp(raw.payload[0], 0, 100);\n\t\tconst defaultToneId = raw.payload[1];\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tdefaultVolume,\n\t\t\tdefaultToneId,\n\t\t});\n\t}\n\n\tpublic defaultVolume: number;\n\n\tpublic defaultToneId: number;\n\n\tpublic serialize(ctx: CCEncodingContext): Bytes {\n\t\tthis.payload = Bytes.from([this.defaultVolume, this.defaultToneId]);\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\"default volume\": `${this.defaultVolume} %`,\n\t\t\t\t\"default tone id\": this.defaultToneId,\n\t\t\t},\n\t\t};\n\t}\n}\n\n@CCCommand(SoundSwitchCommand.ConfigurationGet)\n@expectedCCResponse(SoundSwitchCCConfigurationReport)\nexport class SoundSwitchCCConfigurationGet extends SoundSwitchCC {}\n\n// @publicAPI\nexport interface SoundSwitchCCTonePlaySetOptions {\n\ttoneId: ToneId | number;\n\t// V2+\n\tvolume?: number;\n}\n\n@CCCommand(SoundSwitchCommand.TonePlaySet)\n@useSupervision()\nexport class SoundSwitchCCTonePlaySet extends SoundSwitchCC {\n\tpublic constructor(\n\t\toptions: WithAddress<SoundSwitchCCTonePlaySetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.toneId = options.toneId;\n\t\tthis.volume = options.volume;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): SoundSwitchCCTonePlaySet {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst toneId = raw.payload[0];\n\t\tlet volume: number | undefined;\n\t\tif (toneId !== 0 && raw.payload.length >= 2) {\n\t\t\tvolume = raw.payload[1];\n\t\t}\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\ttoneId,\n\t\t\tvolume,\n\t\t});\n\t}\n\n\tpublic toneId: ToneId | number;\n\tpublic volume?: number;\n\n\tpublic serialize(ctx: CCEncodingContext): Bytes {\n\t\tthis.payload = Bytes.from([this.toneId, this.volume ?? 0]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\tconst message: MessageRecord = {\n\t\t\t\"tone id\": this.toneId,\n\t\t};\n\t\tif (this.volume != undefined) {\n\t\t\tmessage.volume = this.volume === 0 ? \"default\" : `${this.volume} %`;\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 interface SoundSwitchCCTonePlayReportOptions {\n\ttoneId: ToneId | number;\n\t// V2+\n\tvolume?: number;\n}\n\n@CCCommand(SoundSwitchCommand.TonePlayReport)\n@ccValueProperty(\"toneId\", SoundSwitchCCValues.toneId)\n@ccValueProperty(\"volume\", SoundSwitchCCValues.volume)\nexport class SoundSwitchCCTonePlayReport extends SoundSwitchCC {\n\tpublic constructor(\n\t\toptions: WithAddress<SoundSwitchCCTonePlayReportOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.toneId = options.toneId;\n\t\tthis.volume = options.volume;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): SoundSwitchCCTonePlayReport {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst toneId = raw.payload[0];\n\n\t\tlet volume: number | undefined;\n\t\tif (toneId !== 0 && raw.payload.length >= 2) {\n\t\t\tvolume = raw.payload[1];\n\t\t}\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\ttoneId,\n\t\t\tvolume,\n\t\t});\n\t}\n\n\tpublic readonly toneId: ToneId | number;\n\n\tpublic volume?: number;\n\n\tpublic serialize(ctx: CCEncodingContext): Bytes {\n\t\tthis.payload = Bytes.from([this.toneId, this.volume ?? 0]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\tconst message: MessageRecord = {\n\t\t\t\"tone id\": this.toneId,\n\t\t};\n\t\tif (this.volume != undefined) {\n\t\t\tmessage.volume = this.volume === 0 ? \"default\" : `${this.volume} %`;\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(SoundSwitchCommand.TonePlayGet)\n@expectedCCResponse(SoundSwitchCCTonePlayReport)\nexport class SoundSwitchCCTonePlayGet extends SoundSwitchCC {}\n"],
4
+ "sourcesContent": ["import {\n\tCommandClasses,\n\ttype MaybeNotKnown,\n\ttype MessageOrCCLogEntry,\n\tMessagePriority,\n\ttype MessageRecord,\n\ttype SupervisionResult,\n\tValueMetadata,\n\ttype WithAddress,\n\tZWaveError,\n\tZWaveErrorCodes,\n\tsupervisedCommandSucceeded,\n\tvalidatePayload,\n} from \"@zwave-js/core/safe\";\nimport type {\n\tCCEncodingContext,\n\tCCParsingContext,\n\tGetValueDB,\n} from \"@zwave-js/host/safe\";\nimport { Bytes } from \"@zwave-js/shared/safe\";\nimport { pick } from \"@zwave-js/shared/safe\";\nimport { validateArgs } from \"@zwave-js/transformers\";\nimport { clamp } from \"alcalzone-shared/math\";\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\ttype CCResponsePredicate,\n\tCommandClass,\n\ttype InterviewContext,\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 { SoundSwitchCommand, type ToneId } from \"../lib/_Types.js\";\n\nexport const SoundSwitchCCValues = Object.freeze({\n\t...V.defineStaticCCValues(CommandClasses[\"Sound Switch\"], {\n\t\t...V.staticProperty(\n\t\t\t\"volume\",\n\t\t\t{\n\t\t\t\t...ValueMetadata.UInt8,\n\t\t\t\tmin: 0,\n\t\t\t\tmax: 100,\n\t\t\t\tunit: \"%\",\n\t\t\t\tlabel: \"Volume\",\n\t\t\t\tallowManualEntry: true,\n\t\t\t\tstates: {\n\t\t\t\t\t0: \"default\",\n\t\t\t\t},\n\t\t\t} as const,\n\t\t),\n\n\t\t...V.staticProperty(\n\t\t\t\"toneId\",\n\t\t\t{\n\t\t\t\t...ValueMetadata.UInt8,\n\t\t\t\tlabel: \"Play Tone\",\n\t\t\t\tvalueChangeOptions: [\"volume\"],\n\t\t\t} as const,\n\t\t),\n\n\t\t...V.staticProperty(\n\t\t\t\"defaultVolume\",\n\t\t\t{\n\t\t\t\t...ValueMetadata.Number,\n\t\t\t\tmin: 0,\n\t\t\t\tmax: 100,\n\t\t\t\tunit: \"%\",\n\t\t\t\tlabel: \"Default volume\",\n\t\t\t} as const,\n\t\t),\n\n\t\t...V.staticProperty(\n\t\t\t\"defaultToneId\",\n\t\t\t{\n\t\t\t\t...ValueMetadata.Number,\n\t\t\t\tmin: 1,\n\t\t\t\tmax: 254,\n\t\t\t\tlabel: \"Default tone ID\",\n\t\t\t} as const,\n\t\t),\n\t}),\n});\n\n@API(CommandClasses[\"Sound Switch\"])\nexport class SoundSwitchCCAPI extends CCAPI {\n\tpublic supportsCommand(cmd: SoundSwitchCommand): MaybeNotKnown<boolean> {\n\t\tswitch (cmd) {\n\t\t\tcase SoundSwitchCommand.TonesNumberGet:\n\t\t\tcase SoundSwitchCommand.ToneInfoGet:\n\t\t\tcase SoundSwitchCommand.ConfigurationGet:\n\t\t\tcase SoundSwitchCommand.TonePlayGet:\n\t\t\t\treturn this.isSinglecast();\n\t\t\tcase SoundSwitchCommand.ConfigurationSet:\n\t\t\tcase SoundSwitchCommand.TonePlaySet:\n\t\t\t\treturn true; // This is mandatory\n\t\t}\n\t\treturn super.supportsCommand(cmd);\n\t}\n\n\tpublic async getToneCount(): Promise<MaybeNotKnown<number>> {\n\t\tthis.assertSupportsCommand(\n\t\t\tSoundSwitchCommand,\n\t\t\tSoundSwitchCommand.TonesNumberGet,\n\t\t);\n\n\t\tconst cc = new SoundSwitchCCTonesNumberGet({\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\tSoundSwitchCCTonesNumberReport\n\t\t>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\treturn response?.toneCount;\n\t}\n\n\t@validateArgs()\n\t// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n\tpublic async getToneInfo(toneId: number) {\n\t\tthis.assertSupportsCommand(\n\t\t\tSoundSwitchCommand,\n\t\t\tSoundSwitchCommand.ToneInfoGet,\n\t\t);\n\n\t\tconst cc = new SoundSwitchCCToneInfoGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\ttoneId,\n\t\t});\n\t\tconst response = await this.host.sendCommand<\n\t\t\tSoundSwitchCCToneInfoReport\n\t\t>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\tif (response) return pick(response, [\"duration\", \"name\"]);\n\t}\n\n\t@validateArgs()\n\tpublic async setConfiguration(\n\t\tdefaultToneId: number,\n\t\tdefaultVolume: number,\n\t): Promise<SupervisionResult | undefined> {\n\t\tthis.assertSupportsCommand(\n\t\t\tSoundSwitchCommand,\n\t\t\tSoundSwitchCommand.ConfigurationSet,\n\t\t);\n\n\t\tconst cc = new SoundSwitchCCConfigurationSet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tdefaultToneId,\n\t\t\tdefaultVolume,\n\t\t});\n\t\treturn this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n\tpublic async getConfiguration() {\n\t\tthis.assertSupportsCommand(\n\t\t\tSoundSwitchCommand,\n\t\t\tSoundSwitchCommand.ConfigurationGet,\n\t\t);\n\n\t\tconst cc = new SoundSwitchCCConfigurationGet({\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\tSoundSwitchCCConfigurationReport\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, [\"defaultToneId\", \"defaultVolume\"]);\n\t\t}\n\t}\n\n\t@validateArgs()\n\tpublic async play(\n\t\ttoneId: number,\n\t\tvolume?: number,\n\t): Promise<SupervisionResult | undefined> {\n\t\tthis.assertSupportsCommand(\n\t\t\tSoundSwitchCommand,\n\t\t\tSoundSwitchCommand.TonePlaySet,\n\t\t);\n\n\t\tif (toneId === 0) {\n\t\t\tthrow new ZWaveError(\n\t\t\t\t`Tone ID must be > 0. Use stopPlaying to stop the tone.`,\n\t\t\t\tZWaveErrorCodes.Argument_Invalid,\n\t\t\t);\n\t\t}\n\n\t\tconst cc = new SoundSwitchCCTonePlaySet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\ttoneId,\n\t\t\tvolume,\n\t\t});\n\t\treturn this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\tpublic async stopPlaying(): Promise<SupervisionResult | undefined> {\n\t\tthis.assertSupportsCommand(\n\t\t\tSoundSwitchCommand,\n\t\t\tSoundSwitchCommand.TonePlaySet,\n\t\t);\n\n\t\tconst cc = new SoundSwitchCCTonePlaySet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\ttoneId: 0x00,\n\t\t\tvolume: 0x00,\n\t\t});\n\t\treturn this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n\tpublic async getPlaying() {\n\t\tthis.assertSupportsCommand(\n\t\t\tSoundSwitchCommand,\n\t\t\tSoundSwitchCommand.TonePlayGet,\n\t\t);\n\n\t\tconst cc = new SoundSwitchCCTonePlayGet({\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\tSoundSwitchCCTonePlayReport\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, [\"toneId\", \"volume\"]);\n\t\t}\n\t}\n\n\tprotected override get [SET_VALUE](): SetValueImplementation {\n\t\treturn async function(\n\t\t\tthis: SoundSwitchCCAPI,\n\t\t\t{ property },\n\t\t\tvalue,\n\t\t\toptions,\n\t\t) {\n\t\t\tif (property === \"defaultToneId\") {\n\t\t\t\tif (typeof value !== \"number\") {\n\t\t\t\t\tthrowWrongValueType(\n\t\t\t\t\t\tthis.ccId,\n\t\t\t\t\t\tproperty,\n\t\t\t\t\t\t\"number\",\n\t\t\t\t\t\ttypeof value,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn this.setConfiguration(\n\t\t\t\t\tvalue,\n\t\t\t\t\t0xff, /* keep current volume */\n\t\t\t\t);\n\t\t\t} else if (property === \"defaultVolume\") {\n\t\t\t\tif (typeof value !== \"number\") {\n\t\t\t\t\tthrowWrongValueType(\n\t\t\t\t\t\tthis.ccId,\n\t\t\t\t\t\tproperty,\n\t\t\t\t\t\t\"number\",\n\t\t\t\t\t\ttypeof value,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn this.setConfiguration(\n\t\t\t\t\t0x00, /* keep current tone */\n\t\t\t\t\tvalue,\n\t\t\t\t);\n\t\t\t} else if (property === \"volume\") {\n\t\t\t\tif (typeof value !== \"number\") {\n\t\t\t\t\tthrowWrongValueType(\n\t\t\t\t\t\tthis.ccId,\n\t\t\t\t\t\tproperty,\n\t\t\t\t\t\t\"number\",\n\t\t\t\t\t\ttypeof value,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\t// Allow playing a tone by first setting the volume, then the tone ID\n\t\t\t\tthis.tryGetValueDB()?.setValue(\n\t\t\t\t\tSoundSwitchCCValues.volume.endpoint(\n\t\t\t\t\t\tthis.endpoint.index,\n\t\t\t\t\t),\n\t\t\t\t\tvalue,\n\t\t\t\t\t{ source: \"driver\", updateTimestamp: false },\n\t\t\t\t);\n\t\t\t} else if (property === \"toneId\") {\n\t\t\t\tif (typeof value !== \"number\") {\n\t\t\t\t\tthrowWrongValueType(\n\t\t\t\t\t\tthis.ccId,\n\t\t\t\t\t\tproperty,\n\t\t\t\t\t\t\"number\",\n\t\t\t\t\t\ttypeof value,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tlet result: SupervisionResult | undefined;\n\t\t\t\tif (value > 0) {\n\t\t\t\t\t// Use provided volume or try to use the current volume if it exists\n\t\t\t\t\tconst volume = options?.volume !== undefined\n\t\t\t\t\t\t? options.volume\n\t\t\t\t\t\t: this.tryGetValueDB()?.getValue<number>(\n\t\t\t\t\t\t\tSoundSwitchCCValues.volume.endpoint(\n\t\t\t\t\t\t\t\tthis.endpoint.index,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\tresult = await this.play(value, volume);\n\t\t\t\t} else {\n\t\t\t\t\tresult = await this.stopPlaying();\n\t\t\t\t}\n\t\t\t\tif (\n\t\t\t\t\tthis.isSinglecast()\n\t\t\t\t\t&& !supervisedCommandSucceeded(result)\n\t\t\t\t) {\n\t\t\t\t\t// Verify the current value after a (short) delay, unless the command was supervised and successful\n\t\t\t\t\tthis.schedulePoll({ property }, value, {\n\t\t\t\t\t\ttransition: \"fast\",\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\treturn result;\n\t\t\t} else {\n\t\t\t\tthrowUnsupportedProperty(this.ccId, property);\n\t\t\t}\n\t\t};\n\t}\n\n\tprotected get [POLL_VALUE](): PollValueImplementation {\n\t\treturn async function(this: SoundSwitchCCAPI, { property }) {\n\t\t\tswitch (property) {\n\t\t\t\tcase \"defaultToneId\":\n\t\t\t\tcase \"defaultVolume\":\n\t\t\t\t\treturn (await this.getConfiguration())?.[property];\n\n\t\t\t\tcase \"toneId\":\n\t\t\t\tcase \"volume\":\n\t\t\t\t\treturn (await this.getPlaying())?.[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\n@commandClass(CommandClasses[\"Sound Switch\"])\n@implementedVersion(2)\n@ccValues(SoundSwitchCCValues)\nexport class SoundSwitchCC extends CommandClass {\n\tdeclare ccCommand: SoundSwitchCommand;\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[\"Sound Switch\"],\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\tctx.logNode(node.id, {\n\t\t\tmessage: \"requesting tone count...\",\n\t\t\tdirection: \"outbound\",\n\t\t});\n\t\tconst toneCount = await api.getToneCount();\n\t\tif (toneCount != undefined) {\n\t\t\tconst logMessage = `supports ${toneCount} tones`;\n\t\t\tctx.logNode(node.id, {\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: \"Querying tone count timed out, skipping interview...\",\n\t\t\t\tlevel: \"warn\",\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tctx.logNode(node.id, {\n\t\t\tmessage: \"requesting current sound configuration...\",\n\t\t\tdirection: \"outbound\",\n\t\t});\n\t\tconst config = await api.getConfiguration();\n\t\tif (config) {\n\t\t\tconst logMessage = `received current sound configuration:\ndefault tone ID: ${config.defaultToneId}\ndefault volume: ${config.defaultVolume}`;\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tmessage: logMessage,\n\t\t\t\tdirection: \"inbound\",\n\t\t\t});\n\t\t}\n\n\t\tconst metadataStates: Record<number, string> = {};\n\t\tfor (let toneId = 1; toneId <= toneCount; toneId++) {\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tmessage: `requesting info for tone #${toneId}`,\n\t\t\t\tdirection: \"outbound\",\n\t\t\t});\n\t\t\tconst info = await api.getToneInfo(toneId);\n\t\t\tif (!info) continue;\n\t\t\tconst logMessage = `received info for tone #${toneId}:\nname: ${info.name}\nduration: ${info.duration} seconds`;\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tmessage: logMessage,\n\t\t\t\tdirection: \"inbound\",\n\t\t\t});\n\t\t\tmetadataStates[toneId] = `${info.name} (${info.duration} sec)`;\n\t\t}\n\n\t\t// Remember tone count and info on the default tone ID metadata\n\t\tthis.setMetadata(ctx, SoundSwitchCCValues.defaultToneId, {\n\t\t\t...SoundSwitchCCValues.defaultToneId.meta,\n\t\t\tmin: 1,\n\t\t\tmax: toneCount,\n\t\t\tstates: metadataStates,\n\t\t});\n\n\t\t// Remember tone count and info on the tone ID metadata\n\t\tthis.setMetadata(ctx, SoundSwitchCCValues.toneId, {\n\t\t\t...SoundSwitchCCValues.toneId.meta,\n\t\t\tmin: 0,\n\t\t\tmax: toneCount,\n\t\t\tstates: {\n\t\t\t\t0: \"off\",\n\t\t\t\t...metadataStates,\n\t\t\t\t[0xff]: \"default\",\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\n// @publicAPI\nexport interface SoundSwitchCCTonesNumberReportOptions {\n\ttoneCount: number;\n}\n\n@CCCommand(SoundSwitchCommand.TonesNumberReport)\nexport class SoundSwitchCCTonesNumberReport extends SoundSwitchCC {\n\tpublic constructor(\n\t\toptions: WithAddress<SoundSwitchCCTonesNumberReportOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.toneCount = options.toneCount;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): SoundSwitchCCTonesNumberReport {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst toneCount = raw.payload[0];\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\ttoneCount,\n\t\t});\n\t}\n\n\tpublic toneCount: number;\n\n\tpublic serialize(ctx: CCEncodingContext): Bytes {\n\t\tthis.payload = Bytes.from([this.toneCount]);\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: { \"# of tones\": this.toneCount },\n\t\t};\n\t}\n}\n\n@CCCommand(SoundSwitchCommand.TonesNumberGet)\n@expectedCCResponse(SoundSwitchCCTonesNumberReport)\nexport class SoundSwitchCCTonesNumberGet extends SoundSwitchCC {}\n\n// @publicAPI\nexport interface SoundSwitchCCToneInfoReportOptions {\n\ttoneId: number;\n\tduration: number;\n\tname: string;\n}\n\n@CCCommand(SoundSwitchCommand.ToneInfoReport)\nexport class SoundSwitchCCToneInfoReport extends SoundSwitchCC {\n\tpublic constructor(\n\t\toptions: WithAddress<SoundSwitchCCToneInfoReportOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.toneId = options.toneId;\n\t\tthis.duration = options.duration;\n\t\tthis.name = options.name;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): SoundSwitchCCToneInfoReport {\n\t\tvalidatePayload(raw.payload.length >= 4);\n\t\tconst toneId = raw.payload[0];\n\t\tconst duration = raw.payload.readUInt16BE(1);\n\t\tconst nameLength = raw.payload[3];\n\n\t\tvalidatePayload(raw.payload.length >= 4 + nameLength);\n\t\tconst name = raw.payload.subarray(4, 4 + nameLength).toString(\n\t\t\t\"utf8\",\n\t\t);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\ttoneId,\n\t\t\tduration,\n\t\t\tname,\n\t\t});\n\t}\n\n\tpublic readonly toneId: number;\n\tpublic readonly duration: number;\n\tpublic readonly name: string;\n\n\tpublic serialize(ctx: CCEncodingContext): Bytes {\n\t\tthis.payload = Bytes.concat([\n\t\t\tBytes.from([this.toneId, 0, 0, this.name.length]),\n\t\t\tBytes.from(this.name, \"utf8\"),\n\t\t]);\n\t\tthis.payload.writeUInt16BE(this.duration, 1);\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\"tone id\": this.toneId,\n\t\t\t\tduration: `${this.duration} seconds`,\n\t\t\t\tname: this.name,\n\t\t\t},\n\t\t};\n\t}\n}\n\nconst testResponseForSoundSwitchToneInfoGet: CCResponsePredicate<\n\tSoundSwitchCCToneInfoGet,\n\tSoundSwitchCCToneInfoReport\n> = (sent, received) => {\n\treturn received.toneId === sent.toneId;\n};\n\n// @publicAPI\nexport interface SoundSwitchCCToneInfoGetOptions {\n\ttoneId: number;\n}\n\n@CCCommand(SoundSwitchCommand.ToneInfoGet)\n@expectedCCResponse(\n\tSoundSwitchCCToneInfoReport,\n\ttestResponseForSoundSwitchToneInfoGet,\n)\nexport class SoundSwitchCCToneInfoGet extends SoundSwitchCC {\n\tpublic constructor(\n\t\toptions: WithAddress<SoundSwitchCCToneInfoGetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.toneId = options.toneId;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): SoundSwitchCCToneInfoGet {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst toneId = raw.payload[0];\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\ttoneId,\n\t\t});\n\t}\n\n\tpublic toneId: number;\n\n\tpublic serialize(ctx: CCEncodingContext): Bytes {\n\t\tthis.payload = Bytes.from([this.toneId]);\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: { \"tone id\": this.toneId },\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport interface SoundSwitchCCConfigurationSetOptions {\n\tdefaultVolume: number;\n\tdefaultToneId: number;\n}\n\n@CCCommand(SoundSwitchCommand.ConfigurationSet)\n@useSupervision()\nexport class SoundSwitchCCConfigurationSet extends SoundSwitchCC {\n\tpublic constructor(\n\t\toptions: WithAddress<SoundSwitchCCConfigurationSetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.defaultVolume = options.defaultVolume;\n\t\tthis.defaultToneId = options.defaultToneId;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): SoundSwitchCCConfigurationSet {\n\t\tvalidatePayload(raw.payload.length >= 2);\n\t\tconst defaultVolume = raw.payload[0];\n\t\tconst defaultToneId = raw.payload[1];\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tdefaultVolume,\n\t\t\tdefaultToneId,\n\t\t});\n\t}\n\n\tpublic defaultVolume: number;\n\tpublic defaultToneId: number;\n\n\tpublic serialize(ctx: CCEncodingContext): Bytes {\n\t\tthis.payload = Bytes.from([this.defaultVolume, this.defaultToneId]);\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\"default volume\": `${this.defaultVolume} %`,\n\t\t\t\t\"default tone id\": this.defaultToneId,\n\t\t\t},\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport interface SoundSwitchCCConfigurationReportOptions {\n\tdefaultVolume: number;\n\tdefaultToneId: number;\n}\n\n@CCCommand(SoundSwitchCommand.ConfigurationReport)\n@ccValueProperty(\"defaultVolume\", SoundSwitchCCValues.defaultVolume)\n@ccValueProperty(\"defaultToneId\", SoundSwitchCCValues.defaultToneId)\nexport class SoundSwitchCCConfigurationReport extends SoundSwitchCC {\n\tpublic constructor(\n\t\toptions: WithAddress<SoundSwitchCCConfigurationReportOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.defaultVolume = options.defaultVolume;\n\t\tthis.defaultToneId = options.defaultToneId;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): SoundSwitchCCConfigurationReport {\n\t\tvalidatePayload(raw.payload.length >= 2);\n\t\tconst defaultVolume = clamp(raw.payload[0], 0, 100);\n\t\tconst defaultToneId = raw.payload[1];\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tdefaultVolume,\n\t\t\tdefaultToneId,\n\t\t});\n\t}\n\n\tpublic defaultVolume: number;\n\n\tpublic defaultToneId: number;\n\n\tpublic serialize(ctx: CCEncodingContext): Bytes {\n\t\tthis.payload = Bytes.from([this.defaultVolume, this.defaultToneId]);\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\"default volume\": `${this.defaultVolume} %`,\n\t\t\t\t\"default tone id\": this.defaultToneId,\n\t\t\t},\n\t\t};\n\t}\n}\n\n@CCCommand(SoundSwitchCommand.ConfigurationGet)\n@expectedCCResponse(SoundSwitchCCConfigurationReport)\nexport class SoundSwitchCCConfigurationGet extends SoundSwitchCC {}\n\n// @publicAPI\nexport interface SoundSwitchCCTonePlaySetOptions {\n\ttoneId: ToneId | number;\n\t// V2+\n\tvolume?: number;\n}\n\n@CCCommand(SoundSwitchCommand.TonePlaySet)\n@useSupervision()\nexport class SoundSwitchCCTonePlaySet extends SoundSwitchCC {\n\tpublic constructor(\n\t\toptions: WithAddress<SoundSwitchCCTonePlaySetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.toneId = options.toneId;\n\t\tthis.volume = options.volume;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): SoundSwitchCCTonePlaySet {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst toneId = raw.payload[0];\n\t\tlet volume: number | undefined;\n\t\tif (toneId !== 0 && raw.payload.length >= 2) {\n\t\t\tvolume = raw.payload[1];\n\t\t}\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\ttoneId,\n\t\t\tvolume,\n\t\t});\n\t}\n\n\tpublic toneId: ToneId | number;\n\tpublic volume?: number;\n\n\tpublic serialize(ctx: CCEncodingContext): Bytes {\n\t\tthis.payload = Bytes.from([this.toneId, this.volume ?? 0]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\tconst message: MessageRecord = {\n\t\t\t\"tone id\": this.toneId,\n\t\t};\n\t\tif (this.volume != undefined) {\n\t\t\tmessage.volume = this.volume === 0 ? \"default\" : `${this.volume} %`;\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 interface SoundSwitchCCTonePlayReportOptions {\n\ttoneId: ToneId | number;\n\t// V2+\n\tvolume?: number;\n}\n\n@CCCommand(SoundSwitchCommand.TonePlayReport)\n@ccValueProperty(\"toneId\", SoundSwitchCCValues.toneId)\n@ccValueProperty(\"volume\", SoundSwitchCCValues.volume)\nexport class SoundSwitchCCTonePlayReport extends SoundSwitchCC {\n\tpublic constructor(\n\t\toptions: WithAddress<SoundSwitchCCTonePlayReportOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.toneId = options.toneId;\n\t\tthis.volume = options.volume;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): SoundSwitchCCTonePlayReport {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst toneId = raw.payload[0];\n\n\t\tlet volume: number | undefined;\n\t\tif (toneId !== 0 && raw.payload.length >= 2) {\n\t\t\tvolume = raw.payload[1];\n\t\t}\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\ttoneId,\n\t\t\tvolume,\n\t\t});\n\t}\n\n\tpublic readonly toneId: ToneId | number;\n\n\tpublic volume?: number;\n\n\tpublic serialize(ctx: CCEncodingContext): Bytes {\n\t\tthis.payload = Bytes.from([this.toneId, this.volume ?? 0]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\tconst message: MessageRecord = {\n\t\t\t\"tone id\": this.toneId,\n\t\t};\n\t\tif (this.volume != undefined) {\n\t\t\tmessage.volume = this.volume === 0 ? \"default\" : `${this.volume} %`;\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(SoundSwitchCommand.TonePlayGet)\n@expectedCCResponse(SoundSwitchCCTonePlayReport)\nexport class SoundSwitchCCTonePlayGet extends SoundSwitchCC {}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kBAaO;AAMP,IAAAA,eAAsB;AACtB,IAAAA,eAAqB;AAErB,kBAAsB;AACtB,iBAQO;AACP,0BAKO;AACP,oCASO;AACP,oBAAkB;AAClB,mBAAgD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEzC,MAAM,sBAAsB,OAAO,OAAO;EAChD,GAAG,gBAAE,qBAAqB,2BAAe,cAAc,GAAG;IACzD,GAAG,gBAAE,eACJ,UACA;MACC,GAAG,0BAAc;MACjB,KAAK;MACL,KAAK;MACL,MAAM;MACN,OAAO;MACP,kBAAkB;MAClB,QAAQ;QACP,GAAG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SAAS,IAAI,QAAQ,CAAC;AAE5B,UAAI;AACJ,UAAI,WAAW,KAAK,IAAI,QAAQ,UAAU,GAAG;AAC5C,iBAAS,IAAI,QAAQ,CAAC;MACvB;AAEA,aAAO,IAAI,KAAK;QACf,QAAQ,IAAI;QACZ;QACA;OACA;IACF;IAEgB;IAET;IAEA,UAAU,KAAsB;AACtC,WAAK,UAAU,mBAAM,KAAK,CAAC,KAAK,QAAQ,KAAK,UAAU,CAAC,CAAC;AACzD,aAAO,MAAM,UAAU,GAAG;IAC3B;IAEO,WAAW,KAAgB;AACjC,YAAM,UAAyB;QAC9B,WAAW,KAAK;;AAEjB,UAAI,KAAK,UAAU,QAAW;AAC7B,gBAAQ,SAAS,KAAK,WAAW,IAAI,YAAY,GAAG,KAAK,MAAM;MAChE;AACA,aAAO;QACN,GAAG,MAAM,WAAW,GAAG;QACvB;;IAEF;;;;IAKY,4BAAwB,MAAA;8BAFpC,yCAAU,gCAAmB,WAAW,OACxC,kDAAmB,2BAA2B,CAAC;;;;oBACF;gDAAA,YAAa;;;;;;AAA3D,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": ["import_safe"]
7
7
  }
@@ -250,8 +250,7 @@ let ThermostatSetbackCCSet = (() => {
250
250
  static from(raw, ctx) {
251
251
  (0, import_safe.validatePayload)(raw.payload.length >= 2);
252
252
  const setbackType = raw.payload[0] & 3;
253
- const rawSetbackState = raw.payload.readInt8(1);
254
- const setbackState = (0, import_serializers.decodeSetbackState)(rawSetbackState) || rawSetbackState;
253
+ const setbackState = (0, import_serializers.decodeSetbackState)(raw.payload, 1) || raw.payload.readInt8(1);
255
254
  return new this({
256
255
  nodeId: ctx.sourceNodeId,
257
256
  setbackType,
@@ -262,8 +261,8 @@ let ThermostatSetbackCCSet = (() => {
262
261
  /** The offset from the setpoint in 0.1 Kelvin or a special mode */
263
262
  setbackState;
264
263
  serialize(ctx) {
265
- this.payload = import_safe2.Bytes.from([
266
- this.setbackType & 3,
264
+ this.payload = import_safe2.Bytes.concat([
265
+ [this.setbackType & 3],
267
266
  (0, import_serializers.encodeSetbackState)(this.setbackState)
268
267
  ]);
269
268
  return super.serialize(ctx);
@@ -305,8 +304,7 @@ let ThermostatSetbackCCReport = (() => {
305
304
  static from(raw, ctx) {
306
305
  (0, import_safe.validatePayload)(raw.payload.length >= 2);
307
306
  const setbackType = raw.payload[0] & 3;
308
- const rawSetbackState = raw.payload.readInt8(1);
309
- const setbackState = (0, import_serializers.decodeSetbackState)(rawSetbackState) || rawSetbackState;
307
+ const setbackState = (0, import_serializers.decodeSetbackState)(raw.payload, 1) || raw.payload.readInt8(1);
310
308
  return new this({
311
309
  nodeId: ctx.sourceNodeId,
312
310
  setbackType,
@@ -317,8 +315,8 @@ let ThermostatSetbackCCReport = (() => {
317
315
  /** The offset from the setpoint in 0.1 Kelvin or a special mode */
318
316
  setbackState;
319
317
  serialize(ctx) {
320
- this.payload = import_safe2.Bytes.from([
321
- this.setbackType & 3,
318
+ this.payload = import_safe2.Bytes.concat([
319
+ [this.setbackType & 3],
322
320
  (0, import_serializers.encodeSetbackState)(this.setbackState)
323
321
  ]);
324
322
  return super.serialize(ctx);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/cc/ThermostatSetbackCC.ts"],
4
- "sourcesContent": ["import {\n\tCommandClasses,\n\ttype MaybeNotKnown,\n\ttype MessageOrCCLogEntry,\n\tMessagePriority,\n\ttype SupervisionResult,\n\ttype WithAddress,\n\tvalidatePayload,\n} from \"@zwave-js/core/safe\";\nimport type {\n\tCCEncodingContext,\n\tCCParsingContext,\n\tGetValueDB,\n} from \"@zwave-js/host/safe\";\nimport { Bytes } from \"@zwave-js/shared/safe\";\nimport { getEnumMemberName, pick } from \"@zwave-js/shared/safe\";\nimport { validateArgs } from \"@zwave-js/transformers\";\nimport {\n\tCCAPI,\n\tPOLL_VALUE,\n\ttype PollValueImplementation,\n\tthrowUnsupportedProperty,\n} from \"../lib/API.js\";\nimport {\n\ttype CCRaw,\n\tCommandClass,\n\ttype InterviewContext,\n\ttype RefreshValuesContext,\n} from \"../lib/CommandClass.js\";\nimport {\n\tAPI,\n\tCCCommand,\n\tcommandClass,\n\texpectedCCResponse,\n\timplementedVersion,\n\tuseSupervision,\n} from \"../lib/CommandClassDecorators.js\";\nimport {\n\ttype SetbackState,\n\tSetbackType,\n\tThermostatSetbackCommand,\n} from \"../lib/_Types.js\";\nimport { decodeSetbackState, encodeSetbackState } from \"../lib/serializers.js\";\n\n// @noSetValueAPI\n// The setback state consist of two values that must be set together\n\n@API(CommandClasses[\"Thermostat Setback\"])\nexport class ThermostatSetbackCCAPI extends CCAPI {\n\tpublic supportsCommand(\n\t\tcmd: ThermostatSetbackCommand,\n\t): MaybeNotKnown<boolean> {\n\t\tswitch (cmd) {\n\t\t\tcase ThermostatSetbackCommand.Get:\n\t\t\t\treturn this.isSinglecast();\n\t\t\tcase ThermostatSetbackCommand.Set:\n\t\t\t\treturn true; // This is mandatory\n\t\t}\n\t\treturn super.supportsCommand(cmd);\n\t}\n\n\tprotected get [POLL_VALUE](): PollValueImplementation {\n\t\treturn async function(this: ThermostatSetbackCCAPI, { property }) {\n\t\t\tswitch (property) {\n\t\t\t\tcase \"setbackType\":\n\t\t\t\tcase \"setbackState\":\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\tThermostatSetbackCommand,\n\t\t\tThermostatSetbackCommand.Get,\n\t\t);\n\n\t\tconst cc = new ThermostatSetbackCCGet({\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\tThermostatSetbackCCReport\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, [\"setbackType\", \"setbackState\"]);\n\t\t}\n\t}\n\n\t@validateArgs()\n\tpublic async set(\n\t\tsetbackType: SetbackType,\n\t\tsetbackState: SetbackState,\n\t): Promise<SupervisionResult | undefined> {\n\t\tthis.assertSupportsCommand(\n\t\t\tThermostatSetbackCommand,\n\t\t\tThermostatSetbackCommand.Get,\n\t\t);\n\n\t\tconst cc = new ThermostatSetbackCCSet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tsetbackType,\n\t\t\tsetbackState,\n\t\t});\n\t\treturn this.host.sendCommand(cc, this.commandOptions);\n\t}\n}\n\n@commandClass(CommandClasses[\"Thermostat Setback\"])\n@implementedVersion(1)\nexport class ThermostatSetbackCC extends CommandClass {\n\tdeclare ccCommand: ThermostatSetbackCommand;\n\n\tpublic async interview(\n\t\tctx: InterviewContext,\n\t): Promise<void> {\n\t\tconst node = this.getNode(ctx)!;\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\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 Setback\"],\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 thermostat state\n\t\tctx.logNode(node.id, {\n\t\t\tendpoint: this.endpointIndex,\n\t\t\tmessage: \"querying the current thermostat state...\",\n\t\t\tdirection: \"outbound\",\n\t\t});\n\t\tconst setbackResp = await api.get();\n\t\tif (setbackResp) {\n\t\t\tconst logMessage = `received current state:\nsetback type: ${getEnumMemberName(SetbackType, setbackResp.setbackType)}\nsetback state: ${setbackResp.setbackState}`;\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}\n\t}\n}\n\n// @publicAPI\nexport interface ThermostatSetbackCCSetOptions {\n\tsetbackType: SetbackType;\n\tsetbackState: SetbackState;\n}\n\n@CCCommand(ThermostatSetbackCommand.Set)\n@useSupervision()\nexport class ThermostatSetbackCCSet extends ThermostatSetbackCC {\n\tpublic constructor(\n\t\toptions: WithAddress<ThermostatSetbackCCSetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.setbackType = options.setbackType;\n\t\tthis.setbackState = options.setbackState;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): ThermostatSetbackCCSet {\n\t\tvalidatePayload(raw.payload.length >= 2);\n\t\tconst setbackType: SetbackType = raw.payload[0] & 0b11;\n\n\t\t// If we receive an unknown setback state, return the raw value\n\t\tconst rawSetbackState = raw.payload.readInt8(1);\n\t\tconst setbackState: SetbackState = decodeSetbackState(rawSetbackState)\n\t\t\t|| rawSetbackState;\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tsetbackType,\n\t\t\tsetbackState,\n\t\t});\n\t}\n\n\tpublic setbackType: SetbackType;\n\t/** The offset from the setpoint in 0.1 Kelvin or a special mode */\n\tpublic setbackState: SetbackState;\n\n\tpublic serialize(ctx: CCEncodingContext): Bytes {\n\t\tthis.payload = Bytes.from([\n\t\t\tthis.setbackType & 0b11,\n\t\t\tencodeSetbackState(this.setbackState),\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\"setback type\": getEnumMemberName(\n\t\t\t\t\tSetbackType,\n\t\t\t\t\tthis.setbackType,\n\t\t\t\t),\n\t\t\t\t\"setback state\": typeof this.setbackState === \"number\"\n\t\t\t\t\t? `${this.setbackState} K`\n\t\t\t\t\t: this.setbackState,\n\t\t\t},\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport interface ThermostatSetbackCCReportOptions {\n\tsetbackType: SetbackType;\n\tsetbackState: SetbackState;\n}\n\n@CCCommand(ThermostatSetbackCommand.Report)\nexport class ThermostatSetbackCCReport extends ThermostatSetbackCC {\n\tpublic constructor(\n\t\toptions: WithAddress<ThermostatSetbackCCReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\tthis.setbackType = options.setbackType;\n\t\tthis.setbackState = options.setbackState;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): ThermostatSetbackCCReport {\n\t\tvalidatePayload(raw.payload.length >= 2);\n\t\tconst setbackType: SetbackType = raw.payload[0] & 0b11;\n\n\t\t// If we receive an unknown setback state, return the raw value\n\t\tconst rawSetbackState = raw.payload.readInt8(1);\n\t\tconst setbackState: SetbackState = decodeSetbackState(rawSetbackState)\n\t\t\t|| rawSetbackState;\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tsetbackType,\n\t\t\tsetbackState,\n\t\t});\n\t}\n\n\tpublic readonly setbackType: SetbackType;\n\t/** The offset from the setpoint in 0.1 Kelvin or a special mode */\n\tpublic readonly setbackState: SetbackState;\n\n\tpublic serialize(ctx: CCEncodingContext): Bytes {\n\t\tthis.payload = Bytes.from([\n\t\t\tthis.setbackType & 0b11,\n\t\t\tencodeSetbackState(this.setbackState),\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\"setback type\": getEnumMemberName(\n\t\t\t\t\tSetbackType,\n\t\t\t\t\tthis.setbackType,\n\t\t\t\t),\n\t\t\t\t\"setback state\": typeof this.setbackState === \"number\"\n\t\t\t\t\t? `${this.setbackState} K`\n\t\t\t\t\t: this.setbackState,\n\t\t\t},\n\t\t};\n\t}\n}\n\n@CCCommand(ThermostatSetbackCommand.Get)\n@expectedCCResponse(ThermostatSetbackCCReport)\nexport class ThermostatSetbackCCGet extends ThermostatSetbackCC {}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kBAQO;AAMP,IAAAA,eAAsB;AACtB,IAAAA,eAAwC;AAExC,iBAKO;AACP,0BAKO;AACP,oCAOO;AACP,mBAIO;AACP,yBAAuD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAM1C,0BAAsB,MAAA;8BADlC,mCAAI,2BAAe,oBAAoB,CAAC,CAAC;;;;oBACE;8CAAA,YAAK;;;;;;AAAjD,mBAAA,MAAA,mBAAA,EAAA,OAAA,WAAA,GAAA,kBAAA,EAAA,MAAA,SAAA,MAAA,WAAA,MAAA,UAAA,UAAA,GAAA,MAAA,uBAAA;;;AAAa,wBAAA,YAAA,uBAAA;;IACL,gBACN,KAA6B;AAE7B,cAAQ,KAAK;QACZ,KAAK,sCAAyB;AAC7B,iBAAO,KAAK,aAAY;QACzB,KAAK,sCAAyB;AAC7B,iBAAO;MACT;AACA,aAAO,MAAM,gBAAgB,GAAG;IACjC;IAEA,KAAe,qBAAU,IAAC;AACzB,aAAO,eAA6C,EAAE,SAAQ,GAAE;AAC/D,gBAAQ,UAAU;UACjB,KAAK;UACL,KAAK;AACJ,oB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,SAAA,MAAA,WAAA,MAAA,UAAA,UAAA,GAAA,MAAA,uBAAA;;;AAAa,wBAAA,YAAA,uBAAA;;;;;",
4
+ "sourcesContent": ["import {\n\tCommandClasses,\n\ttype MaybeNotKnown,\n\ttype MessageOrCCLogEntry,\n\tMessagePriority,\n\ttype SupervisionResult,\n\ttype WithAddress,\n\tvalidatePayload,\n} from \"@zwave-js/core/safe\";\nimport type {\n\tCCEncodingContext,\n\tCCParsingContext,\n\tGetValueDB,\n} from \"@zwave-js/host/safe\";\nimport { Bytes } from \"@zwave-js/shared/safe\";\nimport { getEnumMemberName, pick } from \"@zwave-js/shared/safe\";\nimport { validateArgs } from \"@zwave-js/transformers\";\nimport {\n\tCCAPI,\n\tPOLL_VALUE,\n\ttype PollValueImplementation,\n\tthrowUnsupportedProperty,\n} from \"../lib/API.js\";\nimport {\n\ttype CCRaw,\n\tCommandClass,\n\ttype InterviewContext,\n\ttype RefreshValuesContext,\n} from \"../lib/CommandClass.js\";\nimport {\n\tAPI,\n\tCCCommand,\n\tcommandClass,\n\texpectedCCResponse,\n\timplementedVersion,\n\tuseSupervision,\n} from \"../lib/CommandClassDecorators.js\";\nimport {\n\ttype SetbackState,\n\tSetbackType,\n\tThermostatSetbackCommand,\n} from \"../lib/_Types.js\";\nimport { decodeSetbackState, encodeSetbackState } from \"../lib/serializers.js\";\n\n// @noSetValueAPI\n// The setback state consist of two values that must be set together\n\n@API(CommandClasses[\"Thermostat Setback\"])\nexport class ThermostatSetbackCCAPI extends CCAPI {\n\tpublic supportsCommand(\n\t\tcmd: ThermostatSetbackCommand,\n\t): MaybeNotKnown<boolean> {\n\t\tswitch (cmd) {\n\t\t\tcase ThermostatSetbackCommand.Get:\n\t\t\t\treturn this.isSinglecast();\n\t\t\tcase ThermostatSetbackCommand.Set:\n\t\t\t\treturn true; // This is mandatory\n\t\t}\n\t\treturn super.supportsCommand(cmd);\n\t}\n\n\tprotected get [POLL_VALUE](): PollValueImplementation {\n\t\treturn async function(this: ThermostatSetbackCCAPI, { property }) {\n\t\t\tswitch (property) {\n\t\t\t\tcase \"setbackType\":\n\t\t\t\tcase \"setbackState\":\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\tThermostatSetbackCommand,\n\t\t\tThermostatSetbackCommand.Get,\n\t\t);\n\n\t\tconst cc = new ThermostatSetbackCCGet({\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\tThermostatSetbackCCReport\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, [\"setbackType\", \"setbackState\"]);\n\t\t}\n\t}\n\n\t@validateArgs()\n\tpublic async set(\n\t\tsetbackType: SetbackType,\n\t\tsetbackState: SetbackState,\n\t): Promise<SupervisionResult | undefined> {\n\t\tthis.assertSupportsCommand(\n\t\t\tThermostatSetbackCommand,\n\t\t\tThermostatSetbackCommand.Get,\n\t\t);\n\n\t\tconst cc = new ThermostatSetbackCCSet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tsetbackType,\n\t\t\tsetbackState,\n\t\t});\n\t\treturn this.host.sendCommand(cc, this.commandOptions);\n\t}\n}\n\n@commandClass(CommandClasses[\"Thermostat Setback\"])\n@implementedVersion(1)\nexport class ThermostatSetbackCC extends CommandClass {\n\tdeclare ccCommand: ThermostatSetbackCommand;\n\n\tpublic async interview(\n\t\tctx: InterviewContext,\n\t): Promise<void> {\n\t\tconst node = this.getNode(ctx)!;\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\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 Setback\"],\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 thermostat state\n\t\tctx.logNode(node.id, {\n\t\t\tendpoint: this.endpointIndex,\n\t\t\tmessage: \"querying the current thermostat state...\",\n\t\t\tdirection: \"outbound\",\n\t\t});\n\t\tconst setbackResp = await api.get();\n\t\tif (setbackResp) {\n\t\t\tconst logMessage = `received current state:\nsetback type: ${getEnumMemberName(SetbackType, setbackResp.setbackType)}\nsetback state: ${setbackResp.setbackState}`;\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}\n\t}\n}\n\n// @publicAPI\nexport interface ThermostatSetbackCCSetOptions {\n\tsetbackType: SetbackType;\n\tsetbackState: SetbackState;\n}\n\n@CCCommand(ThermostatSetbackCommand.Set)\n@useSupervision()\nexport class ThermostatSetbackCCSet extends ThermostatSetbackCC {\n\tpublic constructor(\n\t\toptions: WithAddress<ThermostatSetbackCCSetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.setbackType = options.setbackType;\n\t\tthis.setbackState = options.setbackState;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): ThermostatSetbackCCSet {\n\t\tvalidatePayload(raw.payload.length >= 2);\n\t\tconst setbackType: SetbackType = raw.payload[0] & 0b11;\n\n\t\tconst setbackState: SetbackState = decodeSetbackState(raw.payload, 1)\n\t\t\t// If we receive an unknown setback state, return the raw value\n\t\t\t|| raw.payload.readInt8(1);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tsetbackType,\n\t\t\tsetbackState,\n\t\t});\n\t}\n\n\tpublic setbackType: SetbackType;\n\t/** The offset from the setpoint in 0.1 Kelvin or a special mode */\n\tpublic setbackState: SetbackState;\n\n\tpublic serialize(ctx: CCEncodingContext): Bytes {\n\t\tthis.payload = Bytes.concat([\n\t\t\t[this.setbackType & 0b11],\n\t\t\tencodeSetbackState(this.setbackState),\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\"setback type\": getEnumMemberName(\n\t\t\t\t\tSetbackType,\n\t\t\t\t\tthis.setbackType,\n\t\t\t\t),\n\t\t\t\t\"setback state\": typeof this.setbackState === \"number\"\n\t\t\t\t\t? `${this.setbackState} K`\n\t\t\t\t\t: this.setbackState,\n\t\t\t},\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport interface ThermostatSetbackCCReportOptions {\n\tsetbackType: SetbackType;\n\tsetbackState: SetbackState;\n}\n\n@CCCommand(ThermostatSetbackCommand.Report)\nexport class ThermostatSetbackCCReport extends ThermostatSetbackCC {\n\tpublic constructor(\n\t\toptions: WithAddress<ThermostatSetbackCCReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\tthis.setbackType = options.setbackType;\n\t\tthis.setbackState = options.setbackState;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): ThermostatSetbackCCReport {\n\t\tvalidatePayload(raw.payload.length >= 2);\n\t\tconst setbackType: SetbackType = raw.payload[0] & 0b11;\n\n\t\tconst setbackState: SetbackState = decodeSetbackState(raw.payload, 1)\n\t\t\t// If we receive an unknown setback state, return the raw value\n\t\t\t|| raw.payload.readInt8(1);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tsetbackType,\n\t\t\tsetbackState,\n\t\t});\n\t}\n\n\tpublic readonly setbackType: SetbackType;\n\t/** The offset from the setpoint in 0.1 Kelvin or a special mode */\n\tpublic readonly setbackState: SetbackState;\n\n\tpublic serialize(ctx: CCEncodingContext): Bytes {\n\t\tthis.payload = Bytes.concat([\n\t\t\t[this.setbackType & 0b11],\n\t\t\tencodeSetbackState(this.setbackState),\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\"setback type\": getEnumMemberName(\n\t\t\t\t\tSetbackType,\n\t\t\t\t\tthis.setbackType,\n\t\t\t\t),\n\t\t\t\t\"setback state\": typeof this.setbackState === \"number\"\n\t\t\t\t\t? `${this.setbackState} K`\n\t\t\t\t\t: this.setbackState,\n\t\t\t},\n\t\t};\n\t}\n}\n\n@CCCommand(ThermostatSetbackCommand.Get)\n@expectedCCResponse(ThermostatSetbackCCReport)\nexport class ThermostatSetbackCCGet extends ThermostatSetbackCC {}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kBAQO;AAMP,IAAAA,eAAsB;AACtB,IAAAA,eAAwC;AAExC,iBAKO;AACP,0BAKO;AACP,oCAOO;AACP,mBAIO;AACP,yBAAuD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAM1C,0BAAsB,MAAA;8BADlC,mCAAI,2BAAe,oBAAoB,CAAC,CAAC;;;;oBACE;8CAAA,YAAK;;;;;;AAAjD,mBAAA,MAAA,mBAAA,EAAA,OAAA,WAAA,GAAA,kBAAA,EAAA,MAAA,SAAA,MAAA,W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gB;AACjC,aAAO;QACN,GAAG,MAAM,WAAW,GAAG;QACvB,SAAS;UACR,oBAAgB,gCACf,0BACA,KAAK,WAAW;UAEjB,iBAAiB,OAAO,KAAK,iBAAiB,WAC3C,GAAG,KAAK,YAAY,OACpB,KAAK;;;IAGX;;;;IAKY,0BAAsB,MAAA;8BAFlC,yCAAU,sCAAyB,GAAG,OACtC,kDAAmB,yBAAyB,CAAC;;;;oBACF;8CAAA,YAAmB;;;;;;AAA/D,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": ["import_safe"]
7
7
  }
@@ -32,7 +32,6 @@ module.exports = __toCommonJS(TimeCC_exports);
32
32
  var import_core = require("@zwave-js/core");
33
33
  var import_safe = require("@zwave-js/shared/safe");
34
34
  var import_safe2 = require("@zwave-js/shared/safe");
35
- var import_strings = require("alcalzone-shared/strings/index.js");
36
35
  var import_API = require("../lib/API.js");
37
36
  var import_CommandClass = require("../lib/CommandClass.js");
38
37
  var import_CommandClassDecorators = require("../lib/CommandClassDecorators.js");
@@ -358,7 +357,7 @@ let TimeCCTimeReport = (() => {
358
357
  return {
359
358
  ...super.toLogEntry(ctx),
360
359
  message: {
361
- time: `${(0, import_strings.padStart)(this.hour.toString(), 2, "0")}:${(0, import_strings.padStart)(this.minute.toString(), 2, "0")}:${(0, import_strings.padStart)(this.second.toString(), 2, "0")}`
360
+ time: `${this.hour.toString().padStart(2, "0")}:${this.minute.toString().padStart(2, "0")}:${this.second.toString().padStart(2, "0")}`
362
361
  }
363
362
  };
364
363
  }
@@ -438,7 +437,7 @@ let TimeCCDateReport = (() => {
438
437
  return {
439
438
  ...super.toLogEntry(ctx),
440
439
  message: {
441
- date: `${(0, import_strings.padStart)(this.year.toString(), 4, "0")}-${(0, import_strings.padStart)(this.month.toString(), 2, "0")}-${(0, import_strings.padStart)(this.day.toString(), 2, "0")}`
440
+ date: `${this.year.toString().padStart(4, "0")}-${this.month.toString().padStart(2, "0")}-${this.day.toString().padStart(2, "0")}`
442
441
  }
443
442
  };
444
443
  }