@zwave-js/cc 15.31.1 → 15.32.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 (127) hide show
  1. package/build/cjs/cc/AlarmSensorCC.js +2 -3
  2. package/build/cjs/cc/AlarmSensorCC.js.map +2 -2
  3. package/build/cjs/cc/AssociationGroupInfoCC.js +5 -2
  4. package/build/cjs/cc/AssociationGroupInfoCC.js.map +2 -2
  5. package/build/cjs/cc/BarrierOperatorCC.js +5 -8
  6. package/build/cjs/cc/BarrierOperatorCC.js.map +2 -2
  7. package/build/cjs/cc/BinarySensorCC.js +1 -2
  8. package/build/cjs/cc/BinarySensorCC.js.map +2 -2
  9. package/build/cjs/cc/ColorSwitchCC.js +3 -5
  10. package/build/cjs/cc/ColorSwitchCC.js.map +2 -2
  11. package/build/cjs/cc/ConfigurationCC.d.ts +7 -0
  12. package/build/cjs/cc/ConfigurationCC.js +28 -8
  13. package/build/cjs/cc/ConfigurationCC.js.map +2 -2
  14. package/build/cjs/cc/EntryControlCC.js +3 -2
  15. package/build/cjs/cc/EntryControlCC.js.map +2 -2
  16. package/build/cjs/cc/IndicatorCC.js +3 -3
  17. package/build/cjs/cc/IndicatorCC.js.map +2 -2
  18. package/build/cjs/cc/IrrigationCC.js.map +1 -1
  19. package/build/cjs/cc/LanguageCC.js +6 -2
  20. package/build/cjs/cc/LanguageCC.js.map +2 -2
  21. package/build/cjs/cc/ManufacturerSpecificCC.js +1 -1
  22. package/build/cjs/cc/ManufacturerSpecificCC.js.map +2 -2
  23. package/build/cjs/cc/MeterCC.js +25 -4
  24. package/build/cjs/cc/MeterCC.js.map +2 -2
  25. package/build/cjs/cc/NodeNamingCC.js +2 -2
  26. package/build/cjs/cc/NodeNamingCC.js.map +2 -2
  27. package/build/cjs/cc/NotificationCC.js +10 -11
  28. package/build/cjs/cc/NotificationCC.js.map +2 -2
  29. package/build/cjs/cc/PowerlevelCC.js +1 -1
  30. package/build/cjs/cc/PowerlevelCC.js.map +2 -2
  31. package/build/cjs/cc/Security2CC.js +11 -6
  32. package/build/cjs/cc/Security2CC.js.map +2 -2
  33. package/build/cjs/cc/SecurityCC.js +2 -1
  34. package/build/cjs/cc/SecurityCC.js.map +2 -2
  35. package/build/cjs/cc/SoundSwitchCC.js +1 -1
  36. package/build/cjs/cc/SoundSwitchCC.js.map +2 -2
  37. package/build/cjs/cc/ThermostatSetpointCC.js +2 -1
  38. package/build/cjs/cc/ThermostatSetpointCC.js.map +2 -2
  39. package/build/cjs/cc/UserCredentialCC.d.ts +6 -0
  40. package/build/cjs/cc/UserCredentialCC.js +81 -6
  41. package/build/cjs/cc/UserCredentialCC.js.map +2 -2
  42. package/build/cjs/cc/WindowCoveringCC.js +1 -2
  43. package/build/cjs/cc/WindowCoveringCC.js.map +2 -2
  44. package/build/cjs/cc/_CCValues.generated.d.ts +2 -2
  45. package/build/cjs/lib/Security2/Extension.js +2 -1
  46. package/build/cjs/lib/Security2/Extension.js.map +2 -2
  47. package/build/cjs/lib/securityLogging.d.ts +6 -0
  48. package/build/cjs/lib/securityLogging.js +34 -0
  49. package/build/cjs/lib/securityLogging.js.map +7 -0
  50. package/build/cjs/lib/serializers.js +3 -0
  51. package/build/cjs/lib/serializers.js.map +2 -2
  52. package/build/esm/cc/AlarmSensorCC.d.ts.map +1 -1
  53. package/build/esm/cc/AlarmSensorCC.js +5 -3
  54. package/build/esm/cc/AlarmSensorCC.js.map +1 -1
  55. package/build/esm/cc/AssociationGroupInfoCC.d.ts.map +1 -1
  56. package/build/esm/cc/AssociationGroupInfoCC.js +10 -6
  57. package/build/esm/cc/AssociationGroupInfoCC.js.map +1 -1
  58. package/build/esm/cc/BarrierOperatorCC.d.ts.map +1 -1
  59. package/build/esm/cc/BarrierOperatorCC.js +6 -9
  60. package/build/esm/cc/BarrierOperatorCC.js.map +1 -1
  61. package/build/esm/cc/BinarySensorCC.d.ts.map +1 -1
  62. package/build/esm/cc/BinarySensorCC.js +2 -3
  63. package/build/esm/cc/BinarySensorCC.js.map +1 -1
  64. package/build/esm/cc/ColorSwitchCC.d.ts.map +1 -1
  65. package/build/esm/cc/ColorSwitchCC.js +4 -7
  66. package/build/esm/cc/ColorSwitchCC.js.map +1 -1
  67. package/build/esm/cc/ConfigurationCC.d.ts +7 -0
  68. package/build/esm/cc/ConfigurationCC.d.ts.map +1 -1
  69. package/build/esm/cc/ConfigurationCC.js +34 -13
  70. package/build/esm/cc/ConfigurationCC.js.map +1 -1
  71. package/build/esm/cc/EntryControlCC.d.ts.map +1 -1
  72. package/build/esm/cc/EntryControlCC.js +4 -3
  73. package/build/esm/cc/EntryControlCC.js.map +1 -1
  74. package/build/esm/cc/IndicatorCC.d.ts.map +1 -1
  75. package/build/esm/cc/IndicatorCC.js +4 -6
  76. package/build/esm/cc/IndicatorCC.js.map +1 -1
  77. package/build/esm/cc/IrrigationCC.js.map +1 -1
  78. package/build/esm/cc/LanguageCC.d.ts.map +1 -1
  79. package/build/esm/cc/LanguageCC.js +8 -3
  80. package/build/esm/cc/LanguageCC.js.map +1 -1
  81. package/build/esm/cc/ManufacturerSpecificCC.d.ts.map +1 -1
  82. package/build/esm/cc/ManufacturerSpecificCC.js +2 -2
  83. package/build/esm/cc/ManufacturerSpecificCC.js.map +1 -1
  84. package/build/esm/cc/MeterCC.d.ts.map +1 -1
  85. package/build/esm/cc/MeterCC.js +27 -5
  86. package/build/esm/cc/MeterCC.js.map +1 -1
  87. package/build/esm/cc/NodeNamingCC.d.ts.map +1 -1
  88. package/build/esm/cc/NodeNamingCC.js +3 -3
  89. package/build/esm/cc/NodeNamingCC.js.map +1 -1
  90. package/build/esm/cc/NotificationCC.d.ts.map +1 -1
  91. package/build/esm/cc/NotificationCC.js +22 -24
  92. package/build/esm/cc/NotificationCC.js.map +1 -1
  93. package/build/esm/cc/PowerlevelCC.d.ts.map +1 -1
  94. package/build/esm/cc/PowerlevelCC.js +2 -2
  95. package/build/esm/cc/PowerlevelCC.js.map +1 -1
  96. package/build/esm/cc/Security2CC.d.ts.map +1 -1
  97. package/build/esm/cc/Security2CC.js +21 -10
  98. package/build/esm/cc/Security2CC.js.map +1 -1
  99. package/build/esm/cc/SecurityCC.d.ts.map +1 -1
  100. package/build/esm/cc/SecurityCC.js +4 -4
  101. package/build/esm/cc/SecurityCC.js.map +1 -1
  102. package/build/esm/cc/SoundSwitchCC.d.ts.map +1 -1
  103. package/build/esm/cc/SoundSwitchCC.js +2 -2
  104. package/build/esm/cc/SoundSwitchCC.js.map +1 -1
  105. package/build/esm/cc/ThermostatSetpointCC.d.ts.map +1 -1
  106. package/build/esm/cc/ThermostatSetpointCC.js +5 -1
  107. package/build/esm/cc/ThermostatSetpointCC.js.map +1 -1
  108. package/build/esm/cc/UserCredentialCC.d.ts +6 -0
  109. package/build/esm/cc/UserCredentialCC.d.ts.map +1 -1
  110. package/build/esm/cc/UserCredentialCC.js +103 -13
  111. package/build/esm/cc/UserCredentialCC.js.map +1 -1
  112. package/build/esm/cc/WindowCoveringCC.d.ts.map +1 -1
  113. package/build/esm/cc/WindowCoveringCC.js +3 -4
  114. package/build/esm/cc/WindowCoveringCC.js.map +1 -1
  115. package/build/esm/cc/_CCValues.generated.d.ts +2 -2
  116. package/build/esm/cc/_CCValues.generated.d.ts.map +1 -1
  117. package/build/esm/lib/Security2/Extension.d.ts.map +1 -1
  118. package/build/esm/lib/Security2/Extension.js +3 -3
  119. package/build/esm/lib/Security2/Extension.js.map +1 -1
  120. package/build/esm/lib/securityLogging.d.ts +6 -0
  121. package/build/esm/lib/securityLogging.d.ts.map +1 -0
  122. package/build/esm/lib/securityLogging.js +10 -0
  123. package/build/esm/lib/securityLogging.js.map +1 -0
  124. package/build/esm/lib/serializers.d.ts.map +1 -1
  125. package/build/esm/lib/serializers.js +4 -0
  126. package/build/esm/lib/serializers.js.map +1 -1
  127. package/package.json +11 -11
