@zwave-js/cc 15.19.0 → 15.20.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 (139) hide show
  1. package/build/cjs/cc/AssociationGroupInfoCC.js +1 -1
  2. package/build/cjs/cc/AssociationGroupInfoCC.js.map +2 -2
  3. package/build/cjs/cc/BatteryCC.js +2 -2
  4. package/build/cjs/cc/BatteryCC.js.map +2 -2
  5. package/build/cjs/cc/BinarySwitchCC.js +2 -2
  6. package/build/cjs/cc/BinarySwitchCC.js.map +2 -2
  7. package/build/cjs/cc/ClimateControlScheduleCC.js +1 -1
  8. package/build/cjs/cc/ClimateControlScheduleCC.js.map +2 -2
  9. package/build/cjs/cc/ColorSwitchCC.js +2 -2
  10. package/build/cjs/cc/ColorSwitchCC.js.map +2 -2
  11. package/build/cjs/cc/ConfigurationCC.js +2 -1
  12. package/build/cjs/cc/ConfigurationCC.js.map +2 -2
  13. package/build/cjs/cc/EnergyProductionCC.js +1 -1
  14. package/build/cjs/cc/EnergyProductionCC.js.map +2 -2
  15. package/build/cjs/cc/HumidityControlSetpointCC.js +1 -1
  16. package/build/cjs/cc/HumidityControlSetpointCC.js.map +2 -2
  17. package/build/cjs/cc/IndicatorCC.js +3 -3
  18. package/build/cjs/cc/IndicatorCC.js.map +2 -2
  19. package/build/cjs/cc/IrrigationCC.js +6 -6
  20. package/build/cjs/cc/IrrigationCC.js.map +2 -2
  21. package/build/cjs/cc/ManufacturerProprietaryCC.js +2 -2
  22. package/build/cjs/cc/ManufacturerProprietaryCC.js.map +2 -2
  23. package/build/cjs/cc/MeterCC.js +6 -6
  24. package/build/cjs/cc/MeterCC.js.map +2 -2
  25. package/build/cjs/cc/MultiChannelAssociationCC.js +4 -4
  26. package/build/cjs/cc/MultiChannelAssociationCC.js.map +2 -2
  27. package/build/cjs/cc/MultiChannelCC.js +6 -6
  28. package/build/cjs/cc/MultiChannelCC.js.map +2 -2
  29. package/build/cjs/cc/MultilevelSensorCC.js +2 -2
  30. package/build/cjs/cc/MultilevelSensorCC.js.map +2 -2
  31. package/build/cjs/cc/NotificationCC.js +3 -3
  32. package/build/cjs/cc/NotificationCC.js.map +2 -2
  33. package/build/cjs/cc/ScheduleEntryLockCC.js +4 -4
  34. package/build/cjs/cc/ScheduleEntryLockCC.js.map +2 -2
  35. package/build/cjs/cc/Security2CC.js +7 -7
  36. package/build/cjs/cc/Security2CC.js.map +2 -2
  37. package/build/cjs/cc/SecurityCC.js +5 -5
  38. package/build/cjs/cc/SecurityCC.js.map +2 -2
  39. package/build/cjs/cc/SoundSwitchCC.d.ts +11 -1
  40. package/build/cjs/cc/SoundSwitchCC.js +26 -1
  41. package/build/cjs/cc/SoundSwitchCC.js.map +2 -2
  42. package/build/cjs/cc/SupervisionCC.js +5 -5
  43. package/build/cjs/cc/SupervisionCC.js.map +2 -2
  44. package/build/cjs/cc/ThermostatModeCC.js +2 -2
  45. package/build/cjs/cc/ThermostatModeCC.js.map +2 -2
  46. package/build/cjs/cc/ThermostatSetpointCC.js +3 -3
  47. package/build/cjs/cc/ThermostatSetpointCC.js.map +2 -2
  48. package/build/cjs/cc/TimeCC.js +4 -4
  49. package/build/cjs/cc/TimeCC.js.map +2 -2
  50. package/build/cjs/cc/TransportServiceCC.js +2 -2
  51. package/build/cjs/cc/TransportServiceCC.js.map +2 -2
  52. package/build/cjs/cc/UserCodeCC.js +10 -10
  53. package/build/cjs/cc/UserCodeCC.js.map +2 -2
  54. package/build/cjs/cc/WindowCoveringCC.js +1 -1
  55. package/build/cjs/cc/WindowCoveringCC.js.map +2 -2
  56. package/build/cjs/cc/ZWaveProtocolCC.js +8 -8
  57. package/build/cjs/cc/ZWaveProtocolCC.js.map +2 -2
  58. package/build/cjs/cc/index.js.map +2 -2
  59. package/build/cjs/cc/manufacturerProprietary/FibaroCC.js +1 -1
  60. package/build/cjs/cc/manufacturerProprietary/FibaroCC.js.map +2 -2
  61. package/build/cjs/lib/CommandClass.js +2 -2
  62. package/build/cjs/lib/CommandClass.js.map +2 -2
  63. package/build/cjs/lib/Security2/Extension.js +2 -2
  64. package/build/cjs/lib/Security2/Extension.js.map +2 -2
  65. package/build/cjs/lib/Values.js.map +1 -1
  66. package/build/cjs/lib/traits.d.ts +9 -0
  67. package/build/esm/cc/AssociationGroupInfoCC.js +1 -1
  68. package/build/esm/cc/AssociationGroupInfoCC.js.map +1 -1
  69. package/build/esm/cc/BatteryCC.js +2 -2
  70. package/build/esm/cc/BatteryCC.js.map +1 -1
  71. package/build/esm/cc/BinarySwitchCC.js +2 -2
  72. package/build/esm/cc/BinarySwitchCC.js.map +1 -1
  73. package/build/esm/cc/ClimateControlScheduleCC.js +1 -1
  74. package/build/esm/cc/ClimateControlScheduleCC.js.map +1 -1
  75. package/build/esm/cc/ColorSwitchCC.js +2 -2
  76. package/build/esm/cc/ColorSwitchCC.js.map +1 -1
  77. package/build/esm/cc/ConfigurationCC.d.ts.map +1 -1
  78. package/build/esm/cc/ConfigurationCC.js +2 -1
  79. package/build/esm/cc/ConfigurationCC.js.map +1 -1
  80. package/build/esm/cc/EnergyProductionCC.js +1 -1
  81. package/build/esm/cc/EnergyProductionCC.js.map +1 -1
  82. package/build/esm/cc/HumidityControlSetpointCC.js +1 -1
  83. package/build/esm/cc/HumidityControlSetpointCC.js.map +1 -1
  84. package/build/esm/cc/IndicatorCC.js +3 -3
  85. package/build/esm/cc/IndicatorCC.js.map +1 -1
  86. package/build/esm/cc/IrrigationCC.js +6 -6
  87. package/build/esm/cc/IrrigationCC.js.map +1 -1
  88. package/build/esm/cc/ManufacturerProprietaryCC.js +2 -2
  89. package/build/esm/cc/ManufacturerProprietaryCC.js.map +1 -1
  90. package/build/esm/cc/MeterCC.js +6 -6
  91. package/build/esm/cc/MeterCC.js.map +1 -1
  92. package/build/esm/cc/MultiChannelAssociationCC.js +4 -4
  93. package/build/esm/cc/MultiChannelAssociationCC.js.map +1 -1
  94. package/build/esm/cc/MultiChannelCC.js +6 -6
  95. package/build/esm/cc/MultiChannelCC.js.map +1 -1
  96. package/build/esm/cc/MultilevelSensorCC.js +2 -2
  97. package/build/esm/cc/MultilevelSensorCC.js.map +1 -1
  98. package/build/esm/cc/NotificationCC.js +3 -3
  99. package/build/esm/cc/NotificationCC.js.map +1 -1
  100. package/build/esm/cc/ScheduleEntryLockCC.js +4 -4
  101. package/build/esm/cc/ScheduleEntryLockCC.js.map +1 -1
  102. package/build/esm/cc/Security2CC.js +7 -7
  103. package/build/esm/cc/Security2CC.js.map +1 -1
  104. package/build/esm/cc/SecurityCC.js +5 -5
  105. package/build/esm/cc/SecurityCC.js.map +1 -1
  106. package/build/esm/cc/SoundSwitchCC.d.ts +11 -1
  107. package/build/esm/cc/SoundSwitchCC.d.ts.map +1 -1
  108. package/build/esm/cc/SoundSwitchCC.js +26 -1
  109. package/build/esm/cc/SoundSwitchCC.js.map +1 -1
  110. package/build/esm/cc/SupervisionCC.js +5 -5
  111. package/build/esm/cc/SupervisionCC.js.map +1 -1
  112. package/build/esm/cc/ThermostatModeCC.js +2 -2
  113. package/build/esm/cc/ThermostatModeCC.js.map +1 -1
  114. package/build/esm/cc/ThermostatSetpointCC.js +3 -3
  115. package/build/esm/cc/ThermostatSetpointCC.js.map +1 -1
  116. package/build/esm/cc/TimeCC.js +4 -4
  117. package/build/esm/cc/TimeCC.js.map +1 -1
  118. package/build/esm/cc/TransportServiceCC.js +2 -2
  119. package/build/esm/cc/TransportServiceCC.js.map +1 -1
  120. package/build/esm/cc/UserCodeCC.js +10 -10
  121. package/build/esm/cc/UserCodeCC.js.map +1 -1
  122. package/build/esm/cc/WindowCoveringCC.js +1 -1
  123. package/build/esm/cc/WindowCoveringCC.js.map +1 -1
  124. package/build/esm/cc/ZWaveProtocolCC.js +8 -8
  125. package/build/esm/cc/ZWaveProtocolCC.js.map +1 -1
  126. package/build/esm/cc/index.d.ts.map +1 -1
  127. package/build/esm/cc/index.js +0 -1
  128. package/build/esm/cc/index.js.map +1 -1
  129. package/build/esm/cc/manufacturerProprietary/FibaroCC.js +1 -1
  130. package/build/esm/cc/manufacturerProprietary/FibaroCC.js.map +1 -1
  131. package/build/esm/lib/CommandClass.js +2 -2
  132. package/build/esm/lib/CommandClass.js.map +1 -1
  133. package/build/esm/lib/Security2/Extension.js +2 -2
  134. package/build/esm/lib/Security2/Extension.js.map +1 -1
  135. package/build/esm/lib/Values.js +1 -1
  136. package/build/esm/lib/Values.js.map +1 -1
  137. package/build/esm/lib/traits.d.ts +9 -0
  138. package/build/esm/lib/traits.d.ts.map +1 -1
  139. package/package.json +5 -5
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/cc/SecurityCC.ts"],
4
- "sourcesContent": ["import type { CCEncodingContext, CCParsingContext } from \"@zwave-js/cc\";\nimport {\n\tCommandClasses,\n\tEncapsulationFlags,\n\ttype GetNode,\n\ttype GetValueDB,\n\ttype MaybeNotKnown,\n\ttype MessageOrCCLogEntry,\n\tMessagePriority,\n\ttype MessageRecord,\n\ttype NodeId,\n\tSecurityClass,\n\ttype SecurityManager,\n\ttype SupportsCC,\n\tTransmitOptions,\n\ttype WithAddress,\n\tZWaveError,\n\tZWaveErrorCodes,\n\tcomputeMAC,\n\tdecryptAES128OFB,\n\tencodeCCList,\n\tencryptAES128OFB,\n\tgenerateAuthKey,\n\tgenerateEncryptionKey,\n\tgetCCName,\n\tisTransmissionError,\n\tparseCCList,\n\trandomBytes,\n\tvalidatePayload,\n} from \"@zwave-js/core\";\nimport {\n\tBytes,\n\ttype BytesView,\n\tbuffer2hex,\n\tnum2hex,\n\tpick,\n} from \"@zwave-js/shared\";\nimport { wait } from \"alcalzone-shared/async\";\nimport { CCAPI, PhysicalCCAPI } from \"../lib/API.js\";\nimport {\n\ttype CCRaw,\n\tCommandClass,\n\ttype InterviewContext,\n} from \"../lib/CommandClass.js\";\nimport {\n\tAPI,\n\tCCCommand,\n\tcommandClass,\n\texpectedCCResponse,\n\timplementedVersion,\n} from \"../lib/CommandClassDecorators.js\";\nimport { SecurityCommand } from \"../lib/_Types.js\";\nimport { CRC16CC } from \"./CRC16CC.js\";\nimport { Security2CC } from \"./Security2CC.js\";\nimport { TransportServiceCC } from \"./TransportServiceCC.js\";\n\n// @noSetValueAPI This is an encapsulation CC\n\nfunction getAuthenticationData(\n\tsenderNonce: BytesView,\n\treceiverNonce: BytesView,\n\tccCommand: SecurityCommand,\n\tsendingNodeId: number,\n\treceivingNodeId: number,\n\tencryptedPayload: BytesView,\n): BytesView {\n\treturn Bytes.concat([\n\t\tsenderNonce,\n\t\treceiverNonce,\n\t\tBytes.from([\n\t\t\tccCommand,\n\t\t\tsendingNodeId,\n\t\t\treceivingNodeId,\n\t\t\tencryptedPayload.length,\n\t\t]),\n\t\tencryptedPayload,\n\t]);\n}\n\nfunction throwNoNonce(reason?: string): never {\n\tlet message = `Security CC requires a nonce to be sent!`;\n\tif (reason) message += ` Reason: ${reason}`;\n\tthrow new ZWaveError(message, ZWaveErrorCodes.SecurityCC_NoNonce);\n}\n\nconst HALF_NONCE_SIZE = 8;\n\nfunction assertSecurityRX(\n\tctx: CCParsingContext,\n): asserts ctx is CCParsingContext & { securityManager: SecurityManager } {\n\tif (!ctx.ownNodeId) {\n\t\tthrow new ZWaveError(\n\t\t\t`Secure commands (S0) can only be decoded when the controller's node id is known!`,\n\t\t\tZWaveErrorCodes.Driver_NotReady,\n\t\t);\n\t}\n\n\tif (!ctx.securityManager) {\n\t\tthrow new ZWaveError(\n\t\t\t`Secure commands (S0) can only be decoded when the security manager is set up!`,\n\t\t\tZWaveErrorCodes.Driver_NoSecurity,\n\t\t);\n\t}\n}\n\nfunction assertSecurityTX(\n\tctx: CCEncodingContext,\n): asserts ctx is CCEncodingContext & { securityManager: SecurityManager } {\n\tif (!ctx.ownNodeId) {\n\t\tthrow new ZWaveError(\n\t\t\t`Secure commands (S0) can only be sent when the controller's node id is known!`,\n\t\t\tZWaveErrorCodes.Driver_NotReady,\n\t\t);\n\t}\n\n\tif (!ctx.securityManager) {\n\t\tthrow new ZWaveError(\n\t\t\t`Secure commands (S0) can only be sent when the security manager is set up!`,\n\t\t\tZWaveErrorCodes.Driver_NoSecurity,\n\t\t);\n\t}\n}\n\n// TODO: Ignore commands if received via multicast\n\n// Encapsulation CCs are used internally and too frequently that we\n// want to pay the cost of validating each call\n/* eslint-disable @zwave-js/ccapi-validate-args */\n\n@API(CommandClasses.Security)\nexport class SecurityCCAPI extends PhysicalCCAPI {\n\tpublic supportsCommand(_cmd: SecurityCommand): MaybeNotKnown<boolean> {\n\t\t// All commands are mandatory\n\t\treturn true;\n\t}\n\n\tpublic async sendEncapsulated(\n\t\tencapsulated: CommandClass,\n\t\trequestNextNonce: boolean = false,\n\t): Promise<void> {\n\t\tif (requestNextNonce) {\n\t\t\tthis.assertSupportsCommand(\n\t\t\t\tSecurityCommand,\n\t\t\t\tSecurityCommand.CommandEncapsulation,\n\t\t\t);\n\t\t} else {\n\t\t\tthis.assertSupportsCommand(\n\t\t\t\tSecurityCommand,\n\t\t\t\tSecurityCommand.CommandEncapsulationNonceGet,\n\t\t\t);\n\t\t}\n\n\t\tconst cc = new (\n\t\t\trequestNextNonce\n\t\t\t\t? SecurityCCCommandEncapsulationNonceGet\n\t\t\t\t: SecurityCCCommandEncapsulation\n\t\t)({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tencapsulated,\n\t\t});\n\t\tawait this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\t/**\n\t * Requests a new nonce for Security CC encapsulation which is not directly linked to a specific command.\n\t */\n\tpublic async getNonce(): Promise<BytesView | undefined> {\n\t\tthis.assertSupportsCommand(SecurityCommand, SecurityCommand.NonceGet);\n\n\t\tconst cc = new SecurityCCNonceGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tconst response = await this.host.sendCommand<SecurityCCNonceReport>(\n\t\t\tcc,\n\t\t\t{\n\t\t\t\t...this.commandOptions,\n\t\t\t\t// Only try getting a nonce once\n\t\t\t\tmaxSendAttempts: 1,\n\t\t\t},\n\t\t);\n\t\tif (!response) return;\n\n\t\tconst nonce = response.nonce;\n\t\tconst secMan = this.host.securityManager!;\n\t\tsecMan.setNonce(\n\t\t\t{\n\t\t\t\tissuer: this.endpoint.nodeId,\n\t\t\t\tnonceId: secMan.getNonceId(nonce),\n\t\t\t},\n\t\t\t{ nonce, receiver: this.host.ownNodeId },\n\t\t\t{ free: true },\n\t\t);\n\t\treturn nonce;\n\t}\n\n\t/**\n\t * Responds to a NonceGet request. The message is sent without any retransmission etc.\n\t * The return value indicates whether a nonce was successfully sent\n\t */\n\tpublic async sendNonce(): Promise<boolean> {\n\t\tthis.assertSupportsCommand(\n\t\t\tSecurityCommand,\n\t\t\tSecurityCommand.NonceReport,\n\t\t);\n\n\t\tif (!this.host.securityManager) {\n\t\t\tthrow new ZWaveError(\n\t\t\t\t`Nonces can only be sent if secure communication is set up!`,\n\t\t\t\tZWaveErrorCodes.Driver_NoSecurity,\n\t\t\t);\n\t\t}\n\n\t\tconst nonce = this.host.securityManager.generateNonce(\n\t\t\tthis.endpoint.nodeId,\n\t\t\tHALF_NONCE_SIZE,\n\t\t);\n\t\tconst nonceId = this.host.securityManager.getNonceId(nonce);\n\n\t\tconst cc = new SecurityCCNonceReport({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tnonce,\n\t\t});\n\n\t\ttry {\n\t\t\tawait this.host.sendCommand(cc, {\n\t\t\t\t...this.commandOptions,\n\t\t\t\t// Seems we need these options or some nodes won't accept the nonce\n\t\t\t\ttransmitOptions: TransmitOptions.ACK\n\t\t\t\t\t| TransmitOptions.AutoRoute,\n\t\t\t\t// Only try sending a nonce once\n\t\t\t\tmaxSendAttempts: 1,\n\t\t\t\t// Nonce requests must be handled immediately\n\t\t\t\tpriority: MessagePriority.Immediate,\n\t\t\t\t// We don't want failures causing us to treat the node as asleep or dead\n\t\t\t\tchangeNodeStatusOnMissingACK: false,\n\t\t\t});\n\t\t} catch (e) {\n\t\t\tif (isTransmissionError(e)) {\n\t\t\t\t// The nonce could not be sent, invalidate it\n\t\t\t\tthis.host.securityManager.deleteNonce(nonceId);\n\t\t\t\treturn false;\n\t\t\t} else {\n\t\t\t\t// Pass other errors through\n\t\t\t\tthrow e;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\tpublic async getSecurityScheme(): Promise<[0]> {\n\t\tthis.assertSupportsCommand(SecurityCommand, SecurityCommand.SchemeGet);\n\n\t\tconst cc = new SecurityCCSchemeGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tawait this.host.sendCommand(cc, this.commandOptions);\n\t\t// There is only one scheme, so we hardcode it\n\t\treturn [0];\n\t}\n\n\tpublic async reportSecurityScheme(encapsulated: boolean): Promise<void> {\n\t\tthis.assertSupportsCommand(\n\t\t\tSecurityCommand,\n\t\t\tSecurityCommand.SchemeReport,\n\t\t);\n\n\t\tlet cc: CommandClass = new SecurityCCSchemeReport({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tif (encapsulated) {\n\t\t\tcc = new SecurityCCCommandEncapsulation({\n\t\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\t\tendpointIndex: this.endpoint.index,\n\t\t\t\tencapsulated: cc,\n\t\t\t});\n\t\t}\n\t\tawait this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\tpublic async inheritSecurityScheme(): Promise<void> {\n\t\tthis.assertSupportsCommand(\n\t\t\tSecurityCommand,\n\t\t\tSecurityCommand.SchemeInherit,\n\t\t);\n\n\t\tconst cc = new SecurityCCSchemeInherit({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tawait this.host.sendCommand(cc, this.commandOptions);\n\t\t// There is only one scheme, so we don't return anything here\n\t}\n\n\tpublic async setNetworkKey(networkKey: BytesView): Promise<void> {\n\t\tthis.assertSupportsCommand(\n\t\t\tSecurityCommand,\n\t\t\tSecurityCommand.NetworkKeySet,\n\t\t);\n\n\t\tconst keySet = new SecurityCCNetworkKeySet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tnetworkKey,\n\t\t});\n\t\tconst cc = new SecurityCCCommandEncapsulation({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tencapsulated: keySet,\n\t\t\talternativeNetworkKey: new Uint8Array(16).fill(0),\n\t\t});\n\t\tawait this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\tpublic async verifyNetworkKey(): Promise<void> {\n\t\tthis.assertSupportsCommand(\n\t\t\tSecurityCommand,\n\t\t\tSecurityCommand.NetworkKeyVerify,\n\t\t);\n\n\t\tconst cc = new SecurityCCNetworkKeyVerify({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tawait this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\t// oxlint-disable-next-line typescript/explicit-module-boundary-types\n\tpublic async getSupportedCommands() {\n\t\tthis.assertSupportsCommand(\n\t\t\tSecurityCommand,\n\t\t\tSecurityCommand.CommandsSupportedGet,\n\t\t);\n\n\t\tconst cc = new SecurityCCCommandsSupportedGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tconst response = await this.host.sendCommand<\n\t\t\tSecurityCCCommandsSupportedReport\n\t\t>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\tif (response) {\n\t\t\treturn pick(response, [\"supportedCCs\", \"controlledCCs\"]);\n\t\t}\n\t}\n\n\tpublic async reportSupportedCommands(\n\t\tsupportedCCs: CommandClasses[],\n\t\tcontrolledCCs: CommandClasses[],\n\t): Promise<void> {\n\t\tthis.assertSupportsCommand(\n\t\t\tSecurityCommand,\n\t\t\tSecurityCommand.CommandsSupportedReport,\n\t\t);\n\n\t\tconst cc = new SecurityCCCommandsSupportedReport({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tsupportedCCs,\n\t\t\tcontrolledCCs,\n\t\t\treportsToFollow: 0,\n\t\t});\n\t\tawait this.host.sendCommand(cc, this.commandOptions);\n\t}\n}\n\n@commandClass(CommandClasses.Security)\n@implementedVersion(1)\nexport class SecurityCC extends CommandClass {\n\tdeclare ccCommand: SecurityCommand;\n\t// Force singlecast for the Security CC\n\tdeclare nodeId: number;\n\n\tpublic async interview(\n\t\tctx: InterviewContext,\n\t): Promise<void> {\n\t\tconst node = this.getNode(ctx)!;\n\t\tconst endpoint = this.getEndpoint(ctx)!;\n\t\tconst api = CCAPI.create(\n\t\t\tCommandClasses.Security,\n\t\t\tctx,\n\t\t\tendpoint,\n\t\t).withOptions({\n\t\t\tpriority: MessagePriority.NodeQuery,\n\t\t});\n\n\t\tctx.logNode(node.id, {\n\t\t\tmessage: \"Querying securely supported commands (S0)...\",\n\t\t\tdirection: \"outbound\",\n\t\t});\n\n\t\tlet supportedCCs: CommandClasses[] | undefined;\n\t\tlet controlledCCs: CommandClasses[] | undefined;\n\n\t\t// Try up to 3 times on the root device. We REALLY don't want a spurious timeout or collision to cause us to discard a known good security class\n\t\tconst MAX_ATTEMPTS = this.endpointIndex === 0 ? 3 : 1;\n\t\tfor (let attempts = 1; attempts <= MAX_ATTEMPTS; attempts++) {\n\t\t\tconst resp = await api.getSupportedCommands();\n\t\t\tif (resp) {\n\t\t\t\tsupportedCCs = resp.supportedCCs;\n\t\t\t\tcontrolledCCs = resp.controlledCCs;\n\t\t\t\tbreak;\n\t\t\t} else if (attempts < MAX_ATTEMPTS) {\n\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\t\tmessage:\n\t\t\t\t\t\t`Querying securely supported commands (S0), attempt ${attempts}/${MAX_ATTEMPTS} failed. Retrying in 500ms...`,\n\t\t\t\t\tlevel: \"warn\",\n\t\t\t\t});\n\t\t\t\tawait wait(500);\n\t\t\t}\n\t\t}\n\n\t\tif (!supportedCCs || !controlledCCs) {\n\t\t\tif (node.hasSecurityClass(SecurityClass.S0_Legacy) === true) {\n\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\t\tmessage: \"Querying securely supported commands (S0) failed\",\n\t\t\t\t\tlevel: \"warn\",\n\t\t\t\t});\n\t\t\t\t// TODO: Abort interview?\n\t\t\t} else {\n\t\t\t\t// We didn't know if the node was secure and it didn't respond,\n\t\t\t\t// assume that it doesn't have the S0 security class\n\t\t\t\tctx.logNode(\n\t\t\t\t\tnode.id,\n\t\t\t\t\t`The node was not granted the S0 security class. Continuing interview non-securely.`,\n\t\t\t\t);\n\t\t\t\tnode.setSecurityClass(SecurityClass.S0_Legacy, false);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tconst logLines: string[] = [\n\t\t\t\"received secure commands (S0)\",\n\t\t\t\"supported CCs:\",\n\t\t];\n\t\tfor (const cc of supportedCCs) {\n\t\t\tlogLines.push(`\u00B7 ${getCCName(cc)}`);\n\t\t}\n\t\tlogLines.push(\"controlled CCs:\");\n\t\tfor (const cc of controlledCCs) {\n\t\t\tlogLines.push(`\u00B7 ${getCCName(cc)}`);\n\t\t}\n\t\tctx.logNode(node.id, {\n\t\t\tmessage: logLines.join(\"\\n\"),\n\t\t\tdirection: \"inbound\",\n\t\t});\n\n\t\t// Remember which commands are supported securely\n\t\tfor (const cc of supportedCCs) {\n\t\t\t// Basic CC has special rules for when it is considered supported\n\t\t\t// Therefore we mark all other CCs as supported, but not Basic CC,\n\t\t\t// for which support is determined later.\n\t\t\tif (cc === CommandClasses.Basic) {\n\t\t\t\tendpoint.addCC(cc, { secure: true });\n\t\t\t} else {\n\t\t\t\tendpoint.addCC(cc, {\n\t\t\t\t\tisSupported: true,\n\t\t\t\t\tsecure: true,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\tfor (const cc of controlledCCs) {\n\t\t\t// Basic CC has special rules for when it is considered supported\n\t\t\t// Therefore we mark all other CCs as supported, but not Basic CC,\n\t\t\t// for which support is determined later.\n\t\t\tif (cc === CommandClasses.Basic) {\n\t\t\t\tendpoint.addCC(cc, { secure: true });\n\t\t\t} else {\n\t\t\t\tendpoint.addCC(cc, {\n\t\t\t\t\tisControlled: true,\n\t\t\t\t\tsecure: true,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t// We know for sure that the node is included securely\n\t\tif (node.hasSecurityClass(SecurityClass.S0_Legacy) !== true) {\n\t\t\tnode.setSecurityClass(SecurityClass.S0_Legacy, true);\n\t\t\tctx.logNode(\n\t\t\t\tnode.id,\n\t\t\t\t`The node was granted the S0 security class`,\n\t\t\t);\n\t\t}\n\n\t\t// Remember that the interview is complete\n\t\tthis.setInterviewComplete(ctx, true);\n\t}\n\n\t/** Tests if a command should be sent secure and thus requires encapsulation */\n\tpublic static requiresEncapsulation(cc: CommandClass): boolean {\n\t\t// No security flag -> no encapsulation\n\t\tif (!(cc.encapsulationFlags & EncapsulationFlags.Security)) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// S2, CRC16, Transport Service -> no S2 encapsulation\n\t\tif (\n\t\t\tcc instanceof Security2CC\n\t\t\t|| cc instanceof CRC16CC\n\t\t\t|| cc instanceof TransportServiceCC\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// S0: check command\n\t\tif (cc instanceof SecurityCC) {\n\t\t\tswitch (cc.ccCommand) {\n\t\t\t\t// Already encapsulated\n\t\t\t\tcase SecurityCommand.CommandEncapsulation:\n\t\t\t\tcase SecurityCommand.CommandEncapsulationNonceGet:\n\t\t\t\t// Cannot be sent encapsulated:\n\t\t\t\tcase SecurityCommand.NonceGet:\n\t\t\t\tcase SecurityCommand.NonceReport:\n\t\t\t\tcase SecurityCommand.SchemeGet:\n\t\t\t\tcase SecurityCommand.SchemeReport:\n\t\t\t\t\treturn false;\n\n\t\t\t\tdefault:\n\t\t\t\t\t// All other commands must be encapsulated\n\t\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\t// Everything else needs to be encapsulated if the CC is secure\n\t\treturn true;\n\t}\n\n\t/** Encapsulates a command that should be sent encrypted */\n\tpublic static encapsulate(\n\t\townNodeId: number,\n\t\tsecurityManager: SecurityManager,\n\t\tcc: CommandClass,\n\t): SecurityCCCommandEncapsulation {\n\t\t// TODO: When to return a SecurityCCCommandEncapsulationNonceGet?\n\t\tconst ret = new SecurityCCCommandEncapsulation({\n\t\t\tnodeId: cc.nodeId,\n\t\t\tencapsulated: cc,\n\t\t});\n\n\t\t// Copy the encapsulation flags from the encapsulated command\n\t\t// but omit Security, since we're doing that right now\n\t\tret.encapsulationFlags = cc.encapsulationFlags\n\t\t\t& ~EncapsulationFlags.Security;\n\n\t\treturn ret;\n\t}\n}\n\ninterface SecurityCCNonceReportOptions {\n\tnonce: BytesView;\n}\n\n@CCCommand(SecurityCommand.NonceReport)\nexport class SecurityCCNonceReport extends SecurityCC {\n\tconstructor(\n\t\toptions: WithAddress<SecurityCCNonceReportOptions>,\n\t) {\n\t\tsuper(options);\n\t\tif (options.nonce.length !== HALF_NONCE_SIZE) {\n\t\t\tthrow new ZWaveError(\n\t\t\t\t`Nonce must have length ${HALF_NONCE_SIZE}!`,\n\t\t\t\tZWaveErrorCodes.Argument_Invalid,\n\t\t\t);\n\t\t}\n\t\tthis.nonce = options.nonce;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): SecurityCCNonceReport {\n\t\tvalidatePayload.withReason(\"Invalid nonce length\")(\n\t\t\traw.payload.length === HALF_NONCE_SIZE,\n\t\t);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tnonce: raw.payload,\n\t\t});\n\t}\n\n\tpublic nonce: BytesView;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.view(this.nonce);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: { nonce: buffer2hex(this.nonce) },\n\t\t};\n\t}\n}\n\n@CCCommand(SecurityCommand.NonceGet)\n@expectedCCResponse(SecurityCCNonceReport)\nexport class SecurityCCNonceGet extends SecurityCC {}\n\n// @publicAPI\nexport type SecurityCCCommandEncapsulationOptions =\n\t& {\n\t\talternativeNetworkKey?: BytesView;\n\t}\n\t& ({\n\t\tencapsulated: CommandClass;\n\t} | {\n\t\tdecryptedCCBytes: BytesView;\n\t\tsequenced: boolean;\n\t\tsecondFrame: boolean;\n\t\tsequenceCounter: number;\n\t});\n\nfunction getCCResponseForCommandEncapsulation(\n\tctx: GetNode<NodeId & SupportsCC>,\n\tsent: SecurityCCCommandEncapsulation,\n) {\n\tif (sent.encapsulated.expectsCCResponse(ctx)) {\n\t\treturn SecurityCCCommandEncapsulation;\n\t}\n}\n\n@CCCommand(SecurityCommand.CommandEncapsulation)\n@expectedCCResponse(\n\tgetCCResponseForCommandEncapsulation,\n\t() => \"checkEncapsulated\",\n)\nexport class SecurityCCCommandEncapsulation extends SecurityCC {\n\tpublic constructor(\n\t\toptions: WithAddress<SecurityCCCommandEncapsulationOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\tif (\"encapsulated\" in options) {\n\t\t\tthis.encapsulated = options.encapsulated;\n\t\t\tthis.encapsulated.encapsulatingCC = this as any;\n\t\t} else {\n\t\t\tthis.decryptedCCBytes = options.decryptedCCBytes;\n\t\t\tthis.sequenced = options.sequenced;\n\t\t\tthis.secondFrame = options.secondFrame;\n\t\t\tthis.sequenceCounter = options.sequenceCounter;\n\t\t}\n\t\tthis.alternativeNetworkKey = options.alternativeNetworkKey;\n\t}\n\n\tpublic static async from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): Promise<SecurityCCCommandEncapsulation> {\n\t\tassertSecurityRX(ctx);\n\n\t\t// HALF_NONCE_SIZE bytes iv, 1 byte frame control, at least 1 CC byte, 1 byte nonce id, 8 bytes auth code\n\t\tvalidatePayload(\n\t\t\traw.payload.length >= HALF_NONCE_SIZE + 1 + 1 + 1 + 8,\n\t\t);\n\t\tconst iv = raw.payload.subarray(0, HALF_NONCE_SIZE);\n\t\tconst encryptedPayload = raw.payload.subarray(HALF_NONCE_SIZE, -9);\n\t\tconst nonceId = raw.payload.at(-9)!;\n\t\tconst authCode = raw.payload.subarray(-8);\n\n\t\t// Retrieve the used nonce from the nonce store\n\t\tconst nonce = ctx.securityManager.getNonce(nonceId);\n\t\t// Only accept the message if the nonce hasn't expired\n\t\tif (!nonce) {\n\t\t\tvalidatePayload.fail(\n\t\t\t\t`Nonce ${\n\t\t\t\t\tnum2hex(\n\t\t\t\t\t\tnonceId,\n\t\t\t\t\t)\n\t\t\t\t} expired, cannot decode security encapsulated command.`,\n\t\t\t);\n\t\t}\n\t\t// and mark the nonce as used\n\t\tctx.securityManager.deleteNonce(nonceId);\n\n\t\t// Validate the encrypted data\n\t\tconst authData = getAuthenticationData(\n\t\t\tiv,\n\t\t\tnonce,\n\t\t\tSecurityCommand.CommandEncapsulation,\n\t\t\tctx.sourceNodeId,\n\t\t\tctx.ownNodeId,\n\t\t\tencryptedPayload,\n\t\t);\n\t\tconst expectedAuthCode = await computeMAC(\n\t\t\tauthData,\n\t\t\tawait ctx.securityManager.getAuthKey(),\n\t\t);\n\t\t// Only accept messages with a correct auth code\n\t\tvalidatePayload.withReason(\n\t\t\t\"Invalid auth code, won't accept security encapsulated command.\",\n\t\t)(authCode.equals(expectedAuthCode));\n\n\t\t// Decrypt the encapsulated CC\n\t\tconst frameControlAndDecryptedCC = await decryptAES128OFB(\n\t\t\tencryptedPayload,\n\t\t\tawait ctx.securityManager.getEncryptionKey(),\n\t\t\tBytes.concat([iv, nonce]),\n\t\t);\n\t\tconst frameControl = frameControlAndDecryptedCC[0];\n\t\tconst sequenceCounter = frameControl & 0b1111;\n\t\tconst sequenced = !!(frameControl & 0b1_0000);\n\t\tconst secondFrame = !!(frameControl & 0b10_0000);\n\t\tconst decryptedCCBytes: BytesView | undefined =\n\t\t\tframeControlAndDecryptedCC\n\t\t\t\t.subarray(1);\n\n\t\tconst ret = new SecurityCCCommandEncapsulation({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tsequenceCounter,\n\t\t\tsequenced,\n\t\t\tsecondFrame,\n\t\t\tdecryptedCCBytes,\n\t\t});\n\n\t\tret.authData = authData;\n\t\tret.authCode = authCode;\n\t\tret.iv = iv;\n\n\t\treturn ret;\n\t}\n\n\tprivate sequenced: boolean | undefined;\n\tprivate secondFrame: boolean | undefined;\n\tprivate sequenceCounter: number | undefined;\n\n\tprivate decryptedCCBytes: BytesView | undefined;\n\tpublic encapsulated!: CommandClass;\n\n\tprivate alternativeNetworkKey?: BytesView;\n\n\tpublic get nonceId(): number | undefined {\n\t\treturn this.nonce?.[0];\n\t}\n\tpublic nonce: BytesView | undefined;\n\n\t// Only used testing/for debugging purposes\n\tprivate iv?: BytesView;\n\tprivate authData?: BytesView;\n\tprivate authCode?: BytesView;\n\tprivate ciphertext?: BytesView;\n\n\tpublic getPartialCCSessionId(): Record<string, any> | undefined {\n\t\tif (this.sequenced) {\n\t\t\treturn {\n\t\t\t\t// Treat Encapsulation and EncapsulationNonceGet as one\n\t\t\t\tccCommand: undefined,\n\t\t\t\tsequence: this.sequenceCounter,\n\t\t\t};\n\t\t} else {\n\t\t\treturn {\n\t\t\t\t// Treat Encapsulation and EncapsulationNonceGet as one\n\t\t\t\tccCommand: undefined,\n\t\t\t};\n\t\t}\n\t}\n\n\tpublic expectMoreMessages(): boolean {\n\t\treturn !!this.sequenced && !this.secondFrame;\n\t}\n\n\tpublic async mergePartialCCs(\n\t\tpartials: SecurityCCCommandEncapsulation[],\n\t\tctx: CCParsingContext,\n\t): Promise<void> {\n\t\t// Concat the CC buffers\n\t\tthis.decryptedCCBytes = Bytes.concat(\n\t\t\t[...partials, this].map((cc) => cc.decryptedCCBytes!),\n\t\t);\n\t\t// make sure this contains a complete CC command that's worth splitting\n\t\tvalidatePayload(this.decryptedCCBytes.length >= 2);\n\t\t// and deserialize the CC\n\t\tthis.encapsulated = await CommandClass.parse(\n\t\t\tthis.decryptedCCBytes,\n\t\t\tctx,\n\t\t);\n\t\tthis.encapsulated.encapsulatingCC = this as any;\n\t}\n\n\tpublic async serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tif (!this.nonce) throwNoNonce();\n\t\tif (this.nonce.length !== HALF_NONCE_SIZE) {\n\t\t\tthrowNoNonce(\"Invalid nonce size\");\n\t\t}\n\t\tassertSecurityTX(ctx);\n\n\t\tlet authKey: BytesView;\n\t\tlet encryptionKey: BytesView;\n\t\tif (this.alternativeNetworkKey) {\n\t\t\tauthKey = await generateAuthKey(this.alternativeNetworkKey);\n\t\t\tencryptionKey = await generateEncryptionKey(\n\t\t\t\tthis.alternativeNetworkKey,\n\t\t\t);\n\t\t} else {\n\t\t\tauthKey = await ctx.securityManager.getAuthKey();\n\t\t\tencryptionKey = await ctx.securityManager.getEncryptionKey();\n\t\t}\n\n\t\tconst serializedCC = await this.encapsulated.serialize(ctx);\n\t\tconst plaintext = Bytes.concat([\n\t\t\tBytes.from([0]), // TODO: frame control\n\t\t\tserializedCC,\n\t\t]);\n\t\t// Encrypt the payload\n\t\tconst senderNonce = randomBytes(HALF_NONCE_SIZE);\n\t\tconst iv = Bytes.concat([senderNonce, this.nonce]);\n\t\tconst ciphertext = await encryptAES128OFB(\n\t\t\tplaintext,\n\t\t\tencryptionKey,\n\t\t\tiv,\n\t\t);\n\t\t// And generate the auth code\n\t\tconst authData = getAuthenticationData(\n\t\t\tsenderNonce,\n\t\t\tthis.nonce,\n\t\t\tthis.ccCommand,\n\t\t\tctx.ownNodeId,\n\t\t\tthis.nodeId,\n\t\t\tciphertext,\n\t\t);\n\t\tconst authCode = await computeMAC(authData, authKey);\n\n\t\t// Remember for debugging purposes\n\t\tthis.iv = iv;\n\t\tthis.authData = authData;\n\t\tthis.authCode = authCode;\n\t\tthis.ciphertext = ciphertext;\n\n\t\tthis.payload = Bytes.concat([\n\t\t\tsenderNonce,\n\t\t\tciphertext,\n\t\t\tBytes.from([this.nonceId!]),\n\t\t\tauthCode,\n\t\t]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tprotected computeEncapsulationOverhead(): number {\n\t\t// Security CC adds 8 bytes IV, 1 byte frame control, 1 byte nonce ID, 8 bytes MAC\n\t\treturn super.computeEncapsulationOverhead() + 18;\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\tconst message: MessageRecord = {};\n\t\tif (this.nonceId != undefined) {\n\t\t\tmessage[\"nonce id\"] = this.nonceId;\n\t\t}\n\t\tif (this.sequenced != undefined) {\n\t\t\tmessage.sequenced = this.sequenced;\n\t\t\tif (this.sequenced) {\n\t\t\t\tif (this.secondFrame != undefined) {\n\t\t\t\t\tmessage[\"second frame\"] = this.secondFrame;\n\t\t\t\t}\n\t\t\t\tif (this.sequenceCounter != undefined) {\n\t\t\t\t\tmessage[\"sequence counter\"] = this.sequenceCounter;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Log the plaintext in integration tests and development mode\n\t\tif (\n\t\t\tprocess.env.NODE_ENV === \"test\"\n\t\t\t|| process.env.NODE_ENV === \"development\"\n\t\t) {\n\t\t\tif (this.iv) {\n\t\t\t\tmessage.IV = buffer2hex(this.iv);\n\t\t\t}\n\t\t\tif (this.ciphertext) {\n\t\t\t\tmessage.ciphertext = buffer2hex(this.ciphertext);\n\t\t\t} else if (this.decryptedCCBytes) {\n\t\t\t\tmessage.plaintext = buffer2hex(this.decryptedCCBytes);\n\t\t\t}\n\t\t\tif (this.authData) {\n\t\t\t\tmessage[\"auth data\"] = buffer2hex(this.authData);\n\t\t\t}\n\t\t\tif (this.authCode) {\n\t\t\t\tmessage[\"auth code\"] = buffer2hex(this.authCode);\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage,\n\t\t};\n\t}\n}\n\n// This is the same message, but with another CC command\n@CCCommand(SecurityCommand.CommandEncapsulationNonceGet)\nexport class SecurityCCCommandEncapsulationNonceGet\n\textends SecurityCCCommandEncapsulation\n{}\n\n@CCCommand(SecurityCommand.SchemeReport)\nexport class SecurityCCSchemeReport extends SecurityCC {\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): SecurityCCSchemeReport {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\t// The including controller MUST NOT perform any validation of the Supported Security Schemes byte\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t});\n\t}\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\t// Since it is unlikely that any more schemes will be added to S0, we hardcode the default scheme here (bit 0 = 0)\n\t\tthis.payload = Bytes.from([0]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\t// Hide the default payload line\n\t\t\tmessage: undefined,\n\t\t};\n\t}\n}\n\n@CCCommand(SecurityCommand.SchemeGet)\n@expectedCCResponse(SecurityCCSchemeReport)\nexport class SecurityCCSchemeGet extends SecurityCC {\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): SecurityCCSchemeGet {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\t// The joining node MUST NOT perform any validation of the Supported Security Schemes byte\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t});\n\t}\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\t// Since it is unlikely that any more schemes will be added to S0, we hardcode the default scheme here (bit 0 = 0)\n\t\tthis.payload = Bytes.from([0]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\t// Hide the default payload line\n\t\t\tmessage: undefined,\n\t\t};\n\t}\n}\n\n@CCCommand(SecurityCommand.SchemeInherit)\n@expectedCCResponse(SecurityCCSchemeReport)\nexport class SecurityCCSchemeInherit extends SecurityCC {\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): SecurityCCSchemeInherit {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\t// The joining node MUST NOT perform any validation of the Supported Security Schemes byte\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t});\n\t}\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\t// Since it is unlikely that any more schemes will be added to S0, we hardcode the default scheme here (bit 0 = 0)\n\t\tthis.payload = Bytes.from([0]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\t// Hide the default payload line\n\t\t\tmessage: undefined,\n\t\t};\n\t}\n}\n\n@CCCommand(SecurityCommand.NetworkKeyVerify)\nexport class SecurityCCNetworkKeyVerify extends SecurityCC {}\n\n// @publicAPI\nexport interface SecurityCCNetworkKeySetOptions {\n\tnetworkKey: BytesView;\n}\n\n@CCCommand(SecurityCommand.NetworkKeySet)\n@expectedCCResponse(SecurityCCNetworkKeyVerify)\nexport class SecurityCCNetworkKeySet extends SecurityCC {\n\tpublic constructor(\n\t\toptions: WithAddress<SecurityCCNetworkKeySetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tif (options.networkKey.length !== 16) {\n\t\t\tthrow new ZWaveError(\n\t\t\t\t`The network key must have length 16!`,\n\t\t\t\tZWaveErrorCodes.Argument_Invalid,\n\t\t\t);\n\t\t}\n\t\tthis.networkKey = options.networkKey;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): SecurityCCNetworkKeySet {\n\t\tvalidatePayload(raw.payload.length >= 16);\n\t\tconst networkKey: BytesView = raw.payload.subarray(0, 16);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tnetworkKey,\n\t\t});\n\t}\n\n\tpublic networkKey: BytesView;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.view(this.networkKey);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\t// The network key shouldn't be logged, so users can safely post their logs online\n\t\tconst { message, ...log } = super.toLogEntry(ctx);\n\t\treturn log;\n\t}\n}\n\n// @publicAPI\nexport interface SecurityCCCommandsSupportedReportOptions {\n\treportsToFollow?: number;\n\tsupportedCCs: CommandClasses[];\n\tcontrolledCCs: CommandClasses[];\n}\n\n@CCCommand(SecurityCommand.CommandsSupportedReport)\nexport class SecurityCCCommandsSupportedReport extends SecurityCC {\n\tpublic constructor(\n\t\toptions: WithAddress<SecurityCCCommandsSupportedReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\tthis.supportedCCs = options.supportedCCs;\n\t\tthis.controlledCCs = options.controlledCCs;\n\t\t// TODO: properly split the CCs into multiple reports\n\t\tthis.reportsToFollow = options.reportsToFollow ?? 0;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): SecurityCCCommandsSupportedReport {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst reportsToFollow = raw.payload[0];\n\t\tconst list = parseCCList(raw.payload.subarray(1));\n\t\tconst supportedCCs: CommandClasses[] = list.supportedCCs;\n\t\tconst controlledCCs: CommandClasses[] = list.controlledCCs;\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\treportsToFollow,\n\t\t\tsupportedCCs,\n\t\t\tcontrolledCCs,\n\t\t});\n\t}\n\n\tpublic reportsToFollow: number;\n\tpublic supportedCCs: CommandClasses[];\n\tpublic controlledCCs: CommandClasses[];\n\n\tpublic getPartialCCSessionId(): Record<string, any> | undefined {\n\t\t// Nothing special we can distinguish sessions with\n\t\treturn {};\n\t}\n\n\tpublic expectMoreMessages(): boolean {\n\t\treturn this.reportsToFollow > 0;\n\t}\n\n\tpublic mergePartialCCs(\n\t\tpartials: SecurityCCCommandsSupportedReport[],\n\t): Promise<void> {\n\t\t// Concat the lists of CCs\n\t\tthis.supportedCCs = [...partials, this]\n\t\t\t.map((report) => report.supportedCCs)\n\t\t\t.reduce((prev, cur) => prev.concat(...cur), []);\n\t\tthis.controlledCCs = [...partials, this]\n\t\t\t.map((report) => report.controlledCCs)\n\t\t\t.reduce((prev, cur) => prev.concat(...cur), []);\n\t\treturn Promise.resolve();\n\t}\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.concat([\n\t\t\tBytes.from([this.reportsToFollow]),\n\t\t\tencodeCCList(this.supportedCCs, this.controlledCCs),\n\t\t]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: {\n\t\t\t\treportsToFollow: this.reportsToFollow,\n\t\t\t\tsupportedCCs: this.supportedCCs\n\t\t\t\t\t.map((cc) => getCCName(cc))\n\t\t\t\t\t.map((cc) => `\\n\u00B7 ${cc}`)\n\t\t\t\t\t.join(\"\"),\n\t\t\t\tcontrolledCCs: this.controlledCCs\n\t\t\t\t\t.map((cc) => getCCName(cc))\n\t\t\t\t\t.map((cc) => `\\n\u00B7 ${cc}`)\n\t\t\t\t\t.join(\"\"),\n\t\t\t},\n\t\t};\n\t}\n}\n\n@CCCommand(SecurityCommand.CommandsSupportedGet)\n@expectedCCResponse(SecurityCCCommandsSupportedReport)\nexport class SecurityCCCommandsSupportedGet extends SecurityCC {}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,kBA4BO;AACP,oBAMO;AACP,mBAAqB;AACrB,iBAAqC;AACrC,0BAIO;AACP,oCAMO;AACP,mBAAgC;AAChC,qBAAwB;AACxB,yBAA4B;AAC5B,gCAAmC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAInC,SAAS,sBACR,aACA,eACA,WACA,eACA,iBACA,kBAA2B;AAE3B,SAAO,oBAAM,OAAO;IACnB;IACA;IACA,oBAAM,KAAK;MACV;MACA;MACA;MACA,iBAAiB;KACjB;IACD;GACA;AACF;AAnBS;AAqBT,SAAS,aAAa,QAAe;AACpC,MAAI,UAAU;AACd,MAAI;AAAQ,eAAW,YAAY,MAAM;AACzC,QAAM,IAAI,uBAAW,SAAS,4BAAgB,kBAAkB;AACjE;AAJS;AAMT,MAAM,kBAAkB;AAExB,SAAS,iBACR,KAAqB;AAErB,MAAI,CAAC,IAAI,WAAW;AACnB,UAAM,IAAI,uBACT,oFACA,4BAAgB,eAAe;EAEjC;AAEA,MAAI,CAAC,IAAI,iBAAiB;AACzB,UAAM,IAAI,uBACT,iFACA,4BAAgB,iBAAiB;EAEnC;AACD;AAhBS;AAkBT,SAAS,iBACR,KAAsB;AAEtB,MAAI,CAAC,IAAI,WAAW;AACnB,UAAM,IAAI,uBACT,iFACA,4BAAgB,eAAe;EAEjC;AAEA,MAAI,CAAC,IAAI,iBAAiB;AACzB,UAAM,IAAI,uBACT,8EACA,4BAAgB,iBAAiB;EAEnC;AACD;AAhBS;IAyBI,iBAAa,MAAA;8BADzB,mCAAI,2BAAe,QAAQ,CAAC;;;;oBACM;qCAAA,YAAa;WAAA;;;;;;;;AAAhD,mBAAA,MAAA,mBAAA,EAAA,OAAA,WAAA,GAAA,kBAAA,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,WAAO,uBAAU,EAAE,CAAC,EACzB,IAAI,CAAC,OAAO;OAAO,EAAE,EAAE,EACvB,KAAK,EAAE;;;IAGZ;;;;IAKY,kCAA8B,MAAA;8BAF1C,yCAAU,6BAAgB,oBAAoB,OAC9C,kDAAmB,iCAAiC,CAAC;;;;oBACF;sDAAA,YAAU;WAAA;;;;;;;;AAA9D,mBAAA,MAAA,mBAAA,EAAA,OAAA,WAAA,GAAA,kBAAA,EAAA,MAAA,SAAA,MAAA,WAAA,MAAA,UAAA,UAAA,GAAA,MAAA,uBAAA;;;AAAa,wBAAA,YAAA,uBAAA;;;;;",
4
+ "sourcesContent": ["import type { CCEncodingContext, CCParsingContext } from \"@zwave-js/cc\";\nimport {\n\tCommandClasses,\n\tEncapsulationFlags,\n\ttype GetNode,\n\ttype GetValueDB,\n\ttype MaybeNotKnown,\n\ttype MessageOrCCLogEntry,\n\tMessagePriority,\n\ttype MessageRecord,\n\ttype NodeId,\n\tSecurityClass,\n\ttype SecurityManager,\n\ttype SupportsCC,\n\tTransmitOptions,\n\ttype WithAddress,\n\tZWaveError,\n\tZWaveErrorCodes,\n\tcomputeMAC,\n\tdecryptAES128OFB,\n\tencodeCCList,\n\tencryptAES128OFB,\n\tgenerateAuthKey,\n\tgenerateEncryptionKey,\n\tgetCCName,\n\tisTransmissionError,\n\tparseCCList,\n\trandomBytes,\n\tvalidatePayload,\n} from \"@zwave-js/core\";\nimport {\n\tBytes,\n\ttype BytesView,\n\tbuffer2hex,\n\tnum2hex,\n\tpick,\n} from \"@zwave-js/shared\";\nimport { wait } from \"alcalzone-shared/async\";\nimport { CCAPI, PhysicalCCAPI } from \"../lib/API.js\";\nimport {\n\ttype CCRaw,\n\tCommandClass,\n\ttype InterviewContext,\n} from \"../lib/CommandClass.js\";\nimport {\n\tAPI,\n\tCCCommand,\n\tcommandClass,\n\texpectedCCResponse,\n\timplementedVersion,\n} from \"../lib/CommandClassDecorators.js\";\nimport { SecurityCommand } from \"../lib/_Types.js\";\nimport { CRC16CC } from \"./CRC16CC.js\";\nimport { Security2CC } from \"./Security2CC.js\";\nimport { TransportServiceCC } from \"./TransportServiceCC.js\";\n\n// @noSetValueAPI This is an encapsulation CC\n\nfunction getAuthenticationData(\n\tsenderNonce: BytesView,\n\treceiverNonce: BytesView,\n\tccCommand: SecurityCommand,\n\tsendingNodeId: number,\n\treceivingNodeId: number,\n\tencryptedPayload: BytesView,\n): BytesView {\n\treturn Bytes.concat([\n\t\tsenderNonce,\n\t\treceiverNonce,\n\t\t[\n\t\t\tccCommand,\n\t\t\tsendingNodeId,\n\t\t\treceivingNodeId,\n\t\t\tencryptedPayload.length,\n\t\t],\n\t\tencryptedPayload,\n\t]);\n}\n\nfunction throwNoNonce(reason?: string): never {\n\tlet message = `Security CC requires a nonce to be sent!`;\n\tif (reason) message += ` Reason: ${reason}`;\n\tthrow new ZWaveError(message, ZWaveErrorCodes.SecurityCC_NoNonce);\n}\n\nconst HALF_NONCE_SIZE = 8;\n\nfunction assertSecurityRX(\n\tctx: CCParsingContext,\n): asserts ctx is CCParsingContext & { securityManager: SecurityManager } {\n\tif (!ctx.ownNodeId) {\n\t\tthrow new ZWaveError(\n\t\t\t`Secure commands (S0) can only be decoded when the controller's node id is known!`,\n\t\t\tZWaveErrorCodes.Driver_NotReady,\n\t\t);\n\t}\n\n\tif (!ctx.securityManager) {\n\t\tthrow new ZWaveError(\n\t\t\t`Secure commands (S0) can only be decoded when the security manager is set up!`,\n\t\t\tZWaveErrorCodes.Driver_NoSecurity,\n\t\t);\n\t}\n}\n\nfunction assertSecurityTX(\n\tctx: CCEncodingContext,\n): asserts ctx is CCEncodingContext & { securityManager: SecurityManager } {\n\tif (!ctx.ownNodeId) {\n\t\tthrow new ZWaveError(\n\t\t\t`Secure commands (S0) can only be sent when the controller's node id is known!`,\n\t\t\tZWaveErrorCodes.Driver_NotReady,\n\t\t);\n\t}\n\n\tif (!ctx.securityManager) {\n\t\tthrow new ZWaveError(\n\t\t\t`Secure commands (S0) can only be sent when the security manager is set up!`,\n\t\t\tZWaveErrorCodes.Driver_NoSecurity,\n\t\t);\n\t}\n}\n\n// TODO: Ignore commands if received via multicast\n\n// Encapsulation CCs are used internally and too frequently that we\n// want to pay the cost of validating each call\n/* eslint-disable @zwave-js/ccapi-validate-args */\n\n@API(CommandClasses.Security)\nexport class SecurityCCAPI extends PhysicalCCAPI {\n\tpublic supportsCommand(_cmd: SecurityCommand): MaybeNotKnown<boolean> {\n\t\t// All commands are mandatory\n\t\treturn true;\n\t}\n\n\tpublic async sendEncapsulated(\n\t\tencapsulated: CommandClass,\n\t\trequestNextNonce: boolean = false,\n\t): Promise<void> {\n\t\tif (requestNextNonce) {\n\t\t\tthis.assertSupportsCommand(\n\t\t\t\tSecurityCommand,\n\t\t\t\tSecurityCommand.CommandEncapsulation,\n\t\t\t);\n\t\t} else {\n\t\t\tthis.assertSupportsCommand(\n\t\t\t\tSecurityCommand,\n\t\t\t\tSecurityCommand.CommandEncapsulationNonceGet,\n\t\t\t);\n\t\t}\n\n\t\tconst cc = new (\n\t\t\trequestNextNonce\n\t\t\t\t? SecurityCCCommandEncapsulationNonceGet\n\t\t\t\t: SecurityCCCommandEncapsulation\n\t\t)({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tencapsulated,\n\t\t});\n\t\tawait this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\t/**\n\t * Requests a new nonce for Security CC encapsulation which is not directly linked to a specific command.\n\t */\n\tpublic async getNonce(): Promise<BytesView | undefined> {\n\t\tthis.assertSupportsCommand(SecurityCommand, SecurityCommand.NonceGet);\n\n\t\tconst cc = new SecurityCCNonceGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tconst response = await this.host.sendCommand<SecurityCCNonceReport>(\n\t\t\tcc,\n\t\t\t{\n\t\t\t\t...this.commandOptions,\n\t\t\t\t// Only try getting a nonce once\n\t\t\t\tmaxSendAttempts: 1,\n\t\t\t},\n\t\t);\n\t\tif (!response) return;\n\n\t\tconst nonce = response.nonce;\n\t\tconst secMan = this.host.securityManager!;\n\t\tsecMan.setNonce(\n\t\t\t{\n\t\t\t\tissuer: this.endpoint.nodeId,\n\t\t\t\tnonceId: secMan.getNonceId(nonce),\n\t\t\t},\n\t\t\t{ nonce, receiver: this.host.ownNodeId },\n\t\t\t{ free: true },\n\t\t);\n\t\treturn nonce;\n\t}\n\n\t/**\n\t * Responds to a NonceGet request. The message is sent without any retransmission etc.\n\t * The return value indicates whether a nonce was successfully sent\n\t */\n\tpublic async sendNonce(): Promise<boolean> {\n\t\tthis.assertSupportsCommand(\n\t\t\tSecurityCommand,\n\t\t\tSecurityCommand.NonceReport,\n\t\t);\n\n\t\tif (!this.host.securityManager) {\n\t\t\tthrow new ZWaveError(\n\t\t\t\t`Nonces can only be sent if secure communication is set up!`,\n\t\t\t\tZWaveErrorCodes.Driver_NoSecurity,\n\t\t\t);\n\t\t}\n\n\t\tconst nonce = this.host.securityManager.generateNonce(\n\t\t\tthis.endpoint.nodeId,\n\t\t\tHALF_NONCE_SIZE,\n\t\t);\n\t\tconst nonceId = this.host.securityManager.getNonceId(nonce);\n\n\t\tconst cc = new SecurityCCNonceReport({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tnonce,\n\t\t});\n\n\t\ttry {\n\t\t\tawait this.host.sendCommand(cc, {\n\t\t\t\t...this.commandOptions,\n\t\t\t\t// Seems we need these options or some nodes won't accept the nonce\n\t\t\t\ttransmitOptions: TransmitOptions.ACK\n\t\t\t\t\t| TransmitOptions.AutoRoute,\n\t\t\t\t// Only try sending a nonce once\n\t\t\t\tmaxSendAttempts: 1,\n\t\t\t\t// Nonce requests must be handled immediately\n\t\t\t\tpriority: MessagePriority.Immediate,\n\t\t\t\t// We don't want failures causing us to treat the node as asleep or dead\n\t\t\t\tchangeNodeStatusOnMissingACK: false,\n\t\t\t});\n\t\t} catch (e) {\n\t\t\tif (isTransmissionError(e)) {\n\t\t\t\t// The nonce could not be sent, invalidate it\n\t\t\t\tthis.host.securityManager.deleteNonce(nonceId);\n\t\t\t\treturn false;\n\t\t\t} else {\n\t\t\t\t// Pass other errors through\n\t\t\t\tthrow e;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\tpublic async getSecurityScheme(): Promise<[0]> {\n\t\tthis.assertSupportsCommand(SecurityCommand, SecurityCommand.SchemeGet);\n\n\t\tconst cc = new SecurityCCSchemeGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tawait this.host.sendCommand(cc, this.commandOptions);\n\t\t// There is only one scheme, so we hardcode it\n\t\treturn [0];\n\t}\n\n\tpublic async reportSecurityScheme(encapsulated: boolean): Promise<void> {\n\t\tthis.assertSupportsCommand(\n\t\t\tSecurityCommand,\n\t\t\tSecurityCommand.SchemeReport,\n\t\t);\n\n\t\tlet cc: CommandClass = new SecurityCCSchemeReport({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tif (encapsulated) {\n\t\t\tcc = new SecurityCCCommandEncapsulation({\n\t\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\t\tendpointIndex: this.endpoint.index,\n\t\t\t\tencapsulated: cc,\n\t\t\t});\n\t\t}\n\t\tawait this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\tpublic async inheritSecurityScheme(): Promise<void> {\n\t\tthis.assertSupportsCommand(\n\t\t\tSecurityCommand,\n\t\t\tSecurityCommand.SchemeInherit,\n\t\t);\n\n\t\tconst cc = new SecurityCCSchemeInherit({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tawait this.host.sendCommand(cc, this.commandOptions);\n\t\t// There is only one scheme, so we don't return anything here\n\t}\n\n\tpublic async setNetworkKey(networkKey: BytesView): Promise<void> {\n\t\tthis.assertSupportsCommand(\n\t\t\tSecurityCommand,\n\t\t\tSecurityCommand.NetworkKeySet,\n\t\t);\n\n\t\tconst keySet = new SecurityCCNetworkKeySet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tnetworkKey,\n\t\t});\n\t\tconst cc = new SecurityCCCommandEncapsulation({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tencapsulated: keySet,\n\t\t\talternativeNetworkKey: new Uint8Array(16).fill(0),\n\t\t});\n\t\tawait this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\tpublic async verifyNetworkKey(): Promise<void> {\n\t\tthis.assertSupportsCommand(\n\t\t\tSecurityCommand,\n\t\t\tSecurityCommand.NetworkKeyVerify,\n\t\t);\n\n\t\tconst cc = new SecurityCCNetworkKeyVerify({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tawait this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\t// oxlint-disable-next-line typescript/explicit-module-boundary-types\n\tpublic async getSupportedCommands() {\n\t\tthis.assertSupportsCommand(\n\t\t\tSecurityCommand,\n\t\t\tSecurityCommand.CommandsSupportedGet,\n\t\t);\n\n\t\tconst cc = new SecurityCCCommandsSupportedGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tconst response = await this.host.sendCommand<\n\t\t\tSecurityCCCommandsSupportedReport\n\t\t>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\tif (response) {\n\t\t\treturn pick(response, [\"supportedCCs\", \"controlledCCs\"]);\n\t\t}\n\t}\n\n\tpublic async reportSupportedCommands(\n\t\tsupportedCCs: CommandClasses[],\n\t\tcontrolledCCs: CommandClasses[],\n\t): Promise<void> {\n\t\tthis.assertSupportsCommand(\n\t\t\tSecurityCommand,\n\t\t\tSecurityCommand.CommandsSupportedReport,\n\t\t);\n\n\t\tconst cc = new SecurityCCCommandsSupportedReport({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tsupportedCCs,\n\t\t\tcontrolledCCs,\n\t\t\treportsToFollow: 0,\n\t\t});\n\t\tawait this.host.sendCommand(cc, this.commandOptions);\n\t}\n}\n\n@commandClass(CommandClasses.Security)\n@implementedVersion(1)\nexport class SecurityCC extends CommandClass {\n\tdeclare ccCommand: SecurityCommand;\n\t// Force singlecast for the Security CC\n\tdeclare nodeId: number;\n\n\tpublic async interview(\n\t\tctx: InterviewContext,\n\t): Promise<void> {\n\t\tconst node = this.getNode(ctx)!;\n\t\tconst endpoint = this.getEndpoint(ctx)!;\n\t\tconst api = CCAPI.create(\n\t\t\tCommandClasses.Security,\n\t\t\tctx,\n\t\t\tendpoint,\n\t\t).withOptions({\n\t\t\tpriority: MessagePriority.NodeQuery,\n\t\t});\n\n\t\tctx.logNode(node.id, {\n\t\t\tmessage: \"Querying securely supported commands (S0)...\",\n\t\t\tdirection: \"outbound\",\n\t\t});\n\n\t\tlet supportedCCs: CommandClasses[] | undefined;\n\t\tlet controlledCCs: CommandClasses[] | undefined;\n\n\t\t// Try up to 3 times on the root device. We REALLY don't want a spurious timeout or collision to cause us to discard a known good security class\n\t\tconst MAX_ATTEMPTS = this.endpointIndex === 0 ? 3 : 1;\n\t\tfor (let attempts = 1; attempts <= MAX_ATTEMPTS; attempts++) {\n\t\t\tconst resp = await api.getSupportedCommands();\n\t\t\tif (resp) {\n\t\t\t\tsupportedCCs = resp.supportedCCs;\n\t\t\t\tcontrolledCCs = resp.controlledCCs;\n\t\t\t\tbreak;\n\t\t\t} else if (attempts < MAX_ATTEMPTS) {\n\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\t\tmessage:\n\t\t\t\t\t\t`Querying securely supported commands (S0), attempt ${attempts}/${MAX_ATTEMPTS} failed. Retrying in 500ms...`,\n\t\t\t\t\tlevel: \"warn\",\n\t\t\t\t});\n\t\t\t\tawait wait(500);\n\t\t\t}\n\t\t}\n\n\t\tif (!supportedCCs || !controlledCCs) {\n\t\t\tif (node.hasSecurityClass(SecurityClass.S0_Legacy) === true) {\n\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\t\tmessage: \"Querying securely supported commands (S0) failed\",\n\t\t\t\t\tlevel: \"warn\",\n\t\t\t\t});\n\t\t\t\t// TODO: Abort interview?\n\t\t\t} else {\n\t\t\t\t// We didn't know if the node was secure and it didn't respond,\n\t\t\t\t// assume that it doesn't have the S0 security class\n\t\t\t\tctx.logNode(\n\t\t\t\t\tnode.id,\n\t\t\t\t\t`The node was not granted the S0 security class. Continuing interview non-securely.`,\n\t\t\t\t);\n\t\t\t\tnode.setSecurityClass(SecurityClass.S0_Legacy, false);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tconst logLines: string[] = [\n\t\t\t\"received secure commands (S0)\",\n\t\t\t\"supported CCs:\",\n\t\t];\n\t\tfor (const cc of supportedCCs) {\n\t\t\tlogLines.push(`\u00B7 ${getCCName(cc)}`);\n\t\t}\n\t\tlogLines.push(\"controlled CCs:\");\n\t\tfor (const cc of controlledCCs) {\n\t\t\tlogLines.push(`\u00B7 ${getCCName(cc)}`);\n\t\t}\n\t\tctx.logNode(node.id, {\n\t\t\tmessage: logLines.join(\"\\n\"),\n\t\t\tdirection: \"inbound\",\n\t\t});\n\n\t\t// Remember which commands are supported securely\n\t\tfor (const cc of supportedCCs) {\n\t\t\t// Basic CC has special rules for when it is considered supported\n\t\t\t// Therefore we mark all other CCs as supported, but not Basic CC,\n\t\t\t// for which support is determined later.\n\t\t\tif (cc === CommandClasses.Basic) {\n\t\t\t\tendpoint.addCC(cc, { secure: true });\n\t\t\t} else {\n\t\t\t\tendpoint.addCC(cc, {\n\t\t\t\t\tisSupported: true,\n\t\t\t\t\tsecure: true,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\tfor (const cc of controlledCCs) {\n\t\t\t// Basic CC has special rules for when it is considered supported\n\t\t\t// Therefore we mark all other CCs as supported, but not Basic CC,\n\t\t\t// for which support is determined later.\n\t\t\tif (cc === CommandClasses.Basic) {\n\t\t\t\tendpoint.addCC(cc, { secure: true });\n\t\t\t} else {\n\t\t\t\tendpoint.addCC(cc, {\n\t\t\t\t\tisControlled: true,\n\t\t\t\t\tsecure: true,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t// We know for sure that the node is included securely\n\t\tif (node.hasSecurityClass(SecurityClass.S0_Legacy) !== true) {\n\t\t\tnode.setSecurityClass(SecurityClass.S0_Legacy, true);\n\t\t\tctx.logNode(\n\t\t\t\tnode.id,\n\t\t\t\t`The node was granted the S0 security class`,\n\t\t\t);\n\t\t}\n\n\t\t// Remember that the interview is complete\n\t\tthis.setInterviewComplete(ctx, true);\n\t}\n\n\t/** Tests if a command should be sent secure and thus requires encapsulation */\n\tpublic static requiresEncapsulation(cc: CommandClass): boolean {\n\t\t// No security flag -> no encapsulation\n\t\tif (!(cc.encapsulationFlags & EncapsulationFlags.Security)) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// S2, CRC16, Transport Service -> no S2 encapsulation\n\t\tif (\n\t\t\tcc instanceof Security2CC\n\t\t\t|| cc instanceof CRC16CC\n\t\t\t|| cc instanceof TransportServiceCC\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// S0: check command\n\t\tif (cc instanceof SecurityCC) {\n\t\t\tswitch (cc.ccCommand) {\n\t\t\t\t// Already encapsulated\n\t\t\t\tcase SecurityCommand.CommandEncapsulation:\n\t\t\t\tcase SecurityCommand.CommandEncapsulationNonceGet:\n\t\t\t\t// Cannot be sent encapsulated:\n\t\t\t\tcase SecurityCommand.NonceGet:\n\t\t\t\tcase SecurityCommand.NonceReport:\n\t\t\t\tcase SecurityCommand.SchemeGet:\n\t\t\t\tcase SecurityCommand.SchemeReport:\n\t\t\t\t\treturn false;\n\n\t\t\t\tdefault:\n\t\t\t\t\t// All other commands must be encapsulated\n\t\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\t// Everything else needs to be encapsulated if the CC is secure\n\t\treturn true;\n\t}\n\n\t/** Encapsulates a command that should be sent encrypted */\n\tpublic static encapsulate(\n\t\townNodeId: number,\n\t\tsecurityManager: SecurityManager,\n\t\tcc: CommandClass,\n\t): SecurityCCCommandEncapsulation {\n\t\t// TODO: When to return a SecurityCCCommandEncapsulationNonceGet?\n\t\tconst ret = new SecurityCCCommandEncapsulation({\n\t\t\tnodeId: cc.nodeId,\n\t\t\tencapsulated: cc,\n\t\t});\n\n\t\t// Copy the encapsulation flags from the encapsulated command\n\t\t// but omit Security, since we're doing that right now\n\t\tret.encapsulationFlags = cc.encapsulationFlags\n\t\t\t& ~EncapsulationFlags.Security;\n\n\t\treturn ret;\n\t}\n}\n\ninterface SecurityCCNonceReportOptions {\n\tnonce: BytesView;\n}\n\n@CCCommand(SecurityCommand.NonceReport)\nexport class SecurityCCNonceReport extends SecurityCC {\n\tconstructor(\n\t\toptions: WithAddress<SecurityCCNonceReportOptions>,\n\t) {\n\t\tsuper(options);\n\t\tif (options.nonce.length !== HALF_NONCE_SIZE) {\n\t\t\tthrow new ZWaveError(\n\t\t\t\t`Nonce must have length ${HALF_NONCE_SIZE}!`,\n\t\t\t\tZWaveErrorCodes.Argument_Invalid,\n\t\t\t);\n\t\t}\n\t\tthis.nonce = options.nonce;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): SecurityCCNonceReport {\n\t\tvalidatePayload.withReason(\"Invalid nonce length\")(\n\t\t\traw.payload.length === HALF_NONCE_SIZE,\n\t\t);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tnonce: raw.payload,\n\t\t});\n\t}\n\n\tpublic nonce: BytesView;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.view(this.nonce);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: { nonce: buffer2hex(this.nonce) },\n\t\t};\n\t}\n}\n\n@CCCommand(SecurityCommand.NonceGet)\n@expectedCCResponse(SecurityCCNonceReport)\nexport class SecurityCCNonceGet extends SecurityCC {}\n\n// @publicAPI\nexport type SecurityCCCommandEncapsulationOptions =\n\t& {\n\t\talternativeNetworkKey?: BytesView;\n\t}\n\t& ({\n\t\tencapsulated: CommandClass;\n\t} | {\n\t\tdecryptedCCBytes: BytesView;\n\t\tsequenced: boolean;\n\t\tsecondFrame: boolean;\n\t\tsequenceCounter: number;\n\t});\n\nfunction getCCResponseForCommandEncapsulation(\n\tctx: GetNode<NodeId & SupportsCC>,\n\tsent: SecurityCCCommandEncapsulation,\n) {\n\tif (sent.encapsulated.expectsCCResponse(ctx)) {\n\t\treturn SecurityCCCommandEncapsulation;\n\t}\n}\n\n@CCCommand(SecurityCommand.CommandEncapsulation)\n@expectedCCResponse(\n\tgetCCResponseForCommandEncapsulation,\n\t() => \"checkEncapsulated\",\n)\nexport class SecurityCCCommandEncapsulation extends SecurityCC {\n\tpublic constructor(\n\t\toptions: WithAddress<SecurityCCCommandEncapsulationOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\tif (\"encapsulated\" in options) {\n\t\t\tthis.encapsulated = options.encapsulated;\n\t\t\tthis.encapsulated.encapsulatingCC = this as any;\n\t\t} else {\n\t\t\tthis.decryptedCCBytes = options.decryptedCCBytes;\n\t\t\tthis.sequenced = options.sequenced;\n\t\t\tthis.secondFrame = options.secondFrame;\n\t\t\tthis.sequenceCounter = options.sequenceCounter;\n\t\t}\n\t\tthis.alternativeNetworkKey = options.alternativeNetworkKey;\n\t}\n\n\tpublic static async from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): Promise<SecurityCCCommandEncapsulation> {\n\t\tassertSecurityRX(ctx);\n\n\t\t// HALF_NONCE_SIZE bytes iv, 1 byte frame control, at least 1 CC byte, 1 byte nonce id, 8 bytes auth code\n\t\tvalidatePayload(\n\t\t\traw.payload.length >= HALF_NONCE_SIZE + 1 + 1 + 1 + 8,\n\t\t);\n\t\tconst iv = raw.payload.subarray(0, HALF_NONCE_SIZE);\n\t\tconst encryptedPayload = raw.payload.subarray(HALF_NONCE_SIZE, -9);\n\t\tconst nonceId = raw.payload.at(-9)!;\n\t\tconst authCode = raw.payload.subarray(-8);\n\n\t\t// Retrieve the used nonce from the nonce store\n\t\tconst nonce = ctx.securityManager.getNonce(nonceId);\n\t\t// Only accept the message if the nonce hasn't expired\n\t\tif (!nonce) {\n\t\t\tvalidatePayload.fail(\n\t\t\t\t`Nonce ${\n\t\t\t\t\tnum2hex(\n\t\t\t\t\t\tnonceId,\n\t\t\t\t\t)\n\t\t\t\t} expired, cannot decode security encapsulated command.`,\n\t\t\t);\n\t\t}\n\t\t// and mark the nonce as used\n\t\tctx.securityManager.deleteNonce(nonceId);\n\n\t\t// Validate the encrypted data\n\t\tconst authData = getAuthenticationData(\n\t\t\tiv,\n\t\t\tnonce,\n\t\t\tSecurityCommand.CommandEncapsulation,\n\t\t\tctx.sourceNodeId,\n\t\t\tctx.ownNodeId,\n\t\t\tencryptedPayload,\n\t\t);\n\t\tconst expectedAuthCode = await computeMAC(\n\t\t\tauthData,\n\t\t\tawait ctx.securityManager.getAuthKey(),\n\t\t);\n\t\t// Only accept messages with a correct auth code\n\t\tvalidatePayload.withReason(\n\t\t\t\"Invalid auth code, won't accept security encapsulated command.\",\n\t\t)(authCode.equals(expectedAuthCode));\n\n\t\t// Decrypt the encapsulated CC\n\t\tconst frameControlAndDecryptedCC = await decryptAES128OFB(\n\t\t\tencryptedPayload,\n\t\t\tawait ctx.securityManager.getEncryptionKey(),\n\t\t\tBytes.concat([iv, nonce]),\n\t\t);\n\t\tconst frameControl = frameControlAndDecryptedCC[0];\n\t\tconst sequenceCounter = frameControl & 0b1111;\n\t\tconst sequenced = !!(frameControl & 0b1_0000);\n\t\tconst secondFrame = !!(frameControl & 0b10_0000);\n\t\tconst decryptedCCBytes: BytesView | undefined =\n\t\t\tframeControlAndDecryptedCC\n\t\t\t\t.subarray(1);\n\n\t\tconst ret = new SecurityCCCommandEncapsulation({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tsequenceCounter,\n\t\t\tsequenced,\n\t\t\tsecondFrame,\n\t\t\tdecryptedCCBytes,\n\t\t});\n\n\t\tret.authData = authData;\n\t\tret.authCode = authCode;\n\t\tret.iv = iv;\n\n\t\treturn ret;\n\t}\n\n\tprivate sequenced: boolean | undefined;\n\tprivate secondFrame: boolean | undefined;\n\tprivate sequenceCounter: number | undefined;\n\n\tprivate decryptedCCBytes: BytesView | undefined;\n\tpublic encapsulated!: CommandClass;\n\n\tprivate alternativeNetworkKey?: BytesView;\n\n\tpublic get nonceId(): number | undefined {\n\t\treturn this.nonce?.[0];\n\t}\n\tpublic nonce: BytesView | undefined;\n\n\t// Only used testing/for debugging purposes\n\tprivate iv?: BytesView;\n\tprivate authData?: BytesView;\n\tprivate authCode?: BytesView;\n\tprivate ciphertext?: BytesView;\n\n\tpublic getPartialCCSessionId(): Record<string, any> | undefined {\n\t\tif (this.sequenced) {\n\t\t\treturn {\n\t\t\t\t// Treat Encapsulation and EncapsulationNonceGet as one\n\t\t\t\tccCommand: undefined,\n\t\t\t\tsequence: this.sequenceCounter,\n\t\t\t};\n\t\t} else {\n\t\t\treturn {\n\t\t\t\t// Treat Encapsulation and EncapsulationNonceGet as one\n\t\t\t\tccCommand: undefined,\n\t\t\t};\n\t\t}\n\t}\n\n\tpublic expectMoreMessages(): boolean {\n\t\treturn !!this.sequenced && !this.secondFrame;\n\t}\n\n\tpublic async mergePartialCCs(\n\t\tpartials: SecurityCCCommandEncapsulation[],\n\t\tctx: CCParsingContext,\n\t): Promise<void> {\n\t\t// Concat the CC buffers\n\t\tthis.decryptedCCBytes = Bytes.concat(\n\t\t\t[...partials, this].map((cc) => cc.decryptedCCBytes!),\n\t\t);\n\t\t// make sure this contains a complete CC command that's worth splitting\n\t\tvalidatePayload(this.decryptedCCBytes.length >= 2);\n\t\t// and deserialize the CC\n\t\tthis.encapsulated = await CommandClass.parse(\n\t\t\tthis.decryptedCCBytes,\n\t\t\tctx,\n\t\t);\n\t\tthis.encapsulated.encapsulatingCC = this as any;\n\t}\n\n\tpublic async serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tif (!this.nonce) throwNoNonce();\n\t\tif (this.nonce.length !== HALF_NONCE_SIZE) {\n\t\t\tthrowNoNonce(\"Invalid nonce size\");\n\t\t}\n\t\tassertSecurityTX(ctx);\n\n\t\tlet authKey: BytesView;\n\t\tlet encryptionKey: BytesView;\n\t\tif (this.alternativeNetworkKey) {\n\t\t\tauthKey = await generateAuthKey(this.alternativeNetworkKey);\n\t\t\tencryptionKey = await generateEncryptionKey(\n\t\t\t\tthis.alternativeNetworkKey,\n\t\t\t);\n\t\t} else {\n\t\t\tauthKey = await ctx.securityManager.getAuthKey();\n\t\t\tencryptionKey = await ctx.securityManager.getEncryptionKey();\n\t\t}\n\n\t\tconst serializedCC = await this.encapsulated.serialize(ctx);\n\t\tconst plaintext = Bytes.concat([\n\t\t\t[0], // TODO: frame control\n\t\t\tserializedCC,\n\t\t]);\n\t\t// Encrypt the payload\n\t\tconst senderNonce = randomBytes(HALF_NONCE_SIZE);\n\t\tconst iv = Bytes.concat([senderNonce, this.nonce]);\n\t\tconst ciphertext = await encryptAES128OFB(\n\t\t\tplaintext,\n\t\t\tencryptionKey,\n\t\t\tiv,\n\t\t);\n\t\t// And generate the auth code\n\t\tconst authData = getAuthenticationData(\n\t\t\tsenderNonce,\n\t\t\tthis.nonce,\n\t\t\tthis.ccCommand,\n\t\t\tctx.ownNodeId,\n\t\t\tthis.nodeId,\n\t\t\tciphertext,\n\t\t);\n\t\tconst authCode = await computeMAC(authData, authKey);\n\n\t\t// Remember for debugging purposes\n\t\tthis.iv = iv;\n\t\tthis.authData = authData;\n\t\tthis.authCode = authCode;\n\t\tthis.ciphertext = ciphertext;\n\n\t\tthis.payload = Bytes.concat([\n\t\t\tsenderNonce,\n\t\t\tciphertext,\n\t\t\t[this.nonceId!],\n\t\t\tauthCode,\n\t\t]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tprotected computeEncapsulationOverhead(): number {\n\t\t// Security CC adds 8 bytes IV, 1 byte frame control, 1 byte nonce ID, 8 bytes MAC\n\t\treturn super.computeEncapsulationOverhead() + 18;\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\tconst message: MessageRecord = {};\n\t\tif (this.nonceId != undefined) {\n\t\t\tmessage[\"nonce id\"] = this.nonceId;\n\t\t}\n\t\tif (this.sequenced != undefined) {\n\t\t\tmessage.sequenced = this.sequenced;\n\t\t\tif (this.sequenced) {\n\t\t\t\tif (this.secondFrame != undefined) {\n\t\t\t\t\tmessage[\"second frame\"] = this.secondFrame;\n\t\t\t\t}\n\t\t\t\tif (this.sequenceCounter != undefined) {\n\t\t\t\t\tmessage[\"sequence counter\"] = this.sequenceCounter;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Log the plaintext in integration tests and development mode\n\t\tif (\n\t\t\tprocess.env.NODE_ENV === \"test\"\n\t\t\t|| process.env.NODE_ENV === \"development\"\n\t\t) {\n\t\t\tif (this.iv) {\n\t\t\t\tmessage.IV = buffer2hex(this.iv);\n\t\t\t}\n\t\t\tif (this.ciphertext) {\n\t\t\t\tmessage.ciphertext = buffer2hex(this.ciphertext);\n\t\t\t} else if (this.decryptedCCBytes) {\n\t\t\t\tmessage.plaintext = buffer2hex(this.decryptedCCBytes);\n\t\t\t}\n\t\t\tif (this.authData) {\n\t\t\t\tmessage[\"auth data\"] = buffer2hex(this.authData);\n\t\t\t}\n\t\t\tif (this.authCode) {\n\t\t\t\tmessage[\"auth code\"] = buffer2hex(this.authCode);\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage,\n\t\t};\n\t}\n}\n\n// This is the same message, but with another CC command\n@CCCommand(SecurityCommand.CommandEncapsulationNonceGet)\nexport class SecurityCCCommandEncapsulationNonceGet\n\textends SecurityCCCommandEncapsulation\n{}\n\n@CCCommand(SecurityCommand.SchemeReport)\nexport class SecurityCCSchemeReport extends SecurityCC {\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): SecurityCCSchemeReport {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\t// The including controller MUST NOT perform any validation of the Supported Security Schemes byte\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t});\n\t}\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\t// Since it is unlikely that any more schemes will be added to S0, we hardcode the default scheme here (bit 0 = 0)\n\t\tthis.payload = Bytes.from([0]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\t// Hide the default payload line\n\t\t\tmessage: undefined,\n\t\t};\n\t}\n}\n\n@CCCommand(SecurityCommand.SchemeGet)\n@expectedCCResponse(SecurityCCSchemeReport)\nexport class SecurityCCSchemeGet extends SecurityCC {\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): SecurityCCSchemeGet {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\t// The joining node MUST NOT perform any validation of the Supported Security Schemes byte\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t});\n\t}\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\t// Since it is unlikely that any more schemes will be added to S0, we hardcode the default scheme here (bit 0 = 0)\n\t\tthis.payload = Bytes.from([0]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\t// Hide the default payload line\n\t\t\tmessage: undefined,\n\t\t};\n\t}\n}\n\n@CCCommand(SecurityCommand.SchemeInherit)\n@expectedCCResponse(SecurityCCSchemeReport)\nexport class SecurityCCSchemeInherit extends SecurityCC {\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): SecurityCCSchemeInherit {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\t// The joining node MUST NOT perform any validation of the Supported Security Schemes byte\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t});\n\t}\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\t// Since it is unlikely that any more schemes will be added to S0, we hardcode the default scheme here (bit 0 = 0)\n\t\tthis.payload = Bytes.from([0]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\t// Hide the default payload line\n\t\t\tmessage: undefined,\n\t\t};\n\t}\n}\n\n@CCCommand(SecurityCommand.NetworkKeyVerify)\nexport class SecurityCCNetworkKeyVerify extends SecurityCC {}\n\n// @publicAPI\nexport interface SecurityCCNetworkKeySetOptions {\n\tnetworkKey: BytesView;\n}\n\n@CCCommand(SecurityCommand.NetworkKeySet)\n@expectedCCResponse(SecurityCCNetworkKeyVerify)\nexport class SecurityCCNetworkKeySet extends SecurityCC {\n\tpublic constructor(\n\t\toptions: WithAddress<SecurityCCNetworkKeySetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tif (options.networkKey.length !== 16) {\n\t\t\tthrow new ZWaveError(\n\t\t\t\t`The network key must have length 16!`,\n\t\t\t\tZWaveErrorCodes.Argument_Invalid,\n\t\t\t);\n\t\t}\n\t\tthis.networkKey = options.networkKey;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): SecurityCCNetworkKeySet {\n\t\tvalidatePayload(raw.payload.length >= 16);\n\t\tconst networkKey: BytesView = raw.payload.subarray(0, 16);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tnetworkKey,\n\t\t});\n\t}\n\n\tpublic networkKey: BytesView;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.view(this.networkKey);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\t// The network key shouldn't be logged, so users can safely post their logs online\n\t\tconst { message, ...log } = super.toLogEntry(ctx);\n\t\treturn log;\n\t}\n}\n\n// @publicAPI\nexport interface SecurityCCCommandsSupportedReportOptions {\n\treportsToFollow?: number;\n\tsupportedCCs: CommandClasses[];\n\tcontrolledCCs: CommandClasses[];\n}\n\n@CCCommand(SecurityCommand.CommandsSupportedReport)\nexport class SecurityCCCommandsSupportedReport extends SecurityCC {\n\tpublic constructor(\n\t\toptions: WithAddress<SecurityCCCommandsSupportedReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\tthis.supportedCCs = options.supportedCCs;\n\t\tthis.controlledCCs = options.controlledCCs;\n\t\t// TODO: properly split the CCs into multiple reports\n\t\tthis.reportsToFollow = options.reportsToFollow ?? 0;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): SecurityCCCommandsSupportedReport {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst reportsToFollow = raw.payload[0];\n\t\tconst list = parseCCList(raw.payload.subarray(1));\n\t\tconst supportedCCs: CommandClasses[] = list.supportedCCs;\n\t\tconst controlledCCs: CommandClasses[] = list.controlledCCs;\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\treportsToFollow,\n\t\t\tsupportedCCs,\n\t\t\tcontrolledCCs,\n\t\t});\n\t}\n\n\tpublic reportsToFollow: number;\n\tpublic supportedCCs: CommandClasses[];\n\tpublic controlledCCs: CommandClasses[];\n\n\tpublic getPartialCCSessionId(): Record<string, any> | undefined {\n\t\t// Nothing special we can distinguish sessions with\n\t\treturn {};\n\t}\n\n\tpublic expectMoreMessages(): boolean {\n\t\treturn this.reportsToFollow > 0;\n\t}\n\n\tpublic mergePartialCCs(\n\t\tpartials: SecurityCCCommandsSupportedReport[],\n\t): Promise<void> {\n\t\t// Concat the lists of CCs\n\t\tthis.supportedCCs = [...partials, this]\n\t\t\t.map((report) => report.supportedCCs)\n\t\t\t.reduce((prev, cur) => prev.concat(...cur), []);\n\t\tthis.controlledCCs = [...partials, this]\n\t\t\t.map((report) => report.controlledCCs)\n\t\t\t.reduce((prev, cur) => prev.concat(...cur), []);\n\t\treturn Promise.resolve();\n\t}\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.concat([\n\t\t\t[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 Secur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AoB,OAC9C,kDAAmB,iCAAiC,CAAC;;;;oBACF;sDAAA,YAAU;WAAA;;;;;;;;AAA9D,mBAAA,MAAA,mBAAA,EAAA,OAAA,WAAA,GAAA,kBAAA,EAAA,MAAA,SAAA,MAAA,WAAA,MAAA,UAAA,UAAA,GAAA,MAAA,uBAAA;;;AAAa,wBAAA,YAAA,uBAAA;;;;;",
6
6
  "names": ["SecurityCC", "SecurityCCCommandEncapsulation"]
7
7
  }
@@ -1,5 +1,5 @@
1
1
  import type { CCEncodingContext, CCParsingContext } from "@zwave-js/cc";
2
- import { CommandClasses, type GetValueDB, type MaybeNotKnown, type MessageOrCCLogEntry, type SupervisionResult, type WithAddress } from "@zwave-js/core";
2
+ import { CommandClasses, type EndpointId, type GetValueDB, type MaybeNotKnown, type MessageOrCCLogEntry, type SupervisionResult, type WithAddress } from "@zwave-js/core";
3
3
  import { Bytes } from "@zwave-js/shared";
4
4
  import { CCAPI, POLL_VALUE, type PollValueImplementation, SET_VALUE, type SetValueImplementation } from "../lib/API.js";
5
5
  import { type CCRaw, CommandClass, type InterviewContext } from "../lib/CommandClass.js";
@@ -141,6 +141,16 @@ export declare class SoundSwitchCCAPI extends CCAPI {
141
141
  export declare class SoundSwitchCC extends CommandClass {
142
142
  ccCommand: SoundSwitchCommand;
143
143
  interview(ctx: InterviewContext): Promise<void>;
144
+ /**
145
+ * Retrieves the duration in seconds for a given toneId from metadata.
146
+ * Returns undefined if duration cannot be determined.
147
+ */
148
+ static getToneDurationCached(ctx: GetValueDB, endpoint: EndpointId, toneId: number): MaybeNotKnown<number>;
149
+ /**
150
+ * Retrieves the name for a given toneId from metadata.
151
+ * Returns undefined if name cannot be determined.
152
+ */
153
+ static getToneNameCached(ctx: GetValueDB, endpoint: EndpointId, toneId: number): MaybeNotKnown<string>;
144
154
  }
145
155
  export interface SoundSwitchCCTonesNumberReportOptions {
146
156
  toneCount: number;
@@ -341,6 +341,7 @@ default volume: ${config.defaultVolume}`;
341
341
  });
342
342
  }
343
343
  const metadataStates = {};
344
+ const toneInfo = {};
344
345
  for (let toneId = 1; toneId <= toneCount; toneId++) {
345
346
  ctx.logNode(node.id, {
346
347
  message: `requesting info for tone #${toneId}`,
@@ -357,6 +358,7 @@ duration: ${info.duration} seconds`;
357
358
  direction: "inbound"
358
359
  });
359
360
  metadataStates[toneId] = `${info.name} (${info.duration} sec)`;
361
+ toneInfo[toneId] = { duration: info.duration, name: info.name };
360
362
  }
361
363
  this.setMetadata(ctx, import_CCValues_generated.SoundSwitchCCValues.defaultToneId, {
362
364
  ...import_CCValues_generated.SoundSwitchCCValues.defaultToneId.meta,
@@ -372,10 +374,33 @@ duration: ${info.duration} seconds`;
372
374
  0: "off",
373
375
  ...metadataStates,
374
376
  [255]: "default"
377
+ },
378
+ ccSpecific: {
379
+ toneInfo
375
380
  }
376
381
  });
