@zwave-js/cc 15.24.3 → 15.25.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/AssociationCC.d.ts +1 -1
  2. package/build/cjs/cc/AssociationCC.js +6 -3
  3. package/build/cjs/cc/AssociationCC.js.map +2 -2
  4. package/build/cjs/cc/AssociationGroupInfoCC.js +5 -1
  5. package/build/cjs/cc/AssociationGroupInfoCC.js.map +2 -2
  6. package/build/cjs/cc/ColorSwitchCC.js +5 -2
  7. package/build/cjs/cc/ColorSwitchCC.js.map +2 -2
  8. package/build/cjs/cc/ConfigurationCC.d.ts +14 -3
  9. package/build/cjs/cc/ConfigurationCC.js +65 -19
  10. package/build/cjs/cc/ConfigurationCC.js.map +2 -2
  11. package/build/cjs/cc/IndicatorCC.js +7 -3
  12. package/build/cjs/cc/IndicatorCC.js.map +2 -2
  13. package/build/cjs/cc/IrrigationCC.js +6 -2
  14. package/build/cjs/cc/IrrigationCC.js.map +2 -2
  15. package/build/cjs/cc/MeterCC.js +6 -1
  16. package/build/cjs/cc/MeterCC.js.map +2 -2
  17. package/build/cjs/cc/MultiChannelAssociationCC.d.ts +1 -1
  18. package/build/cjs/cc/MultiChannelAssociationCC.js +6 -3
  19. package/build/cjs/cc/MultiChannelAssociationCC.js.map +2 -2
  20. package/build/cjs/cc/MultiChannelCC.d.ts +1 -1
  21. package/build/cjs/cc/MultiChannelCC.js +4 -2
  22. package/build/cjs/cc/MultiChannelCC.js.map +2 -2
  23. package/build/cjs/cc/MultilevelSensorCC.js +7 -3
  24. package/build/cjs/cc/MultilevelSensorCC.js.map +2 -2
  25. package/build/cjs/cc/NotificationCC.js +9 -2
  26. package/build/cjs/cc/NotificationCC.js.map +2 -2
  27. package/build/cjs/cc/SceneControllerConfigurationCC.js +1 -0
  28. package/build/cjs/cc/SceneControllerConfigurationCC.js.map +2 -2
  29. package/build/cjs/cc/SecurityCC.d.ts +2 -2
  30. package/build/cjs/cc/SecurityCC.js +6 -4
  31. package/build/cjs/cc/SecurityCC.js.map +2 -2
  32. package/build/cjs/cc/ThermostatOperatingStateCC.d.ts +1 -1
  33. package/build/cjs/cc/ThermostatOperatingStateCC.js +2 -2
  34. package/build/cjs/cc/ThermostatOperatingStateCC.js.map +2 -2
  35. package/build/cjs/cc/ThermostatSetpointCC.js +8 -3
  36. package/build/cjs/cc/ThermostatSetpointCC.js.map +2 -2
  37. package/build/cjs/cc/TransportServiceCC.d.ts +0 -14
  38. package/build/cjs/cc/TransportServiceCC.js +0 -41
  39. package/build/cjs/cc/TransportServiceCC.js.map +2 -2
  40. package/build/cjs/cc/UserCodeCC.js +5 -1
  41. package/build/cjs/cc/UserCodeCC.js.map +2 -2
  42. package/build/cjs/cc/UserCredentialCC.d.ts +2 -2
  43. package/build/cjs/cc/UserCredentialCC.js +7 -3
  44. package/build/cjs/cc/UserCredentialCC.js.map +2 -2
  45. package/build/cjs/cc/VersionCC.js +7 -5
  46. package/build/cjs/cc/VersionCC.js.map +2 -2
  47. package/build/cjs/cc/WindowCoveringCC.js +6 -4
  48. package/build/cjs/cc/WindowCoveringCC.js.map +2 -2
  49. package/build/cjs/lib/CommandClass.d.ts +15 -6
  50. package/build/cjs/lib/CommandClass.js +10 -5
  51. package/build/cjs/lib/CommandClass.js.map +2 -2
  52. package/build/cjs/lib/traits.d.ts +16 -1
  53. package/build/esm/cc/AssociationCC.d.ts +1 -1
  54. package/build/esm/cc/AssociationCC.d.ts.map +1 -1
  55. package/build/esm/cc/AssociationCC.js +6 -3
  56. package/build/esm/cc/AssociationCC.js.map +1 -1
  57. package/build/esm/cc/AssociationGroupInfoCC.d.ts.map +1 -1
  58. package/build/esm/cc/AssociationGroupInfoCC.js +7 -1
  59. package/build/esm/cc/AssociationGroupInfoCC.js.map +1 -1
  60. package/build/esm/cc/ColorSwitchCC.d.ts.map +1 -1
  61. package/build/esm/cc/ColorSwitchCC.js +5 -2
  62. package/build/esm/cc/ColorSwitchCC.js.map +1 -1
  63. package/build/esm/cc/ConfigurationCC.d.ts +14 -3
  64. package/build/esm/cc/ConfigurationCC.d.ts.map +1 -1
  65. package/build/esm/cc/ConfigurationCC.js +98 -25
  66. package/build/esm/cc/ConfigurationCC.js.map +1 -1
  67. package/build/esm/cc/IndicatorCC.d.ts.map +1 -1
  68. package/build/esm/cc/IndicatorCC.js +8 -3
  69. package/build/esm/cc/IndicatorCC.js.map +1 -1
  70. package/build/esm/cc/IrrigationCC.d.ts.map +1 -1
  71. package/build/esm/cc/IrrigationCC.js +6 -2
  72. package/build/esm/cc/IrrigationCC.js.map +1 -1
  73. package/build/esm/cc/MeterCC.d.ts.map +1 -1
  74. package/build/esm/cc/MeterCC.js +6 -1
  75. package/build/esm/cc/MeterCC.js.map +1 -1
  76. package/build/esm/cc/MultiChannelAssociationCC.d.ts +1 -1
  77. package/build/esm/cc/MultiChannelAssociationCC.d.ts.map +1 -1
  78. package/build/esm/cc/MultiChannelAssociationCC.js +6 -3
  79. package/build/esm/cc/MultiChannelAssociationCC.js.map +1 -1
  80. package/build/esm/cc/MultiChannelCC.d.ts +1 -1
  81. package/build/esm/cc/MultiChannelCC.d.ts.map +1 -1
  82. package/build/esm/cc/MultiChannelCC.js +4 -2
  83. package/build/esm/cc/MultiChannelCC.js.map +1 -1
  84. package/build/esm/cc/MultilevelSensorCC.d.ts.map +1 -1
  85. package/build/esm/cc/MultilevelSensorCC.js +7 -3
  86. package/build/esm/cc/MultilevelSensorCC.js.map +1 -1
  87. package/build/esm/cc/NotificationCC.d.ts.map +1 -1
  88. package/build/esm/cc/NotificationCC.js +9 -2
  89. package/build/esm/cc/NotificationCC.js.map +1 -1
  90. package/build/esm/cc/SceneControllerConfigurationCC.d.ts.map +1 -1
  91. package/build/esm/cc/SceneControllerConfigurationCC.js +1 -0
  92. package/build/esm/cc/SceneControllerConfigurationCC.js.map +1 -1
  93. package/build/esm/cc/SecurityCC.d.ts +2 -2
  94. package/build/esm/cc/SecurityCC.d.ts.map +1 -1
  95. package/build/esm/cc/SecurityCC.js +7 -4
  96. package/build/esm/cc/SecurityCC.js.map +1 -1
  97. package/build/esm/cc/ThermostatOperatingStateCC.d.ts +1 -1
  98. package/build/esm/cc/ThermostatOperatingStateCC.d.ts.map +1 -1
  99. package/build/esm/cc/ThermostatOperatingStateCC.js +2 -2
  100. package/build/esm/cc/ThermostatOperatingStateCC.js.map +1 -1
  101. package/build/esm/cc/ThermostatSetpointCC.d.ts.map +1 -1
  102. package/build/esm/cc/ThermostatSetpointCC.js +10 -3
  103. package/build/esm/cc/ThermostatSetpointCC.js.map +1 -1
  104. package/build/esm/cc/TransportServiceCC.d.ts +0 -14
  105. package/build/esm/cc/TransportServiceCC.d.ts.map +1 -1
  106. package/build/esm/cc/TransportServiceCC.js +1 -54
  107. package/build/esm/cc/TransportServiceCC.js.map +1 -1
  108. package/build/esm/cc/UserCodeCC.d.ts.map +1 -1
  109. package/build/esm/cc/UserCodeCC.js +4 -0
  110. package/build/esm/cc/UserCodeCC.js.map +1 -1
  111. package/build/esm/cc/UserCredentialCC.d.ts +2 -2
  112. package/build/esm/cc/UserCredentialCC.d.ts.map +1 -1
  113. package/build/esm/cc/UserCredentialCC.js +7 -4
  114. package/build/esm/cc/UserCredentialCC.js.map +1 -1
  115. package/build/esm/cc/VersionCC.d.ts.map +1 -1
  116. package/build/esm/cc/VersionCC.js +12 -6
  117. package/build/esm/cc/VersionCC.js.map +1 -1
  118. package/build/esm/cc/WindowCoveringCC.d.ts.map +1 -1
  119. package/build/esm/cc/WindowCoveringCC.js +7 -5
  120. package/build/esm/cc/WindowCoveringCC.js.map +1 -1
  121. package/build/esm/lib/CommandClass.d.ts +15 -6
  122. package/build/esm/lib/CommandClass.d.ts.map +1 -1
  123. package/build/esm/lib/CommandClass.js +10 -5
  124. package/build/esm/lib/CommandClass.js.map +1 -1
  125. package/build/esm/lib/traits.d.ts +16 -1
  126. package/build/esm/lib/traits.d.ts.map +1 -1
  127. package/package.json +4 -4