@@ -305,9 +305,8 @@ let BinarySensorCCReport = (() => {
305
305
  const value = raw.payload[0] === 255;
306
306
  let type = import_Types.BinarySensorType.Any;
307
307
  if (raw.payload.length >= 2) {
308
- type = raw.payload[1];
308
+ type = (0, import_core.parseEnumValue)(import_Types.BinarySensorType, raw.payload[1]);
309
309
  }
310
- (0, import_core.validatePayload)((0, import_shared.isEnumMember)(import_Types.BinarySensorType, type));
311
310
  return new this({
312
311
  nodeId: ctx.sourceNodeId,
313
312
  value,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src_gen/cc/BinarySensorCC.ts"],
4
- "sourcesContent": ["import * as __validateArgs from \"./BinarySensorCC._validateArgs.js\";\nconst { validateArgs_BinarySensorCCAPI_get, validateArgs_BinarySensorCCAPI_sendReport, validateArgs_BinarySensorCCAPI_reportSupportedSensorTypes } = __validateArgs;\nimport { CommandClasses, type EndpointId, type GetValueDB, type MaybeNotKnown, type MessageOrCCLogEntry, MessagePriority, type SupervisionResult, ValueMetadata, type WithAddress, encodeBitMask, logList, logText, parseBitMask, validatePayload, } from \"@zwave-js/core\";\nimport { Bytes, getEnumMemberName, isEnumMember } from \"@zwave-js/shared\";\nimport { CCAPI, POLL_VALUE, PhysicalCCAPI, type PollValueImplementation, throwUnsupportedProperty, } from \"../lib/API.js\";\nimport { type CCRaw, CommandClass, type InterviewContext, type PersistValuesContext, type RefreshValuesContext, type RefreshValuesOptions, getEffectiveCCVersion, } from \"../lib/CommandClass.js\";\nimport { API, CCCommand, ccValueProperty, ccValues, commandClass, expectedCCResponse, implementedVersion, } from \"../lib/CommandClassDecorators.js\";\nimport { V } from \"../lib/Values.js\";\nimport { BinarySensorCommand, BinarySensorType } from \"../lib/_Types.js\";\nimport type { CCEncodingContext, CCParsingContext } from \"../lib/traits.js\";\nimport { BinarySensorCCValues } from \"./_CCValues.generated.js\";\nexport { BinarySensorCCValues };\n// @noSetValueAPI This CC is read-only\n@API(CommandClasses[\"Binary Sensor\"])\nexport class BinarySensorCCAPI extends PhysicalCCAPI {\n public supportsCommand(cmd: BinarySensorCommand): MaybeNotKnown<boolean> {\n switch (cmd) {\n case BinarySensorCommand.Get:\n case BinarySensorCommand.Report:\n return true; // This is mandatory\n case BinarySensorCommand.SupportedGet:\n case BinarySensorCommand.SupportedReport:\n return this.version >= 2;\n }\n return super.supportsCommand(cmd);\n }\n protected get [POLL_VALUE](): PollValueImplementation {\n return async function (this: BinarySensorCCAPI, { property }) {\n if (typeof property === \"string\") {\n const sensorType = (BinarySensorType as any)[property] as BinarySensorType | undefined;\n if (sensorType)\n return this.get(sensorType);\n }\n throwUnsupportedProperty(this.ccId, property);\n };\n }\n /**\n * Retrieves the current value from this sensor\n * @param sensorType The (optional) sensor type to retrieve the value for\n */\n @validateArgs_BinarySensorCCAPI_get()\n public async get(sensorType?: BinarySensorType): Promise<MaybeNotKnown<boolean>> {\n this.assertSupportsCommand(BinarySensorCommand, BinarySensorCommand.Get);\n const cc = new BinarySensorCCGet({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n sensorType,\n });\n const response = await this.host.sendCommand<BinarySensorCCReport>(cc, this.commandOptions);\n // We don't want to repeat the sensor type\n return response?.value;\n }\n @validateArgs_BinarySensorCCAPI_sendReport()\n public async sendReport(value: boolean, sensorType?: BinarySensorType): Promise<SupervisionResult | undefined> {\n this.assertSupportsCommand(BinarySensorCommand, BinarySensorCommand.Report);\n const cc = new BinarySensorCCReport({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n value,\n type: sensorType,\n });\n return this.host.sendCommand(cc, this.commandOptions);\n }\n public async getSupportedSensorTypes(): Promise<readonly BinarySensorType[] | undefined> {\n this.assertSupportsCommand(BinarySensorCommand, BinarySensorCommand.SupportedGet);\n const cc = new BinarySensorCCSupportedGet({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n });\n const response = await this.host.sendCommand<BinarySensorCCSupportedReport>(cc, this.commandOptions);\n // We don't want to repeat the sensor type\n return response?.supportedSensorTypes;\n }\n @validateArgs_BinarySensorCCAPI_reportSupportedSensorTypes()\n public async reportSupportedSensorTypes(supported: BinarySensorType[]): Promise<SupervisionResult | undefined> {\n this.assertSupportsCommand(BinarySensorCommand, BinarySensorCommand.SupportedReport);\n const cc = new BinarySensorCCSupportedReport({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n supportedSensorTypes: supported,\n });\n return this.host.sendCommand(cc, this.commandOptions);\n }\n}\n@commandClass(CommandClasses[\"Binary Sensor\"])\n@implementedVersion(2)\n@ccValues(BinarySensorCCValues)\nexport class BinarySensorCC extends CommandClass {\n declare ccCommand: BinarySensorCommand;\n public async interview(ctx: InterviewContext): Promise<void> {\n const node = this.getNode(ctx)!;\n const endpoint = this.getEndpoint(ctx)!;\n const api = CCAPI.create(CommandClasses[\"Binary Sensor\"], ctx, endpoint).withOptions({\n priority: MessagePriority.NodeQuery,\n tag: \"interview\",\n });\n ctx.logNode(node.id, {\n endpoint: this.endpointIndex,\n message: `Interviewing ${this.ccName}...`,\n direction: \"none\",\n });\n // Find out which sensor types this sensor supports\n if (api.version >= 2) {\n ctx.logNode(node.id, {\n endpoint: this.endpointIndex,\n message: \"querying supported sensor types...\",\n direction: \"outbound\",\n });\n const supportedSensorTypes = await api.getSupportedSensorTypes();\n if (supportedSensorTypes) {\n ctx.logNode(node.id, {\n endpoint: this.endpointIndex,\n message: logText(\"received supported sensor types:\", {\n nested: logList(supportedSensorTypes.map((type) => getEnumMemberName(BinarySensorType, type))),\n }),\n direction: \"inbound\",\n });\n }\n else {\n ctx.logNode(node.id, {\n endpoint: this.endpointIndex,\n message: \"Querying supported sensor types timed out, skipping interview...\",\n level: \"warn\",\n });\n return;\n }\n }\n await this.refreshValues(ctx, { tag: \"interview\" });\n // Remember that the interview is complete\n this.setInterviewComplete(ctx, true);\n }\n public async refreshValues(ctx: RefreshValuesContext, options?: RefreshValuesOptions): Promise<void> {\n const node = this.getNode(ctx)!;\n const endpoint = this.getEndpoint(ctx)!;\n const api = CCAPI.create(CommandClasses[\"Binary Sensor\"], ctx, endpoint).withOptions({\n priority: options?.priority ?? MessagePriority.NodeQuery,\n tag: options?.tag,\n });\n // Query (all of) the sensor's current value(s)\n if (api.version === 1) {\n ctx.logNode(node.id, {\n endpoint: this.endpointIndex,\n message: \"querying current value...\",\n direction: \"outbound\",\n });\n const currentValue = await api.get();\n if (currentValue != undefined) {\n ctx.logNode(node.id, {\n endpoint: this.endpointIndex,\n message: `received current value: ${currentValue}`,\n direction: \"inbound\",\n });\n }\n }\n else {\n const supportedSensorTypes: readonly BinarySensorType[] = this.getValue(ctx, BinarySensorCCValues.supportedSensorTypes)\n ?? [];\n for (const type of supportedSensorTypes) {\n // Some devices report invalid sensor types, but the CC API checks\n // for valid values and throws otherwise.\n if (!isEnumMember(BinarySensorType, type))\n continue;\n const sensorName = getEnumMemberName(BinarySensorType, type);\n ctx.logNode(node.id, {\n endpoint: this.endpointIndex,\n message: `querying current value for ${sensorName}...`,\n direction: \"outbound\",\n });\n const currentValue = await api.get(type);\n if (currentValue != undefined) {\n ctx.logNode(node.id, {\n endpoint: this.endpointIndex,\n message: `received current value for ${sensorName}: ${currentValue}`,\n direction: \"inbound\",\n });\n }\n }\n }\n }\n /**\n * Returns which sensor types are supported.\n * This only works AFTER the interview process\n */\n public static getSupportedSensorTypesCached(ctx: GetValueDB, endpoint: EndpointId): MaybeNotKnown<BinarySensorType[]> {\n return ctx\n .getValueDB(endpoint.nodeId)\n .getValue(BinarySensorCCValues.supportedSensorTypes.endpoint(endpoint.index));\n }\n public setMappedBasicValue(ctx: GetValueDB, value: number): boolean {\n // Prefer setting an existing value to avoid creating a spurious \"Any\" sensor type.\n // Check for the Any type first (backwards compat), then the first one that\n // already exists in the value DB. Fall back to Any if none exist.\n const valueDB = this.getValueDB(ctx);\n const anyValueId = BinarySensorCCValues.state(BinarySensorType.Any).endpoint(this.endpointIndex);\n let sensorType: BinarySensorType;\n if (valueDB.hasMetadata(anyValueId)) {\n sensorType = BinarySensorType.Any;\n }\n else {\n const existingSensorTypes = valueDB\n .getAllMetadata(CommandClasses[\"Binary Sensor\"])\n .filter((v) => v.endpoint === this.endpointIndex\n && BinarySensorCCValues.state.is(v))\n .map((v) => (v.metadata as {\n ccSpecific?: {\n sensorType?: BinarySensorType;\n };\n })?.ccSpecific?.sensorType)\n .filter((t): t is BinarySensorType => t != undefined)\n .toSorted((a, b) => a - b);\n sensorType = existingSensorTypes[0] ?? BinarySensorType.Any;\n }\n const binarySensorValue = BinarySensorCCValues.state(sensorType);\n this.setValue(ctx, binarySensorValue, value > 0);\n return true;\n }\n}\n// @publicAPI\nexport interface BinarySensorCCReportOptions {\n type?: BinarySensorType;\n value: boolean;\n}\n@CCCommand(BinarySensorCommand.Report)\nexport class BinarySensorCCReport extends BinarySensorCC {\n public constructor(options: WithAddress<BinarySensorCCReportOptions>) {\n super(options);\n this.type = options.type ?? BinarySensorType.Any;\n this.value = options.value;\n }\n public static from(raw: CCRaw, ctx: CCParsingContext): BinarySensorCCReport {\n validatePayload(raw.payload.length >= 1);\n const value = raw.payload[0] === 0xff;\n let type: BinarySensorType = BinarySensorType.Any;\n if (raw.payload.length >= 2) {\n type = raw.payload[1];\n }\n validatePayload(isEnumMember(BinarySensorType, type));\n return new this({\n nodeId: ctx.sourceNodeId,\n value,\n type,\n });\n }\n public persistValues(ctx: PersistValuesContext): boolean {\n if (!super.persistValues(ctx))\n return false;\n // The sensor type field only exists in V2+ reports.\n // Ignore it if the device advertises version 1.\n const ccVersion = getEffectiveCCVersion(ctx, this);\n // Workaround for devices reporting with sensor type Any -> find first supported sensor type and use that\n let sensorType = BinarySensorType.Any;\n if (ccVersion >= 2) {\n sensorType = this.type;\n }\n if (sensorType === BinarySensorType.Any) {\n const supportedSensorTypes = this.getValue<BinarySensorType[]>(ctx, BinarySensorCCValues.supportedSensorTypes);\n if (supportedSensorTypes?.length) {\n sensorType = supportedSensorTypes[0];\n }\n }\n const binarySensorValue = BinarySensorCCValues.state(sensorType);\n this.setMetadata(ctx, binarySensorValue, binarySensorValue.meta);\n this.setValue(ctx, binarySensorValue, this.value);\n return true;\n }\n public type: BinarySensorType;\n public value: boolean;\n public serialize(ctx: CCEncodingContext): Promise<Bytes> {\n this.payload = Bytes.from([this.value ? 0xff : 0x00, this.type]);\n return super.serialize(ctx);\n }\n public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n return {\n ...super.toLogEntry(ctx),\n message: {\n type: getEnumMemberName(BinarySensorType, this.type),\n value: this.value,\n },\n };\n }\n}\nfunction testResponseForBinarySensorGet(sent: BinarySensorCCGet, received: BinarySensorCCReport) {\n // We expect a Binary Sensor Report that matches the requested sensor type (if a type was requested)\n return (sent.sensorType == undefined\n || sent.sensorType === BinarySensorType.Any\n || received.type === sent.sensorType\n // This is technically not correct, but some devices do this anyways\n || received.type === BinarySensorType.Any);\n}\n// @publicAPI\nexport interface BinarySensorCCGetOptions {\n sensorType?: BinarySensorType;\n}\n@CCCommand(BinarySensorCommand.Get)\n@expectedCCResponse(BinarySensorCCReport, testResponseForBinarySensorGet)\nexport class BinarySensorCCGet extends BinarySensorCC {\n public constructor(options: WithAddress<BinarySensorCCGetOptions>) {\n super(options);\n this.sensorType = options.sensorType;\n }\n public static from(raw: CCRaw, ctx: CCParsingContext): BinarySensorCCGet {\n let sensorType: BinarySensorType | undefined;\n if (raw.payload.length >= 1) {\n sensorType = raw.payload[0];\n }\n return new this({\n nodeId: ctx.sourceNodeId,\n sensorType,\n });\n }\n public sensorType: BinarySensorType | undefined;\n public serialize(ctx: CCEncodingContext): Promise<Bytes> {\n this.payload = Bytes.from([this.sensorType ?? BinarySensorType.Any]);\n return super.serialize(ctx);\n }\n public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n return {\n ...super.toLogEntry(ctx),\n message: {\n type: getEnumMemberName(BinarySensorType, this.sensorType ?? BinarySensorType.Any),\n },\n };\n }\n}\n// @publicAPI\nexport interface BinarySensorCCSupportedReportOptions {\n supportedSensorTypes: BinarySensorType[];\n}\n@CCCommand(BinarySensorCommand.SupportedReport)\n@ccValueProperty(\"supportedSensorTypes\", BinarySensorCCValues.supportedSensorTypes)\nexport class BinarySensorCCSupportedReport extends BinarySensorCC {\n public constructor(options: WithAddress<BinarySensorCCSupportedReportOptions>) {\n super(options);\n this.supportedSensorTypes = options.supportedSensorTypes;\n }\n public static from(raw: CCRaw, ctx: CCParsingContext): BinarySensorCCSupportedReport {\n validatePayload(raw.payload.length >= 1);\n // The enumeration starts at 1, but the first (reserved) bit is included\n // in the report\n const supportedSensorTypes: BinarySensorType[] = parseBitMask(raw.payload, 0).filter((t) => t !== 0);\n return new this({\n nodeId: ctx.sourceNodeId,\n supportedSensorTypes,\n });\n }\n public supportedSensorTypes: BinarySensorType[];\n public serialize(ctx: CCEncodingContext): Promise<Bytes> {\n this.payload = encodeBitMask(this.supportedSensorTypes.filter((t) => t !== BinarySensorType.Any), undefined, 0);\n return super.serialize(ctx);\n }\n public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n return {\n ...super.toLogEntry(ctx),\n message: {\n \"supported types\": this.supportedSensorTypes\n .map((type) => getEnumMemberName(BinarySensorType, type))\n .join(\", \"),\n },\n };\n }\n}\n@CCCommand(BinarySensorCommand.SupportedGet)\n@expectedCCResponse(BinarySensorCCSupportedReport)\nexport class BinarySensorCCSupportedGet extends BinarySensorCC {\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qBAAgC;AAEhC,kBAA0P;AAC1P,oBAAuD;AACvD,iBAA0G;AAC1G,0BAAyK;AACzK,oCAAiH;AAEjH,mBAAsD;AAEtD,gCAAqC;AATrC,MAAM,EAAE,oCAAoC,2CAA2C,0DAAyD,IAAK;IAaxI,qBAAiB,MAAA;8BAD7B,mCAAI,2BAAe,eAAe,CAAC,CAAC;;;;oBACE;;;;;yCAAA,YAAa;WAAA;;;;;;;;yBA0B/C,mCAAkC,CAAE;gCAYpC,0CAAyC,CAAE;gDAqB3C,0DAAyD,CAAE;AAhC5D,qCAAA,M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AAA,MAAA,uBAAA;;;AAAa,0CAAA,YAAA,uBAAA;;;;;",
4
+ "sourcesContent": ["import * as __validateArgs from \"./BinarySensorCC._validateArgs.js\";\nconst { validateArgs_BinarySensorCCAPI_get, validateArgs_BinarySensorCCAPI_sendReport, validateArgs_BinarySensorCCAPI_reportSupportedSensorTypes } = __validateArgs;\nimport { CommandClasses, type EndpointId, type GetValueDB, type MaybeNotKnown, type MessageOrCCLogEntry, MessagePriority, type SupervisionResult, ValueMetadata, type WithAddress, encodeBitMask, logList, logText, parseBitMask, parseEnumValue, validatePayload, } from \"@zwave-js/core\";\nimport { Bytes, getEnumMemberName, isEnumMember } from \"@zwave-js/shared\";\nimport { CCAPI, POLL_VALUE, PhysicalCCAPI, type PollValueImplementation, throwUnsupportedProperty, } from \"../lib/API.js\";\nimport { type CCRaw, CommandClass, type InterviewContext, type PersistValuesContext, type RefreshValuesContext, type RefreshValuesOptions, getEffectiveCCVersion, } from \"../lib/CommandClass.js\";\nimport { API, CCCommand, ccValueProperty, ccValues, commandClass, expectedCCResponse, implementedVersion, } from \"../lib/CommandClassDecorators.js\";\nimport { V } from \"../lib/Values.js\";\nimport { BinarySensorCommand, BinarySensorType } from \"../lib/_Types.js\";\nimport type { CCEncodingContext, CCParsingContext } from \"../lib/traits.js\";\nimport { BinarySensorCCValues } from \"./_CCValues.generated.js\";\nexport { BinarySensorCCValues };\n// @noSetValueAPI This CC is read-only\n@API(CommandClasses[\"Binary Sensor\"])\nexport class BinarySensorCCAPI extends PhysicalCCAPI {\n public supportsCommand(cmd: BinarySensorCommand): MaybeNotKnown<boolean> {\n switch (cmd) {\n case BinarySensorCommand.Get:\n case BinarySensorCommand.Report:\n return true; // This is mandatory\n case BinarySensorCommand.SupportedGet:\n case BinarySensorCommand.SupportedReport:\n return this.version >= 2;\n }\n return super.supportsCommand(cmd);\n }\n protected get [POLL_VALUE](): PollValueImplementation {\n return async function (this: BinarySensorCCAPI, { property }) {\n if (typeof property === \"string\") {\n const sensorType = (BinarySensorType as any)[property] as BinarySensorType | undefined;\n if (sensorType)\n return this.get(sensorType);\n }\n throwUnsupportedProperty(this.ccId, property);\n };\n }\n /**\n * Retrieves the current value from this sensor\n * @param sensorType The (optional) sensor type to retrieve the value for\n */\n @validateArgs_BinarySensorCCAPI_get()\n public async get(sensorType?: BinarySensorType): Promise<MaybeNotKnown<boolean>> {\n this.assertSupportsCommand(BinarySensorCommand, BinarySensorCommand.Get);\n const cc = new BinarySensorCCGet({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n sensorType,\n });\n const response = await this.host.sendCommand<BinarySensorCCReport>(cc, this.commandOptions);\n // We don't want to repeat the sensor type\n return response?.value;\n }\n @validateArgs_BinarySensorCCAPI_sendReport()\n public async sendReport(value: boolean, sensorType?: BinarySensorType): Promise<SupervisionResult | undefined> {\n this.assertSupportsCommand(BinarySensorCommand, BinarySensorCommand.Report);\n const cc = new BinarySensorCCReport({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n value,\n type: sensorType,\n });\n return this.host.sendCommand(cc, this.commandOptions);\n }\n public async getSupportedSensorTypes(): Promise<readonly BinarySensorType[] | undefined> {\n this.assertSupportsCommand(BinarySensorCommand, BinarySensorCommand.SupportedGet);\n const cc = new BinarySensorCCSupportedGet({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n });\n const response = await this.host.sendCommand<BinarySensorCCSupportedReport>(cc, this.commandOptions);\n // We don't want to repeat the sensor type\n return response?.supportedSensorTypes;\n }\n @validateArgs_BinarySensorCCAPI_reportSupportedSensorTypes()\n public async reportSupportedSensorTypes(supported: BinarySensorType[]): Promise<SupervisionResult | undefined> {\n this.assertSupportsCommand(BinarySensorCommand, BinarySensorCommand.SupportedReport);\n const cc = new BinarySensorCCSupportedReport({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n supportedSensorTypes: supported,\n });\n return this.host.sendCommand(cc, this.commandOptions);\n }\n}\n@commandClass(CommandClasses[\"Binary Sensor\"])\n@implementedVersion(2)\n@ccValues(BinarySensorCCValues)\nexport class BinarySensorCC extends CommandClass {\n declare ccCommand: BinarySensorCommand;\n public async interview(ctx: InterviewContext): Promise<void> {\n const node = this.getNode(ctx)!;\n const endpoint = this.getEndpoint(ctx)!;\n const api = CCAPI.create(CommandClasses[\"Binary Sensor\"], ctx, endpoint).withOptions({\n priority: MessagePriority.NodeQuery,\n tag: \"interview\",\n });\n ctx.logNode(node.id, {\n endpoint: this.endpointIndex,\n message: `Interviewing ${this.ccName}...`,\n direction: \"none\",\n });\n // Find out which sensor types this sensor supports\n if (api.version >= 2) {\n ctx.logNode(node.id, {\n endpoint: this.endpointIndex,\n message: \"querying supported sensor types...\",\n direction: \"outbound\",\n });\n const supportedSensorTypes = await api.getSupportedSensorTypes();\n if (supportedSensorTypes) {\n ctx.logNode(node.id, {\n endpoint: this.endpointIndex,\n message: logText(\"received supported sensor types:\", {\n nested: logList(supportedSensorTypes.map((type) => getEnumMemberName(BinarySensorType, type))),\n }),\n direction: \"inbound\",\n });\n }\n else {\n ctx.logNode(node.id, {\n endpoint: this.endpointIndex,\n message: \"Querying supported sensor types timed out, skipping interview...\",\n level: \"warn\",\n });\n return;\n }\n }\n await this.refreshValues(ctx, { tag: \"interview\" });\n // Remember that the interview is complete\n this.setInterviewComplete(ctx, true);\n }\n public async refreshValues(ctx: RefreshValuesContext, options?: RefreshValuesOptions): Promise<void> {\n const node = this.getNode(ctx)!;\n const endpoint = this.getEndpoint(ctx)!;\n const api = CCAPI.create(CommandClasses[\"Binary Sensor\"], ctx, endpoint).withOptions({\n priority: options?.priority ?? MessagePriority.NodeQuery,\n tag: options?.tag,\n });\n // Query (all of) the sensor's current value(s)\n if (api.version === 1) {\n ctx.logNode(node.id, {\n endpoint: this.endpointIndex,\n message: \"querying current value...\",\n direction: \"outbound\",\n });\n const currentValue = await api.get();\n if (currentValue != undefined) {\n ctx.logNode(node.id, {\n endpoint: this.endpointIndex,\n message: `received current value: ${currentValue}`,\n direction: \"inbound\",\n });\n }\n }\n else {\n const supportedSensorTypes: readonly BinarySensorType[] = this.getValue(ctx, BinarySensorCCValues.supportedSensorTypes)\n ?? [];\n for (const type of supportedSensorTypes) {\n // Some devices report invalid sensor types, but the CC API checks\n // for valid values and throws otherwise.\n if (!isEnumMember(BinarySensorType, type))\n continue;\n const sensorName = getEnumMemberName(BinarySensorType, type);\n ctx.logNode(node.id, {\n endpoint: this.endpointIndex,\n message: `querying current value for ${sensorName}...`,\n direction: \"outbound\",\n });\n const currentValue = await api.get(type);\n if (currentValue != undefined) {\n ctx.logNode(node.id, {\n endpoint: this.endpointIndex,\n message: `received current value for ${sensorName}: ${currentValue}`,\n direction: \"inbound\",\n });\n }\n }\n }\n }\n /**\n * Returns which sensor types are supported.\n * This only works AFTER the interview process\n */\n public static getSupportedSensorTypesCached(ctx: GetValueDB, endpoint: EndpointId): MaybeNotKnown<BinarySensorType[]> {\n return ctx\n .getValueDB(endpoint.nodeId)\n .getValue(BinarySensorCCValues.supportedSensorTypes.endpoint(endpoint.index));\n }\n public setMappedBasicValue(ctx: GetValueDB, value: number): boolean {\n // Prefer setting an existing value to avoid creating a spurious \"Any\" sensor type.\n // Check for the Any type first (backwards compat), then the first one that\n // already exists in the value DB. Fall back to Any if none exist.\n const valueDB = this.getValueDB(ctx);\n const anyValueId = BinarySensorCCValues.state(BinarySensorType.Any).endpoint(this.endpointIndex);\n let sensorType: BinarySensorType;\n if (valueDB.hasMetadata(anyValueId)) {\n sensorType = BinarySensorType.Any;\n }\n else {\n const existingSensorTypes = valueDB\n .getAllMetadata(CommandClasses[\"Binary Sensor\"])\n .filter((v) => v.endpoint === this.endpointIndex\n && BinarySensorCCValues.state.is(v))\n .map((v) => (v.metadata as {\n ccSpecific?: {\n sensorType?: BinarySensorType;\n };\n })?.ccSpecific?.sensorType)\n .filter((t): t is BinarySensorType => t != undefined)\n .toSorted((a, b) => a - b);\n sensorType = existingSensorTypes[0] ?? BinarySensorType.Any;\n }\n const binarySensorValue = BinarySensorCCValues.state(sensorType);\n this.setValue(ctx, binarySensorValue, value > 0);\n return true;\n }\n}\n// @publicAPI\nexport interface BinarySensorCCReportOptions {\n type?: BinarySensorType;\n value: boolean;\n}\n@CCCommand(BinarySensorCommand.Report)\nexport class BinarySensorCCReport extends BinarySensorCC {\n public constructor(options: WithAddress<BinarySensorCCReportOptions>) {\n super(options);\n this.type = options.type ?? BinarySensorType.Any;\n this.value = options.value;\n }\n public static from(raw: CCRaw, ctx: CCParsingContext): BinarySensorCCReport {\n validatePayload(raw.payload.length >= 1);\n const value = raw.payload[0] === 0xff;\n let type: BinarySensorType = BinarySensorType.Any;\n if (raw.payload.length >= 2) {\n type = parseEnumValue(BinarySensorType, raw.payload[1]);\n }\n return new this({\n nodeId: ctx.sourceNodeId,\n value,\n type,\n });\n }\n public persistValues(ctx: PersistValuesContext): boolean {\n if (!super.persistValues(ctx))\n return false;\n // The sensor type field only exists in V2+ reports.\n // Ignore it if the device advertises version 1.\n const ccVersion = getEffectiveCCVersion(ctx, this);\n // Workaround for devices reporting with sensor type Any -> find first supported sensor type and use that\n let sensorType = BinarySensorType.Any;\n if (ccVersion >= 2) {\n sensorType = this.type;\n }\n if (sensorType === BinarySensorType.Any) {\n const supportedSensorTypes = this.getValue<BinarySensorType[]>(ctx, BinarySensorCCValues.supportedSensorTypes);\n if (supportedSensorTypes?.length) {\n sensorType = supportedSensorTypes[0];\n }\n }\n const binarySensorValue = BinarySensorCCValues.state(sensorType);\n this.setMetadata(ctx, binarySensorValue, binarySensorValue.meta);\n this.setValue(ctx, binarySensorValue, this.value);\n return true;\n }\n public type: BinarySensorType;\n public value: boolean;\n public serialize(ctx: CCEncodingContext): Promise<Bytes> {\n this.payload = Bytes.from([this.value ? 0xff : 0x00, this.type]);\n return super.serialize(ctx);\n }\n public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n return {\n ...super.toLogEntry(ctx),\n message: {\n type: getEnumMemberName(BinarySensorType, this.type),\n value: this.value,\n },\n };\n }\n}\nfunction testResponseForBinarySensorGet(sent: BinarySensorCCGet, received: BinarySensorCCReport) {\n // We expect a Binary Sensor Report that matches the requested sensor type (if a type was requested)\n return (sent.sensorType == undefined\n || sent.sensorType === BinarySensorType.Any\n || received.type === sent.sensorType\n // This is technically not correct, but some devices do this anyways\n || received.type === BinarySensorType.Any);\n}\n// @publicAPI\nexport interface BinarySensorCCGetOptions {\n sensorType?: BinarySensorType;\n}\n@CCCommand(BinarySensorCommand.Get)\n@expectedCCResponse(BinarySensorCCReport, testResponseForBinarySensorGet)\nexport class BinarySensorCCGet extends BinarySensorCC {\n public constructor(options: WithAddress<BinarySensorCCGetOptions>) {\n super(options);\n this.sensorType = options.sensorType;\n }\n public static from(raw: CCRaw, ctx: CCParsingContext): BinarySensorCCGet {\n let sensorType: BinarySensorType | undefined;\n if (raw.payload.length >= 1) {\n sensorType = raw.payload[0];\n }\n return new this({\n nodeId: ctx.sourceNodeId,\n sensorType,\n });\n }\n public sensorType: BinarySensorType | undefined;\n public serialize(ctx: CCEncodingContext): Promise<Bytes> {\n this.payload = Bytes.from([this.sensorType ?? BinarySensorType.Any]);\n return super.serialize(ctx);\n }\n public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n return {\n ...super.toLogEntry(ctx),\n message: {\n type: getEnumMemberName(BinarySensorType, this.sensorType ?? BinarySensorType.Any),\n },\n };\n }\n}\n// @publicAPI\nexport interface BinarySensorCCSupportedReportOptions {\n supportedSensorTypes: BinarySensorType[];\n}\n@CCCommand(BinarySensorCommand.SupportedReport)\n@ccValueProperty(\"supportedSensorTypes\", BinarySensorCCValues.supportedSensorTypes)\nexport class BinarySensorCCSupportedReport extends BinarySensorCC {\n public constructor(options: WithAddress<BinarySensorCCSupportedReportOptions>) {\n super(options);\n this.supportedSensorTypes = options.supportedSensorTypes;\n }\n public static from(raw: CCRaw, ctx: CCParsingContext): BinarySensorCCSupportedReport {\n validatePayload(raw.payload.length >= 1);\n // The enumeration starts at 1, but the first (reserved) bit is included\n // in the report\n const supportedSensorTypes: BinarySensorType[] = parseBitMask(raw.payload, 0).filter((t) => t !== 0);\n return new this({\n nodeId: ctx.sourceNodeId,\n supportedSensorTypes,\n });\n }\n public supportedSensorTypes: BinarySensorType[];\n public serialize(ctx: CCEncodingContext): Promise<Bytes> {\n this.payload = encodeBitMask(this.supportedSensorTypes.filter((t) => t !== BinarySensorType.Any), undefined, 0);\n return super.serialize(ctx);\n }\n public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n return {\n ...super.toLogEntry(ctx),\n message: {\n \"supported types\": this.supportedSensorTypes\n .map((type) => getEnumMemberName(BinarySensorType, type))\n .join(\", \"),\n },\n };\n }\n}\n@CCCommand(BinarySensorCommand.SupportedGet)\n@expectedCCResponse(BinarySensorCCSupportedReport)\nexport class BinarySensorCCSupportedGet extends BinarySensorCC {\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qBAAgC;AAEhC,kBAA0Q;AAC1Q,oBAAuD;AACvD,iBAA0G;AAC1G,0BAAyK;AACzK,oCAAiH;AAEjH,mBAAsD;AAEtD,gCAAqC;AATrC,MAAM,EAAE,oCAAoC,2CAA2C,0DAAyD,IAAK;IAaxI,qBAAiB,MAAA;8BAD7B,mCAAI,2BAAe,eAAe,CAAC,CAAC;;;;oBACE;;;;;yCAAA,YAAa;WAAA;;;;;;;;yBA0B/C,mCAAkC,CAAE;gCAYpC,0CAAyC,CAAE;gDAqB3C,0DAAyD,CAAE;AAhC5D,qCAAA,MAAA,MAAA,iBAAA,EAAA,MAAA,UAAA,MAAA,OAAA,QAAA,OAAA,SAAA,OAAA,QAAA,EAAA,KAAA,gCAAA,SAAA,KAAA,QAAA,KAAA,gCAAA,IAAa,KAAb,OAAgB,GAAA,UAAA,UAAA,GAAA,MAAA,0BAAA;AAYhB,qCAAA,MAAA,MAAA,wBAAA,EAAA,MAAA,UAAA,MAAA,cAAA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,OAAA,WAAA,GAAA,kBAAA,EAAA,MAAA,SAAA,MAAA,WAAA,MAAA,UAAA,UAAA,GAAA,MAAA,uBAAA;;;AAAa,0CAAA,YAAA,uBAAA;;IACT,YAAmB,SAA0D;AACzE,YAAM,OAAO;AACb,WAAK,uBAAuB,QAAQ;IACxC;IACO,OAAO,KAAK,KAAY,KAAqB;AAChD,uCAAgB,IAAI,QAAQ,UAAU,CAAC;AAGvC,YAAM,2BAA2C,0BAAa,IAAI,SAAS,CAAC,EAAE,OAAO,CAAC,MAAM,MAAM,CAAC;AACnG,aAAO,IAAI,KAAK;QACZ,QAAQ,IAAI;QACZ;OACH;IACL;IACO;IACA,UAAU,KAAsB;AACnC,WAAK,cAAU,2BAAc,KAAK,qBAAqB,OAAO,CAAC,MAAM,MAAM,8BAAiB,GAAG,GAAG,QAAW,CAAC;AAC9G,aAAO,MAAM,UAAU,GAAG;IAC9B;IACO,WAAW,KAAgB;AAC9B,aAAO;QACH,GAAG,MAAM,WAAW,GAAG;QACvB,SAAS;UACL,mBAAmB,KAAK,qBACnB,IAAI,CAAC,aAAS,iCAAkB,+BAAkB,IAAI,CAAC,EACvD,KAAK,IAAI;;;IAG1B;;;;IAIS,8BAA0B,MAAA;8BAFtC,yCAAU,iCAAoB,YAAY,OAC1C,kDAAmB,6BAA6B,CAAC;;;;oBACF;kDAAA,YAAc;WAAA;;;;;;;;AAA9D,qCAAA,MAAA,mBAAA,EAAA,OAAA,WAAA,GAAA,kBAAA,EAAA,MAAA,SAAA,MAAA,WAAA,MAAA,UAAA,UAAA,GAAA,MAAA,uBAAA;;;AAAa,0CAAA,YAAA,uBAAA;;;;;",
6
6
  "names": []
7
7
  }
@@ -507,8 +507,7 @@ let ColorSwitchCCReport = (() => {
507
507
  }
508
508
  static from(raw, ctx) {
509
509
  (0, import_core.validatePayload)(raw.payload.length >= 2);
510
- const colorComponent = raw.payload[0];
511
- (0, import_core.validatePayload)((0, import_shared.isEnumMember)(import_Types.ColorComponent, colorComponent));
510
+ const colorComponent = (0, import_core.parseEnumValue)(import_Types.ColorComponent, raw.payload[0]);
512
511
  const currentValue = raw.payload[1];
513
512
  let targetValue;
514
513
  let duration;
@@ -696,9 +695,8 @@ let ColorSwitchCCSet = (() => {
696
695
  const component = raw.payload[offset];
697
696
  const value = raw.payload[offset + 1];
698
697
  const key = colorComponentToTableKey(component);
699
- if (key) {
700
- this.colorTable[key] = value;
701
- }
698
+ if (key)
699
+ colorTable[key] = value;
702
700
  offset += 2;
703
701
  }
704
702
  let duration;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src_gen/cc/ColorSwitchCC.ts"],
4
- "sourcesContent": ["import * as __validateArgs from \"./ColorSwitchCC._validateArgs.js\";\nconst { validateArgs_ColorSwitchCCAPI_get, validateArgs_ColorSwitchCCAPI_set, validateArgs_ColorSwitchCCAPI_startLevelChange, validateArgs_ColorSwitchCCAPI_stopLevelChange } = __validateArgs;\nimport { CommandClasses, Duration, type GetValueDB, type MaybeNotKnown, type MessageOrCCLogEntry, MessagePriority, type MessageRecord, type SupervisionResult, type ValueDB, type ValueID, ValueMetadata, type WithAddress, ZWaveError, ZWaveErrorCodes, encodeBitMask, isUnsupervisedOrSucceeded, logList, logText, parseBitMask, supervisedCommandSucceeded, validatePayload, } from \"@zwave-js/core\";\nimport { Bytes, getEnumMemberName, isEnumMember, keysOf, pick, } from \"@zwave-js/shared\";\nimport { clamp } from \"alcalzone-shared/math\";\nimport { isObject } from \"alcalzone-shared/typeguards\";\nimport { CCAPI, POLL_VALUE, type PollValueImplementation, SET_VALUE, type SetValueImplementation, throwMissingPropertyKey, throwUnsupportedProperty, throwUnsupportedPropertyKey, throwWrongValueType, } from \"../lib/API.js\";\nimport { type CCRaw, CommandClass, type InterviewContext, type PersistValuesContext, type RefreshValuesContext, type RefreshValuesOptions, getEffectiveCCVersion, } from \"../lib/CommandClass.js\";\nimport { API, CCCommand, ccValueProperty, ccValues, commandClass, expectedCCResponse, implementedVersion, useSupervision, } from \"../lib/CommandClassDecorators.js\";\nimport { V } from \"../lib/Values.js\";\nimport { ColorComponent, ColorComponentMap, type ColorKey, ColorSwitchCommand, type ColorTable, LevelChangeDirection, } from \"../lib/_Types.js\";\nimport type { CCEncodingContext, CCParsingContext } from \"../lib/traits.js\";\nconst hexColorRegex = /^#?(?<red>[0-9a-f]{2})(?<green>[0-9a-f]{2})(?<blue>[0-9a-f]{2})$/i;\nconst colorTableKeys = [\n ...keysOf(ColorComponent),\n ...keysOf(ColorComponentMap),\n];\nfunction colorTableKeyToComponent(key: string): ColorComponent {\n if (/^\\d+$/.test(key)) {\n return parseInt(key, 10);\n }\n else if (key in ColorComponentMap) {\n return (ColorComponentMap as any)[key];\n }\n else if (key in ColorComponent) {\n return (ColorComponent as any)[key];\n }\n throw new ZWaveError(`Invalid color key ${key}!`, ZWaveErrorCodes.Argument_Invalid);\n}\nfunction colorComponentToTableKey(component: ColorComponent): ColorKey | undefined {\n for (const [key, comp] of Object.entries(ColorComponentMap)) {\n if (comp === component)\n return key as any;\n }\n}\nimport { ColorSwitchCCValues } from \"./_CCValues.generated.js\";\nexport { ColorSwitchCCValues };\n@API(CommandClasses[\"Color Switch\"])\nexport class ColorSwitchCCAPI extends CCAPI {\n public supportsCommand(cmd: ColorSwitchCommand): MaybeNotKnown<boolean> {\n switch (cmd) {\n case ColorSwitchCommand.SupportedGet:\n case ColorSwitchCommand.Get:\n return this.isSinglecast();\n case ColorSwitchCommand.Set:\n case ColorSwitchCommand.StartLevelChange:\n case ColorSwitchCommand.StopLevelChange:\n return true; // These are mandatory\n }\n return super.supportsCommand(cmd);\n }\n public async getSupported(): Promise<MaybeNotKnown<readonly ColorComponent[]>> {\n this.assertSupportsCommand(ColorSwitchCommand, ColorSwitchCommand.SupportedGet);\n const cc = new ColorSwitchCCSupportedGet({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n });\n const response = await this.host.sendCommand<ColorSwitchCCSupportedReport>(cc, this.commandOptions);\n return response?.supportedColorComponents;\n }\n @validateArgs_ColorSwitchCCAPI_get()\n // oxlint-disable-next-line typescript/explicit-module-boundary-types\n public async get(component: ColorComponent) {\n this.assertSupportsCommand(ColorSwitchCommand, ColorSwitchCommand.Get);\n const cc = new ColorSwitchCCGet({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n colorComponent: component,\n });\n const response = await this.host.sendCommand<ColorSwitchCCReport>(cc, this.commandOptions);\n if (response) {\n return pick(response, [\"currentValue\", \"targetValue\", \"duration\"]);\n }\n }\n @validateArgs_ColorSwitchCCAPI_set()\n public async set(options: ColorSwitchCCSetOptions): Promise<SupervisionResult | undefined> {\n this.assertSupportsCommand(ColorSwitchCommand, ColorSwitchCommand.Set);\n const cc = new ColorSwitchCCSet({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n ...options,\n });\n const result = await this.host.sendCommand(cc, this.commandOptions);\n if (isUnsupervisedOrSucceeded(result)) {\n // If the command did not fail, assume that it succeeded and update the values accordingly\n // TODO: The API methods should not modify the value DB directly, but to do so\n // this requires a nicer way of synchronizing hexColor with the others\n if (this.isSinglecast()) {\n // Update each color component separately and record the changes to the compound value\n this.updateCurrentColor(this.getValueDB(), cc.colorTable);\n }\n else if (this.isMulticast()) {\n // Figure out which nodes were affected by this command\n const affectedNodes = this.endpoint.node.physicalNodes.filter((node) => node\n .getEndpoint(this.endpoint.index)\n ?.supportsCC(this.ccId));\n // and optimistically update the currentColor\n for (const node of affectedNodes) {\n const valueDB = this.host.tryGetValueDB(node.id);\n if (valueDB) {\n this.updateCurrentColor(valueDB, cc.colorTable);\n }\n }\n }\n }\n return result;\n }\n /** Updates the current color for a given node by merging in the given changes */\n private updateCurrentColor(valueDB: ValueDB, colorTable: ColorTable) {\n let updatedRGB = false;\n const currentColorValueId = ColorSwitchCCValues.currentColor.endpoint(this.endpoint.index);\n const targetColorValueId = ColorSwitchCCValues.targetColor.endpoint(this.endpoint.index);\n const currentCompoundColor = valueDB.getValue<Partial<Record<ColorKey, number>>>(currentColorValueId) ?? {};\n const targetCompoundColor = valueDB.getValue<Partial<Record<ColorKey, number>>>(targetColorValueId) ?? {};\n for (const [key, value] of Object.entries(colorTable)) {\n const component = colorTableKeyToComponent(key);\n if (component === ColorComponent.Red\n || component === ColorComponent.Green\n || component === ColorComponent.Blue) {\n updatedRGB = true;\n }\n valueDB.setValue(ColorSwitchCCValues.currentColorChannel(component).endpoint(this.endpoint.index), value);\n // Update the compound value\n if (key in ColorComponentMap) {\n currentCompoundColor[key as ColorKey] = value;\n targetCompoundColor[key as ColorKey] = value;\n }\n }\n // And store the updated compound values\n valueDB.setValue(currentColorValueId, currentCompoundColor);\n valueDB.setValue(targetColorValueId, targetCompoundColor);\n // and hex color if necessary\n const supportsHex = valueDB.getValue<boolean>(ColorSwitchCCValues.supportsHexColor.endpoint(this.endpoint.index));\n if (supportsHex && updatedRGB) {\n const hexValueId = ColorSwitchCCValues.hexColor.endpoint(this.endpoint.index);\n const [r, g, b] = [\n ColorComponent.Red,\n ColorComponent.Green,\n ColorComponent.Blue,\n ].map((c) => valueDB.getValue<number>(ColorSwitchCCValues.currentColorChannel(c).endpoint(this.endpoint.index)) ?? 0);\n const hexValue = (r << 16) | (g << 8) | b;\n valueDB.setValue(hexValueId, hexValue.toString(16).padStart(6, \"0\"));\n }\n }\n @validateArgs_ColorSwitchCCAPI_startLevelChange()\n public async startLevelChange(options: ColorSwitchCCStartLevelChangeOptions): Promise<SupervisionResult | undefined> {\n this.assertSupportsCommand(ColorSwitchCommand, ColorSwitchCommand.StartLevelChange);\n const cc = new ColorSwitchCCStartLevelChange({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n ...options,\n });\n return this.host.sendCommand(cc, this.commandOptions);\n }\n @validateArgs_ColorSwitchCCAPI_stopLevelChange()\n public async stopLevelChange(colorComponent: ColorComponent): Promise<SupervisionResult | undefined> {\n this.assertSupportsCommand(ColorSwitchCommand, ColorSwitchCommand.StopLevelChange);\n const cc = new ColorSwitchCCStopLevelChange({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n colorComponent,\n });\n return this.host.sendCommand(cc, this.commandOptions);\n }\n protected override get [SET_VALUE](): SetValueImplementation {\n return async function (this: ColorSwitchCCAPI, { property, propertyKey }, value, options) {\n if (property === \"targetColor\") {\n const duration = Duration.from(options?.transitionDuration);\n if (propertyKey != undefined) {\n // Single color component, only accepts numbers\n if (typeof propertyKey !== \"number\") {\n throwUnsupportedPropertyKey(this.ccId, property, propertyKey);\n }\n else if (typeof value !== \"number\") {\n throwWrongValueType(this.ccId, property, \"number\", typeof value);\n }\n const result = await this.set({\n [propertyKey]: value,\n duration,\n });\n if (this.isSinglecast()\n && !supervisedCommandSucceeded(result)) {\n // Verify the current value after a (short) delay, unless the command was supervised and successful\n this.schedulePoll({ property, propertyKey }, value, {\n duration,\n transition: \"fast\",\n });\n }\n return result;\n }\n else {\n // Set the compound color object\n // Ensure the value is an object with only valid keys\n if (!isObject(value)\n || !Object.keys(value).every((key) => key in ColorComponentMap)) {\n throw new ZWaveError(`${CommandClasses[this.ccId]}: \"${property}\" must be set to an object which specifies each color channel`, ZWaveErrorCodes.Argument_Invalid);\n }\n // Ensure that each property is numeric\n for (const [key, val] of Object.entries(value)) {\n if (typeof val !== \"number\") {\n throwWrongValueType(this.ccId, `${property}.${key}`, \"number\", typeof val);\n }\n }\n // GH#2527: strip unsupported color components, because some devices don't react otherwise\n if (this.isSinglecast()) {\n const supportedColors = this.tryGetValueDB()?.getValue<readonly ColorComponent[]>(ColorSwitchCCValues.supportedColorComponents.endpoint(this.endpoint.index));\n if (supportedColors) {\n value = pick(value, supportedColors\n .map((c) => colorComponentToTableKey(c))\n .filter((c) => !!c));\n }\n }\n // Avoid sending empty commands\n if (Object.keys(value as any).length === 0)\n return;\n return this.set({ ...(value as ColorTable), duration });\n // We're not going to poll each color component separately\n }\n }\n else if (property === \"hexColor\") {\n // No property key, this is the hex color #rrggbb\n if (typeof value !== \"string\") {\n throwWrongValueType(this.ccId, property, \"string\", typeof value);\n }\n const duration = Duration.from(options?.transitionDuration);\n return this.set({ hexColor: value, duration });\n }\n else {\n throwUnsupportedProperty(this.ccId, property);\n }\n };\n }\n public isSetValueOptimistic(_valueId: ValueID): boolean {\n return false; // Color Switch CC handles updating the value DB itself\n }\n protected get [POLL_VALUE](): PollValueImplementation {\n return async function (this: ColorSwitchCCAPI, { property, propertyKey }) {\n if (propertyKey == undefined) {\n throwMissingPropertyKey(this.ccId, property);\n }\n else if (typeof propertyKey !== \"number\") {\n throwUnsupportedPropertyKey(this.ccId, property, propertyKey);\n }\n switch (property) {\n case \"currentColor\":\n return (await this.get(propertyKey))?.currentValue;\n case \"targetColor\":\n return (await this.get(propertyKey))?.targetValue;\n case \"duration\":\n return (await this.get(propertyKey))?.duration;\n default:\n throwUnsupportedProperty(this.ccId, property);\n }\n };\n }\n}\n@commandClass(CommandClasses[\"Color Switch\"])\n@implementedVersion(3)\n@ccValues(ColorSwitchCCValues)\nexport class ColorSwitchCC extends CommandClass {\n declare ccCommand: ColorSwitchCommand;\n public async interview(ctx: InterviewContext): Promise<void> {\n const node = this.getNode(ctx)!;\n const endpoint = this.getEndpoint(ctx)!;\n const api = CCAPI.create(CommandClasses[\"Color Switch\"], ctx, endpoint).withOptions({\n priority: MessagePriority.NodeQuery,\n tag: \"interview\",\n });\n ctx.logNode(node.id, {\n endpoint: this.endpointIndex,\n message: `Interviewing ${this.ccName}...`,\n direction: \"none\",\n });\n ctx.logNode(node.id, {\n endpoint: this.endpointIndex,\n message: \"querying supported colors...\",\n direction: \"outbound\",\n });\n const supportedColors = await api.getSupported();\n if (!supportedColors) {\n ctx.logNode(node.id, {\n endpoint: this.endpointIndex,\n message: \"Querying supported colors timed out, skipping interview...\",\n level: \"warn\",\n });\n return;\n }\n ctx.logNode(node.id, {\n endpoint: this.endpointIndex,\n message: logText(\"received supported colors:\", {\n nested: logList(supportedColors.map((c) => getEnumMemberName(ColorComponent, c))),\n }),\n direction: \"outbound\",\n });\n // Create metadata for the separate color channels\n for (const color of supportedColors) {\n const currentColorChannelValue = ColorSwitchCCValues.currentColorChannel(color);\n this.setMetadata(ctx, currentColorChannelValue);\n const targetColorChannelValue = ColorSwitchCCValues.targetColorChannel(color);\n this.setMetadata(ctx, targetColorChannelValue);\n }\n // And the compound one\n const currentColorValue = ColorSwitchCCValues.currentColor;\n this.setMetadata(ctx, currentColorValue);\n const targetColorValue = ColorSwitchCCValues.targetColor;\n this.setMetadata(ctx, targetColorValue);\n // Create the collective HEX color values\n const supportsHex = [\n ColorComponent.Red,\n ColorComponent.Green,\n ColorComponent.Blue,\n ].every((c) => supportedColors.includes(c));\n this.setValue(ctx, ColorSwitchCCValues.supportsHexColor, supportsHex);\n if (supportsHex) {\n const hexColorValue = ColorSwitchCCValues.hexColor;\n this.setMetadata(ctx, hexColorValue);\n }\n // Query all color components\n await this.refreshValues(ctx, {\n tag: \"interview\",\n onProgress: (completed, total) => node.reportInterviewProgress(completed, total),\n });\n // Remember that the interview is complete\n this.setInterviewComplete(ctx, true);\n }\n public async refreshValues(ctx: RefreshValuesContext, options?: RefreshValuesOptions): Promise<void> {\n const node = this.getNode(ctx)!;\n const endpoint = this.getEndpoint(ctx)!;\n const api = CCAPI.create(CommandClasses[\"Color Switch\"], ctx, endpoint).withOptions({\n priority: options?.priority ?? MessagePriority.NodeQuery,\n tag: options?.tag,\n });\n const supportedColors: readonly ColorComponent[] = this.getValue(ctx, ColorSwitchCCValues.supportedColorComponents)\n ?? [];\n for (const [i, color] of supportedColors.entries()) {\n // Some devices report invalid colors, but the CC API checks\n // for valid values and throws otherwise.\n if (!isEnumMember(ColorComponent, color))\n continue;\n const colorName = getEnumMemberName(ColorComponent, color);\n ctx.logNode(node.id, {\n endpoint: this.endpointIndex,\n message: `querying current color state (${colorName})`,\n direction: \"outbound\",\n });\n await api.get(color);\n options?.onProgress?.(i + 1, supportedColors.length);\n }\n }\n public translatePropertyKey(ctx: GetValueDB, property: string | number, propertyKey: string | number): string | undefined {\n if ((property === \"currentColor\" || property === \"targetColor\")\n && typeof propertyKey === \"number\") {\n const translated = ColorComponent[propertyKey];\n if (translated)\n return translated;\n }\n return super.translatePropertyKey(ctx, property, propertyKey);\n }\n}\n// @publicAPI\nexport interface ColorSwitchCCSupportedReportOptions {\n supportedColorComponents: readonly ColorComponent[];\n}\n@CCCommand(ColorSwitchCommand.SupportedReport)\n@ccValueProperty(\"supportedColorComponents\", ColorSwitchCCValues.supportedColorComponents)\nexport class ColorSwitchCCSupportedReport extends ColorSwitchCC {\n public constructor(options: WithAddress<ColorSwitchCCSupportedReportOptions>) {\n super(options);\n this.supportedColorComponents = options.supportedColorComponents;\n }\n public static from(raw: CCRaw, ctx: CCParsingContext): ColorSwitchCCSupportedReport {\n // Docs say 'variable length', but the table shows 2 bytes.\n validatePayload(raw.payload.length >= 2);\n const supportedColorComponents: ColorComponent[] = parseBitMask(raw.payload.subarray(0, 2), ColorComponent[\"Warm White\"]);\n return new this({\n nodeId: ctx.sourceNodeId,\n supportedColorComponents,\n });\n }\n public readonly supportedColorComponents: readonly ColorComponent[];\n public serialize(ctx: CCEncodingContext): Promise<Bytes> {\n this.payload = encodeBitMask(this.supportedColorComponents, 15, // fixed 2 bytes\n ColorComponent[\"Warm White\"]);\n return super.serialize(ctx);\n }\n public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n return {\n ...super.toLogEntry(ctx),\n message: {\n \"supported color components\": logList(this.supportedColorComponents.map((c) => getEnumMemberName(ColorComponent, c))),\n },\n };\n }\n}\n@CCCommand(ColorSwitchCommand.SupportedGet)\n@expectedCCResponse(ColorSwitchCCSupportedReport)\nexport class ColorSwitchCCSupportedGet extends ColorSwitchCC {\n}\n// @publicAPI\nexport interface ColorSwitchCCReportOptions {\n colorComponent: ColorComponent;\n currentValue: number;\n targetValue?: number;\n duration?: Duration | string;\n}\n@CCCommand(ColorSwitchCommand.Report)\n@ccValueProperty(\"currentValue\", ColorSwitchCCValues.currentColorChannel, (self) => [self.colorComponent])\n@ccValueProperty(\"targetValue\", ColorSwitchCCValues.targetColorChannel, (self) => [self.colorComponent])\n@ccValueProperty(\"duration\", ColorSwitchCCValues.duration)\nexport class ColorSwitchCCReport extends ColorSwitchCC {\n public constructor(options: WithAddress<ColorSwitchCCReportOptions>) {\n super(options);\n this.colorComponent = options.colorComponent;\n this.currentValue = options.currentValue;\n this.targetValue = options.targetValue;\n this.duration = Duration.from(options.duration);\n }\n public static from(raw: CCRaw, ctx: CCParsingContext): ColorSwitchCCReport {\n validatePayload(raw.payload.length >= 2);\n const colorComponent: ColorComponent = raw.payload[0];\n validatePayload(isEnumMember(ColorComponent, colorComponent));\n const currentValue = raw.payload[1];\n let targetValue: number | undefined;\n let duration: Duration | undefined;\n if (raw.payload.length >= 4) {\n targetValue = raw.payload[2];\n duration = Duration.parseReport(raw.payload[3]);\n }\n return new this({\n nodeId: ctx.sourceNodeId,\n colorComponent,\n currentValue,\n targetValue,\n duration,\n });\n }\n public persistValues(ctx: PersistValuesContext): boolean {\n // Duration is stored globally instead of per component\n if (!super.persistValues(ctx))\n return false;\n // Update compound current value\n const colorTableKey = colorComponentToTableKey(this.colorComponent);\n if (colorTableKey) {\n const compoundCurrentColorValue = ColorSwitchCCValues.currentColor;\n const compoundCurrentColor: Partial<Record<ColorKey, number>> = this.getValue(ctx, compoundCurrentColorValue) ?? {};\n compoundCurrentColor[colorTableKey] = this.currentValue;\n this.setValue(ctx, compoundCurrentColorValue, compoundCurrentColor);\n // and target value\n if (this.targetValue != undefined) {\n const compoundTargetColorValue = ColorSwitchCCValues.targetColor;\n const compoundTargetColor: Partial<Record<ColorKey, number>> = this.getValue(ctx, compoundTargetColorValue) ?? {};\n compoundTargetColor[colorTableKey] = this.targetValue;\n this.setValue(ctx, compoundTargetColorValue, compoundTargetColor);\n }\n }\n // Update collective hex value if required\n const supportsHex = !!this.getValue(ctx, ColorSwitchCCValues.supportsHexColor);\n if (supportsHex\n && (this.colorComponent === ColorComponent.Red\n || this.colorComponent === ColorComponent.Green\n || this.colorComponent === ColorComponent.Blue)) {\n const hexColorValue = ColorSwitchCCValues.hexColor;\n const hexValue: string = this.getValue(ctx, hexColorValue) ?? \"000000\";\n const byteOffset = ColorComponent.Blue - this.colorComponent;\n const byteMask = 0xff << (byteOffset * 8);\n let hexValueNumeric = parseInt(hexValue, 16);\n hexValueNumeric =\n (hexValueNumeric & ~byteMask)\n | (this.currentValue << (byteOffset * 8));\n this.setValue(ctx, hexColorValue, hexValueNumeric.toString(16).padStart(6, \"0\"));\n }\n return true;\n }\n public readonly colorComponent: ColorComponent;\n public readonly currentValue: number;\n public readonly targetValue: number | undefined;\n public readonly duration: Duration | undefined;\n public serialize(ctx: CCEncodingContext): Promise<Bytes> {\n this.payload = Bytes.from([this.colorComponent, this.currentValue]);\n if (this.targetValue != undefined && this.duration != undefined) {\n this.payload = Bytes.concat([\n this.payload,\n [\n this.targetValue ?? 0xfe,\n (this.duration ?? Duration.default()).serializeReport(),\n ],\n ]);\n }\n return super.serialize(ctx);\n }\n public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n const message: MessageRecord = {\n \"color component\": getEnumMemberName(ColorComponent, this.colorComponent),\n \"current value\": this.currentValue,\n };\n if (this.targetValue != undefined) {\n message[\"target value\"] = this.targetValue;\n }\n if (this.duration != undefined) {\n message.duration = this.duration.toString();\n }\n return {\n ...super.toLogEntry(ctx),\n message,\n };\n }\n}\n// @publicAPI\nexport interface ColorSwitchCCGetOptions {\n colorComponent: ColorComponent;\n}\nfunction testResponseForColorSwitchGet(sent: ColorSwitchCCGet, received: ColorSwitchCCReport) {\n return sent.colorComponent === received.colorComponent;\n}\n@CCCommand(ColorSwitchCommand.Get)\n@expectedCCResponse(ColorSwitchCCReport, testResponseForColorSwitchGet)\nexport class ColorSwitchCCGet extends ColorSwitchCC {\n public constructor(options: WithAddress<ColorSwitchCCGetOptions>) {\n super(options);\n this._colorComponent = options.colorComponent;\n }\n public static from(raw: CCRaw, ctx: CCParsingContext): ColorSwitchCCGet {\n validatePayload(raw.payload.length >= 1);\n const colorComponent: ColorComponent = raw.payload[0];\n return new this({\n nodeId: ctx.sourceNodeId,\n colorComponent,\n });\n }\n private _colorComponent: ColorComponent;\n public get colorComponent(): ColorComponent {\n return this._colorComponent;\n }\n public set colorComponent(value: ColorComponent) {\n if (!ColorComponent[value]) {\n throw new ZWaveError(\"colorComponent must be a valid color component index.\", ZWaveErrorCodes.Argument_Invalid);\n }\n this._colorComponent = value;\n }\n public serialize(ctx: CCEncodingContext): Promise<Bytes> {\n this.payload = Bytes.from([this._colorComponent]);\n return super.serialize(ctx);\n }\n public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n return {\n ...super.toLogEntry(ctx),\n message: {\n \"color component\": getEnumMemberName(ColorComponent, this.colorComponent),\n },\n };\n }\n}\n// @publicAPI\nexport type ColorSwitchCCSetOptions = (ColorTable | {\n hexColor: string;\n}) & {\n duration?: Duration | string;\n};\n@CCCommand(ColorSwitchCommand.Set)\n@useSupervision()\nexport class ColorSwitchCCSet extends ColorSwitchCC {\n public constructor(options: WithAddress<ColorSwitchCCSetOptions>) {\n super(options);\n // Populate properties from options object\n if (\"hexColor\" in options) {\n const match = hexColorRegex.exec(options.hexColor);\n if (!match) {\n throw new ZWaveError(`${options.hexColor} is not a valid HEX color string`, ZWaveErrorCodes.Argument_Invalid);\n }\n this.colorTable = {\n red: parseInt(match.groups!.red, 16),\n green: parseInt(match.groups!.green, 16),\n blue: parseInt(match.groups!.blue, 16),\n };\n }\n else {\n this.colorTable = pick(options, colorTableKeys as any[]);\n }\n this.duration = Duration.from(options.duration);\n }\n public static from(raw: CCRaw, ctx: CCParsingContext): ColorSwitchCCSet {\n validatePayload(raw.payload.length >= 1);\n const populatedColorCount = raw.payload[0] & 0b11111;\n validatePayload(raw.payload.length >= 1 + populatedColorCount * 2);\n const colorTable: ColorTable = {};\n let offset = 1;\n for (let color = 0; color < populatedColorCount; color++) {\n const component = raw.payload[offset];\n const value = raw.payload[offset + 1];\n const key = colorComponentToTableKey(component);\n if (key) {\n // @ts-expect-error\n this.colorTable[key] = value;\n }\n offset += 2;\n }\n let duration: Duration | undefined;\n if (raw.payload.length > offset) {\n duration = Duration.parseSet(raw.payload[offset]);\n }\n return new this({\n nodeId: ctx.sourceNodeId,\n ...colorTable,\n duration,\n });\n }\n public colorTable: ColorTable;\n public duration: Duration | undefined;\n public serialize(ctx: CCEncodingContext): Promise<Bytes> {\n const populatedColorCount = Object.keys(this.colorTable).length;\n this.payload = new Bytes(1 + populatedColorCount * 2 + 1);\n this.payload[0] = populatedColorCount & 0b11111;\n let i = 1;\n for (const [key, value] of Object.entries(this.colorTable)) {\n const component = colorTableKeyToComponent(key);\n this.payload[i] = component;\n this.payload[i + 1] = clamp(value, 0, 0xff);\n i += 2;\n }\n this.payload[i] = (this.duration ?? Duration.default()).serializeSet();\n const ccVersion = getEffectiveCCVersion(ctx, this);\n if (ccVersion < 2\n && ctx.getDeviceConfig?.(this.nodeId as number)?.compat\n ?.encodeCCsUsingTargetVersion) {\n // When forcing CC version 1, omit the duration byte\n this.payload = this.payload.subarray(0, -1);\n }\n return super.serialize(ctx);\n }\n public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n const message: MessageRecord = {};\n for (const [key, value] of Object.entries(this.colorTable)) {\n const realKey: string = key in ColorComponentMap\n ? (ColorComponent as any)[(ColorComponentMap as any)[key]]\n : (ColorComponent as any)[key];\n message[realKey] = value;\n }\n if (this.duration != undefined) {\n message.duration = this.duration.toString();\n }\n return {\n ...super.toLogEntry(ctx),\n message,\n };\n }\n}\n// @publicAPI\nexport type ColorSwitchCCStartLevelChangeOptions = {\n colorComponent: ColorComponent;\n direction: keyof typeof LevelChangeDirection;\n} & ({\n ignoreStartLevel: true;\n startLevel?: number;\n} | {\n ignoreStartLevel: false;\n startLevel: number;\n}) & {\n // Version >= 3:\n duration?: Duration | string;\n};\n@CCCommand(ColorSwitchCommand.StartLevelChange)\n@useSupervision()\nexport class ColorSwitchCCStartLevelChange extends ColorSwitchCC {\n public constructor(options: WithAddress<ColorSwitchCCStartLevelChangeOptions>) {\n super(options);\n this.duration = Duration.from(options.duration);\n this.ignoreStartLevel = options.ignoreStartLevel;\n this.startLevel = options.startLevel ?? 0;\n this.direction = options.direction;\n this.colorComponent = options.colorComponent;\n }\n public static from(raw: CCRaw, ctx: CCParsingContext): ColorSwitchCCStartLevelChange {\n validatePayload(raw.payload.length >= 3);\n const ignoreStartLevel = !!((raw.payload[0] & 32) >>> 5);\n const direction = (raw.payload[0] & 64) >>> 6 ? \"down\" : \"up\";\n const colorComponent: ColorComponent = raw.payload[1];\n const startLevel = raw.payload[2];\n let duration: Duration | undefined;\n if (raw.payload.length >= 4) {\n duration = Duration.parseSet(raw.payload[3]);\n }\n return new this({\n nodeId: ctx.sourceNodeId,\n ignoreStartLevel,\n direction,\n colorComponent,\n startLevel,\n duration,\n });\n }\n public duration: Duration | undefined;\n public startLevel: number;\n public ignoreStartLevel: boolean;\n public direction: keyof typeof LevelChangeDirection;\n public colorComponent: ColorComponent;\n public serialize(ctx: CCEncodingContext): Promise<Bytes> {\n const controlByte = (LevelChangeDirection[this.direction] << 6)\n | (this.ignoreStartLevel ? 32 : 0);\n this.payload = Bytes.from([\n controlByte,\n this.colorComponent,\n this.startLevel,\n (this.duration ?? Duration.default()).serializeSet(),\n ]);\n const ccVersion = getEffectiveCCVersion(ctx, this);\n if (ccVersion < 3\n && ctx.getDeviceConfig?.(this.nodeId as number)?.compat\n ?.encodeCCsUsingTargetVersion) {\n // When forcing CC version 1 or 2, omit the duration byte\n this.payload = this.payload.subarray(0, -1);\n }\n return super.serialize(ctx);\n }\n public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n const message: MessageRecord = {\n \"color component\": getEnumMemberName(ColorComponent, this.colorComponent),\n \"start level\": `${this.startLevel}${this.ignoreStartLevel ? \" (ignored)\" : \"\"}`,\n direction: this.direction,\n };\n if (this.duration != undefined) {\n message.duration = this.duration.toString();\n }\n return {\n ...super.toLogEntry(ctx),\n message,\n };\n }\n}\n// @publicAPI\nexport interface ColorSwitchCCStopLevelChangeOptions {\n colorComponent: ColorComponent;\n}\n@CCCommand(ColorSwitchCommand.StopLevelChange)\n@useSupervision()\nexport class ColorSwitchCCStopLevelChange extends ColorSwitchCC {\n public constructor(options: WithAddress<ColorSwitchCCStopLevelChangeOptions>) {\n super(options);\n this.colorComponent = options.colorComponent;\n }\n public static from(raw: CCRaw, ctx: CCParsingContext): ColorSwitchCCStopLevelChange {\n validatePayload(raw.payload.length >= 1);\n const colorComponent: ColorComponent = raw.payload[0];\n return new this({\n nodeId: ctx.sourceNodeId,\n colorComponent,\n });\n }\n public readonly colorComponent: ColorComponent;\n public serialize(ctx: CCEncodingContext): Promise<Bytes> {\n this.payload = Bytes.from([this.colorComponent]);\n return super.serialize(ctx);\n }\n public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n return {\n ...super.toLogEntry(ctx),\n message: {\n \"color component\": getEnumMemberName(ColorComponent, this.colorComponent),\n },\n };\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qBAAgC;AAEhC,kBAAuX;AACvX,oBAAsE;AACtE,kBAAsB;AACtB,wBAAyB;AACzB,iBAA8M;AAC9M,0BAAyK;AACzK,oCAAiI;AAEjI,mBAA6H;AAyB7H,gCAAoC;AAlCpC,MAAM,EAAE,mCAAmC,mCAAmC,gDAAgD,8CAA6C,IAAK;AAWhL,MAAM,gBAAgB;AACtB,MAAM,iBAAiB;EACnB,OAAG,sBAAO,2BAAc;EACxB,OAAG,sBAAO,8BAAiB;;AAE/B,SAAS,yBAAyB,KAAW;AACzC,MAAI,QAAQ,KAAK,GAAG,GAAG;AACnB,WAAO,SAAS,KAAK,EAAE;EAC3B,WACS,OAAO,gCAAmB;AAC/B,WAAQ,+BAA0B,GAAG;EACzC,WACS,OA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O;AACb,WAAK,iBAAiB,QAAQ;IAClC;IACO,OAAO,KAAK,KAAY,KAAqB;AAChD,uCAAgB,IAAI,QAAQ,UAAU,CAAC;AACvC,YAAM,iBAAiC,IAAI,QAAQ,CAAC;AACpD,aAAO,IAAI,KAAK;QACZ,QAAQ,IAAI;QACZ;OACH;IACL;IACgB;IACT,UAAU,KAAsB;AACnC,WAAK,UAAU,oBAAM,KAAK,CAAC,KAAK,cAAc,CAAC;AAC/C,aAAO,MAAM,UAAU,GAAG;IAC9B;IACO,WAAW,KAAgB;AAC9B,aAAO;QACH,GAAG,MAAM,WAAW,GAAG;QACvB,SAAS;UACL,uBAAmB,iCAAkB,6BAAgB,KAAK,cAAc;;;IAGpF;;;;",
4
+ "sourcesContent": ["import * as __validateArgs from \"./ColorSwitchCC._validateArgs.js\";\nconst { validateArgs_ColorSwitchCCAPI_get, validateArgs_ColorSwitchCCAPI_set, validateArgs_ColorSwitchCCAPI_startLevelChange, validateArgs_ColorSwitchCCAPI_stopLevelChange } = __validateArgs;\nimport { CommandClasses, Duration, type GetValueDB, type MaybeNotKnown, type MessageOrCCLogEntry, MessagePriority, type MessageRecord, type SupervisionResult, type ValueDB, type ValueID, ValueMetadata, type WithAddress, ZWaveError, ZWaveErrorCodes, encodeBitMask, isUnsupervisedOrSucceeded, logList, logText, parseBitMask, supervisedCommandSucceeded, parseEnumValue, validatePayload, } from \"@zwave-js/core\";\nimport { Bytes, getEnumMemberName, isEnumMember, keysOf, pick, } from \"@zwave-js/shared\";\nimport { clamp } from \"alcalzone-shared/math\";\nimport { isObject } from \"alcalzone-shared/typeguards\";\nimport { CCAPI, POLL_VALUE, type PollValueImplementation, SET_VALUE, type SetValueImplementation, throwMissingPropertyKey, throwUnsupportedProperty, throwUnsupportedPropertyKey, throwWrongValueType, } from \"../lib/API.js\";\nimport { type CCRaw, CommandClass, type InterviewContext, type PersistValuesContext, type RefreshValuesContext, type RefreshValuesOptions, getEffectiveCCVersion, } from \"../lib/CommandClass.js\";\nimport { API, CCCommand, ccValueProperty, ccValues, commandClass, expectedCCResponse, implementedVersion, useSupervision, } from \"../lib/CommandClassDecorators.js\";\nimport { V } from \"../lib/Values.js\";\nimport { ColorComponent, ColorComponentMap, type ColorKey, ColorSwitchCommand, type ColorTable, LevelChangeDirection, } from \"../lib/_Types.js\";\nimport type { CCEncodingContext, CCParsingContext } from \"../lib/traits.js\";\nconst hexColorRegex = /^#?(?<red>[0-9a-f]{2})(?<green>[0-9a-f]{2})(?<blue>[0-9a-f]{2})$/i;\nconst colorTableKeys = [\n ...keysOf(ColorComponent),\n ...keysOf(ColorComponentMap),\n];\nfunction colorTableKeyToComponent(key: string): ColorComponent {\n if (/^\\d+$/.test(key)) {\n return parseInt(key, 10);\n }\n else if (key in ColorComponentMap) {\n return (ColorComponentMap as any)[key];\n }\n else if (key in ColorComponent) {\n return (ColorComponent as any)[key];\n }\n throw new ZWaveError(`Invalid color key ${key}!`, ZWaveErrorCodes.Argument_Invalid);\n}\nfunction colorComponentToTableKey(component: ColorComponent): ColorKey | undefined {\n for (const [key, comp] of Object.entries(ColorComponentMap)) {\n if (comp === component)\n return key as any;\n }\n}\nimport { ColorSwitchCCValues } from \"./_CCValues.generated.js\";\nexport { ColorSwitchCCValues };\n@API(CommandClasses[\"Color Switch\"])\nexport class ColorSwitchCCAPI extends CCAPI {\n public supportsCommand(cmd: ColorSwitchCommand): MaybeNotKnown<boolean> {\n switch (cmd) {\n case ColorSwitchCommand.SupportedGet:\n case ColorSwitchCommand.Get:\n return this.isSinglecast();\n case ColorSwitchCommand.Set:\n case ColorSwitchCommand.StartLevelChange:\n case ColorSwitchCommand.StopLevelChange:\n return true; // These are mandatory\n }\n return super.supportsCommand(cmd);\n }\n public async getSupported(): Promise<MaybeNotKnown<readonly ColorComponent[]>> {\n this.assertSupportsCommand(ColorSwitchCommand, ColorSwitchCommand.SupportedGet);\n const cc = new ColorSwitchCCSupportedGet({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n });\n const response = await this.host.sendCommand<ColorSwitchCCSupportedReport>(cc, this.commandOptions);\n return response?.supportedColorComponents;\n }\n @validateArgs_ColorSwitchCCAPI_get()\n // oxlint-disable-next-line typescript/explicit-module-boundary-types\n public async get(component: ColorComponent) {\n this.assertSupportsCommand(ColorSwitchCommand, ColorSwitchCommand.Get);\n const cc = new ColorSwitchCCGet({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n colorComponent: component,\n });\n const response = await this.host.sendCommand<ColorSwitchCCReport>(cc, this.commandOptions);\n if (response) {\n return pick(response, [\"currentValue\", \"targetValue\", \"duration\"]);\n }\n }\n @validateArgs_ColorSwitchCCAPI_set()\n public async set(options: ColorSwitchCCSetOptions): Promise<SupervisionResult | undefined> {\n this.assertSupportsCommand(ColorSwitchCommand, ColorSwitchCommand.Set);\n const cc = new ColorSwitchCCSet({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n ...options,\n });\n const result = await this.host.sendCommand(cc, this.commandOptions);\n if (isUnsupervisedOrSucceeded(result)) {\n // If the command did not fail, assume that it succeeded and update the values accordingly\n // TODO: The API methods should not modify the value DB directly, but to do so\n // this requires a nicer way of synchronizing hexColor with the others\n if (this.isSinglecast()) {\n // Update each color component separately and record the changes to the compound value\n this.updateCurrentColor(this.getValueDB(), cc.colorTable);\n }\n else if (this.isMulticast()) {\n // Figure out which nodes were affected by this command\n const affectedNodes = this.endpoint.node.physicalNodes.filter((node) => node\n .getEndpoint(this.endpoint.index)\n ?.supportsCC(this.ccId));\n // and optimistically update the currentColor\n for (const node of affectedNodes) {\n const valueDB = this.host.tryGetValueDB(node.id);\n if (valueDB) {\n this.updateCurrentColor(valueDB, cc.colorTable);\n }\n }\n }\n }\n return result;\n }\n /** Updates the current color for a given node by merging in the given changes */\n private updateCurrentColor(valueDB: ValueDB, colorTable: ColorTable) {\n let updatedRGB = false;\n const currentColorValueId = ColorSwitchCCValues.currentColor.endpoint(this.endpoint.index);\n const targetColorValueId = ColorSwitchCCValues.targetColor.endpoint(this.endpoint.index);\n const currentCompoundColor = valueDB.getValue<Partial<Record<ColorKey, number>>>(currentColorValueId) ?? {};\n const targetCompoundColor = valueDB.getValue<Partial<Record<ColorKey, number>>>(targetColorValueId) ?? {};\n for (const [key, value] of Object.entries(colorTable)) {\n const component = colorTableKeyToComponent(key);\n if (component === ColorComponent.Red\n || component === ColorComponent.Green\n || component === ColorComponent.Blue) {\n updatedRGB = true;\n }\n valueDB.setValue(ColorSwitchCCValues.currentColorChannel(component).endpoint(this.endpoint.index), value);\n // Update the compound value\n if (key in ColorComponentMap) {\n currentCompoundColor[key as ColorKey] = value;\n targetCompoundColor[key as ColorKey] = value;\n }\n }\n // And store the updated compound values\n valueDB.setValue(currentColorValueId, currentCompoundColor);\n valueDB.setValue(targetColorValueId, targetCompoundColor);\n // and hex color if necessary\n const supportsHex = valueDB.getValue<boolean>(ColorSwitchCCValues.supportsHexColor.endpoint(this.endpoint.index));\n if (supportsHex && updatedRGB) {\n const hexValueId = ColorSwitchCCValues.hexColor.endpoint(this.endpoint.index);\n const [r, g, b] = [\n ColorComponent.Red,\n ColorComponent.Green,\n ColorComponent.Blue,\n ].map((c) => valueDB.getValue<number>(ColorSwitchCCValues.currentColorChannel(c).endpoint(this.endpoint.index)) ?? 0);\n const hexValue = (r << 16) | (g << 8) | b;\n valueDB.setValue(hexValueId, hexValue.toString(16).padStart(6, \"0\"));\n }\n }\n @validateArgs_ColorSwitchCCAPI_startLevelChange()\n public async startLevelChange(options: ColorSwitchCCStartLevelChangeOptions): Promise<SupervisionResult | undefined> {\n this.assertSupportsCommand(ColorSwitchCommand, ColorSwitchCommand.StartLevelChange);\n const cc = new ColorSwitchCCStartLevelChange({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n ...options,\n });\n return this.host.sendCommand(cc, this.commandOptions);\n }\n @validateArgs_ColorSwitchCCAPI_stopLevelChange()\n public async stopLevelChange(colorComponent: ColorComponent): Promise<SupervisionResult | undefined> {\n this.assertSupportsCommand(ColorSwitchCommand, ColorSwitchCommand.StopLevelChange);\n const cc = new ColorSwitchCCStopLevelChange({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n colorComponent,\n });\n return this.host.sendCommand(cc, this.commandOptions);\n }\n protected override get [SET_VALUE](): SetValueImplementation {\n return async function (this: ColorSwitchCCAPI, { property, propertyKey }, value, options) {\n if (property === \"targetColor\") {\n const duration = Duration.from(options?.transitionDuration);\n if (propertyKey != undefined) {\n // Single color component, only accepts numbers\n if (typeof propertyKey !== \"number\") {\n throwUnsupportedPropertyKey(this.ccId, property, propertyKey);\n }\n else if (typeof value !== \"number\") {\n throwWrongValueType(this.ccId, property, \"number\", typeof value);\n }\n const result = await this.set({\n [propertyKey]: value,\n duration,\n });\n if (this.isSinglecast()\n && !supervisedCommandSucceeded(result)) {\n // Verify the current value after a (short) delay, unless the command was supervised and successful\n this.schedulePoll({ property, propertyKey }, value, {\n duration,\n transition: \"fast\",\n });\n }\n return result;\n }\n else {\n // Set the compound color object\n // Ensure the value is an object with only valid keys\n if (!isObject(value)\n || !Object.keys(value).every((key) => key in ColorComponentMap)) {\n throw new ZWaveError(`${CommandClasses[this.ccId]}: \"${property}\" must be set to an object which specifies each color channel`, ZWaveErrorCodes.Argument_Invalid);\n }\n // Ensure that each property is numeric\n for (const [key, val] of Object.entries(value)) {\n if (typeof val !== \"number\") {\n throwWrongValueType(this.ccId, `${property}.${key}`, \"number\", typeof val);\n }\n }\n // GH#2527: strip unsupported color components, because some devices don't react otherwise\n if (this.isSinglecast()) {\n const supportedColors = this.tryGetValueDB()?.getValue<readonly ColorComponent[]>(ColorSwitchCCValues.supportedColorComponents.endpoint(this.endpoint.index));\n if (supportedColors) {\n value = pick(value, supportedColors\n .map((c) => colorComponentToTableKey(c))\n .filter((c) => !!c));\n }\n }\n // Avoid sending empty commands\n if (Object.keys(value as any).length === 0)\n return;\n return this.set({ ...(value as ColorTable), duration });\n // We're not going to poll each color component separately\n }\n }\n else if (property === \"hexColor\") {\n // No property key, this is the hex color #rrggbb\n if (typeof value !== \"string\") {\n throwWrongValueType(this.ccId, property, \"string\", typeof value);\n }\n const duration = Duration.from(options?.transitionDuration);\n return this.set({ hexColor: value, duration });\n }\n else {\n throwUnsupportedProperty(this.ccId, property);\n }\n };\n }\n public isSetValueOptimistic(_valueId: ValueID): boolean {\n return false; // Color Switch CC handles updating the value DB itself\n }\n protected get [POLL_VALUE](): PollValueImplementation {\n return async function (this: ColorSwitchCCAPI, { property, propertyKey }) {\n if (propertyKey == undefined) {\n throwMissingPropertyKey(this.ccId, property);\n }\n else if (typeof propertyKey !== \"number\") {\n throwUnsupportedPropertyKey(this.ccId, property, propertyKey);\n }\n switch (property) {\n case \"currentColor\":\n return (await this.get(propertyKey))?.currentValue;\n case \"targetColor\":\n return (await this.get(propertyKey))?.targetValue;\n case \"duration\":\n return (await this.get(propertyKey))?.duration;\n default:\n throwUnsupportedProperty(this.ccId, property);\n }\n };\n }\n}\n@commandClass(CommandClasses[\"Color Switch\"])\n@implementedVersion(3)\n@ccValues(ColorSwitchCCValues)\nexport class ColorSwitchCC extends CommandClass {\n declare ccCommand: ColorSwitchCommand;\n public async interview(ctx: InterviewContext): Promise<void> {\n const node = this.getNode(ctx)!;\n const endpoint = this.getEndpoint(ctx)!;\n const api = CCAPI.create(CommandClasses[\"Color Switch\"], ctx, endpoint).withOptions({\n priority: MessagePriority.NodeQuery,\n tag: \"interview\",\n });\n ctx.logNode(node.id, {\n endpoint: this.endpointIndex,\n message: `Interviewing ${this.ccName}...`,\n direction: \"none\",\n });\n ctx.logNode(node.id, {\n endpoint: this.endpointIndex,\n message: \"querying supported colors...\",\n direction: \"outbound\",\n });\n const supportedColors = await api.getSupported();\n if (!supportedColors) {\n ctx.logNode(node.id, {\n endpoint: this.endpointIndex,\n message: \"Querying supported colors timed out, skipping interview...\",\n level: \"warn\",\n });\n return;\n }\n ctx.logNode(node.id, {\n endpoint: this.endpointIndex,\n message: logText(\"received supported colors:\", {\n nested: logList(supportedColors.map((c) => getEnumMemberName(ColorComponent, c))),\n }),\n direction: \"outbound\",\n });\n // Create metadata for the separate color channels\n for (const color of supportedColors) {\n const currentColorChannelValue = ColorSwitchCCValues.currentColorChannel(color);\n this.setMetadata(ctx, currentColorChannelValue);\n const targetColorChannelValue = ColorSwitchCCValues.targetColorChannel(color);\n this.setMetadata(ctx, targetColorChannelValue);\n }\n // And the compound one\n const currentColorValue = ColorSwitchCCValues.currentColor;\n this.setMetadata(ctx, currentColorValue);\n const targetColorValue = ColorSwitchCCValues.targetColor;\n this.setMetadata(ctx, targetColorValue);\n // Create the collective HEX color values\n const supportsHex = [\n ColorComponent.Red,\n ColorComponent.Green,\n ColorComponent.Blue,\n ].every((c) => supportedColors.includes(c));\n this.setValue(ctx, ColorSwitchCCValues.supportsHexColor, supportsHex);\n if (supportsHex) {\n const hexColorValue = ColorSwitchCCValues.hexColor;\n this.setMetadata(ctx, hexColorValue);\n }\n // Query all color components\n await this.refreshValues(ctx, {\n tag: \"interview\",\n onProgress: (completed, total) => node.reportInterviewProgress(completed, total),\n });\n // Remember that the interview is complete\n this.setInterviewComplete(ctx, true);\n }\n public async refreshValues(ctx: RefreshValuesContext, options?: RefreshValuesOptions): Promise<void> {\n const node = this.getNode(ctx)!;\n const endpoint = this.getEndpoint(ctx)!;\n const api = CCAPI.create(CommandClasses[\"Color Switch\"], ctx, endpoint).withOptions({\n priority: options?.priority ?? MessagePriority.NodeQuery,\n tag: options?.tag,\n });\n const supportedColors: readonly ColorComponent[] = this.getValue(ctx, ColorSwitchCCValues.supportedColorComponents)\n ?? [];\n for (const [i, color] of supportedColors.entries()) {\n // Some devices report invalid colors, but the CC API checks\n // for valid values and throws otherwise.\n if (!isEnumMember(ColorComponent, color))\n continue;\n const colorName = getEnumMemberName(ColorComponent, color);\n ctx.logNode(node.id, {\n endpoint: this.endpointIndex,\n message: `querying current color state (${colorName})`,\n direction: \"outbound\",\n });\n await api.get(color);\n options?.onProgress?.(i + 1, supportedColors.length);\n }\n }\n public translatePropertyKey(ctx: GetValueDB, property: string | number, propertyKey: string | number): string | undefined {\n if ((property === \"currentColor\" || property === \"targetColor\")\n && typeof propertyKey === \"number\") {\n const translated = ColorComponent[propertyKey];\n if (translated)\n return translated;\n }\n return super.translatePropertyKey(ctx, property, propertyKey);\n }\n}\n// @publicAPI\nexport interface ColorSwitchCCSupportedReportOptions {\n supportedColorComponents: readonly ColorComponent[];\n}\n@CCCommand(ColorSwitchCommand.SupportedReport)\n@ccValueProperty(\"supportedColorComponents\", ColorSwitchCCValues.supportedColorComponents)\nexport class ColorSwitchCCSupportedReport extends ColorSwitchCC {\n public constructor(options: WithAddress<ColorSwitchCCSupportedReportOptions>) {\n super(options);\n this.supportedColorComponents = options.supportedColorComponents;\n }\n public static from(raw: CCRaw, ctx: CCParsingContext): ColorSwitchCCSupportedReport {\n // Docs say 'variable length', but the table shows 2 bytes.\n validatePayload(raw.payload.length >= 2);\n const supportedColorComponents: ColorComponent[] = parseBitMask(raw.payload.subarray(0, 2), ColorComponent[\"Warm White\"]);\n return new this({\n nodeId: ctx.sourceNodeId,\n supportedColorComponents,\n });\n }\n public readonly supportedColorComponents: readonly ColorComponent[];\n public serialize(ctx: CCEncodingContext): Promise<Bytes> {\n this.payload = encodeBitMask(this.supportedColorComponents, 15, // fixed 2 bytes\n ColorComponent[\"Warm White\"]);\n return super.serialize(ctx);\n }\n public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n return {\n ...super.toLogEntry(ctx),\n message: {\n \"supported color components\": logList(this.supportedColorComponents.map((c) => getEnumMemberName(ColorComponent, c))),\n },\n };\n }\n}\n@CCCommand(ColorSwitchCommand.SupportedGet)\n@expectedCCResponse(ColorSwitchCCSupportedReport)\nexport class ColorSwitchCCSupportedGet extends ColorSwitchCC {\n}\n// @publicAPI\nexport interface ColorSwitchCCReportOptions {\n colorComponent: ColorComponent;\n currentValue: number;\n targetValue?: number;\n duration?: Duration | string;\n}\n@CCCommand(ColorSwitchCommand.Report)\n@ccValueProperty(\"currentValue\", ColorSwitchCCValues.currentColorChannel, (self) => [self.colorComponent])\n@ccValueProperty(\"targetValue\", ColorSwitchCCValues.targetColorChannel, (self) => [self.colorComponent])\n@ccValueProperty(\"duration\", ColorSwitchCCValues.duration)\nexport class ColorSwitchCCReport extends ColorSwitchCC {\n public constructor(options: WithAddress<ColorSwitchCCReportOptions>) {\n super(options);\n this.colorComponent = options.colorComponent;\n this.currentValue = options.currentValue;\n this.targetValue = options.targetValue;\n this.duration = Duration.from(options.duration);\n }\n public static from(raw: CCRaw, ctx: CCParsingContext): ColorSwitchCCReport {\n validatePayload(raw.payload.length >= 2);\n const colorComponent = parseEnumValue(ColorComponent, raw.payload[0]);\n const currentValue = raw.payload[1];\n let targetValue: number | undefined;\n let duration: Duration | undefined;\n if (raw.payload.length >= 4) {\n targetValue = raw.payload[2];\n duration = Duration.parseReport(raw.payload[3]);\n }\n return new this({\n nodeId: ctx.sourceNodeId,\n colorComponent,\n currentValue,\n targetValue,\n duration,\n });\n }\n public persistValues(ctx: PersistValuesContext): boolean {\n // Duration is stored globally instead of per component\n if (!super.persistValues(ctx))\n return false;\n // Update compound current value\n const colorTableKey = colorComponentToTableKey(this.colorComponent);\n if (colorTableKey) {\n const compoundCurrentColorValue = ColorSwitchCCValues.currentColor;\n const compoundCurrentColor: Partial<Record<ColorKey, number>> = this.getValue(ctx, compoundCurrentColorValue) ?? {};\n compoundCurrentColor[colorTableKey] = this.currentValue;\n this.setValue(ctx, compoundCurrentColorValue, compoundCurrentColor);\n // and target value\n if (this.targetValue != undefined) {\n const compoundTargetColorValue = ColorSwitchCCValues.targetColor;\n const compoundTargetColor: Partial<Record<ColorKey, number>> = this.getValue(ctx, compoundTargetColorValue) ?? {};\n compoundTargetColor[colorTableKey] = this.targetValue;\n this.setValue(ctx, compoundTargetColorValue, compoundTargetColor);\n }\n }\n // Update collective hex value if required\n const supportsHex = !!this.getValue(ctx, ColorSwitchCCValues.supportsHexColor);\n if (supportsHex\n && (this.colorComponent === ColorComponent.Red\n || this.colorComponent === ColorComponent.Green\n || this.colorComponent === ColorComponent.Blue)) {\n const hexColorValue = ColorSwitchCCValues.hexColor;\n const hexValue: string = this.getValue(ctx, hexColorValue) ?? \"000000\";\n const byteOffset = ColorComponent.Blue - this.colorComponent;\n const byteMask = 0xff << (byteOffset * 8);\n let hexValueNumeric = parseInt(hexValue, 16);\n hexValueNumeric =\n (hexValueNumeric & ~byteMask)\n | (this.currentValue << (byteOffset * 8));\n this.setValue(ctx, hexColorValue, hexValueNumeric.toString(16).padStart(6, \"0\"));\n }\n return true;\n }\n public readonly colorComponent: ColorComponent;\n public readonly currentValue: number;\n public readonly targetValue: number | undefined;\n public readonly duration: Duration | undefined;\n public serialize(ctx: CCEncodingContext): Promise<Bytes> {\n this.payload = Bytes.from([this.colorComponent, this.currentValue]);\n if (this.targetValue != undefined && this.duration != undefined) {\n this.payload = Bytes.concat([\n this.payload,\n [\n this.targetValue ?? 0xfe,\n (this.duration ?? Duration.default()).serializeReport(),\n ],\n ]);\n }\n return super.serialize(ctx);\n }\n public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n const message: MessageRecord = {\n \"color component\": getEnumMemberName(ColorComponent, this.colorComponent),\n \"current value\": this.currentValue,\n };\n if (this.targetValue != undefined) {\n message[\"target value\"] = this.targetValue;\n }\n if (this.duration != undefined) {\n message.duration = this.duration.toString();\n }\n return {\n ...super.toLogEntry(ctx),\n message,\n };\n }\n}\n// @publicAPI\nexport interface ColorSwitchCCGetOptions {\n colorComponent: ColorComponent;\n}\nfunction testResponseForColorSwitchGet(sent: ColorSwitchCCGet, received: ColorSwitchCCReport) {\n return sent.colorComponent === received.colorComponent;\n}\n@CCCommand(ColorSwitchCommand.Get)\n@expectedCCResponse(ColorSwitchCCReport, testResponseForColorSwitchGet)\nexport class ColorSwitchCCGet extends ColorSwitchCC {\n public constructor(options: WithAddress<ColorSwitchCCGetOptions>) {\n super(options);\n this._colorComponent = options.colorComponent;\n }\n public static from(raw: CCRaw, ctx: CCParsingContext): ColorSwitchCCGet {\n validatePayload(raw.payload.length >= 1);\n const colorComponent: ColorComponent = raw.payload[0];\n return new this({\n nodeId: ctx.sourceNodeId,\n colorComponent,\n });\n }\n private _colorComponent: ColorComponent;\n public get colorComponent(): ColorComponent {\n return this._colorComponent;\n }\n public set colorComponent(value: ColorComponent) {\n if (!ColorComponent[value]) {\n throw new ZWaveError(\"colorComponent must be a valid color component index.\", ZWaveErrorCodes.Argument_Invalid);\n }\n this._colorComponent = value;\n }\n public serialize(ctx: CCEncodingContext): Promise<Bytes> {\n this.payload = Bytes.from([this._colorComponent]);\n return super.serialize(ctx);\n }\n public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n return {\n ...super.toLogEntry(ctx),\n message: {\n \"color component\": getEnumMemberName(ColorComponent, this.colorComponent),\n },\n };\n }\n}\n// @publicAPI\nexport type ColorSwitchCCSetOptions = (ColorTable | {\n hexColor: string;\n}) & {\n duration?: Duration | string;\n};\n@CCCommand(ColorSwitchCommand.Set)\n@useSupervision()\nexport class ColorSwitchCCSet extends ColorSwitchCC {\n public constructor(options: WithAddress<ColorSwitchCCSetOptions>) {\n super(options);\n // Populate properties from options object\n if (\"hexColor\" in options) {\n const match = hexColorRegex.exec(options.hexColor);\n if (!match) {\n throw new ZWaveError(`${options.hexColor} is not a valid HEX color string`, ZWaveErrorCodes.Argument_Invalid);\n }\n this.colorTable = {\n red: parseInt(match.groups!.red, 16),\n green: parseInt(match.groups!.green, 16),\n blue: parseInt(match.groups!.blue, 16),\n };\n }\n else {\n this.colorTable = pick(options, colorTableKeys as any[]);\n }\n this.duration = Duration.from(options.duration);\n }\n public static from(raw: CCRaw, ctx: CCParsingContext): ColorSwitchCCSet {\n validatePayload(raw.payload.length >= 1);\n const populatedColorCount = raw.payload[0] & 0b11111;\n validatePayload(raw.payload.length >= 1 + populatedColorCount * 2);\n const colorTable: Partial<Record<ColorKey, number>> = {};\n let offset = 1;\n for (let color = 0; color < populatedColorCount; color++) {\n const component = raw.payload[offset];\n const value = raw.payload[offset + 1];\n const key = colorComponentToTableKey(component);\n if (key)\n colorTable[key] = value;\n offset += 2;\n }\n let duration: Duration | undefined;\n if (raw.payload.length > offset) {\n duration = Duration.parseSet(raw.payload[offset]);\n }\n return new this({\n nodeId: ctx.sourceNodeId,\n ...colorTable,\n duration,\n });\n }\n public colorTable: ColorTable;\n public duration: Duration | undefined;\n public serialize(ctx: CCEncodingContext): Promise<Bytes> {\n const populatedColorCount = Object.keys(this.colorTable).length;\n this.payload = new Bytes(1 + populatedColorCount * 2 + 1);\n this.payload[0] = populatedColorCount & 0b11111;\n let i = 1;\n for (const [key, value] of Object.entries(this.colorTable)) {\n const component = colorTableKeyToComponent(key);\n this.payload[i] = component;\n this.payload[i + 1] = clamp(value, 0, 0xff);\n i += 2;\n }\n this.payload[i] = (this.duration ?? Duration.default()).serializeSet();\n const ccVersion = getEffectiveCCVersion(ctx, this);\n if (ccVersion < 2\n && ctx.getDeviceConfig?.(this.nodeId as number)?.compat\n ?.encodeCCsUsingTargetVersion) {\n // When forcing CC version 1, omit the duration byte\n this.payload = this.payload.subarray(0, -1);\n }\n return super.serialize(ctx);\n }\n public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n const message: MessageRecord = {};\n for (const [key, value] of Object.entries(this.colorTable)) {\n const realKey: string = key in ColorComponentMap\n ? (ColorComponent as any)[(ColorComponentMap as any)[key]]\n : (ColorComponent as any)[key];\n message[realKey] = value;\n }\n if (this.duration != undefined) {\n message.duration = this.duration.toString();\n }\n return {\n ...super.toLogEntry(ctx),\n message,\n };\n }\n}\n// @publicAPI\nexport type ColorSwitchCCStartLevelChangeOptions = {\n colorComponent: ColorComponent;\n direction: keyof typeof LevelChangeDirection;\n} & ({\n ignoreStartLevel: true;\n startLevel?: number;\n} | {\n ignoreStartLevel: false;\n startLevel: number;\n}) & {\n // Version >= 3:\n duration?: Duration | string;\n};\n@CCCommand(ColorSwitchCommand.StartLevelChange)\n@useSupervision()\nexport class ColorSwitchCCStartLevelChange extends ColorSwitchCC {\n public constructor(options: WithAddress<ColorSwitchCCStartLevelChangeOptions>) {\n super(options);\n this.duration = Duration.from(options.duration);\n this.ignoreStartLevel = options.ignoreStartLevel;\n this.startLevel = options.startLevel ?? 0;\n this.direction = options.direction;\n this.colorComponent = options.colorComponent;\n }\n public static from(raw: CCRaw, ctx: CCParsingContext): ColorSwitchCCStartLevelChange {\n validatePayload(raw.payload.length >= 3);\n const ignoreStartLevel = !!((raw.payload[0] & 32) >>> 5);\n const direction = (raw.payload[0] & 64) >>> 6 ? \"down\" : \"up\";\n const colorComponent: ColorComponent = raw.payload[1];\n const startLevel = raw.payload[2];\n let duration: Duration | undefined;\n if (raw.payload.length >= 4) {\n duration = Duration.parseSet(raw.payload[3]);\n }\n return new this({\n nodeId: ctx.sourceNodeId,\n ignoreStartLevel,\n direction,\n colorComponent,\n startLevel,\n duration,\n });\n }\n public duration: Duration | undefined;\n public startLevel: number;\n public ignoreStartLevel: boolean;\n public direction: keyof typeof LevelChangeDirection;\n public colorComponent: ColorComponent;\n public serialize(ctx: CCEncodingContext): Promise<Bytes> {\n const controlByte = (LevelChangeDirection[this.direction] << 6)\n | (this.ignoreStartLevel ? 32 : 0);\n this.payload = Bytes.from([\n controlByte,\n this.colorComponent,\n this.startLevel,\n (this.duration ?? Duration.default()).serializeSet(),\n ]);\n const ccVersion = getEffectiveCCVersion(ctx, this);\n if (ccVersion < 3\n && ctx.getDeviceConfig?.(this.nodeId as number)?.compat\n ?.encodeCCsUsingTargetVersion) {\n // When forcing CC version 1 or 2, omit the duration byte\n this.payload = this.payload.subarray(0, -1);\n }\n return super.serialize(ctx);\n }\n public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n const message: MessageRecord = {\n \"color component\": getEnumMemberName(ColorComponent, this.colorComponent),\n \"start level\": `${this.startLevel}${this.ignoreStartLevel ? \" (ignored)\" : \"\"}`,\n direction: this.direction,\n };\n if (this.duration != undefined) {\n message.duration = this.duration.toString();\n }\n return {\n ...super.toLogEntry(ctx),\n message,\n };\n }\n}\n// @publicAPI\nexport interface ColorSwitchCCStopLevelChangeOptions {\n colorComponent: ColorComponent;\n}\n@CCCommand(ColorSwitchCommand.StopLevelChange)\n@useSupervision()\nexport class ColorSwitchCCStopLevelChange extends ColorSwitchCC {\n public constructor(options: WithAddress<ColorSwitchCCStopLevelChangeOptions>) {\n super(options);\n this.colorComponent = options.colorComponent;\n }\n public static from(raw: CCRaw, ctx: CCParsingContext): ColorSwitchCCStopLevelChange {\n validatePayload(raw.payload.length >= 1);\n const colorComponent: ColorComponent = raw.payload[0];\n return new this({\n nodeId: ctx.sourceNodeId,\n colorComponent,\n });\n }\n public readonly colorComponent: ColorComponent;\n public serialize(ctx: CCEncodingContext): Promise<Bytes> {\n this.payload = Bytes.from([this.colorComponent]);\n return super.serialize(ctx);\n }\n public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n return {\n ...super.toLogEntry(ctx),\n message: {\n \"color component\": getEnumMemberName(ColorComponent, this.colorComponent),\n },\n };\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qBAAgC;AAEhC,kBAAuY;AACvY,oBAAsE;AACtE,kBAAsB;AACtB,wBAAyB;AACzB,iBAA8M;AAC9M,0BAAyK;AACzK,oCAAiI;AAEjI,mBAA6H;AAyB7H,gCAAoC;AAlCpC,MAAM,EAAE,mCAAmC,mCAAmC,gDAAgD,8CAA6C,IAAK;AAWhL,MAAM,gBAAgB;AACtB,MAAM,iBAAiB;EACnB,OAAG,sBAAO,2BAAc;EACxB,OAAG,sBAAO,8BAAiB;;AAE/B,SAAS,yBAAyB,KAAW;AACzC,MAAI,QAAQ,KAAK,GAAG,GAAG;AACnB,WAAO,SAAS,KAAK,EAAE;EAC3B,WACS,OAAO,gCAAmB;AAC/B,WAAQ,+BAA0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B,QAAQ;IAClC;IACO,OAAO,KAAK,KAAY,KAAqB;AAChD,uCAAgB,IAAI,QAAQ,UAAU,CAAC;AACvC,YAAM,iBAAiC,IAAI,QAAQ,CAAC;AACpD,aAAO,IAAI,KAAK;QACZ,QAAQ,IAAI;QACZ;OACH;IACL;IACgB;IACT,UAAU,KAAsB;AACnC,WAAK,UAAU,oBAAM,KAAK,CAAC,KAAK,cAAc,CAAC;AAC/C,aAAO,MAAM,UAAU,GAAG;IAC9B;IACO,WAAW,KAAgB;AAC9B,aAAO;QACH,GAAG,MAAM,WAAW,GAAG;QACvB,SAAS;UACL,uBAAmB,iCAAkB,6BAAgB,KAAK,cAAc;;;IAGpF;;;;",
6
6
  "names": []
7
7
  }
@@ -113,6 +113,11 @@ export declare class ConfigurationCCAPI extends CCAPI {
113
113
  export declare class ConfigurationCC extends CommandClass {
114
114
  ccCommand: ConfigurationCommand;
115
115
  interview(ctx: InterviewContext): Promise<void>;
116
+ /**
117
+ * Applies all recommended values from the device config to this node
118
+ * Applies only if the current value is still the default value and
119
+ * the recommended value is different
120
+ */
116
121
  private applyRecommendedValues;
117
122
  refreshValues(ctx: RefreshValuesContext, options?: RefreshValuesOptions): Promise<void>;
118
123
  /**
@@ -277,6 +282,7 @@ export declare class ConfigurationCCNameReport extends ConfigurationCC {
277
282
  static from(raw: CCRaw, ctx: CCParsingContext): ConfigurationCCNameReport;
278
283
  readonly parameter: number;
279
284
  name: string;
285
+ private rawName;
280
286
  readonly reportsToFollow: number;
281
287
  persistValues(ctx: PersistValuesContext): boolean;
282
288
  serialize(ctx: CCEncodingContext): Promise<Bytes>;
@@ -303,6 +309,7 @@ export declare class ConfigurationCCInfoReport extends ConfigurationCC {
303
309
  static from(raw: CCRaw, ctx: CCParsingContext): ConfigurationCCInfoReport;
304
310
  readonly parameter: number;
305
311
  info: string;
312
+ private rawInfo;
306
313
  readonly reportsToFollow: number;
307
314
  persistValues(ctx: PersistValuesContext): boolean;
308
315
  serialize(ctx: CCEncodingContext): Promise<Bytes>;
@@ -1526,6 +1526,9 @@ let ConfigurationCCBulkReport = (() => {
1526
1526
  const defaultValues = !!(raw.payload[4] & 128);
1527
1527
  const isHandshakeResponse = !!(raw.payload[4] & 64);
1528
1528
  const valueSize = raw.payload[4] & 7;
1529
+ if (numParams !== 0 && !isValidValueSize(valueSize)) {
1530
+ import_core.validatePayload.fail(`Invalid value size ${valueSize}`);
1531
+ }
1529
1532
  (0, import_core.validatePayload)(raw.payload.length >= 5 + numParams * valueSize);
1530
1533
  const values = {};
1531
1534
  for (let i = 0; i < numParams; i++) {
@@ -1714,16 +1717,21 @@ let ConfigurationCCNameReport = (() => {
1714
1717
  if (reportsToFollow > 0) {
1715
1718
  (0, import_core.validatePayload)(raw.payload.length >= 4);
1716
1719
  }
1717
- const name = raw.payload.subarray(3).toString("utf8");
1718
- return new this({
1720
+ const rawName = raw.payload.subarray(3).toString("utf8");
1721
+ const ret = new this({
1719
1722
  nodeId: ctx.sourceNodeId,
1720
1723
  parameter,
1721
1724
  reportsToFollow,
1722
- name
1725
+ name: (0, import_shared.stripControlCharacters)(rawName)
1723
1726
  });
1727
+ ret.rawName = rawName;
1728
+ return ret;
1724
1729
  }
1725
1730
  parameter;
1726
1731
  name;
1732
+ // Line breaks and NUL terminators may be split across reports, so the
1733
+ // merged text must be sanitized as a whole
1734
+ rawName;
1727
1735
  reportsToFollow;
1728
1736
  persistValues(ctx) {
1729
1737
  if (!super.persistValues(ctx))
@@ -1764,7 +1772,7 @@ let ConfigurationCCNameReport = (() => {
1764
1772
  return this.reportsToFollow;
1765
1773
  }
1766
1774
  mergePartialCCs(partials, _ctx) {
1767
- this.name = [...partials, this].map((report) => report.name).reduce((prev, cur) => prev + cur, "");
1775
+ this.name = (0, import_shared.stripControlCharacters)([...partials, this].map((report) => report.rawName ?? report.name).join(""));
1768
1776
  return Promise.resolve();
1769
1777
  }
1770
1778
  toLogEntry(ctx) {
@@ -1860,16 +1868,21 @@ let ConfigurationCCInfoReport = (() => {
1860
1868
  if (reportsToFollow > 0) {
1861
1869
  (0, import_core.validatePayload)(raw.payload.length >= 4);
1862
1870
  }
1863
- const info = raw.payload.subarray(3).toString("utf8");
1864
- return new this({
1871
+ const rawInfo = raw.payload.subarray(3).toString("utf8");
1872
+ const ret = new this({
1865
1873
  nodeId: ctx.sourceNodeId,
1866
1874
  parameter,
1867
1875
  reportsToFollow,
1868
- info
1876
+ info: (0, import_shared.stripControlCharacters)(rawInfo, { keepNewlines: true })
1869
1877
  });
1878
+ ret.rawInfo = rawInfo;
1879
+ return ret;
1870
1880
  }
1871
1881
  parameter;
1872
1882
  info;
1883
+ // Line breaks and NUL terminators may be split across reports, so the
1884
+ // merged text must be sanitized as a whole
1885
+ rawInfo;
1873
1886
  reportsToFollow;
1874
1887
  persistValues(ctx) {
1875
1888
  if (!super.persistValues(ctx))
@@ -1910,7 +1923,7 @@ let ConfigurationCCInfoReport = (() => {
1910
1923
  return this.reportsToFollow;
1911
1924
  }
1912
1925
  mergePartialCCs(partials, _ctx) {
1913
- this.info = [...partials, this].map((report) => report.info).reduce((prev, cur) => prev + cur, "");
1926
+ this.info = (0, import_shared.stripControlCharacters)([...partials, this].map((report) => report.rawInfo ?? report.info).join(""), { keepNewlines: true });
1914
1927
  return Promise.resolve();
1915
1928
  }
1916
1929
  toLogEntry(ctx) {
@@ -2021,6 +2034,9 @@ let ConfigurationCCPropertiesReport = (() => {
2021
2034
  const parameter = raw.payload.readUInt16BE(0);
2022
2035
  const valueFormat = (raw.payload[2] & 56) >>> 3;
2023
2036
  const valueSize = raw.payload[2] & 7;
2037
+ if (valueSize !== 0 && !isValidValueSize(valueSize)) {
2038
+ import_core.validatePayload.fail(`Invalid value size ${valueSize}`);
2039
+ }
2024
2040
  let nextParameter;
2025
2041
  if (valueSize === 0 && raw.payload.length < 5) {
2026
2042
  nextParameter = 0;
@@ -2301,6 +2317,10 @@ function parseValue(raw, size, format) {
2301
2317
  }
2302
2318
  }
2303
2319
  __name(parseValue, "parseValue");
2320
+ function isValidValueSize(valueSize) {
2321
+ return valueSize === 1 || valueSize === 2 || valueSize === 4;
2322
+ }
2323
+ __name(isValidValueSize, "isValidValueSize");
2304
2324
  function throwInvalidValueError(value, parameter, valueSize, valueFormat) {
2305
2325
  throw new import_core.ZWaveError(`The value ${value} is invalid for configuration parameter ${parameter} (size = ${valueSize}, format = ${(0, import_shared.getEnumMemberName)(import_core.ConfigValueFormat, valueFormat)})!`, import_core.ZWaveErrorCodes.Argument_Invalid);
2306
2326
  }