@zwave-js/cc 15.18.0 → 15.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/cc/AssociationGroupInfoCC.js +1 -1
- package/build/cjs/cc/AssociationGroupInfoCC.js.map +2 -2
- package/build/cjs/cc/BatteryCC.js +2 -2
- package/build/cjs/cc/BatteryCC.js.map +2 -2
- package/build/cjs/cc/BinarySwitchCC.js +2 -2
- package/build/cjs/cc/BinarySwitchCC.js.map +2 -2
- package/build/cjs/cc/ClimateControlScheduleCC.js +1 -1
- package/build/cjs/cc/ClimateControlScheduleCC.js.map +2 -2
- package/build/cjs/cc/ColorSwitchCC.js +2 -2
- package/build/cjs/cc/ColorSwitchCC.js.map +2 -2
- package/build/cjs/cc/ConfigurationCC.js +3 -2
- package/build/cjs/cc/ConfigurationCC.js.map +2 -2
- package/build/cjs/cc/EnergyProductionCC.js +1 -1
- package/build/cjs/cc/EnergyProductionCC.js.map +2 -2
- package/build/cjs/cc/HumidityControlSetpointCC.js +1 -1
- package/build/cjs/cc/HumidityControlSetpointCC.js.map +2 -2
- package/build/cjs/cc/IndicatorCC.js +3 -3
- package/build/cjs/cc/IndicatorCC.js.map +2 -2
- package/build/cjs/cc/IrrigationCC.js +6 -6
- package/build/cjs/cc/IrrigationCC.js.map +2 -2
- package/build/cjs/cc/ManufacturerProprietaryCC.js +2 -2
- package/build/cjs/cc/ManufacturerProprietaryCC.js.map +2 -2
- package/build/cjs/cc/MeterCC.js +6 -6
- package/build/cjs/cc/MeterCC.js.map +2 -2
- package/build/cjs/cc/MultiChannelAssociationCC.js +4 -4
- package/build/cjs/cc/MultiChannelAssociationCC.js.map +2 -2
- package/build/cjs/cc/MultiChannelCC.js +6 -6
- package/build/cjs/cc/MultiChannelCC.js.map +2 -2
- package/build/cjs/cc/MultilevelSensorCC.js +2 -2
- package/build/cjs/cc/MultilevelSensorCC.js.map +2 -2
- package/build/cjs/cc/NotificationCC.js +3 -3
- package/build/cjs/cc/NotificationCC.js.map +2 -2
- package/build/cjs/cc/ScheduleEntryLockCC.js +4 -4
- package/build/cjs/cc/ScheduleEntryLockCC.js.map +2 -2
- package/build/cjs/cc/Security2CC.js +7 -7
- package/build/cjs/cc/Security2CC.js.map +2 -2
- package/build/cjs/cc/SecurityCC.js +5 -5
- package/build/cjs/cc/SecurityCC.js.map +2 -2
- package/build/cjs/cc/SoundSwitchCC.d.ts +11 -1
- package/build/cjs/cc/SoundSwitchCC.js +34 -5
- package/build/cjs/cc/SoundSwitchCC.js.map +2 -2
- package/build/cjs/cc/SupervisionCC.js +5 -5
- package/build/cjs/cc/SupervisionCC.js.map +2 -2
- package/build/cjs/cc/ThermostatModeCC.js +2 -2
- package/build/cjs/cc/ThermostatModeCC.js.map +2 -2
- package/build/cjs/cc/ThermostatSetpointCC.js +3 -3
- package/build/cjs/cc/ThermostatSetpointCC.js.map +2 -2
- package/build/cjs/cc/TimeCC.js +4 -4
- package/build/cjs/cc/TimeCC.js.map +2 -2
- package/build/cjs/cc/TransportServiceCC.js +2 -2
- package/build/cjs/cc/TransportServiceCC.js.map +2 -2
- package/build/cjs/cc/UserCodeCC.js +54 -39
- package/build/cjs/cc/UserCodeCC.js.map +2 -2
- package/build/cjs/cc/WindowCoveringCC.js +1 -1
- package/build/cjs/cc/WindowCoveringCC.js.map +2 -2
- package/build/cjs/cc/ZWaveProtocolCC.js +8 -8
- package/build/cjs/cc/ZWaveProtocolCC.js.map +2 -2
- package/build/cjs/cc/index.js.map +2 -2
- package/build/cjs/cc/manufacturerProprietary/FibaroCC.js +1 -1
- package/build/cjs/cc/manufacturerProprietary/FibaroCC.js.map +2 -2
- package/build/cjs/lib/API.d.ts +2 -2
- package/build/cjs/lib/API.js.map +2 -2
- package/build/cjs/lib/CommandClass.js +2 -2
- package/build/cjs/lib/CommandClass.js.map +2 -2
- package/build/cjs/lib/Security2/Extension.js +2 -2
- package/build/cjs/lib/Security2/Extension.js.map +2 -2
- package/build/cjs/lib/Values.js.map +1 -1
- package/build/cjs/lib/traits.d.ts +9 -0
- package/build/cjs/lib/utils.d.ts +7 -1
- package/build/cjs/lib/utils.js +21 -17
- package/build/cjs/lib/utils.js.map +2 -2
- package/build/esm/cc/AssociationGroupInfoCC.js +1 -1
- package/build/esm/cc/AssociationGroupInfoCC.js.map +1 -1
- package/build/esm/cc/BatteryCC.js +2 -2
- package/build/esm/cc/BatteryCC.js.map +1 -1
- package/build/esm/cc/BinarySwitchCC.js +2 -2
- package/build/esm/cc/BinarySwitchCC.js.map +1 -1
- package/build/esm/cc/ClimateControlScheduleCC.js +1 -1
- package/build/esm/cc/ClimateControlScheduleCC.js.map +1 -1
- package/build/esm/cc/ColorSwitchCC.js +2 -2
- package/build/esm/cc/ColorSwitchCC.js.map +1 -1
- package/build/esm/cc/ConfigurationCC.d.ts.map +1 -1
- package/build/esm/cc/ConfigurationCC.js +3 -2
- package/build/esm/cc/ConfigurationCC.js.map +1 -1
- package/build/esm/cc/EnergyProductionCC.js +1 -1
- package/build/esm/cc/EnergyProductionCC.js.map +1 -1
- package/build/esm/cc/HumidityControlSetpointCC.js +1 -1
- package/build/esm/cc/HumidityControlSetpointCC.js.map +1 -1
- package/build/esm/cc/IndicatorCC.js +3 -3
- package/build/esm/cc/IndicatorCC.js.map +1 -1
- package/build/esm/cc/IrrigationCC.js +6 -6
- package/build/esm/cc/IrrigationCC.js.map +1 -1
- package/build/esm/cc/ManufacturerProprietaryCC.js +2 -2
- package/build/esm/cc/ManufacturerProprietaryCC.js.map +1 -1
- package/build/esm/cc/MeterCC.js +6 -6
- package/build/esm/cc/MeterCC.js.map +1 -1
- package/build/esm/cc/MultiChannelAssociationCC.js +4 -4
- package/build/esm/cc/MultiChannelAssociationCC.js.map +1 -1
- package/build/esm/cc/MultiChannelCC.js +6 -6
- package/build/esm/cc/MultiChannelCC.js.map +1 -1
- package/build/esm/cc/MultilevelSensorCC.js +2 -2
- package/build/esm/cc/MultilevelSensorCC.js.map +1 -1
- package/build/esm/cc/NotificationCC.js +3 -3
- package/build/esm/cc/NotificationCC.js.map +1 -1
- package/build/esm/cc/ScheduleEntryLockCC.js +4 -4
- package/build/esm/cc/ScheduleEntryLockCC.js.map +1 -1
- package/build/esm/cc/Security2CC.js +7 -7
- package/build/esm/cc/Security2CC.js.map +1 -1
- package/build/esm/cc/SecurityCC.js +5 -5
- package/build/esm/cc/SecurityCC.js.map +1 -1
- package/build/esm/cc/SoundSwitchCC.d.ts +11 -1
- package/build/esm/cc/SoundSwitchCC.d.ts.map +1 -1
- package/build/esm/cc/SoundSwitchCC.js +34 -5
- package/build/esm/cc/SoundSwitchCC.js.map +1 -1
- package/build/esm/cc/SupervisionCC.js +5 -5
- package/build/esm/cc/SupervisionCC.js.map +1 -1
- package/build/esm/cc/ThermostatModeCC.js +2 -2
- package/build/esm/cc/ThermostatModeCC.js.map +1 -1
- package/build/esm/cc/ThermostatSetpointCC.js +3 -3
- package/build/esm/cc/ThermostatSetpointCC.js.map +1 -1
- package/build/esm/cc/TimeCC.js +4 -4
- package/build/esm/cc/TimeCC.js.map +1 -1
- package/build/esm/cc/TransportServiceCC.js +2 -2
- package/build/esm/cc/TransportServiceCC.js.map +1 -1
- package/build/esm/cc/UserCodeCC.d.ts.map +1 -1
- package/build/esm/cc/UserCodeCC.js +80 -43
- package/build/esm/cc/UserCodeCC.js.map +1 -1
- package/build/esm/cc/WindowCoveringCC.js +1 -1
- package/build/esm/cc/WindowCoveringCC.js.map +1 -1
- package/build/esm/cc/ZWaveProtocolCC.js +8 -8
- package/build/esm/cc/ZWaveProtocolCC.js.map +1 -1
- package/build/esm/cc/index.d.ts.map +1 -1
- package/build/esm/cc/index.js +0 -1
- package/build/esm/cc/index.js.map +1 -1
- package/build/esm/cc/manufacturerProprietary/FibaroCC.js +1 -1
- package/build/esm/cc/manufacturerProprietary/FibaroCC.js.map +1 -1
- package/build/esm/lib/API.d.ts +2 -2
- package/build/esm/lib/API.d.ts.map +1 -1
- package/build/esm/lib/API.js.map +1 -1
- package/build/esm/lib/CommandClass.js +2 -2
- package/build/esm/lib/CommandClass.js.map +1 -1
- package/build/esm/lib/Security2/Extension.js +2 -2
- package/build/esm/lib/Security2/Extension.js.map +1 -1
- package/build/esm/lib/Values.js +1 -1
- package/build/esm/lib/Values.js.map +1 -1
- package/build/esm/lib/traits.d.ts +9 -0
- package/build/esm/lib/traits.d.ts.map +1 -1
- package/build/esm/lib/utils.d.ts +7 -1
- package/build/esm/lib/utils.d.ts.map +1 -1
- package/build/esm/lib/utils.js +25 -21
- package/build/esm/lib/utils.js.map +1 -1
- package/package.json +8 -8
|
@@ -390,7 +390,7 @@ let AssociationGroupInfoCCNameReport = (() => {
|
|
|
390
390
|
}
|
|
391
391
|
serialize(ctx) {
|
|
392
392
|
this.payload = import_shared.Bytes.concat([
|
|
393
|
-
|
|
393
|
+
[this.groupId, this.name.length],
|
|
394
394
|
import_shared.Bytes.from(this.name, "utf8")
|
|
395
395
|
]);
|
|
396
396
|
return super.serialize(ctx);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cc/AssociationGroupInfoCC.ts"],
|
|
4
|
-
"sourcesContent": ["import type { CCEncodingContext, CCParsingContext } from \"@zwave-js/cc\";\nimport {\n\tCommandClasses,\n\ttype EndpointId,\n\ttype GetValueDB,\n\ttype MaybeNotKnown,\n\ttype MessageOrCCLogEntry,\n\tMessagePriority,\n\ttype MessageRecord,\n\ttype SupportsCC,\n\ttype WithAddress,\n\tencodeCCId,\n\tgetCCName,\n\tparseCCId,\n\tvalidatePayload,\n} from \"@zwave-js/core\";\nimport { Bytes, cpp2js, getEnumMemberName, num2hex } from \"@zwave-js/shared\";\nimport { validateArgs } from \"@zwave-js/transformers\";\nimport { CCAPI, PhysicalCCAPI } from \"../lib/API.js\";\nimport {\n\ttype CCRaw,\n\tCommandClass,\n\ttype InterviewContext,\n\ttype PersistValuesContext,\n\ttype RefreshValuesContext,\n} from \"../lib/CommandClass.js\";\nimport {\n\tAPI,\n\tCCCommand,\n\tccValueProperty,\n\tccValues,\n\tcommandClass,\n\texpectedCCResponse,\n\timplementedVersion,\n} from \"../lib/CommandClassDecorators.js\";\nimport { V } from \"../lib/Values.js\";\nimport {\n\tAssociationGroupInfoCommand,\n\tAssociationGroupInfoProfile,\n} from \"../lib/_Types.js\";\nimport { AssociationCC } from \"./AssociationCC.js\";\nimport { MultiChannelAssociationCC } from \"./MultiChannelAssociationCC.js\";\n\nexport const AssociationGroupInfoCCValues = V.defineCCValues(\n\tCommandClasses[\"Association Group Information\"],\n\t{\n\t\t...V.staticProperty(\"hasDynamicInfo\", undefined, { internal: true }),\n\t\t...V.dynamicPropertyAndKeyWithName(\n\t\t\t\"groupName\",\n\t\t\t\"name\",\n\t\t\t(groupId: number) => groupId,\n\t\t\t({ property, propertyKey }) =>\n\t\t\t\tproperty === \"name\" && typeof propertyKey === \"number\",\n\t\t\tundefined,\n\t\t\t{ internal: true },\n\t\t),\n\t\t...V.dynamicPropertyAndKeyWithName(\n\t\t\t\"groupInfo\",\n\t\t\t\"info\",\n\t\t\t(groupId: number) => groupId,\n\t\t\t({ property, propertyKey }) =>\n\t\t\t\tproperty === \"info\" && typeof propertyKey === \"number\",\n\t\t\tundefined,\n\t\t\t{ internal: true },\n\t\t),\n\t\t...V.dynamicPropertyAndKeyWithName(\n\t\t\t\"commands\",\n\t\t\t\"issuedCommands\",\n\t\t\t(groupId: number) => groupId,\n\t\t\t({ property, propertyKey }) =>\n\t\t\t\tproperty === \"issuedCommands\"\n\t\t\t\t&& typeof propertyKey === \"number\",\n\t\t\tundefined,\n\t\t\t{ internal: true },\n\t\t),\n\t},\n);\n\n// @noSetValueAPI This CC only has get-type commands\n\n@API(CommandClasses[\"Association Group Information\"])\nexport class AssociationGroupInfoCCAPI extends PhysicalCCAPI {\n\tpublic supportsCommand(\n\t\tcmd: AssociationGroupInfoCommand,\n\t): MaybeNotKnown<boolean> {\n\t\tswitch (cmd) {\n\t\t\tcase AssociationGroupInfoCommand.NameGet:\n\t\t\tcase AssociationGroupInfoCommand.NameReport:\n\t\t\tcase AssociationGroupInfoCommand.InfoGet:\n\t\t\tcase AssociationGroupInfoCommand.InfoReport:\n\t\t\tcase AssociationGroupInfoCommand.CommandListGet:\n\t\t\tcase AssociationGroupInfoCommand.CommandListReport:\n\t\t\t\treturn true; // This is mandatory\n\t\t}\n\t\treturn super.supportsCommand(cmd);\n\t}\n\n\t@validateArgs()\n\tpublic async getGroupName(groupId: number): Promise<MaybeNotKnown<string>> {\n\t\tthis.assertSupportsCommand(\n\t\t\tAssociationGroupInfoCommand,\n\t\t\tAssociationGroupInfoCommand.NameGet,\n\t\t);\n\n\t\tconst cc = new AssociationGroupInfoCCNameGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tgroupId,\n\t\t});\n\t\tconst response = await this.host.sendCommand<\n\t\t\tAssociationGroupInfoCCNameReport\n\t\t>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\tif (response) return response.name;\n\t}\n\n\t@validateArgs()\n\tpublic async reportGroupName(groupId: number, name: string): Promise<void> {\n\t\tthis.assertSupportsCommand(\n\t\t\tAssociationGroupInfoCommand,\n\t\t\tAssociationGroupInfoCommand.NameReport,\n\t\t);\n\n\t\tconst cc = new AssociationGroupInfoCCNameReport({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tgroupId,\n\t\t\tname,\n\t\t});\n\n\t\tawait this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\t@validateArgs()\n\t// oxlint-disable-next-line typescript/explicit-module-boundary-types\n\tpublic async getGroupInfo(groupId: number, refreshCache: boolean = false) {\n\t\tthis.assertSupportsCommand(\n\t\t\tAssociationGroupInfoCommand,\n\t\t\tAssociationGroupInfoCommand.InfoGet,\n\t\t);\n\n\t\tconst cc = new AssociationGroupInfoCCInfoGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tgroupId,\n\t\t\trefreshCache,\n\t\t});\n\t\tconst response = await this.host.sendCommand<\n\t\t\tAssociationGroupInfoCCInfoReport\n\t\t>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\t// SDS13782 says: If List Mode is set to 0, the Group Count field MUST be set to 1.\n\t\t// But that's not always the case. Apparently some endpoints return 0 groups\n\t\t// although they support AGI CC\n\t\tif (response && response.groups.length > 0) {\n\t\t\tconst { groupId: _, ...info } = response.groups[0];\n\t\t\treturn {\n\t\t\t\thasDynamicInfo: response.hasDynamicInfo,\n\t\t\t\t...info,\n\t\t\t};\n\t\t}\n\t}\n\n\t@validateArgs()\n\tpublic async reportGroupInfo(\n\t\toptions: AssociationGroupInfoCCInfoReportOptions,\n\t): Promise<void> {\n\t\tthis.assertSupportsCommand(\n\t\t\tAssociationGroupInfoCommand,\n\t\t\tAssociationGroupInfoCommand.InfoReport,\n\t\t);\n\n\t\tconst cc = new AssociationGroupInfoCCInfoReport({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\t...options,\n\t\t});\n\n\t\tawait this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\t@validateArgs()\n\tpublic async getCommands(\n\t\tgroupId: number,\n\t\tallowCache: boolean = true,\n\t): Promise<\n\t\tMaybeNotKnown<AssociationGroupInfoCCCommandListReport[\"commands\"]>\n\t> {\n\t\tthis.assertSupportsCommand(\n\t\t\tAssociationGroupInfoCommand,\n\t\t\tAssociationGroupInfoCommand.CommandListGet,\n\t\t);\n\n\t\tconst cc = new AssociationGroupInfoCCCommandListGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tgroupId,\n\t\t\tallowCache,\n\t\t});\n\t\tconst response = await this.host.sendCommand<\n\t\t\tAssociationGroupInfoCCCommandListReport\n\t\t>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\tif (response) return response.commands;\n\t}\n\n\t@validateArgs()\n\tpublic async reportCommands(\n\t\tgroupId: number,\n\t\tcommands: ReadonlyMap<CommandClasses, readonly number[]>,\n\t): Promise<void> {\n\t\tthis.assertSupportsCommand(\n\t\t\tAssociationGroupInfoCommand,\n\t\t\tAssociationGroupInfoCommand.CommandListReport,\n\t\t);\n\n\t\tconst cc = new AssociationGroupInfoCCCommandListReport({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tgroupId,\n\t\t\tcommands,\n\t\t});\n\n\t\tawait this.host.sendCommand(cc, this.commandOptions);\n\t}\n}\n\n@commandClass(CommandClasses[\"Association Group Information\"])\n@implementedVersion(3)\n@ccValues(AssociationGroupInfoCCValues)\nexport class AssociationGroupInfoCC extends CommandClass {\n\tdeclare ccCommand: AssociationGroupInfoCommand;\n\n\tpublic determineRequiredCCInterviews(): readonly CommandClasses[] {\n\t\t// AssociationCC must be interviewed after Z-Wave+ if that is supported\n\t\treturn [\n\t\t\t...super.determineRequiredCCInterviews(),\n\t\t\tCommandClasses.Association,\n\t\t\tCommandClasses[\"Multi Channel Association\"],\n\t\t];\n\t}\n\n\t/** Returns the name of an association group */\n\tpublic static getGroupNameCached(\n\t\tctx: GetValueDB,\n\t\tendpoint: EndpointId,\n\t\tgroupId: number,\n\t): MaybeNotKnown<string> {\n\t\treturn ctx\n\t\t\t.getValueDB(endpoint.nodeId)\n\t\t\t.getValue(\n\t\t\t\tAssociationGroupInfoCCValues.groupName(groupId).endpoint(\n\t\t\t\t\tendpoint.index,\n\t\t\t\t),\n\t\t\t);\n\t}\n\n\t/** Returns the association profile for an association group */\n\tpublic static getGroupProfileCached(\n\t\tctx: GetValueDB,\n\t\tendpoint: EndpointId,\n\t\tgroupId: number,\n\t): MaybeNotKnown<AssociationGroupInfoProfile> {\n\t\treturn ctx.getValueDB(endpoint.nodeId).getValue<{\n\t\t\tprofile: AssociationGroupInfoProfile;\n\t\t}>(\n\t\t\tAssociationGroupInfoCCValues.groupInfo(groupId).endpoint(\n\t\t\t\tendpoint.index,\n\t\t\t),\n\t\t)\n\t\t\t?.profile;\n\t}\n\n\t/** Returns the dictionary of all commands issued by the given association group */\n\tpublic static getIssuedCommandsCached(\n\t\tctx: GetValueDB,\n\t\tendpoint: EndpointId,\n\t\tgroupId: number,\n\t): MaybeNotKnown<ReadonlyMap<CommandClasses, readonly number[]>> {\n\t\treturn ctx\n\t\t\t.getValueDB(endpoint.nodeId)\n\t\t\t.getValue(\n\t\t\t\tAssociationGroupInfoCCValues.commands(groupId).endpoint(\n\t\t\t\t\tendpoint.index,\n\t\t\t\t),\n\t\t\t);\n\t}\n\n\tpublic static findGroupsForIssuedCommand(\n\t\tctx: GetValueDB,\n\t\tendpoint: EndpointId & SupportsCC,\n\t\tccId: CommandClasses,\n\t\tcommand: number,\n\t): number[] {\n\t\tconst ret: number[] = [];\n\t\tconst associationGroupCount = this.getAssociationGroupCountCached(\n\t\t\tctx,\n\t\t\tendpoint,\n\t\t);\n\t\tfor (let groupId = 1; groupId <= associationGroupCount; groupId++) {\n\t\t\t// Scan the issued commands of all groups if there's a match\n\t\t\tconst issuedCommands = this.getIssuedCommandsCached(\n\t\t\t\tctx,\n\t\t\t\tendpoint,\n\t\t\t\tgroupId,\n\t\t\t);\n\t\t\tif (!issuedCommands) continue;\n\t\t\tif (\n\t\t\t\tissuedCommands.has(ccId)\n\t\t\t\t&& issuedCommands.get(ccId)!.includes(command)\n\t\t\t) {\n\t\t\t\tret.push(groupId);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\treturn ret;\n\t}\n\n\tprivate static getAssociationGroupCountCached(\n\t\tctx: GetValueDB,\n\t\tendpoint: EndpointId & SupportsCC,\n\t): number {\n\t\t// The association group count is either determined by the\n\t\t// Association CC or the Multi Channel Association CC\n\n\t\treturn (\n\t\t\t// First query the Multi Channel Association CC\n\t\t\t// And fall back to 0\n\t\t\t(endpoint.supportsCC(\n\t\t\t\tCommandClasses[\"Multi Channel Association\"],\n\t\t\t)\n\t\t\t\t&& MultiChannelAssociationCC.getGroupCountCached(\n\t\t\t\t\tctx,\n\t\t\t\t\tendpoint,\n\t\t\t\t))\n\t\t\t// Then the Association CC\n\t\t\t|| (endpoint.supportsCC(CommandClasses.Association)\n\t\t\t\t&& AssociationCC.getGroupCountCached(ctx, endpoint))\n\t\t\t|| 0\n\t\t);\n\t}\n\n\tpublic async interview(\n\t\tctx: InterviewContext,\n\t): Promise<void> {\n\t\tconst node = this.getNode(ctx)!;\n\t\tconst endpoint = this.getEndpoint(ctx)!;\n\t\tconst api = CCAPI.create(\n\t\t\tCommandClasses[\"Association Group Information\"],\n\t\t\tctx,\n\t\t\tendpoint,\n\t\t).withOptions({ priority: MessagePriority.NodeQuery });\n\n\t\tctx.logNode(node.id, {\n\t\t\tendpoint: this.endpointIndex,\n\t\t\tmessage: `Interviewing ${this.ccName}...`,\n\t\t\tdirection: \"none\",\n\t\t});\n\n\t\tconst associationGroupCount = AssociationGroupInfoCC\n\t\t\t.getAssociationGroupCountCached(\n\t\t\t\tctx,\n\t\t\t\tendpoint,\n\t\t\t);\n\n\t\tfor (let groupId = 1; groupId <= associationGroupCount; groupId++) {\n\t\t\t// First get the group's name\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\tmessage: `Association group #${groupId}: Querying name...`,\n\t\t\t\tdirection: \"outbound\",\n\t\t\t});\n\t\t\tconst name = await api.getGroupName(groupId);\n\t\t\tif (name) {\n\t\t\t\tconst logMessage =\n\t\t\t\t\t`Association group #${groupId} has name \"${name}\"`;\n\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\t\tmessage: logMessage,\n\t\t\t\t\tdirection: \"inbound\",\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// Then the command list\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\tmessage:\n\t\t\t\t\t`Association group #${groupId}: Querying command list...`,\n\t\t\t\tdirection: \"outbound\",\n\t\t\t});\n\t\t\tawait api.getCommands(groupId);\n\t\t\t// Not sure how to log this\n\t\t}\n\n\t\t// Finally query each group for its information\n\t\tawait this.refreshValues(ctx);\n\n\t\t// Remember that the interview is complete\n\t\tthis.setInterviewComplete(ctx, true);\n\t}\n\n\tpublic async refreshValues(\n\t\tctx: RefreshValuesContext,\n\t): Promise<void> {\n\t\tconst node = this.getNode(ctx)!;\n\t\tconst endpoint = this.getEndpoint(ctx)!;\n\t\tconst api = CCAPI.create(\n\t\t\tCommandClasses[\"Association Group Information\"],\n\t\t\tctx,\n\t\t\tendpoint,\n\t\t).withOptions({ priority: MessagePriority.NodeQuery });\n\n\t\t// Query the information for each group (this is the only thing that could be dynamic)\n\t\tconst associationGroupCount = AssociationGroupInfoCC\n\t\t\t.getAssociationGroupCountCached(\n\t\t\t\tctx,\n\t\t\t\tendpoint,\n\t\t\t);\n\t\tconst hasDynamicInfo = this.getValue<boolean>(\n\t\t\tctx,\n\t\t\tAssociationGroupInfoCCValues.hasDynamicInfo,\n\t\t);\n\n\t\tfor (let groupId = 1; groupId <= associationGroupCount; groupId++) {\n\t\t\t// Then its information\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\tmessage: `Association group #${groupId}: Querying info...`,\n\t\t\t\tdirection: \"outbound\",\n\t\t\t});\n\t\t\tconst info = await api.getGroupInfo(groupId, !!hasDynamicInfo);\n\t\t\tif (info) {\n\t\t\t\tconst logMessage =\n\t\t\t\t\t`Received info for association group #${groupId}:\ninfo is dynamic: ${info.hasDynamicInfo}\nprofile: ${\n\t\t\t\t\t\tgetEnumMemberName(\n\t\t\t\t\t\t\tAssociationGroupInfoProfile,\n\t\t\t\t\t\t\tinfo.profile,\n\t\t\t\t\t\t)\n\t\t\t\t\t}`;\n\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\t\tmessage: logMessage,\n\t\t\t\t\tdirection: \"inbound\",\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n}\n\n// @publicAPI\nexport interface AssociationGroupInfoCCNameReportOptions {\n\tgroupId: number;\n\tname: string;\n}\n\n@CCCommand(AssociationGroupInfoCommand.NameReport)\nexport class AssociationGroupInfoCCNameReport extends AssociationGroupInfoCC {\n\tpublic constructor(\n\t\toptions: WithAddress<AssociationGroupInfoCCNameReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\tthis.groupId = options.groupId;\n\t\tthis.name = options.name;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): AssociationGroupInfoCCNameReport {\n\t\tvalidatePayload(raw.payload.length >= 2);\n\t\tconst groupId = raw.payload[0];\n\t\tconst nameLength = raw.payload[1];\n\t\tvalidatePayload(raw.payload.length >= 2 + nameLength);\n\t\t// The specs don't allow 0-terminated string, but some devices use them\n\t\t// So we need to cut them off\n\t\tconst name = cpp2js(\n\t\t\traw.payload.subarray(2, 2 + nameLength).toString(\"utf8\"),\n\t\t);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tgroupId,\n\t\t\tname,\n\t\t});\n\t}\n\n\tpublic readonly groupId: number;\n\tpublic readonly name: string;\n\n\tpublic persistValues(ctx: PersistValuesContext): boolean {\n\t\tif (!super.persistValues(ctx)) return false;\n\t\tconst valueDB = this.getValueDB(ctx);\n\n\t\tvalueDB.setValue(\n\t\t\tAssociationGroupInfoCCValues.groupName(this.groupId).endpoint(\n\t\t\t\tthis.endpointIndex,\n\t\t\t),\n\t\t\tthis.name,\n\t\t);\n\n\t\treturn true;\n\t}\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.concat([\n\t\t\tBytes.from([this.groupId, this.name.length]),\n\t\t\tBytes.from(this.name, \"utf8\"),\n\t\t]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: {\n\t\t\t\t\"group id\": this.groupId,\n\t\t\t\tname: this.name,\n\t\t\t},\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport interface AssociationGroupInfoCCNameGetOptions {\n\tgroupId: number;\n}\n\n@CCCommand(AssociationGroupInfoCommand.NameGet)\n@expectedCCResponse(AssociationGroupInfoCCNameReport)\nexport class AssociationGroupInfoCCNameGet extends AssociationGroupInfoCC {\n\tpublic constructor(\n\t\toptions: WithAddress<AssociationGroupInfoCCNameGetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.groupId = options.groupId;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): AssociationGroupInfoCCNameGet {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst groupId = raw.payload[0];\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tgroupId,\n\t\t});\n\t}\n\n\tpublic groupId: number;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.from([this.groupId]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: { \"group id\": this.groupId },\n\t\t};\n\t}\n}\n\nexport interface AssociationGroupInfo {\n\tgroupId: number;\n\tmode: number;\n\tprofile: number;\n\teventCode: number;\n}\n\n// @publicAPI\nexport interface AssociationGroupInfoCCInfoReportOptions {\n\tisListMode: boolean;\n\thasDynamicInfo: boolean;\n\tgroups: AssociationGroupInfo[];\n}\n\n@CCCommand(AssociationGroupInfoCommand.InfoReport)\n@ccValueProperty(\"hasDynamicInfo\", AssociationGroupInfoCCValues.hasDynamicInfo)\nexport class AssociationGroupInfoCCInfoReport extends AssociationGroupInfoCC {\n\tpublic constructor(\n\t\toptions: WithAddress<AssociationGroupInfoCCInfoReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\tthis.isListMode = options.isListMode;\n\t\tthis.hasDynamicInfo = options.hasDynamicInfo;\n\t\tthis.groups = options.groups;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): AssociationGroupInfoCCInfoReport {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst isListMode = !!(raw.payload[0] & 0b1000_0000);\n\t\tconst hasDynamicInfo = !!(raw.payload[0] & 0b0100_0000);\n\t\tconst groupCount = raw.payload[0] & 0b0011_1111;\n\t\t// each group requires 7 bytes of payload\n\t\tvalidatePayload(raw.payload.length >= 1 + groupCount * 7);\n\t\tconst groups: AssociationGroupInfo[] = [];\n\t\tfor (let i = 0; i < groupCount; i++) {\n\t\t\tconst offset = 1 + i * 7;\n\t\t\t// Parse the payload\n\t\t\tconst groupBytes = raw.payload.subarray(offset, offset + 7);\n\t\t\tconst groupId = groupBytes[0];\n\t\t\tconst mode = 0; // groupBytes[1];\n\t\t\tconst profile = groupBytes.readUInt16BE(2);\n\t\t\tconst eventCode = 0; // groupBytes.readUInt16BE(5);\n\t\t\tgroups.push({ groupId, mode, profile, eventCode });\n\t\t}\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tisListMode,\n\t\t\thasDynamicInfo,\n\t\t\tgroups,\n\t\t});\n\t}\n\n\tpublic readonly isListMode: boolean;\n\n\tpublic readonly hasDynamicInfo: boolean;\n\n\tpublic readonly groups: readonly AssociationGroupInfo[];\n\n\tpublic persistValues(ctx: PersistValuesContext): boolean {\n\t\tif (!super.persistValues(ctx)) return false;\n\n\t\tfor (const group of this.groups) {\n\t\t\tconst { groupId, mode, profile, eventCode } = group;\n\t\t\tthis.setValue(\n\t\t\t\tctx,\n\t\t\t\tAssociationGroupInfoCCValues.groupInfo(groupId),\n\t\t\t\t{\n\t\t\t\t\tmode,\n\t\t\t\t\tprofile,\n\t\t\t\t\teventCode,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t\treturn true;\n\t}\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.alloc(1 + this.groups.length * 7, 0);\n\n\t\tthis.payload[0] = (this.isListMode ? 0b1000_0000 : 0)\n\t\t\t| (this.hasDynamicInfo ? 0b0100_0000 : 0)\n\t\t\t| (this.groups.length & 0b0011_1111);\n\n\t\tfor (let i = 0; i < this.groups.length; i++) {\n\t\t\tconst offset = 1 + i * 7;\n\t\t\tthis.payload[offset] = this.groups[i].groupId;\n\t\t\tthis.payload.writeUInt16BE(this.groups[i].profile, offset + 2);\n\t\t\t// The remaining bytes are zero\n\t\t}\n\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: {\n\t\t\t\t\"is list mode\": this.isListMode,\n\t\t\t\t\"has dynamic info\": this.hasDynamicInfo,\n\t\t\t\tgroups: this.groups\n\t\t\t\t\t.map(\n\t\t\t\t\t\t(g) => `\n\u00B7 Group #${g.groupId}\n mode: ${g.mode}\n profile: ${g.profile}\n event code: ${g.eventCode}`,\n\t\t\t\t\t)\n\t\t\t\t\t.join(\"\"),\n\t\t\t},\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport type AssociationGroupInfoCCInfoGetOptions =\n\t& {\n\t\trefreshCache: boolean;\n\t}\n\t& (\n\t\t| {\n\t\t\tlistMode: boolean;\n\t\t}\n\t\t| {\n\t\t\tgroupId: number;\n\t\t}\n\t);\n\n@CCCommand(AssociationGroupInfoCommand.InfoGet)\n@expectedCCResponse(AssociationGroupInfoCCInfoReport)\nexport class AssociationGroupInfoCCInfoGet extends AssociationGroupInfoCC {\n\tpublic constructor(\n\t\toptions: WithAddress<AssociationGroupInfoCCInfoGetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.refreshCache = options.refreshCache;\n\t\tif (\"listMode\" in options) this.listMode = options.listMode;\n\t\tif (\"groupId\" in options) this.groupId = options.groupId;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): AssociationGroupInfoCCInfoGet {\n\t\tvalidatePayload(raw.payload.length >= 2);\n\t\tconst optionByte = raw.payload[0];\n\t\tconst refreshCache = !!(optionByte & 0b1000_0000);\n\t\tconst listMode: boolean | undefined = !!(optionByte & 0b0100_0000);\n\t\tlet groupId: number | undefined;\n\n\t\tif (!listMode) {\n\t\t\tgroupId = raw.payload[1];\n\t\t}\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\trefreshCache,\n\t\t\tlistMode,\n\t\t\tgroupId,\n\t\t});\n\t}\n\n\tpublic refreshCache: boolean;\n\tpublic listMode?: boolean;\n\tpublic groupId?: number;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tconst isListMode = this.listMode === true;\n\t\tconst optionByte = (this.refreshCache ? 0b1000_0000 : 0)\n\t\t\t| (isListMode ? 0b0100_0000 : 0);\n\t\tthis.payload = Bytes.from([\n\t\t\toptionByte,\n\t\t\tisListMode ? 0 : this.groupId!,\n\t\t]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\tconst message: MessageRecord = {};\n\t\tif (this.groupId != undefined) {\n\t\t\tmessage[\"group id\"] = this.groupId;\n\t\t}\n\t\tif (this.listMode != undefined) {\n\t\t\tmessage[\"list mode\"] = this.listMode;\n\t\t}\n\t\tmessage[\"refresh cache\"] = this.refreshCache;\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage,\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport interface AssociationGroupInfoCCCommandListReportOptions {\n\tgroupId: number;\n\tcommands: ReadonlyMap<CommandClasses, readonly number[]>;\n}\n\n@CCCommand(AssociationGroupInfoCommand.CommandListReport)\n@ccValueProperty(\n\t\"commands\",\n\tAssociationGroupInfoCCValues.commands,\n\t(self) => [self.groupId],\n)\nexport class AssociationGroupInfoCCCommandListReport\n\textends AssociationGroupInfoCC\n{\n\tpublic constructor(\n\t\toptions: WithAddress<AssociationGroupInfoCCCommandListReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\tthis.groupId = options.groupId;\n\t\tthis.commands = options.commands;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): AssociationGroupInfoCCCommandListReport {\n\t\tvalidatePayload(raw.payload.length >= 2);\n\t\tconst groupId = raw.payload[0];\n\t\tconst listLength = raw.payload[1];\n\t\tvalidatePayload(raw.payload.length >= 2 + listLength);\n\t\tconst listBytes = raw.payload.subarray(2, 2 + listLength);\n\t\t// Parse all CC ids and commands\n\t\tlet offset = 0;\n\t\tconst commands = new Map<CommandClasses, number[]>();\n\t\twhile (offset < listLength) {\n\t\t\tconst { ccId, bytesRead } = parseCCId(listBytes, offset);\n\t\t\tconst command = listBytes[offset + bytesRead];\n\t\t\tif (!commands.has(ccId)) commands.set(ccId, []);\n\t\t\tcommands.get(ccId)!.push(command);\n\t\t\toffset += bytesRead + 1;\n\t\t}\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tgroupId,\n\t\t\tcommands,\n\t\t});\n\t}\n\n\tpublic readonly groupId: number;\n\n\tpublic readonly commands: ReadonlyMap<CommandClasses, readonly number[]>;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\t// To make it easier to encode possible extended CCs, we first\n\t\t// allocate as much space as we may need, then trim it again\n\t\tthis.payload = new Bytes(2 + this.commands.size * 3);\n\t\tthis.payload[0] = this.groupId;\n\t\tlet offset = 2;\n\t\tfor (const [ccId, commands] of this.commands) {\n\t\t\tfor (const command of commands) {\n\t\t\t\toffset += encodeCCId(ccId, this.payload, offset);\n\t\t\t\tthis.payload[offset] = command;\n\t\t\t\toffset++;\n\t\t\t}\n\t\t}\n\t\tthis.payload[1] = offset - 2; // list length\n\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: {\n\t\t\t\t\"group id\": this.groupId,\n\t\t\t\tcommands: [...this.commands]\n\t\t\t\t\t.map(([cc, cmds]) => {\n\t\t\t\t\t\treturn `\\n\u00B7 ${getCCName(cc)}: ${\n\t\t\t\t\t\t\tcmds\n\t\t\t\t\t\t\t\t.map((cmd) => num2hex(cmd))\n\t\t\t\t\t\t\t\t.join(\", \")\n\t\t\t\t\t\t}`;\n\t\t\t\t\t})\n\t\t\t\t\t.join(\"\"),\n\t\t\t},\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport interface AssociationGroupInfoCCCommandListGetOptions {\n\tallowCache: boolean;\n\tgroupId: number;\n}\n\n@CCCommand(AssociationGroupInfoCommand.CommandListGet)\n@expectedCCResponse(AssociationGroupInfoCCCommandListReport)\nexport class AssociationGroupInfoCCCommandListGet\n\textends AssociationGroupInfoCC\n{\n\tpublic constructor(\n\t\toptions: WithAddress<AssociationGroupInfoCCCommandListGetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.allowCache = options.allowCache;\n\t\tthis.groupId = options.groupId;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): AssociationGroupInfoCCCommandListGet {\n\t\tvalidatePayload(raw.payload.length >= 2);\n\t\tconst allowCache = !!(raw.payload[0] & 0b1000_0000);\n\t\tconst groupId = raw.payload[1];\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tallowCache,\n\t\t\tgroupId,\n\t\t});\n\t}\n\n\tpublic allowCache: boolean;\n\tpublic groupId: number;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.from([\n\t\t\tthis.allowCache ? 0b1000_0000 : 0,\n\t\t\tthis.groupId,\n\t\t]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: {\n\t\t\t\t\"group id\": this.groupId,\n\t\t\t\t\"allow cache\": this.allowCache,\n\t\t\t},\n\t\t};\n\t}\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,kBAcO;AACP,oBAA0D;AAE1D,iBAAqC;AACrC,0BAMO;AACP,oCAQO;AACP,oBAAkB;AAClB,mBAGO;AACP,2BAA8B;AAC9B,uCAA0C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAwC7B,6BAAyB,MAAA;8BADrC,mCAAI,2BAAe,+BAA+B,CAAC,CAAC;;;;oBACN;;;;;;;;iDAAA,YAAa;WAAA;;;;;;;;kCAgB1D,oDAAA,CAAc;qCAqBd,uDAAA,CAAc;kCAiBd,oDAAA,CAAc;qCAgCd,uDAAA,CAAc;iCAkBd,mDAAA,CAAc;oCA2Bd,sDAAA,CAAc;AAlHf,mBAAA,MAAA,MAAA,0BAAA,EAAA,MAAA,UAAA,MAAA,gBAAA,QAAA,OAAA,SAAA,OAAA,QAAA,EAAA,KAAA,gCAAA,kBAAA,KAAA,QAAA,KAAA,gCAAA,IAAa,cAAb,OAAyB,GAAA,UAAA,UAAA,GAAA,MAAA,0BAAA;AAqBzB,mBAAA,MAAA,MAAA,6BAAA,EAAA,MAAA,UAAA,MAAA,mBAAA,QAAA,OAAA,SAAA,OAAA,QAAA,EAAA,KAAA,gCAAA,qBAAA,KAAA,QAAA,KAAA,gCAAA,IAAa,iBAAb,OAA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MAAM,UAAU,GAAG;IAC3B;IAEO,WAAW,KAAgB;AACjC,aAAO;QACN,GAAG,MAAM,WAAW,GAAG;QACvB,SAAS;UACR,YAAY,KAAK;UACjB,eAAe,KAAK;;;IAGvB;;;;",
|
|
4
|
+
"sourcesContent": ["import type { CCEncodingContext, CCParsingContext } from \"@zwave-js/cc\";\nimport {\n\tCommandClasses,\n\ttype EndpointId,\n\ttype GetValueDB,\n\ttype MaybeNotKnown,\n\ttype MessageOrCCLogEntry,\n\tMessagePriority,\n\ttype MessageRecord,\n\ttype SupportsCC,\n\ttype WithAddress,\n\tencodeCCId,\n\tgetCCName,\n\tparseCCId,\n\tvalidatePayload,\n} from \"@zwave-js/core\";\nimport { Bytes, cpp2js, getEnumMemberName, num2hex } from \"@zwave-js/shared\";\nimport { validateArgs } from \"@zwave-js/transformers\";\nimport { CCAPI, PhysicalCCAPI } from \"../lib/API.js\";\nimport {\n\ttype CCRaw,\n\tCommandClass,\n\ttype InterviewContext,\n\ttype PersistValuesContext,\n\ttype RefreshValuesContext,\n} from \"../lib/CommandClass.js\";\nimport {\n\tAPI,\n\tCCCommand,\n\tccValueProperty,\n\tccValues,\n\tcommandClass,\n\texpectedCCResponse,\n\timplementedVersion,\n} from \"../lib/CommandClassDecorators.js\";\nimport { V } from \"../lib/Values.js\";\nimport {\n\tAssociationGroupInfoCommand,\n\tAssociationGroupInfoProfile,\n} from \"../lib/_Types.js\";\nimport { AssociationCC } from \"./AssociationCC.js\";\nimport { MultiChannelAssociationCC } from \"./MultiChannelAssociationCC.js\";\n\nexport const AssociationGroupInfoCCValues = V.defineCCValues(\n\tCommandClasses[\"Association Group Information\"],\n\t{\n\t\t...V.staticProperty(\"hasDynamicInfo\", undefined, { internal: true }),\n\t\t...V.dynamicPropertyAndKeyWithName(\n\t\t\t\"groupName\",\n\t\t\t\"name\",\n\t\t\t(groupId: number) => groupId,\n\t\t\t({ property, propertyKey }) =>\n\t\t\t\tproperty === \"name\" && typeof propertyKey === \"number\",\n\t\t\tundefined,\n\t\t\t{ internal: true },\n\t\t),\n\t\t...V.dynamicPropertyAndKeyWithName(\n\t\t\t\"groupInfo\",\n\t\t\t\"info\",\n\t\t\t(groupId: number) => groupId,\n\t\t\t({ property, propertyKey }) =>\n\t\t\t\tproperty === \"info\" && typeof propertyKey === \"number\",\n\t\t\tundefined,\n\t\t\t{ internal: true },\n\t\t),\n\t\t...V.dynamicPropertyAndKeyWithName(\n\t\t\t\"commands\",\n\t\t\t\"issuedCommands\",\n\t\t\t(groupId: number) => groupId,\n\t\t\t({ property, propertyKey }) =>\n\t\t\t\tproperty === \"issuedCommands\"\n\t\t\t\t&& typeof propertyKey === \"number\",\n\t\t\tundefined,\n\t\t\t{ internal: true },\n\t\t),\n\t},\n);\n\n// @noSetValueAPI This CC only has get-type commands\n\n@API(CommandClasses[\"Association Group Information\"])\nexport class AssociationGroupInfoCCAPI extends PhysicalCCAPI {\n\tpublic supportsCommand(\n\t\tcmd: AssociationGroupInfoCommand,\n\t): MaybeNotKnown<boolean> {\n\t\tswitch (cmd) {\n\t\t\tcase AssociationGroupInfoCommand.NameGet:\n\t\t\tcase AssociationGroupInfoCommand.NameReport:\n\t\t\tcase AssociationGroupInfoCommand.InfoGet:\n\t\t\tcase AssociationGroupInfoCommand.InfoReport:\n\t\t\tcase AssociationGroupInfoCommand.CommandListGet:\n\t\t\tcase AssociationGroupInfoCommand.CommandListReport:\n\t\t\t\treturn true; // This is mandatory\n\t\t}\n\t\treturn super.supportsCommand(cmd);\n\t}\n\n\t@validateArgs()\n\tpublic async getGroupName(groupId: number): Promise<MaybeNotKnown<string>> {\n\t\tthis.assertSupportsCommand(\n\t\t\tAssociationGroupInfoCommand,\n\t\t\tAssociationGroupInfoCommand.NameGet,\n\t\t);\n\n\t\tconst cc = new AssociationGroupInfoCCNameGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tgroupId,\n\t\t});\n\t\tconst response = await this.host.sendCommand<\n\t\t\tAssociationGroupInfoCCNameReport\n\t\t>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\tif (response) return response.name;\n\t}\n\n\t@validateArgs()\n\tpublic async reportGroupName(groupId: number, name: string): Promise<void> {\n\t\tthis.assertSupportsCommand(\n\t\t\tAssociationGroupInfoCommand,\n\t\t\tAssociationGroupInfoCommand.NameReport,\n\t\t);\n\n\t\tconst cc = new AssociationGroupInfoCCNameReport({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tgroupId,\n\t\t\tname,\n\t\t});\n\n\t\tawait this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\t@validateArgs()\n\t// oxlint-disable-next-line typescript/explicit-module-boundary-types\n\tpublic async getGroupInfo(groupId: number, refreshCache: boolean = false) {\n\t\tthis.assertSupportsCommand(\n\t\t\tAssociationGroupInfoCommand,\n\t\t\tAssociationGroupInfoCommand.InfoGet,\n\t\t);\n\n\t\tconst cc = new AssociationGroupInfoCCInfoGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tgroupId,\n\t\t\trefreshCache,\n\t\t});\n\t\tconst response = await this.host.sendCommand<\n\t\t\tAssociationGroupInfoCCInfoReport\n\t\t>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\t// SDS13782 says: If List Mode is set to 0, the Group Count field MUST be set to 1.\n\t\t// But that's not always the case. Apparently some endpoints return 0 groups\n\t\t// although they support AGI CC\n\t\tif (response && response.groups.length > 0) {\n\t\t\tconst { groupId: _, ...info } = response.groups[0];\n\t\t\treturn {\n\t\t\t\thasDynamicInfo: response.hasDynamicInfo,\n\t\t\t\t...info,\n\t\t\t};\n\t\t}\n\t}\n\n\t@validateArgs()\n\tpublic async reportGroupInfo(\n\t\toptions: AssociationGroupInfoCCInfoReportOptions,\n\t): Promise<void> {\n\t\tthis.assertSupportsCommand(\n\t\t\tAssociationGroupInfoCommand,\n\t\t\tAssociationGroupInfoCommand.InfoReport,\n\t\t);\n\n\t\tconst cc = new AssociationGroupInfoCCInfoReport({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\t...options,\n\t\t});\n\n\t\tawait this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\t@validateArgs()\n\tpublic async getCommands(\n\t\tgroupId: number,\n\t\tallowCache: boolean = true,\n\t): Promise<\n\t\tMaybeNotKnown<AssociationGroupInfoCCCommandListReport[\"commands\"]>\n\t> {\n\t\tthis.assertSupportsCommand(\n\t\t\tAssociationGroupInfoCommand,\n\t\t\tAssociationGroupInfoCommand.CommandListGet,\n\t\t);\n\n\t\tconst cc = new AssociationGroupInfoCCCommandListGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tgroupId,\n\t\t\tallowCache,\n\t\t});\n\t\tconst response = await this.host.sendCommand<\n\t\t\tAssociationGroupInfoCCCommandListReport\n\t\t>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\tif (response) return response.commands;\n\t}\n\n\t@validateArgs()\n\tpublic async reportCommands(\n\t\tgroupId: number,\n\t\tcommands: ReadonlyMap<CommandClasses, readonly number[]>,\n\t): Promise<void> {\n\t\tthis.assertSupportsCommand(\n\t\t\tAssociationGroupInfoCommand,\n\t\t\tAssociationGroupInfoCommand.CommandListReport,\n\t\t);\n\n\t\tconst cc = new AssociationGroupInfoCCCommandListReport({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tgroupId,\n\t\t\tcommands,\n\t\t});\n\n\t\tawait this.host.sendCommand(cc, this.commandOptions);\n\t}\n}\n\n@commandClass(CommandClasses[\"Association Group Information\"])\n@implementedVersion(3)\n@ccValues(AssociationGroupInfoCCValues)\nexport class AssociationGroupInfoCC extends CommandClass {\n\tdeclare ccCommand: AssociationGroupInfoCommand;\n\n\tpublic determineRequiredCCInterviews(): readonly CommandClasses[] {\n\t\t// AssociationCC must be interviewed after Z-Wave+ if that is supported\n\t\treturn [\n\t\t\t...super.determineRequiredCCInterviews(),\n\t\t\tCommandClasses.Association,\n\t\t\tCommandClasses[\"Multi Channel Association\"],\n\t\t];\n\t}\n\n\t/** Returns the name of an association group */\n\tpublic static getGroupNameCached(\n\t\tctx: GetValueDB,\n\t\tendpoint: EndpointId,\n\t\tgroupId: number,\n\t): MaybeNotKnown<string> {\n\t\treturn ctx\n\t\t\t.getValueDB(endpoint.nodeId)\n\t\t\t.getValue(\n\t\t\t\tAssociationGroupInfoCCValues.groupName(groupId).endpoint(\n\t\t\t\t\tendpoint.index,\n\t\t\t\t),\n\t\t\t);\n\t}\n\n\t/** Returns the association profile for an association group */\n\tpublic static getGroupProfileCached(\n\t\tctx: GetValueDB,\n\t\tendpoint: EndpointId,\n\t\tgroupId: number,\n\t): MaybeNotKnown<AssociationGroupInfoProfile> {\n\t\treturn ctx.getValueDB(endpoint.nodeId).getValue<{\n\t\t\tprofile: AssociationGroupInfoProfile;\n\t\t}>(\n\t\t\tAssociationGroupInfoCCValues.groupInfo(groupId).endpoint(\n\t\t\t\tendpoint.index,\n\t\t\t),\n\t\t)\n\t\t\t?.profile;\n\t}\n\n\t/** Returns the dictionary of all commands issued by the given association group */\n\tpublic static getIssuedCommandsCached(\n\t\tctx: GetValueDB,\n\t\tendpoint: EndpointId,\n\t\tgroupId: number,\n\t): MaybeNotKnown<ReadonlyMap<CommandClasses, readonly number[]>> {\n\t\treturn ctx\n\t\t\t.getValueDB(endpoint.nodeId)\n\t\t\t.getValue(\n\t\t\t\tAssociationGroupInfoCCValues.commands(groupId).endpoint(\n\t\t\t\t\tendpoint.index,\n\t\t\t\t),\n\t\t\t);\n\t}\n\n\tpublic static findGroupsForIssuedCommand(\n\t\tctx: GetValueDB,\n\t\tendpoint: EndpointId & SupportsCC,\n\t\tccId: CommandClasses,\n\t\tcommand: number,\n\t): number[] {\n\t\tconst ret: number[] = [];\n\t\tconst associationGroupCount = this.getAssociationGroupCountCached(\n\t\t\tctx,\n\t\t\tendpoint,\n\t\t);\n\t\tfor (let groupId = 1; groupId <= associationGroupCount; groupId++) {\n\t\t\t// Scan the issued commands of all groups if there's a match\n\t\t\tconst issuedCommands = this.getIssuedCommandsCached(\n\t\t\t\tctx,\n\t\t\t\tendpoint,\n\t\t\t\tgroupId,\n\t\t\t);\n\t\t\tif (!issuedCommands) continue;\n\t\t\tif (\n\t\t\t\tissuedCommands.has(ccId)\n\t\t\t\t&& issuedCommands.get(ccId)!.includes(command)\n\t\t\t) {\n\t\t\t\tret.push(groupId);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\treturn ret;\n\t}\n\n\tprivate static getAssociationGroupCountCached(\n\t\tctx: GetValueDB,\n\t\tendpoint: EndpointId & SupportsCC,\n\t): number {\n\t\t// The association group count is either determined by the\n\t\t// Association CC or the Multi Channel Association CC\n\n\t\treturn (\n\t\t\t// First query the Multi Channel Association CC\n\t\t\t// And fall back to 0\n\t\t\t(endpoint.supportsCC(\n\t\t\t\tCommandClasses[\"Multi Channel Association\"],\n\t\t\t)\n\t\t\t\t&& MultiChannelAssociationCC.getGroupCountCached(\n\t\t\t\t\tctx,\n\t\t\t\t\tendpoint,\n\t\t\t\t))\n\t\t\t// Then the Association CC\n\t\t\t|| (endpoint.supportsCC(CommandClasses.Association)\n\t\t\t\t&& AssociationCC.getGroupCountCached(ctx, endpoint))\n\t\t\t|| 0\n\t\t);\n\t}\n\n\tpublic async interview(\n\t\tctx: InterviewContext,\n\t): Promise<void> {\n\t\tconst node = this.getNode(ctx)!;\n\t\tconst endpoint = this.getEndpoint(ctx)!;\n\t\tconst api = CCAPI.create(\n\t\t\tCommandClasses[\"Association Group Information\"],\n\t\t\tctx,\n\t\t\tendpoint,\n\t\t).withOptions({ priority: MessagePriority.NodeQuery });\n\n\t\tctx.logNode(node.id, {\n\t\t\tendpoint: this.endpointIndex,\n\t\t\tmessage: `Interviewing ${this.ccName}...`,\n\t\t\tdirection: \"none\",\n\t\t});\n\n\t\tconst associationGroupCount = AssociationGroupInfoCC\n\t\t\t.getAssociationGroupCountCached(\n\t\t\t\tctx,\n\t\t\t\tendpoint,\n\t\t\t);\n\n\t\tfor (let groupId = 1; groupId <= associationGroupCount; groupId++) {\n\t\t\t// First get the group's name\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\tmessage: `Association group #${groupId}: Querying name...`,\n\t\t\t\tdirection: \"outbound\",\n\t\t\t});\n\t\t\tconst name = await api.getGroupName(groupId);\n\t\t\tif (name) {\n\t\t\t\tconst logMessage =\n\t\t\t\t\t`Association group #${groupId} has name \"${name}\"`;\n\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\t\tmessage: logMessage,\n\t\t\t\t\tdirection: \"inbound\",\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// Then the command list\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\tmessage:\n\t\t\t\t\t`Association group #${groupId}: Querying command list...`,\n\t\t\t\tdirection: \"outbound\",\n\t\t\t});\n\t\t\tawait api.getCommands(groupId);\n\t\t\t// Not sure how to log this\n\t\t}\n\n\t\t// Finally query each group for its information\n\t\tawait this.refreshValues(ctx);\n\n\t\t// Remember that the interview is complete\n\t\tthis.setInterviewComplete(ctx, true);\n\t}\n\n\tpublic async refreshValues(\n\t\tctx: RefreshValuesContext,\n\t): Promise<void> {\n\t\tconst node = this.getNode(ctx)!;\n\t\tconst endpoint = this.getEndpoint(ctx)!;\n\t\tconst api = CCAPI.create(\n\t\t\tCommandClasses[\"Association Group Information\"],\n\t\t\tctx,\n\t\t\tendpoint,\n\t\t).withOptions({ priority: MessagePriority.NodeQuery });\n\n\t\t// Query the information for each group (this is the only thing that could be dynamic)\n\t\tconst associationGroupCount = AssociationGroupInfoCC\n\t\t\t.getAssociationGroupCountCached(\n\t\t\t\tctx,\n\t\t\t\tendpoint,\n\t\t\t);\n\t\tconst hasDynamicInfo = this.getValue<boolean>(\n\t\t\tctx,\n\t\t\tAssociationGroupInfoCCValues.hasDynamicInfo,\n\t\t);\n\n\t\tfor (let groupId = 1; groupId <= associationGroupCount; groupId++) {\n\t\t\t// Then its information\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\tmessage: `Association group #${groupId}: Querying info...`,\n\t\t\t\tdirection: \"outbound\",\n\t\t\t});\n\t\t\tconst info = await api.getGroupInfo(groupId, !!hasDynamicInfo);\n\t\t\tif (info) {\n\t\t\t\tconst logMessage =\n\t\t\t\t\t`Received info for association group #${groupId}:\ninfo is dynamic: ${info.hasDynamicInfo}\nprofile: ${\n\t\t\t\t\t\tgetEnumMemberName(\n\t\t\t\t\t\t\tAssociationGroupInfoProfile,\n\t\t\t\t\t\t\tinfo.profile,\n\t\t\t\t\t\t)\n\t\t\t\t\t}`;\n\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\t\tmessage: logMessage,\n\t\t\t\t\tdirection: \"inbound\",\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n}\n\n// @publicAPI\nexport interface AssociationGroupInfoCCNameReportOptions {\n\tgroupId: number;\n\tname: string;\n}\n\n@CCCommand(AssociationGroupInfoCommand.NameReport)\nexport class AssociationGroupInfoCCNameReport extends AssociationGroupInfoCC {\n\tpublic constructor(\n\t\toptions: WithAddress<AssociationGroupInfoCCNameReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\tthis.groupId = options.groupId;\n\t\tthis.name = options.name;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): AssociationGroupInfoCCNameReport {\n\t\tvalidatePayload(raw.payload.length >= 2);\n\t\tconst groupId = raw.payload[0];\n\t\tconst nameLength = raw.payload[1];\n\t\tvalidatePayload(raw.payload.length >= 2 + nameLength);\n\t\t// The specs don't allow 0-terminated string, but some devices use them\n\t\t// So we need to cut them off\n\t\tconst name = cpp2js(\n\t\t\traw.payload.subarray(2, 2 + nameLength).toString(\"utf8\"),\n\t\t);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tgroupId,\n\t\t\tname,\n\t\t});\n\t}\n\n\tpublic readonly groupId: number;\n\tpublic readonly name: string;\n\n\tpublic persistValues(ctx: PersistValuesContext): boolean {\n\t\tif (!super.persistValues(ctx)) return false;\n\t\tconst valueDB = this.getValueDB(ctx);\n\n\t\tvalueDB.setValue(\n\t\t\tAssociationGroupInfoCCValues.groupName(this.groupId).endpoint(\n\t\t\t\tthis.endpointIndex,\n\t\t\t),\n\t\t\tthis.name,\n\t\t);\n\n\t\treturn true;\n\t}\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.concat([\n\t\t\t[this.groupId, this.name.length],\n\t\t\tBytes.from(this.name, \"utf8\"),\n\t\t]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: {\n\t\t\t\t\"group id\": this.groupId,\n\t\t\t\tname: this.name,\n\t\t\t},\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport interface AssociationGroupInfoCCNameGetOptions {\n\tgroupId: number;\n}\n\n@CCCommand(AssociationGroupInfoCommand.NameGet)\n@expectedCCResponse(AssociationGroupInfoCCNameReport)\nexport class AssociationGroupInfoCCNameGet extends AssociationGroupInfoCC {\n\tpublic constructor(\n\t\toptions: WithAddress<AssociationGroupInfoCCNameGetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.groupId = options.groupId;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): AssociationGroupInfoCCNameGet {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst groupId = raw.payload[0];\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tgroupId,\n\t\t});\n\t}\n\n\tpublic groupId: number;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.from([this.groupId]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: { \"group id\": this.groupId },\n\t\t};\n\t}\n}\n\nexport interface AssociationGroupInfo {\n\tgroupId: number;\n\tmode: number;\n\tprofile: number;\n\teventCode: number;\n}\n\n// @publicAPI\nexport interface AssociationGroupInfoCCInfoReportOptions {\n\tisListMode: boolean;\n\thasDynamicInfo: boolean;\n\tgroups: AssociationGroupInfo[];\n}\n\n@CCCommand(AssociationGroupInfoCommand.InfoReport)\n@ccValueProperty(\"hasDynamicInfo\", AssociationGroupInfoCCValues.hasDynamicInfo)\nexport class AssociationGroupInfoCCInfoReport extends AssociationGroupInfoCC {\n\tpublic constructor(\n\t\toptions: WithAddress<AssociationGroupInfoCCInfoReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\tthis.isListMode = options.isListMode;\n\t\tthis.hasDynamicInfo = options.hasDynamicInfo;\n\t\tthis.groups = options.groups;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): AssociationGroupInfoCCInfoReport {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst isListMode = !!(raw.payload[0] & 0b1000_0000);\n\t\tconst hasDynamicInfo = !!(raw.payload[0] & 0b0100_0000);\n\t\tconst groupCount = raw.payload[0] & 0b0011_1111;\n\t\t// each group requires 7 bytes of payload\n\t\tvalidatePayload(raw.payload.length >= 1 + groupCount * 7);\n\t\tconst groups: AssociationGroupInfo[] = [];\n\t\tfor (let i = 0; i < groupCount; i++) {\n\t\t\tconst offset = 1 + i * 7;\n\t\t\t// Parse the payload\n\t\t\tconst groupBytes = raw.payload.subarray(offset, offset + 7);\n\t\t\tconst groupId = groupBytes[0];\n\t\t\tconst mode = 0; // groupBytes[1];\n\t\t\tconst profile = groupBytes.readUInt16BE(2);\n\t\t\tconst eventCode = 0; // groupBytes.readUInt16BE(5);\n\t\t\tgroups.push({ groupId, mode, profile, eventCode });\n\t\t}\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tisListMode,\n\t\t\thasDynamicInfo,\n\t\t\tgroups,\n\t\t});\n\t}\n\n\tpublic readonly isListMode: boolean;\n\n\tpublic readonly hasDynamicInfo: boolean;\n\n\tpublic readonly groups: readonly AssociationGroupInfo[];\n\n\tpublic persistValues(ctx: PersistValuesContext): boolean {\n\t\tif (!super.persistValues(ctx)) return false;\n\n\t\tfor (const group of this.groups) {\n\t\t\tconst { groupId, mode, profile, eventCode } = group;\n\t\t\tthis.setValue(\n\t\t\t\tctx,\n\t\t\t\tAssociationGroupInfoCCValues.groupInfo(groupId),\n\t\t\t\t{\n\t\t\t\t\tmode,\n\t\t\t\t\tprofile,\n\t\t\t\t\teventCode,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t\treturn true;\n\t}\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.alloc(1 + this.groups.length * 7, 0);\n\n\t\tthis.payload[0] = (this.isListMode ? 0b1000_0000 : 0)\n\t\t\t| (this.hasDynamicInfo ? 0b0100_0000 : 0)\n\t\t\t| (this.groups.length & 0b0011_1111);\n\n\t\tfor (let i = 0; i < this.groups.length; i++) {\n\t\t\tconst offset = 1 + i * 7;\n\t\t\tthis.payload[offset] = this.groups[i].groupId;\n\t\t\tthis.payload.writeUInt16BE(this.groups[i].profile, offset + 2);\n\t\t\t// The remaining bytes are zero\n\t\t}\n\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: {\n\t\t\t\t\"is list mode\": this.isListMode,\n\t\t\t\t\"has dynamic info\": this.hasDynamicInfo,\n\t\t\t\tgroups: this.groups\n\t\t\t\t\t.map(\n\t\t\t\t\t\t(g) => `\n\u00B7 Group #${g.groupId}\n mode: ${g.mode}\n profile: ${g.profile}\n event code: ${g.eventCode}`,\n\t\t\t\t\t)\n\t\t\t\t\t.join(\"\"),\n\t\t\t},\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport type AssociationGroupInfoCCInfoGetOptions =\n\t& {\n\t\trefreshCache: boolean;\n\t}\n\t& (\n\t\t| {\n\t\t\tlistMode: boolean;\n\t\t}\n\t\t| {\n\t\t\tgroupId: number;\n\t\t}\n\t);\n\n@CCCommand(AssociationGroupInfoCommand.InfoGet)\n@expectedCCResponse(AssociationGroupInfoCCInfoReport)\nexport class AssociationGroupInfoCCInfoGet extends AssociationGroupInfoCC {\n\tpublic constructor(\n\t\toptions: WithAddress<AssociationGroupInfoCCInfoGetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.refreshCache = options.refreshCache;\n\t\tif (\"listMode\" in options) this.listMode = options.listMode;\n\t\tif (\"groupId\" in options) this.groupId = options.groupId;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): AssociationGroupInfoCCInfoGet {\n\t\tvalidatePayload(raw.payload.length >= 2);\n\t\tconst optionByte = raw.payload[0];\n\t\tconst refreshCache = !!(optionByte & 0b1000_0000);\n\t\tconst listMode: boolean | undefined = !!(optionByte & 0b0100_0000);\n\t\tlet groupId: number | undefined;\n\n\t\tif (!listMode) {\n\t\t\tgroupId = raw.payload[1];\n\t\t}\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\trefreshCache,\n\t\t\tlistMode,\n\t\t\tgroupId,\n\t\t});\n\t}\n\n\tpublic refreshCache: boolean;\n\tpublic listMode?: boolean;\n\tpublic groupId?: number;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tconst isListMode = this.listMode === true;\n\t\tconst optionByte = (this.refreshCache ? 0b1000_0000 : 0)\n\t\t\t| (isListMode ? 0b0100_0000 : 0);\n\t\tthis.payload = Bytes.from([\n\t\t\toptionByte,\n\t\t\tisListMode ? 0 : this.groupId!,\n\t\t]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\tconst message: MessageRecord = {};\n\t\tif (this.groupId != undefined) {\n\t\t\tmessage[\"group id\"] = this.groupId;\n\t\t}\n\t\tif (this.listMode != undefined) {\n\t\t\tmessage[\"list mode\"] = this.listMode;\n\t\t}\n\t\tmessage[\"refresh cache\"] = this.refreshCache;\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage,\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport interface AssociationGroupInfoCCCommandListReportOptions {\n\tgroupId: number;\n\tcommands: ReadonlyMap<CommandClasses, readonly number[]>;\n}\n\n@CCCommand(AssociationGroupInfoCommand.CommandListReport)\n@ccValueProperty(\n\t\"commands\",\n\tAssociationGroupInfoCCValues.commands,\n\t(self) => [self.groupId],\n)\nexport class AssociationGroupInfoCCCommandListReport\n\textends AssociationGroupInfoCC\n{\n\tpublic constructor(\n\t\toptions: WithAddress<AssociationGroupInfoCCCommandListReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\tthis.groupId = options.groupId;\n\t\tthis.commands = options.commands;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): AssociationGroupInfoCCCommandListReport {\n\t\tvalidatePayload(raw.payload.length >= 2);\n\t\tconst groupId = raw.payload[0];\n\t\tconst listLength = raw.payload[1];\n\t\tvalidatePayload(raw.payload.length >= 2 + listLength);\n\t\tconst listBytes = raw.payload.subarray(2, 2 + listLength);\n\t\t// Parse all CC ids and commands\n\t\tlet offset = 0;\n\t\tconst commands = new Map<CommandClasses, number[]>();\n\t\twhile (offset < listLength) {\n\t\t\tconst { ccId, bytesRead } = parseCCId(listBytes, offset);\n\t\t\tconst command = listBytes[offset + bytesRead];\n\t\t\tif (!commands.has(ccId)) commands.set(ccId, []);\n\t\t\tcommands.get(ccId)!.push(command);\n\t\t\toffset += bytesRead + 1;\n\t\t}\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tgroupId,\n\t\t\tcommands,\n\t\t});\n\t}\n\n\tpublic readonly groupId: number;\n\n\tpublic readonly commands: ReadonlyMap<CommandClasses, readonly number[]>;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\t// To make it easier to encode possible extended CCs, we first\n\t\t// allocate as much space as we may need, then trim it again\n\t\tthis.payload = new Bytes(2 + this.commands.size * 3);\n\t\tthis.payload[0] = this.groupId;\n\t\tlet offset = 2;\n\t\tfor (const [ccId, commands] of this.commands) {\n\t\t\tfor (const command of commands) {\n\t\t\t\toffset += encodeCCId(ccId, this.payload, offset);\n\t\t\t\tthis.payload[offset] = command;\n\t\t\t\toffset++;\n\t\t\t}\n\t\t}\n\t\tthis.payload[1] = offset - 2; // list length\n\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: {\n\t\t\t\t\"group id\": this.groupId,\n\t\t\t\tcommands: [...this.commands]\n\t\t\t\t\t.map(([cc, cmds]) => {\n\t\t\t\t\t\treturn `\\n\u00B7 ${getCCName(cc)}: ${\n\t\t\t\t\t\t\tcmds\n\t\t\t\t\t\t\t\t.map((cmd) => num2hex(cmd))\n\t\t\t\t\t\t\t\t.join(\", \")\n\t\t\t\t\t\t}`;\n\t\t\t\t\t})\n\t\t\t\t\t.join(\"\"),\n\t\t\t},\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport interface AssociationGroupInfoCCCommandListGetOptions {\n\tallowCache: boolean;\n\tgroupId: number;\n}\n\n@CCCommand(AssociationGroupInfoCommand.CommandListGet)\n@expectedCCResponse(AssociationGroupInfoCCCommandListReport)\nexport class AssociationGroupInfoCCCommandListGet\n\textends AssociationGroupInfoCC\n{\n\tpublic constructor(\n\t\toptions: WithAddress<AssociationGroupInfoCCCommandListGetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.allowCache = options.allowCache;\n\t\tthis.groupId = options.groupId;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): AssociationGroupInfoCCCommandListGet {\n\t\tvalidatePayload(raw.payload.length >= 2);\n\t\tconst allowCache = !!(raw.payload[0] & 0b1000_0000);\n\t\tconst groupId = raw.payload[1];\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tallowCache,\n\t\t\tgroupId,\n\t\t});\n\t}\n\n\tpublic allowCache: boolean;\n\tpublic groupId: number;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.from([\n\t\t\tthis.allowCache ? 0b1000_0000 : 0,\n\t\t\tthis.groupId,\n\t\t]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: {\n\t\t\t\t\"group id\": this.groupId,\n\t\t\t\t\"allow cache\": this.allowCache,\n\t\t\t},\n\t\t};\n\t}\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,kBAcO;AACP,oBAA0D;AAE1D,iBAAqC;AACrC,0BAMO;AACP,oCAQO;AACP,oBAAkB;AAClB,mBAGO;AACP,2BAA8B;AAC9B,uCAA0C;;;;;;;;;;;;;;;;;;;;;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4DAAA,YAAsB;WAAA;;;;;;;;AAD/B,mBAAA,MAAA,mBAAA,EAAA,OAAA,WAAA,GAAA,kBAAA,EAAA,MAAA,SAAA,MAAA,WAAA,MAAA,UAAA,UAAA,GAAA,MAAA,uBAAA;;;AAAa,wBAAA,YAAA,uBAAA;;IAGZ,YACC,SAAiE;AAEjE,YAAM,OAAO;AACb,WAAK,aAAa,QAAQ;AAC1B,WAAK,UAAU,QAAQ;IACxB;IAEO,OAAO,KACb,KACA,KAAqB;AAErB,uCAAgB,IAAI,QAAQ,UAAU,CAAC;AACvC,YAAM,aAAa,CAAC,EAAE,IAAI,QAAQ,CAAC,IAAI;AACvC,YAAM,UAAU,IAAI,QAAQ,CAAC;AAE7B,aAAO,IAAI,KAAK;QACf,QAAQ,IAAI;QACZ;QACA;OACA;IACF;IAEO;IACA;IAEA,UAAU,KAAsB;AACtC,WAAK,UAAU,oBAAM,KAAK;QACzB,KAAK,aAAa,MAAc;QAChC,KAAK;OACL;AACD,aAAO,MAAM,UAAU,GAAG;IAC3B;IAEO,WAAW,KAAgB;AACjC,aAAO;QACN,GAAG,MAAM,WAAW,GAAG;QACvB,SAAS;UACR,YAAY,KAAK;UACjB,eAAe,KAAK;;;IAGvB;;;;",
|
|
6
6
|
"names": ["AssociationGroupInfoCC"]
|
|
7
7
|
}
|
|
@@ -362,10 +362,10 @@ let BatteryCCReport = (() => {
|
|
|
362
362
|
if (this.chargingStatus != void 0) {
|
|
363
363
|
this.payload = import_shared.Bytes.concat([
|
|
364
364
|
this.payload,
|
|
365
|
-
|
|
365
|
+
[
|
|
366
366
|
(this.chargingStatus << 6) + (this.rechargeable ? 32 : 0) + (this.backup ? 16 : 0) + (this.overheating ? 8 : 0) + (this.lowFluid ? 4 : 0) + (this.rechargeOrReplace === import_Types.BatteryReplacementStatus.Now ? 2 : this.rechargeOrReplace === import_Types.BatteryReplacementStatus.Soon ? 1 : 0),
|
|
367
367
|
(this.lowTemperatureStatus ? 2 : 0) + (this.disconnected ? 1 : 0)
|
|
368
|
-
]
|
|
368
|
+
]
|
|
369
369
|
]);
|
|
370
370
|
}
|
|
371
371
|
return super.serialize(ctx);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cc/BatteryCC.ts"],
|
|
4
|
-
"sourcesContent": ["import type { CCEncodingContext, CCParsingContext } from \"@zwave-js/cc\";\nimport type { GetDeviceConfig } from \"@zwave-js/config\";\nimport {\n\tCommandClasses,\n\ttype ControlsCC,\n\ttype EndpointId,\n\ttype GetEndpoint,\n\ttype GetNode,\n\ttype GetSupportedCCVersion,\n\ttype GetValueDB,\n\ttype MaybeNotKnown,\n\ttype MessageOrCCLogEntry,\n\tMessagePriority,\n\ttype MessageRecord,\n\ttype NodeId,\n\ttype SinglecastCC,\n\ttype SupportsCC,\n\tValueMetadata,\n\ttype WithAddress,\n\tencodeFloatWithScale,\n\tenumValuesToMetadataStates,\n\tparseFloatWithScale,\n\ttimespan,\n\tvalidatePayload,\n} from \"@zwave-js/core\";\nimport {\n\ttype AllOrNone,\n\tBytes,\n\tgetEnumMemberName,\n\tpick,\n} from \"@zwave-js/shared\";\nimport {\n\tCCAPI,\n\tPOLL_VALUE,\n\tPhysicalCCAPI,\n\ttype PollValueImplementation,\n\tthrowUnsupportedProperty,\n} from \"../lib/API.js\";\nimport {\n\ttype CCRaw,\n\tCommandClass,\n\ttype InterviewContext,\n\ttype PersistValuesContext,\n\ttype RefreshValuesContext,\n} from \"../lib/CommandClass.js\";\nimport {\n\tAPI,\n\tCCCommand,\n\tccValueProperty,\n\tccValues,\n\tcommandClass,\n\texpectedCCResponse,\n\timplementedVersion,\n} from \"../lib/CommandClassDecorators.js\";\nimport { V } from \"../lib/Values.js\";\nimport {\n\tBatteryChargingStatus,\n\tBatteryCommand,\n\tBatteryReplacementStatus,\n} from \"../lib/_Types.js\";\nimport { NotificationCCValues } from \"./NotificationCC.js\";\n\nexport const BatteryCCValues = V.defineCCValues(CommandClasses.Battery, {\n\t...V.staticProperty(\n\t\t\"level\",\n\t\t{\n\t\t\t...ValueMetadata.ReadOnlyUInt8,\n\t\t\tmax: 100,\n\t\t\tunit: \"%\",\n\t\t\tlabel: \"Battery level\",\n\t\t} as const,\n\t),\n\n\t...V.staticProperty(\n\t\t\"maximumCapacity\",\n\t\t{\n\t\t\t...ValueMetadata.ReadOnlyUInt8,\n\t\t\tmax: 100,\n\t\t\tunit: \"%\",\n\t\t\tlabel: \"Maximum capacity\",\n\t\t} as const,\n\t\t{\n\t\t\tminVersion: 2,\n\t\t} as const,\n\t),\n\n\t...V.staticProperty(\n\t\t\"temperature\",\n\t\t{\n\t\t\t...ValueMetadata.ReadOnlyInt8,\n\t\t\tlabel: \"Temperature\",\n\t\t\t// For now, only \u00B0C is specified as a valid unit\n\t\t\t// If this ever changes, update the unit in persistValues on the fly\n\t\t\tunit: \"\u00B0C\",\n\t\t} as const,\n\t\t{\n\t\t\tminVersion: 2,\n\t\t} as const,\n\t),\n\n\t...V.staticProperty(\n\t\t\"chargingStatus\",\n\t\t{\n\t\t\t...ValueMetadata.ReadOnlyUInt8,\n\t\t\tlabel: \"Charging status\",\n\t\t\tstates: enumValuesToMetadataStates(BatteryChargingStatus),\n\t\t} as const,\n\t\t{\n\t\t\tminVersion: 2,\n\t\t} as const,\n\t),\n\n\t...V.staticProperty(\n\t\t\"rechargeable\",\n\t\t{\n\t\t\t...ValueMetadata.ReadOnlyBoolean,\n\t\t\tlabel: \"Rechargeable\",\n\t\t} as const,\n\t\t{\n\t\t\tminVersion: 2,\n\t\t} as const,\n\t),\n\n\t...V.staticProperty(\n\t\t\"backup\",\n\t\t{\n\t\t\t...ValueMetadata.ReadOnlyBoolean,\n\t\t\tlabel: \"Used as backup\",\n\t\t} as const,\n\t\t{\n\t\t\tminVersion: 2,\n\t\t} as const,\n\t),\n\n\t...V.staticProperty(\n\t\t\"overheating\",\n\t\t{\n\t\t\t...ValueMetadata.ReadOnlyBoolean,\n\t\t\tlabel: \"Overheating\",\n\t\t} as const,\n\t\t{\n\t\t\tminVersion: 2,\n\t\t} as const,\n\t),\n\n\t...V.staticProperty(\n\t\t\"lowFluid\",\n\t\t{\n\t\t\t...ValueMetadata.ReadOnlyBoolean,\n\t\t\tlabel: \"Fluid is low\",\n\t\t} as const,\n\t\t{\n\t\t\tminVersion: 2,\n\t\t} as const,\n\t),\n\n\t...V.staticProperty(\n\t\t\"rechargeOrReplace\",\n\t\t{\n\t\t\t...ValueMetadata.ReadOnlyUInt8,\n\t\t\tlabel: \"Recharge or replace\",\n\t\t\tstates: enumValuesToMetadataStates(BatteryReplacementStatus),\n\t\t} as const,\n\t\t{\n\t\t\tminVersion: 2,\n\t\t} as const,\n\t),\n\n\t...V.staticProperty(\n\t\t\"disconnected\",\n\t\t{\n\t\t\t...ValueMetadata.ReadOnlyBoolean,\n\t\t\tlabel: \"Battery is disconnected\",\n\t\t} as const,\n\t\t{\n\t\t\tminVersion: 2,\n\t\t} as const,\n\t),\n\n\t...V.staticProperty(\n\t\t\"lowTemperatureStatus\",\n\t\t{\n\t\t\t...ValueMetadata.ReadOnlyBoolean,\n\t\t\tlabel: \"Battery temperature is low\",\n\t\t} as const,\n\t\t{\n\t\t\tminVersion: 3,\n\t\t} as const,\n\t),\n});\n\n// @noSetValueAPI This CC is read-only\n\n@API(CommandClasses.Battery)\nexport class BatteryCCAPI extends PhysicalCCAPI {\n\tpublic supportsCommand(cmd: BatteryCommand): MaybeNotKnown<boolean> {\n\t\tswitch (cmd) {\n\t\t\tcase BatteryCommand.Get:\n\t\t\t\treturn true; // This is mandatory\n\t\t\tcase BatteryCommand.HealthGet:\n\t\t\t\treturn this.version >= 2;\n\t\t}\n\t\treturn super.supportsCommand(cmd);\n\t}\n\n\tprotected get [POLL_VALUE](): PollValueImplementation {\n\t\treturn async function(this: BatteryCCAPI, { property }) {\n\t\t\tswitch (property) {\n\t\t\t\tcase \"level\":\n\t\t\t\tcase \"chargingStatus\":\n\t\t\t\tcase \"rechargeable\":\n\t\t\t\tcase \"backup\":\n\t\t\t\tcase \"overheating\":\n\t\t\t\tcase \"lowFluid\":\n\t\t\t\tcase \"rechargeOrReplace\":\n\t\t\t\tcase \"lowTemperatureStatus\":\n\t\t\t\tcase \"disconnected\":\n\t\t\t\t\treturn (await this.get())?.[property];\n\n\t\t\t\tcase \"maximumCapacity\":\n\t\t\t\tcase \"temperature\":\n\t\t\t\t\treturn (await this.getHealth())?.[property];\n\n\t\t\t\tdefault:\n\t\t\t\t\tthrowUnsupportedProperty(this.ccId, property);\n\t\t\t}\n\t\t};\n\t}\n\n\t// oxlint-disable-next-line typescript/explicit-module-boundary-types\n\tpublic async get() {\n\t\tthis.assertSupportsCommand(BatteryCommand, BatteryCommand.Get);\n\n\t\tconst cc = new BatteryCCGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tconst response = await this.host.sendCommand<BatteryCCReport>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\tif (response) {\n\t\t\treturn pick(response, [\n\t\t\t\t\"level\",\n\t\t\t\t\"chargingStatus\",\n\t\t\t\t\"rechargeable\",\n\t\t\t\t\"backup\",\n\t\t\t\t\"overheating\",\n\t\t\t\t\"lowFluid\",\n\t\t\t\t\"rechargeOrReplace\",\n\t\t\t\t\"lowTemperatureStatus\",\n\t\t\t\t\"disconnected\",\n\t\t\t]);\n\t\t}\n\t}\n\n\t// oxlint-disable-next-line typescript/explicit-module-boundary-types\n\tpublic async getHealth() {\n\t\tthis.assertSupportsCommand(BatteryCommand, BatteryCommand.HealthGet);\n\n\t\tconst cc = new BatteryCCHealthGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tconst response = await this.host.sendCommand<BatteryCCHealthReport>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\tif (response) {\n\t\t\treturn pick(response, [\"maximumCapacity\", \"temperature\"]);\n\t\t}\n\t}\n}\n\n@commandClass(CommandClasses.Battery)\n@implementedVersion(3)\n@ccValues(BatteryCCValues)\nexport class BatteryCC extends CommandClass {\n\tdeclare ccCommand: BatteryCommand;\n\n\tpublic async interview(\n\t\tctx: InterviewContext,\n\t): Promise<void> {\n\t\tconst node = this.getNode(ctx)!;\n\n\t\tctx.logNode(node.id, {\n\t\t\tendpoint: this.endpointIndex,\n\t\t\tmessage: `Interviewing ${this.ccName}...`,\n\t\t\tdirection: \"none\",\n\t\t});\n\n\t\t// Query the Battery status\n\t\tawait this.refreshValues(ctx);\n\n\t\t// Remember that the interview is complete\n\t\tthis.setInterviewComplete(ctx, true);\n\t}\n\n\tpublic async refreshValues(\n\t\tctx: RefreshValuesContext,\n\t): Promise<void> {\n\t\tconst node = this.getNode(ctx)!;\n\t\tconst endpoint = this.getEndpoint(ctx)!;\n\t\tconst api = CCAPI.create(\n\t\t\tCommandClasses.Battery,\n\t\t\tctx,\n\t\t\tendpoint,\n\t\t).withOptions({\n\t\t\tpriority: MessagePriority.NodeQuery,\n\t\t});\n\n\t\tctx.logNode(node.id, {\n\t\t\tendpoint: this.endpointIndex,\n\t\t\tmessage: \"querying battery status...\",\n\t\t\tdirection: \"outbound\",\n\t\t});\n\n\t\tconst batteryStatus = await api.get();\n\t\tif (batteryStatus) {\n\t\t\tlet logMessage = `received response for battery information:\nlevel: ${\n\t\t\t\tbatteryStatus.level === 0xff\n\t\t\t\t\t? \"low\"\n\t\t\t\t\t: (batteryStatus.level + \" %\")\n\t\t\t}`;\n\t\t\tif (api.version >= 2) {\n\t\t\t\tlogMessage += `\nstatus: ${\n\t\t\t\t\tBatteryChargingStatus[batteryStatus.chargingStatus!]\n\t\t\t\t}\nrechargeable: ${batteryStatus.rechargeable}\nis backup: ${batteryStatus.backup}\nis overheating: ${batteryStatus.overheating}\nfluid is low: ${batteryStatus.lowFluid}\nneeds to be replaced or charged: ${\n\t\t\t\t\tBatteryReplacementStatus[batteryStatus.rechargeOrReplace!]\n\t\t\t\t}\nis low temperature ${batteryStatus.lowTemperatureStatus}\nis disconnected: ${batteryStatus.disconnected}`;\n\t\t\t}\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\tmessage: logMessage,\n\t\t\t\tdirection: \"inbound\",\n\t\t\t});\n\t\t}\n\n\t\tif (api.version >= 2) {\n\t\t\t// always query the health\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\tmessage: \"querying battery health...\",\n\t\t\t\tdirection: \"outbound\",\n\t\t\t});\n\n\t\t\tconst batteryHealth = await api.getHealth();\n\t\t\tif (batteryHealth) {\n\t\t\t\tconst logMessage = `received response for battery health:\nmax. capacity: ${batteryHealth.maximumCapacity} %\ntemperature: ${batteryHealth.temperature} \u00B0C`;\n\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\t\tmessage: logMessage,\n\t\t\t\t\tdirection: \"inbound\",\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic shouldRefreshValues(\n\t\tthis: SinglecastCC<this>,\n\t\tctx:\n\t\t\t& GetValueDB\n\t\t\t& GetSupportedCCVersion\n\t\t\t& GetDeviceConfig\n\t\t\t& GetNode<\n\t\t\t\tNodeId & GetEndpoint<EndpointId & SupportsCC & ControlsCC>\n\t\t\t>,\n\t): boolean {\n\t\t// Check when the battery state was last updated\n\t\tconst valueDB = ctx.tryGetValueDB(this.nodeId);\n\t\tif (!valueDB) return true;\n\n\t\tconst lastUpdated = valueDB.getTimestamp(\n\t\t\tBatteryCCValues.level.endpoint(this.endpointIndex),\n\t\t);\n\t\treturn (\n\t\t\tlastUpdated == undefined\n\t\t\t// The specs say once per month, but that's a bit too unfrequent IMO\n\t\t\t// Also the maximum that setInterval supports is ~24.85 days\n\t\t\t|| Date.now() - lastUpdated > timespan.days(7)\n\t\t);\n\t}\n}\n\n// @publicAPI\nexport type BatteryCCReportOptions =\n\t& {\n\t\tlevel: number | \"low\";\n\t}\n\t& AllOrNone<{\n\t\t// V2+\n\t\tchargingStatus: BatteryChargingStatus;\n\t\trechargeable: boolean;\n\t\tbackup: boolean;\n\t\toverheating: boolean;\n\t\tlowFluid: boolean;\n\t\trechargeOrReplace: BatteryReplacementStatus;\n\t\tdisconnected: boolean;\n\t}>\n\t& AllOrNone<{\n\t\t// V3+\n\t\tlowTemperatureStatus: boolean;\n\t}>;\n\n@CCCommand(BatteryCommand.Report)\n@ccValueProperty(\"level\", BatteryCCValues.level)\n@ccValueProperty(\"chargingStatus\", BatteryCCValues.chargingStatus)\n@ccValueProperty(\"rechargeable\", BatteryCCValues.rechargeable)\n@ccValueProperty(\"backup\", BatteryCCValues.backup)\n@ccValueProperty(\"overheating\", BatteryCCValues.overheating)\n@ccValueProperty(\"lowFluid\", BatteryCCValues.lowFluid)\n@ccValueProperty(\"rechargeOrReplace\", BatteryCCValues.rechargeOrReplace)\n@ccValueProperty(\"disconnected\", BatteryCCValues.disconnected)\n@ccValueProperty(\"lowTemperatureStatus\", BatteryCCValues.lowTemperatureStatus)\nexport class BatteryCCReport extends BatteryCC {\n\tpublic constructor(\n\t\toptions: WithAddress<BatteryCCReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\tthis.level = typeof options.level === \"number\" ? options.level : 0xff;\n\t\tthis.chargingStatus = options.chargingStatus;\n\t\tthis.rechargeable = options.rechargeable;\n\t\tthis.backup = options.backup;\n\t\tthis.overheating = options.overheating;\n\t\tthis.lowFluid = options.lowFluid;\n\t\tthis.rechargeOrReplace = options.rechargeOrReplace;\n\t\tthis.disconnected = options.disconnected;\n\t\tthis.lowTemperatureStatus = options.lowTemperatureStatus;\n\t}\n\n\tpublic static from(raw: CCRaw, ctx: CCParsingContext): BatteryCCReport {\n\t\tlet ccOptions: BatteryCCReportOptions;\n\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst level = raw.payload[0];\n\t\tvalidatePayload.withReason(`Invalid battery level ${level}`)(\n\t\t\t// This field MUST be in the range 0x00..0x64 or set to 0xFF\n\t\t\tlevel <= 100 || level === 0xff,\n\t\t);\n\n\t\tccOptions = {\n\t\t\tlevel,\n\t\t};\n\n\t\tif (raw.payload.length >= 3) {\n\t\t\t// Starting with V2\n\t\t\tconst chargingStatus: BatteryChargingStatus = raw.payload[1] >>> 6;\n\t\t\tconst rechargeable = !!(raw.payload[1] & 0b0010_0000);\n\t\t\tconst backup = !!(raw.payload[1] & 0b0001_0000);\n\t\t\tconst overheating = !!(raw.payload[1] & 0b1000);\n\t\t\tconst lowFluid = !!(raw.payload[1] & 0b0100);\n\t\t\tconst rechargeOrReplace: BatteryReplacementStatus =\n\t\t\t\t!!(raw.payload[1] & 0b10)\n\t\t\t\t\t? BatteryReplacementStatus.Now\n\t\t\t\t\t: !!(raw.payload[1] & 0b1)\n\t\t\t\t\t? BatteryReplacementStatus.Soon\n\t\t\t\t\t: BatteryReplacementStatus.No;\n\t\t\tconst lowTemperatureStatus = !!(raw.payload[2] & 0b10);\n\t\t\tconst disconnected = !!(raw.payload[2] & 0b1);\n\n\t\t\tccOptions = {\n\t\t\t\t...ccOptions,\n\t\t\t\tchargingStatus,\n\t\t\t\trechargeable,\n\t\t\t\tbackup,\n\t\t\t\toverheating,\n\t\t\t\tlowFluid,\n\t\t\t\trechargeOrReplace,\n\t\t\t\tlowTemperatureStatus,\n\t\t\t\tdisconnected,\n\t\t\t};\n\t\t}\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\t...ccOptions,\n\t\t});\n\t}\n\n\tpublic persistValues(ctx: PersistValuesContext): boolean {\n\t\t// This is a bit hacky, but we need to avoid persisting 0xff as the battery level\n\t\t// because the report is meant as a notification in that case.\n\t\tif (this.level === 0xff) {\n\t\t\t// @ts-expect-error\n\t\t\tthis.level = undefined;\n\t\t}\n\n\t\tif (!super.persistValues(ctx)) return false;\n\n\t\tif (this.level === undefined) {\n\t\t\t// @ts-expect-error\n\t\t\tthis.level = 0xff;\n\t\t}\n\n\t\t// Na\u00EFve heuristic for a full battery\n\t\tif (this.level >= 90) {\n\t\t\t// Some devices send Notification CC Reports with battery information,\n\t\t\t// or this information is mapped from legacy V1 alarm values.\n\t\t\t// We may need to idle the corresponding values when the battery is full\n\t\t\tconst notificationCCVersion = ctx.getSupportedCCVersion(\n\t\t\t\tCommandClasses.Notification,\n\t\t\t\tthis.nodeId as number,\n\t\t\t\tthis.endpointIndex,\n\t\t\t);\n\t\t\tif (\n\t\t\t\t// supported\n\t\t\t\tnotificationCCVersion > 0\n\t\t\t\t// but idling is not required\n\t\t\t\t&& notificationCCVersion < 8\n\t\t\t) {\n\t\t\t\tconst batteryLevelStatusValue = NotificationCCValues\n\t\t\t\t\t.notificationVariable(\n\t\t\t\t\t\t\"Power Management\",\n\t\t\t\t\t\t\"Battery level status\",\n\t\t\t\t\t);\n\t\t\t\t// If not undefined and not idle\n\t\t\t\tif (this.getValue(ctx, batteryLevelStatusValue)) {\n\t\t\t\t\tthis.setValue(\n\t\t\t\t\t\tctx,\n\t\t\t\t\t\tbatteryLevelStatusValue,\n\t\t\t\t\t\t0, /* idle */\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tpublic readonly level: number;\n\n\tpublic readonly chargingStatus: BatteryChargingStatus | undefined;\n\n\tpublic readonly rechargeable: boolean | undefined;\n\n\tpublic readonly backup: boolean | undefined;\n\n\tpublic readonly overheating: boolean | undefined;\n\n\tpublic readonly lowFluid: boolean | undefined;\n\n\tpublic readonly rechargeOrReplace: BatteryReplacementStatus | undefined;\n\n\tpublic readonly disconnected: boolean | undefined;\n\n\tpublic readonly lowTemperatureStatus: boolean | undefined;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.from([this.level]);\n\t\tif (this.chargingStatus != undefined) {\n\t\t\tthis.payload = Bytes.concat([\n\t\t\t\tthis.payload,\n\t\t\t\tBytes.from([\n\t\t\t\t\t(this.chargingStatus << 6)\n\t\t\t\t\t+ (this.rechargeable ? 0b0010_0000 : 0)\n\t\t\t\t\t+ (this.backup ? 0b0001_0000 : 0)\n\t\t\t\t\t+ (this.overheating ? 0b1000 : 0)\n\t\t\t\t\t+ (this.lowFluid ? 0b0100 : 0)\n\t\t\t\t\t+ (this.rechargeOrReplace === BatteryReplacementStatus.Now\n\t\t\t\t\t\t? 0b10\n\t\t\t\t\t\t: this.rechargeOrReplace\n\t\t\t\t\t\t\t\t=== BatteryReplacementStatus.Soon\n\t\t\t\t\t\t? 0b1\n\t\t\t\t\t\t: 0),\n\t\t\t\t\t(this.lowTemperatureStatus ? 0b10 : 0)\n\t\t\t\t\t+ (this.disconnected ? 0b1 : 0),\n\t\t\t\t]),\n\t\t\t]);\n\t\t}\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\tconst message: MessageRecord = this.level === 0xff\n\t\t\t? { \"is low\": true }\n\t\t\t: { level: this.level };\n\n\t\tif (this.chargingStatus != undefined) {\n\t\t\tmessage[\"charging status\"] = getEnumMemberName(\n\t\t\t\tBatteryChargingStatus,\n\t\t\t\tthis.chargingStatus,\n\t\t\t);\n\t\t}\n\t\tif (this.rechargeable != undefined) {\n\t\t\tmessage.rechargeable = this.rechargeable;\n\t\t}\n\t\tif (this.backup != undefined) {\n\t\t\tmessage.backup = this.backup;\n\t\t}\n\t\tif (this.overheating != undefined) {\n\t\t\tmessage.overheating = this.overheating;\n\t\t}\n\t\tif (this.lowFluid != undefined) {\n\t\t\tmessage[\"low fluid\"] = this.lowFluid;\n\t\t}\n\t\tif (this.rechargeOrReplace != undefined) {\n\t\t\tmessage[\"recharge or replace\"] = getEnumMemberName(\n\t\t\t\tBatteryReplacementStatus,\n\t\t\t\tthis.rechargeOrReplace,\n\t\t\t);\n\t\t}\n\t\tif (this.lowTemperatureStatus != undefined) {\n\t\t\tmessage.lowTemperatureStatus = this.lowTemperatureStatus;\n\t\t}\n\t\tif (this.disconnected != undefined) {\n\t\t\tmessage.disconnected = this.disconnected;\n\t\t}\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage,\n\t\t};\n\t}\n}\n\n@CCCommand(BatteryCommand.Get)\n@expectedCCResponse(BatteryCCReport)\nexport class BatteryCCGet extends BatteryCC {}\n\n// @publicAPI\nexport interface BatteryCCHealthReportOptions {\n\tmaximumCapacity?: number;\n\ttemperature?: number;\n\ttemperatureScale?: number;\n}\n\n@CCCommand(BatteryCommand.HealthReport)\n@ccValueProperty(\"maximumCapacity\", BatteryCCValues.maximumCapacity)\n@ccValueProperty(\"temperature\", BatteryCCValues.temperature)\nexport class BatteryCCHealthReport extends BatteryCC {\n\tpublic constructor(\n\t\toptions: WithAddress<BatteryCCHealthReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\t// TODO: Check implementation:\n\t\tthis.maximumCapacity = options.maximumCapacity;\n\t\tthis.temperature = options.temperature;\n\t\tthis.temperatureScale = options.temperatureScale;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): BatteryCCHealthReport {\n\t\tvalidatePayload(raw.payload.length >= 2);\n\t\t// Parse maximum capacity. 0xff means unknown\n\t\tlet maximumCapacity: number | undefined = raw.payload[0];\n\t\tif (maximumCapacity === 0xff) maximumCapacity = undefined;\n\t\tconst {\n\t\t\tvalue: temperature,\n\t\t\tscale: temperatureScale,\n\t\t} = parseFloatWithScale(\n\t\t\traw.payload.subarray(1),\n\t\t\ttrue, // The temperature field may be omitted\n\t\t);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tmaximumCapacity,\n\t\t\ttemperature,\n\t\t\ttemperatureScale,\n\t\t});\n\t}\n\n\tpublic readonly maximumCapacity: number | undefined;\n\tpublic readonly temperature: number | undefined;\n\tprivate readonly temperatureScale: number | undefined;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tconst temperature = this.temperature != undefined\n\t\t\t? encodeFloatWithScale(\n\t\t\t\tthis.temperature,\n\t\t\t\tthis.temperatureScale ?? 0x00,\n\t\t\t)\n\t\t\t// size, precision and scale must be 0 if the temperature is omitted\n\t\t\t: Bytes.from([0x00]);\n\n\t\tthis.payload = Bytes.concat([\n\t\t\t[this.maximumCapacity ?? 0xff],\n\t\t\ttemperature,\n\t\t]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: {\n\t\t\t\ttemperature: this.temperature != undefined\n\t\t\t\t\t? this.temperature\n\t\t\t\t\t: \"unknown\",\n\t\t\t\t\"max capacity\": this.maximumCapacity != undefined\n\t\t\t\t\t? `${this.maximumCapacity} %`\n\t\t\t\t\t: \"unknown\",\n\t\t\t},\n\t\t};\n\t}\n}\n\n@CCCommand(BatteryCommand.HealthGet)\n@expectedCCResponse(BatteryCCHealthReport)\nexport class BatteryCCHealthGet extends BatteryCC {}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,kBAsBO;AACP,oBAKO;AACP,iBAMO;AACP,0BAMO;AACP,oCAQO;AACP,oBAAkB;AAClB,mBAIO;AACP,4BAAqC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAsIxB,gBAAY,MAAA;8BADxB,mCAAI,2BAAe,OAAO,CAAC;;;;oBACM;oCAAA,YAAa;WAAA;;;;;;;;AAA/C,mBAAA,MAAA,mBAAA,EAAA,OAAA,WAAA,GAAA,kBAAA,EAAA,MAAA,SAAA,MAAA,WAAA,MAAA,UAAA,UAAA,GAAA,MAAA,uBAAA;;;AAAa,wBAAA,YAAA,uBAAA;;IACL,gBAAgB,KAAmB;AACzC,cAAQ,KAAK;QACZ,KAAK,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,KAAK,QACL,KAAK,aAAa;AAEnB;;UAEC,wBAAwB,KAErB,wBAAwB;UAC1B;AACD,gBAAM,0BAA0B,2CAC9B,qBACA,oBACA,sBAAsB;AAGxB,cAAI,KAAK,SAAS,KAAK,uBAAuB,GAAG;AAChD,iBAAK,SACJ,KACA,yBACA,CAAC;UAEH;QACD;MACD;AAEA,aAAO;IACR;IAEgB;IAEA;IAEA;IAEA;IAEA;IAEA;IAEA;IAEA;IAEA;IAET,UAAU,KAAsB;AACtC,WAAK,UAAU,oBAAM,KAAK,CAAC,KAAK,KAAK,CAAC;AACtC,UAAI,KAAK,kBAAkB,QAAW;AACrC,aAAK,UAAU,oBAAM,OAAO;UAC3B,KAAK;UACL
|
|
4
|
+
"sourcesContent": ["import type { CCEncodingContext, CCParsingContext } from \"@zwave-js/cc\";\nimport type { GetDeviceConfig } from \"@zwave-js/config\";\nimport {\n\tCommandClasses,\n\ttype ControlsCC,\n\ttype EndpointId,\n\ttype GetEndpoint,\n\ttype GetNode,\n\ttype GetSupportedCCVersion,\n\ttype GetValueDB,\n\ttype MaybeNotKnown,\n\ttype MessageOrCCLogEntry,\n\tMessagePriority,\n\ttype MessageRecord,\n\ttype NodeId,\n\ttype SinglecastCC,\n\ttype SupportsCC,\n\tValueMetadata,\n\ttype WithAddress,\n\tencodeFloatWithScale,\n\tenumValuesToMetadataStates,\n\tparseFloatWithScale,\n\ttimespan,\n\tvalidatePayload,\n} from \"@zwave-js/core\";\nimport {\n\ttype AllOrNone,\n\tBytes,\n\tgetEnumMemberName,\n\tpick,\n} from \"@zwave-js/shared\";\nimport {\n\tCCAPI,\n\tPOLL_VALUE,\n\tPhysicalCCAPI,\n\ttype PollValueImplementation,\n\tthrowUnsupportedProperty,\n} from \"../lib/API.js\";\nimport {\n\ttype CCRaw,\n\tCommandClass,\n\ttype InterviewContext,\n\ttype PersistValuesContext,\n\ttype RefreshValuesContext,\n} from \"../lib/CommandClass.js\";\nimport {\n\tAPI,\n\tCCCommand,\n\tccValueProperty,\n\tccValues,\n\tcommandClass,\n\texpectedCCResponse,\n\timplementedVersion,\n} from \"../lib/CommandClassDecorators.js\";\nimport { V } from \"../lib/Values.js\";\nimport {\n\tBatteryChargingStatus,\n\tBatteryCommand,\n\tBatteryReplacementStatus,\n} from \"../lib/_Types.js\";\nimport { NotificationCCValues } from \"./NotificationCC.js\";\n\nexport const BatteryCCValues = V.defineCCValues(CommandClasses.Battery, {\n\t...V.staticProperty(\n\t\t\"level\",\n\t\t{\n\t\t\t...ValueMetadata.ReadOnlyUInt8,\n\t\t\tmax: 100,\n\t\t\tunit: \"%\",\n\t\t\tlabel: \"Battery level\",\n\t\t} as const,\n\t),\n\n\t...V.staticProperty(\n\t\t\"maximumCapacity\",\n\t\t{\n\t\t\t...ValueMetadata.ReadOnlyUInt8,\n\t\t\tmax: 100,\n\t\t\tunit: \"%\",\n\t\t\tlabel: \"Maximum capacity\",\n\t\t} as const,\n\t\t{\n\t\t\tminVersion: 2,\n\t\t} as const,\n\t),\n\n\t...V.staticProperty(\n\t\t\"temperature\",\n\t\t{\n\t\t\t...ValueMetadata.ReadOnlyInt8,\n\t\t\tlabel: \"Temperature\",\n\t\t\t// For now, only \u00B0C is specified as a valid unit\n\t\t\t// If this ever changes, update the unit in persistValues on the fly\n\t\t\tunit: \"\u00B0C\",\n\t\t} as const,\n\t\t{\n\t\t\tminVersion: 2,\n\t\t} as const,\n\t),\n\n\t...V.staticProperty(\n\t\t\"chargingStatus\",\n\t\t{\n\t\t\t...ValueMetadata.ReadOnlyUInt8,\n\t\t\tlabel: \"Charging status\",\n\t\t\tstates: enumValuesToMetadataStates(BatteryChargingStatus),\n\t\t} as const,\n\t\t{\n\t\t\tminVersion: 2,\n\t\t} as const,\n\t),\n\n\t...V.staticProperty(\n\t\t\"rechargeable\",\n\t\t{\n\t\t\t...ValueMetadata.ReadOnlyBoolean,\n\t\t\tlabel: \"Rechargeable\",\n\t\t} as const,\n\t\t{\n\t\t\tminVersion: 2,\n\t\t} as const,\n\t),\n\n\t...V.staticProperty(\n\t\t\"backup\",\n\t\t{\n\t\t\t...ValueMetadata.ReadOnlyBoolean,\n\t\t\tlabel: \"Used as backup\",\n\t\t} as const,\n\t\t{\n\t\t\tminVersion: 2,\n\t\t} as const,\n\t),\n\n\t...V.staticProperty(\n\t\t\"overheating\",\n\t\t{\n\t\t\t...ValueMetadata.ReadOnlyBoolean,\n\t\t\tlabel: \"Overheating\",\n\t\t} as const,\n\t\t{\n\t\t\tminVersion: 2,\n\t\t} as const,\n\t),\n\n\t...V.staticProperty(\n\t\t\"lowFluid\",\n\t\t{\n\t\t\t...ValueMetadata.ReadOnlyBoolean,\n\t\t\tlabel: \"Fluid is low\",\n\t\t} as const,\n\t\t{\n\t\t\tminVersion: 2,\n\t\t} as const,\n\t),\n\n\t...V.staticProperty(\n\t\t\"rechargeOrReplace\",\n\t\t{\n\t\t\t...ValueMetadata.ReadOnlyUInt8,\n\t\t\tlabel: \"Recharge or replace\",\n\t\t\tstates: enumValuesToMetadataStates(BatteryReplacementStatus),\n\t\t} as const,\n\t\t{\n\t\t\tminVersion: 2,\n\t\t} as const,\n\t),\n\n\t...V.staticProperty(\n\t\t\"disconnected\",\n\t\t{\n\t\t\t...ValueMetadata.ReadOnlyBoolean,\n\t\t\tlabel: \"Battery is disconnected\",\n\t\t} as const,\n\t\t{\n\t\t\tminVersion: 2,\n\t\t} as const,\n\t),\n\n\t...V.staticProperty(\n\t\t\"lowTemperatureStatus\",\n\t\t{\n\t\t\t...ValueMetadata.ReadOnlyBoolean,\n\t\t\tlabel: \"Battery temperature is low\",\n\t\t} as const,\n\t\t{\n\t\t\tminVersion: 3,\n\t\t} as const,\n\t),\n});\n\n// @noSetValueAPI This CC is read-only\n\n@API(CommandClasses.Battery)\nexport class BatteryCCAPI extends PhysicalCCAPI {\n\tpublic supportsCommand(cmd: BatteryCommand): MaybeNotKnown<boolean> {\n\t\tswitch (cmd) {\n\t\t\tcase BatteryCommand.Get:\n\t\t\t\treturn true; // This is mandatory\n\t\t\tcase BatteryCommand.HealthGet:\n\t\t\t\treturn this.version >= 2;\n\t\t}\n\t\treturn super.supportsCommand(cmd);\n\t}\n\n\tprotected get [POLL_VALUE](): PollValueImplementation {\n\t\treturn async function(this: BatteryCCAPI, { property }) {\n\t\t\tswitch (property) {\n\t\t\t\tcase \"level\":\n\t\t\t\tcase \"chargingStatus\":\n\t\t\t\tcase \"rechargeable\":\n\t\t\t\tcase \"backup\":\n\t\t\t\tcase \"overheating\":\n\t\t\t\tcase \"lowFluid\":\n\t\t\t\tcase \"rechargeOrReplace\":\n\t\t\t\tcase \"lowTemperatureStatus\":\n\t\t\t\tcase \"disconnected\":\n\t\t\t\t\treturn (await this.get())?.[property];\n\n\t\t\t\tcase \"maximumCapacity\":\n\t\t\t\tcase \"temperature\":\n\t\t\t\t\treturn (await this.getHealth())?.[property];\n\n\t\t\t\tdefault:\n\t\t\t\t\tthrowUnsupportedProperty(this.ccId, property);\n\t\t\t}\n\t\t};\n\t}\n\n\t// oxlint-disable-next-line typescript/explicit-module-boundary-types\n\tpublic async get() {\n\t\tthis.assertSupportsCommand(BatteryCommand, BatteryCommand.Get);\n\n\t\tconst cc = new BatteryCCGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tconst response = await this.host.sendCommand<BatteryCCReport>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\tif (response) {\n\t\t\treturn pick(response, [\n\t\t\t\t\"level\",\n\t\t\t\t\"chargingStatus\",\n\t\t\t\t\"rechargeable\",\n\t\t\t\t\"backup\",\n\t\t\t\t\"overheating\",\n\t\t\t\t\"lowFluid\",\n\t\t\t\t\"rechargeOrReplace\",\n\t\t\t\t\"lowTemperatureStatus\",\n\t\t\t\t\"disconnected\",\n\t\t\t]);\n\t\t}\n\t}\n\n\t// oxlint-disable-next-line typescript/explicit-module-boundary-types\n\tpublic async getHealth() {\n\t\tthis.assertSupportsCommand(BatteryCommand, BatteryCommand.HealthGet);\n\n\t\tconst cc = new BatteryCCHealthGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tconst response = await this.host.sendCommand<BatteryCCHealthReport>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\tif (response) {\n\t\t\treturn pick(response, [\"maximumCapacity\", \"temperature\"]);\n\t\t}\n\t}\n}\n\n@commandClass(CommandClasses.Battery)\n@implementedVersion(3)\n@ccValues(BatteryCCValues)\nexport class BatteryCC extends CommandClass {\n\tdeclare ccCommand: BatteryCommand;\n\n\tpublic async interview(\n\t\tctx: InterviewContext,\n\t): Promise<void> {\n\t\tconst node = this.getNode(ctx)!;\n\n\t\tctx.logNode(node.id, {\n\t\t\tendpoint: this.endpointIndex,\n\t\t\tmessage: `Interviewing ${this.ccName}...`,\n\t\t\tdirection: \"none\",\n\t\t});\n\n\t\t// Query the Battery status\n\t\tawait this.refreshValues(ctx);\n\n\t\t// Remember that the interview is complete\n\t\tthis.setInterviewComplete(ctx, true);\n\t}\n\n\tpublic async refreshValues(\n\t\tctx: RefreshValuesContext,\n\t): Promise<void> {\n\t\tconst node = this.getNode(ctx)!;\n\t\tconst endpoint = this.getEndpoint(ctx)!;\n\t\tconst api = CCAPI.create(\n\t\t\tCommandClasses.Battery,\n\t\t\tctx,\n\t\t\tendpoint,\n\t\t).withOptions({\n\t\t\tpriority: MessagePriority.NodeQuery,\n\t\t});\n\n\t\tctx.logNode(node.id, {\n\t\t\tendpoint: this.endpointIndex,\n\t\t\tmessage: \"querying battery status...\",\n\t\t\tdirection: \"outbound\",\n\t\t});\n\n\t\tconst batteryStatus = await api.get();\n\t\tif (batteryStatus) {\n\t\t\tlet logMessage = `received response for battery information:\nlevel: ${\n\t\t\t\tbatteryStatus.level === 0xff\n\t\t\t\t\t? \"low\"\n\t\t\t\t\t: (batteryStatus.level + \" %\")\n\t\t\t}`;\n\t\t\tif (api.version >= 2) {\n\t\t\t\tlogMessage += `\nstatus: ${\n\t\t\t\t\tBatteryChargingStatus[batteryStatus.chargingStatus!]\n\t\t\t\t}\nrechargeable: ${batteryStatus.rechargeable}\nis backup: ${batteryStatus.backup}\nis overheating: ${batteryStatus.overheating}\nfluid is low: ${batteryStatus.lowFluid}\nneeds to be replaced or charged: ${\n\t\t\t\t\tBatteryReplacementStatus[batteryStatus.rechargeOrReplace!]\n\t\t\t\t}\nis low temperature ${batteryStatus.lowTemperatureStatus}\nis disconnected: ${batteryStatus.disconnected}`;\n\t\t\t}\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\tmessage: logMessage,\n\t\t\t\tdirection: \"inbound\",\n\t\t\t});\n\t\t}\n\n\t\tif (api.version >= 2) {\n\t\t\t// always query the health\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\tmessage: \"querying battery health...\",\n\t\t\t\tdirection: \"outbound\",\n\t\t\t});\n\n\t\t\tconst batteryHealth = await api.getHealth();\n\t\t\tif (batteryHealth) {\n\t\t\t\tconst logMessage = `received response for battery health:\nmax. capacity: ${batteryHealth.maximumCapacity} %\ntemperature: ${batteryHealth.temperature} \u00B0C`;\n\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\t\tmessage: logMessage,\n\t\t\t\t\tdirection: \"inbound\",\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic shouldRefreshValues(\n\t\tthis: SinglecastCC<this>,\n\t\tctx:\n\t\t\t& GetValueDB\n\t\t\t& GetSupportedCCVersion\n\t\t\t& GetDeviceConfig\n\t\t\t& GetNode<\n\t\t\t\tNodeId & GetEndpoint<EndpointId & SupportsCC & ControlsCC>\n\t\t\t>,\n\t): boolean {\n\t\t// Check when the battery state was last updated\n\t\tconst valueDB = ctx.tryGetValueDB(this.nodeId);\n\t\tif (!valueDB) return true;\n\n\t\tconst lastUpdated = valueDB.getTimestamp(\n\t\t\tBatteryCCValues.level.endpoint(this.endpointIndex),\n\t\t);\n\t\treturn (\n\t\t\tlastUpdated == undefined\n\t\t\t// The specs say once per month, but that's a bit too unfrequent IMO\n\t\t\t// Also the maximum that setInterval supports is ~24.85 days\n\t\t\t|| Date.now() - lastUpdated > timespan.days(7)\n\t\t);\n\t}\n}\n\n// @publicAPI\nexport type BatteryCCReportOptions =\n\t& {\n\t\tlevel: number | \"low\";\n\t}\n\t& AllOrNone<{\n\t\t// V2+\n\t\tchargingStatus: BatteryChargingStatus;\n\t\trechargeable: boolean;\n\t\tbackup: boolean;\n\t\toverheating: boolean;\n\t\tlowFluid: boolean;\n\t\trechargeOrReplace: BatteryReplacementStatus;\n\t\tdisconnected: boolean;\n\t}>\n\t& AllOrNone<{\n\t\t// V3+\n\t\tlowTemperatureStatus: boolean;\n\t}>;\n\n@CCCommand(BatteryCommand.Report)\n@ccValueProperty(\"level\", BatteryCCValues.level)\n@ccValueProperty(\"chargingStatus\", BatteryCCValues.chargingStatus)\n@ccValueProperty(\"rechargeable\", BatteryCCValues.rechargeable)\n@ccValueProperty(\"backup\", BatteryCCValues.backup)\n@ccValueProperty(\"overheating\", BatteryCCValues.overheating)\n@ccValueProperty(\"lowFluid\", BatteryCCValues.lowFluid)\n@ccValueProperty(\"rechargeOrReplace\", BatteryCCValues.rechargeOrReplace)\n@ccValueProperty(\"disconnected\", BatteryCCValues.disconnected)\n@ccValueProperty(\"lowTemperatureStatus\", BatteryCCValues.lowTemperatureStatus)\nexport class BatteryCCReport extends BatteryCC {\n\tpublic constructor(\n\t\toptions: WithAddress<BatteryCCReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\tthis.level = typeof options.level === \"number\" ? options.level : 0xff;\n\t\tthis.chargingStatus = options.chargingStatus;\n\t\tthis.rechargeable = options.rechargeable;\n\t\tthis.backup = options.backup;\n\t\tthis.overheating = options.overheating;\n\t\tthis.lowFluid = options.lowFluid;\n\t\tthis.rechargeOrReplace = options.rechargeOrReplace;\n\t\tthis.disconnected = options.disconnected;\n\t\tthis.lowTemperatureStatus = options.lowTemperatureStatus;\n\t}\n\n\tpublic static from(raw: CCRaw, ctx: CCParsingContext): BatteryCCReport {\n\t\tlet ccOptions: BatteryCCReportOptions;\n\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst level = raw.payload[0];\n\t\tvalidatePayload.withReason(`Invalid battery level ${level}`)(\n\t\t\t// This field MUST be in the range 0x00..0x64 or set to 0xFF\n\t\t\tlevel <= 100 || level === 0xff,\n\t\t);\n\n\t\tccOptions = {\n\t\t\tlevel,\n\t\t};\n\n\t\tif (raw.payload.length >= 3) {\n\t\t\t// Starting with V2\n\t\t\tconst chargingStatus: BatteryChargingStatus = raw.payload[1] >>> 6;\n\t\t\tconst rechargeable = !!(raw.payload[1] & 0b0010_0000);\n\t\t\tconst backup = !!(raw.payload[1] & 0b0001_0000);\n\t\t\tconst overheating = !!(raw.payload[1] & 0b1000);\n\t\t\tconst lowFluid = !!(raw.payload[1] & 0b0100);\n\t\t\tconst rechargeOrReplace: BatteryReplacementStatus =\n\t\t\t\t!!(raw.payload[1] & 0b10)\n\t\t\t\t\t? BatteryReplacementStatus.Now\n\t\t\t\t\t: !!(raw.payload[1] & 0b1)\n\t\t\t\t\t? BatteryReplacementStatus.Soon\n\t\t\t\t\t: BatteryReplacementStatus.No;\n\t\t\tconst lowTemperatureStatus = !!(raw.payload[2] & 0b10);\n\t\t\tconst disconnected = !!(raw.payload[2] & 0b1);\n\n\t\t\tccOptions = {\n\t\t\t\t...ccOptions,\n\t\t\t\tchargingStatus,\n\t\t\t\trechargeable,\n\t\t\t\tbackup,\n\t\t\t\toverheating,\n\t\t\t\tlowFluid,\n\t\t\t\trechargeOrReplace,\n\t\t\t\tlowTemperatureStatus,\n\t\t\t\tdisconnected,\n\t\t\t};\n\t\t}\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\t...ccOptions,\n\t\t});\n\t}\n\n\tpublic persistValues(ctx: PersistValuesContext): boolean {\n\t\t// This is a bit hacky, but we need to avoid persisting 0xff as the battery level\n\t\t// because the report is meant as a notification in that case.\n\t\tif (this.level === 0xff) {\n\t\t\t// @ts-expect-error\n\t\t\tthis.level = undefined;\n\t\t}\n\n\t\tif (!super.persistValues(ctx)) return false;\n\n\t\tif (this.level === undefined) {\n\t\t\t// @ts-expect-error\n\t\t\tthis.level = 0xff;\n\t\t}\n\n\t\t// Na\u00EFve heuristic for a full battery\n\t\tif (this.level >= 90) {\n\t\t\t// Some devices send Notification CC Reports with battery information,\n\t\t\t// or this information is mapped from legacy V1 alarm values.\n\t\t\t// We may need to idle the corresponding values when the battery is full\n\t\t\tconst notificationCCVersion = ctx.getSupportedCCVersion(\n\t\t\t\tCommandClasses.Notification,\n\t\t\t\tthis.nodeId as number,\n\t\t\t\tthis.endpointIndex,\n\t\t\t);\n\t\t\tif (\n\t\t\t\t// supported\n\t\t\t\tnotificationCCVersion > 0\n\t\t\t\t// but idling is not required\n\t\t\t\t&& notificationCCVersion < 8\n\t\t\t) {\n\t\t\t\tconst batteryLevelStatusValue = NotificationCCValues\n\t\t\t\t\t.notificationVariable(\n\t\t\t\t\t\t\"Power Management\",\n\t\t\t\t\t\t\"Battery level status\",\n\t\t\t\t\t);\n\t\t\t\t// If not undefined and not idle\n\t\t\t\tif (this.getValue(ctx, batteryLevelStatusValue)) {\n\t\t\t\t\tthis.setValue(\n\t\t\t\t\t\tctx,\n\t\t\t\t\t\tbatteryLevelStatusValue,\n\t\t\t\t\t\t0, /* idle */\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tpublic readonly level: number;\n\n\tpublic readonly chargingStatus: BatteryChargingStatus | undefined;\n\n\tpublic readonly rechargeable: boolean | undefined;\n\n\tpublic readonly backup: boolean | undefined;\n\n\tpublic readonly overheating: boolean | undefined;\n\n\tpublic readonly lowFluid: boolean | undefined;\n\n\tpublic readonly rechargeOrReplace: BatteryReplacementStatus | undefined;\n\n\tpublic readonly disconnected: boolean | undefined;\n\n\tpublic readonly lowTemperatureStatus: boolean | undefined;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.from([this.level]);\n\t\tif (this.chargingStatus != undefined) {\n\t\t\tthis.payload = Bytes.concat([\n\t\t\t\tthis.payload,\n\t\t\t\t[\n\t\t\t\t\t(this.chargingStatus << 6)\n\t\t\t\t\t+ (this.rechargeable ? 0b0010_0000 : 0)\n\t\t\t\t\t+ (this.backup ? 0b0001_0000 : 0)\n\t\t\t\t\t+ (this.overheating ? 0b1000 : 0)\n\t\t\t\t\t+ (this.lowFluid ? 0b0100 : 0)\n\t\t\t\t\t+ (this.rechargeOrReplace === BatteryReplacementStatus.Now\n\t\t\t\t\t\t? 0b10\n\t\t\t\t\t\t: this.rechargeOrReplace\n\t\t\t\t\t\t\t\t=== BatteryReplacementStatus.Soon\n\t\t\t\t\t\t? 0b1\n\t\t\t\t\t\t: 0),\n\t\t\t\t\t(this.lowTemperatureStatus ? 0b10 : 0)\n\t\t\t\t\t+ (this.disconnected ? 0b1 : 0),\n\t\t\t\t],\n\t\t\t]);\n\t\t}\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\tconst message: MessageRecord = this.level === 0xff\n\t\t\t? { \"is low\": true }\n\t\t\t: { level: this.level };\n\n\t\tif (this.chargingStatus != undefined) {\n\t\t\tmessage[\"charging status\"] = getEnumMemberName(\n\t\t\t\tBatteryChargingStatus,\n\t\t\t\tthis.chargingStatus,\n\t\t\t);\n\t\t}\n\t\tif (this.rechargeable != undefined) {\n\t\t\tmessage.rechargeable = this.rechargeable;\n\t\t}\n\t\tif (this.backup != undefined) {\n\t\t\tmessage.backup = this.backup;\n\t\t}\n\t\tif (this.overheating != undefined) {\n\t\t\tmessage.overheating = this.overheating;\n\t\t}\n\t\tif (this.lowFluid != undefined) {\n\t\t\tmessage[\"low fluid\"] = this.lowFluid;\n\t\t}\n\t\tif (this.rechargeOrReplace != undefined) {\n\t\t\tmessage[\"recharge or replace\"] = getEnumMemberName(\n\t\t\t\tBatteryReplacementStatus,\n\t\t\t\tthis.rechargeOrReplace,\n\t\t\t);\n\t\t}\n\t\tif (this.lowTemperatureStatus != undefined) {\n\t\t\tmessage.lowTemperatureStatus = this.lowTemperatureStatus;\n\t\t}\n\t\tif (this.disconnected != undefined) {\n\t\t\tmessage.disconnected = this.disconnected;\n\t\t}\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage,\n\t\t};\n\t}\n}\n\n@CCCommand(BatteryCommand.Get)\n@expectedCCResponse(BatteryCCReport)\nexport class BatteryCCGet extends BatteryCC {}\n\n// @publicAPI\nexport interface BatteryCCHealthReportOptions {\n\tmaximumCapacity?: number;\n\ttemperature?: number;\n\ttemperatureScale?: number;\n}\n\n@CCCommand(BatteryCommand.HealthReport)\n@ccValueProperty(\"maximumCapacity\", BatteryCCValues.maximumCapacity)\n@ccValueProperty(\"temperature\", BatteryCCValues.temperature)\nexport class BatteryCCHealthReport extends BatteryCC {\n\tpublic constructor(\n\t\toptions: WithAddress<BatteryCCHealthReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\t// TODO: Check implementation:\n\t\tthis.maximumCapacity = options.maximumCapacity;\n\t\tthis.temperature = options.temperature;\n\t\tthis.temperatureScale = options.temperatureScale;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): BatteryCCHealthReport {\n\t\tvalidatePayload(raw.payload.length >= 2);\n\t\t// Parse maximum capacity. 0xff means unknown\n\t\tlet maximumCapacity: number | undefined = raw.payload[0];\n\t\tif (maximumCapacity === 0xff) maximumCapacity = undefined;\n\t\tconst {\n\t\t\tvalue: temperature,\n\t\t\tscale: temperatureScale,\n\t\t} = parseFloatWithScale(\n\t\t\traw.payload.subarray(1),\n\t\t\ttrue, // The temperature field may be omitted\n\t\t);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tmaximumCapacity,\n\t\t\ttemperature,\n\t\t\ttemperatureScale,\n\t\t});\n\t}\n\n\tpublic readonly maximumCapacity: number | undefined;\n\tpublic readonly temperature: number | undefined;\n\tprivate readonly temperatureScale: number | undefined;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tconst temperature = this.temperature != undefined\n\t\t\t? encodeFloatWithScale(\n\t\t\t\tthis.temperature,\n\t\t\t\tthis.temperatureScale ?? 0x00,\n\t\t\t)\n\t\t\t// size, precision and scale must be 0 if the temperature is omitted\n\t\t\t: Bytes.from([0x00]);\n\n\t\tthis.payload = Bytes.concat([\n\t\t\t[this.maximumCapacity ?? 0xff],\n\t\t\ttemperature,\n\t\t]);\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: {\n\t\t\t\ttemperature: this.temperature != undefined\n\t\t\t\t\t? this.temperature\n\t\t\t\t\t: \"unknown\",\n\t\t\t\t\"max capacity\": this.maximumCapacity != undefined\n\t\t\t\t\t? `${this.maximumCapacity} %`\n\t\t\t\t\t: \"unknown\",\n\t\t\t},\n\t\t};\n\t}\n}\n\n@CCCommand(BatteryCommand.HealthGet)\n@expectedCCResponse(BatteryCCHealthReport)\nexport class BatteryCCHealthGet extends BatteryCC {}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,kBAsBO;AACP,oBAKO;AACP,iBAMO;AACP,0BAMO;AACP,oCAQO;AACP,oBAAkB;AAClB,mBAIO;AACP,4BAAqC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAsIxB,gBAAY,MAAA;8BADxB,mCAAI,2BAAe,OAAO,CAAC;;;;oBACM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B,uCAAgB,IAAI,QAAQ,UAAU,CAAC;AAEvC,UAAI,kBAAsC,IAAI,QAAQ,CAAC;AACvD,UAAI,oBAAoB;AAAM,0BAAkB;AAChD,YAAM,EACL,OAAO,aACP,OAAO,iBAAgB,QACpB,iCACH,IAAI,QAAQ,SAAS,CAAC,GACtB,IAAI;AAGL,aAAO,IAAI,KAAK;QACf,QAAQ,IAAI;QACZ;QACA;QACA;OACA;IACF;IAEgB;IACA;IACC;IAEV,UAAU,KAAsB;AACtC,YAAM,cAAc,KAAK,eAAe,aACrC,kCACD,KAAK,aACL,KAAK,oBAAoB,CAAI,IAG5B,oBAAM,KAAK,CAAC,CAAI,CAAC;AAEpB,WAAK,UAAU,oBAAM,OAAO;QAC3B,CAAC,KAAK,mBAAmB,GAAI;QAC7B;OACA;AACD,aAAO,MAAM,UAAU,GAAG;IAC3B;IAEO,WAAW,KAAgB;AACjC,aAAO;QACN,GAAG,MAAM,WAAW,GAAG;QACvB,SAAS;UACR,aAAa,KAAK,eAAe,SAC9B,KAAK,cACL;UACH,gBAAgB,KAAK,mBAAmB,SACrC,GAAG,KAAK,eAAe,OACvB;;;IAGN;;;;IAKY,sBAAkB,MAAA;8BAF9B,yCAAU,4BAAe,SAAS,OAClC,kDAAmB,qBAAqB,CAAC;;;;oBACF;0CAAA,YAAS;WAAA;;;;;;;;AAAjD,mBAAA,MAAA,mBAAA,EAAA,OAAA,WAAA,GAAA,kBAAA,EAAA,MAAA,SAAA,MAAA,WAAA,MAAA,UAAA,UAAA,GAAA,MAAA,uBAAA;;;AAAa,wBAAA,YAAA,uBAAA;;;;;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -387,10 +387,10 @@ let BinarySwitchCCReport = (() => {
|
|
|
387
387
|
if (this.targetValue !== void 0) {
|
|
388
388
|
this.payload = import_shared.Bytes.concat([
|
|
389
389
|
this.payload,
|
|
390
|
-
|
|
390
|
+
[
|
|
391
391
|
(0, import_core.encodeMaybeBoolean)(this.targetValue),
|
|
392
392
|
(this.duration ?? import_core.Duration.default()).serializeReport()
|
|
393
|
-
]
|
|
393
|
+
]
|
|
394
394
|
]);
|
|
395
395
|
}
|
|
396
396
|
return super.serialize(ctx);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cc/BinarySwitchCC.ts"],
|
|
4
|
-
"sourcesContent": ["import type { CCEncodingContext, CCParsingContext } from \"@zwave-js/cc\";\nimport {\n\tCommandClasses,\n\tDuration,\n\ttype GetValueDB,\n\ttype MaybeNotKnown,\n\ttype MaybeUnknown,\n\ttype MessageOrCCLogEntry,\n\tMessagePriority,\n\ttype MessageRecord,\n\ttype SupervisionResult,\n\tUNKNOWN_STATE,\n\tValueMetadata,\n\ttype WithAddress,\n\tencodeMaybeBoolean,\n\tmaybeUnknownToString,\n\tparseMaybeBoolean,\n\tvalidatePayload,\n} from \"@zwave-js/core\";\nimport { Bytes } from \"@zwave-js/shared\";\nimport { validateArgs } from \"@zwave-js/transformers\";\nimport {\n\tCCAPI,\n\tPOLL_VALUE,\n\ttype PollValueImplementation,\n\tSET_VALUE,\n\tSET_VALUE_HOOKS,\n\ttype SetValueImplementation,\n\ttype SetValueImplementationHooksFactory,\n\tthrowUnsupportedProperty,\n\tthrowWrongValueType,\n} from \"../lib/API.js\";\nimport {\n\ttype CCRaw,\n\tCommandClass,\n\ttype InterviewContext,\n\ttype RefreshValuesContext,\n\tgetEffectiveCCVersion,\n} from \"../lib/CommandClass.js\";\nimport {\n\tAPI,\n\tCCCommand,\n\tccValueProperty,\n\tccValues,\n\tcommandClass,\n\texpectedCCResponse,\n\timplementedVersion,\n\tuseSupervision,\n} from \"../lib/CommandClassDecorators.js\";\nimport { V } from \"../lib/Values.js\";\nimport { BinarySwitchCommand } from \"../lib/_Types.js\";\n\nexport const BinarySwitchCCValues = V.defineCCValues(\n\tCommandClasses[\"Binary Switch\"],\n\t{\n\t\t...V.staticProperty(\n\t\t\t\"currentValue\",\n\t\t\t{\n\t\t\t\t...ValueMetadata.ReadOnlyBoolean,\n\t\t\t\tlabel: \"Current value\",\n\t\t\t} as const,\n\t\t),\n\t\t...V.staticProperty(\n\t\t\t\"targetValue\",\n\t\t\t{\n\t\t\t\t...ValueMetadata.Boolean,\n\t\t\t\tlabel: \"Target value\",\n\t\t\t\tvalueChangeOptions: [\"transitionDuration\"],\n\t\t\t} as const,\n\t\t),\n\t\t...V.staticProperty(\n\t\t\t\"duration\",\n\t\t\t{\n\t\t\t\t...ValueMetadata.ReadOnlyDuration,\n\t\t\t\tlabel: \"Remaining duration\",\n\t\t\t} as const,\n\t\t\t{ minVersion: 2 } as const,\n\t\t),\n\t},\n);\n\n@API(CommandClasses[\"Binary Switch\"])\nexport class BinarySwitchCCAPI extends CCAPI {\n\tpublic supportsCommand(cmd: BinarySwitchCommand): MaybeNotKnown<boolean> {\n\t\tswitch (cmd) {\n\t\t\tcase BinarySwitchCommand.Get:\n\t\t\t\treturn this.isSinglecast();\n\t\t\tcase BinarySwitchCommand.Set:\n\t\t\t\treturn true;\n\t\t}\n\t\treturn super.supportsCommand(cmd);\n\t}\n\n\t// oxlint-disable-next-line typescript/explicit-module-boundary-types\n\tpublic async get() {\n\t\tthis.assertSupportsCommand(\n\t\t\tBinarySwitchCommand,\n\t\t\tBinarySwitchCommand.Get,\n\t\t);\n\n\t\tconst cc = new BinarySwitchCCGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tconst response = await this.host.sendCommand<BinarySwitchCCReport>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\tif (response) {\n\t\t\treturn {\n\t\t\t\t// interpret unknown values as false\n\t\t\t\tcurrentValue: response.currentValue || false,\n\t\t\t\ttargetValue: response.targetValue,\n\t\t\t\tduration: response.duration,\n\t\t\t};\n\t\t}\n\t}\n\n\t/**\n\t * Sets the switch to the given value\n\t * @param targetValue The target value to set\n\t * @param duration The duration after which the target value should be reached. Can be a Duration instance or a user-friendly duration string like `\"1m17s\"`. Only supported in V2 and above.\n\t */\n\t@validateArgs()\n\tpublic async set(\n\t\ttargetValue: boolean,\n\t\tduration?: Duration | string,\n\t): Promise<SupervisionResult | undefined> {\n\t\tthis.assertSupportsCommand(\n\t\t\tBinarySwitchCommand,\n\t\t\tBinarySwitchCommand.Set,\n\t\t);\n\n\t\tconst cc = new BinarySwitchCCSet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\ttargetValue,\n\t\t\tduration,\n\t\t});\n\t\treturn this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\tprotected override get [SET_VALUE](): SetValueImplementation {\n\t\treturn async function(\n\t\t\tthis: BinarySwitchCCAPI,\n\t\t\t{ property },\n\t\t\tvalue,\n\t\t\toptions,\n\t\t) {\n\t\t\tif (property !== \"targetValue\") {\n\t\t\t\tthrowUnsupportedProperty(this.ccId, property);\n\t\t\t}\n\t\t\tif (typeof value !== \"boolean\") {\n\t\t\t\tthrowWrongValueType(\n\t\t\t\t\tthis.ccId,\n\t\t\t\t\tproperty,\n\t\t\t\t\t\"boolean\",\n\t\t\t\t\ttypeof value,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst duration = Duration.from(options?.transitionDuration);\n\t\t\treturn this.set(value, duration);\n\t\t};\n\t}\n\n\tprotected [SET_VALUE_HOOKS]: SetValueImplementationHooksFactory = (\n\t\t{ property },\n\t\tvalue,\n\t\toptions,\n\t) => {\n\t\tif (property === \"targetValue\") {\n\t\t\tconst currentValueValueId = BinarySwitchCCValues.currentValue\n\t\t\t\t.endpoint(this.endpoint.index);\n\n\t\t\treturn {\n\t\t\t\toptimisticallyUpdateRelatedValues: (\n\t\t\t\t\t_supervisedAndSuccessful,\n\t\t\t\t) => {\n\t\t\t\t\t// After setting targetValue, optimistically update currentValue\n\t\t\t\t\tif (this.isSinglecast()) {\n\t\t\t\t\t\tthis.tryGetValueDB()?.setValue(\n\t\t\t\t\t\t\tcurrentValueValueId,\n\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t);\n\t\t\t\t\t} else if (this.isMulticast()) {\n\t\t\t\t\t\t// Figure out which nodes were affected by this command\n\t\t\t\t\t\tconst affectedNodes = this.endpoint.node.physicalNodes\n\t\t\t\t\t\t\t.filter((node) =>\n\t\t\t\t\t\t\t\tnode\n\t\t\t\t\t\t\t\t\t.getEndpoint(this.endpoint.index)\n\t\t\t\t\t\t\t\t\t?.supportsCC(this.ccId)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t// and optimistically update the currentValue\n\t\t\t\t\t\tfor (const node of affectedNodes) {\n\t\t\t\t\t\t\tthis.host\n\t\t\t\t\t\t\t\t.tryGetValueDB(node.id)\n\t\t\t\t\t\t\t\t?.setValue(currentValueValueId, value);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\n\t\t\t\tverifyChanges: () => {\n\t\t\t\t\tif (this.isSinglecast()) {\n\t\t\t\t\t\t// We query currentValue instead of targetValue to make sure that unsolicited updates cancel the scheduled poll\n\t\t\t\t\t\tthis.schedulePoll(currentValueValueId, value, {\n\t\t\t\t\t\t\tduration: Duration.from(\n\t\t\t\t\t\t\t\toptions?.transitionDuration,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t// on/off \"transitions\" are usually fast\n\t\t\t\t\t\t\ttransition: \"fast\",\n\t\t\t\t\t\t});\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// For multicasts, do not schedule a refresh - this could cause a LOT of traffic\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t};\n\n\tprotected get [POLL_VALUE](): PollValueImplementation {\n\t\treturn async function(this: BinarySwitchCCAPI, { property }) {\n\t\t\tswitch (property) {\n\t\t\t\tcase \"currentValue\":\n\t\t\t\tcase \"targetValue\":\n\t\t\t\tcase \"duration\":\n\t\t\t\t\treturn (await this.get())?.[property];\n\t\t\t\tdefault:\n\t\t\t\t\tthrowUnsupportedProperty(this.ccId, property);\n\t\t\t}\n\t\t};\n\t}\n}\n\n@commandClass(CommandClasses[\"Binary Switch\"])\n@implementedVersion(2)\n@ccValues(BinarySwitchCCValues)\nexport class BinarySwitchCC extends CommandClass {\n\tdeclare ccCommand: BinarySwitchCommand;\n\n\tpublic async interview(\n\t\tctx: InterviewContext,\n\t): Promise<void> {\n\t\tconst node = this.getNode(ctx)!;\n\n\t\tctx.logNode(node.id, {\n\t\t\tendpoint: this.endpointIndex,\n\t\t\tmessage: `Interviewing ${this.ccName}...`,\n\t\t\tdirection: \"none\",\n\t\t});\n\n\t\tawait this.refreshValues(ctx);\n\n\t\t// Remember that the interview is complete\n\t\tthis.setInterviewComplete(ctx, true);\n\t}\n\n\tpublic async refreshValues(\n\t\tctx: RefreshValuesContext,\n\t): Promise<void> {\n\t\tconst node = this.getNode(ctx)!;\n\t\tconst endpoint = this.getEndpoint(ctx)!;\n\t\tconst api = CCAPI.create(\n\t\t\tCommandClasses[\"Binary Switch\"],\n\t\t\tctx,\n\t\t\tendpoint,\n\t\t).withOptions({\n\t\t\tpriority: MessagePriority.NodeQuery,\n\t\t});\n\n\t\t// Query the current state\n\t\tctx.logNode(node.id, {\n\t\t\tendpoint: this.endpointIndex,\n\t\t\tmessage: \"querying Binary Switch state...\",\n\t\t\tdirection: \"outbound\",\n\t\t});\n\n\t\tconst resp = await api.get();\n\t\tif (resp) {\n\t\t\tlet logMessage = `received Binary Switch state:\ncurrent value: ${resp.currentValue}`;\n\t\t\tif (resp.targetValue != undefined) {\n\t\t\t\tlogMessage += `\ntarget value: ${resp.targetValue}\nremaining duration: ${resp.duration?.toString() ?? \"undefined\"}`;\n\t\t\t}\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\tmessage: logMessage,\n\t\t\t\tdirection: \"inbound\",\n\t\t\t});\n\t\t}\n\t}\n\n\tpublic setMappedBasicValue(\n\t\tctx: GetValueDB,\n\t\tvalue: number,\n\t): boolean {\n\t\tthis.setValue(ctx, BinarySwitchCCValues.currentValue, value > 0);\n\t\treturn true;\n\t}\n}\n\n// @publicAPI\nexport interface BinarySwitchCCSetOptions {\n\ttargetValue: boolean;\n\tduration?: Duration | string;\n}\n\n@CCCommand(BinarySwitchCommand.Set)\n@useSupervision()\nexport class BinarySwitchCCSet extends BinarySwitchCC {\n\tpublic constructor(\n\t\toptions: WithAddress<BinarySwitchCCSetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.targetValue = options.targetValue;\n\t\tthis.duration = Duration.from(options.duration);\n\t}\n\n\tpublic static from(raw: CCRaw, ctx: CCParsingContext): BinarySwitchCCSet {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst targetValue = !!raw.payload[0];\n\t\tlet duration: Duration | undefined;\n\n\t\tif (raw.payload.length >= 2) {\n\t\t\tduration = Duration.parseSet(raw.payload[1]);\n\t\t}\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\ttargetValue,\n\t\t\tduration,\n\t\t});\n\t}\n\n\tpublic targetValue: boolean;\n\tpublic duration: Duration | undefined;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.from([\n\t\t\tthis.targetValue ? 0xff : 0x00,\n\t\t\t(this.duration ?? Duration.default()).serializeSet(),\n\t\t]);\n\n\t\tconst ccVersion = getEffectiveCCVersion(ctx, this);\n\t\tif (\n\t\t\tccVersion < 2 && ctx.getDeviceConfig?.(\n\t\t\t\tthis.nodeId as number,\n\t\t\t)?.compat?.encodeCCsUsingTargetVersion\n\t\t) {\n\t\t\t// When forcing CC version 1, only send the target value\n\t\t\tthis.payload = this.payload.subarray(0, 1);\n\t\t}\n\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\tconst message: MessageRecord = {\n\t\t\t\"target value\": this.targetValue,\n\t\t};\n\t\tif (this.duration != undefined) {\n\t\t\tmessage.duration = this.duration.toString();\n\t\t}\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage,\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport interface BinarySwitchCCReportOptions {\n\tcurrentValue?: MaybeUnknown<boolean>;\n\ttargetValue?: MaybeUnknown<boolean>;\n\tduration?: Duration | string;\n}\n\n@CCCommand(BinarySwitchCommand.Report)\n@ccValueProperty(\"currentValue\", BinarySwitchCCValues.currentValue)\n@ccValueProperty(\"targetValue\", BinarySwitchCCValues.targetValue)\n@ccValueProperty(\"duration\", BinarySwitchCCValues.duration)\nexport class BinarySwitchCCReport extends BinarySwitchCC {\n\tpublic constructor(\n\t\toptions: WithAddress<BinarySwitchCCReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\tthis.currentValue = options.currentValue;\n\t\tthis.targetValue = options.targetValue;\n\t\tthis.duration = Duration.from(options.duration);\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): BinarySwitchCCReport {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst currentValue: MaybeUnknown<boolean> | undefined =\n\t\t\tparseMaybeBoolean(\n\t\t\t\traw.payload[0],\n\t\t\t);\n\t\tlet targetValue: MaybeUnknown<boolean> | undefined;\n\t\tlet duration: Duration | undefined;\n\n\t\tif (raw.payload.length >= 3) {\n\t\t\ttargetValue = parseMaybeBoolean(raw.payload[1]);\n\t\t\tduration = Duration.parseReport(raw.payload[2]);\n\t\t}\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tcurrentValue,\n\t\t\ttargetValue,\n\t\t\tduration,\n\t\t});\n\t}\n\n\tpublic readonly currentValue: MaybeUnknown<boolean> | undefined;\n\n\tpublic readonly targetValue: MaybeUnknown<boolean> | undefined;\n\n\tpublic readonly duration: Duration | undefined;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.from([\n\t\t\tencodeMaybeBoolean(this.currentValue ?? UNKNOWN_STATE),\n\t\t]);\n\t\tif (this.targetValue !== undefined) {\n\t\t\tthis.payload = Bytes.concat([\n\t\t\t\tthis.payload,\n\t\t\t\tBytes.from([\n\t\t\t\t\tencodeMaybeBoolean(this.targetValue),\n\t\t\t\t\t(this.duration ?? Duration.default()).serializeReport(),\n\t\t\t\t]),\n\t\t\t]);\n\t\t}\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\tconst message: MessageRecord = {\n\t\t\t\"current value\": maybeUnknownToString(this.currentValue),\n\t\t};\n\t\tif (this.targetValue !== undefined) {\n\t\t\tmessage[\"target value\"] = maybeUnknownToString(this.targetValue);\n\t\t}\n\t\tif (this.duration != undefined) {\n\t\t\tmessage.duration = this.duration.toString();\n\t\t}\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage,\n\t\t};\n\t}\n}\n\n@CCCommand(BinarySwitchCommand.Get)\n@expectedCCResponse(BinarySwitchCCReport)\nexport class BinarySwitchCCGet extends BinarySwitchCC {}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,kBAiBO;AACP,oBAAsB;AAEtB,iBAUO;AACP,0BAMO;AACP,oCASO;AACP,oBAAkB;AAClB,mBAAoC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAgCvB,qBAAiB,MAAA;8BAD7B,mCAAI,2BAAe,eAAe,CAAC,CAAC;;;;oBACE;;;yCAAA,YAAK;WAAA;;;;;;;;AA0C3C,mBAAA,MAAA,MAAA,iBAAA,EAAA,MAAA,UAAA,MAAA,OAAA,QAAA,OAAA,SAAA,OAAA,QAAA,EAAA,KAAA,gCAAA,SAAA,KAAA,QAAA,KAAA,gCAAA,IAAa,KAAb,OAAgB,GAAA,UAAA,UAAA,GAAA,MAA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,uBAAA;;IACZ,YACC,SAAiD;AAEjD,YAAM,OAAO;AAEb,WAAK,eAAe,QAAQ;AAC5B,WAAK,cAAc,QAAQ;AAC3B,WAAK,WAAW,qBAAS,KAAK,QAAQ,QAAQ;IAC/C;IAEO,OAAO,KACb,KACA,KAAqB;AAErB,uCAAgB,IAAI,QAAQ,UAAU,CAAC;AACvC,YAAM,mBACL,+BACC,IAAI,QAAQ,CAAC,CAAC;AAEhB,UAAI;AACJ,UAAI;AAEJ,UAAI,IAAI,QAAQ,UAAU,GAAG;AAC5B,0BAAc,+BAAkB,IAAI,QAAQ,CAAC,CAAC;AAC9C,mBAAW,qBAAS,YAAY,IAAI,QAAQ,CAAC,CAAC;MAC/C;AAEA,aAAO,IAAI,KAAK;QACf,QAAQ,IAAI;QACZ;QACA;QACA;OACA;IACF;IAEgB;IAEA;IAEA;IAET,UAAU,KAAsB;AACtC,WAAK,UAAU,oBAAM,KAAK;YACzB,gCAAmB,KAAK,gBAAgB,yBAAa;OACrD;AACD,UAAI,KAAK,gBAAgB,QAAW;AACnC,aAAK,UAAU,oBAAM,OAAO;UAC3B,KAAK;UACL
|
|
4
|
+
"sourcesContent": ["import type { CCEncodingContext, CCParsingContext } from \"@zwave-js/cc\";\nimport {\n\tCommandClasses,\n\tDuration,\n\ttype GetValueDB,\n\ttype MaybeNotKnown,\n\ttype MaybeUnknown,\n\ttype MessageOrCCLogEntry,\n\tMessagePriority,\n\ttype MessageRecord,\n\ttype SupervisionResult,\n\tUNKNOWN_STATE,\n\tValueMetadata,\n\ttype WithAddress,\n\tencodeMaybeBoolean,\n\tmaybeUnknownToString,\n\tparseMaybeBoolean,\n\tvalidatePayload,\n} from \"@zwave-js/core\";\nimport { Bytes } from \"@zwave-js/shared\";\nimport { validateArgs } from \"@zwave-js/transformers\";\nimport {\n\tCCAPI,\n\tPOLL_VALUE,\n\ttype PollValueImplementation,\n\tSET_VALUE,\n\tSET_VALUE_HOOKS,\n\ttype SetValueImplementation,\n\ttype SetValueImplementationHooksFactory,\n\tthrowUnsupportedProperty,\n\tthrowWrongValueType,\n} from \"../lib/API.js\";\nimport {\n\ttype CCRaw,\n\tCommandClass,\n\ttype InterviewContext,\n\ttype RefreshValuesContext,\n\tgetEffectiveCCVersion,\n} from \"../lib/CommandClass.js\";\nimport {\n\tAPI,\n\tCCCommand,\n\tccValueProperty,\n\tccValues,\n\tcommandClass,\n\texpectedCCResponse,\n\timplementedVersion,\n\tuseSupervision,\n} from \"../lib/CommandClassDecorators.js\";\nimport { V } from \"../lib/Values.js\";\nimport { BinarySwitchCommand } from \"../lib/_Types.js\";\n\nexport const BinarySwitchCCValues = V.defineCCValues(\n\tCommandClasses[\"Binary Switch\"],\n\t{\n\t\t...V.staticProperty(\n\t\t\t\"currentValue\",\n\t\t\t{\n\t\t\t\t...ValueMetadata.ReadOnlyBoolean,\n\t\t\t\tlabel: \"Current value\",\n\t\t\t} as const,\n\t\t),\n\t\t...V.staticProperty(\n\t\t\t\"targetValue\",\n\t\t\t{\n\t\t\t\t...ValueMetadata.Boolean,\n\t\t\t\tlabel: \"Target value\",\n\t\t\t\tvalueChangeOptions: [\"transitionDuration\"],\n\t\t\t} as const,\n\t\t),\n\t\t...V.staticProperty(\n\t\t\t\"duration\",\n\t\t\t{\n\t\t\t\t...ValueMetadata.ReadOnlyDuration,\n\t\t\t\tlabel: \"Remaining duration\",\n\t\t\t} as const,\n\t\t\t{ minVersion: 2 } as const,\n\t\t),\n\t},\n);\n\n@API(CommandClasses[\"Binary Switch\"])\nexport class BinarySwitchCCAPI extends CCAPI {\n\tpublic supportsCommand(cmd: BinarySwitchCommand): MaybeNotKnown<boolean> {\n\t\tswitch (cmd) {\n\t\t\tcase BinarySwitchCommand.Get:\n\t\t\t\treturn this.isSinglecast();\n\t\t\tcase BinarySwitchCommand.Set:\n\t\t\t\treturn true;\n\t\t}\n\t\treturn super.supportsCommand(cmd);\n\t}\n\n\t// oxlint-disable-next-line typescript/explicit-module-boundary-types\n\tpublic async get() {\n\t\tthis.assertSupportsCommand(\n\t\t\tBinarySwitchCommand,\n\t\t\tBinarySwitchCommand.Get,\n\t\t);\n\n\t\tconst cc = new BinarySwitchCCGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tconst response = await this.host.sendCommand<BinarySwitchCCReport>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\tif (response) {\n\t\t\treturn {\n\t\t\t\t// interpret unknown values as false\n\t\t\t\tcurrentValue: response.currentValue || false,\n\t\t\t\ttargetValue: response.targetValue,\n\t\t\t\tduration: response.duration,\n\t\t\t};\n\t\t}\n\t}\n\n\t/**\n\t * Sets the switch to the given value\n\t * @param targetValue The target value to set\n\t * @param duration The duration after which the target value should be reached. Can be a Duration instance or a user-friendly duration string like `\"1m17s\"`. Only supported in V2 and above.\n\t */\n\t@validateArgs()\n\tpublic async set(\n\t\ttargetValue: boolean,\n\t\tduration?: Duration | string,\n\t): Promise<SupervisionResult | undefined> {\n\t\tthis.assertSupportsCommand(\n\t\t\tBinarySwitchCommand,\n\t\t\tBinarySwitchCommand.Set,\n\t\t);\n\n\t\tconst cc = new BinarySwitchCCSet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\ttargetValue,\n\t\t\tduration,\n\t\t});\n\t\treturn this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\tprotected override get [SET_VALUE](): SetValueImplementation {\n\t\treturn async function(\n\t\t\tthis: BinarySwitchCCAPI,\n\t\t\t{ property },\n\t\t\tvalue,\n\t\t\toptions,\n\t\t) {\n\t\t\tif (property !== \"targetValue\") {\n\t\t\t\tthrowUnsupportedProperty(this.ccId, property);\n\t\t\t}\n\t\t\tif (typeof value !== \"boolean\") {\n\t\t\t\tthrowWrongValueType(\n\t\t\t\t\tthis.ccId,\n\t\t\t\t\tproperty,\n\t\t\t\t\t\"boolean\",\n\t\t\t\t\ttypeof value,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst duration = Duration.from(options?.transitionDuration);\n\t\t\treturn this.set(value, duration);\n\t\t};\n\t}\n\n\tprotected [SET_VALUE_HOOKS]: SetValueImplementationHooksFactory = (\n\t\t{ property },\n\t\tvalue,\n\t\toptions,\n\t) => {\n\t\tif (property === \"targetValue\") {\n\t\t\tconst currentValueValueId = BinarySwitchCCValues.currentValue\n\t\t\t\t.endpoint(this.endpoint.index);\n\n\t\t\treturn {\n\t\t\t\toptimisticallyUpdateRelatedValues: (\n\t\t\t\t\t_supervisedAndSuccessful,\n\t\t\t\t) => {\n\t\t\t\t\t// After setting targetValue, optimistically update currentValue\n\t\t\t\t\tif (this.isSinglecast()) {\n\t\t\t\t\t\tthis.tryGetValueDB()?.setValue(\n\t\t\t\t\t\t\tcurrentValueValueId,\n\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t);\n\t\t\t\t\t} else if (this.isMulticast()) {\n\t\t\t\t\t\t// Figure out which nodes were affected by this command\n\t\t\t\t\t\tconst affectedNodes = this.endpoint.node.physicalNodes\n\t\t\t\t\t\t\t.filter((node) =>\n\t\t\t\t\t\t\t\tnode\n\t\t\t\t\t\t\t\t\t.getEndpoint(this.endpoint.index)\n\t\t\t\t\t\t\t\t\t?.supportsCC(this.ccId)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t// and optimistically update the currentValue\n\t\t\t\t\t\tfor (const node of affectedNodes) {\n\t\t\t\t\t\t\tthis.host\n\t\t\t\t\t\t\t\t.tryGetValueDB(node.id)\n\t\t\t\t\t\t\t\t?.setValue(currentValueValueId, value);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\n\t\t\t\tverifyChanges: () => {\n\t\t\t\t\tif (this.isSinglecast()) {\n\t\t\t\t\t\t// We query currentValue instead of targetValue to make sure that unsolicited updates cancel the scheduled poll\n\t\t\t\t\t\tthis.schedulePoll(currentValueValueId, value, {\n\t\t\t\t\t\t\tduration: Duration.from(\n\t\t\t\t\t\t\t\toptions?.transitionDuration,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t// on/off \"transitions\" are usually fast\n\t\t\t\t\t\t\ttransition: \"fast\",\n\t\t\t\t\t\t});\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// For multicasts, do not schedule a refresh - this could cause a LOT of traffic\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t};\n\n\tprotected get [POLL_VALUE](): PollValueImplementation {\n\t\treturn async function(this: BinarySwitchCCAPI, { property }) {\n\t\t\tswitch (property) {\n\t\t\t\tcase \"currentValue\":\n\t\t\t\tcase \"targetValue\":\n\t\t\t\tcase \"duration\":\n\t\t\t\t\treturn (await this.get())?.[property];\n\t\t\t\tdefault:\n\t\t\t\t\tthrowUnsupportedProperty(this.ccId, property);\n\t\t\t}\n\t\t};\n\t}\n}\n\n@commandClass(CommandClasses[\"Binary Switch\"])\n@implementedVersion(2)\n@ccValues(BinarySwitchCCValues)\nexport class BinarySwitchCC extends CommandClass {\n\tdeclare ccCommand: BinarySwitchCommand;\n\n\tpublic async interview(\n\t\tctx: InterviewContext,\n\t): Promise<void> {\n\t\tconst node = this.getNode(ctx)!;\n\n\t\tctx.logNode(node.id, {\n\t\t\tendpoint: this.endpointIndex,\n\t\t\tmessage: `Interviewing ${this.ccName}...`,\n\t\t\tdirection: \"none\",\n\t\t});\n\n\t\tawait this.refreshValues(ctx);\n\n\t\t// Remember that the interview is complete\n\t\tthis.setInterviewComplete(ctx, true);\n\t}\n\n\tpublic async refreshValues(\n\t\tctx: RefreshValuesContext,\n\t): Promise<void> {\n\t\tconst node = this.getNode(ctx)!;\n\t\tconst endpoint = this.getEndpoint(ctx)!;\n\t\tconst api = CCAPI.create(\n\t\t\tCommandClasses[\"Binary Switch\"],\n\t\t\tctx,\n\t\t\tendpoint,\n\t\t).withOptions({\n\t\t\tpriority: MessagePriority.NodeQuery,\n\t\t});\n\n\t\t// Query the current state\n\t\tctx.logNode(node.id, {\n\t\t\tendpoint: this.endpointIndex,\n\t\t\tmessage: \"querying Binary Switch state...\",\n\t\t\tdirection: \"outbound\",\n\t\t});\n\n\t\tconst resp = await api.get();\n\t\tif (resp) {\n\t\t\tlet logMessage = `received Binary Switch state:\ncurrent value: ${resp.currentValue}`;\n\t\t\tif (resp.targetValue != undefined) {\n\t\t\t\tlogMessage += `\ntarget value: ${resp.targetValue}\nremaining duration: ${resp.duration?.toString() ?? \"undefined\"}`;\n\t\t\t}\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\tmessage: logMessage,\n\t\t\t\tdirection: \"inbound\",\n\t\t\t});\n\t\t}\n\t}\n\n\tpublic setMappedBasicValue(\n\t\tctx: GetValueDB,\n\t\tvalue: number,\n\t): boolean {\n\t\tthis.setValue(ctx, BinarySwitchCCValues.currentValue, value > 0);\n\t\treturn true;\n\t}\n}\n\n// @publicAPI\nexport interface BinarySwitchCCSetOptions {\n\ttargetValue: boolean;\n\tduration?: Duration | string;\n}\n\n@CCCommand(BinarySwitchCommand.Set)\n@useSupervision()\nexport class BinarySwitchCCSet extends BinarySwitchCC {\n\tpublic constructor(\n\t\toptions: WithAddress<BinarySwitchCCSetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.targetValue = options.targetValue;\n\t\tthis.duration = Duration.from(options.duration);\n\t}\n\n\tpublic static from(raw: CCRaw, ctx: CCParsingContext): BinarySwitchCCSet {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst targetValue = !!raw.payload[0];\n\t\tlet duration: Duration | undefined;\n\n\t\tif (raw.payload.length >= 2) {\n\t\t\tduration = Duration.parseSet(raw.payload[1]);\n\t\t}\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\ttargetValue,\n\t\t\tduration,\n\t\t});\n\t}\n\n\tpublic targetValue: boolean;\n\tpublic duration: Duration | undefined;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.from([\n\t\t\tthis.targetValue ? 0xff : 0x00,\n\t\t\t(this.duration ?? Duration.default()).serializeSet(),\n\t\t]);\n\n\t\tconst ccVersion = getEffectiveCCVersion(ctx, this);\n\t\tif (\n\t\t\tccVersion < 2 && ctx.getDeviceConfig?.(\n\t\t\t\tthis.nodeId as number,\n\t\t\t)?.compat?.encodeCCsUsingTargetVersion\n\t\t) {\n\t\t\t// When forcing CC version 1, only send the target value\n\t\t\tthis.payload = this.payload.subarray(0, 1);\n\t\t}\n\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\tconst message: MessageRecord = {\n\t\t\t\"target value\": this.targetValue,\n\t\t};\n\t\tif (this.duration != undefined) {\n\t\t\tmessage.duration = this.duration.toString();\n\t\t}\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage,\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport interface BinarySwitchCCReportOptions {\n\tcurrentValue?: MaybeUnknown<boolean>;\n\ttargetValue?: MaybeUnknown<boolean>;\n\tduration?: Duration | string;\n}\n\n@CCCommand(BinarySwitchCommand.Report)\n@ccValueProperty(\"currentValue\", BinarySwitchCCValues.currentValue)\n@ccValueProperty(\"targetValue\", BinarySwitchCCValues.targetValue)\n@ccValueProperty(\"duration\", BinarySwitchCCValues.duration)\nexport class BinarySwitchCCReport extends BinarySwitchCC {\n\tpublic constructor(\n\t\toptions: WithAddress<BinarySwitchCCReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\tthis.currentValue = options.currentValue;\n\t\tthis.targetValue = options.targetValue;\n\t\tthis.duration = Duration.from(options.duration);\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): BinarySwitchCCReport {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst currentValue: MaybeUnknown<boolean> | undefined =\n\t\t\tparseMaybeBoolean(\n\t\t\t\traw.payload[0],\n\t\t\t);\n\t\tlet targetValue: MaybeUnknown<boolean> | undefined;\n\t\tlet duration: Duration | undefined;\n\n\t\tif (raw.payload.length >= 3) {\n\t\t\ttargetValue = parseMaybeBoolean(raw.payload[1]);\n\t\t\tduration = Duration.parseReport(raw.payload[2]);\n\t\t}\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tcurrentValue,\n\t\t\ttargetValue,\n\t\t\tduration,\n\t\t});\n\t}\n\n\tpublic readonly currentValue: MaybeUnknown<boolean> | undefined;\n\n\tpublic readonly targetValue: MaybeUnknown<boolean> | undefined;\n\n\tpublic readonly duration: Duration | undefined;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.from([\n\t\t\tencodeMaybeBoolean(this.currentValue ?? UNKNOWN_STATE),\n\t\t]);\n\t\tif (this.targetValue !== undefined) {\n\t\t\tthis.payload = Bytes.concat([\n\t\t\t\tthis.payload,\n\t\t\t\t[\n\t\t\t\t\tencodeMaybeBoolean(this.targetValue),\n\t\t\t\t\t(this.duration ?? Duration.default()).serializeReport(),\n\t\t\t\t],\n\t\t\t]);\n\t\t}\n\t\treturn super.serialize(ctx);\n\t}\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\tconst message: MessageRecord = {\n\t\t\t\"current value\": maybeUnknownToString(this.currentValue),\n\t\t};\n\t\tif (this.targetValue !== undefined) {\n\t\t\tmessage[\"target value\"] = maybeUnknownToString(this.targetValue);\n\t\t}\n\t\tif (this.duration != undefined) {\n\t\t\tmessage.duration = this.duration.toString();\n\t\t}\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage,\n\t\t};\n\t}\n}\n\n@CCCommand(BinarySwitchCommand.Get)\n@expectedCCResponse(BinarySwitchCCReport)\nexport class BinarySwitchCCGet extends BinarySwitchCC {}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;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AEtD;MACF;AACA,aAAO,MAAM,UAAU,GAAG;IAC3B;IAEO,WAAW,KAAgB;AACjC,YAAM,UAAyB;QAC9B,qBAAiB,kCAAqB,KAAK,YAAY;;AAExD,UAAI,KAAK,gBAAgB,QAAW;AACnC,gBAAQ,cAAc,QAAI,kCAAqB,KAAK,WAAW;MAChE;AACA,UAAI,KAAK,YAAY,QAAW;AAC/B,gBAAQ,WAAW,KAAK,SAAS,SAAQ;MAC1C;AACA,aAAO;QACN,GAAG,MAAM,WAAW,GAAG;QACvB;;IAEF;;;;IAKY,qBAAiB,MAAA;8BAF7B,yCAAU,iCAAoB,GAAG,OACjC,kDAAmB,oBAAoB,CAAC;;;;oBACF;yCAAA,YAAc;WAAA;;;;;;;;AAArD,mBAAA,MAAA,mBAAA,EAAA,OAAA,WAAA,GAAA,kBAAA,EAAA,MAAA,SAAA,MAAA,WAAA,MAAA,UAAA,UAAA,GAAA,MAAA,uBAAA;;;AAAa,wBAAA,YAAA,uBAAA;;;;;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -260,7 +260,7 @@ let ClimateControlScheduleCCSet = (() => {
|
|
|
260
260
|
});
|
|
261
261
|
}
|
|
262
262
|
this.payload = import_shared.Bytes.concat([
|
|
263
|
-
|
|
263
|
+
[this.weekday & 7],
|
|
264
264
|
...allSwitchPoints.map((sp) => (0, import_serializers.encodeSwitchpoint)(sp))
|
|
265
265
|
]);
|
|
266
266
|
return super.serialize(ctx);
|