@@ -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, 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\n .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 });\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: `received supported colors:${supportedColors\n .map((c) => `\\n\u00B7 ${getEnumMemberName(ColorComponent, c)}`)\n .join(\"\")}`,\n direction: \"outbound\",\n });\n // Create metadata for the separate color channels\n for (const color of supportedColors) {\n const currentColorChannelValue = ColorSwitchCCValues\n .currentColorChannel(color);\n this.setMetadata(ctx, currentColorChannelValue);\n const targetColorChannelValue = ColorSwitchCCValues\n .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 // 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 });\n const supportedColors: readonly ColorComponent[] = this.getValue(ctx, ColorSwitchCCValues.supportedColorComponents) ?? [];\n for (const color of supportedColors) {\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 }\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\": this.supportedColorComponents\n .map((c) => `\\n\u00B7 ${getEnumMemberName(ColorComponent, c)}`)\n .join(\"\"),\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)\n ?? \"000000\";\n const byteOffset = ColorComponent.Blue - this.colorComponent;\n const byteMask = 0xff << (byteOffset * 8);\n let hexValueNumeric = parseInt(hexValue, 16);\n hexValueNumeric = (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([\n this.colorComponent,\n this.currentValue,\n ]);\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 && ctx.getDeviceConfig?.(this.nodeId as number)?.compat?.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)\n ? \"down\"\n : \"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 && ctx.getDeviceConfig?.(this.nodeId as number)?.compat?.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,kBAAqW;AACrW,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,OAAO,6BAAgB;AAC5B,WAAQ,4BAAuB,GAAG;EACtC;AACA,QAAM,IAAI,uBAAW,qBAAqB,GAAG,KAAK,4BAAgB,gBAAgB;AACtF;AAXS;AAYT,SAAS,yBAAyB,WAAyB;AACvD,aAAW,CAAC,KAAK,IAAI,KAAK,OAAO,QAAQ,8BAAiB,GAAG;AACzD,QAAI,SAAS;AACT,aAAO;EACf;AACJ;AALS;IASI,oBAAgB,MAAA;8BAD5B,mCAAI,2BAAe,cAAc,CAAC,CAAC;;;;oBACE;;;;;;wCAAA,YAAK;WAAA;;;;;;;;AAwBvC,qCAAA,MAAA,MAAA,iBAAA,EAAA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C9C;AACA,aAAO,MAAM,UAAU,GAAG;IAC9B;IACO,WAAW,KAAgB;AAC9B,YAAM,UAAyB;QAC3B,uBAAmB,iCAAkB,6BAAgB,KAAK,cAAc;QACxE,eAAe,GAAG,KAAK,UAAU,GAAG,KAAK,mBAAmB,eAAe,EAAE;QAC7E,WAAW,KAAK;;AAEpB,UAAI,KAAK,YAAY,QAAW;AAC5B,gBAAQ,WAAW,KAAK,SAAS,SAAQ;MAC7C;AACA,aAAO;QACH,GAAG,MAAM,WAAW,GAAG;QACvB;;IAER;;;;IAQS,gCAA4B,MAAA;8BAFxC,yCAAU,gCAAmB,eAAe,OAC5C,8CAAc,CAAE;;;;oBACiC;oDAAA,YAAa;WAAA;;;;;;;;AAA/D,qCAAA,MAAA,mBAAA,EAAA,OAAA,WAAA,GAAA,kBAAA,EAAA,MAAA,SAAA,MAAA,WAAA,MAAA,UAAA,UAAA,GAAA,MAAA,uBAAA;;;AAAa,0CAAA,YAAA,uBAAA;;IACT,YAAmB,SAAyD;AACxE,YAAM,OAAO;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, 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\n .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 });\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: `received supported colors:${supportedColors\n .map((c) => `\\n\u00B7 ${getEnumMemberName(ColorComponent, c)}`)\n .join(\"\")}`,\n direction: \"outbound\",\n });\n // Create metadata for the separate color channels\n for (const color of supportedColors) {\n const currentColorChannelValue = ColorSwitchCCValues\n .currentColorChannel(color);\n this.setMetadata(ctx, currentColorChannelValue);\n const targetColorChannelValue = ColorSwitchCCValues\n .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 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 });\n const supportedColors: readonly ColorComponent[] = this.getValue(ctx, ColorSwitchCCValues.supportedColorComponents) ?? [];\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\": this.supportedColorComponents\n .map((c) => `\\n\u00B7 ${getEnumMemberName(ColorComponent, c)}`)\n .join(\"\"),\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)\n ?? \"000000\";\n const byteOffset = ColorComponent.Blue - this.colorComponent;\n const byteMask = 0xff << (byteOffset * 8);\n let hexValueNumeric = parseInt(hexValue, 16);\n hexValueNumeric = (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([\n this.colorComponent,\n this.currentValue,\n ]);\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 && ctx.getDeviceConfig?.(this.nodeId as number)?.compat?.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)\n ? \"down\"\n : \"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 && ctx.getDeviceConfig?.(this.nodeId as number)?.compat?.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,kBAAqW;AACrW,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,OAAO,6BAAgB;AAC5B,WAAQ,4BAAuB,GAAG;EACtC;AACA,QAAM,IAAI,uBAAW,qBAAqB,GAAG,KAAK,4BAAgB,gBAAgB;AACtF;AAXS;AAYT,SAAS,yBAAyB,WAAyB;AACvD,aAAW,CAAC,KAAK,IAAI,KAAK,OAAO,QAAQ,8BAAiB,GAAG;AACzD,QAAI,SAAS;AACT,aAAO;EACf;AACJ;AALS;IASI,oBAAgB,MAAA;8BAD5B,mCAAI,2BAAe,cAAc,CAAC,CAAC;;;;oBACE;;;;;;wCAAA,YAAK;WAAA;;;;;;;;AAwBvC,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,G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C9C;AACA,aAAO,MAAM,UAAU,GAAG;IAC9B;IACO,WAAW,KAAgB;AAC9B,YAAM,UAAyB;QAC3B,uBAAmB,iCAAkB,6BAAgB,KAAK,cAAc;QACxE,eAAe,GAAG,KAAK,UAAU,GAAG,KAAK,mBAAmB,eAAe,EAAE;QAC7E,WAAW,KAAK;;AAEpB,UAAI,KAAK,YAAY,QAAW;AAC5B,gBAAQ,WAAW,KAAK,SAAS,SAAQ;MAC7C;AACA,aAAO;QACH,GAAG,MAAM,WAAW,GAAG;QACvB;;IAER;;;;IAQS,gCAA4B,MAAA;8BAFxC,yCAAU,gCAAmB,eAAe,OAC5C,8CAAc,CAAE;;;;oBACiC;oDAAA,YAAa;WAAA;;;;;;;;AAA/D,qCAAA,MAAA,mBAAA,EAAA,OAAA,WAAA,GAAA,kBAAA,EAAA,MAAA,SAAA,MAAA,WAAA,MAAA,UAAA,UAAA,GAAA,MAAA,uBAAA;;;AAAa,0CAAA,YAAA,uBAAA;;IACT,YAAmB,SAAyD;AACxE,YAAM,OAAO;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;;;;",
6
6
  "names": []