377
382
  this.setInterviewComplete(ctx, true);
378
383
  }
384
+ /**
385
+ * Retrieves the duration in seconds for a given toneId from metadata.
386
+ * Returns undefined if duration cannot be determined.
387
+ */
388
+ static getToneDurationCached(ctx, endpoint, toneId) {
389
+ const valueDb = ctx.getValueDB(endpoint.nodeId);
390
+ const toneIdValueId = import_CCValues_generated.SoundSwitchCCValues.toneId.endpoint(endpoint.index);
391
+ const metadata = valueDb.getMetadata(toneIdValueId);
392
+ return metadata?.ccSpecific?.toneInfo?.[toneId]?.duration;
393
+ }
394
+ /**
395
+ * Retrieves the name for a given toneId from metadata.
396
+ * Returns undefined if name cannot be determined.
397
+ */
398
+ static getToneNameCached(ctx, endpoint, toneId) {
399
+ const valueDb = ctx.getValueDB(endpoint.nodeId);
400
+ const toneIdValueId = import_CCValues_generated.SoundSwitchCCValues.toneId.endpoint(endpoint.index);
401
+ const metadata = valueDb.getMetadata(toneIdValueId);
402
+ return metadata?.ccSpecific?.toneInfo?.[toneId]?.name;
403
+ }
379
404
  };
