@zwave-js/cc 15.31.0 → 15.31.2
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/BarrierOperatorCC.js +5 -8
- package/build/cjs/cc/BarrierOperatorCC.js.map +2 -2
- package/build/cjs/cc/BinarySensorCC.js +1 -2
- package/build/cjs/cc/BinarySensorCC.js.map +2 -2
- package/build/cjs/cc/ColorSwitchCC.js +1 -2
- package/build/cjs/cc/ColorSwitchCC.js.map +2 -2
- package/build/cjs/cc/ConfigurationCC.d.ts +5 -0
- package/build/cjs/cc/PowerlevelCC.js +1 -1
- package/build/cjs/cc/PowerlevelCC.js.map +2 -2
- package/build/cjs/cc/WindowCoveringCC.js +1 -2
- package/build/cjs/cc/WindowCoveringCC.js.map +2 -2
- package/build/cjs/cc/_CCValues.generated.d.ts +2 -2
- package/build/esm/cc/BarrierOperatorCC.d.ts.map +1 -1
- package/build/esm/cc/BarrierOperatorCC.js +6 -9
- package/build/esm/cc/BarrierOperatorCC.js.map +1 -1
- package/build/esm/cc/BinarySensorCC.d.ts.map +1 -1
- package/build/esm/cc/BinarySensorCC.js +2 -3
- package/build/esm/cc/BinarySensorCC.js.map +1 -1
- package/build/esm/cc/ColorSwitchCC.d.ts.map +1 -1
- package/build/esm/cc/ColorSwitchCC.js +2 -3
- package/build/esm/cc/ColorSwitchCC.js.map +1 -1
- package/build/esm/cc/ConfigurationCC.d.ts +5 -0
- package/build/esm/cc/ConfigurationCC.d.ts.map +1 -1
- package/build/esm/cc/PowerlevelCC.d.ts.map +1 -1
- package/build/esm/cc/PowerlevelCC.js +2 -2
- package/build/esm/cc/PowerlevelCC.js.map +1 -1
- package/build/esm/cc/WindowCoveringCC.d.ts.map +1 -1
- package/build/esm/cc/WindowCoveringCC.js +3 -4
- package/build/esm/cc/WindowCoveringCC.js.map +1 -1
- package/build/esm/cc/_CCValues.generated.d.ts +2 -2
- package/build/esm/cc/_CCValues.generated.d.ts.map +1 -1
- package/package.json +9 -9
|
@@ -582,9 +582,8 @@ let BarrierOperatorCCEventSignalingSet = (() => {
|
|
|
582
582
|
}
|
|
583
583
|
static from(raw, ctx) {
|
|
584
584
|
(0, import_core.validatePayload)(raw.payload.length >= 2);
|
|
585
|
-
const subsystemType = raw.payload[0];
|
|
586
|
-
const subsystemState = raw.payload[1];
|
|
587
|
-
(0, import_core.validatePayload)((0, import_shared.isEnumMember)(import_Types.SubsystemType, subsystemType), (0, import_shared.isEnumMember)(import_Types.SubsystemState, subsystemState));
|
|
585
|
+
const subsystemType = (0, import_core.parseEnumValue)(import_Types.SubsystemType, raw.payload[0]);
|
|
586
|
+
const subsystemState = (0, import_core.parseEnumValue)(import_Types.SubsystemState, raw.payload[1]);
|
|
588
587
|
return new this({
|
|
589
588
|
nodeId: ctx.sourceNodeId,
|
|
590
589
|
subsystemType,
|
|
@@ -636,9 +635,8 @@ let BarrierOperatorCCEventSignalingReport = (() => {
|
|
|
636
635
|
}
|
|
637
636
|
static from(raw, ctx) {
|
|
638
637
|
(0, import_core.validatePayload)(raw.payload.length >= 2);
|
|
639
|
-
const subsystemType = raw.payload[0];
|
|
640
|
-
const subsystemState = raw.payload[1];
|
|
641
|
-
(0, import_core.validatePayload)((0, import_shared.isEnumMember)(import_Types.SubsystemType, subsystemType), (0, import_shared.isEnumMember)(import_Types.SubsystemState, subsystemState));
|
|
638
|
+
const subsystemType = (0, import_core.parseEnumValue)(import_Types.SubsystemType, raw.payload[0]);
|
|
639
|
+
const subsystemState = (0, import_core.parseEnumValue)(import_Types.SubsystemState, raw.payload[1]);
|
|
642
640
|
return new this({
|
|
643
641
|
nodeId: ctx.sourceNodeId,
|
|
644
642
|
subsystemType,
|
|
@@ -697,8 +695,7 @@ let BarrierOperatorCCEventSignalingGet = (() => {
|
|
|
697
695
|
}
|
|
698
696
|
static from(raw, ctx) {
|
|
699
697
|
(0, import_core.validatePayload)(raw.payload.length >= 1);
|
|
700
|
-
const subsystemType = raw.payload[0];
|
|
701
|
-
(0, import_core.validatePayload)((0, import_shared.isEnumMember)(import_Types.SubsystemType, subsystemType));
|
|
698
|
+
const subsystemType = (0, import_core.parseEnumValue)(import_Types.SubsystemType, raw.payload[0]);
|
|
702
699
|
return new this({ nodeId: ctx.sourceNodeId, subsystemType });
|
|
703
700
|
}
|
|
704
701
|
subsystemType;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src_gen/cc/BarrierOperatorCC.ts"],
|
|
4
|
-
"sourcesContent": ["import * as __validateArgs from \"./BarrierOperatorCC._validateArgs.js\";\nconst { validateArgs_BarrierOperatorCCAPI_set, validateArgs_BarrierOperatorCCAPI_getSignalingCapabilities, validateArgs_BarrierOperatorCCAPI_getEventSignaling, validateArgs_BarrierOperatorCCAPI_setEventSignaling } = __validateArgs;\nimport { CommandClasses, type GetNode, type GetValueDB, type MaybeNotKnown, type MaybeUnknown, type MessageOrCCLogEntry, MessagePriority, type NodeId, type SupervisionResult, type SupportsCC, UNKNOWN_STATE, ValueMetadata, type WithAddress, ZWaveError, ZWaveErrorCodes, enumValuesToMetadataStates, logList, logText, maybeUnknownToString, parseBitMask, encodeBitMask, validatePayload, } from \"@zwave-js/core\";\nimport { Bytes, getEnumMemberName, isEnumMember, noop, pick, } from \"@zwave-js/shared\";\nimport { CCAPI, POLL_VALUE, type PollValueImplementation, SET_VALUE, SET_VALUE_HOOKS, type SetValueImplementation, type SetValueImplementationHooksFactory, throwMissingPropertyKey, throwUnsupportedProperty, throwUnsupportedPropertyKey, throwWrongValueType, } from \"../lib/API.js\";\nimport { type CCRaw, CommandClass, type InterviewContext, type PersistValuesContext, type RefreshValuesContext, type RefreshValuesOptions, } from \"../lib/CommandClass.js\";\nimport { API, CCCommand, ccValueProperty, ccValues, commandClass, expectedCCResponse, implementedVersion, useSupervision, } from \"../lib/CommandClassDecorators.js\";\nimport { V } from \"../lib/Values.js\";\nimport { BarrierOperatorCommand, BarrierState, SubsystemState, SubsystemType, } from \"../lib/_Types.js\";\nimport type { CCEncodingContext, CCParsingContext } from \"../lib/traits.js\";\nimport { ApplicationStatusCCRejectedRequest } from \"./ApplicationStatusCC.js\";\nimport { BarrierOperatorCCValues } from \"./_CCValues.generated.js\";\nexport { BarrierOperatorCCValues };\n@API(CommandClasses[\"Barrier Operator\"])\nexport class BarrierOperatorCCAPI extends CCAPI {\n public supportsCommand(cmd: BarrierOperatorCommand): MaybeNotKnown<boolean> {\n switch (cmd) {\n case BarrierOperatorCommand.Get:\n case BarrierOperatorCommand.Set:\n case BarrierOperatorCommand.SignalingCapabilitiesGet:\n case BarrierOperatorCommand.EventSignalingGet:\n case BarrierOperatorCommand.EventSignalingSet:\n return true; // This is mandatory\n }\n return super.supportsCommand(cmd);\n }\n // oxlint-disable-next-line typescript/explicit-module-boundary-types\n public async get() {\n this.assertSupportsCommand(BarrierOperatorCommand, BarrierOperatorCommand.Get);\n const cc = new BarrierOperatorCCGet({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n });\n const response = await this.host.sendCommand<BarrierOperatorCCReport>(cc, this.commandOptions);\n if (response) {\n return pick(response, [\"currentState\", \"position\"]);\n }\n }\n @validateArgs_BarrierOperatorCCAPI_set()\n public async set(targetState: BarrierState.Open | BarrierState.Closed): Promise<SupervisionResult | undefined> {\n this.assertSupportsCommand(BarrierOperatorCommand, BarrierOperatorCommand.Set);\n const cc = new BarrierOperatorCCSet({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n targetState,\n });\n return this.host.sendCommand(cc, this.commandOptions);\n }\n @validateArgs_BarrierOperatorCCAPI_getSignalingCapabilities()\n public async getSignalingCapabilities(): Promise<MaybeNotKnown<readonly SubsystemType[]>> {\n this.assertSupportsCommand(BarrierOperatorCommand, BarrierOperatorCommand.SignalingCapabilitiesGet);\n const cc = new BarrierOperatorCCSignalingCapabilitiesGet({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n });\n const response = await this.host.sendCommand<BarrierOperatorCCSignalingCapabilitiesReport>(cc, this.commandOptions);\n return response?.supportedSubsystemTypes;\n }\n @validateArgs_BarrierOperatorCCAPI_getEventSignaling()\n public async getEventSignaling(subsystemType: SubsystemType): Promise<MaybeNotKnown<SubsystemState>> {\n this.assertSupportsCommand(BarrierOperatorCommand, BarrierOperatorCommand.EventSignalingGet);\n const cc = new BarrierOperatorCCEventSignalingGet({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n subsystemType,\n });\n const response = await this.host.sendCommand<BarrierOperatorCCEventSignalingReport>(cc, this.commandOptions);\n return response?.subsystemState;\n }\n @validateArgs_BarrierOperatorCCAPI_setEventSignaling()\n public async setEventSignaling(subsystemType: SubsystemType, subsystemState: SubsystemState): Promise<SupervisionResult | undefined> {\n this.assertSupportsCommand(BarrierOperatorCommand, BarrierOperatorCommand.EventSignalingSet);\n const cc = new BarrierOperatorCCEventSignalingSet({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n subsystemType,\n subsystemState,\n });\n return this.host.sendCommand(cc, this.commandOptions);\n }\n protected override get [SET_VALUE](): SetValueImplementation {\n return async function (this: BarrierOperatorCCAPI, { property, propertyKey }, value) {\n if (property === \"targetState\") {\n if (typeof value !== \"number\") {\n throwWrongValueType(this.ccId, property, \"number\", typeof value);\n }\n const targetValue = value === BarrierState.Closed\n ? BarrierState.Closed\n : BarrierState.Open;\n return this.set(targetValue);\n }\n else if (property === \"signalingState\") {\n if (propertyKey == undefined) {\n throwMissingPropertyKey(this.ccId, property);\n }\n else if (typeof propertyKey !== \"number\") {\n throwUnsupportedPropertyKey(this.ccId, property, propertyKey);\n }\n if (typeof value !== \"number\") {\n throwWrongValueType(this.ccId, property, \"number\", typeof value);\n }\n return this.setEventSignaling(propertyKey, value);\n }\n else {\n throwUnsupportedProperty(this.ccId, property);\n }\n };\n }\n protected [SET_VALUE_HOOKS]: SetValueImplementationHooksFactory = ({ property, propertyKey }, value, _options) => {\n const valueId = {\n commandClass: this.ccId,\n property,\n propertyKey,\n };\n if (BarrierOperatorCCValues.targetState.is(valueId)) {\n const currentStateValueId = BarrierOperatorCCValues.currentState.endpoint(this.endpoint.index);\n const targetValue = value === BarrierState.Closed\n ? BarrierState.Closed\n : BarrierState.Open;\n return {\n // This is the target value for a split target/current state pair.\n isSplitStateTargetValue: true,\n // Barrier Operator commands may take some time to be executed.\n // Therefore we try to supervise the command execution and delay the\n // optimistic update until the final result is received.\n supervisionDelayedUpdates: true,\n supervisionOnSuccess: () => {\n this.tryGetValueDB()?.setValue(currentStateValueId, targetValue);\n },\n supervisionOnFailure: async () => {\n // The command failed, so now we don't know the status - refresh the current value\n try {\n await this.get();\n }\n catch {\n // ignore\n }\n },\n optimisticallyUpdateRelatedValues: (supervisedAndSuccessful) => {\n // For barriers, do not update the current value unless we actually know the command was successful\n if (!supervisedAndSuccessful)\n return;\n if (this.isSinglecast()) {\n this.tryGetValueDB()?.setValue(currentStateValueId, targetValue);\n }\n else if (this.isMulticast()) {\n // Figure out which nodes were affected by this command\n const affectedNodes = this.endpoint.node.physicalNodes.filter((node) => node\n .getEndpoint(this.endpoint.index)\n ?.supportsCC(this.ccId));\n // and optimistically update the currentValue\n for (const node of affectedNodes) {\n this.host\n .tryGetValueDB(node.id)\n ?.setValue(currentStateValueId, targetValue);\n }\n }\n },\n verifyChanges: () => {\n if (this.isSinglecast()) {\n // We query currentValue instead of targetValue to make sure that unsolicited updates cancel the scheduled poll\n this.schedulePoll(currentStateValueId, targetValue);\n }\n else {\n // For multicasts, do not schedule a refresh - this could cause a LOT of traffic\n }\n },\n };\n }\n else if (BarrierOperatorCCValues.signalingState.is(valueId)) {\n const subsystemType = propertyKey as SubsystemType;\n const signalingStateValueId = BarrierOperatorCCValues.signalingState(subsystemType).endpoint(this.endpoint.index);\n return {\n verifyChanges: () => {\n if (this.isSinglecast()) {\n this.schedulePoll(signalingStateValueId, value, {\n // Signaling state changes are fast\n transition: \"fast\",\n });\n }\n },\n };\n }\n };\n protected get [POLL_VALUE](): PollValueImplementation {\n return async function (this: BarrierOperatorCCAPI, { property, propertyKey }) {\n switch (property) {\n case \"currentState\":\n case \"position\":\n return (await this.get())?.[property];\n case \"signalingState\":\n if (propertyKey == undefined) {\n throwMissingPropertyKey(this.ccId, property);\n }\n else if (typeof propertyKey !== \"number\") {\n throwUnsupportedPropertyKey(this.ccId, property, propertyKey);\n }\n return this.getEventSignaling(propertyKey);\n default:\n throwUnsupportedProperty(this.ccId, property);\n }\n };\n }\n}\n@commandClass(CommandClasses[\"Barrier Operator\"])\n@implementedVersion(1)\n@ccValues(BarrierOperatorCCValues)\nexport class BarrierOperatorCC extends CommandClass {\n declare ccCommand: BarrierOperatorCommand;\n public async interview(ctx: InterviewContext): Promise<void> {\n const node = this.getNode(ctx)!;\n const endpoint = this.getEndpoint(ctx)!;\n const api = CCAPI.create(CommandClasses[\"Barrier Operator\"], ctx, endpoint).withOptions({\n priority: MessagePriority.NodeQuery,\n tag: \"interview\",\n });\n ctx.logNode(node.id, {\n endpoint: this.endpointIndex,\n message: `Interviewing ${this.ccName}...`,\n direction: \"none\",\n });\n // Create targetState value if it does not exist\n this.ensureMetadata(ctx, BarrierOperatorCCValues.targetState);\n ctx.logNode(node.id, {\n message: \"Querying signaling capabilities...\",\n direction: \"outbound\",\n });\n const resp = await api.getSignalingCapabilities();\n if (resp) {\n ctx.logNode(node.id, {\n message: logText(\"Received supported subsystem types:\", {\n nested: logList(resp.map((t) => getEnumMemberName(SubsystemType, t))),\n }),\n direction: \"inbound\",\n });\n // Enable all supported subsystems\n for (const subsystemType of resp) {\n // Some devices report invalid subsystem types, but the CC API checks\n // for valid values and throws otherwise.\n if (!isEnumMember(SubsystemType, subsystemType))\n continue;\n ctx.logNode(node.id, {\n message: `Enabling subsystem ${getEnumMemberName(SubsystemType, subsystemType)}...`,\n direction: \"outbound\",\n });\n await api\n .setEventSignaling(subsystemType, SubsystemState.On)\n .catch(noop);\n }\n }\n await this.refreshValues(ctx, { tag: \"interview\" });\n // Remember that the interview is complete\n this.setInterviewComplete(ctx, true);\n }\n public async refreshValues(ctx: RefreshValuesContext, options?: RefreshValuesOptions): Promise<void> {\n const node = this.getNode(ctx)!;\n const endpoint = this.getEndpoint(ctx)!;\n const api = CCAPI.create(CommandClasses[\"Barrier Operator\"], ctx, endpoint).withOptions({\n priority: options?.priority ?? MessagePriority.NodeQuery,\n tag: options?.tag,\n });\n const supportedSubsystems: SubsystemType[] = this.getValue(ctx, BarrierOperatorCCValues.supportedSubsystemTypes)\n ?? [];\n for (const subsystemType of supportedSubsystems) {\n // Some devices report invalid subsystem types, but the CC API checks\n // for valid values and throws otherwise.\n if (!isEnumMember(SubsystemType, subsystemType))\n continue;\n ctx.logNode(node.id, {\n message: `Querying event signaling state for subsystem ${getEnumMemberName(SubsystemType, subsystemType)}...`,\n direction: \"outbound\",\n });\n const state = await api.getEventSignaling(subsystemType);\n if (state != undefined) {\n ctx.logNode(node.id, {\n message: `Subsystem ${getEnumMemberName(SubsystemType, subsystemType)} has state ${getEnumMemberName(SubsystemState, state)}`,\n direction: \"inbound\",\n });\n }\n }\n ctx.logNode(node.id, {\n message: \"querying current barrier state...\",\n direction: \"outbound\",\n });\n await api.get();\n }\n}\n// @publicAPI\nexport interface BarrierOperatorCCSetOptions {\n targetState: BarrierState.Open | BarrierState.Closed;\n}\nfunction getCCResponseForBarrierOperatorCCSet(ctx: GetNode<NodeId & SupportsCC>, sent: BarrierOperatorCCSet) {\n // CC:0066.01.01.11.009: If the requested operation is prohibited by\n // the specific device class [...], the device MUST notify the requester\n // by issuing an Application Rejected Request Command\n if (sent.isSinglecast()\n && !sent.isEncapsulatedWith(CommandClasses.Supervision)\n && ctx\n .getNode(sent.nodeId)\n ?.supportsCC(CommandClasses[\"Application Status\"])) {\n return ApplicationStatusCCRejectedRequest;\n }\n}\n@CCCommand(BarrierOperatorCommand.Set)\n@expectedCCResponse(getCCResponseForBarrierOperatorCCSet)\n@useSupervision()\nexport class BarrierOperatorCCSet extends BarrierOperatorCC {\n public constructor(options: WithAddress<BarrierOperatorCCSetOptions>) {\n super(options);\n this.targetState = options.targetState;\n }\n public static from(raw: CCRaw, ctx: CCParsingContext): BarrierOperatorCCSet {\n validatePayload(raw.payload.length >= 1);\n const targetState = raw.payload[0];\n validatePayload(targetState === BarrierState.Open\n || targetState === BarrierState.Closed);\n return new this({ nodeId: ctx.sourceNodeId, targetState });\n }\n public targetState: BarrierState.Open | BarrierState.Closed;\n public serialize(ctx: CCEncodingContext): Promise<Bytes> {\n this.payload = Bytes.from([this.targetState]);\n return super.serialize(ctx);\n }\n public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n return {\n ...super.toLogEntry(ctx),\n message: { \"target state\": this.targetState },\n };\n }\n}\n// @publicAPI\nexport interface BarrierOperatorCCReportOptions {\n position: MaybeUnknown<number>;\n currentState: MaybeUnknown<BarrierState>;\n}\n@CCCommand(BarrierOperatorCommand.Report)\n@ccValueProperty(\"currentState\", BarrierOperatorCCValues.currentState)\n@ccValueProperty(\"position\", BarrierOperatorCCValues.position)\nexport class BarrierOperatorCCReport extends BarrierOperatorCC {\n public constructor(options: WithAddress<BarrierOperatorCCReportOptions>) {\n super(options);\n // TODO: Check implementation:\n this.position = options.position;\n this.currentState = options.currentState;\n }\n public static from(raw: CCRaw, ctx: CCParsingContext): BarrierOperatorCCReport {\n validatePayload(raw.payload.length >= 1);\n // The payload byte encodes information about the state and position in a single value\n const payloadValue = raw.payload[0];\n let position: MaybeUnknown<number>;\n if (payloadValue <= 99) {\n // known position\n position = payloadValue;\n }\n else if (payloadValue === 255) {\n // known position, fully opened\n position = 100;\n }\n else {\n // unknown position\n position = UNKNOWN_STATE;\n }\n let currentState: MaybeUnknown<BarrierState>;\n if (payloadValue === BarrierState.Closed\n || payloadValue >= BarrierState.Closing) {\n // predefined states\n currentState = payloadValue;\n }\n else if (payloadValue > 0 && payloadValue <= 99) {\n // stopped at exact position\n currentState = BarrierState.Stopped;\n }\n else {\n // invalid value, assume unknown\n currentState = UNKNOWN_STATE;\n }\n return new this({\n nodeId: ctx.sourceNodeId,\n position,\n currentState,\n });\n }\n public readonly currentState: MaybeUnknown<BarrierState>;\n public readonly position: MaybeUnknown<number>;\n public serialize(ctx: CCEncodingContext): Promise<Bytes> {\n let value: number;\n if (this.currentState === BarrierState.Stopped\n && typeof this.position === \"number\") {\n value = this.position === 100 ? 0xff : this.position;\n }\n else if (this.currentState != null) {\n value = this.currentState;\n }\n else {\n throw new ZWaveError(\"Cannot serialize a Barrier Operator Report without a known state\", ZWaveErrorCodes.Argument_Invalid);\n }\n this.payload = Bytes.from([value]);\n return super.serialize(ctx);\n }\n public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n return {\n ...super.toLogEntry(ctx),\n message: {\n \"barrier position\": maybeUnknownToString(this.position),\n \"barrier state\": this.currentState != undefined\n ? getEnumMemberName(BarrierState, this.currentState)\n : \"unknown\",\n },\n };\n }\n}\n@CCCommand(BarrierOperatorCommand.Get)\n@expectedCCResponse(BarrierOperatorCCReport)\nexport class BarrierOperatorCCGet extends BarrierOperatorCC {\n}\n// @publicAPI\nexport interface BarrierOperatorCCSignalingCapabilitiesReportOptions {\n supportedSubsystemTypes: SubsystemType[];\n}\n@CCCommand(BarrierOperatorCommand.SignalingCapabilitiesReport)\n@ccValueProperty(\"supportedSubsystemTypes\", BarrierOperatorCCValues.supportedSubsystemTypes)\nexport class BarrierOperatorCCSignalingCapabilitiesReport extends BarrierOperatorCC {\n public constructor(options: WithAddress<BarrierOperatorCCSignalingCapabilitiesReportOptions>) {\n super(options);\n // TODO: Check implementation:\n this.supportedSubsystemTypes = options.supportedSubsystemTypes;\n }\n public static from(raw: CCRaw, ctx: CCParsingContext): BarrierOperatorCCSignalingCapabilitiesReport {\n const supportedSubsystemTypes: SubsystemType[] = parseBitMask(raw.payload, SubsystemType.Audible);\n return new this({\n nodeId: ctx.sourceNodeId,\n supportedSubsystemTypes,\n });\n }\n public readonly supportedSubsystemTypes: readonly SubsystemType[];\n public serialize(ctx: CCEncodingContext): Promise<Bytes> {\n this.payload = encodeBitMask(this.supportedSubsystemTypes, undefined, SubsystemType.Audible);\n return super.serialize(ctx);\n }\n public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n return {\n ...super.toLogEntry(ctx),\n message: {\n \"supported types\": logList(this.supportedSubsystemTypes.map((t) => getEnumMemberName(SubsystemType, t))),\n },\n };\n }\n}\n@CCCommand(BarrierOperatorCommand.SignalingCapabilitiesGet)\n@expectedCCResponse(BarrierOperatorCCSignalingCapabilitiesReport)\nexport class BarrierOperatorCCSignalingCapabilitiesGet extends BarrierOperatorCC {\n}\n// @publicAPI\nexport interface BarrierOperatorCCEventSignalingSetOptions {\n subsystemType: SubsystemType;\n subsystemState: SubsystemState;\n}\n@CCCommand(BarrierOperatorCommand.EventSignalingSet)\n@useSupervision()\nexport class BarrierOperatorCCEventSignalingSet extends BarrierOperatorCC {\n public constructor(options: WithAddress<BarrierOperatorCCEventSignalingSetOptions>) {\n super(options);\n this.subsystemType = options.subsystemType;\n this.subsystemState = options.subsystemState;\n }\n public static from(raw: CCRaw, ctx: CCParsingContext): BarrierOperatorCCEventSignalingSet {\n validatePayload(raw.payload.length >= 2);\n const subsystemType = raw.payload[0];\n const subsystemState = raw.payload[1];\n validatePayload(isEnumMember(SubsystemType, subsystemType), isEnumMember(SubsystemState, subsystemState));\n return new this({\n nodeId: ctx.sourceNodeId,\n subsystemType,\n subsystemState,\n });\n }\n public subsystemType: SubsystemType;\n public subsystemState: SubsystemState;\n public serialize(ctx: CCEncodingContext): Promise<Bytes> {\n this.payload = Bytes.from([this.subsystemType, this.subsystemState]);\n return super.serialize(ctx);\n }\n public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n return {\n ...super.toLogEntry(ctx),\n message: {\n \"subsystem type\": getEnumMemberName(SubsystemType, this.subsystemType),\n \"subsystem state\": getEnumMemberName(SubsystemState, this.subsystemState),\n },\n };\n }\n}\n// @publicAPI\nexport interface BarrierOperatorCCEventSignalingReportOptions {\n subsystemType: SubsystemType;\n subsystemState: SubsystemState;\n}\n@CCCommand(BarrierOperatorCommand.EventSignalingReport)\nexport class BarrierOperatorCCEventSignalingReport extends BarrierOperatorCC {\n public constructor(options: WithAddress<BarrierOperatorCCEventSignalingReportOptions>) {\n super(options);\n // TODO: Check implementation:\n this.subsystemType = options.subsystemType;\n this.subsystemState = options.subsystemState;\n }\n public static from(raw: CCRaw, ctx: CCParsingContext): BarrierOperatorCCEventSignalingReport {\n validatePayload(raw.payload.length >= 2);\n const subsystemType: SubsystemType = raw.payload[0];\n const subsystemState: SubsystemState = raw.payload[1];\n validatePayload(isEnumMember(SubsystemType, subsystemType), isEnumMember(SubsystemState, subsystemState));\n return new this({\n nodeId: ctx.sourceNodeId,\n subsystemType,\n subsystemState,\n });\n }\n public persistValues(ctx: PersistValuesContext): boolean {\n if (!super.persistValues(ctx))\n return false;\n const signalingStateValue = BarrierOperatorCCValues.signalingState(this.subsystemType);\n this.ensureMetadata(ctx, signalingStateValue);\n this.setValue(ctx, signalingStateValue, this.subsystemState);\n return true;\n }\n public readonly subsystemType: SubsystemType;\n public readonly subsystemState: SubsystemState;\n public serialize(ctx: CCEncodingContext): Promise<Bytes> {\n this.payload = Bytes.from([this.subsystemType, this.subsystemState]);\n return super.serialize(ctx);\n }\n public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n return {\n ...super.toLogEntry(ctx),\n message: {\n \"subsystem type\": getEnumMemberName(SubsystemType, this.subsystemType),\n \"subsystem state\": getEnumMemberName(SubsystemState, this.subsystemState),\n },\n };\n }\n}\n// @publicAPI\nexport interface BarrierOperatorCCEventSignalingGetOptions {\n subsystemType: SubsystemType;\n}\n@CCCommand(BarrierOperatorCommand.EventSignalingGet)\n@expectedCCResponse(BarrierOperatorCCEventSignalingReport)\nexport class BarrierOperatorCCEventSignalingGet extends BarrierOperatorCC {\n public constructor(options: WithAddress<BarrierOperatorCCEventSignalingGetOptions>) {\n super(options);\n this.subsystemType = options.subsystemType;\n }\n public static from(raw: CCRaw, ctx: CCParsingContext): BarrierOperatorCCEventSignalingGet {\n validatePayload(raw.payload.length >= 1);\n const subsystemType = raw.payload[0];\n validatePayload(isEnumMember(SubsystemType, subsystemType));\n return new this({ nodeId: ctx.sourceNodeId, subsystemType });\n }\n public subsystemType: SubsystemType;\n public serialize(ctx: CCEncodingContext): Promise<Bytes> {\n this.payload = Bytes.from([this.subsystemType]);\n return super.serialize(ctx);\n }\n public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n return {\n ...super.toLogEntry(ctx),\n message: {\n \"subsystem type\": getEnumMemberName(SubsystemType, this.subsystemType),\n },\n };\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qBAAgC;AAEhC,kBAAsY;AACtY,oBAAoE;AACpE,iBAAwQ;AACxQ,0BAAkJ;AAClJ,oCAAiI;AAEjI,mBAAqF;AAErF,iCAAmD;AACnD,gCAAwC;AAVxC,MAAM,EAAE,uCAAuC,4DAA4D,qDAAqD,oDAAmD,IAAK;IAa3M,wBAAoB,MAAA;8BADhC,mCAAI,2BAAe,kBAAkB,CAAC,CAAC;;;;oBACE;;;;;;4CAAA,YAAK;WAAA;;;;;;;;AAyB3C,qCAAA,MAAA,MAAA,iBAAA,EAAA,MAAA,UAAA,MAAA,OAAA,QAAA,OAAA,SAAA,OAAA,QAAA,EAAA,KAAA,gCAAA,SAAA,KAAA,QAAA,KAAA,gCAAA,IAAa,KAAb,OAAgB,GAAA,UAAA,UAAA,GAAA,MAAA,0BAAA;AAUhB,qCAAA,MAAA,MAAA,sCAAA,EAAA,MAAA,UAAA,MAAA,4BAAA,QAAA,OAAA,SAAA,OAAA,QAAA,EAAA,KAAA,gCAAA,8BAAA,KAAA,QAAA,KAAA,gCAAA,IAAa,0BAAb,OAAqC,GAAA,UAAA,UAAA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;AAC9B,aAAO;QACH,GAAG,MAAM,WAAW,GAAG;QACvB,SAAS;UACL,sBAAkB,iCAAkB,4BAAe,KAAK,aAAa;UACrE,uBAAmB,iCAAkB,6BAAgB,KAAK,cAAc;;;IAGpF;;;;IAQS,sCAAkC,MAAA;8BAF9C,yCAAU,oCAAuB,iBAAiB,OAClD,kDAAmB,qCAAqC,CAAC;;;;oBACF;0DAAA,YAAiB;WAAA;;;;;;;;AAAzE,qCAAA,MAAA,mBAAA,EAAA,OAAA,WAAA,GAAA,kBAAA,EAAA,MAAA,SAAA,MAAA,WAAA,MAAA,UAAA,UAAA,GAAA,MAAA,uBAAA;;;AAAa,0CAAA,YAAA,uBAAA;;IACT,YAAmB,SAA+D;AAC9E,YAAM,OAAO;AACb,WAAK,gBAAgB,QAAQ;IACjC;IACO,OAAO,KAAK,KAAY,KAAqB;AAChD,uCAAgB,IAAI,QAAQ,UAAU,CAAC;AACvC,YAAM,gBAAgB,IAAI,QAAQ,CAAC;AACnC,2CAAgB,4BAAa,4BAAe,aAAa,CAAC;AAC1D,aAAO,IAAI,KAAK,EAAE,QAAQ,IAAI,cAAc,cAAa,CAAE;IAC/D;IACO;IACA,UAAU,KAAsB;AACnC,WAAK,UAAU,oBAAM,KAAK,CAAC,KAAK,aAAa,CAAC;AAC9C,aAAO,MAAM,UAAU,GAAG;IAC9B;IACO,WAAW,KAAgB;AAC9B,aAAO;QACH,GAAG,MAAM,WAAW,GAAG;QACvB,SAAS;UACL,sBAAkB,iCAAkB,4BAAe,KAAK,aAAa;;;IAGjF;;;;",
|
|
4
|
+
"sourcesContent": ["import * as __validateArgs from \"./BarrierOperatorCC._validateArgs.js\";\nconst { validateArgs_BarrierOperatorCCAPI_set, validateArgs_BarrierOperatorCCAPI_getSignalingCapabilities, validateArgs_BarrierOperatorCCAPI_getEventSignaling, validateArgs_BarrierOperatorCCAPI_setEventSignaling } = __validateArgs;\nimport { CommandClasses, type GetNode, type GetValueDB, type MaybeNotKnown, type MaybeUnknown, type MessageOrCCLogEntry, MessagePriority, type NodeId, type SupervisionResult, type SupportsCC, UNKNOWN_STATE, ValueMetadata, type WithAddress, ZWaveError, ZWaveErrorCodes, enumValuesToMetadataStates, logList, logText, maybeUnknownToString, parseBitMask, encodeBitMask, parseEnumValue, validatePayload, } from \"@zwave-js/core\";\nimport { Bytes, getEnumMemberName, isEnumMember, noop, pick, } from \"@zwave-js/shared\";\nimport { CCAPI, POLL_VALUE, type PollValueImplementation, SET_VALUE, SET_VALUE_HOOKS, type SetValueImplementation, type SetValueImplementationHooksFactory, throwMissingPropertyKey, throwUnsupportedProperty, throwUnsupportedPropertyKey, throwWrongValueType, } from \"../lib/API.js\";\nimport { type CCRaw, CommandClass, type InterviewContext, type PersistValuesContext, type RefreshValuesContext, type RefreshValuesOptions, } from \"../lib/CommandClass.js\";\nimport { API, CCCommand, ccValueProperty, ccValues, commandClass, expectedCCResponse, implementedVersion, useSupervision, } from \"../lib/CommandClassDecorators.js\";\nimport { V } from \"../lib/Values.js\";\nimport { BarrierOperatorCommand, BarrierState, SubsystemState, SubsystemType, } from \"../lib/_Types.js\";\nimport type { CCEncodingContext, CCParsingContext } from \"../lib/traits.js\";\nimport { ApplicationStatusCCRejectedRequest } from \"./ApplicationStatusCC.js\";\nimport { BarrierOperatorCCValues } from \"./_CCValues.generated.js\";\nexport { BarrierOperatorCCValues };\n@API(CommandClasses[\"Barrier Operator\"])\nexport class BarrierOperatorCCAPI extends CCAPI {\n public supportsCommand(cmd: BarrierOperatorCommand): MaybeNotKnown<boolean> {\n switch (cmd) {\n case BarrierOperatorCommand.Get:\n case BarrierOperatorCommand.Set:\n case BarrierOperatorCommand.SignalingCapabilitiesGet:\n case BarrierOperatorCommand.EventSignalingGet:\n case BarrierOperatorCommand.EventSignalingSet:\n return true; // This is mandatory\n }\n return super.supportsCommand(cmd);\n }\n // oxlint-disable-next-line typescript/explicit-module-boundary-types\n public async get() {\n this.assertSupportsCommand(BarrierOperatorCommand, BarrierOperatorCommand.Get);\n const cc = new BarrierOperatorCCGet({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n });\n const response = await this.host.sendCommand<BarrierOperatorCCReport>(cc, this.commandOptions);\n if (response) {\n return pick(response, [\"currentState\", \"position\"]);\n }\n }\n @validateArgs_BarrierOperatorCCAPI_set()\n public async set(targetState: BarrierState.Open | BarrierState.Closed): Promise<SupervisionResult | undefined> {\n this.assertSupportsCommand(BarrierOperatorCommand, BarrierOperatorCommand.Set);\n const cc = new BarrierOperatorCCSet({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n targetState,\n });\n return this.host.sendCommand(cc, this.commandOptions);\n }\n @validateArgs_BarrierOperatorCCAPI_getSignalingCapabilities()\n public async getSignalingCapabilities(): Promise<MaybeNotKnown<readonly SubsystemType[]>> {\n this.assertSupportsCommand(BarrierOperatorCommand, BarrierOperatorCommand.SignalingCapabilitiesGet);\n const cc = new BarrierOperatorCCSignalingCapabilitiesGet({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n });\n const response = await this.host.sendCommand<BarrierOperatorCCSignalingCapabilitiesReport>(cc, this.commandOptions);\n return response?.supportedSubsystemTypes;\n }\n @validateArgs_BarrierOperatorCCAPI_getEventSignaling()\n public async getEventSignaling(subsystemType: SubsystemType): Promise<MaybeNotKnown<SubsystemState>> {\n this.assertSupportsCommand(BarrierOperatorCommand, BarrierOperatorCommand.EventSignalingGet);\n const cc = new BarrierOperatorCCEventSignalingGet({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n subsystemType,\n });\n const response = await this.host.sendCommand<BarrierOperatorCCEventSignalingReport>(cc, this.commandOptions);\n return response?.subsystemState;\n }\n @validateArgs_BarrierOperatorCCAPI_setEventSignaling()\n public async setEventSignaling(subsystemType: SubsystemType, subsystemState: SubsystemState): Promise<SupervisionResult | undefined> {\n this.assertSupportsCommand(BarrierOperatorCommand, BarrierOperatorCommand.EventSignalingSet);\n const cc = new BarrierOperatorCCEventSignalingSet({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n subsystemType,\n subsystemState,\n });\n return this.host.sendCommand(cc, this.commandOptions);\n }\n protected override get [SET_VALUE](): SetValueImplementation {\n return async function (this: BarrierOperatorCCAPI, { property, propertyKey }, value) {\n if (property === \"targetState\") {\n if (typeof value !== \"number\") {\n throwWrongValueType(this.ccId, property, \"number\", typeof value);\n }\n const targetValue = value === BarrierState.Closed\n ? BarrierState.Closed\n : BarrierState.Open;\n return this.set(targetValue);\n }\n else if (property === \"signalingState\") {\n if (propertyKey == undefined) {\n throwMissingPropertyKey(this.ccId, property);\n }\n else if (typeof propertyKey !== \"number\") {\n throwUnsupportedPropertyKey(this.ccId, property, propertyKey);\n }\n if (typeof value !== \"number\") {\n throwWrongValueType(this.ccId, property, \"number\", typeof value);\n }\n return this.setEventSignaling(propertyKey, value);\n }\n else {\n throwUnsupportedProperty(this.ccId, property);\n }\n };\n }\n protected [SET_VALUE_HOOKS]: SetValueImplementationHooksFactory = ({ property, propertyKey }, value, _options) => {\n const valueId = {\n commandClass: this.ccId,\n property,\n propertyKey,\n };\n if (BarrierOperatorCCValues.targetState.is(valueId)) {\n const currentStateValueId = BarrierOperatorCCValues.currentState.endpoint(this.endpoint.index);\n const targetValue = value === BarrierState.Closed\n ? BarrierState.Closed\n : BarrierState.Open;\n return {\n // This is the target value for a split target/current state pair.\n isSplitStateTargetValue: true,\n // Barrier Operator commands may take some time to be executed.\n // Therefore we try to supervise the command execution and delay the\n // optimistic update until the final result is received.\n supervisionDelayedUpdates: true,\n supervisionOnSuccess: () => {\n this.tryGetValueDB()?.setValue(currentStateValueId, targetValue);\n },\n supervisionOnFailure: async () => {\n // The command failed, so now we don't know the status - refresh the current value\n try {\n await this.get();\n }\n catch {\n // ignore\n }\n },\n optimisticallyUpdateRelatedValues: (supervisedAndSuccessful) => {\n // For barriers, do not update the current value unless we actually know the command was successful\n if (!supervisedAndSuccessful)\n return;\n if (this.isSinglecast()) {\n this.tryGetValueDB()?.setValue(currentStateValueId, targetValue);\n }\n else if (this.isMulticast()) {\n // Figure out which nodes were affected by this command\n const affectedNodes = this.endpoint.node.physicalNodes.filter((node) => node\n .getEndpoint(this.endpoint.index)\n ?.supportsCC(this.ccId));\n // and optimistically update the currentValue\n for (const node of affectedNodes) {\n this.host\n .tryGetValueDB(node.id)\n ?.setValue(currentStateValueId, targetValue);\n }\n }\n },\n verifyChanges: () => {\n if (this.isSinglecast()) {\n // We query currentValue instead of targetValue to make sure that unsolicited updates cancel the scheduled poll\n this.schedulePoll(currentStateValueId, targetValue);\n }\n else {\n // For multicasts, do not schedule a refresh - this could cause a LOT of traffic\n }\n },\n };\n }\n else if (BarrierOperatorCCValues.signalingState.is(valueId)) {\n const subsystemType = propertyKey as SubsystemType;\n const signalingStateValueId = BarrierOperatorCCValues.signalingState(subsystemType).endpoint(this.endpoint.index);\n return {\n verifyChanges: () => {\n if (this.isSinglecast()) {\n this.schedulePoll(signalingStateValueId, value, {\n // Signaling state changes are fast\n transition: \"fast\",\n });\n }\n },\n };\n }\n };\n protected get [POLL_VALUE](): PollValueImplementation {\n return async function (this: BarrierOperatorCCAPI, { property, propertyKey }) {\n switch (property) {\n case \"currentState\":\n case \"position\":\n return (await this.get())?.[property];\n case \"signalingState\":\n if (propertyKey == undefined) {\n throwMissingPropertyKey(this.ccId, property);\n }\n else if (typeof propertyKey !== \"number\") {\n throwUnsupportedPropertyKey(this.ccId, property, propertyKey);\n }\n return this.getEventSignaling(propertyKey);\n default:\n throwUnsupportedProperty(this.ccId, property);\n }\n };\n }\n}\n@commandClass(CommandClasses[\"Barrier Operator\"])\n@implementedVersion(1)\n@ccValues(BarrierOperatorCCValues)\nexport class BarrierOperatorCC extends CommandClass {\n declare ccCommand: BarrierOperatorCommand;\n public async interview(ctx: InterviewContext): Promise<void> {\n const node = this.getNode(ctx)!;\n const endpoint = this.getEndpoint(ctx)!;\n const api = CCAPI.create(CommandClasses[\"Barrier Operator\"], ctx, endpoint).withOptions({\n priority: MessagePriority.NodeQuery,\n tag: \"interview\",\n });\n ctx.logNode(node.id, {\n endpoint: this.endpointIndex,\n message: `Interviewing ${this.ccName}...`,\n direction: \"none\",\n });\n // Create targetState value if it does not exist\n this.ensureMetadata(ctx, BarrierOperatorCCValues.targetState);\n ctx.logNode(node.id, {\n message: \"Querying signaling capabilities...\",\n direction: \"outbound\",\n });\n const resp = await api.getSignalingCapabilities();\n if (resp) {\n ctx.logNode(node.id, {\n message: logText(\"Received supported subsystem types:\", {\n nested: logList(resp.map((t) => getEnumMemberName(SubsystemType, t))),\n }),\n direction: \"inbound\",\n });\n // Enable all supported subsystems\n for (const subsystemType of resp) {\n // Some devices report invalid subsystem types, but the CC API checks\n // for valid values and throws otherwise.\n if (!isEnumMember(SubsystemType, subsystemType))\n continue;\n ctx.logNode(node.id, {\n message: `Enabling subsystem ${getEnumMemberName(SubsystemType, subsystemType)}...`,\n direction: \"outbound\",\n });\n await api\n .setEventSignaling(subsystemType, SubsystemState.On)\n .catch(noop);\n }\n }\n await this.refreshValues(ctx, { tag: \"interview\" });\n // Remember that the interview is complete\n this.setInterviewComplete(ctx, true);\n }\n public async refreshValues(ctx: RefreshValuesContext, options?: RefreshValuesOptions): Promise<void> {\n const node = this.getNode(ctx)!;\n const endpoint = this.getEndpoint(ctx)!;\n const api = CCAPI.create(CommandClasses[\"Barrier Operator\"], ctx, endpoint).withOptions({\n priority: options?.priority ?? MessagePriority.NodeQuery,\n tag: options?.tag,\n });\n const supportedSubsystems: SubsystemType[] = this.getValue(ctx, BarrierOperatorCCValues.supportedSubsystemTypes)\n ?? [];\n for (const subsystemType of supportedSubsystems) {\n // Some devices report invalid subsystem types, but the CC API checks\n // for valid values and throws otherwise.\n if (!isEnumMember(SubsystemType, subsystemType))\n continue;\n ctx.logNode(node.id, {\n message: `Querying event signaling state for subsystem ${getEnumMemberName(SubsystemType, subsystemType)}...`,\n direction: \"outbound\",\n });\n const state = await api.getEventSignaling(subsystemType);\n if (state != undefined) {\n ctx.logNode(node.id, {\n message: `Subsystem ${getEnumMemberName(SubsystemType, subsystemType)} has state ${getEnumMemberName(SubsystemState, state)}`,\n direction: \"inbound\",\n });\n }\n }\n ctx.logNode(node.id, {\n message: \"querying current barrier state...\",\n direction: \"outbound\",\n });\n await api.get();\n }\n}\n// @publicAPI\nexport interface BarrierOperatorCCSetOptions {\n targetState: BarrierState.Open | BarrierState.Closed;\n}\nfunction getCCResponseForBarrierOperatorCCSet(ctx: GetNode<NodeId & SupportsCC>, sent: BarrierOperatorCCSet) {\n // CC:0066.01.01.11.009: If the requested operation is prohibited by\n // the specific device class [...], the device MUST notify the requester\n // by issuing an Application Rejected Request Command\n if (sent.isSinglecast()\n && !sent.isEncapsulatedWith(CommandClasses.Supervision)\n && ctx\n .getNode(sent.nodeId)\n ?.supportsCC(CommandClasses[\"Application Status\"])) {\n return ApplicationStatusCCRejectedRequest;\n }\n}\n@CCCommand(BarrierOperatorCommand.Set)\n@expectedCCResponse(getCCResponseForBarrierOperatorCCSet)\n@useSupervision()\nexport class BarrierOperatorCCSet extends BarrierOperatorCC {\n public constructor(options: WithAddress<BarrierOperatorCCSetOptions>) {\n super(options);\n this.targetState = options.targetState;\n }\n public static from(raw: CCRaw, ctx: CCParsingContext): BarrierOperatorCCSet {\n validatePayload(raw.payload.length >= 1);\n const targetState = raw.payload[0];\n validatePayload(targetState === BarrierState.Open\n || targetState === BarrierState.Closed);\n return new this({ nodeId: ctx.sourceNodeId, targetState });\n }\n public targetState: BarrierState.Open | BarrierState.Closed;\n public serialize(ctx: CCEncodingContext): Promise<Bytes> {\n this.payload = Bytes.from([this.targetState]);\n return super.serialize(ctx);\n }\n public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n return {\n ...super.toLogEntry(ctx),\n message: { \"target state\": this.targetState },\n };\n }\n}\n// @publicAPI\nexport interface BarrierOperatorCCReportOptions {\n position: MaybeUnknown<number>;\n currentState: MaybeUnknown<BarrierState>;\n}\n@CCCommand(BarrierOperatorCommand.Report)\n@ccValueProperty(\"currentState\", BarrierOperatorCCValues.currentState)\n@ccValueProperty(\"position\", BarrierOperatorCCValues.position)\nexport class BarrierOperatorCCReport extends BarrierOperatorCC {\n public constructor(options: WithAddress<BarrierOperatorCCReportOptions>) {\n super(options);\n // TODO: Check implementation:\n this.position = options.position;\n this.currentState = options.currentState;\n }\n public static from(raw: CCRaw, ctx: CCParsingContext): BarrierOperatorCCReport {\n validatePayload(raw.payload.length >= 1);\n // The payload byte encodes information about the state and position in a single value\n const payloadValue = raw.payload[0];\n let position: MaybeUnknown<number>;\n if (payloadValue <= 99) {\n // known position\n position = payloadValue;\n }\n else if (payloadValue === 255) {\n // known position, fully opened\n position = 100;\n }\n else {\n // unknown position\n position = UNKNOWN_STATE;\n }\n let currentState: MaybeUnknown<BarrierState>;\n if (payloadValue === BarrierState.Closed\n || payloadValue >= BarrierState.Closing) {\n // predefined states\n currentState = payloadValue;\n }\n else if (payloadValue > 0 && payloadValue <= 99) {\n // stopped at exact position\n currentState = BarrierState.Stopped;\n }\n else {\n // invalid value, assume unknown\n currentState = UNKNOWN_STATE;\n }\n return new this({\n nodeId: ctx.sourceNodeId,\n position,\n currentState,\n });\n }\n public readonly currentState: MaybeUnknown<BarrierState>;\n public readonly position: MaybeUnknown<number>;\n public serialize(ctx: CCEncodingContext): Promise<Bytes> {\n let value: number;\n if (this.currentState === BarrierState.Stopped\n && typeof this.position === \"number\") {\n value = this.position === 100 ? 0xff : this.position;\n }\n else if (this.currentState != null) {\n value = this.currentState;\n }\n else {\n throw new ZWaveError(\"Cannot serialize a Barrier Operator Report without a known state\", ZWaveErrorCodes.Argument_Invalid);\n }\n this.payload = Bytes.from([value]);\n return super.serialize(ctx);\n }\n public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n return {\n ...super.toLogEntry(ctx),\n message: {\n \"barrier position\": maybeUnknownToString(this.position),\n \"barrier state\": this.currentState != undefined\n ? getEnumMemberName(BarrierState, this.currentState)\n : \"unknown\",\n },\n };\n }\n}\n@CCCommand(BarrierOperatorCommand.Get)\n@expectedCCResponse(BarrierOperatorCCReport)\nexport class BarrierOperatorCCGet extends BarrierOperatorCC {\n}\n// @publicAPI\nexport interface BarrierOperatorCCSignalingCapabilitiesReportOptions {\n supportedSubsystemTypes: SubsystemType[];\n}\n@CCCommand(BarrierOperatorCommand.SignalingCapabilitiesReport)\n@ccValueProperty(\"supportedSubsystemTypes\", BarrierOperatorCCValues.supportedSubsystemTypes)\nexport class BarrierOperatorCCSignalingCapabilitiesReport extends BarrierOperatorCC {\n public constructor(options: WithAddress<BarrierOperatorCCSignalingCapabilitiesReportOptions>) {\n super(options);\n // TODO: Check implementation:\n this.supportedSubsystemTypes = options.supportedSubsystemTypes;\n }\n public static from(raw: CCRaw, ctx: CCParsingContext): BarrierOperatorCCSignalingCapabilitiesReport {\n const supportedSubsystemTypes: SubsystemType[] = parseBitMask(raw.payload, SubsystemType.Audible);\n return new this({\n nodeId: ctx.sourceNodeId,\n supportedSubsystemTypes,\n });\n }\n public readonly supportedSubsystemTypes: readonly SubsystemType[];\n public serialize(ctx: CCEncodingContext): Promise<Bytes> {\n this.payload = encodeBitMask(this.supportedSubsystemTypes, undefined, SubsystemType.Audible);\n return super.serialize(ctx);\n }\n public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n return {\n ...super.toLogEntry(ctx),\n message: {\n \"supported types\": logList(this.supportedSubsystemTypes.map((t) => getEnumMemberName(SubsystemType, t))),\n },\n };\n }\n}\n@CCCommand(BarrierOperatorCommand.SignalingCapabilitiesGet)\n@expectedCCResponse(BarrierOperatorCCSignalingCapabilitiesReport)\nexport class BarrierOperatorCCSignalingCapabilitiesGet extends BarrierOperatorCC {\n}\n// @publicAPI\nexport interface BarrierOperatorCCEventSignalingSetOptions {\n subsystemType: SubsystemType;\n subsystemState: SubsystemState;\n}\n@CCCommand(BarrierOperatorCommand.EventSignalingSet)\n@useSupervision()\nexport class BarrierOperatorCCEventSignalingSet extends BarrierOperatorCC {\n public constructor(options: WithAddress<BarrierOperatorCCEventSignalingSetOptions>) {\n super(options);\n this.subsystemType = options.subsystemType;\n this.subsystemState = options.subsystemState;\n }\n public static from(raw: CCRaw, ctx: CCParsingContext): BarrierOperatorCCEventSignalingSet {\n validatePayload(raw.payload.length >= 2);\n const subsystemType = parseEnumValue(SubsystemType, raw.payload[0]);\n const subsystemState = parseEnumValue(SubsystemState, raw.payload[1]);\n return new this({\n nodeId: ctx.sourceNodeId,\n subsystemType,\n subsystemState,\n });\n }\n public subsystemType: SubsystemType;\n public subsystemState: SubsystemState;\n public serialize(ctx: CCEncodingContext): Promise<Bytes> {\n this.payload = Bytes.from([this.subsystemType, this.subsystemState]);\n return super.serialize(ctx);\n }\n public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n return {\n ...super.toLogEntry(ctx),\n message: {\n \"subsystem type\": getEnumMemberName(SubsystemType, this.subsystemType),\n \"subsystem state\": getEnumMemberName(SubsystemState, this.subsystemState),\n },\n };\n }\n}\n// @publicAPI\nexport interface BarrierOperatorCCEventSignalingReportOptions {\n subsystemType: SubsystemType;\n subsystemState: SubsystemState;\n}\n@CCCommand(BarrierOperatorCommand.EventSignalingReport)\nexport class BarrierOperatorCCEventSignalingReport extends BarrierOperatorCC {\n public constructor(options: WithAddress<BarrierOperatorCCEventSignalingReportOptions>) {\n super(options);\n // TODO: Check implementation:\n this.subsystemType = options.subsystemType;\n this.subsystemState = options.subsystemState;\n }\n public static from(raw: CCRaw, ctx: CCParsingContext): BarrierOperatorCCEventSignalingReport {\n validatePayload(raw.payload.length >= 2);\n const subsystemType = parseEnumValue(SubsystemType, raw.payload[0]);\n const subsystemState = parseEnumValue(SubsystemState, raw.payload[1]);\n return new this({\n nodeId: ctx.sourceNodeId,\n subsystemType,\n subsystemState,\n });\n }\n public persistValues(ctx: PersistValuesContext): boolean {\n if (!super.persistValues(ctx))\n return false;\n const signalingStateValue = BarrierOperatorCCValues.signalingState(this.subsystemType);\n this.ensureMetadata(ctx, signalingStateValue);\n this.setValue(ctx, signalingStateValue, this.subsystemState);\n return true;\n }\n public readonly subsystemType: SubsystemType;\n public readonly subsystemState: SubsystemState;\n public serialize(ctx: CCEncodingContext): Promise<Bytes> {\n this.payload = Bytes.from([this.subsystemType, this.subsystemState]);\n return super.serialize(ctx);\n }\n public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n return {\n ...super.toLogEntry(ctx),\n message: {\n \"subsystem type\": getEnumMemberName(SubsystemType, this.subsystemType),\n \"subsystem state\": getEnumMemberName(SubsystemState, this.subsystemState),\n },\n };\n }\n}\n// @publicAPI\nexport interface BarrierOperatorCCEventSignalingGetOptions {\n subsystemType: SubsystemType;\n}\n@CCCommand(BarrierOperatorCommand.EventSignalingGet)\n@expectedCCResponse(BarrierOperatorCCEventSignalingReport)\nexport class BarrierOperatorCCEventSignalingGet extends BarrierOperatorCC {\n public constructor(options: WithAddress<BarrierOperatorCCEventSignalingGetOptions>) {\n super(options);\n this.subsystemType = options.subsystemType;\n }\n public static from(raw: CCRaw, ctx: CCParsingContext): BarrierOperatorCCEventSignalingGet {\n validatePayload(raw.payload.length >= 1);\n const subsystemType = parseEnumValue(SubsystemType, raw.payload[0]);\n return new this({ nodeId: ctx.sourceNodeId, subsystemType });\n }\n public subsystemType: SubsystemType;\n public serialize(ctx: CCEncodingContext): Promise<Bytes> {\n this.payload = Bytes.from([this.subsystemType]);\n return super.serialize(ctx);\n }\n public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n return {\n ...super.toLogEntry(ctx),\n message: {\n \"subsystem type\": getEnumMemberName(SubsystemType, this.subsystemType),\n },\n };\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qBAAgC;AAEhC,kBAAsZ;AACtZ,oBAAoE;AACpE,iBAAwQ;AACxQ,0BAAkJ;AAClJ,oCAAiI;AAEjI,mBAAqF;AA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A,UAAU,KAAsB;AACnC,WAAK,UAAU,oBAAM,KAAK,CAAC,KAAK,aAAa,CAAC;AAC9C,aAAO,MAAM,UAAU,GAAG;IAC9B;IACO,WAAW,KAAgB;AAC9B,aAAO;QACH,GAAG,MAAM,WAAW,GAAG;QACvB,SAAS;UACL,sBAAkB,iCAAkB,4BAAe,KAAK,aAAa;;;IAGjF;;;;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -305,9 +305,8 @@ let BinarySensorCCReport = (() => {
|
|
|
305
305
|
const value = raw.payload[0] === 255;
|
|
306
306
|
let type = import_Types.BinarySensorType.Any;
|
|
307
307
|
if (raw.payload.length >= 2) {
|
|
308
|
-
type = raw.payload[1];
|
|
308
|
+
type = (0, import_core.parseEnumValue)(import_Types.BinarySensorType, raw.payload[1]);
|
|
309
309
|
}
|
|
310
|
-
(0, import_core.validatePayload)((0, import_shared.isEnumMember)(import_Types.BinarySensorType, type));
|
|
311
310
|
return new this({
|
|
312
311
|
nodeId: ctx.sourceNodeId,
|
|
313
312
|
value,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src_gen/cc/BinarySensorCC.ts"],
|
|
4
|
-
"sourcesContent": ["import * as __validateArgs from \"./BinarySensorCC._validateArgs.js\";\nconst { validateArgs_BinarySensorCCAPI_get, validateArgs_BinarySensorCCAPI_sendReport, validateArgs_BinarySensorCCAPI_reportSupportedSensorTypes } = __validateArgs;\nimport { CommandClasses, type EndpointId, type GetValueDB, type MaybeNotKnown, type MessageOrCCLogEntry, MessagePriority, type SupervisionResult, ValueMetadata, type WithAddress, encodeBitMask, logList, logText, parseBitMask, validatePayload, } from \"@zwave-js/core\";\nimport { Bytes, getEnumMemberName, isEnumMember } from \"@zwave-js/shared\";\nimport { CCAPI, POLL_VALUE, PhysicalCCAPI, type PollValueImplementation, throwUnsupportedProperty, } from \"../lib/API.js\";\nimport { type CCRaw, CommandClass, type InterviewContext, type PersistValuesContext, type RefreshValuesContext, type RefreshValuesOptions, getEffectiveCCVersion, } from \"../lib/CommandClass.js\";\nimport { API, CCCommand, ccValueProperty, ccValues, commandClass, expectedCCResponse, implementedVersion, } from \"../lib/CommandClassDecorators.js\";\nimport { V } from \"../lib/Values.js\";\nimport { BinarySensorCommand, BinarySensorType } from \"../lib/_Types.js\";\nimport type { CCEncodingContext, CCParsingContext } from \"../lib/traits.js\";\nimport { BinarySensorCCValues } from \"./_CCValues.generated.js\";\nexport { BinarySensorCCValues };\n// @noSetValueAPI This CC is read-only\n@API(CommandClasses[\"Binary Sensor\"])\nexport class BinarySensorCCAPI extends PhysicalCCAPI {\n public supportsCommand(cmd: BinarySensorCommand): MaybeNotKnown<boolean> {\n switch (cmd) {\n case BinarySensorCommand.Get:\n case BinarySensorCommand.Report:\n return true; // This is mandatory\n case BinarySensorCommand.SupportedGet:\n case BinarySensorCommand.SupportedReport:\n return this.version >= 2;\n }\n return super.supportsCommand(cmd);\n }\n protected get [POLL_VALUE](): PollValueImplementation {\n return async function (this: BinarySensorCCAPI, { property }) {\n if (typeof property === \"string\") {\n const sensorType = (BinarySensorType as any)[property] as BinarySensorType | undefined;\n if (sensorType)\n return this.get(sensorType);\n }\n throwUnsupportedProperty(this.ccId, property);\n };\n }\n /**\n * Retrieves the current value from this sensor\n * @param sensorType The (optional) sensor type to retrieve the value for\n */\n @validateArgs_BinarySensorCCAPI_get()\n public async get(sensorType?: BinarySensorType): Promise<MaybeNotKnown<boolean>> {\n this.assertSupportsCommand(BinarySensorCommand, BinarySensorCommand.Get);\n const cc = new BinarySensorCCGet({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n sensorType,\n });\n const response = await this.host.sendCommand<BinarySensorCCReport>(cc, this.commandOptions);\n // We don't want to repeat the sensor type\n return response?.value;\n }\n @validateArgs_BinarySensorCCAPI_sendReport()\n public async sendReport(value: boolean, sensorType?: BinarySensorType): Promise<SupervisionResult | undefined> {\n this.assertSupportsCommand(BinarySensorCommand, BinarySensorCommand.Report);\n const cc = new BinarySensorCCReport({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n value,\n type: sensorType,\n });\n return this.host.sendCommand(cc, this.commandOptions);\n }\n public async getSupportedSensorTypes(): Promise<readonly BinarySensorType[] | undefined> {\n this.assertSupportsCommand(BinarySensorCommand, BinarySensorCommand.SupportedGet);\n const cc = new BinarySensorCCSupportedGet({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n });\n const response = await this.host.sendCommand<BinarySensorCCSupportedReport>(cc, this.commandOptions);\n // We don't want to repeat the sensor type\n return response?.supportedSensorTypes;\n }\n @validateArgs_BinarySensorCCAPI_reportSupportedSensorTypes()\n public async reportSupportedSensorTypes(supported: BinarySensorType[]): Promise<SupervisionResult | undefined> {\n this.assertSupportsCommand(BinarySensorCommand, BinarySensorCommand.SupportedReport);\n const cc = new BinarySensorCCSupportedReport({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n supportedSensorTypes: supported,\n });\n return this.host.sendCommand(cc, this.commandOptions);\n }\n}\n@commandClass(CommandClasses[\"Binary Sensor\"])\n@implementedVersion(2)\n@ccValues(BinarySensorCCValues)\nexport class BinarySensorCC extends CommandClass {\n declare ccCommand: BinarySensorCommand;\n public async interview(ctx: InterviewContext): Promise<void> {\n const node = this.getNode(ctx)!;\n const endpoint = this.getEndpoint(ctx)!;\n const api = CCAPI.create(CommandClasses[\"Binary Sensor\"], ctx, endpoint).withOptions({\n priority: MessagePriority.NodeQuery,\n tag: \"interview\",\n });\n ctx.logNode(node.id, {\n endpoint: this.endpointIndex,\n message: `Interviewing ${this.ccName}...`,\n direction: \"none\",\n });\n // Find out which sensor types this sensor supports\n if (api.version >= 2) {\n ctx.logNode(node.id, {\n endpoint: this.endpointIndex,\n message: \"querying supported sensor types...\",\n direction: \"outbound\",\n });\n const supportedSensorTypes = await api.getSupportedSensorTypes();\n if (supportedSensorTypes) {\n ctx.logNode(node.id, {\n endpoint: this.endpointIndex,\n message: logText(\"received supported sensor types:\", {\n nested: logList(supportedSensorTypes.map((type) => getEnumMemberName(BinarySensorType, type))),\n }),\n direction: \"inbound\",\n });\n }\n else {\n ctx.logNode(node.id, {\n endpoint: this.endpointIndex,\n message: \"Querying supported sensor types timed out, skipping interview...\",\n level: \"warn\",\n });\n return;\n }\n }\n await this.refreshValues(ctx, { tag: \"interview\" });\n // Remember that the interview is complete\n this.setInterviewComplete(ctx, true);\n }\n public async refreshValues(ctx: RefreshValuesContext, options?: RefreshValuesOptions): Promise<void> {\n const node = this.getNode(ctx)!;\n const endpoint = this.getEndpoint(ctx)!;\n const api = CCAPI.create(CommandClasses[\"Binary Sensor\"], ctx, endpoint).withOptions({\n priority: options?.priority ?? MessagePriority.NodeQuery,\n tag: options?.tag,\n });\n // Query (all of) the sensor's current value(s)\n if (api.version === 1) {\n ctx.logNode(node.id, {\n endpoint: this.endpointIndex,\n message: \"querying current value...\",\n direction: \"outbound\",\n });\n const currentValue = await api.get();\n if (currentValue != undefined) {\n ctx.logNode(node.id, {\n endpoint: this.endpointIndex,\n message: `received current value: ${currentValue}`,\n direction: \"inbound\",\n });\n }\n }\n else {\n const supportedSensorTypes: readonly BinarySensorType[] = this.getValue(ctx, BinarySensorCCValues.supportedSensorTypes)\n ?? [];\n for (const type of supportedSensorTypes) {\n // Some devices report invalid sensor types, but the CC API checks\n // for valid values and throws otherwise.\n if (!isEnumMember(BinarySensorType, type))\n continue;\n const sensorName = getEnumMemberName(BinarySensorType, type);\n ctx.logNode(node.id, {\n endpoint: this.endpointIndex,\n message: `querying current value for ${sensorName}...`,\n direction: \"outbound\",\n });\n const currentValue = await api.get(type);\n if (currentValue != undefined) {\n ctx.logNode(node.id, {\n endpoint: this.endpointIndex,\n message: `received current value for ${sensorName}: ${currentValue}`,\n direction: \"inbound\",\n });\n }\n }\n }\n }\n /**\n * Returns which sensor types are supported.\n * This only works AFTER the interview process\n */\n public static getSupportedSensorTypesCached(ctx: GetValueDB, endpoint: EndpointId): MaybeNotKnown<BinarySensorType[]> {\n return ctx\n .getValueDB(endpoint.nodeId)\n .getValue(BinarySensorCCValues.supportedSensorTypes.endpoint(endpoint.index));\n }\n public setMappedBasicValue(ctx: GetValueDB, value: number): boolean {\n // Prefer setting an existing value to avoid creating a spurious \"Any\" sensor type.\n // Check for the Any type first (backwards compat), then the first one that\n // already exists in the value DB. Fall back to Any if none exist.\n const valueDB = this.getValueDB(ctx);\n const anyValueId = BinarySensorCCValues.state(BinarySensorType.Any).endpoint(this.endpointIndex);\n let sensorType: BinarySensorType;\n if (valueDB.hasMetadata(anyValueId)) {\n sensorType = BinarySensorType.Any;\n }\n else {\n const existingSensorTypes = valueDB\n .getAllMetadata(CommandClasses[\"Binary Sensor\"])\n .filter((v) => v.endpoint === this.endpointIndex\n && BinarySensorCCValues.state.is(v))\n .map((v) => (v.metadata as {\n ccSpecific?: {\n sensorType?: BinarySensorType;\n };\n })?.ccSpecific?.sensorType)\n .filter((t): t is BinarySensorType => t != undefined)\n .toSorted((a, b) => a - b);\n sensorType = existingSensorTypes[0] ?? BinarySensorType.Any;\n }\n const binarySensorValue = BinarySensorCCValues.state(sensorType);\n this.setValue(ctx, binarySensorValue, value > 0);\n return true;\n }\n}\n// @publicAPI\nexport interface BinarySensorCCReportOptions {\n type?: BinarySensorType;\n value: boolean;\n}\n@CCCommand(BinarySensorCommand.Report)\nexport class BinarySensorCCReport extends BinarySensorCC {\n public constructor(options: WithAddress<BinarySensorCCReportOptions>) {\n super(options);\n this.type = options.type ?? BinarySensorType.Any;\n this.value = options.value;\n }\n public static from(raw: CCRaw, ctx: CCParsingContext): BinarySensorCCReport {\n validatePayload(raw.payload.length >= 1);\n const value = raw.payload[0] === 0xff;\n let type: BinarySensorType = BinarySensorType.Any;\n if (raw.payload.length >= 2) {\n type = raw.payload[1];\n }\n validatePayload(isEnumMember(BinarySensorType, type));\n return new this({\n nodeId: ctx.sourceNodeId,\n value,\n type,\n });\n }\n public persistValues(ctx: PersistValuesContext): boolean {\n if (!super.persistValues(ctx))\n return false;\n // The sensor type field only exists in V2+ reports.\n // Ignore it if the device advertises version 1.\n const ccVersion = getEffectiveCCVersion(ctx, this);\n // Workaround for devices reporting with sensor type Any -> find first supported sensor type and use that\n let sensorType = BinarySensorType.Any;\n if (ccVersion >= 2) {\n sensorType = this.type;\n }\n if (sensorType === BinarySensorType.Any) {\n const supportedSensorTypes = this.getValue<BinarySensorType[]>(ctx, BinarySensorCCValues.supportedSensorTypes);\n if (supportedSensorTypes?.length) {\n sensorType = supportedSensorTypes[0];\n }\n }\n const binarySensorValue = BinarySensorCCValues.state(sensorType);\n this.setMetadata(ctx, binarySensorValue, binarySensorValue.meta);\n this.setValue(ctx, binarySensorValue, this.value);\n return true;\n }\n public type: BinarySensorType;\n public value: boolean;\n public serialize(ctx: CCEncodingContext): Promise<Bytes> {\n this.payload = Bytes.from([this.value ? 0xff : 0x00, this.type]);\n return super.serialize(ctx);\n }\n public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n return {\n ...super.toLogEntry(ctx),\n message: {\n type: getEnumMemberName(BinarySensorType, this.type),\n value: this.value,\n },\n };\n }\n}\nfunction testResponseForBinarySensorGet(sent: BinarySensorCCGet, received: BinarySensorCCReport) {\n // We expect a Binary Sensor Report that matches the requested sensor type (if a type was requested)\n return (sent.sensorType == undefined\n || sent.sensorType === BinarySensorType.Any\n || received.type === sent.sensorType\n // This is technically not correct, but some devices do this anyways\n || received.type === BinarySensorType.Any);\n}\n// @publicAPI\nexport interface BinarySensorCCGetOptions {\n sensorType?: BinarySensorType;\n}\n@CCCommand(BinarySensorCommand.Get)\n@expectedCCResponse(BinarySensorCCReport, testResponseForBinarySensorGet)\nexport class BinarySensorCCGet extends BinarySensorCC {\n public constructor(options: WithAddress<BinarySensorCCGetOptions>) {\n super(options);\n this.sensorType = options.sensorType;\n }\n public static from(raw: CCRaw, ctx: CCParsingContext): BinarySensorCCGet {\n let sensorType: BinarySensorType | undefined;\n if (raw.payload.length >= 1) {\n sensorType = raw.payload[0];\n }\n return new this({\n nodeId: ctx.sourceNodeId,\n sensorType,\n });\n }\n public sensorType: BinarySensorType | undefined;\n public serialize(ctx: CCEncodingContext): Promise<Bytes> {\n this.payload = Bytes.from([this.sensorType ?? BinarySensorType.Any]);\n return super.serialize(ctx);\n }\n public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n return {\n ...super.toLogEntry(ctx),\n message: {\n type: getEnumMemberName(BinarySensorType, this.sensorType ?? BinarySensorType.Any),\n },\n };\n }\n}\n// @publicAPI\nexport interface BinarySensorCCSupportedReportOptions {\n supportedSensorTypes: BinarySensorType[];\n}\n@CCCommand(BinarySensorCommand.SupportedReport)\n@ccValueProperty(\"supportedSensorTypes\", BinarySensorCCValues.supportedSensorTypes)\nexport class BinarySensorCCSupportedReport extends BinarySensorCC {\n public constructor(options: WithAddress<BinarySensorCCSupportedReportOptions>) {\n super(options);\n this.supportedSensorTypes = options.supportedSensorTypes;\n }\n public static from(raw: CCRaw, ctx: CCParsingContext): BinarySensorCCSupportedReport {\n validatePayload(raw.payload.length >= 1);\n // The enumeration starts at 1, but the first (reserved) bit is included\n // in the report\n const supportedSensorTypes: BinarySensorType[] = parseBitMask(raw.payload, 0).filter((t) => t !== 0);\n return new this({\n nodeId: ctx.sourceNodeId,\n supportedSensorTypes,\n });\n }\n public supportedSensorTypes: BinarySensorType[];\n public serialize(ctx: CCEncodingContext): Promise<Bytes> {\n this.payload = encodeBitMask(this.supportedSensorTypes.filter((t) => t !== BinarySensorType.Any), undefined, 0);\n return super.serialize(ctx);\n }\n public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n return {\n ...super.toLogEntry(ctx),\n message: {\n \"supported types\": this.supportedSensorTypes\n .map((type) => getEnumMemberName(BinarySensorType, type))\n .join(\", \"),\n },\n };\n }\n}\n@CCCommand(BinarySensorCommand.SupportedGet)\n@expectedCCResponse(BinarySensorCCSupportedReport)\nexport class BinarySensorCCSupportedGet extends BinarySensorCC {\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qBAAgC;AAEhC,
|
|
4
|
+
"sourcesContent": ["import * as __validateArgs from \"./BinarySensorCC._validateArgs.js\";\nconst { validateArgs_BinarySensorCCAPI_get, validateArgs_BinarySensorCCAPI_sendReport, validateArgs_BinarySensorCCAPI_reportSupportedSensorTypes } = __validateArgs;\nimport { CommandClasses, type EndpointId, type GetValueDB, type MaybeNotKnown, type MessageOrCCLogEntry, MessagePriority, type SupervisionResult, ValueMetadata, type WithAddress, encodeBitMask, logList, logText, parseBitMask, parseEnumValue, validatePayload, } from \"@zwave-js/core\";\nimport { Bytes, getEnumMemberName, isEnumMember } from \"@zwave-js/shared\";\nimport { CCAPI, POLL_VALUE, PhysicalCCAPI, type PollValueImplementation, throwUnsupportedProperty, } from \"../lib/API.js\";\nimport { type CCRaw, CommandClass, type InterviewContext, type PersistValuesContext, type RefreshValuesContext, type RefreshValuesOptions, getEffectiveCCVersion, } from \"../lib/CommandClass.js\";\nimport { API, CCCommand, ccValueProperty, ccValues, commandClass, expectedCCResponse, implementedVersion, } from \"../lib/CommandClassDecorators.js\";\nimport { V } from \"../lib/Values.js\";\nimport { BinarySensorCommand, BinarySensorType } from \"../lib/_Types.js\";\nimport type { CCEncodingContext, CCParsingContext } from \"../lib/traits.js\";\nimport { BinarySensorCCValues } from \"./_CCValues.generated.js\";\nexport { BinarySensorCCValues };\n// @noSetValueAPI This CC is read-only\n@API(CommandClasses[\"Binary Sensor\"])\nexport class BinarySensorCCAPI extends PhysicalCCAPI {\n public supportsCommand(cmd: BinarySensorCommand): MaybeNotKnown<boolean> {\n switch (cmd) {\n case BinarySensorCommand.Get:\n case BinarySensorCommand.Report:\n return true; // This is mandatory\n case BinarySensorCommand.SupportedGet:\n case BinarySensorCommand.SupportedReport:\n return this.version >= 2;\n }\n return super.supportsCommand(cmd);\n }\n protected get [POLL_VALUE](): PollValueImplementation {\n return async function (this: BinarySensorCCAPI, { property }) {\n if (typeof property === \"string\") {\n const sensorType = (BinarySensorType as any)[property] as BinarySensorType | undefined;\n if (sensorType)\n return this.get(sensorType);\n }\n throwUnsupportedProperty(this.ccId, property);\n };\n }\n /**\n * Retrieves the current value from this sensor\n * @param sensorType The (optional) sensor type to retrieve the value for\n */\n @validateArgs_BinarySensorCCAPI_get()\n public async get(sensorType?: BinarySensorType): Promise<MaybeNotKnown<boolean>> {\n this.assertSupportsCommand(BinarySensorCommand, BinarySensorCommand.Get);\n const cc = new BinarySensorCCGet({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n sensorType,\n });\n const response = await this.host.sendCommand<BinarySensorCCReport>(cc, this.commandOptions);\n // We don't want to repeat the sensor type\n return response?.value;\n }\n @validateArgs_BinarySensorCCAPI_sendReport()\n public async sendReport(value: boolean, sensorType?: BinarySensorType): Promise<SupervisionResult | undefined> {\n this.assertSupportsCommand(BinarySensorCommand, BinarySensorCommand.Report);\n const cc = new BinarySensorCCReport({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n value,\n type: sensorType,\n });\n return this.host.sendCommand(cc, this.commandOptions);\n }\n public async getSupportedSensorTypes(): Promise<readonly BinarySensorType[] | undefined> {\n this.assertSupportsCommand(BinarySensorCommand, BinarySensorCommand.SupportedGet);\n const cc = new BinarySensorCCSupportedGet({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n });\n const response = await this.host.sendCommand<BinarySensorCCSupportedReport>(cc, this.commandOptions);\n // We don't want to repeat the sensor type\n return response?.supportedSensorTypes;\n }\n @validateArgs_BinarySensorCCAPI_reportSupportedSensorTypes()\n public async reportSupportedSensorTypes(supported: BinarySensorType[]): Promise<SupervisionResult | undefined> {\n this.assertSupportsCommand(BinarySensorCommand, BinarySensorCommand.SupportedReport);\n const cc = new BinarySensorCCSupportedReport({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n supportedSensorTypes: supported,\n });\n return this.host.sendCommand(cc, this.commandOptions);\n }\n}\n@commandClass(CommandClasses[\"Binary Sensor\"])\n@implementedVersion(2)\n@ccValues(BinarySensorCCValues)\nexport class BinarySensorCC extends CommandClass {\n declare ccCommand: BinarySensorCommand;\n public async interview(ctx: InterviewContext): Promise<void> {\n const node = this.getNode(ctx)!;\n const endpoint = this.getEndpoint(ctx)!;\n const api = CCAPI.create(CommandClasses[\"Binary Sensor\"], ctx, endpoint).withOptions({\n priority: MessagePriority.NodeQuery,\n tag: \"interview\",\n });\n ctx.logNode(node.id, {\n endpoint: this.endpointIndex,\n message: `Interviewing ${this.ccName}...`,\n direction: \"none\",\n });\n // Find out which sensor types this sensor supports\n if (api.version >= 2) {\n ctx.logNode(node.id, {\n endpoint: this.endpointIndex,\n message: \"querying supported sensor types...\",\n direction: \"outbound\",\n });\n const supportedSensorTypes = await api.getSupportedSensorTypes();\n if (supportedSensorTypes) {\n ctx.logNode(node.id, {\n endpoint: this.endpointIndex,\n message: logText(\"received supported sensor types:\", {\n nested: logList(supportedSensorTypes.map((type) => getEnumMemberName(BinarySensorType, type))),\n }),\n direction: \"inbound\",\n });\n }\n else {\n ctx.logNode(node.id, {\n endpoint: this.endpointIndex,\n message: \"Querying supported sensor types timed out, skipping interview...\",\n level: \"warn\",\n });\n return;\n }\n }\n await this.refreshValues(ctx, { tag: \"interview\" });\n // Remember that the interview is complete\n this.setInterviewComplete(ctx, true);\n }\n public async refreshValues(ctx: RefreshValuesContext, options?: RefreshValuesOptions): Promise<void> {\n const node = this.getNode(ctx)!;\n const endpoint = this.getEndpoint(ctx)!;\n const api = CCAPI.create(CommandClasses[\"Binary Sensor\"], ctx, endpoint).withOptions({\n priority: options?.priority ?? MessagePriority.NodeQuery,\n tag: options?.tag,\n });\n // Query (all of) the sensor's current value(s)\n if (api.version === 1) {\n ctx.logNode(node.id, {\n endpoint: this.endpointIndex,\n message: \"querying current value...\",\n direction: \"outbound\",\n });\n const currentValue = await api.get();\n if (currentValue != undefined) {\n ctx.logNode(node.id, {\n endpoint: this.endpointIndex,\n message: `received current value: ${currentValue}`,\n direction: \"inbound\",\n });\n }\n }\n else {\n const supportedSensorTypes: readonly BinarySensorType[] = this.getValue(ctx, BinarySensorCCValues.supportedSensorTypes)\n ?? [];\n for (const type of supportedSensorTypes) {\n // Some devices report invalid sensor types, but the CC API checks\n // for valid values and throws otherwise.\n if (!isEnumMember(BinarySensorType, type))\n continue;\n const sensorName = getEnumMemberName(BinarySensorType, type);\n ctx.logNode(node.id, {\n endpoint: this.endpointIndex,\n message: `querying current value for ${sensorName}...`,\n direction: \"outbound\",\n });\n const currentValue = await api.get(type);\n if (currentValue != undefined) {\n ctx.logNode(node.id, {\n endpoint: this.endpointIndex,\n message: `received current value for ${sensorName}: ${currentValue}`,\n direction: \"inbound\",\n });\n }\n }\n }\n }\n /**\n * Returns which sensor types are supported.\n * This only works AFTER the interview process\n */\n public static getSupportedSensorTypesCached(ctx: GetValueDB, endpoint: EndpointId): MaybeNotKnown<BinarySensorType[]> {\n return ctx\n .getValueDB(endpoint.nodeId)\n .getValue(BinarySensorCCValues.supportedSensorTypes.endpoint(endpoint.index));\n }\n public setMappedBasicValue(ctx: GetValueDB, value: number): boolean {\n // Prefer setting an existing value to avoid creating a spurious \"Any\" sensor type.\n // Check for the Any type first (backwards compat), then the first one that\n // already exists in the value DB. Fall back to Any if none exist.\n const valueDB = this.getValueDB(ctx);\n const anyValueId = BinarySensorCCValues.state(BinarySensorType.Any).endpoint(this.endpointIndex);\n let sensorType: BinarySensorType;\n if (valueDB.hasMetadata(anyValueId)) {\n sensorType = BinarySensorType.Any;\n }\n else {\n const existingSensorTypes = valueDB\n .getAllMetadata(CommandClasses[\"Binary Sensor\"])\n .filter((v) => v.endpoint === this.endpointIndex\n && BinarySensorCCValues.state.is(v))\n .map((v) => (v.metadata as {\n ccSpecific?: {\n sensorType?: BinarySensorType;\n };\n })?.ccSpecific?.sensorType)\n .filter((t): t is BinarySensorType => t != undefined)\n .toSorted((a, b) => a - b);\n sensorType = existingSensorTypes[0] ?? BinarySensorType.Any;\n }\n const binarySensorValue = BinarySensorCCValues.state(sensorType);\n this.setValue(ctx, binarySensorValue, value > 0);\n return true;\n }\n}\n// @publicAPI\nexport interface BinarySensorCCReportOptions {\n type?: BinarySensorType;\n value: boolean;\n}\n@CCCommand(BinarySensorCommand.Report)\nexport class BinarySensorCCReport extends BinarySensorCC {\n public constructor(options: WithAddress<BinarySensorCCReportOptions>) {\n super(options);\n this.type = options.type ?? BinarySensorType.Any;\n this.value = options.value;\n }\n public static from(raw: CCRaw, ctx: CCParsingContext): BinarySensorCCReport {\n validatePayload(raw.payload.length >= 1);\n const value = raw.payload[0] === 0xff;\n let type: BinarySensorType = BinarySensorType.Any;\n if (raw.payload.length >= 2) {\n type = parseEnumValue(BinarySensorType, raw.payload[1]);\n }\n return new this({\n nodeId: ctx.sourceNodeId,\n value,\n type,\n });\n }\n public persistValues(ctx: PersistValuesContext): boolean {\n if (!super.persistValues(ctx))\n return false;\n // The sensor type field only exists in V2+ reports.\n // Ignore it if the device advertises version 1.\n const ccVersion = getEffectiveCCVersion(ctx, this);\n // Workaround for devices reporting with sensor type Any -> find first supported sensor type and use that\n let sensorType = BinarySensorType.Any;\n if (ccVersion >= 2) {\n sensorType = this.type;\n }\n if (sensorType === BinarySensorType.Any) {\n const supportedSensorTypes = this.getValue<BinarySensorType[]>(ctx, BinarySensorCCValues.supportedSensorTypes);\n if (supportedSensorTypes?.length) {\n sensorType = supportedSensorTypes[0];\n }\n }\n const binarySensorValue = BinarySensorCCValues.state(sensorType);\n this.setMetadata(ctx, binarySensorValue, binarySensorValue.meta);\n this.setValue(ctx, binarySensorValue, this.value);\n return true;\n }\n public type: BinarySensorType;\n public value: boolean;\n public serialize(ctx: CCEncodingContext): Promise<Bytes> {\n this.payload = Bytes.from([this.value ? 0xff : 0x00, this.type]);\n return super.serialize(ctx);\n }\n public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n return {\n ...super.toLogEntry(ctx),\n message: {\n type: getEnumMemberName(BinarySensorType, this.type),\n value: this.value,\n },\n };\n }\n}\nfunction testResponseForBinarySensorGet(sent: BinarySensorCCGet, received: BinarySensorCCReport) {\n // We expect a Binary Sensor Report that matches the requested sensor type (if a type was requested)\n return (sent.sensorType == undefined\n || sent.sensorType === BinarySensorType.Any\n || received.type === sent.sensorType\n // This is technically not correct, but some devices do this anyways\n || received.type === BinarySensorType.Any);\n}\n// @publicAPI\nexport interface BinarySensorCCGetOptions {\n sensorType?: BinarySensorType;\n}\n@CCCommand(BinarySensorCommand.Get)\n@expectedCCResponse(BinarySensorCCReport, testResponseForBinarySensorGet)\nexport class BinarySensorCCGet extends BinarySensorCC {\n public constructor(options: WithAddress<BinarySensorCCGetOptions>) {\n super(options);\n this.sensorType = options.sensorType;\n }\n public static from(raw: CCRaw, ctx: CCParsingContext): BinarySensorCCGet {\n let sensorType: BinarySensorType | undefined;\n if (raw.payload.length >= 1) {\n sensorType = raw.payload[0];\n }\n return new this({\n nodeId: ctx.sourceNodeId,\n sensorType,\n });\n }\n public sensorType: BinarySensorType | undefined;\n public serialize(ctx: CCEncodingContext): Promise<Bytes> {\n this.payload = Bytes.from([this.sensorType ?? BinarySensorType.Any]);\n return super.serialize(ctx);\n }\n public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n return {\n ...super.toLogEntry(ctx),\n message: {\n type: getEnumMemberName(BinarySensorType, this.sensorType ?? BinarySensorType.Any),\n },\n };\n }\n}\n// @publicAPI\nexport interface BinarySensorCCSupportedReportOptions {\n supportedSensorTypes: BinarySensorType[];\n}\n@CCCommand(BinarySensorCommand.SupportedReport)\n@ccValueProperty(\"supportedSensorTypes\", BinarySensorCCValues.supportedSensorTypes)\nexport class BinarySensorCCSupportedReport extends BinarySensorCC {\n public constructor(options: WithAddress<BinarySensorCCSupportedReportOptions>) {\n super(options);\n this.supportedSensorTypes = options.supportedSensorTypes;\n }\n public static from(raw: CCRaw, ctx: CCParsingContext): BinarySensorCCSupportedReport {\n validatePayload(raw.payload.length >= 1);\n // The enumeration starts at 1, but the first (reserved) bit is included\n // in the report\n const supportedSensorTypes: BinarySensorType[] = parseBitMask(raw.payload, 0).filter((t) => t !== 0);\n return new this({\n nodeId: ctx.sourceNodeId,\n supportedSensorTypes,\n });\n }\n public supportedSensorTypes: BinarySensorType[];\n public serialize(ctx: CCEncodingContext): Promise<Bytes> {\n this.payload = encodeBitMask(this.supportedSensorTypes.filter((t) => t !== BinarySensorType.Any), undefined, 0);\n return super.serialize(ctx);\n }\n public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n return {\n ...super.toLogEntry(ctx),\n message: {\n \"supported types\": this.supportedSensorTypes\n .map((type) => getEnumMemberName(BinarySensorType, type))\n .join(\", \"),\n },\n };\n }\n}\n@CCCommand(BinarySensorCommand.SupportedGet)\n@expectedCCResponse(BinarySensorCCSupportedReport)\nexport class BinarySensorCCSupportedGet extends BinarySensorCC {\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qBAAgC;AAEhC,kBAA0Q;AAC1Q,oBAAuD;AACvD,iBAA0G;AAC1G,0BAAyK;AACzK,oCAAiH;AAEjH,mBAAsD;AAEtD,gCAAqC;AATrC,MAAM,EAAE,oCAAoC,2CAA2C,0DAAyD,IAAK;IAaxI,qBAAiB,MAAA;8BAD7B,mCAAI,2BAAe,eAAe,CAAC,CAAC;;;;oBACE;;;;;yCAAA,YAAa;WAAA;;;;;;;;yBA0B/C,mCAAkC,CAAE;gCAYpC,0CAAyC,CAAE;gDAqB3C,0DAAyD,CAAE;AAhC5D,qCAAA,MAAA,MAAA,iBAAA,EAAA,MAAA,UAAA,MAAA,OAAA,QAAA,OAAA,SAAA,OAAA,QAAA,EAAA,KAAA,gCAAA,SAAA,KAAA,QAAA,KAAA,gCAAA,IAAa,KAAb,OAAgB,GAAA,UA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
|
|
509
509
|
(0, import_core.validatePayload)(raw.payload.length >= 2);
|
|
510
|
-
const colorComponent = raw.payload[0];
|
|
511
|
-
(0, import_core.validatePayload)((0, import_shared.isEnumMember)(import_Types.ColorComponent, colorComponent));
|
|
510
|
+
const colorComponent = (0, import_core.parseEnumValue)(import_Types.ColorComponent, raw.payload[0]);
|
|
512
511
|
const currentValue = raw.payload[1];
|
|
513
512
|
let targetValue;
|
|
514
513
|
let duration;
|