7
7
  }
@@ -28,6 +28,16 @@ export type ConfigurationCCAPISetOptions = {
28
28
  bitMask: number;
29
29
  value: number;
30
30
  });
31
+ /**
32
+ * Returns the distinct parameter numbers in a ParamInfoMap. Partial parameters share a
33
+ * parameter number and are collapsed to a single entry, since they are queried together.
34
+ */
35
+ export declare function getDistinctConfigParameters(paramInfo: ParamInfoMap): number[];
36
+ /**
37
+ * Returns the distinct readable (non-write-only) parameter numbers in a ParamInfoMap.
38
+ * These are the parameters whose value is queried during the interview.
39
+ */
40
+ export declare function getReadableConfigParameters(paramInfo: ParamInfoMap): number[];
31
41
  /**
32
42
  * Refreshes all stored configuration parameter metadata from the device config file.
33
43
  * This handles updates to existing params, addition of new params,
@@ -240,7 +250,8 @@ export declare class ConfigurationCCBulkReport extends ConfigurationCC {
240
250
  private _values;
241
251
  get values(): ReadonlyMap<number, ConfigValue>;
242
252
  getPartialCCSessionId(): Record<string, any> | undefined;
243
- expectMoreMessages(): boolean;
253
+ getRemainingSegments(): number | undefined;
254
+ mergePartialCCs(partials: ConfigurationCCBulkReport[], _ctx: CCParsingContext): Promise<void>;
244
255
  toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry;
245
256
  }
246
257
  export interface ConfigurationCCBulkGetOptions {
@@ -269,7 +280,7 @@ export declare class ConfigurationCCNameReport extends ConfigurationCC {
269
280
  persistValues(ctx: PersistValuesContext): boolean;
270
281
  serialize(ctx: CCEncodingContext): Promise<Bytes>;
271
282
  getPartialCCSessionId(): Record<string, any> | undefined;
272
- expectMoreMessages(): boolean;
283
+ getRemainingSegments(): number | undefined;
273
284
  mergePartialCCs(partials: ConfigurationCCNameReport[], _ctx: CCParsingContext): Promise<void>;
274
285
  toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry;
275
286
  }
@@ -295,7 +306,7 @@ export declare class ConfigurationCCInfoReport extends ConfigurationCC {
295
306
  persistValues(ctx: PersistValuesContext): boolean;
296
307
  serialize(ctx: CCEncodingContext): Promise<Bytes>;
297
308
  getPartialCCSessionId(): Record<string, any> | undefined;
298
- expectMoreMessages(): boolean;
309
+ getRemainingSegments(): number | undefined;
299
310
  mergePartialCCs(partials: ConfigurationCCInfoReport[], _ctx: CCParsingContext): Promise<void>;
300
311
  toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry;
301
312
  }
@@ -46,6 +46,8 @@ __export(ConfigurationCC_exports, {
46
46
  ConfigurationCCReport: () => ConfigurationCCReport,
47
47
  ConfigurationCCSet: () => ConfigurationCCSet,
48
48
  ConfigurationCCValues: () => import_CCValues_generated.ConfigurationCCValues,
49
+ getDistinctConfigParameters: () => getDistinctConfigParameters,
50
+ getReadableConfigParameters: () => getReadableConfigParameters,
49
51
  refreshConfigParamMetadataFromConfigFile: () => refreshConfigParamMetadataFromConfigFile
50
52
  });
51
53
  module.exports = __toCommonJS(ConfigurationCC_exports);
@@ -167,6 +169,26 @@ function getParamInformationFromConfigFile(ctx, nodeId, endpointIndex) {
167
169
  }
168
170
  }
169
171
  __name(getParamInformationFromConfigFile, "getParamInformationFromConfigFile");
172
+ function getDistinctConfigParameters(paramInfo) {
173
+ return (0, import_arrays.distinct)([...paramInfo.keys()].map((key) => key.parameter));
174
+ }
175
+ __name(getDistinctConfigParameters, "getDistinctConfigParameters");
176
+ function getReadableConfigParameters(paramInfo) {
177
+ return (0, import_arrays.distinct)([...paramInfo.keys()].filter((key) => !paramInfo.get(key)?.writeOnly).map((key) => key.parameter));
178
+ }
179
+ __name(getReadableConfigParameters, "getReadableConfigParameters");
180
+ function estimateConfigurationInterviewQueryCount(paramInfo, ccVersion, assumedParamCount, skipNameQuery, skipInfoQuery) {
181
+ if (paramInfo?.size) {
182
+ if (ccVersion < 3)
183
+ return getReadableConfigParameters(paramInfo).length;
184
+ return getDistinctConfigParameters(paramInfo).length + getReadableConfigParameters(paramInfo).length;
185
+ }
186
+ if (ccVersion < 3)
187
+ return assumedParamCount;
188
+ const queriesPerParam = 2 + (skipNameQuery ? 0 : 1) + (skipInfoQuery ? 0 : 1);
189
+ return assumedParamCount * queriesPerParam;
190
+ }
191
+ __name(estimateConfigurationInterviewQueryCount, "estimateConfigurationInterviewQueryCount");
170
192
  function configParamInfoToMetadata(info) {
171
193
  return (0, import_core.stripUndefined)({
172
194
  // TODO: Make this smarter! (0...1 ==> boolean)
@@ -749,6 +771,7 @@ let ConfigurationCC = (() => {
749
771
  this.deserializeParamInformationFromConfig(ctx, paramInfo);
750
772
  }
751
773
  const documentedParamNumbers = new Set(Array.from(paramInfo?.keys() ?? []).map((k) => k.parameter));
774
+ let configScanProgress = 0;
752
775
  if (api.version >= 3) {
753
776
  ctx.logNode(node.id, {
754
777
  endpoint: this.endpointIndex,
@@ -775,6 +798,8 @@ let ConfigurationCC = (() => {
775
798
  });
776
799
  return;
777
800
  }
801
+ const expectedQueryCount = estimateConfigurationInterviewQueryCount(paramInfo, api.version, node.getInterviewProgressWeight(import_core.CommandClasses.Configuration), !!deviceConfig?.compat?.skipConfigurationNameQuery, !!deviceConfig?.compat?.skipConfigurationInfoQuery);
802
+ let scannedQueries = 0;
778
803
  while (param > 0) {
779
804
  ctx.logNode(node.id, {
780
805
  endpoint: this.endpointIndex,
@@ -794,6 +819,7 @@ let ConfigurationCC = (() => {
794
819
  break;
795
820
  }
796
821
  const { nextParameter, ...properties } = props;
822
+ node.reportInterviewProgress(++scannedQueries, expectedQueryCount);
797
823
  let logMessage;
798
824
  if (properties.valueSize === 0) {
799
825
  logMessage = `Parameter #${param} is unsupported. Next parameter: ${nextParameter}`;
@@ -805,12 +831,14 @@ let ConfigurationCC = (() => {
805
831
  // If querying the name fails, don't abort the entire interview
806
832
  () => void 0
807
833
  );
834
+ node.reportInterviewProgress(++scannedQueries, expectedQueryCount);
808
835
  }
809
836
  if (!deviceConfig?.compat?.skipConfigurationInfoQuery) {
810
837
  await api.getInfo(param).catch(
811
838
  // If querying the info fails, don't abort the entire interview
812
839
  () => void 0
813
840
  );
841
+ node.reportInterviewProgress(++scannedQueries, expectedQueryCount);
814
842
  }
815
843
  }
816
844
  logMessage = `received information for parameter #${param}:`;
@@ -840,8 +868,14 @@ alters capabilities: ${!!properties.altersCapabilities}`;
840
868
  break;
841
869
  }
842
870
  }
871
+ configScanProgress = Math.min(1, scannedQueries / expectedQueryCount);
843
872
  }
844
- await this.refreshValues(ctx);
873
+ await this.refreshValues(ctx, {
874
+ onProgress: /* @__PURE__ */ __name((completed, total) => {
875
+ const fraction = total > 0 ? configScanProgress + completed / total * (1 - configScanProgress) : configScanProgress;
876
+ node.reportInterviewProgress(fraction, 1);
877
+ }, "onProgress")
878
+ });
845
879
  if (paramInfo !== void 0 && ctx.getInterviewOptions().applyRecommendedConfigParamValues === true) {
846
880
  await this.applyRecommendedValues(ctx, node, paramInfo, api);
847
881
  }