380
405
  return SoundSwitchCC2 = _classThis;
381
406
  })();
@@ -493,7 +518,7 @@ let SoundSwitchCCToneInfoReport = (() => {
493
518
  name;
494
519
  serialize(ctx) {
495
520
  this.payload = import_shared.Bytes.concat([
496
- import_shared.Bytes.from([this.toneId, 0, 0, this.name.length]),
521
+ [this.toneId, 0, 0, this.name.length],
497
522
  import_shared.Bytes.from(this.name, "utf8")
498
523
  ]);
499
524
  this.payload.writeUInt16BE(this.duration, 1);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/cc/SoundSwitchCC.ts"],
4
- "sourcesContent": ["import type { CCEncodingContext, CCParsingContext } from \"@zwave-js/cc\";\nimport {\n\tCommandClasses,\n\ttype GetValueDB,\n\ttype MaybeNotKnown,\n\ttype MessageOrCCLogEntry,\n\tMessagePriority,\n\ttype MessageRecord,\n\ttype SupervisionResult,\n\tValueMetadata,\n\ttype WithAddress,\n\tZWaveError,\n\tZWaveErrorCodes,\n\tsupervisedCommandSucceeded,\n\tvalidatePayload,\n} from \"@zwave-js/core\";\nimport { Bytes, pick } from \"@zwave-js/shared\";\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 = V.defineCCValues(\n\tCommandClasses[\"Sound Switch\"],\n\t{\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\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\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\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// oxlint-disable-next-line typescript/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\tpublic async setConfiguration(\n\t\tdefaultToneId: number,\n\t\tdefaultVolume?: number,\n\t): Promise<SupervisionResult | undefined>;\n\tpublic async setConfiguration(\n\t\tdefaultToneId: number | undefined,\n\t\tdefaultVolume: number,\n\t): Promise<SupervisionResult | undefined>;\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: defaultToneId ?? 0x00,\n\t\t\tdefaultVolume: defaultVolume ?? 0xff,\n\t\t});\n\t\treturn this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\t// oxlint-disable-next-line typescript/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// oxlint-disable-next-line typescript/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): Promise<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): Promise<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): Promise<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 type SoundSwitchCCConfigurationSetOptions = {\n\tdefaultVolume: number;\n\tdefaultToneId?: number;\n} | {\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 ?? 0xff;\n\t\tthis.defaultToneId = options.defaultToneId ?? 0x00;\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): Promise<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\tconst message: MessageRecord = {};\n\t\tif (this.defaultVolume !== 0xff) {\n\t\t\tmessage[\"default volume\"] = `${this.defaultVolume} %`;\n\t\t}\n\t\tif (this.defaultToneId !== 0x00) {\n\t\t\tmessage[\"default tone id\"] = this.defaultToneId;\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 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): Promise<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): Promise<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): Promise<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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,KAAK;QACf,QAAQ,IAAI;QACZ;QACA;OACA;IACF;IAEgB;IAET;IAEA,UAAU,KAAsB;AACtC,WAAK,UAAU,oBAAM,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;WAAA;;;;;;;;AAA3D,mBAAA,MAAA,mBAAA,EAAA,OAAA,WAAA,GAAA,kBAAA,EAAA,MAAA,SAAA,MAAA,WAAA,MAAA,UAAA,UAAA,GAAA,MAAA,uBAAA;;;AAAa,wBAAA,YAAA,uBAAA;;;;;",
4
+ "sourcesContent": ["import type { CCEncodingContext, CCParsingContext } from \"@zwave-js/cc\";\nimport {\n\tCommandClasses,\n\ttype EndpointId,\n\ttype GetValueDB,\n\ttype MaybeNotKnown,\n\ttype MessageOrCCLogEntry,\n\tMessagePriority,\n\ttype MessageRecord,\n\ttype SupervisionResult,\n\tValueMetadata,\n\ttype WithAddress,\n\tZWaveError,\n\tZWaveErrorCodes,\n\tsupervisedCommandSucceeded,\n\tvalidatePayload,\n} from \"@zwave-js/core\";\nimport { Bytes, pick } from \"@zwave-js/shared\";\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 = V.defineCCValues(\n\tCommandClasses[\"Sound Switch\"],\n\t{\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\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\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\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// oxlint-disable-next-line typescript/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\tpublic async setConfiguration(\n\t\tdefaultToneId: number,\n\t\tdefaultVolume?: number,\n\t): Promise<SupervisionResult | undefined>;\n\tpublic async setConfiguration(\n\t\tdefaultToneId: number | undefined,\n\t\tdefaultVolume: number,\n\t): Promise<SupervisionResult | undefined>;\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: defaultToneId ?? 0x00,\n\t\t\tdefaultVolume: defaultVolume ?? 0xff,\n\t\t});\n\t\treturn this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\t// oxlint-disable-next-line typescript/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// oxlint-disable-next-line typescript/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\tconst toneInfo: Record<number, { duration: number; name: 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\ttoneInfo[toneId] = { duration: info.duration, name: info.name };\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\tccSpecific: {\n\t\t\t\ttoneInfo,\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/**\n\t * Retrieves the duration in seconds for a given toneId from metadata.\n\t * Returns undefined if duration cannot be determined.\n\t */\n\tpublic static getToneDurationCached(\n\t\tctx: GetValueDB,\n\t\tendpoint: EndpointId,\n\t\ttoneId: number,\n\t): MaybeNotKnown<number> {\n\t\tconst valueDb = ctx.getValueDB(endpoint.nodeId);\n\t\tconst toneIdValueId = SoundSwitchCCValues.toneId.endpoint(\n\t\t\tendpoint.index,\n\t\t);\n\t\tconst metadata = valueDb.getMetadata(toneIdValueId);\n\t\treturn metadata?.ccSpecific?.toneInfo?.[toneId]?.duration;\n\t}\n\n\t/**\n\t * Retrieves the name for a given toneId from metadata.\n\t * Returns undefined if name cannot be determined.\n\t */\n\tpublic static getToneNameCached(\n\t\tctx: GetValueDB,\n\t\tendpoint: EndpointId,\n\t\ttoneId: number,\n\t): MaybeNotKnown<string> {\n\t\tconst valueDb = ctx.getValueDB(endpoint.nodeId);\n\t\tconst toneIdValueId = SoundSwitchCCValues.toneId.endpoint(\n\t\t\tendpoint.index,\n\t\t);\n\t\tconst metadata = valueDb.getMetadata(toneIdValueId);\n\t\treturn metadata?.ccSpecific?.toneInfo?.[toneId]?.name;\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): Promise<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): Promise<Bytes> {\n\t\tthis.payload = Bytes.concat([\n\t\t\t[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): Promise<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 type SoundSwitchCCConfigurationSetOptions = {\n\tdefaultVolume: number;\n\tdefaultToneId?: number;\n} | {\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 ?? 0xff;\n\t\tthis.defaultToneId = options.defaultToneId ?? 0x00;\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): Promise<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\tconst message: MessageRecord = {};\n\t\tif (this.defaultVolume !== 0xff) {\n\t\t\tmessage[\"default volume\"] = `${this.defaultVolume} %`;\n\t\t}\n\t\tif (this.defaultToneId !== 0x00) {\n\t\t\tmessage[\"default tone id\"] = this.defaultToneId;\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 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): Promise<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): Promise<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): Promise<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\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A,YAAA,uBAAA;;;;;",
6
6
  "names": []
7
7
  }
@@ -281,15 +281,15 @@ let SupervisionCCReport = (() => {
281
281
  duration;
282
282
  serialize(ctx) {
283
283
  this.payload = import_shared.Bytes.concat([
284
- import_shared.Bytes.from([
284
+ [
285
285
  (this.moreUpdatesFollow ? 128 : 0) | (this.requestWakeUpOnDemand ? 64 : 0) | this.sessionId & 63,
286
286
  this.status
287
- ])
287
+ ]
288
288
  ]);
289
289
  if (this.duration) {
290
290
  this.payload = import_shared.Bytes.concat([
291
291
  this.payload,
292
- import_shared.Bytes.from([this.duration.serializeReport()])
292
+ [this.duration.serializeReport()]
293
293
  ]);
294
294
  }
295
295
  return super.serialize(ctx);
@@ -373,10 +373,10 @@ let SupervisionCCGet = (() => {
373
373
  async serialize(ctx) {
374
374
  const encapCC = await this.encapsulated.serialize(ctx);
375
375
  this.payload = import_shared.Bytes.concat([
376
- import_shared.Bytes.from([
376
+ [
377
377
  (this.requestStatusUpdates ? 128 : 0) | this.sessionId & 63,
378
378
  encapCC.length
379
- ]),
379
+ ],
380
380
  encapCC
381
381
  ]);
382
382
  return super.serialize(ctx);