@@ -895,29 +929,25 @@ alters capabilities: ${!!properties.altersCapabilities}`;
895
929
  if (api.version < 3) {
896
930
  const paramInfo = getParamInformationFromConfigFile(ctx, node.id, this.endpointIndex);
897
931
  if (paramInfo?.size) {
898
- const alreadyQueried = /* @__PURE__ */ new Set();
899
- for (const param of paramInfo.keys()) {
900
- if (paramInfo.get(param)?.writeOnly)
901
- continue;
902
- if (alreadyQueried.has(param.parameter))
903
- continue;
904
- alreadyQueried.add(param.parameter);
932
+ const parametersToQuery = getReadableConfigParameters(paramInfo);
933
+ for (const [i, parameter] of parametersToQuery.entries()) {
905
934
  ctx.logNode(node.id, {
906
935
  endpoint: this.endpointIndex,
907
- message: `querying parameter #${param.parameter} value...`,
936
+ message: `querying parameter #${parameter} value...`,
908
937
  direction: "outbound"
909
938
  });
910
- const paramValue = await api.get(param.parameter);
939
+ const paramValue = await api.get(parameter);
940
+ options?.onProgress?.(i + 1, parametersToQuery.length);
911
941
  if (typeof paramValue === "number") {
912
942
  ctx.logNode(node.id, {
913
943
  endpoint: this.endpointIndex,
914
- message: `parameter #${param.parameter} has value: ${paramValue}`,
944
+ message: `parameter #${parameter} has value: ${paramValue}`,
915
945
  direction: "inbound"
916
946
  });
917
947
  } else if (!paramValue) {
918
948
  ctx.logNode(node.id, {
919
949
  endpoint: this.endpointIndex,
920
- message: `received no value for parameter #${param.parameter}`,
950
+ message: `received no value for parameter #${parameter}`,
921
951
  direction: "inbound",
922
952
  level: "warn"
923
953
  });
@@ -932,7 +962,7 @@ alters capabilities: ${!!properties.altersCapabilities}`;
932
962
  }
933
963
  } else {
934
964
  const parameters = (0, import_arrays.distinct)(this.getDefinedValueIDs(ctx).map((v) => v.property).filter((p) => typeof p === "number"));
935
- for (const param of parameters) {
965
+ for (const [i, param] of parameters.entries()) {
936
966
  if (this.getParamInformation(ctx, param).readable !== false) {
937
967
  ctx.logNode(node.id, {
938
968
  endpoint: this.endpointIndex,
@@ -947,6 +977,7 @@ alters capabilities: ${!!properties.altersCapabilities}`;
947
977
  direction: "none"
948
978
  });
949
979
  }
980
+ options?.onProgress?.(i + 1, parameters.length);
950
981
  }
951
982
  }
952
983
  }
@@ -1512,8 +1543,21 @@ let ConfigurationCCBulkReport = (() => {
1512
1543
  getPartialCCSessionId() {
1513
1544
  return {};
1514
1545
  }
1515
- expectMoreMessages() {
1516
- return this.reportsToFollow > 0;
1546
+ getRemainingSegments() {
1547
+ return this.reportsToFollow;
1548
+ }
1549
+ mergePartialCCs(partials, _ctx) {
1550
+ const merged = /* @__PURE__ */ new Map();
1551
+ for (const partial of partials) {
1552
+ for (const [parameter, value] of partial._values) {
1553
+ merged.set(parameter, value);
1554
+ }
1555
+ }
1556
+ for (const [parameter, value] of this._values) {
1557
+ merged.set(parameter, value);
1558
+ }
1559
+ this._values = merged;
1560
+ return Promise.resolve();
1517
1561
  }
1518
1562
  toLogEntry(ctx) {
1519
1563
  const message = {
@@ -1662,8 +1706,8 @@ let ConfigurationCCNameReport = (() => {
1662
1706
  getPartialCCSessionId() {
1663
1707
  return { parameter: this.parameter };
1664
1708
  }
1665
- expectMoreMessages() {
1666
- return this.reportsToFollow > 0;
1709
+ getRemainingSegments() {
1710
+ return this.reportsToFollow;
1667
1711
  }
1668
1712
  mergePartialCCs(partials, _ctx) {
1669
1713
  this.name = [...partials, this].map((report) => report.name).reduce((prev, cur) => prev + cur, "");
@@ -1808,8 +1852,8 @@ let ConfigurationCCInfoReport = (() => {
1808
1852
  getPartialCCSessionId() {
1809
1853
  return { parameter: this.parameter };
1810
1854
  }
1811
- expectMoreMessages() {
1812
- return this.reportsToFollow > 0;
1855
+ getRemainingSegments() {
1856
+ return this.reportsToFollow;
1813
1857
  }
1814
1858
  mergePartialCCs(partials, _ctx) {
1815
1859
  this.info = [...partials, this].map((report) => report.info).reduce((prev, cur) => prev + cur, "");
@@ -2236,6 +2280,8 @@ __name(serializeValue, "serializeValue");
2236
2280
  ConfigurationCCReport,
2237
2281
  ConfigurationCCSet,
2238
2282
  ConfigurationCCValues,
2283
+ getDistinctConfigParameters,
2284
+ getReadableConfigParameters,
2239
2285
  refreshConfigParamMetadataFromConfigFile
2240
2286
  });
2241
2287
  //# sourceMappingURL=ConfigurationCC.js.map