@zwave-js/cc 15.15.0 → 15.15.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/NotificationCC.js +1 -1
- package/build/cjs/cc/NotificationCC.js.map +2 -2
- package/build/cjs/cc/ProtectionCC.d.ts +1 -3
- package/build/cjs/cc/ProtectionCC.js.map +1 -1
- package/build/cjs/cc/SecurityCC.d.ts +2 -0
- package/build/cjs/cc/SecurityCC.js +12 -0
- package/build/cjs/cc/SecurityCC.js.map +2 -2
- package/build/cjs/cc/_CCValues.generated.d.ts +2 -6
- package/build/cjs/cc/_CCValues.generated.js +1 -1
- package/build/cjs/cc/_CCValues.generated.js.map +1 -1
- package/build/cjs/cc/index.js +69 -65
- package/build/cjs/cc/index.js.map +1 -1
- package/build/cjs/index.js +11 -11
- package/build/cjs/index.js.map +1 -1
- package/build/esm/cc/NotificationCC.js +1 -1
- package/build/esm/cc/NotificationCC.js.map +1 -1
- package/build/esm/cc/ProtectionCC.d.ts +1 -3
- package/build/esm/cc/ProtectionCC.d.ts.map +1 -1
- package/build/esm/cc/SecurityCC.d.ts +2 -0
- package/build/esm/cc/SecurityCC.d.ts.map +1 -1
- package/build/esm/cc/SecurityCC.js +14 -0
- package/build/esm/cc/SecurityCC.js.map +1 -1
- package/build/esm/cc/_CCValues.generated.d.ts +2 -6
- package/build/esm/cc/_CCValues.generated.d.ts.map +1 -1
- package/build/esm/cc/_CCValues.generated.js +1 -1
- package/build/esm/cc/_CCValues.generated.js.map +1 -1
- package/package.json +7 -7
|
@@ -781,7 +781,7 @@ let NotificationCCReport = (() => {
|
|
|
781
781
|
}
|
|
782
782
|
} else if ((0, import_shared.isUint8Array)(this.eventParameters)) {
|
|
783
783
|
message["event parameters"] = (0, import_shared.buffer2hex)(this.eventParameters);
|
|
784
|
-
} else if (import_core.Duration
|
|
784
|
+
} else if (this.eventParameters instanceof import_core.Duration) {
|
|
785
785
|
message["event parameters"] = this.eventParameters.toString();
|
|
786
786
|
} else {
|
|
787
787
|
message["event parameters"] = Object.entries(this.eventParameters).map(([param, val]) => `
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cc/NotificationCC.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\tDuration,\n\ttype EndpointId,\n\ttype GetEndpoint,\n\ttype GetNode,\n\ttype GetSupportedCCVersion,\n\ttype GetValueDB,\n\ttype LogNode,\n\ttype MaybeNotKnown,\n\ttype MessageOrCCLogEntry,\n\tMessagePriority,\n\ttype MessageRecord,\n\ttype NodeId,\n\ttype Notification,\n\ttype NotificationState,\n\ttype NotificationValue,\n\tSecurityClass,\n\ttype SinglecastCC,\n\ttype SupervisionResult,\n\ttype SupportsCC,\n\ttype ValueID,\n\tValueMetadata,\n\ttype ValueMetadataNumeric,\n\ttype WithAddress,\n\tZWaveError,\n\tZWaveErrorCodes,\n\tencodeBitMask,\n\tgetCCName,\n\tgetNotification,\n\tgetNotificationEventName,\n\tgetNotificationName,\n\tgetNotificationValue,\n\tgetNotificationValueName,\n\tisZWaveError,\n\tparseBitMask,\n\ttimespan,\n\tvalidatePayload,\n} from \"@zwave-js/core\";\nimport {\n\tBytes,\n\tbuffer2hex,\n\tisUint8Array,\n\tnum2hex,\n\tpick,\n} from \"@zwave-js/shared\";\nimport { validateArgs } from \"@zwave-js/transformers\";\nimport { isArray } from \"alcalzone-shared/typeguards\";\nimport {\n\tCCAPI,\n\tPOLL_VALUE,\n\tPhysicalCCAPI,\n\ttype PollValueImplementation,\n\tthrowUnsupportedProperty,\n} from \"../lib/API.js\";\nimport {\n\tCCRaw,\n\tCommandClass,\n\ttype InterviewContext,\n\tInvalidCC,\n\ttype PersistValuesContext,\n\ttype RefreshValuesContext,\n\tgetEffectiveCCVersion,\n} from \"../lib/CommandClass.js\";\nimport {\n\tAPI,\n\tCCCommand,\n\tccValueProperty,\n\tccValues,\n\tcommandClass,\n\texpectedCCResponse,\n\tgetCCCommandConstructor,\n\timplementedVersion,\n\tuseSupervision,\n} from \"../lib/CommandClassDecorators.js\";\nimport { isNotificationEventPayload } from \"../lib/NotificationEventPayload.js\";\nimport { V } from \"../lib/Values.js\";\nimport { NotificationCommand, UserCodeCommand } from \"../lib/_Types.js\";\nimport * as ccUtils from \"../lib/utils.js\";\nimport { AssociationGroupInfoCC } from \"./AssociationGroupInfoCC.js\";\n\nexport const NotificationCCValues = V.defineCCValues(\n\tCommandClasses.Notification,\n\t{\n\t\t...V.staticProperty(\"supportsV1Alarm\", undefined, {\n\t\t\tinternal: true,\n\t\t\tsupportsEndpoints: false,\n\t\t}),\n\t\t...V.staticProperty(\"supportedNotificationTypes\", undefined, {\n\t\t\tinternal: true,\n\t\t\tsupportsEndpoints: false,\n\t\t}),\n\t\t...V.staticProperty(\"notificationMode\", undefined, {\n\t\t\tinternal: true,\n\t\t\tsupportsEndpoints: false,\n\t\t}),\n\t\t...V.staticProperty(\"lastRefresh\", undefined, {\n\t\t\tinternal: true,\n\t\t}),\n\t\t...V.staticProperty(\n\t\t\t\"alarmType\",\n\t\t\t{\n\t\t\t\t...ValueMetadata.ReadOnlyUInt8,\n\t\t\t\tlabel: \"Alarm Type\",\n\t\t\t} as const,\n\t\t),\n\t\t...V.staticProperty(\n\t\t\t\"alarmLevel\",\n\t\t\t{\n\t\t\t\t...ValueMetadata.ReadOnlyUInt8,\n\t\t\t\tlabel: \"Alarm Level\",\n\t\t\t} as const,\n\t\t),\n\t\t...V.staticPropertyAndKeyWithName(\n\t\t\t\"doorStateSimple\",\n\t\t\t\"Access Control\",\n\t\t\t\"Door state (simple)\",\n\t\t\t{\n\t\t\t\t// Must be a number for compatibility reasons\n\t\t\t\t...ValueMetadata.ReadOnlyUInt8,\n\t\t\t\tlabel: \"Door state (simple)\",\n\t\t\t\tstates: {\n\t\t\t\t\t[0x16]: \"Window/door is open\",\n\t\t\t\t\t[0x17]: \"Window/door is closed\",\n\t\t\t\t},\n\t\t\t\tccSpecific: {\n\t\t\t\t\tnotificationType: 0x06,\n\t\t\t\t},\n\t\t\t} as const,\n\t\t\t{\n\t\t\t\tautoCreate: shouldAutoCreateSimpleDoorSensorValue,\n\t\t\t} as const,\n\t\t),\n\t\t...V.staticPropertyAndKeyWithName(\n\t\t\t\"doorTiltState\",\n\t\t\t\"Access Control\",\n\t\t\t\"Door tilt state\",\n\t\t\t{\n\t\t\t\t// Must be a number for compatibility reasons\n\t\t\t\t...ValueMetadata.ReadOnlyUInt8,\n\t\t\t\tlabel: \"Door tilt state\",\n\t\t\t\tstates: {\n\t\t\t\t\t[0x00]: \"Window/door is not tilted\",\n\t\t\t\t\t[0x01]: \"Window/door is tilted\",\n\t\t\t\t},\n\t\t\t\tccSpecific: {\n\t\t\t\t\tnotificationType: 0x06,\n\t\t\t\t},\n\t\t\t} as const,\n\t\t\t{\n\t\t\t\t// This is created when the tilt state is first received.\n\t\t\t\tautoCreate: false,\n\t\t\t} as const,\n\t\t),\n\t\t...V.dynamicPropertyAndKeyWithName(\n\t\t\t\"supportedNotificationEvents\",\n\t\t\t\"supportedNotificationEvents\",\n\t\t\t(notificationType: number) => notificationType,\n\t\t\t({ property, propertyKey }) =>\n\t\t\t\tproperty === \"supportedNotificationEvents\"\n\t\t\t\t&& typeof propertyKey === \"number\",\n\t\t\tundefined,\n\t\t\t{ internal: true, supportsEndpoints: false },\n\t\t),\n\t\t...V.dynamicPropertyWithName(\n\t\t\t\"unknownNotificationType\",\n\t\t\t(notificationType: number) =>\n\t\t\t\t`UNKNOWN_${num2hex(notificationType)}`,\n\t\t\t({ property }) =>\n\t\t\t\ttypeof property === \"string\"\n\t\t\t\t&& property.startsWith(\"UNKNOWN_0x\"),\n\t\t\t(notificationType: number) => ({\n\t\t\t\t...ValueMetadata.ReadOnlyUInt8,\n\t\t\t\tlabel: `Unknown notification (${\n\t\t\t\t\tnum2hex(\n\t\t\t\t\t\tnotificationType,\n\t\t\t\t\t)\n\t\t\t\t})`,\n\t\t\t\tccSpecific: { notificationType },\n\t\t\t} as const),\n\t\t),\n\t\t...V.dynamicPropertyAndKeyWithName(\n\t\t\t\"unknownNotificationVariable\",\n\t\t\t(notificationType: number, notificationName: string) =>\n\t\t\t\tnotificationName,\n\t\t\t\"unknown\",\n\t\t\t({ property, propertyKey }) =>\n\t\t\t\ttypeof property === \"string\" && propertyKey === \"unknown\",\n\t\t\t(notificationType: number, notificationName: string) => ({\n\t\t\t\t...ValueMetadata.ReadOnlyUInt8,\n\t\t\t\tlabel: `${notificationName}: Unknown value`,\n\t\t\t\tccSpecific: { notificationType },\n\t\t\t} as const),\n\t\t),\n\t\t...V.dynamicPropertyAndKeyWithName(\n\t\t\t\"notificationVariable\",\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\t\t\t(notificationName: string, variableName: string) =>\n\t\t\t\tnotificationName,\n\t\t\t(notificationName: string, variableName: string) => variableName,\n\t\t\t({ property, propertyKey }) =>\n\t\t\t\ttypeof property === \"string\" && typeof propertyKey === \"string\",\n\t\t\t// Notification metadata is so dynamic, it does not make sense to define it here\n\t\t\tundefined,\n\t\t),\n\t},\n);\n\nexport function shouldAutoCreateSimpleDoorSensorValue(\n\tctx: GetValueDB,\n\tendpoint: EndpointId,\n): boolean {\n\tconst valueDB = ctx.tryGetValueDB(endpoint.nodeId);\n\tif (!valueDB) return false;\n\tconst supportedACEvents = valueDB.getValue<readonly number[]>(\n\t\tNotificationCCValues.supportedNotificationEvents(\n\t\t\t// Access Control\n\t\t\t0x06,\n\t\t).endpoint(endpoint.index),\n\t);\n\tif (!supportedACEvents) return false;\n\treturn (\n\t\tsupportedACEvents.includes(\n\t\t\t// Window/door is open\n\t\t\t0x16,\n\t\t)\n\t\t&& supportedACEvents.includes(\n\t\t\t// Window/door is closed\n\t\t\t0x17,\n\t\t)\n\t);\n}\n\n@API(CommandClasses.Notification)\nexport class NotificationCCAPI extends PhysicalCCAPI {\n\tpublic supportsCommand(cmd: NotificationCommand): MaybeNotKnown<boolean> {\n\t\tswitch (cmd) {\n\t\t\tcase NotificationCommand.Report:\n\t\t\tcase NotificationCommand.Get:\n\t\t\t\treturn true; // These exist starting with V1\n\n\t\t\tcase NotificationCommand.Set:\n\t\t\tcase NotificationCommand.SupportedGet:\n\t\t\t\treturn this.version >= 2;\n\n\t\t\tcase NotificationCommand.EventSupportedGet:\n\t\t\t\treturn this.version >= 3;\n\t\t}\n\t\treturn super.supportsCommand(cmd);\n\t}\n\n\tprotected get [POLL_VALUE](): PollValueImplementation {\n\t\treturn async function(\n\t\t\tthis: NotificationCCAPI,\n\t\t\t{ property, propertyKey },\n\t\t) {\n\t\t\tconst valueId: ValueID = {\n\t\t\t\tcommandClass: this.ccId,\n\t\t\t\tendpoint: this.endpoint.index,\n\t\t\t\tproperty,\n\t\t\t\tpropertyKey,\n\t\t\t};\n\t\t\tif (NotificationCCValues.notificationVariable.is(valueId)) {\n\t\t\t\tconst notificationType: number | undefined = this\n\t\t\t\t\t.tryGetValueDB()?.getMetadata(valueId)?.ccSpecific\n\t\t\t\t\t?.notificationType;\n\t\t\t\tif (notificationType != undefined) {\n\t\t\t\t\treturn this.getInternal({ notificationType });\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthrowUnsupportedProperty(this.ccId, property);\n\t\t};\n\t}\n\n\t/**\n\t * @internal\n\t */\n\tpublic async getInternal(\n\t\toptions: NotificationCCGetOptions,\n\t): Promise<NotificationCCReport | undefined> {\n\t\tthis.assertSupportsCommand(\n\t\t\tNotificationCommand,\n\t\t\tNotificationCommand.Get,\n\t\t);\n\n\t\tconst cc = new NotificationCCGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\t...options,\n\t\t});\n\t\treturn this.host.sendCommand<NotificationCCReport>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t}\n\n\t@validateArgs()\n\tpublic async sendReport(\n\t\toptions: NotificationCCReportOptions,\n\t): Promise<SupervisionResult | undefined> {\n\t\tthis.assertSupportsCommand(\n\t\t\tNotificationCommand,\n\t\t\tNotificationCommand.Report,\n\t\t);\n\n\t\tconst cc = new NotificationCCReport({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\t...options,\n\t\t});\n\t\treturn this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\t@validateArgs()\n\t// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n\tpublic async get(options: NotificationCCGetOptions) {\n\t\tconst response = await this.getInternal(options);\n\t\tif (response) {\n\t\t\treturn pick(response, [\n\t\t\t\t\"notificationStatus\",\n\t\t\t\t\"notificationEvent\",\n\t\t\t\t\"alarmLevel\",\n\t\t\t\t\"eventParameters\",\n\t\t\t\t\"sequenceNumber\",\n\t\t\t]);\n\t\t}\n\t}\n\n\t@validateArgs()\n\tpublic async set(\n\t\tnotificationType: number,\n\t\tnotificationStatus: boolean,\n\t): Promise<SupervisionResult | undefined> {\n\t\tthis.assertSupportsCommand(\n\t\t\tNotificationCommand,\n\t\t\tNotificationCommand.Set,\n\t\t);\n\n\t\tconst cc = new NotificationCCSet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tnotificationType,\n\t\t\tnotificationStatus,\n\t\t});\n\t\treturn this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n\tpublic async getSupported() {\n\t\tthis.assertSupportsCommand(\n\t\t\tNotificationCommand,\n\t\t\tNotificationCommand.SupportedGet,\n\t\t);\n\n\t\tconst cc = new NotificationCCSupportedGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tconst response = await this.host.sendCommand<\n\t\t\tNotificationCCSupportedReport\n\t\t>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\tif (response) {\n\t\t\treturn pick(response, [\n\t\t\t\t\"supportsV1Alarm\",\n\t\t\t\t\"supportedNotificationTypes\",\n\t\t\t]);\n\t\t}\n\t}\n\n\t@validateArgs()\n\tpublic async getSupportedEvents(\n\t\tnotificationType: number,\n\t): Promise<MaybeNotKnown<readonly number[]>> {\n\t\tthis.assertSupportsCommand(\n\t\t\tNotificationCommand,\n\t\t\tNotificationCommand.EventSupportedGet,\n\t\t);\n\n\t\tconst cc = new NotificationCCEventSupportedGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tnotificationType,\n\t\t});\n\t\tconst response = await this.host.sendCommand<\n\t\t\tNotificationCCEventSupportedReport\n\t\t>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\treturn response?.supportedEvents;\n\t}\n}\n\nexport function getNotificationEnumBehavior(\n\tnotification: Notification,\n\tvalueConfig: NotificationState,\n): \"none\" | \"extend\" | \"replace\" {\n\tconst variable = notification.variables.find((v) =>\n\t\tv.states.has(valueConfig.value)\n\t);\n\tif (!variable) return \"none\";\n\tconst numStatesWithEnums = [...variable.states.values()].filter(\n\t\t(val) => val.parameter?.type === \"enum\",\n\t).length;\n\tif (numStatesWithEnums === 0) return \"none\";\n\t// An enum value replaces the original value if there is only a single possible state\n\t// which also has an enum parameter\n\tif (numStatesWithEnums === 1 && variable.states.size === 1) {\n\t\treturn \"replace\";\n\t}\n\treturn \"extend\";\n}\n\nexport function getNotificationStateValueWithEnum(\n\tstateValue: number,\n\tenumValue: number,\n): number {\n\treturn (stateValue << 8) | enumValue;\n}\n\n/**\n * Returns the metadata to use for a known notification value.\n * Can be used to extend a previously defined metadata,\n * e.g. for V2 notifications that don't allow discovering supported events.\n */\nexport function getNotificationValueMetadata(\n\tprevious: ValueMetadataNumeric | undefined,\n\tnotification: Notification,\n\tvalueConfig: NotificationState,\n): ValueMetadataNumeric {\n\tconst metadata: ValueMetadataNumeric = previous ?? {\n\t\t...ValueMetadata.ReadOnlyUInt8,\n\t\tlabel: valueConfig.variableName,\n\t\tstates: {},\n\t\tccSpecific: {\n\t\t\tnotificationType: notification.type,\n\t\t},\n\t};\n\tif (valueConfig.idle) {\n\t\tmetadata.states![0] = \"idle\";\n\t}\n\tconst enumBehavior = getNotificationEnumBehavior(\n\t\tnotification,\n\t\tvalueConfig,\n\t);\n\tif (enumBehavior !== \"replace\") {\n\t\tmetadata.states![valueConfig.value] = valueConfig.label;\n\t}\n\tif (valueConfig.parameter?.type === \"enum\") {\n\t\tfor (\n\t\t\tconst [key, label] of Object.entries(valueConfig.parameter.values)\n\t\t) {\n\t\t\tconst value = parseInt(key);\n\t\t\tconst stateKey = enumBehavior === \"replace\"\n\t\t\t\t? value\n\t\t\t\t: getNotificationStateValueWithEnum(valueConfig.value, value);\n\t\t\tmetadata.states![stateKey] = label;\n\t\t}\n\t}\n\n\treturn metadata;\n}\n\n@commandClass(CommandClasses.Notification)\n@implementedVersion(8)\n@ccValues(NotificationCCValues)\nexport class NotificationCC extends CommandClass {\n\tdeclare ccCommand: NotificationCommand;\n\n\t// former AlarmCC (v1..v2)\n\n\tpublic determineRequiredCCInterviews(): readonly CommandClasses[] {\n\t\treturn [\n\t\t\t...super.determineRequiredCCInterviews(),\n\t\t\tCommandClasses.Association,\n\t\t\tCommandClasses[\"Multi Channel Association\"],\n\t\t\tCommandClasses[\"Association Group Information\"],\n\t\t];\n\t}\n\n\tprivate async determineNotificationMode(\n\t\tctx: GetValueDB & GetNode<NodeId & SupportsCC> & LogNode,\n\t\tapi: NotificationCCAPI,\n\t\tsupportedNotificationEvents: ReadonlyMap<number, readonly number[]>,\n\t): Promise<\"push\" | \"pull\"> {\n\t\tconst node = this.getNode(ctx)!;\n\n\t\t// SDS14223: If the supporting node does not support the Association Command Class,\n\t\t// it may be concluded that the supporting node implements Pull Mode and discovery may be aborted.\n\t\tif (!node.supportsCC(CommandClasses.Association)) return \"pull\";\n\n\t\tif (node.supportsCC(CommandClasses[\"Association Group Information\"])) {\n\t\t\ttry {\n\t\t\t\tconst groupsIssueingNotifications = AssociationGroupInfoCC\n\t\t\t\t\t.findGroupsForIssuedCommand(\n\t\t\t\t\t\tctx,\n\t\t\t\t\t\tnode,\n\t\t\t\t\t\tthis.ccId,\n\t\t\t\t\t\tNotificationCommand.Report,\n\t\t\t\t\t);\n\t\t\t\treturn groupsIssueingNotifications.length > 0 ? \"push\" : \"pull\";\n\t\t\t} catch {\n\t\t\t\t// We might be dealing with an older cache file, fall back to testing\n\t\t\t}\n\t\t}\n\n\t\tctx.logNode(node.id, {\n\t\t\tendpoint: this.endpointIndex,\n\t\t\tmessage: `determining whether this node is pull or push...`,\n\t\t\tdirection: \"outbound\",\n\t\t});\n\t\t// Find a notification type with at least one supported event\n\t\tfor (const [type, events] of supportedNotificationEvents) {\n\t\t\tif (events.length === 0) continue;\n\t\t\t// Enable the event and request the status\n\t\t\tawait api.set(type, true);\n\t\t\ttry {\n\t\t\t\tconst resp = await api.get({\n\t\t\t\t\tnotificationType: type,\n\t\t\t\t\tnotificationEvent: events[0],\n\t\t\t\t});\n\t\t\t\tswitch (resp?.notificationStatus) {\n\t\t\t\t\tcase 0xff:\n\t\t\t\t\t\treturn \"push\";\n\t\t\t\t\tcase 0xfe:\n\t\t\t\t\tcase 0x00:\n\t\t\t\t\t\treturn \"pull\";\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t/* ignore */\n\t\t\t}\n\t\t}\n\n\t\t// If everything failed, e.g. because the node is V1/V2, assume this is a \"push\" node.\n\t\t// If we assumed \"pull\", we would have to query the node regularly, which can cause\n\t\t// the node to return old (already handled) notifications.\n\t\t// https://github.com/zwave-js/zwave-js/issues/5626\n\t\treturn \"push\";\n\t}\n\n\t/** Whether the node implements push or pull notifications */\n\tpublic static getNotificationMode(\n\t\tctx: GetValueDB,\n\t\tnode: NodeId,\n\t): MaybeNotKnown<\"push\" | \"pull\"> {\n\t\treturn ctx\n\t\t\t.getValueDB(node.id)\n\t\t\t.getValue(NotificationCCValues.notificationMode.id);\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.Notification,\n\t\t\tctx,\n\t\t\tendpoint,\n\t\t).withOptions({\n\t\t\tpriority: MessagePriority.NodeQuery,\n\t\t});\n\n\t\tctx.logNode(node.id, {\n\t\t\tendpoint: this.endpointIndex,\n\t\t\tmessage: `Interviewing ${this.ccName}...`,\n\t\t\tdirection: \"none\",\n\t\t});\n\n\t\t// If one Association group issues Notification Reports,\n\t\t// we must associate ourselves with that channel\n\t\ttry {\n\t\t\tawait ccUtils.assignLifelineIssueingCommand(\n\t\t\t\tctx,\n\t\t\t\tendpoint,\n\t\t\t\tthis.ccId,\n\t\t\t\tNotificationCommand.Report,\n\t\t\t);\n\t\t} catch {\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tendpoint: endpoint.index,\n\t\t\t\tmessage: `Configuring associations to receive ${\n\t\t\t\t\tgetCCName(\n\t\t\t\t\t\tthis.ccId,\n\t\t\t\t\t)\n\t\t\t\t} reports failed!`,\n\t\t\t\tlevel: \"warn\",\n\t\t\t});\n\t\t}\n\n\t\tlet supportsV1Alarm = false;\n\t\tif (api.version >= 2) {\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\tmessage: \"querying supported notification types...\",\n\t\t\t\tdirection: \"outbound\",\n\t\t\t});\n\n\t\t\tconst suppResponse = await api.getSupported();\n\t\t\tif (!suppResponse) {\n\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\t\tmessage:\n\t\t\t\t\t\t\"Querying supported notification types timed out, skipping interview...\",\n\t\t\t\t\tlevel: \"warn\",\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsupportsV1Alarm = suppResponse.supportsV1Alarm;\n\t\t\tconst supportedNotificationTypes =\n\t\t\t\tsuppResponse.supportedNotificationTypes;\n\t\t\tconst supportedNotificationNames = supportedNotificationTypes.map(\n\t\t\t\tgetNotificationName,\n\t\t\t);\n\t\t\tconst supportedNotificationEvents = new Map<\n\t\t\t\tnumber,\n\t\t\t\treadonly number[]\n\t\t\t>();\n\n\t\t\tconst logMessage = `received supported notification types:${\n\t\t\t\tsupportedNotificationNames\n\t\t\t\t\t.map((name) => `\\n\u00B7 ${name}`)\n\t\t\t\t\t.join(\"\")\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\n\t\t\tif (api.version >= 3) {\n\t\t\t\t// Query each notification for its supported events\n\t\t\t\tfor (let i = 0; i < supportedNotificationTypes.length; i++) {\n\t\t\t\t\tconst type = supportedNotificationTypes[i];\n\t\t\t\t\tconst name = supportedNotificationNames[i];\n\n\t\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t`querying supported notification events for ${name}...`,\n\t\t\t\t\t\tdirection: \"outbound\",\n\t\t\t\t\t});\n\t\t\t\t\tconst supportedEvents = await api.getSupportedEvents(type);\n\t\t\t\t\tif (supportedEvents) {\n\t\t\t\t\t\tsupportedNotificationEvents.set(type, supportedEvents);\n\t\t\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t\t`received supported notification events for ${name}: ${\n\t\t\t\t\t\t\t\t\tsupportedEvents\n\t\t\t\t\t\t\t\t\t\t.map(String)\n\t\t\t\t\t\t\t\t\t\t.join(\", \")\n\t\t\t\t\t\t\t\t}`,\n\t\t\t\t\t\t\tdirection: \"inbound\",\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Determine whether the node is a push or pull node\n\t\t\tlet notificationMode = this.getValue<\"push\" | \"pull\">(\n\t\t\t\tctx,\n\t\t\t\tNotificationCCValues.notificationMode,\n\t\t\t);\n\t\t\tif (notificationMode !== \"push\" && notificationMode !== \"pull\") {\n\t\t\t\tnotificationMode = await this.determineNotificationMode(\n\t\t\t\t\tctx,\n\t\t\t\t\tapi,\n\t\t\t\t\tsupportedNotificationEvents,\n\t\t\t\t);\n\t\t\t\tthis.setValue(\n\t\t\t\t\tctx,\n\t\t\t\t\tNotificationCCValues.notificationMode,\n\t\t\t\t\tnotificationMode,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (notificationMode === \"pull\") {\n\t\t\t\tawait this.refreshValues(ctx);\n\t\t\t} /* if (notificationMode === \"push\") */ else {\n\t\t\t\tfor (let i = 0; i < supportedNotificationTypes.length; i++) {\n\t\t\t\t\tconst type = supportedNotificationTypes[i];\n\t\t\t\t\tconst name = supportedNotificationNames[i];\n\t\t\t\t\tconst notification = getNotification(type);\n\n\t\t\t\t\t// Enable reports for each notification type\n\t\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\t\t\tmessage: `enabling notifications for ${name}...`,\n\t\t\t\t\t\tdirection: \"outbound\",\n\t\t\t\t\t});\n\t\t\t\t\tawait api.set(type, true);\n\n\t\t\t\t\t// Set the value to idle if possible and there is no value yet\n\t\t\t\t\tif (notification) {\n\t\t\t\t\t\tconst events = supportedNotificationEvents.get(type);\n\t\t\t\t\t\tif (events) {\n\t\t\t\t\t\t\t// Find all variables that are supported by this node and have an idle state\n\t\t\t\t\t\t\tfor (\n\t\t\t\t\t\t\t\tconst variable of notification.variables\n\t\t\t\t\t\t\t\t\t.filter((v) => !!v.idle)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t[...variable.states.keys()].some((key) =>\n\t\t\t\t\t\t\t\t\t\tevents.includes(key)\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tconst value = NotificationCCValues\n\t\t\t\t\t\t\t\t\t\t.notificationVariable(\n\t\t\t\t\t\t\t\t\t\t\tnotification.name,\n\t\t\t\t\t\t\t\t\t\t\tvariable.name,\n\t\t\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\t\t// Set the value to idle if it has no value yet\n\t\t\t\t\t\t\t\t\t// TODO: GH#1028\n\t\t\t\t\t\t\t\t\t// * do this only if the last update was more than 5 minutes ago\n\t\t\t\t\t\t\t\t\t// * schedule an auto-idle if the last update was less than 5 minutes ago but before the current applHost start\n\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\tthis.getValue(ctx, value)\n\t\t\t\t\t\t\t\t\t\t\t== undefined\n\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\tthis.setValue(\n\t\t\t\t\t\t\t\t\t\t\tctx,\n\t\t\t\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\t\t\t\t0, /* idle */\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Only create metadata for V1 values if necessary\n\t\tif (api.version === 1 || supportsV1Alarm) {\n\t\t\tthis.ensureMetadata(ctx, NotificationCCValues.alarmType);\n\t\t\tthis.ensureMetadata(ctx, NotificationCCValues.alarmLevel);\n\t\t}\n\n\t\t// Also create metadata for values mapped through compat config\n\t\tconst mappings = ctx.getDeviceConfig?.(this.nodeId as number)\n\t\t\t?.compat?.alarmMapping;\n\t\tif (mappings) {\n\t\t\t// Find all mappings to a valid notification variable\n\t\t\tconst supportedNotifications = new Map<number, Set<number>>();\n\t\t\tfor (const { to } of mappings) {\n\t\t\t\tconst notification = getNotification(to.notificationType);\n\t\t\t\tif (!notification) continue;\n\t\t\t\tconst valueConfig = getNotificationValue(\n\t\t\t\t\tnotification,\n\t\t\t\t\tto.notificationEvent,\n\t\t\t\t);\n\n\t\t\t\t// Remember supported notification types and events to create the internal values later\n\t\t\t\tif (!supportedNotifications.has(to.notificationType)) {\n\t\t\t\t\tsupportedNotifications.set(\n\t\t\t\t\t\tto.notificationType,\n\t\t\t\t\t\tnew Set(),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst supportedNotificationTypesSet = supportedNotifications\n\t\t\t\t\t.get(to.notificationType)!;\n\t\t\t\tsupportedNotificationTypesSet.add(to.notificationEvent);\n\n\t\t\t\tif (valueConfig?.type !== \"state\") continue;\n\n\t\t\t\tconst notificationValue = NotificationCCValues\n\t\t\t\t\t.notificationVariable(\n\t\t\t\t\t\tnotification.name,\n\t\t\t\t\t\tvalueConfig.variableName,\n\t\t\t\t\t);\n\n\t\t\t\t// Create or update the metadata\n\t\t\t\tconst metadata = getNotificationValueMetadata(\n\t\t\t\t\tthis.getMetadata(ctx, notificationValue),\n\t\t\t\t\tnotification,\n\t\t\t\t\tvalueConfig,\n\t\t\t\t);\n\t\t\t\tthis.setMetadata(ctx, notificationValue, metadata);\n\n\t\t\t\t// Set the value to idle if it has no value yet\n\t\t\t\tif (valueConfig.idle) {\n\t\t\t\t\t// TODO: GH#1028\n\t\t\t\t\t// * do this only if the last update was more than 5 minutes ago\n\t\t\t\t\t// * schedule an auto-idle if the last update was less than 5 minutes ago but before the current applHost start\n\t\t\t\t\tif (\n\t\t\t\t\t\tthis.getValue(ctx, notificationValue) == undefined\n\t\t\t\t\t) {\n\t\t\t\t\t\tthis.setValue(\n\t\t\t\t\t\t\tctx,\n\t\t\t\t\t\t\tnotificationValue,\n\t\t\t\t\t\t\t0, /* idle */\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Remember supported notification types and events in the cache\n\t\t\tthis.setValue(\n\t\t\t\tctx,\n\t\t\t\tNotificationCCValues.supportedNotificationTypes,\n\t\t\t\t[...supportedNotifications.keys()],\n\t\t\t);\n\t\t\tfor (const [type, events] of supportedNotifications) {\n\t\t\t\tthis.setValue(\n\t\t\t\t\tctx,\n\t\t\t\t\tNotificationCCValues.supportedNotificationEvents(type),\n\t\t\t\t\t[...events],\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t// Remember that the interview is complete\n\t\tthis.setInterviewComplete(ctx, true);\n\t}\n\n\tpublic async refreshValues(\n\t\tctx: RefreshValuesContext,\n\t): Promise<void> {\n\t\tconst node = this.getNode(ctx)!;\n\t\t// Refreshing values only works on pull nodes\n\t\tif (NotificationCC.getNotificationMode(ctx, node) === \"pull\") {\n\t\t\tconst endpoint = this.getEndpoint(ctx)!;\n\t\t\tconst api = CCAPI.create(\n\t\t\t\tCommandClasses.Notification,\n\t\t\t\tctx,\n\t\t\t\tendpoint,\n\t\t\t).withOptions({\n\t\t\t\tpriority: MessagePriority.NodeQuery,\n\t\t\t});\n\n\t\t\t// Load supported notification types and events from cache\n\t\t\tconst supportedNotificationTypes = this.getValue<readonly number[]>(\n\t\t\t\tctx,\n\t\t\t\tNotificationCCValues.supportedNotificationTypes,\n\t\t\t) ?? [];\n\t\t\tconst supportedNotificationNames = supportedNotificationTypes.map(\n\t\t\t\tgetNotificationName,\n\t\t\t);\n\n\t\t\tfor (let i = 0; i < supportedNotificationTypes.length; i++) {\n\t\t\t\tconst type = supportedNotificationTypes[i];\n\t\t\t\tconst name = supportedNotificationNames[i];\n\n\t\t\t\t// Always query each notification for its current status\n\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\t\tmessage: `querying notification status for ${name}...`,\n\t\t\t\t\tdirection: \"outbound\",\n\t\t\t\t});\n\t\t\t\tconst response = await api.getInternal({\n\t\t\t\t\tnotificationType: type,\n\t\t\t\t});\n\t\t\t\t// NotificationReports don't store their values themselves,\n\t\t\t\t// because the behaviour is too complex and spans the lifetime\n\t\t\t\t// of several reports. Thus we handle it in the Node instance\n\n\t\t\t\t// @ts-expect-error\n\t\t\t\tif (response) await node.handleCommand(response);\n\t\t\t}\n\n\t\t\t// Remember when we did this\n\t\t\tthis.setValue(\n\t\t\t\tctx,\n\t\t\t\tNotificationCCValues.lastRefresh,\n\t\t\t\tDate.now(),\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// Pull-mode nodes must be polled regularly\n\n\t\tconst isPullMode = NotificationCC.getNotificationMode(\n\t\t\tctx,\n\t\t\tthis.getNode(ctx)!,\n\t\t) === \"pull\";\n\t\tif (!isPullMode) return false;\n\n\t\tconst lastUpdated = this.getValue<number>(\n\t\t\tctx,\n\t\t\tNotificationCCValues.lastRefresh,\n\t\t);\n\n\t\treturn (\n\t\t\tlastUpdated == undefined\n\t\t\t|| Date.now() - lastUpdated > timespan.hours(6)\n\t\t);\n\t}\n}\n\n// @publicAPI\nexport interface NotificationCCSetOptions {\n\tnotificationType: number;\n\tnotificationStatus: boolean;\n}\n\n@CCCommand(NotificationCommand.Set)\n@useSupervision()\nexport class NotificationCCSet extends NotificationCC {\n\tpublic constructor(\n\t\toptions: WithAddress<NotificationCCSetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.notificationType = options.notificationType;\n\t\tthis.notificationStatus = options.notificationStatus;\n\t}\n\n\tpublic static from(raw: CCRaw, ctx: CCParsingContext): NotificationCCSet {\n\t\tvalidatePayload(raw.payload.length >= 2);\n\t\tconst notificationType = raw.payload[0];\n\t\tconst notificationStatus = raw.payload[1] === 0xff;\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tnotificationType,\n\t\t\tnotificationStatus,\n\t\t});\n\t}\n\n\tpublic notificationType: number;\n\tpublic notificationStatus: boolean;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.from([\n\t\t\tthis.notificationType,\n\t\t\tthis.notificationStatus ? 0xff : 0x00,\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\"notification type\": getNotificationName(this.notificationType),\n\t\t\t\tstatus: this.notificationStatus,\n\t\t\t},\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport type NotificationCCReportOptions = {\n\talarmType?: number;\n\talarmLevel?: number;\n\tnotificationType?: number;\n\tnotificationEvent?: number;\n\tnotificationStatus?: number;\n\teventParameters?: Uint8Array;\n\tsequenceNumber?: number;\n};\n\n@CCCommand(NotificationCommand.Report)\n@useSupervision()\nexport class NotificationCCReport extends NotificationCC {\n\tpublic constructor(\n\t\toptions: WithAddress<NotificationCCReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\tif (options.alarmType != undefined) {\n\t\t\tthis.alarmType = options.alarmType;\n\t\t\tthis.alarmLevel = options.alarmLevel;\n\t\t}\n\n\t\tif (options.notificationType != undefined) {\n\t\t\tthis.notificationType = options.notificationType;\n\t\t\tthis.notificationStatus = options.notificationStatus ?? true;\n\t\t\tthis.notificationEvent = options.notificationEvent;\n\t\t\tthis.eventParameters = options.eventParameters;\n\t\t\tthis.sequenceNumber = options.sequenceNumber;\n\t\t}\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): NotificationCCReport {\n\t\tvalidatePayload(raw.payload.length >= 2);\n\t\tconst alarmType = raw.payload[0];\n\t\tconst alarmLevel = raw.payload[1];\n\n\t\t// Byte 2 used to be zensorNetSourceNodeId in V2 and V3, but we don't care about that\n\n\t\tif (raw.payload.length < 7) {\n\t\t\treturn new this({\n\t\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\t\talarmType,\n\t\t\t\talarmLevel,\n\t\t\t});\n\t\t}\n\n\t\t// V2+ requires the alarm bytes to be zero. Manufacturers don't care though, so we don't enforce that.\n\t\t// Don't use the version to decide because we might discard notifications\n\t\t// before the interview is complete\n\n\t\tconst notificationStatus = raw.payload[3];\n\t\tconst notificationType = raw.payload[4];\n\t\tconst notificationEvent = raw.payload[5];\n\n\t\tconst containsSeqNum = !!(raw.payload[6] & 0b1000_0000);\n\t\tconst numEventParams = raw.payload[6] & 0b11111;\n\t\tlet eventParameters: Uint8Array | undefined;\n\t\tif (numEventParams > 0) {\n\t\t\tvalidatePayload(raw.payload.length >= 7 + numEventParams);\n\t\t\teventParameters = raw.payload.subarray(7, 7 + numEventParams);\n\t\t}\n\t\tlet sequenceNumber: number | undefined;\n\t\tif (containsSeqNum) {\n\t\t\tvalidatePayload(\n\t\t\t\traw.payload.length >= 7 + numEventParams + 1,\n\t\t\t);\n\t\t\tsequenceNumber = raw.payload[7 + numEventParams];\n\t\t}\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\talarmType,\n\t\t\talarmLevel,\n\t\t\tnotificationStatus,\n\t\t\tnotificationType,\n\t\t\tnotificationEvent,\n\t\t\teventParameters,\n\t\t\tsequenceNumber,\n\t\t});\n\t}\n\n\tpublic persistValues(ctx: PersistValuesContext): boolean {\n\t\tif (!super.persistValues(ctx)) return false;\n\n\t\tconst ccVersion = getEffectiveCCVersion(ctx, this);\n\n\t\t// Check if we need to re-interpret the alarm values somehow\n\t\tif (\n\t\t\tthis.alarmType != undefined\n\t\t\t&& this.alarmLevel != undefined\n\t\t\t&& this.alarmType !== 0\n\t\t) {\n\t\t\tif (ccVersion >= 2) {\n\t\t\t\t// Check if the device actually supports Notification CC, but chooses\n\t\t\t\t// to send Alarm frames instead (GH#1034)\n\t\t\t\tconst supportedNotificationTypes = this.getValue<\n\t\t\t\t\treadonly number[]\n\t\t\t\t>(ctx, NotificationCCValues.supportedNotificationTypes);\n\t\t\t\tif (\n\t\t\t\t\tisArray(supportedNotificationTypes)\n\t\t\t\t\t&& supportedNotificationTypes.includes(this.alarmType)\n\t\t\t\t) {\n\t\t\t\t\tconst supportedNotificationEvents = this.getValue<\n\t\t\t\t\t\treadonly number[]\n\t\t\t\t\t>(\n\t\t\t\t\t\tctx,\n\t\t\t\t\t\tNotificationCCValues.supportedNotificationEvents(\n\t\t\t\t\t\t\tthis.alarmType,\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t\tif (\n\t\t\t\t\t\tisArray(supportedNotificationEvents)\n\t\t\t\t\t\t&& supportedNotificationEvents.includes(this.alarmLevel)\n\t\t\t\t\t) {\n\t\t\t\t\t\t// This alarm frame corresponds to a valid notification event\n\t\t\t\t\t\tctx.logNode(\n\t\t\t\t\t\t\tthis.nodeId as number,\n\t\t\t\t\t\t\t`treating V1 Alarm frame as Notification Report`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.notificationType = this.alarmType;\n\t\t\t\t\t\tthis.notificationEvent = this.alarmLevel;\n\t\t\t\t\t\tthis.alarmType = undefined;\n\t\t\t\t\t\tthis.alarmLevel = undefined;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// V1 Alarm, check if there is a compat option to map this V1 report to a V2+ report\n\t\t\t\tconst mapping = ctx.getDeviceConfig?.(\n\t\t\t\t\tthis.nodeId as number,\n\t\t\t\t)?.compat?.alarmMapping;\n\t\t\t\tconst match = mapping?.find(\n\t\t\t\t\t(m) =>\n\t\t\t\t\t\tm.from.alarmType === this.alarmType\n\t\t\t\t\t\t&& (m.from.alarmLevel == undefined\n\t\t\t\t\t\t\t|| m.from.alarmLevel === this.alarmLevel),\n\t\t\t\t);\n\t\t\t\tif (match) {\n\t\t\t\t\tctx.logNode(\n\t\t\t\t\t\tthis.nodeId as number,\n\t\t\t\t\t\t`compat mapping found, treating V1 Alarm frame as Notification Report`,\n\t\t\t\t\t);\n\t\t\t\t\tthis.notificationType = match.to.notificationType;\n\t\t\t\t\tthis.notificationEvent = match.to.notificationEvent;\n\t\t\t\t\tif (match.to.eventParameters) {\n\t\t\t\t\t\tthis.eventParameters = {};\n\t\t\t\t\t\tfor (\n\t\t\t\t\t\t\tconst [key, val] of Object.entries(\n\t\t\t\t\t\t\t\tmatch.to.eventParameters,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tif (typeof val === \"number\") {\n\t\t\t\t\t\t\t\tthis.eventParameters[key] = val;\n\t\t\t\t\t\t\t} else if (val === \"alarmLevel\") {\n\t\t\t\t\t\t\t\tthis.eventParameters[key] = this.alarmLevel;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t// After mapping we do not set the legacy V1 values to undefined\n\t\t\t\t\t// Otherwise, adding a new mapping will be a breaking change\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Now we can interpret the event parameters and turn them into something useful\n\t\tthis.parseEventParameters(ctx);\n\n\t\tif (this.alarmType != undefined) {\n\t\t\tconst alarmTypeValue = NotificationCCValues.alarmType;\n\t\t\tthis.ensureMetadata(ctx, alarmTypeValue);\n\t\t\tthis.setValue(ctx, alarmTypeValue, this.alarmType);\n\t\t}\n\t\tif (this.alarmLevel != undefined) {\n\t\t\tconst alarmLevelValue = NotificationCCValues.alarmLevel;\n\t\t\tthis.ensureMetadata(ctx, alarmLevelValue);\n\t\t\tthis.setValue(ctx, alarmLevelValue, this.alarmLevel);\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tpublic alarmType: number | undefined;\n\tpublic alarmLevel: number | undefined;\n\n\tpublic notificationType: number | undefined;\n\tpublic notificationStatus: boolean | number | undefined;\n\tpublic notificationEvent: number | undefined;\n\n\tpublic eventParameters:\n\t\t| Uint8Array\n\t\t| Duration\n\t\t| Record<string, number>\n\t\t| number\n\t\t| undefined;\n\n\tpublic sequenceNumber: number | undefined;\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\tlet message: MessageRecord = {};\n\t\tif (this.alarmType) {\n\t\t\tmessage = {\n\t\t\t\t\"V1 alarm type\": this.alarmType,\n\t\t\t\t\"V1 alarm level\": this.alarmLevel!,\n\t\t\t};\n\t\t}\n\n\t\tlet valueConfig: NotificationValue | undefined;\n\t\tif (this.notificationType) {\n\t\t\tconst notification = getNotification(this.notificationType);\n\t\t\tif (notification) {\n\t\t\t\tvalueConfig = getNotificationValue(\n\t\t\t\t\tnotification,\n\t\t\t\t\tthis.notificationEvent!,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (valueConfig) {\n\t\t\t\tmessage = {\n\t\t\t\t\t...message,\n\t\t\t\t\t\"notification type\": getNotificationName(\n\t\t\t\t\t\tthis.notificationType,\n\t\t\t\t\t),\n\t\t\t\t\t\"notification status\": this.notificationStatus!,\n\t\t\t\t\t[`notification ${valueConfig.type}`]: valueConfig.label\n\t\t\t\t\t\t?? `Unknown (${num2hex(this.notificationEvent)})`,\n\t\t\t\t};\n\t\t\t} else if (this.notificationEvent === 0x00) {\n\t\t\t\tmessage = {\n\t\t\t\t\t...message,\n\t\t\t\t\t\"notification type\": this.notificationType,\n\t\t\t\t\t\"notification status\": this.notificationStatus!,\n\t\t\t\t\t\"notification state\": \"idle\",\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\tmessage = {\n\t\t\t\t\t...message,\n\t\t\t\t\t\"notification type\": this.notificationType,\n\t\t\t\t\t\"notification status\": this.notificationStatus!,\n\t\t\t\t\t\"notification event\": num2hex(this.notificationEvent),\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t\tif (this.sequenceNumber != undefined) {\n\t\t\tmessage[\"sequence number\"] = this.sequenceNumber;\n\t\t}\n\t\tif (this.eventParameters != undefined) {\n\t\t\tif (typeof this.eventParameters === \"number\") {\n\t\t\t\t// Try to look up the enum label\n\t\t\t\tlet found = false;\n\t\t\t\tif (\n\t\t\t\t\tvalueConfig?.parameter?.type === \"enum\"\n\t\t\t\t) {\n\t\t\t\t\tconst label =\n\t\t\t\t\t\tvalueConfig.parameter.values[this.eventParameters];\n\t\t\t\t\tif (label) {\n\t\t\t\t\t\tmessage[\"state parameters\"] = label;\n\t\t\t\t\t\tfound = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (!found) {\n\t\t\t\t\tmessage[\"state parameters\"] = num2hex(this.eventParameters);\n\t\t\t\t}\n\t\t\t} else if (isUint8Array(this.eventParameters)) {\n\t\t\t\tmessage[\"event parameters\"] = buffer2hex(this.eventParameters);\n\t\t\t} else if (Duration.isDuration(this.eventParameters)) {\n\t\t\t\tmessage[\"event parameters\"] = this.eventParameters.toString();\n\t\t\t} else {\n\t\t\t\tmessage[\"event parameters\"] = Object.entries(\n\t\t\t\t\tthis.eventParameters,\n\t\t\t\t)\n\t\t\t\t\t.map(([param, val]) => `\\n ${param}: ${num2hex(val)}`)\n\t\t\t\t\t.join(\"\");\n\t\t\t}\n\t\t} else if (\n\t\t\tvalueConfig?.parameter?.type === \"enum\"\n\t\t\t&& valueConfig.parameter.default != undefined\n\t\t) {\n\t\t\tconst label = valueConfig.parameter.values[\n\t\t\t\tvalueConfig.parameter.default\n\t\t\t];\n\t\t\tif (label) {\n\t\t\t\tmessage[\"state parameters\"] = `${label} (omitted)`;\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage,\n\t\t};\n\t}\n\n\tprivate parseEventParameters(ctx: PersistValuesContext): void {\n\t\t// This only makes sense for V2+ notifications\n\t\tif (\n\t\t\tthis.notificationType == undefined\n\t\t\t|| this.notificationEvent == undefined\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Look up the received notification and value in the config\n\t\tconst notification = getNotification(this.notificationType);\n\t\tif (!notification) return;\n\t\tconst valueConfig = getNotificationValue(\n\t\t\tnotification,\n\t\t\tthis.notificationEvent,\n\t\t);\n\t\tif (!valueConfig) return;\n\n\t\t// Parse the event parameters if possible\n\t\tif (valueConfig.parameter?.type === \"duration\") {\n\t\t\t// This only makes sense if the event parameters are a buffer\n\t\t\tif (!isUint8Array(this.eventParameters)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// The parameters contain a Duration\n\t\t\tthis.eventParameters = Duration.parseReport(\n\t\t\t\tthis.eventParameters[0],\n\t\t\t);\n\t\t} else if (valueConfig.parameter?.type === \"commandclass\") {\n\t\t\t// This only makes sense if the event parameters are a buffer\n\t\t\tif (!isUint8Array(this.eventParameters)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// The parameters **should** contain a CC, however there might be some exceptions\n\t\t\tif (\n\t\t\t\tthis.eventParameters.length === 1\n\t\t\t\t&& notification.type === 0x06\n\t\t\t\t&& (this.notificationEvent === 0x05\n\t\t\t\t\t|| this.notificationEvent === 0x06)\n\t\t\t) {\n\t\t\t\t// Access control -> Keypad Lock/Unlock operation\n\t\t\t\t// Some devices only send the User ID, not a complete CC payload\n\t\t\t\tthis.eventParameters = {\n\t\t\t\t\tuserId: this.eventParameters[0],\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\t// Try to parse the event parameters - if this fails, we should still handle the notification report\n\t\t\t\ttry {\n\t\t\t\t\t// Convert CommandClass instances to a standardized object representation\n\n\t\t\t\t\t// We do not want to parse asynchronously here, but the `CommandClass.parse` method is async.\n\t\t\t\t\t// However, we only deal with simple CCs that can be parsed synchronously. We can do this\n\t\t\t\t\t// by replicating what `CommandClass.parse` does: determine the correct CC class and call its\n\t\t\t\t\t// `from` method. If that returns a CC instance, we're good to continue.\n\n\t\t\t\t\tconst raw = CCRaw.parse(this.eventParameters);\n\t\t\t\t\tif (raw.ccCommand == undefined) {\n\t\t\t\t\t\tvalidatePayload.fail(\n\t\t\t\t\t\t\t\"event parameters contain an invalid CC\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tconst CommandConstructor = getCCCommandConstructor(\n\t\t\t\t\t\traw.ccId,\n\t\t\t\t\t\traw.ccCommand,\n\t\t\t\t\t);\n\t\t\t\t\tif (!CommandConstructor) {\n\t\t\t\t\t\tvalidatePayload.fail(\n\t\t\t\t\t\t\t\"event parameters contain an invalid CC\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst cc = CommandConstructor.from(raw, {\n\t\t\t\t\t\t...ctx,\n\t\t\t\t\t\tframeType: \"singlecast\",\n\t\t\t\t\t\tsourceNodeId: this.nodeId as number,\n\t\t\t\t\t\t// Security encapsulation is handled outside of this CC,\n\t\t\t\t\t\t// so it is not needed here:\n\t\t\t\t\t\thasSecurityClass: () => false,\n\t\t\t\t\t\tgetHighestSecurityClass: () => SecurityClass.None,\n\t\t\t\t\t\tsetSecurityClass: () => {},\n\t\t\t\t\t\tsecurityManager: undefined,\n\t\t\t\t\t\tsecurityManager2: undefined,\n\t\t\t\t\t\tsecurityManagerLR: undefined,\n\t\t\t\t\t});\n\t\t\t\t\tif (cc instanceof Promise) {\n\t\t\t\t\t\tvalidatePayload.fail(\n\t\t\t\t\t\t\t\"Cannot asynchronously parse CC from event parameters\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tvalidatePayload(!(cc instanceof InvalidCC));\n\t\t\t\t\tcc.encapsulatingCC = this as any;\n\n\t\t\t\t\tif (isNotificationEventPayload(cc)) {\n\t\t\t\t\t\tthis.eventParameters = cc\n\t\t\t\t\t\t\t.toNotificationEventParameters();\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// If a CC has no good toJSON() representation, we're only interested in the payload\n\t\t\t\t\t\tlet json = cc.toJSON();\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\"nodeId\" in json\n\t\t\t\t\t\t\t&& \"ccId\" in json\n\t\t\t\t\t\t\t&& \"payload\" in json\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tjson = pick(json, [\"payload\"]);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthis.eventParameters = json;\n\t\t\t\t\t}\n\t\t\t\t} catch (e) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tisZWaveError(e)\n\t\t\t\t\t\t&& e.code\n\t\t\t\t\t\t\t=== ZWaveErrorCodes.PacketFormat_InvalidPayload\n\t\t\t\t\t\t&& isUint8Array(this.eventParameters)\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst { ccId, ccCommand } = CCRaw.parse(\n\t\t\t\t\t\t\tthis.eventParameters,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tccId === CommandClasses[\"User Code\"]\n\t\t\t\t\t\t\t&& ccCommand === UserCodeCommand.Report\n\t\t\t\t\t\t\t&& this.eventParameters.length >= 3\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t// Access control -> Keypad Lock/Unlock operation\n\t\t\t\t\t\t\t// Some devices report the user code with truncated UserCode reports\n\t\t\t\t\t\t\tthis.eventParameters = {\n\t\t\t\t\t\t\t\tuserId: this.eventParameters[2],\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tctx.logNode(\n\t\t\t\t\t\t\t\tthis.nodeId as number,\n\t\t\t\t\t\t\t\t`Failed to parse Notification CC event parameters, ignoring them...`,\n\t\t\t\t\t\t\t\t\"error\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// unexpected error\n\t\t\t\t\t\tthrow e;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (valueConfig.parameter?.type === \"value\") {\n\t\t\t// This only makes sense if the event parameters are a buffer\n\t\t\tif (!isUint8Array(this.eventParameters)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// The parameters contain a named value\n\t\t\tthis.eventParameters = {\n\t\t\t\t[valueConfig.parameter.propertyName]: Bytes.view(\n\t\t\t\t\tthis.eventParameters,\n\t\t\t\t)\n\t\t\t\t\t.readUIntBE(\n\t\t\t\t\t\t0,\n\t\t\t\t\t\tthis.eventParameters.length,\n\t\t\t\t\t),\n\t\t\t};\n\t\t} else if (valueConfig.parameter?.type === \"enum\") {\n\t\t\t// The parameters may contain an enum value\n\t\t\tthis.eventParameters = isUint8Array(this.eventParameters)\n\t\t\t\t\t&& this.eventParameters.length === 1\n\t\t\t\t? this.eventParameters[0]\n\t\t\t\t: undefined;\n\n\t\t\t// Some devices send notifications without an event parameter when they should.\n\t\t\t// In this case, fall back to the default value where possible.\n\n\t\t\tif (\n\t\t\t\tthis.eventParameters == undefined\n\t\t\t\t&& valueConfig.parameter.default != undefined\n\t\t\t) {\n\t\t\t\tthis.eventParameters = valueConfig.parameter.default;\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tif (this.notificationType != undefined) {\n\t\t\tif (\n\t\t\t\tthis.notificationEvent == undefined\n\t\t\t) {\n\t\t\t\tthrow new ZWaveError(\n\t\t\t\t\t`Notification CC reports requires the notification event to be set!`,\n\t\t\t\t\tZWaveErrorCodes.Argument_Invalid,\n\t\t\t\t);\n\t\t\t} else if (\n\t\t\t\tthis.eventParameters != undefined\n\t\t\t\t&& !isUint8Array(this.eventParameters)\n\t\t\t) {\n\t\t\t\tthrow new ZWaveError(\n\t\t\t\t\t`When sending Notification CC reports, the event parameters can only be buffers!`,\n\t\t\t\t\tZWaveErrorCodes.Argument_Invalid,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst controlByte =\n\t\t\t\t(this.sequenceNumber != undefined ? 0b1000_0000 : 0)\n\t\t\t\t| ((this.eventParameters?.length ?? 0) & 0b11111);\n\t\t\tthis.payload = Bytes.from([\n\t\t\t\t0,\n\t\t\t\t0,\n\t\t\t\t0,\n\t\t\t\t0xff,\n\t\t\t\tthis.notificationType,\n\t\t\t\tthis.notificationEvent,\n\t\t\t\tcontrolByte,\n\t\t\t]);\n\t\t\tif (this.eventParameters) {\n\t\t\t\tthis.payload = Bytes.concat([\n\t\t\t\t\tthis.payload,\n\t\t\t\t\tthis.eventParameters,\n\t\t\t\t]);\n\t\t\t}\n\t\t\tif (this.sequenceNumber != undefined) {\n\t\t\t\tthis.payload = Bytes.concat([\n\t\t\t\t\tthis.payload,\n\t\t\t\t\tBytes.from([this.sequenceNumber]),\n\t\t\t\t]);\n\t\t\t}\n\t\t} else {\n\t\t\tthis.payload = Bytes.from([\n\t\t\t\tthis.alarmType ?? 0x00,\n\t\t\t\tthis.alarmLevel ?? 0x00,\n\t\t\t]);\n\t\t}\n\n\t\treturn super.serialize(ctx);\n\t}\n}\n\n// @publicAPI\nexport type NotificationCCGetOptions =\n\t| {\n\t\talarmType: number;\n\t}\n\t| {\n\t\tnotificationType: number;\n\t\tnotificationEvent?: number;\n\t};\n\n@CCCommand(NotificationCommand.Get)\n@expectedCCResponse(NotificationCCReport)\nexport class NotificationCCGet extends NotificationCC {\n\tpublic constructor(\n\t\toptions: WithAddress<NotificationCCGetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tif (\"alarmType\" in options) {\n\t\t\tthis.alarmType = options.alarmType;\n\t\t} else {\n\t\t\tthis.notificationType = options.notificationType;\n\t\t\tthis.notificationEvent = options.notificationEvent;\n\t\t}\n\t}\n\n\tpublic static from(raw: CCRaw, ctx: CCParsingContext): NotificationCCGet {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\n\t\tif (raw.payload.length >= 2) {\n\t\t\tconst notificationType = raw.payload[1];\n\t\t\tlet notificationEvent: number | undefined;\n\t\t\tif (raw.payload.length >= 3 && notificationType != 0xff) {\n\t\t\t\tnotificationEvent = raw.payload[2];\n\t\t\t}\n\t\t\treturn new this({\n\t\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\t\tnotificationType,\n\t\t\t\tnotificationEvent,\n\t\t\t});\n\t\t} else {\n\t\t\tconst alarmType = raw.payload[0];\n\t\t\treturn new this({\n\t\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\t\talarmType,\n\t\t\t});\n\t\t}\n\t}\n\n\t/** Proprietary V1/V2 alarm type */\n\tpublic alarmType: number | undefined;\n\t/** Regulated V3+ notification type */\n\tpublic notificationType: number | undefined;\n\tpublic notificationEvent: number | undefined;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tconst notificationEvent = this.notificationEvent === 0xff\n\t\t\t? 0x00\n\t\t\t: this.notificationEvent;\n\t\tthis.payload = Bytes.from([\n\t\t\tthis.alarmType ?? 0x00,\n\t\t\tthis.notificationType ?? 0xff,\n\t\t\tnotificationEvent ?? 0x00,\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.alarmType != undefined) {\n\t\t\tmessage[\"V1 alarm type\"] = this.alarmType;\n\t\t}\n\t\tif (this.notificationType != undefined) {\n\t\t\tmessage[\"notification type\"] = getNotificationName(\n\t\t\t\tthis.notificationType,\n\t\t\t);\n\t\t\tif (this.notificationEvent != undefined) {\n\t\t\t\tmessage[\"notification event\"] = getNotificationEventName(\n\t\t\t\t\tthis.notificationType,\n\t\t\t\t\tthis.notificationEvent,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage,\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport interface NotificationCCSupportedReportOptions {\n\tsupportsV1Alarm: boolean;\n\tsupportedNotificationTypes: number[];\n}\n\n@CCCommand(NotificationCommand.SupportedReport)\n@ccValueProperty(\"supportsV1Alarm\", NotificationCCValues.supportsV1Alarm)\n@ccValueProperty(\n\t\"supportedNotificationTypes\",\n\tNotificationCCValues.supportedNotificationTypes,\n)\nexport class NotificationCCSupportedReport extends NotificationCC {\n\tpublic constructor(\n\t\toptions: WithAddress<NotificationCCSupportedReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\tthis.supportsV1Alarm = options.supportsV1Alarm;\n\t\tthis.supportedNotificationTypes = options.supportedNotificationTypes;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): NotificationCCSupportedReport {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst supportsV1Alarm = !!(raw.payload[0] & 0b1000_0000);\n\t\tconst numBitMaskBytes = raw.payload[0] & 0b0001_1111;\n\t\tvalidatePayload(\n\t\t\tnumBitMaskBytes > 0,\n\t\t\traw.payload.length >= 1 + numBitMaskBytes,\n\t\t);\n\t\tconst notificationBitMask = raw.payload.subarray(\n\t\t\t1,\n\t\t\t1 + numBitMaskBytes,\n\t\t);\n\t\tconst supportedNotificationTypes = parseBitMask(\n\t\t\tnotificationBitMask,\n\t\t\t// bit 0 is ignored, but counting still starts at 1, so the first bit must have the value 0\n\t\t\t0,\n\t\t);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tsupportsV1Alarm,\n\t\t\tsupportedNotificationTypes,\n\t\t});\n\t}\n\n\tpublic supportsV1Alarm: boolean;\n\n\tpublic supportedNotificationTypes: number[];\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tconst bitMask = encodeBitMask(\n\t\t\tthis.supportedNotificationTypes,\n\t\t\tMath.max(...this.supportedNotificationTypes),\n\t\t\t0,\n\t\t);\n\t\tthis.payload = Bytes.concat([\n\t\t\tBytes.from([\n\t\t\t\t(this.supportsV1Alarm ? 0b1000_0000 : 0) | bitMask.length,\n\t\t\t]),\n\t\t\tbitMask,\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\"supports V1 alarm\": this.supportsV1Alarm,\n\t\t\t\t\"supported notification types\": this.supportedNotificationTypes\n\t\t\t\t\t.map(\n\t\t\t\t\t\t(t) => `\\n\u00B7 ${getNotificationName(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@CCCommand(NotificationCommand.SupportedGet)\n@expectedCCResponse(NotificationCCSupportedReport)\nexport class NotificationCCSupportedGet extends NotificationCC {}\n\n// @publicAPI\nexport interface NotificationCCEventSupportedReportOptions {\n\tnotificationType: number;\n\tsupportedEvents: number[];\n}\n\n@CCCommand(NotificationCommand.EventSupportedReport)\nexport class NotificationCCEventSupportedReport extends NotificationCC {\n\tpublic constructor(\n\t\toptions: WithAddress<NotificationCCEventSupportedReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\tthis.notificationType = options.notificationType;\n\t\tthis.supportedEvents = options.supportedEvents;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): NotificationCCEventSupportedReport {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst notificationType = raw.payload[0];\n\t\tconst numBitMaskBytes = raw.payload[1] & 0b000_11111;\n\n\t\tif (numBitMaskBytes === 0) {\n\t\t\t// Notification type is not supported\n\t\t\treturn new this({\n\t\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\t\tnotificationType,\n\t\t\t\tsupportedEvents: [],\n\t\t\t});\n\t\t}\n\n\t\tvalidatePayload(raw.payload.length >= 2 + numBitMaskBytes);\n\t\tconst eventBitMask = raw.payload.subarray(2, 2 + numBitMaskBytes);\n\t\tconst supportedEvents = parseBitMask(\n\t\t\teventBitMask,\n\t\t\t// In this mask, bit 0 is ignored, but counting still starts at 1, so the first bit must have the value 0\n\t\t\t0,\n\t\t);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tnotificationType,\n\t\t\tsupportedEvents,\n\t\t});\n\t}\n\n\tpublic persistValues(ctx: PersistValuesContext): boolean {\n\t\tif (!super.persistValues(ctx)) return false;\n\n\t\t// Store which events this notification supports\n\t\tthis.setValue(\n\t\t\tctx,\n\t\t\tNotificationCCValues.supportedNotificationEvents(\n\t\t\t\tthis.notificationType,\n\t\t\t),\n\t\t\tthis.supportedEvents,\n\t\t);\n\n\t\t// For each event, predefine the value metadata\n\t\tconst notification = getNotification(this.notificationType);\n\n\t\tif (!notification) {\n\t\t\t// This is an unknown notification\n\t\t\tthis.setMetadata(\n\t\t\t\tctx,\n\t\t\t\tNotificationCCValues.unknownNotificationType(\n\t\t\t\t\tthis.notificationType,\n\t\t\t\t),\n\t\t\t);\n\t\t} else {\n\t\t\t// This is a standardized notification\n\t\t\tlet isFirst = true;\n\t\t\tfor (const value of this.supportedEvents) {\n\t\t\t\t// Find out which property we need to update\n\t\t\t\tconst valueConfig = getNotificationValue(notification, value);\n\t\t\t\tif (valueConfig?.type === \"state\") {\n\t\t\t\t\tconst notificationValue = NotificationCCValues\n\t\t\t\t\t\t.notificationVariable(\n\t\t\t\t\t\t\tnotification.name,\n\t\t\t\t\t\t\tvalueConfig.variableName,\n\t\t\t\t\t\t);\n\n\t\t\t\t\t// After we've created the metadata initially, extend it\n\t\t\t\t\tconst metadata = getNotificationValueMetadata(\n\t\t\t\t\t\tisFirst\n\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t: this.getMetadata(ctx, notificationValue),\n\t\t\t\t\t\tnotification,\n\t\t\t\t\t\tvalueConfig,\n\t\t\t\t\t);\n\n\t\t\t\t\tthis.setMetadata(ctx, notificationValue, metadata);\n\n\t\t\t\t\tisFirst = false;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tpublic notificationType: number;\n\tpublic supportedEvents: number[];\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.from([this.notificationType, 0]);\n\t\tif (this.supportedEvents.length > 0) {\n\t\t\tconst bitMask = encodeBitMask(\n\t\t\t\tthis.supportedEvents,\n\t\t\t\tMath.max(...this.supportedEvents),\n\t\t\t\t0,\n\t\t\t);\n\t\t\tthis.payload[1] = bitMask.length;\n\t\t\tthis.payload = Bytes.concat([this.payload, bitMask]);\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\"notification type\": getNotificationName(this.notificationType),\n\t\t\t\t\"supported events\": this.supportedEvents\n\t\t\t\t\t.map(\n\t\t\t\t\t\t(e) =>\n\t\t\t\t\t\t\t`\\n\u00B7 ${\n\t\t\t\t\t\t\t\tgetNotificationValueName(\n\t\t\t\t\t\t\t\t\tthis.notificationType,\n\t\t\t\t\t\t\t\t\te,\n\t\t\t\t\t\t\t\t)\n\t\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 NotificationCCEventSupportedGetOptions {\n\tnotificationType: number;\n}\n\n@CCCommand(NotificationCommand.EventSupportedGet)\n@expectedCCResponse(NotificationCCEventSupportedReport)\nexport class NotificationCCEventSupportedGet extends NotificationCC {\n\tpublic constructor(\n\t\toptions: WithAddress<NotificationCCEventSupportedGetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.notificationType = options.notificationType;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): NotificationCCEventSupportedGet {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst notificationType = raw.payload[0];\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tnotificationType,\n\t\t});\n\t}\n\n\tpublic notificationType: number;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.from([this.notificationType]);\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\"notification type\": getNotificationName(this.notificationType),\n\t\t\t},\n\t\t};\n\t}\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,kBAuCO;AACP,oBAMO;AAEP,wBAAwB;AACxB,iBAMO;AACP,0BAQO;AACP,oCAUO;AACP,sCAA2C;AAC3C,oBAAkB;AAClB,mBAAqD;AACrD,cAAyB;AACzB,oCAAuC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiIjC,SAAU,sCACf,KACA,UAAoB;AAEpB,QAAM,UAAU,IAAI,cAAc,SAAS,MAAM;AACjD,MAAI,CAAC;AAAS,WAAO;AACrB,QAAM,oBAAoB,QAAQ,SACjC,+CAAqB;;IAEpB;EAAI,EACH,SAAS,SAAS,KAAK,CAAC;AAE3B,MAAI,CAAC;AAAmB,WAAO;AAC/B,SACC,kBAAkB;;IAEjB;EAAI,KAEF,kBAAkB;;IAEpB;EAAI;AAGP;AAvBgB;IA0BH,qBAAiB,MAAA;8BAD7B,mCAAI,2BAAe,YAAY,CAAC;;;;oBACM;;;;;;yCAAA,YAAa;WAAA;;;;;;;;gCA+DlD,0CAAA,CAAc;yBAiBd,mCAAA,CAAc;yBAed,mCAAA,CAAc;wCA4Cd,kDAAA,CAAc;AA3Ef,mBAAA,MAAA,MAAA,wBAAA,EAAA,MAAA,UAAA,MAAA,cAAA,QAAA,OAAA,SAAA,OAAA,QAAA,EAAA,KAAA,gCAAA,gBAAA,KAAA,QAAA,KAAA,gCAAA,IAAa,YAAb,OAAuB,GAAA,UAAA,UAAA,GAAA,MAAA,0BAAA;AAkBvB,mB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AC,CAEH,EAAE,EAEH,KAAK,EAAE;;;IAGZ;;;;IAUY,mCAA+B,MAAA;8BAF3C,yCAAU,iCAAoB,iBAAiB,OAC/C,kDAAmB,kCAAkC,CAAC;;;;oBACF;uDAAA,YAAc;WAAA;;;;;;;;AAAnE,mBAAA,MAAA,mBAAA,EAAA,OAAA,WAAA,GAAA,kBAAA,EAAA,MAAA,SAAA,MAAA,WAAA,MAAA,UAAA,UAAA,GAAA,MAAA,uBAAA;;;AAAa,wBAAA,YAAA,uBAAA;;IACZ,YACC,SAA4D;AAE5D,YAAM,OAAO;AACb,WAAK,mBAAmB,QAAQ;IACjC;IAEO,OAAO,KACb,KACA,KAAqB;AAErB,uCAAgB,IAAI,QAAQ,UAAU,CAAC;AACvC,YAAM,mBAAmB,IAAI,QAAQ,CAAC;AAEtC,aAAO,IAAI,KAAK;QACf,QAAQ,IAAI;QACZ;OACA;IACF;IAEO;IAEA,UAAU,KAAsB;AACtC,WAAK,UAAU,oBAAM,KAAK,CAAC,KAAK,gBAAgB,CAAC;AACjD,aAAO,MAAM,UAAU,GAAG;IAC3B;IAEO,WAAW,KAAgB;AACjC,aAAO;QACN,GAAG,MAAM,WAAW,GAAG;QACvB,SAAS;UACR,yBAAqB,iCAAoB,KAAK,gBAAgB;;;IAGjE;;;;",
|
|
4
|
+
"sourcesContent": ["import type { CCEncodingContext, CCParsingContext } from \"@zwave-js/cc\";\nimport type { GetDeviceConfig } from \"@zwave-js/config\";\nimport {\n\tCommandClasses,\n\ttype ControlsCC,\n\tDuration,\n\ttype EndpointId,\n\ttype GetEndpoint,\n\ttype GetNode,\n\ttype GetSupportedCCVersion,\n\ttype GetValueDB,\n\ttype LogNode,\n\ttype MaybeNotKnown,\n\ttype MessageOrCCLogEntry,\n\tMessagePriority,\n\ttype MessageRecord,\n\ttype NodeId,\n\ttype Notification,\n\ttype NotificationState,\n\ttype NotificationValue,\n\tSecurityClass,\n\ttype SinglecastCC,\n\ttype SupervisionResult,\n\ttype SupportsCC,\n\ttype ValueID,\n\tValueMetadata,\n\ttype ValueMetadataNumeric,\n\ttype WithAddress,\n\tZWaveError,\n\tZWaveErrorCodes,\n\tencodeBitMask,\n\tgetCCName,\n\tgetNotification,\n\tgetNotificationEventName,\n\tgetNotificationName,\n\tgetNotificationValue,\n\tgetNotificationValueName,\n\tisZWaveError,\n\tparseBitMask,\n\ttimespan,\n\tvalidatePayload,\n} from \"@zwave-js/core\";\nimport {\n\tBytes,\n\tbuffer2hex,\n\tisUint8Array,\n\tnum2hex,\n\tpick,\n} from \"@zwave-js/shared\";\nimport { validateArgs } from \"@zwave-js/transformers\";\nimport { isArray } from \"alcalzone-shared/typeguards\";\nimport {\n\tCCAPI,\n\tPOLL_VALUE,\n\tPhysicalCCAPI,\n\ttype PollValueImplementation,\n\tthrowUnsupportedProperty,\n} from \"../lib/API.js\";\nimport {\n\tCCRaw,\n\tCommandClass,\n\ttype InterviewContext,\n\tInvalidCC,\n\ttype PersistValuesContext,\n\ttype RefreshValuesContext,\n\tgetEffectiveCCVersion,\n} from \"../lib/CommandClass.js\";\nimport {\n\tAPI,\n\tCCCommand,\n\tccValueProperty,\n\tccValues,\n\tcommandClass,\n\texpectedCCResponse,\n\tgetCCCommandConstructor,\n\timplementedVersion,\n\tuseSupervision,\n} from \"../lib/CommandClassDecorators.js\";\nimport { isNotificationEventPayload } from \"../lib/NotificationEventPayload.js\";\nimport { V } from \"../lib/Values.js\";\nimport { NotificationCommand, UserCodeCommand } from \"../lib/_Types.js\";\nimport * as ccUtils from \"../lib/utils.js\";\nimport { AssociationGroupInfoCC } from \"./AssociationGroupInfoCC.js\";\n\nexport const NotificationCCValues = V.defineCCValues(\n\tCommandClasses.Notification,\n\t{\n\t\t...V.staticProperty(\"supportsV1Alarm\", undefined, {\n\t\t\tinternal: true,\n\t\t\tsupportsEndpoints: false,\n\t\t}),\n\t\t...V.staticProperty(\"supportedNotificationTypes\", undefined, {\n\t\t\tinternal: true,\n\t\t\tsupportsEndpoints: false,\n\t\t}),\n\t\t...V.staticProperty(\"notificationMode\", undefined, {\n\t\t\tinternal: true,\n\t\t\tsupportsEndpoints: false,\n\t\t}),\n\t\t...V.staticProperty(\"lastRefresh\", undefined, {\n\t\t\tinternal: true,\n\t\t}),\n\t\t...V.staticProperty(\n\t\t\t\"alarmType\",\n\t\t\t{\n\t\t\t\t...ValueMetadata.ReadOnlyUInt8,\n\t\t\t\tlabel: \"Alarm Type\",\n\t\t\t} as const,\n\t\t),\n\t\t...V.staticProperty(\n\t\t\t\"alarmLevel\",\n\t\t\t{\n\t\t\t\t...ValueMetadata.ReadOnlyUInt8,\n\t\t\t\tlabel: \"Alarm Level\",\n\t\t\t} as const,\n\t\t),\n\t\t...V.staticPropertyAndKeyWithName(\n\t\t\t\"doorStateSimple\",\n\t\t\t\"Access Control\",\n\t\t\t\"Door state (simple)\",\n\t\t\t{\n\t\t\t\t// Must be a number for compatibility reasons\n\t\t\t\t...ValueMetadata.ReadOnlyUInt8,\n\t\t\t\tlabel: \"Door state (simple)\",\n\t\t\t\tstates: {\n\t\t\t\t\t[0x16]: \"Window/door is open\",\n\t\t\t\t\t[0x17]: \"Window/door is closed\",\n\t\t\t\t},\n\t\t\t\tccSpecific: {\n\t\t\t\t\tnotificationType: 0x06,\n\t\t\t\t},\n\t\t\t} as const,\n\t\t\t{\n\t\t\t\tautoCreate: shouldAutoCreateSimpleDoorSensorValue,\n\t\t\t} as const,\n\t\t),\n\t\t...V.staticPropertyAndKeyWithName(\n\t\t\t\"doorTiltState\",\n\t\t\t\"Access Control\",\n\t\t\t\"Door tilt state\",\n\t\t\t{\n\t\t\t\t// Must be a number for compatibility reasons\n\t\t\t\t...ValueMetadata.ReadOnlyUInt8,\n\t\t\t\tlabel: \"Door tilt state\",\n\t\t\t\tstates: {\n\t\t\t\t\t[0x00]: \"Window/door is not tilted\",\n\t\t\t\t\t[0x01]: \"Window/door is tilted\",\n\t\t\t\t},\n\t\t\t\tccSpecific: {\n\t\t\t\t\tnotificationType: 0x06,\n\t\t\t\t},\n\t\t\t} as const,\n\t\t\t{\n\t\t\t\t// This is created when the tilt state is first received.\n\t\t\t\tautoCreate: false,\n\t\t\t} as const,\n\t\t),\n\t\t...V.dynamicPropertyAndKeyWithName(\n\t\t\t\"supportedNotificationEvents\",\n\t\t\t\"supportedNotificationEvents\",\n\t\t\t(notificationType: number) => notificationType,\n\t\t\t({ property, propertyKey }) =>\n\t\t\t\tproperty === \"supportedNotificationEvents\"\n\t\t\t\t&& typeof propertyKey === \"number\",\n\t\t\tundefined,\n\t\t\t{ internal: true, supportsEndpoints: false },\n\t\t),\n\t\t...V.dynamicPropertyWithName(\n\t\t\t\"unknownNotificationType\",\n\t\t\t(notificationType: number) =>\n\t\t\t\t`UNKNOWN_${num2hex(notificationType)}`,\n\t\t\t({ property }) =>\n\t\t\t\ttypeof property === \"string\"\n\t\t\t\t&& property.startsWith(\"UNKNOWN_0x\"),\n\t\t\t(notificationType: number) => ({\n\t\t\t\t...ValueMetadata.ReadOnlyUInt8,\n\t\t\t\tlabel: `Unknown notification (${\n\t\t\t\t\tnum2hex(\n\t\t\t\t\t\tnotificationType,\n\t\t\t\t\t)\n\t\t\t\t})`,\n\t\t\t\tccSpecific: { notificationType },\n\t\t\t} as const),\n\t\t),\n\t\t...V.dynamicPropertyAndKeyWithName(\n\t\t\t\"unknownNotificationVariable\",\n\t\t\t(notificationType: number, notificationName: string) =>\n\t\t\t\tnotificationName,\n\t\t\t\"unknown\",\n\t\t\t({ property, propertyKey }) =>\n\t\t\t\ttypeof property === \"string\" && propertyKey === \"unknown\",\n\t\t\t(notificationType: number, notificationName: string) => ({\n\t\t\t\t...ValueMetadata.ReadOnlyUInt8,\n\t\t\t\tlabel: `${notificationName}: Unknown value`,\n\t\t\t\tccSpecific: { notificationType },\n\t\t\t} as const),\n\t\t),\n\t\t...V.dynamicPropertyAndKeyWithName(\n\t\t\t\"notificationVariable\",\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\t\t\t(notificationName: string, variableName: string) =>\n\t\t\t\tnotificationName,\n\t\t\t(notificationName: string, variableName: string) => variableName,\n\t\t\t({ property, propertyKey }) =>\n\t\t\t\ttypeof property === \"string\" && typeof propertyKey === \"string\",\n\t\t\t// Notification metadata is so dynamic, it does not make sense to define it here\n\t\t\tundefined,\n\t\t),\n\t},\n);\n\nexport function shouldAutoCreateSimpleDoorSensorValue(\n\tctx: GetValueDB,\n\tendpoint: EndpointId,\n): boolean {\n\tconst valueDB = ctx.tryGetValueDB(endpoint.nodeId);\n\tif (!valueDB) return false;\n\tconst supportedACEvents = valueDB.getValue<readonly number[]>(\n\t\tNotificationCCValues.supportedNotificationEvents(\n\t\t\t// Access Control\n\t\t\t0x06,\n\t\t).endpoint(endpoint.index),\n\t);\n\tif (!supportedACEvents) return false;\n\treturn (\n\t\tsupportedACEvents.includes(\n\t\t\t// Window/door is open\n\t\t\t0x16,\n\t\t)\n\t\t&& supportedACEvents.includes(\n\t\t\t// Window/door is closed\n\t\t\t0x17,\n\t\t)\n\t);\n}\n\n@API(CommandClasses.Notification)\nexport class NotificationCCAPI extends PhysicalCCAPI {\n\tpublic supportsCommand(cmd: NotificationCommand): MaybeNotKnown<boolean> {\n\t\tswitch (cmd) {\n\t\t\tcase NotificationCommand.Report:\n\t\t\tcase NotificationCommand.Get:\n\t\t\t\treturn true; // These exist starting with V1\n\n\t\t\tcase NotificationCommand.Set:\n\t\t\tcase NotificationCommand.SupportedGet:\n\t\t\t\treturn this.version >= 2;\n\n\t\t\tcase NotificationCommand.EventSupportedGet:\n\t\t\t\treturn this.version >= 3;\n\t\t}\n\t\treturn super.supportsCommand(cmd);\n\t}\n\n\tprotected get [POLL_VALUE](): PollValueImplementation {\n\t\treturn async function(\n\t\t\tthis: NotificationCCAPI,\n\t\t\t{ property, propertyKey },\n\t\t) {\n\t\t\tconst valueId: ValueID = {\n\t\t\t\tcommandClass: this.ccId,\n\t\t\t\tendpoint: this.endpoint.index,\n\t\t\t\tproperty,\n\t\t\t\tpropertyKey,\n\t\t\t};\n\t\t\tif (NotificationCCValues.notificationVariable.is(valueId)) {\n\t\t\t\tconst notificationType: number | undefined = this\n\t\t\t\t\t.tryGetValueDB()?.getMetadata(valueId)?.ccSpecific\n\t\t\t\t\t?.notificationType;\n\t\t\t\tif (notificationType != undefined) {\n\t\t\t\t\treturn this.getInternal({ notificationType });\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthrowUnsupportedProperty(this.ccId, property);\n\t\t};\n\t}\n\n\t/**\n\t * @internal\n\t */\n\tpublic async getInternal(\n\t\toptions: NotificationCCGetOptions,\n\t): Promise<NotificationCCReport | undefined> {\n\t\tthis.assertSupportsCommand(\n\t\t\tNotificationCommand,\n\t\t\tNotificationCommand.Get,\n\t\t);\n\n\t\tconst cc = new NotificationCCGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\t...options,\n\t\t});\n\t\treturn this.host.sendCommand<NotificationCCReport>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t}\n\n\t@validateArgs()\n\tpublic async sendReport(\n\t\toptions: NotificationCCReportOptions,\n\t): Promise<SupervisionResult | undefined> {\n\t\tthis.assertSupportsCommand(\n\t\t\tNotificationCommand,\n\t\t\tNotificationCommand.Report,\n\t\t);\n\n\t\tconst cc = new NotificationCCReport({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\t...options,\n\t\t});\n\t\treturn this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\t@validateArgs()\n\t// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n\tpublic async get(options: NotificationCCGetOptions) {\n\t\tconst response = await this.getInternal(options);\n\t\tif (response) {\n\t\t\treturn pick(response, [\n\t\t\t\t\"notificationStatus\",\n\t\t\t\t\"notificationEvent\",\n\t\t\t\t\"alarmLevel\",\n\t\t\t\t\"eventParameters\",\n\t\t\t\t\"sequenceNumber\",\n\t\t\t]);\n\t\t}\n\t}\n\n\t@validateArgs()\n\tpublic async set(\n\t\tnotificationType: number,\n\t\tnotificationStatus: boolean,\n\t): Promise<SupervisionResult | undefined> {\n\t\tthis.assertSupportsCommand(\n\t\t\tNotificationCommand,\n\t\t\tNotificationCommand.Set,\n\t\t);\n\n\t\tconst cc = new NotificationCCSet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tnotificationType,\n\t\t\tnotificationStatus,\n\t\t});\n\t\treturn this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n\tpublic async getSupported() {\n\t\tthis.assertSupportsCommand(\n\t\t\tNotificationCommand,\n\t\t\tNotificationCommand.SupportedGet,\n\t\t);\n\n\t\tconst cc = new NotificationCCSupportedGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tconst response = await this.host.sendCommand<\n\t\t\tNotificationCCSupportedReport\n\t\t>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\tif (response) {\n\t\t\treturn pick(response, [\n\t\t\t\t\"supportsV1Alarm\",\n\t\t\t\t\"supportedNotificationTypes\",\n\t\t\t]);\n\t\t}\n\t}\n\n\t@validateArgs()\n\tpublic async getSupportedEvents(\n\t\tnotificationType: number,\n\t): Promise<MaybeNotKnown<readonly number[]>> {\n\t\tthis.assertSupportsCommand(\n\t\t\tNotificationCommand,\n\t\t\tNotificationCommand.EventSupportedGet,\n\t\t);\n\n\t\tconst cc = new NotificationCCEventSupportedGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tnotificationType,\n\t\t});\n\t\tconst response = await this.host.sendCommand<\n\t\t\tNotificationCCEventSupportedReport\n\t\t>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\treturn response?.supportedEvents;\n\t}\n}\n\nexport function getNotificationEnumBehavior(\n\tnotification: Notification,\n\tvalueConfig: NotificationState,\n): \"none\" | \"extend\" | \"replace\" {\n\tconst variable = notification.variables.find((v) =>\n\t\tv.states.has(valueConfig.value)\n\t);\n\tif (!variable) return \"none\";\n\tconst numStatesWithEnums = [...variable.states.values()].filter(\n\t\t(val) => val.parameter?.type === \"enum\",\n\t).length;\n\tif (numStatesWithEnums === 0) return \"none\";\n\t// An enum value replaces the original value if there is only a single possible state\n\t// which also has an enum parameter\n\tif (numStatesWithEnums === 1 && variable.states.size === 1) {\n\t\treturn \"replace\";\n\t}\n\treturn \"extend\";\n}\n\nexport function getNotificationStateValueWithEnum(\n\tstateValue: number,\n\tenumValue: number,\n): number {\n\treturn (stateValue << 8) | enumValue;\n}\n\n/**\n * Returns the metadata to use for a known notification value.\n * Can be used to extend a previously defined metadata,\n * e.g. for V2 notifications that don't allow discovering supported events.\n */\nexport function getNotificationValueMetadata(\n\tprevious: ValueMetadataNumeric | undefined,\n\tnotification: Notification,\n\tvalueConfig: NotificationState,\n): ValueMetadataNumeric {\n\tconst metadata: ValueMetadataNumeric = previous ?? {\n\t\t...ValueMetadata.ReadOnlyUInt8,\n\t\tlabel: valueConfig.variableName,\n\t\tstates: {},\n\t\tccSpecific: {\n\t\t\tnotificationType: notification.type,\n\t\t},\n\t};\n\tif (valueConfig.idle) {\n\t\tmetadata.states![0] = \"idle\";\n\t}\n\tconst enumBehavior = getNotificationEnumBehavior(\n\t\tnotification,\n\t\tvalueConfig,\n\t);\n\tif (enumBehavior !== \"replace\") {\n\t\tmetadata.states![valueConfig.value] = valueConfig.label;\n\t}\n\tif (valueConfig.parameter?.type === \"enum\") {\n\t\tfor (\n\t\t\tconst [key, label] of Object.entries(valueConfig.parameter.values)\n\t\t) {\n\t\t\tconst value = parseInt(key);\n\t\t\tconst stateKey = enumBehavior === \"replace\"\n\t\t\t\t? value\n\t\t\t\t: getNotificationStateValueWithEnum(valueConfig.value, value);\n\t\t\tmetadata.states![stateKey] = label;\n\t\t}\n\t}\n\n\treturn metadata;\n}\n\n@commandClass(CommandClasses.Notification)\n@implementedVersion(8)\n@ccValues(NotificationCCValues)\nexport class NotificationCC extends CommandClass {\n\tdeclare ccCommand: NotificationCommand;\n\n\t// former AlarmCC (v1..v2)\n\n\tpublic determineRequiredCCInterviews(): readonly CommandClasses[] {\n\t\treturn [\n\t\t\t...super.determineRequiredCCInterviews(),\n\t\t\tCommandClasses.Association,\n\t\t\tCommandClasses[\"Multi Channel Association\"],\n\t\t\tCommandClasses[\"Association Group Information\"],\n\t\t];\n\t}\n\n\tprivate async determineNotificationMode(\n\t\tctx: GetValueDB & GetNode<NodeId & SupportsCC> & LogNode,\n\t\tapi: NotificationCCAPI,\n\t\tsupportedNotificationEvents: ReadonlyMap<number, readonly number[]>,\n\t): Promise<\"push\" | \"pull\"> {\n\t\tconst node = this.getNode(ctx)!;\n\n\t\t// SDS14223: If the supporting node does not support the Association Command Class,\n\t\t// it may be concluded that the supporting node implements Pull Mode and discovery may be aborted.\n\t\tif (!node.supportsCC(CommandClasses.Association)) return \"pull\";\n\n\t\tif (node.supportsCC(CommandClasses[\"Association Group Information\"])) {\n\t\t\ttry {\n\t\t\t\tconst groupsIssueingNotifications = AssociationGroupInfoCC\n\t\t\t\t\t.findGroupsForIssuedCommand(\n\t\t\t\t\t\tctx,\n\t\t\t\t\t\tnode,\n\t\t\t\t\t\tthis.ccId,\n\t\t\t\t\t\tNotificationCommand.Report,\n\t\t\t\t\t);\n\t\t\t\treturn groupsIssueingNotifications.length > 0 ? \"push\" : \"pull\";\n\t\t\t} catch {\n\t\t\t\t// We might be dealing with an older cache file, fall back to testing\n\t\t\t}\n\t\t}\n\n\t\tctx.logNode(node.id, {\n\t\t\tendpoint: this.endpointIndex,\n\t\t\tmessage: `determining whether this node is pull or push...`,\n\t\t\tdirection: \"outbound\",\n\t\t});\n\t\t// Find a notification type with at least one supported event\n\t\tfor (const [type, events] of supportedNotificationEvents) {\n\t\t\tif (events.length === 0) continue;\n\t\t\t// Enable the event and request the status\n\t\t\tawait api.set(type, true);\n\t\t\ttry {\n\t\t\t\tconst resp = await api.get({\n\t\t\t\t\tnotificationType: type,\n\t\t\t\t\tnotificationEvent: events[0],\n\t\t\t\t});\n\t\t\t\tswitch (resp?.notificationStatus) {\n\t\t\t\t\tcase 0xff:\n\t\t\t\t\t\treturn \"push\";\n\t\t\t\t\tcase 0xfe:\n\t\t\t\t\tcase 0x00:\n\t\t\t\t\t\treturn \"pull\";\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t/* ignore */\n\t\t\t}\n\t\t}\n\n\t\t// If everything failed, e.g. because the node is V1/V2, assume this is a \"push\" node.\n\t\t// If we assumed \"pull\", we would have to query the node regularly, which can cause\n\t\t// the node to return old (already handled) notifications.\n\t\t// https://github.com/zwave-js/zwave-js/issues/5626\n\t\treturn \"push\";\n\t}\n\n\t/** Whether the node implements push or pull notifications */\n\tpublic static getNotificationMode(\n\t\tctx: GetValueDB,\n\t\tnode: NodeId,\n\t): MaybeNotKnown<\"push\" | \"pull\"> {\n\t\treturn ctx\n\t\t\t.getValueDB(node.id)\n\t\t\t.getValue(NotificationCCValues.notificationMode.id);\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.Notification,\n\t\t\tctx,\n\t\t\tendpoint,\n\t\t).withOptions({\n\t\t\tpriority: MessagePriority.NodeQuery,\n\t\t});\n\n\t\tctx.logNode(node.id, {\n\t\t\tendpoint: this.endpointIndex,\n\t\t\tmessage: `Interviewing ${this.ccName}...`,\n\t\t\tdirection: \"none\",\n\t\t});\n\n\t\t// If one Association group issues Notification Reports,\n\t\t// we must associate ourselves with that channel\n\t\ttry {\n\t\t\tawait ccUtils.assignLifelineIssueingCommand(\n\t\t\t\tctx,\n\t\t\t\tendpoint,\n\t\t\t\tthis.ccId,\n\t\t\t\tNotificationCommand.Report,\n\t\t\t);\n\t\t} catch {\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tendpoint: endpoint.index,\n\t\t\t\tmessage: `Configuring associations to receive ${\n\t\t\t\t\tgetCCName(\n\t\t\t\t\t\tthis.ccId,\n\t\t\t\t\t)\n\t\t\t\t} reports failed!`,\n\t\t\t\tlevel: \"warn\",\n\t\t\t});\n\t\t}\n\n\t\tlet supportsV1Alarm = false;\n\t\tif (api.version >= 2) {\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\tmessage: \"querying supported notification types...\",\n\t\t\t\tdirection: \"outbound\",\n\t\t\t});\n\n\t\t\tconst suppResponse = await api.getSupported();\n\t\t\tif (!suppResponse) {\n\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\t\tmessage:\n\t\t\t\t\t\t\"Querying supported notification types timed out, skipping interview...\",\n\t\t\t\t\tlevel: \"warn\",\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsupportsV1Alarm = suppResponse.supportsV1Alarm;\n\t\t\tconst supportedNotificationTypes =\n\t\t\t\tsuppResponse.supportedNotificationTypes;\n\t\t\tconst supportedNotificationNames = supportedNotificationTypes.map(\n\t\t\t\tgetNotificationName,\n\t\t\t);\n\t\t\tconst supportedNotificationEvents = new Map<\n\t\t\t\tnumber,\n\t\t\t\treadonly number[]\n\t\t\t>();\n\n\t\t\tconst logMessage = `received supported notification types:${\n\t\t\t\tsupportedNotificationNames\n\t\t\t\t\t.map((name) => `\\n\u00B7 ${name}`)\n\t\t\t\t\t.join(\"\")\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\n\t\t\tif (api.version >= 3) {\n\t\t\t\t// Query each notification for its supported events\n\t\t\t\tfor (let i = 0; i < supportedNotificationTypes.length; i++) {\n\t\t\t\t\tconst type = supportedNotificationTypes[i];\n\t\t\t\t\tconst name = supportedNotificationNames[i];\n\n\t\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t`querying supported notification events for ${name}...`,\n\t\t\t\t\t\tdirection: \"outbound\",\n\t\t\t\t\t});\n\t\t\t\t\tconst supportedEvents = await api.getSupportedEvents(type);\n\t\t\t\t\tif (supportedEvents) {\n\t\t\t\t\t\tsupportedNotificationEvents.set(type, supportedEvents);\n\t\t\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t\t`received supported notification events for ${name}: ${\n\t\t\t\t\t\t\t\t\tsupportedEvents\n\t\t\t\t\t\t\t\t\t\t.map(String)\n\t\t\t\t\t\t\t\t\t\t.join(\", \")\n\t\t\t\t\t\t\t\t}`,\n\t\t\t\t\t\t\tdirection: \"inbound\",\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Determine whether the node is a push or pull node\n\t\t\tlet notificationMode = this.getValue<\"push\" | \"pull\">(\n\t\t\t\tctx,\n\t\t\t\tNotificationCCValues.notificationMode,\n\t\t\t);\n\t\t\tif (notificationMode !== \"push\" && notificationMode !== \"pull\") {\n\t\t\t\tnotificationMode = await this.determineNotificationMode(\n\t\t\t\t\tctx,\n\t\t\t\t\tapi,\n\t\t\t\t\tsupportedNotificationEvents,\n\t\t\t\t);\n\t\t\t\tthis.setValue(\n\t\t\t\t\tctx,\n\t\t\t\t\tNotificationCCValues.notificationMode,\n\t\t\t\t\tnotificationMode,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (notificationMode === \"pull\") {\n\t\t\t\tawait this.refreshValues(ctx);\n\t\t\t} /* if (notificationMode === \"push\") */ else {\n\t\t\t\tfor (let i = 0; i < supportedNotificationTypes.length; i++) {\n\t\t\t\t\tconst type = supportedNotificationTypes[i];\n\t\t\t\t\tconst name = supportedNotificationNames[i];\n\t\t\t\t\tconst notification = getNotification(type);\n\n\t\t\t\t\t// Enable reports for each notification type\n\t\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\t\t\tmessage: `enabling notifications for ${name}...`,\n\t\t\t\t\t\tdirection: \"outbound\",\n\t\t\t\t\t});\n\t\t\t\t\tawait api.set(type, true);\n\n\t\t\t\t\t// Set the value to idle if possible and there is no value yet\n\t\t\t\t\tif (notification) {\n\t\t\t\t\t\tconst events = supportedNotificationEvents.get(type);\n\t\t\t\t\t\tif (events) {\n\t\t\t\t\t\t\t// Find all variables that are supported by this node and have an idle state\n\t\t\t\t\t\t\tfor (\n\t\t\t\t\t\t\t\tconst variable of notification.variables\n\t\t\t\t\t\t\t\t\t.filter((v) => !!v.idle)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t[...variable.states.keys()].some((key) =>\n\t\t\t\t\t\t\t\t\t\tevents.includes(key)\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tconst value = NotificationCCValues\n\t\t\t\t\t\t\t\t\t\t.notificationVariable(\n\t\t\t\t\t\t\t\t\t\t\tnotification.name,\n\t\t\t\t\t\t\t\t\t\t\tvariable.name,\n\t\t\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\t\t// Set the value to idle if it has no value yet\n\t\t\t\t\t\t\t\t\t// TODO: GH#1028\n\t\t\t\t\t\t\t\t\t// * do this only if the last update was more than 5 minutes ago\n\t\t\t\t\t\t\t\t\t// * schedule an auto-idle if the last update was less than 5 minutes ago but before the current applHost start\n\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\tthis.getValue(ctx, value)\n\t\t\t\t\t\t\t\t\t\t\t== undefined\n\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\tthis.setValue(\n\t\t\t\t\t\t\t\t\t\t\tctx,\n\t\t\t\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\t\t\t\t0, /* idle */\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Only create metadata for V1 values if necessary\n\t\tif (api.version === 1 || supportsV1Alarm) {\n\t\t\tthis.ensureMetadata(ctx, NotificationCCValues.alarmType);\n\t\t\tthis.ensureMetadata(ctx, NotificationCCValues.alarmLevel);\n\t\t}\n\n\t\t// Also create metadata for values mapped through compat config\n\t\tconst mappings = ctx.getDeviceConfig?.(this.nodeId as number)\n\t\t\t?.compat?.alarmMapping;\n\t\tif (mappings) {\n\t\t\t// Find all mappings to a valid notification variable\n\t\t\tconst supportedNotifications = new Map<number, Set<number>>();\n\t\t\tfor (const { to } of mappings) {\n\t\t\t\tconst notification = getNotification(to.notificationType);\n\t\t\t\tif (!notification) continue;\n\t\t\t\tconst valueConfig = getNotificationValue(\n\t\t\t\t\tnotification,\n\t\t\t\t\tto.notificationEvent,\n\t\t\t\t);\n\n\t\t\t\t// Remember supported notification types and events to create the internal values later\n\t\t\t\tif (!supportedNotifications.has(to.notificationType)) {\n\t\t\t\t\tsupportedNotifications.set(\n\t\t\t\t\t\tto.notificationType,\n\t\t\t\t\t\tnew Set(),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst supportedNotificationTypesSet = supportedNotifications\n\t\t\t\t\t.get(to.notificationType)!;\n\t\t\t\tsupportedNotificationTypesSet.add(to.notificationEvent);\n\n\t\t\t\tif (valueConfig?.type !== \"state\") continue;\n\n\t\t\t\tconst notificationValue = NotificationCCValues\n\t\t\t\t\t.notificationVariable(\n\t\t\t\t\t\tnotification.name,\n\t\t\t\t\t\tvalueConfig.variableName,\n\t\t\t\t\t);\n\n\t\t\t\t// Create or update the metadata\n\t\t\t\tconst metadata = getNotificationValueMetadata(\n\t\t\t\t\tthis.getMetadata(ctx, notificationValue),\n\t\t\t\t\tnotification,\n\t\t\t\t\tvalueConfig,\n\t\t\t\t);\n\t\t\t\tthis.setMetadata(ctx, notificationValue, metadata);\n\n\t\t\t\t// Set the value to idle if it has no value yet\n\t\t\t\tif (valueConfig.idle) {\n\t\t\t\t\t// TODO: GH#1028\n\t\t\t\t\t// * do this only if the last update was more than 5 minutes ago\n\t\t\t\t\t// * schedule an auto-idle if the last update was less than 5 minutes ago but before the current applHost start\n\t\t\t\t\tif (\n\t\t\t\t\t\tthis.getValue(ctx, notificationValue) == undefined\n\t\t\t\t\t) {\n\t\t\t\t\t\tthis.setValue(\n\t\t\t\t\t\t\tctx,\n\t\t\t\t\t\t\tnotificationValue,\n\t\t\t\t\t\t\t0, /* idle */\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Remember supported notification types and events in the cache\n\t\t\tthis.setValue(\n\t\t\t\tctx,\n\t\t\t\tNotificationCCValues.supportedNotificationTypes,\n\t\t\t\t[...supportedNotifications.keys()],\n\t\t\t);\n\t\t\tfor (const [type, events] of supportedNotifications) {\n\t\t\t\tthis.setValue(\n\t\t\t\t\tctx,\n\t\t\t\t\tNotificationCCValues.supportedNotificationEvents(type),\n\t\t\t\t\t[...events],\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t// Remember that the interview is complete\n\t\tthis.setInterviewComplete(ctx, true);\n\t}\n\n\tpublic async refreshValues(\n\t\tctx: RefreshValuesContext,\n\t): Promise<void> {\n\t\tconst node = this.getNode(ctx)!;\n\t\t// Refreshing values only works on pull nodes\n\t\tif (NotificationCC.getNotificationMode(ctx, node) === \"pull\") {\n\t\t\tconst endpoint = this.getEndpoint(ctx)!;\n\t\t\tconst api = CCAPI.create(\n\t\t\t\tCommandClasses.Notification,\n\t\t\t\tctx,\n\t\t\t\tendpoint,\n\t\t\t).withOptions({\n\t\t\t\tpriority: MessagePriority.NodeQuery,\n\t\t\t});\n\n\t\t\t// Load supported notification types and events from cache\n\t\t\tconst supportedNotificationTypes = this.getValue<readonly number[]>(\n\t\t\t\tctx,\n\t\t\t\tNotificationCCValues.supportedNotificationTypes,\n\t\t\t) ?? [];\n\t\t\tconst supportedNotificationNames = supportedNotificationTypes.map(\n\t\t\t\tgetNotificationName,\n\t\t\t);\n\n\t\t\tfor (let i = 0; i < supportedNotificationTypes.length; i++) {\n\t\t\t\tconst type = supportedNotificationTypes[i];\n\t\t\t\tconst name = supportedNotificationNames[i];\n\n\t\t\t\t// Always query each notification for its current status\n\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\tendpoint: this.endpointIndex,\n\t\t\t\t\tmessage: `querying notification status for ${name}...`,\n\t\t\t\t\tdirection: \"outbound\",\n\t\t\t\t});\n\t\t\t\tconst response = await api.getInternal({\n\t\t\t\t\tnotificationType: type,\n\t\t\t\t});\n\t\t\t\t// NotificationReports don't store their values themselves,\n\t\t\t\t// because the behaviour is too complex and spans the lifetime\n\t\t\t\t// of several reports. Thus we handle it in the Node instance\n\n\t\t\t\t// @ts-expect-error\n\t\t\t\tif (response) await node.handleCommand(response);\n\t\t\t}\n\n\t\t\t// Remember when we did this\n\t\t\tthis.setValue(\n\t\t\t\tctx,\n\t\t\t\tNotificationCCValues.lastRefresh,\n\t\t\t\tDate.now(),\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// Pull-mode nodes must be polled regularly\n\n\t\tconst isPullMode = NotificationCC.getNotificationMode(\n\t\t\tctx,\n\t\t\tthis.getNode(ctx)!,\n\t\t) === \"pull\";\n\t\tif (!isPullMode) return false;\n\n\t\tconst lastUpdated = this.getValue<number>(\n\t\t\tctx,\n\t\t\tNotificationCCValues.lastRefresh,\n\t\t);\n\n\t\treturn (\n\t\t\tlastUpdated == undefined\n\t\t\t|| Date.now() - lastUpdated > timespan.hours(6)\n\t\t);\n\t}\n}\n\n// @publicAPI\nexport interface NotificationCCSetOptions {\n\tnotificationType: number;\n\tnotificationStatus: boolean;\n}\n\n@CCCommand(NotificationCommand.Set)\n@useSupervision()\nexport class NotificationCCSet extends NotificationCC {\n\tpublic constructor(\n\t\toptions: WithAddress<NotificationCCSetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.notificationType = options.notificationType;\n\t\tthis.notificationStatus = options.notificationStatus;\n\t}\n\n\tpublic static from(raw: CCRaw, ctx: CCParsingContext): NotificationCCSet {\n\t\tvalidatePayload(raw.payload.length >= 2);\n\t\tconst notificationType = raw.payload[0];\n\t\tconst notificationStatus = raw.payload[1] === 0xff;\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tnotificationType,\n\t\t\tnotificationStatus,\n\t\t});\n\t}\n\n\tpublic notificationType: number;\n\tpublic notificationStatus: boolean;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.from([\n\t\t\tthis.notificationType,\n\t\t\tthis.notificationStatus ? 0xff : 0x00,\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\"notification type\": getNotificationName(this.notificationType),\n\t\t\t\tstatus: this.notificationStatus,\n\t\t\t},\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport type NotificationCCReportOptions = {\n\talarmType?: number;\n\talarmLevel?: number;\n\tnotificationType?: number;\n\tnotificationEvent?: number;\n\tnotificationStatus?: number;\n\teventParameters?: Uint8Array;\n\tsequenceNumber?: number;\n};\n\n@CCCommand(NotificationCommand.Report)\n@useSupervision()\nexport class NotificationCCReport extends NotificationCC {\n\tpublic constructor(\n\t\toptions: WithAddress<NotificationCCReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\tif (options.alarmType != undefined) {\n\t\t\tthis.alarmType = options.alarmType;\n\t\t\tthis.alarmLevel = options.alarmLevel;\n\t\t}\n\n\t\tif (options.notificationType != undefined) {\n\t\t\tthis.notificationType = options.notificationType;\n\t\t\tthis.notificationStatus = options.notificationStatus ?? true;\n\t\t\tthis.notificationEvent = options.notificationEvent;\n\t\t\tthis.eventParameters = options.eventParameters;\n\t\t\tthis.sequenceNumber = options.sequenceNumber;\n\t\t}\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): NotificationCCReport {\n\t\tvalidatePayload(raw.payload.length >= 2);\n\t\tconst alarmType = raw.payload[0];\n\t\tconst alarmLevel = raw.payload[1];\n\n\t\t// Byte 2 used to be zensorNetSourceNodeId in V2 and V3, but we don't care about that\n\n\t\tif (raw.payload.length < 7) {\n\t\t\treturn new this({\n\t\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\t\talarmType,\n\t\t\t\talarmLevel,\n\t\t\t});\n\t\t}\n\n\t\t// V2+ requires the alarm bytes to be zero. Manufacturers don't care though, so we don't enforce that.\n\t\t// Don't use the version to decide because we might discard notifications\n\t\t// before the interview is complete\n\n\t\tconst notificationStatus = raw.payload[3];\n\t\tconst notificationType = raw.payload[4];\n\t\tconst notificationEvent = raw.payload[5];\n\n\t\tconst containsSeqNum = !!(raw.payload[6] & 0b1000_0000);\n\t\tconst numEventParams = raw.payload[6] & 0b11111;\n\t\tlet eventParameters: Uint8Array | undefined;\n\t\tif (numEventParams > 0) {\n\t\t\tvalidatePayload(raw.payload.length >= 7 + numEventParams);\n\t\t\teventParameters = raw.payload.subarray(7, 7 + numEventParams);\n\t\t}\n\t\tlet sequenceNumber: number | undefined;\n\t\tif (containsSeqNum) {\n\t\t\tvalidatePayload(\n\t\t\t\traw.payload.length >= 7 + numEventParams + 1,\n\t\t\t);\n\t\t\tsequenceNumber = raw.payload[7 + numEventParams];\n\t\t}\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\talarmType,\n\t\t\talarmLevel,\n\t\t\tnotificationStatus,\n\t\t\tnotificationType,\n\t\t\tnotificationEvent,\n\t\t\teventParameters,\n\t\t\tsequenceNumber,\n\t\t});\n\t}\n\n\tpublic persistValues(ctx: PersistValuesContext): boolean {\n\t\tif (!super.persistValues(ctx)) return false;\n\n\t\tconst ccVersion = getEffectiveCCVersion(ctx, this);\n\n\t\t// Check if we need to re-interpret the alarm values somehow\n\t\tif (\n\t\t\tthis.alarmType != undefined\n\t\t\t&& this.alarmLevel != undefined\n\t\t\t&& this.alarmType !== 0\n\t\t) {\n\t\t\tif (ccVersion >= 2) {\n\t\t\t\t// Check if the device actually supports Notification CC, but chooses\n\t\t\t\t// to send Alarm frames instead (GH#1034)\n\t\t\t\tconst supportedNotificationTypes = this.getValue<\n\t\t\t\t\treadonly number[]\n\t\t\t\t>(ctx, NotificationCCValues.supportedNotificationTypes);\n\t\t\t\tif (\n\t\t\t\t\tisArray(supportedNotificationTypes)\n\t\t\t\t\t&& supportedNotificationTypes.includes(this.alarmType)\n\t\t\t\t) {\n\t\t\t\t\tconst supportedNotificationEvents = this.getValue<\n\t\t\t\t\t\treadonly number[]\n\t\t\t\t\t>(\n\t\t\t\t\t\tctx,\n\t\t\t\t\t\tNotificationCCValues.supportedNotificationEvents(\n\t\t\t\t\t\t\tthis.alarmType,\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t\tif (\n\t\t\t\t\t\tisArray(supportedNotificationEvents)\n\t\t\t\t\t\t&& supportedNotificationEvents.includes(this.alarmLevel)\n\t\t\t\t\t) {\n\t\t\t\t\t\t// This alarm frame corresponds to a valid notification event\n\t\t\t\t\t\tctx.logNode(\n\t\t\t\t\t\t\tthis.nodeId as number,\n\t\t\t\t\t\t\t`treating V1 Alarm frame as Notification Report`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.notificationType = this.alarmType;\n\t\t\t\t\t\tthis.notificationEvent = this.alarmLevel;\n\t\t\t\t\t\tthis.alarmType = undefined;\n\t\t\t\t\t\tthis.alarmLevel = undefined;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// V1 Alarm, check if there is a compat option to map this V1 report to a V2+ report\n\t\t\t\tconst mapping = ctx.getDeviceConfig?.(\n\t\t\t\t\tthis.nodeId as number,\n\t\t\t\t)?.compat?.alarmMapping;\n\t\t\t\tconst match = mapping?.find(\n\t\t\t\t\t(m) =>\n\t\t\t\t\t\tm.from.alarmType === this.alarmType\n\t\t\t\t\t\t&& (m.from.alarmLevel == undefined\n\t\t\t\t\t\t\t|| m.from.alarmLevel === this.alarmLevel),\n\t\t\t\t);\n\t\t\t\tif (match) {\n\t\t\t\t\tctx.logNode(\n\t\t\t\t\t\tthis.nodeId as number,\n\t\t\t\t\t\t`compat mapping found, treating V1 Alarm frame as Notification Report`,\n\t\t\t\t\t);\n\t\t\t\t\tthis.notificationType = match.to.notificationType;\n\t\t\t\t\tthis.notificationEvent = match.to.notificationEvent;\n\t\t\t\t\tif (match.to.eventParameters) {\n\t\t\t\t\t\tthis.eventParameters = {};\n\t\t\t\t\t\tfor (\n\t\t\t\t\t\t\tconst [key, val] of Object.entries(\n\t\t\t\t\t\t\t\tmatch.to.eventParameters,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tif (typeof val === \"number\") {\n\t\t\t\t\t\t\t\tthis.eventParameters[key] = val;\n\t\t\t\t\t\t\t} else if (val === \"alarmLevel\") {\n\t\t\t\t\t\t\t\tthis.eventParameters[key] = this.alarmLevel;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t// After mapping we do not set the legacy V1 values to undefined\n\t\t\t\t\t// Otherwise, adding a new mapping will be a breaking change\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Now we can interpret the event parameters and turn them into something useful\n\t\tthis.parseEventParameters(ctx);\n\n\t\tif (this.alarmType != undefined) {\n\t\t\tconst alarmTypeValue = NotificationCCValues.alarmType;\n\t\t\tthis.ensureMetadata(ctx, alarmTypeValue);\n\t\t\tthis.setValue(ctx, alarmTypeValue, this.alarmType);\n\t\t}\n\t\tif (this.alarmLevel != undefined) {\n\t\t\tconst alarmLevelValue = NotificationCCValues.alarmLevel;\n\t\t\tthis.ensureMetadata(ctx, alarmLevelValue);\n\t\t\tthis.setValue(ctx, alarmLevelValue, this.alarmLevel);\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tpublic alarmType: number | undefined;\n\tpublic alarmLevel: number | undefined;\n\n\tpublic notificationType: number | undefined;\n\tpublic notificationStatus: boolean | number | undefined;\n\tpublic notificationEvent: number | undefined;\n\n\tpublic eventParameters:\n\t\t| Uint8Array\n\t\t| Duration\n\t\t| Record<string, number>\n\t\t| number\n\t\t| undefined;\n\n\tpublic sequenceNumber: number | undefined;\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\tlet message: MessageRecord = {};\n\t\tif (this.alarmType) {\n\t\t\tmessage = {\n\t\t\t\t\"V1 alarm type\": this.alarmType,\n\t\t\t\t\"V1 alarm level\": this.alarmLevel!,\n\t\t\t};\n\t\t}\n\n\t\tlet valueConfig: NotificationValue | undefined;\n\t\tif (this.notificationType) {\n\t\t\tconst notification = getNotification(this.notificationType);\n\t\t\tif (notification) {\n\t\t\t\tvalueConfig = getNotificationValue(\n\t\t\t\t\tnotification,\n\t\t\t\t\tthis.notificationEvent!,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (valueConfig) {\n\t\t\t\tmessage = {\n\t\t\t\t\t...message,\n\t\t\t\t\t\"notification type\": getNotificationName(\n\t\t\t\t\t\tthis.notificationType,\n\t\t\t\t\t),\n\t\t\t\t\t\"notification status\": this.notificationStatus!,\n\t\t\t\t\t[`notification ${valueConfig.type}`]: valueConfig.label\n\t\t\t\t\t\t?? `Unknown (${num2hex(this.notificationEvent)})`,\n\t\t\t\t};\n\t\t\t} else if (this.notificationEvent === 0x00) {\n\t\t\t\tmessage = {\n\t\t\t\t\t...message,\n\t\t\t\t\t\"notification type\": this.notificationType,\n\t\t\t\t\t\"notification status\": this.notificationStatus!,\n\t\t\t\t\t\"notification state\": \"idle\",\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\tmessage = {\n\t\t\t\t\t...message,\n\t\t\t\t\t\"notification type\": this.notificationType,\n\t\t\t\t\t\"notification status\": this.notificationStatus!,\n\t\t\t\t\t\"notification event\": num2hex(this.notificationEvent),\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t\tif (this.sequenceNumber != undefined) {\n\t\t\tmessage[\"sequence number\"] = this.sequenceNumber;\n\t\t}\n\t\tif (this.eventParameters != undefined) {\n\t\t\tif (typeof this.eventParameters === \"number\") {\n\t\t\t\t// Try to look up the enum label\n\t\t\t\tlet found = false;\n\t\t\t\tif (\n\t\t\t\t\tvalueConfig?.parameter?.type === \"enum\"\n\t\t\t\t) {\n\t\t\t\t\tconst label =\n\t\t\t\t\t\tvalueConfig.parameter.values[this.eventParameters];\n\t\t\t\t\tif (label) {\n\t\t\t\t\t\tmessage[\"state parameters\"] = label;\n\t\t\t\t\t\tfound = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (!found) {\n\t\t\t\t\tmessage[\"state parameters\"] = num2hex(this.eventParameters);\n\t\t\t\t}\n\t\t\t} else if (isUint8Array(this.eventParameters)) {\n\t\t\t\tmessage[\"event parameters\"] = buffer2hex(this.eventParameters);\n\t\t\t} else if (this.eventParameters instanceof Duration) {\n\t\t\t\tmessage[\"event parameters\"] = this.eventParameters.toString();\n\t\t\t} else {\n\t\t\t\tmessage[\"event parameters\"] = Object.entries(\n\t\t\t\t\tthis.eventParameters,\n\t\t\t\t)\n\t\t\t\t\t.map(([param, val]) => `\\n ${param}: ${num2hex(val)}`)\n\t\t\t\t\t.join(\"\");\n\t\t\t}\n\t\t} else if (\n\t\t\tvalueConfig?.parameter?.type === \"enum\"\n\t\t\t&& valueConfig.parameter.default != undefined\n\t\t) {\n\t\t\tconst label = valueConfig.parameter.values[\n\t\t\t\tvalueConfig.parameter.default\n\t\t\t];\n\t\t\tif (label) {\n\t\t\t\tmessage[\"state parameters\"] = `${label} (omitted)`;\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage,\n\t\t};\n\t}\n\n\tprivate parseEventParameters(ctx: PersistValuesContext): void {\n\t\t// This only makes sense for V2+ notifications\n\t\tif (\n\t\t\tthis.notificationType == undefined\n\t\t\t|| this.notificationEvent == undefined\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Look up the received notification and value in the config\n\t\tconst notification = getNotification(this.notificationType);\n\t\tif (!notification) return;\n\t\tconst valueConfig = getNotificationValue(\n\t\t\tnotification,\n\t\t\tthis.notificationEvent,\n\t\t);\n\t\tif (!valueConfig) return;\n\n\t\t// Parse the event parameters if possible\n\t\tif (valueConfig.parameter?.type === \"duration\") {\n\t\t\t// This only makes sense if the event parameters are a buffer\n\t\t\tif (!isUint8Array(this.eventParameters)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// The parameters contain a Duration\n\t\t\tthis.eventParameters = Duration.parseReport(\n\t\t\t\tthis.eventParameters[0],\n\t\t\t);\n\t\t} else if (valueConfig.parameter?.type === \"commandclass\") {\n\t\t\t// This only makes sense if the event parameters are a buffer\n\t\t\tif (!isUint8Array(this.eventParameters)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// The parameters **should** contain a CC, however there might be some exceptions\n\t\t\tif (\n\t\t\t\tthis.eventParameters.length === 1\n\t\t\t\t&& notification.type === 0x06\n\t\t\t\t&& (this.notificationEvent === 0x05\n\t\t\t\t\t|| this.notificationEvent === 0x06)\n\t\t\t) {\n\t\t\t\t// Access control -> Keypad Lock/Unlock operation\n\t\t\t\t// Some devices only send the User ID, not a complete CC payload\n\t\t\t\tthis.eventParameters = {\n\t\t\t\t\tuserId: this.eventParameters[0],\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\t// Try to parse the event parameters - if this fails, we should still handle the notification report\n\t\t\t\ttry {\n\t\t\t\t\t// Convert CommandClass instances to a standardized object representation\n\n\t\t\t\t\t// We do not want to parse asynchronously here, but the `CommandClass.parse` method is async.\n\t\t\t\t\t// However, we only deal with simple CCs that can be parsed synchronously. We can do this\n\t\t\t\t\t// by replicating what `CommandClass.parse` does: determine the correct CC class and call its\n\t\t\t\t\t// `from` method. If that returns a CC instance, we're good to continue.\n\n\t\t\t\t\tconst raw = CCRaw.parse(this.eventParameters);\n\t\t\t\t\tif (raw.ccCommand == undefined) {\n\t\t\t\t\t\tvalidatePayload.fail(\n\t\t\t\t\t\t\t\"event parameters contain an invalid CC\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tconst CommandConstructor = getCCCommandConstructor(\n\t\t\t\t\t\traw.ccId,\n\t\t\t\t\t\traw.ccCommand,\n\t\t\t\t\t);\n\t\t\t\t\tif (!CommandConstructor) {\n\t\t\t\t\t\tvalidatePayload.fail(\n\t\t\t\t\t\t\t\"event parameters contain an invalid CC\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst cc = CommandConstructor.from(raw, {\n\t\t\t\t\t\t...ctx,\n\t\t\t\t\t\tframeType: \"singlecast\",\n\t\t\t\t\t\tsourceNodeId: this.nodeId as number,\n\t\t\t\t\t\t// Security encapsulation is handled outside of this CC,\n\t\t\t\t\t\t// so it is not needed here:\n\t\t\t\t\t\thasSecurityClass: () => false,\n\t\t\t\t\t\tgetHighestSecurityClass: () => SecurityClass.None,\n\t\t\t\t\t\tsetSecurityClass: () => {},\n\t\t\t\t\t\tsecurityManager: undefined,\n\t\t\t\t\t\tsecurityManager2: undefined,\n\t\t\t\t\t\tsecurityManagerLR: undefined,\n\t\t\t\t\t});\n\t\t\t\t\tif (cc instanceof Promise) {\n\t\t\t\t\t\tvalidatePayload.fail(\n\t\t\t\t\t\t\t\"Cannot asynchronously parse CC from event parameters\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tvalidatePayload(!(cc instanceof InvalidCC));\n\t\t\t\t\tcc.encapsulatingCC = this as any;\n\n\t\t\t\t\tif (isNotificationEventPayload(cc)) {\n\t\t\t\t\t\tthis.eventParameters = cc\n\t\t\t\t\t\t\t.toNotificationEventParameters();\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// If a CC has no good toJSON() representation, we're only interested in the payload\n\t\t\t\t\t\tlet json = cc.toJSON();\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\"nodeId\" in json\n\t\t\t\t\t\t\t&& \"ccId\" in json\n\t\t\t\t\t\t\t&& \"payload\" in json\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tjson = pick(json, [\"payload\"]);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthis.eventParameters = json;\n\t\t\t\t\t}\n\t\t\t\t} catch (e) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tisZWaveError(e)\n\t\t\t\t\t\t&& e.code\n\t\t\t\t\t\t\t=== ZWaveErrorCodes.PacketFormat_InvalidPayload\n\t\t\t\t\t\t&& isUint8Array(this.eventParameters)\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst { ccId, ccCommand } = CCRaw.parse(\n\t\t\t\t\t\t\tthis.eventParameters,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tccId === CommandClasses[\"User Code\"]\n\t\t\t\t\t\t\t&& ccCommand === UserCodeCommand.Report\n\t\t\t\t\t\t\t&& this.eventParameters.length >= 3\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t// Access control -> Keypad Lock/Unlock operation\n\t\t\t\t\t\t\t// Some devices report the user code with truncated UserCode reports\n\t\t\t\t\t\t\tthis.eventParameters = {\n\t\t\t\t\t\t\t\tuserId: this.eventParameters[2],\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tctx.logNode(\n\t\t\t\t\t\t\t\tthis.nodeId as number,\n\t\t\t\t\t\t\t\t`Failed to parse Notification CC event parameters, ignoring them...`,\n\t\t\t\t\t\t\t\t\"error\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// unexpected error\n\t\t\t\t\t\tthrow e;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (valueConfig.parameter?.type === \"value\") {\n\t\t\t// This only makes sense if the event parameters are a buffer\n\t\t\tif (!isUint8Array(this.eventParameters)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// The parameters contain a named value\n\t\t\tthis.eventParameters = {\n\t\t\t\t[valueConfig.parameter.propertyName]: Bytes.view(\n\t\t\t\t\tthis.eventParameters,\n\t\t\t\t)\n\t\t\t\t\t.readUIntBE(\n\t\t\t\t\t\t0,\n\t\t\t\t\t\tthis.eventParameters.length,\n\t\t\t\t\t),\n\t\t\t};\n\t\t} else if (valueConfig.parameter?.type === \"enum\") {\n\t\t\t// The parameters may contain an enum value\n\t\t\tthis.eventParameters = isUint8Array(this.eventParameters)\n\t\t\t\t\t&& this.eventParameters.length === 1\n\t\t\t\t? this.eventParameters[0]\n\t\t\t\t: undefined;\n\n\t\t\t// Some devices send notifications without an event parameter when they should.\n\t\t\t// In this case, fall back to the default value where possible.\n\n\t\t\tif (\n\t\t\t\tthis.eventParameters == undefined\n\t\t\t\t&& valueConfig.parameter.default != undefined\n\t\t\t) {\n\t\t\t\tthis.eventParameters = valueConfig.parameter.default;\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tif (this.notificationType != undefined) {\n\t\t\tif (\n\t\t\t\tthis.notificationEvent == undefined\n\t\t\t) {\n\t\t\t\tthrow new ZWaveError(\n\t\t\t\t\t`Notification CC reports requires the notification event to be set!`,\n\t\t\t\t\tZWaveErrorCodes.Argument_Invalid,\n\t\t\t\t);\n\t\t\t} else if (\n\t\t\t\tthis.eventParameters != undefined\n\t\t\t\t&& !isUint8Array(this.eventParameters)\n\t\t\t) {\n\t\t\t\tthrow new ZWaveError(\n\t\t\t\t\t`When sending Notification CC reports, the event parameters can only be buffers!`,\n\t\t\t\t\tZWaveErrorCodes.Argument_Invalid,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst controlByte =\n\t\t\t\t(this.sequenceNumber != undefined ? 0b1000_0000 : 0)\n\t\t\t\t| ((this.eventParameters?.length ?? 0) & 0b11111);\n\t\t\tthis.payload = Bytes.from([\n\t\t\t\t0,\n\t\t\t\t0,\n\t\t\t\t0,\n\t\t\t\t0xff,\n\t\t\t\tthis.notificationType,\n\t\t\t\tthis.notificationEvent,\n\t\t\t\tcontrolByte,\n\t\t\t]);\n\t\t\tif (this.eventParameters) {\n\t\t\t\tthis.payload = Bytes.concat([\n\t\t\t\t\tthis.payload,\n\t\t\t\t\tthis.eventParameters,\n\t\t\t\t]);\n\t\t\t}\n\t\t\tif (this.sequenceNumber != undefined) {\n\t\t\t\tthis.payload = Bytes.concat([\n\t\t\t\t\tthis.payload,\n\t\t\t\t\tBytes.from([this.sequenceNumber]),\n\t\t\t\t]);\n\t\t\t}\n\t\t} else {\n\t\t\tthis.payload = Bytes.from([\n\t\t\t\tthis.alarmType ?? 0x00,\n\t\t\t\tthis.alarmLevel ?? 0x00,\n\t\t\t]);\n\t\t}\n\n\t\treturn super.serialize(ctx);\n\t}\n}\n\n// @publicAPI\nexport type NotificationCCGetOptions =\n\t| {\n\t\talarmType: number;\n\t}\n\t| {\n\t\tnotificationType: number;\n\t\tnotificationEvent?: number;\n\t};\n\n@CCCommand(NotificationCommand.Get)\n@expectedCCResponse(NotificationCCReport)\nexport class NotificationCCGet extends NotificationCC {\n\tpublic constructor(\n\t\toptions: WithAddress<NotificationCCGetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tif (\"alarmType\" in options) {\n\t\t\tthis.alarmType = options.alarmType;\n\t\t} else {\n\t\t\tthis.notificationType = options.notificationType;\n\t\t\tthis.notificationEvent = options.notificationEvent;\n\t\t}\n\t}\n\n\tpublic static from(raw: CCRaw, ctx: CCParsingContext): NotificationCCGet {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\n\t\tif (raw.payload.length >= 2) {\n\t\t\tconst notificationType = raw.payload[1];\n\t\t\tlet notificationEvent: number | undefined;\n\t\t\tif (raw.payload.length >= 3 && notificationType != 0xff) {\n\t\t\t\tnotificationEvent = raw.payload[2];\n\t\t\t}\n\t\t\treturn new this({\n\t\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\t\tnotificationType,\n\t\t\t\tnotificationEvent,\n\t\t\t});\n\t\t} else {\n\t\t\tconst alarmType = raw.payload[0];\n\t\t\treturn new this({\n\t\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\t\talarmType,\n\t\t\t});\n\t\t}\n\t}\n\n\t/** Proprietary V1/V2 alarm type */\n\tpublic alarmType: number | undefined;\n\t/** Regulated V3+ notification type */\n\tpublic notificationType: number | undefined;\n\tpublic notificationEvent: number | undefined;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tconst notificationEvent = this.notificationEvent === 0xff\n\t\t\t? 0x00\n\t\t\t: this.notificationEvent;\n\t\tthis.payload = Bytes.from([\n\t\t\tthis.alarmType ?? 0x00,\n\t\t\tthis.notificationType ?? 0xff,\n\t\t\tnotificationEvent ?? 0x00,\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.alarmType != undefined) {\n\t\t\tmessage[\"V1 alarm type\"] = this.alarmType;\n\t\t}\n\t\tif (this.notificationType != undefined) {\n\t\t\tmessage[\"notification type\"] = getNotificationName(\n\t\t\t\tthis.notificationType,\n\t\t\t);\n\t\t\tif (this.notificationEvent != undefined) {\n\t\t\t\tmessage[\"notification event\"] = getNotificationEventName(\n\t\t\t\t\tthis.notificationType,\n\t\t\t\t\tthis.notificationEvent,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage,\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport interface NotificationCCSupportedReportOptions {\n\tsupportsV1Alarm: boolean;\n\tsupportedNotificationTypes: number[];\n}\n\n@CCCommand(NotificationCommand.SupportedReport)\n@ccValueProperty(\"supportsV1Alarm\", NotificationCCValues.supportsV1Alarm)\n@ccValueProperty(\n\t\"supportedNotificationTypes\",\n\tNotificationCCValues.supportedNotificationTypes,\n)\nexport class NotificationCCSupportedReport extends NotificationCC {\n\tpublic constructor(\n\t\toptions: WithAddress<NotificationCCSupportedReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\tthis.supportsV1Alarm = options.supportsV1Alarm;\n\t\tthis.supportedNotificationTypes = options.supportedNotificationTypes;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): NotificationCCSupportedReport {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst supportsV1Alarm = !!(raw.payload[0] & 0b1000_0000);\n\t\tconst numBitMaskBytes = raw.payload[0] & 0b0001_1111;\n\t\tvalidatePayload(\n\t\t\tnumBitMaskBytes > 0,\n\t\t\traw.payload.length >= 1 + numBitMaskBytes,\n\t\t);\n\t\tconst notificationBitMask = raw.payload.subarray(\n\t\t\t1,\n\t\t\t1 + numBitMaskBytes,\n\t\t);\n\t\tconst supportedNotificationTypes = parseBitMask(\n\t\t\tnotificationBitMask,\n\t\t\t// bit 0 is ignored, but counting still starts at 1, so the first bit must have the value 0\n\t\t\t0,\n\t\t);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tsupportsV1Alarm,\n\t\t\tsupportedNotificationTypes,\n\t\t});\n\t}\n\n\tpublic supportsV1Alarm: boolean;\n\n\tpublic supportedNotificationTypes: number[];\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tconst bitMask = encodeBitMask(\n\t\t\tthis.supportedNotificationTypes,\n\t\t\tMath.max(...this.supportedNotificationTypes),\n\t\t\t0,\n\t\t);\n\t\tthis.payload = Bytes.concat([\n\t\t\tBytes.from([\n\t\t\t\t(this.supportsV1Alarm ? 0b1000_0000 : 0) | bitMask.length,\n\t\t\t]),\n\t\t\tbitMask,\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\"supports V1 alarm\": this.supportsV1Alarm,\n\t\t\t\t\"supported notification types\": this.supportedNotificationTypes\n\t\t\t\t\t.map(\n\t\t\t\t\t\t(t) => `\\n\u00B7 ${getNotificationName(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@CCCommand(NotificationCommand.SupportedGet)\n@expectedCCResponse(NotificationCCSupportedReport)\nexport class NotificationCCSupportedGet extends NotificationCC {}\n\n// @publicAPI\nexport interface NotificationCCEventSupportedReportOptions {\n\tnotificationType: number;\n\tsupportedEvents: number[];\n}\n\n@CCCommand(NotificationCommand.EventSupportedReport)\nexport class NotificationCCEventSupportedReport extends NotificationCC {\n\tpublic constructor(\n\t\toptions: WithAddress<NotificationCCEventSupportedReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\tthis.notificationType = options.notificationType;\n\t\tthis.supportedEvents = options.supportedEvents;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): NotificationCCEventSupportedReport {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst notificationType = raw.payload[0];\n\t\tconst numBitMaskBytes = raw.payload[1] & 0b000_11111;\n\n\t\tif (numBitMaskBytes === 0) {\n\t\t\t// Notification type is not supported\n\t\t\treturn new this({\n\t\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\t\tnotificationType,\n\t\t\t\tsupportedEvents: [],\n\t\t\t});\n\t\t}\n\n\t\tvalidatePayload(raw.payload.length >= 2 + numBitMaskBytes);\n\t\tconst eventBitMask = raw.payload.subarray(2, 2 + numBitMaskBytes);\n\t\tconst supportedEvents = parseBitMask(\n\t\t\teventBitMask,\n\t\t\t// In this mask, bit 0 is ignored, but counting still starts at 1, so the first bit must have the value 0\n\t\t\t0,\n\t\t);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tnotificationType,\n\t\t\tsupportedEvents,\n\t\t});\n\t}\n\n\tpublic persistValues(ctx: PersistValuesContext): boolean {\n\t\tif (!super.persistValues(ctx)) return false;\n\n\t\t// Store which events this notification supports\n\t\tthis.setValue(\n\t\t\tctx,\n\t\t\tNotificationCCValues.supportedNotificationEvents(\n\t\t\t\tthis.notificationType,\n\t\t\t),\n\t\t\tthis.supportedEvents,\n\t\t);\n\n\t\t// For each event, predefine the value metadata\n\t\tconst notification = getNotification(this.notificationType);\n\n\t\tif (!notification) {\n\t\t\t// This is an unknown notification\n\t\t\tthis.setMetadata(\n\t\t\t\tctx,\n\t\t\t\tNotificationCCValues.unknownNotificationType(\n\t\t\t\t\tthis.notificationType,\n\t\t\t\t),\n\t\t\t);\n\t\t} else {\n\t\t\t// This is a standardized notification\n\t\t\tlet isFirst = true;\n\t\t\tfor (const value of this.supportedEvents) {\n\t\t\t\t// Find out which property we need to update\n\t\t\t\tconst valueConfig = getNotificationValue(notification, value);\n\t\t\t\tif (valueConfig?.type === \"state\") {\n\t\t\t\t\tconst notificationValue = NotificationCCValues\n\t\t\t\t\t\t.notificationVariable(\n\t\t\t\t\t\t\tnotification.name,\n\t\t\t\t\t\t\tvalueConfig.variableName,\n\t\t\t\t\t\t);\n\n\t\t\t\t\t// After we've created the metadata initially, extend it\n\t\t\t\t\tconst metadata = getNotificationValueMetadata(\n\t\t\t\t\t\tisFirst\n\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t: this.getMetadata(ctx, notificationValue),\n\t\t\t\t\t\tnotification,\n\t\t\t\t\t\tvalueConfig,\n\t\t\t\t\t);\n\n\t\t\t\t\tthis.setMetadata(ctx, notificationValue, metadata);\n\n\t\t\t\t\tisFirst = false;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tpublic notificationType: number;\n\tpublic supportedEvents: number[];\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.from([this.notificationType, 0]);\n\t\tif (this.supportedEvents.length > 0) {\n\t\t\tconst bitMask = encodeBitMask(\n\t\t\t\tthis.supportedEvents,\n\t\t\t\tMath.max(...this.supportedEvents),\n\t\t\t\t0,\n\t\t\t);\n\t\t\tthis.payload[1] = bitMask.length;\n\t\t\tthis.payload = Bytes.concat([this.payload, bitMask]);\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\"notification type\": getNotificationName(this.notificationType),\n\t\t\t\t\"supported events\": this.supportedEvents\n\t\t\t\t\t.map(\n\t\t\t\t\t\t(e) =>\n\t\t\t\t\t\t\t`\\n\u00B7 ${\n\t\t\t\t\t\t\t\tgetNotificationValueName(\n\t\t\t\t\t\t\t\t\tthis.notificationType,\n\t\t\t\t\t\t\t\t\te,\n\t\t\t\t\t\t\t\t)\n\t\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 NotificationCCEventSupportedGetOptions {\n\tnotificationType: number;\n}\n\n@CCCommand(NotificationCommand.EventSupportedGet)\n@expectedCCResponse(NotificationCCEventSupportedReport)\nexport class NotificationCCEventSupportedGet extends NotificationCC {\n\tpublic constructor(\n\t\toptions: WithAddress<NotificationCCEventSupportedGetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.notificationType = options.notificationType;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): NotificationCCEventSupportedGet {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst notificationType = raw.payload[0];\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tnotificationType,\n\t\t});\n\t}\n\n\tpublic notificationType: number;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.from([this.notificationType]);\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\"notification type\": getNotificationName(this.notificationType),\n\t\t\t},\n\t\t};\n\t}\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,kBAuCO;AACP,oBAMO;AAEP,wBAAwB;AACxB,iBAMO;AACP,0BAQO;AACP,oCAUO;AACP,sCAA2C;AAC3C,oBAAkB;AAClB,mBAAqD;AACrD,cAAyB;AACzB,oCAAuC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiIjC,SAAU,sCACf,KACA,UAAoB;AAEpB,QAAM,UAAU,IAAI,cAAc,SAAS,MAAM;AACjD,MAA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AAK,gBAAgB,CAAC;AACjD,aAAO,MAAM,UAAU,GAAG;IAC3B;IAEO,WAAW,KAAgB;AACjC,aAAO;QACN,GAAG,MAAM,WAAW,GAAG;QACvB,SAAS;UACR,yBAAqB,iCAAoB,KAAK,gBAAgB;;;IAGjE;;;;",
|
|
6
6
|
"names": ["NotificationCC"]
|
|
7
7
|
}
|
|
@@ -100,9 +100,7 @@ export declare const ProtectionCCValues: Readonly<{
|
|
|
100
100
|
is: (valueId: import("@zwave-js/core").ValueID) => boolean;
|
|
101
101
|
readonly meta: {
|
|
102
102
|
readonly label: "RF protection timeout";
|
|
103
|
-
readonly
|
|
104
|
-
readonly max: 255;
|
|
105
|
-
readonly type: "number";
|
|
103
|
+
readonly type: "timeout";
|
|
106
104
|
readonly readable: true;
|
|
107
105
|
readonly writeable: true;
|
|
108
106
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cc/ProtectionCC.ts"],
|
|
4
|
-
"sourcesContent": ["import type { CCEncodingContext, CCParsingContext } from \"@zwave-js/cc\";\nimport {\n\tCommandClasses,\n\ttype GetValueDB,\n\tMAX_NODES,\n\ttype MaybeNotKnown,\n\ttype MessageOrCCLogEntry,\n\tMessagePriority,\n\ttype MessageRecord,\n\ttype SupervisionResult,\n\tTimeout,\n\tValueMetadata,\n\ttype WithAddress,\n\tZWaveError,\n\tZWaveErrorCodes,\n\tenumValuesToMetadataStates,\n\tparseBitMask,\n\tvalidatePayload,\n} from \"@zwave-js/core\";\nimport { Bytes, getEnumMemberName, pick } from \"@zwave-js/shared\";\nimport { validateArgs } from \"@zwave-js/transformers\";\nimport {\n\tCCAPI,\n\tPOLL_VALUE,\n\ttype PollValueImplementation,\n\tSET_VALUE,\n\ttype SetValueImplementation,\n\tthrowUnsupportedProperty,\n\tthrowWrongValueType,\n} from \"../lib/API.js\";\nimport {\n\ttype CCRaw,\n\tCommandClass,\n\ttype InterviewContext,\n\ttype PersistValuesContext,\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 {\n\tLocalProtectionState,\n\tProtectionCommand,\n\tRFProtectionState,\n} from \"../lib/_Types.js\";\n\nexport const ProtectionCCValues = V.defineCCValues(CommandClasses.Protection, {\n\t...V.staticProperty(\n\t\t\"exclusiveControlNodeId\",\n\t\t{\n\t\t\t...ValueMetadata.UInt8,\n\t\t\tmin: 1,\n\t\t\tmax: MAX_NODES,\n\t\t\tlabel: \"Node ID with exclusive control\",\n\t\t} as const,\n\t\t{ minVersion: 2 } as const,\n\t),\n\t...V.staticPropertyWithName(\n\t\t\"localProtectionState\",\n\t\t\"local\",\n\t\t{\n\t\t\t...ValueMetadata.Number,\n\t\t\tlabel: \"Local protection state\",\n\t\t\tstates: enumValuesToMetadataStates(LocalProtectionState),\n\t\t} as const,\n\t),\n\t...V.staticPropertyWithName(\n\t\t\"rfProtectionState\",\n\t\t\"rf\",\n\t\t{\n\t\t\t...ValueMetadata.Number,\n\t\t\tlabel: \"RF protection state\",\n\t\t\tstates: enumValuesToMetadataStates(RFProtectionState),\n\t\t} as const,\n\t\t{ minVersion: 2 } as const,\n\t),\n\t...V.staticProperty(\n\t\t\"timeout\",\n\t\t{\n\t\t\t...ValueMetadata.UInt8,\n\t\t\tlabel: \"RF protection timeout\",\n\t\t} as const,\n\t\t{ minVersion: 2 } as const,\n\t),\n\t...V.staticProperty(\"supportsExclusiveControl\", undefined, {\n\t\tinternal: true,\n\t}),\n\t...V.staticProperty(\"supportsTimeout\", undefined, {\n\t\tinternal: true,\n\t}),\n\t...V.staticProperty(\"supportedLocalStates\", undefined, {\n\t\tinternal: true,\n\t}),\n\t...V.staticProperty(\"supportedRFStates\", undefined, {\n\t\tinternal: true,\n\t}),\n});\n\n@API(CommandClasses.Protection)\nexport class ProtectionCCAPI extends CCAPI {\n\tpublic supportsCommand(cmd: ProtectionCommand): MaybeNotKnown<boolean> {\n\t\tswitch (cmd) {\n\t\t\tcase ProtectionCommand.Get:\n\t\t\t\treturn this.isSinglecast();\n\t\t\tcase ProtectionCommand.Set:\n\t\t\t\treturn true; // This is mandatory\n\t\t\tcase ProtectionCommand.SupportedGet:\n\t\t\t\treturn this.version >= 2 && this.isSinglecast();\n\t\t\tcase ProtectionCommand.TimeoutGet:\n\t\t\tcase ProtectionCommand.TimeoutSet: {\n\t\t\t\treturn (\n\t\t\t\t\tthis.isSinglecast()\n\t\t\t\t\t&& this.tryGetValueDB()?.getValue<boolean>(\n\t\t\t\t\t\tProtectionCCValues.supportsTimeout.endpoint(\n\t\t\t\t\t\t\tthis.endpoint.index,\n\t\t\t\t\t\t),\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\t\t\tcase ProtectionCommand.ExclusiveControlGet:\n\t\t\tcase ProtectionCommand.ExclusiveControlSet: {\n\t\t\t\treturn (\n\t\t\t\t\tthis.isSinglecast()\n\t\t\t\t\t&& this.tryGetValueDB()?.getValue<boolean>(\n\t\t\t\t\t\tProtectionCCValues.supportsExclusiveControl.endpoint(\n\t\t\t\t\t\t\tthis.endpoint.index,\n\t\t\t\t\t\t),\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\treturn super.supportsCommand(cmd);\n\t}\n\n\tprotected override get [SET_VALUE](): SetValueImplementation {\n\t\treturn async function(this: ProtectionCCAPI, { property }, value) {\n\t\t\tconst valueDB = this.tryGetValueDB();\n\t\t\tif (property === \"local\") {\n\t\t\t\tif (typeof value !== \"number\") {\n\t\t\t\t\tthrowWrongValueType(\n\t\t\t\t\t\tthis.ccId,\n\t\t\t\t\t\tproperty,\n\t\t\t\t\t\t\"number\",\n\t\t\t\t\t\ttypeof value,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\t// We need to set both values together, so retrieve the other one from the value DB\n\t\t\t\tconst rf = valueDB?.getValue<RFProtectionState>(\n\t\t\t\t\tProtectionCCValues.rfProtectionState.endpoint(\n\t\t\t\t\t\tthis.endpoint.index,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\treturn this.set(value, rf);\n\t\t\t} else if (property === \"rf\") {\n\t\t\t\tif (typeof value !== \"number\") {\n\t\t\t\t\tthrowWrongValueType(\n\t\t\t\t\t\tthis.ccId,\n\t\t\t\t\t\tproperty,\n\t\t\t\t\t\t\"number\",\n\t\t\t\t\t\ttypeof value,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\t// We need to set both values together, so retrieve the other one from the value DB\n\t\t\t\tconst local = valueDB?.getValue<LocalProtectionState>(\n\t\t\t\t\tProtectionCCValues.localProtectionState.endpoint(\n\t\t\t\t\t\tthis.endpoint.index,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\treturn this.set(\n\t\t\t\t\tlocal ?? LocalProtectionState.Unprotected,\n\t\t\t\t\tvalue,\n\t\t\t\t);\n\t\t\t} else if (property === \"exclusiveControlNodeId\") {\n\t\t\t\tif (typeof value !== \"number\") {\n\t\t\t\t\tthrowWrongValueType(\n\t\t\t\t\t\tthis.ccId,\n\t\t\t\t\t\tproperty,\n\t\t\t\t\t\t\"number\",\n\t\t\t\t\t\ttypeof value,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn this.setExclusiveControl(value);\n\t\t\t} else {\n\t\t\t\tthrowUnsupportedProperty(this.ccId, property);\n\t\t\t}\n\t\t};\n\t}\n\n\tprotected get [POLL_VALUE](): PollValueImplementation {\n\t\treturn async function(this: ProtectionCCAPI, { property }) {\n\t\t\tswitch (property) {\n\t\t\t\tcase \"local\":\n\t\t\t\tcase \"rf\":\n\t\t\t\t\treturn (await this.get())?.[property];\n\t\t\t\tcase \"exclusiveControlNodeId\":\n\t\t\t\t\treturn this.getExclusiveControl();\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// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n\tpublic async get() {\n\t\tthis.assertSupportsCommand(ProtectionCommand, ProtectionCommand.Get);\n\n\t\tconst cc = new ProtectionCCGet({\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<ProtectionCCReport>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\tif (response) {\n\t\t\treturn pick(response, [\"local\", \"rf\"]);\n\t\t}\n\t}\n\n\t@validateArgs({ strictEnums: true })\n\tpublic async set(\n\t\tlocal: LocalProtectionState,\n\t\trf?: RFProtectionState,\n\t): Promise<SupervisionResult | undefined> {\n\t\tthis.assertSupportsCommand(ProtectionCommand, ProtectionCommand.Set);\n\n\t\tconst cc = new ProtectionCCSet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tlocal,\n\t\t\trf,\n\t\t});\n\t\treturn this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n\tpublic async getSupported() {\n\t\tthis.assertSupportsCommand(\n\t\t\tProtectionCommand,\n\t\t\tProtectionCommand.SupportedGet,\n\t\t);\n\n\t\tconst cc = new ProtectionCCSupportedGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tconst response = await this.host.sendCommand<\n\t\t\tProtectionCCSupportedReport\n\t\t>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\tif (response) {\n\t\t\treturn pick(response, [\n\t\t\t\t\"supportsExclusiveControl\",\n\t\t\t\t\"supportsTimeout\",\n\t\t\t\t\"supportedLocalStates\",\n\t\t\t\t\"supportedRFStates\",\n\t\t\t]);\n\t\t}\n\t}\n\n\tpublic async getExclusiveControl(): Promise<MaybeNotKnown<number>> {\n\t\tthis.assertSupportsCommand(\n\t\t\tProtectionCommand,\n\t\t\tProtectionCommand.ExclusiveControlGet,\n\t\t);\n\n\t\tconst cc = new ProtectionCCExclusiveControlGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tconst response = await this.host.sendCommand<\n\t\t\tProtectionCCExclusiveControlReport\n\t\t>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\treturn response?.exclusiveControlNodeId;\n\t}\n\n\t@validateArgs()\n\tpublic async setExclusiveControl(\n\t\tnodeId: number,\n\t): Promise<SupervisionResult | undefined> {\n\t\tthis.assertSupportsCommand(\n\t\t\tProtectionCommand,\n\t\t\tProtectionCommand.ExclusiveControlSet,\n\t\t);\n\n\t\tconst cc = new ProtectionCCExclusiveControlSet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\texclusiveControlNodeId: nodeId,\n\t\t});\n\t\treturn this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\tpublic async getTimeout(): Promise<MaybeNotKnown<Timeout>> {\n\t\tthis.assertSupportsCommand(\n\t\t\tProtectionCommand,\n\t\t\tProtectionCommand.TimeoutGet,\n\t\t);\n\n\t\tconst cc = new ProtectionCCTimeoutGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tconst response = await this.host.sendCommand<\n\t\t\tProtectionCCTimeoutReport\n\t\t>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\treturn response?.timeout;\n\t}\n\n\t@validateArgs()\n\tpublic async setTimeout(\n\t\ttimeout: Timeout,\n\t): Promise<SupervisionResult | undefined> {\n\t\tthis.assertSupportsCommand(\n\t\t\tProtectionCommand,\n\t\t\tProtectionCommand.TimeoutSet,\n\t\t);\n\n\t\tconst cc = new ProtectionCCTimeoutSet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\ttimeout,\n\t\t});\n\t\treturn this.host.sendCommand(cc, this.commandOptions);\n\t}\n}\n\n@commandClass(CommandClasses.Protection)\n@implementedVersion(2)\n@ccValues(ProtectionCCValues)\nexport class ProtectionCC extends CommandClass {\n\tdeclare ccCommand: ProtectionCommand;\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.Protection,\n\t\t\tctx,\n\t\t\tendpoint,\n\t\t).withOptions({\n\t\t\tpriority: MessagePriority.NodeQuery,\n\t\t});\n\n\t\tctx.logNode(node.id, {\n\t\t\tendpoint: this.endpointIndex,\n\t\t\tmessage: `Interviewing ${this.ccName}...`,\n\t\t\tdirection: \"none\",\n\t\t});\n\n\t\t// We need to do some queries after a potential timeout\n\t\t// In this case, do now mark this CC as interviewed completely\n\t\tlet hadCriticalTimeout = false;\n\n\t\t// First find out what the device supports\n\t\tif (api.version >= 2) {\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tmessage: \"querying protection capabilities...\",\n\t\t\t\tdirection: \"outbound\",\n\t\t\t});\n\t\t\tconst resp = await api.getSupported();\n\t\t\tif (resp) {\n\t\t\t\tconst logMessage = `received protection capabilities:\nexclusive control: ${resp.supportsExclusiveControl}\ntimeout: ${resp.supportsTimeout}\nlocal protection states: ${\n\t\t\t\t\tresp.supportedLocalStates\n\t\t\t\t\t\t.map((local) =>\n\t\t\t\t\t\t\tgetEnumMemberName(LocalProtectionState, local)\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.map((str) => `\\n\u00B7 ${str}`)\n\t\t\t\t\t\t.join(\"\")\n\t\t\t\t}\nRF protection states: ${\n\t\t\t\t\tresp.supportedRFStates\n\t\t\t\t\t\t.map((local) =>\n\t\t\t\t\t\t\tgetEnumMemberName(RFProtectionState, local)\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.map((str) => `\\n\u00B7 ${str}`)\n\t\t\t\t\t\t.join(\"\")\n\t\t\t\t}`;\n\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\tmessage: logMessage,\n\t\t\t\t\tdirection: \"inbound\",\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\thadCriticalTimeout = true;\n\t\t\t}\n\t\t}\n\n\t\tawait this.refreshValues(ctx);\n\n\t\t// Remember that the interview is complete\n\t\tif (!hadCriticalTimeout) this.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.Protection,\n\t\t\tctx,\n\t\t\tendpoint,\n\t\t).withOptions({\n\t\t\tpriority: MessagePriority.NodeQuery,\n\t\t});\n\n\t\tconst supportsExclusiveControl = !!this.getValue(\n\t\t\tctx,\n\t\t\tProtectionCCValues.supportsExclusiveControl,\n\t\t);\n\t\tconst supportsTimeout = !!this.getValue(\n\t\t\tctx,\n\t\t\tProtectionCCValues.supportsTimeout,\n\t\t);\n\n\t\t// Query the current state\n\t\tctx.logNode(node.id, {\n\t\t\tmessage: \"querying protection status...\",\n\t\t\tdirection: \"outbound\",\n\t\t});\n\t\tconst protectionResp = await api.get();\n\t\tif (protectionResp) {\n\t\t\tlet logMessage = `received protection status:\nlocal: ${getEnumMemberName(LocalProtectionState, protectionResp.local)}`;\n\t\t\tif (protectionResp.rf != undefined) {\n\t\t\t\tlogMessage += `\nrf ${getEnumMemberName(RFProtectionState, protectionResp.rf)}`;\n\t\t\t}\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tmessage: logMessage,\n\t\t\t\tdirection: \"inbound\",\n\t\t\t});\n\t\t}\n\n\t\tif (supportsTimeout) {\n\t\t\t// Query the current timeout\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tmessage: \"querying protection timeout...\",\n\t\t\t\tdirection: \"outbound\",\n\t\t\t});\n\t\t\tconst timeout = await api.getTimeout();\n\t\t\tif (timeout) {\n\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\tmessage: `received timeout: ${timeout.toString()}`,\n\t\t\t\t\tdirection: \"inbound\",\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tif (supportsExclusiveControl) {\n\t\t\t// Query the current timeout\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tmessage: \"querying exclusive control node...\",\n\t\t\t\tdirection: \"outbound\",\n\t\t\t});\n\t\t\tconst nodeId = await api.getExclusiveControl();\n\t\t\tif (nodeId != undefined) {\n\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\tmessage: (nodeId !== 0\n\t\t\t\t\t\t? `Node ${nodeId.toString().padStart(3, \"0\")}`\n\t\t\t\t\t\t: `no node`) + ` has exclusive control`,\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 ProtectionCCSetOptions {\n\tlocal: LocalProtectionState;\n\trf?: RFProtectionState;\n}\n\n@CCCommand(ProtectionCommand.Set)\n@useSupervision()\nexport class ProtectionCCSet extends ProtectionCC {\n\tpublic constructor(\n\t\toptions: WithAddress<ProtectionCCSetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.local = options.local;\n\t\tthis.rf = options.rf;\n\t}\n\n\tpublic static from(_raw: CCRaw, _ctx: CCParsingContext): ProtectionCCSet {\n\t\t// TODO: Deserialize payload\n\t\tthrow new ZWaveError(\n\t\t\t`${this.name}: deserialization not implemented`,\n\t\t\tZWaveErrorCodes.Deserialization_NotImplemented,\n\t\t);\n\n\t\t// return new ProtectionCCSet({\n\t\t// \tnodeId: ctx.sourceNodeId,\n\t\t// });\n\t}\n\n\tpublic local: LocalProtectionState;\n\tpublic rf?: RFProtectionState;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.from([\n\t\t\tthis.local & 0b1111,\n\t\t\t(this.rf ?? RFProtectionState.Unprotected) & 0b1111,\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 include the local state\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\tlocal: getEnumMemberName(LocalProtectionState, this.local),\n\t\t};\n\t\tif (this.rf != undefined) {\n\t\t\tmessage.rf = getEnumMemberName(RFProtectionState, this.rf);\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 ProtectionCCReportOptions {\n\tlocal: LocalProtectionState;\n\trf?: RFProtectionState;\n}\n\n@CCCommand(ProtectionCommand.Report)\n@ccValueProperty(\"local\", ProtectionCCValues.localProtectionState)\n@ccValueProperty(\"rf\", ProtectionCCValues.rfProtectionState)\nexport class ProtectionCCReport extends ProtectionCC {\n\tpublic constructor(\n\t\toptions: WithAddress<ProtectionCCReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\t// TODO: Check implementation:\n\t\tthis.local = options.local;\n\t\tthis.rf = options.rf;\n\t}\n\n\tpublic static from(raw: CCRaw, ctx: CCParsingContext): ProtectionCCReport {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst local: LocalProtectionState = raw.payload[0] & 0b1111;\n\t\tlet rf: RFProtectionState | undefined;\n\t\tif (raw.payload.length >= 2) {\n\t\t\trf = raw.payload[1] & 0b1111;\n\t\t}\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tlocal,\n\t\t\trf,\n\t\t});\n\t}\n\n\tpublic readonly local: LocalProtectionState;\n\n\tpublic readonly rf?: RFProtectionState;\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\tconst message: MessageRecord = {\n\t\t\tlocal: getEnumMemberName(LocalProtectionState, this.local),\n\t\t};\n\t\tif (this.rf != undefined) {\n\t\t\tmessage.rf = getEnumMemberName(RFProtectionState, this.rf);\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(ProtectionCommand.Get)\n@expectedCCResponse(ProtectionCCReport)\nexport class ProtectionCCGet extends ProtectionCC {}\n\n// @publicAPI\nexport interface ProtectionCCSupportedReportOptions {\n\tsupportsTimeout: boolean;\n\tsupportsExclusiveControl: boolean;\n\tsupportedLocalStates: LocalProtectionState[];\n\tsupportedRFStates: RFProtectionState[];\n}\n\n@CCCommand(ProtectionCommand.SupportedReport)\n@ccValueProperty(\n\t\"supportsExclusiveControl\",\n\tProtectionCCValues.supportsExclusiveControl,\n)\n@ccValueProperty(\"supportsTimeout\", ProtectionCCValues.supportsTimeout)\n@ccValueProperty(\n\t\"supportedLocalStates\",\n\tProtectionCCValues.supportedLocalStates,\n)\n@ccValueProperty(\"supportedRFStates\", ProtectionCCValues.supportedRFStates)\nexport class ProtectionCCSupportedReport extends ProtectionCC {\n\tpublic constructor(\n\t\toptions: WithAddress<ProtectionCCSupportedReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\t// TODO: Check implementation:\n\t\tthis.supportsTimeout = options.supportsTimeout;\n\t\tthis.supportsExclusiveControl = options.supportsExclusiveControl;\n\t\tthis.supportedLocalStates = options.supportedLocalStates;\n\t\tthis.supportedRFStates = options.supportedRFStates;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): ProtectionCCSupportedReport {\n\t\tvalidatePayload(raw.payload.length >= 5);\n\t\tconst supportsTimeout = !!(raw.payload[0] & 0b1);\n\t\tconst supportsExclusiveControl = !!(raw.payload[0] & 0b10);\n\t\tconst supportedLocalStates: LocalProtectionState[] = parseBitMask(\n\t\t\traw.payload.subarray(1, 3),\n\t\t\tLocalProtectionState.Unprotected,\n\t\t);\n\t\tconst supportedRFStates: RFProtectionState[] = parseBitMask(\n\t\t\traw.payload.subarray(3, 5),\n\t\t\tRFProtectionState.Unprotected,\n\t\t);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tsupportsTimeout,\n\t\t\tsupportsExclusiveControl,\n\t\t\tsupportedLocalStates,\n\t\t\tsupportedRFStates,\n\t\t});\n\t}\n\n\tpublic persistValues(ctx: PersistValuesContext): boolean {\n\t\tif (!super.persistValues(ctx)) return false;\n\n\t\t// update metadata (partially) for the local and rf values\n\t\tconst localStateValue = ProtectionCCValues.localProtectionState;\n\t\tthis.setMetadata(ctx, localStateValue, {\n\t\t\t...localStateValue.meta,\n\t\t\tstates: enumValuesToMetadataStates(\n\t\t\t\tLocalProtectionState,\n\t\t\t\tthis.supportedLocalStates,\n\t\t\t),\n\t\t});\n\n\t\tconst rfStateValue = ProtectionCCValues.rfProtectionState;\n\t\tthis.setMetadata(ctx, rfStateValue, {\n\t\t\t...rfStateValue.meta,\n\t\t\tstates: enumValuesToMetadataStates(\n\t\t\t\tRFProtectionState,\n\t\t\t\tthis.supportedRFStates,\n\t\t\t),\n\t\t});\n\n\t\treturn true;\n\t}\n\n\tpublic readonly supportsExclusiveControl: boolean;\n\n\tpublic readonly supportsTimeout: boolean;\n\n\tpublic readonly supportedLocalStates: LocalProtectionState[];\n\n\tpublic readonly supportedRFStates: RFProtectionState[];\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\"supports exclusive control\": this.supportsExclusiveControl,\n\t\t\t\t\"supports timeout\": this.supportsTimeout,\n\t\t\t\t\"local protection states\": this.supportedLocalStates\n\t\t\t\t\t.map((local) =>\n\t\t\t\t\t\tgetEnumMemberName(LocalProtectionState, local)\n\t\t\t\t\t)\n\t\t\t\t\t.map((str) => `\\n\u00B7 ${str}`)\n\t\t\t\t\t.join(\"\"),\n\t\t\t\t\"RF protection states\": this.supportedRFStates\n\t\t\t\t\t.map((rf) => getEnumMemberName(RFProtectionState, rf))\n\t\t\t\t\t.map((str) => `\\n\u00B7 ${str}`)\n\t\t\t\t\t.join(\"\"),\n\t\t\t},\n\t\t};\n\t}\n}\n\n@CCCommand(ProtectionCommand.SupportedGet)\n@expectedCCResponse(ProtectionCCSupportedReport)\nexport class ProtectionCCSupportedGet extends ProtectionCC {}\n\n// @publicAPI\nexport interface ProtectionCCExclusiveControlReportOptions {\n\texclusiveControlNodeId: number;\n}\n\n@CCCommand(ProtectionCommand.ExclusiveControlReport)\n@ccValueProperty(\n\t\"exclusiveControlNodeId\",\n\tProtectionCCValues.exclusiveControlNodeId,\n)\nexport class ProtectionCCExclusiveControlReport extends ProtectionCC {\n\tpublic constructor(\n\t\toptions: WithAddress<ProtectionCCExclusiveControlReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\t// TODO: Check implementation:\n\t\tthis.exclusiveControlNodeId = options.exclusiveControlNodeId;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): ProtectionCCExclusiveControlReport {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst exclusiveControlNodeId = raw.payload[0];\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\texclusiveControlNodeId,\n\t\t});\n\t}\n\n\tpublic readonly exclusiveControlNodeId: number;\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\"exclusive control node id\": this.exclusiveControlNodeId,\n\t\t\t},\n\t\t};\n\t}\n}\n\n@CCCommand(ProtectionCommand.ExclusiveControlGet)\n@expectedCCResponse(ProtectionCCExclusiveControlReport)\nexport class ProtectionCCExclusiveControlGet extends ProtectionCC {}\n\n// @publicAPI\nexport interface ProtectionCCExclusiveControlSetOptions {\n\texclusiveControlNodeId: number;\n}\n\n@CCCommand(ProtectionCommand.ExclusiveControlSet)\n@expectedCCResponse(ProtectionCCReport)\n@useSupervision()\nexport class ProtectionCCExclusiveControlSet extends ProtectionCC {\n\tpublic constructor(\n\t\toptions: WithAddress<ProtectionCCExclusiveControlSetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.exclusiveControlNodeId = options.exclusiveControlNodeId;\n\t}\n\n\tpublic static from(\n\t\t_raw: CCRaw,\n\t\t_ctx: CCParsingContext,\n\t): ProtectionCCExclusiveControlSet {\n\t\t// TODO: Deserialize payload\n\t\tthrow new ZWaveError(\n\t\t\t`${this.name}: deserialization not implemented`,\n\t\t\tZWaveErrorCodes.Deserialization_NotImplemented,\n\t\t);\n\n\t\t// return new ProtectionCCExclusiveControlSet({\n\t\t// \tnodeId: ctx.sourceNodeId,\n\t\t// });\n\t}\n\n\tpublic exclusiveControlNodeId: number;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.from([this.exclusiveControlNodeId]);\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\"exclusive control node id\": this.exclusiveControlNodeId,\n\t\t\t},\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport interface ProtectionCCTimeoutReportOptions {\n\ttimeout: Timeout;\n}\n\n@CCCommand(ProtectionCommand.TimeoutReport)\n@ccValueProperty(\"timeout\", ProtectionCCValues.timeout)\nexport class ProtectionCCTimeoutReport extends ProtectionCC {\n\tpublic constructor(\n\t\toptions: WithAddress<ProtectionCCTimeoutReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\t// TODO: Check implementation:\n\t\tthis.timeout = options.timeout;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): ProtectionCCTimeoutReport {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst timeout: Timeout = Timeout.parse(raw.payload[0]);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\ttimeout,\n\t\t});\n\t}\n\n\tpublic readonly timeout: Timeout;\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: { timeout: this.timeout.toString() },\n\t\t};\n\t}\n}\n\n@CCCommand(ProtectionCommand.TimeoutGet)\n@expectedCCResponse(ProtectionCCTimeoutReport)\nexport class ProtectionCCTimeoutGet extends ProtectionCC {}\n\n// @publicAPI\nexport interface ProtectionCCTimeoutSetOptions {\n\ttimeout: Timeout;\n}\n\n@CCCommand(ProtectionCommand.TimeoutSet)\n@expectedCCResponse(ProtectionCCReport)\n@useSupervision()\nexport class ProtectionCCTimeoutSet extends ProtectionCC {\n\tpublic constructor(\n\t\toptions: WithAddress<ProtectionCCTimeoutSetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.timeout = options.timeout;\n\t}\n\n\tpublic static from(\n\t\t_raw: CCRaw,\n\t\t_ctx: CCParsingContext,\n\t): ProtectionCCTimeoutSet {\n\t\t// TODO: Deserialize payload\n\t\tthrow new ZWaveError(\n\t\t\t`${this.name}: deserialization not implemented`,\n\t\t\tZWaveErrorCodes.Deserialization_NotImplemented,\n\t\t);\n\n\t\t// return new ProtectionCCTimeoutSet({\n\t\t// \tnodeId: ctx.sourceNodeId,\n\t\t// });\n\t}\n\n\tpublic timeout: Timeout;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.from([this.timeout.serialize()]);\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: { timeout: this.timeout.toString() },\n\t\t};\n\t}\n}\n"],
|
|
4
|
+
"sourcesContent": ["import type { CCEncodingContext, CCParsingContext } from \"@zwave-js/cc\";\nimport {\n\tCommandClasses,\n\ttype GetValueDB,\n\tMAX_NODES,\n\ttype MaybeNotKnown,\n\ttype MessageOrCCLogEntry,\n\tMessagePriority,\n\ttype MessageRecord,\n\ttype SupervisionResult,\n\tTimeout,\n\tValueMetadata,\n\ttype WithAddress,\n\tZWaveError,\n\tZWaveErrorCodes,\n\tenumValuesToMetadataStates,\n\tparseBitMask,\n\tvalidatePayload,\n} from \"@zwave-js/core\";\nimport { Bytes, getEnumMemberName, pick } from \"@zwave-js/shared\";\nimport { validateArgs } from \"@zwave-js/transformers\";\nimport {\n\tCCAPI,\n\tPOLL_VALUE,\n\ttype PollValueImplementation,\n\tSET_VALUE,\n\ttype SetValueImplementation,\n\tthrowUnsupportedProperty,\n\tthrowWrongValueType,\n} from \"../lib/API.js\";\nimport {\n\ttype CCRaw,\n\tCommandClass,\n\ttype InterviewContext,\n\ttype PersistValuesContext,\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 {\n\tLocalProtectionState,\n\tProtectionCommand,\n\tRFProtectionState,\n} from \"../lib/_Types.js\";\n\nexport const ProtectionCCValues = V.defineCCValues(CommandClasses.Protection, {\n\t...V.staticProperty(\n\t\t\"exclusiveControlNodeId\",\n\t\t{\n\t\t\t...ValueMetadata.UInt8,\n\t\t\tmin: 1,\n\t\t\tmax: MAX_NODES,\n\t\t\tlabel: \"Node ID with exclusive control\",\n\t\t} as const,\n\t\t{ minVersion: 2 } as const,\n\t),\n\t...V.staticPropertyWithName(\n\t\t\"localProtectionState\",\n\t\t\"local\",\n\t\t{\n\t\t\t...ValueMetadata.Number,\n\t\t\tlabel: \"Local protection state\",\n\t\t\tstates: enumValuesToMetadataStates(LocalProtectionState),\n\t\t} as const,\n\t),\n\t...V.staticPropertyWithName(\n\t\t\"rfProtectionState\",\n\t\t\"rf\",\n\t\t{\n\t\t\t...ValueMetadata.Number,\n\t\t\tlabel: \"RF protection state\",\n\t\t\tstates: enumValuesToMetadataStates(RFProtectionState),\n\t\t} as const,\n\t\t{ minVersion: 2 } as const,\n\t),\n\t...V.staticProperty(\n\t\t\"timeout\",\n\t\t{\n\t\t\t...ValueMetadata.Timeout,\n\t\t\tlabel: \"RF protection timeout\",\n\t\t} as const,\n\t\t{ minVersion: 2 } as const,\n\t),\n\t...V.staticProperty(\"supportsExclusiveControl\", undefined, {\n\t\tinternal: true,\n\t}),\n\t...V.staticProperty(\"supportsTimeout\", undefined, {\n\t\tinternal: true,\n\t}),\n\t...V.staticProperty(\"supportedLocalStates\", undefined, {\n\t\tinternal: true,\n\t}),\n\t...V.staticProperty(\"supportedRFStates\", undefined, {\n\t\tinternal: true,\n\t}),\n});\n\n@API(CommandClasses.Protection)\nexport class ProtectionCCAPI extends CCAPI {\n\tpublic supportsCommand(cmd: ProtectionCommand): MaybeNotKnown<boolean> {\n\t\tswitch (cmd) {\n\t\t\tcase ProtectionCommand.Get:\n\t\t\t\treturn this.isSinglecast();\n\t\t\tcase ProtectionCommand.Set:\n\t\t\t\treturn true; // This is mandatory\n\t\t\tcase ProtectionCommand.SupportedGet:\n\t\t\t\treturn this.version >= 2 && this.isSinglecast();\n\t\t\tcase ProtectionCommand.TimeoutGet:\n\t\t\tcase ProtectionCommand.TimeoutSet: {\n\t\t\t\treturn (\n\t\t\t\t\tthis.isSinglecast()\n\t\t\t\t\t&& this.tryGetValueDB()?.getValue<boolean>(\n\t\t\t\t\t\tProtectionCCValues.supportsTimeout.endpoint(\n\t\t\t\t\t\t\tthis.endpoint.index,\n\t\t\t\t\t\t),\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\t\t\tcase ProtectionCommand.ExclusiveControlGet:\n\t\t\tcase ProtectionCommand.ExclusiveControlSet: {\n\t\t\t\treturn (\n\t\t\t\t\tthis.isSinglecast()\n\t\t\t\t\t&& this.tryGetValueDB()?.getValue<boolean>(\n\t\t\t\t\t\tProtectionCCValues.supportsExclusiveControl.endpoint(\n\t\t\t\t\t\t\tthis.endpoint.index,\n\t\t\t\t\t\t),\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\treturn super.supportsCommand(cmd);\n\t}\n\n\tprotected override get [SET_VALUE](): SetValueImplementation {\n\t\treturn async function(this: ProtectionCCAPI, { property }, value) {\n\t\t\tconst valueDB = this.tryGetValueDB();\n\t\t\tif (property === \"local\") {\n\t\t\t\tif (typeof value !== \"number\") {\n\t\t\t\t\tthrowWrongValueType(\n\t\t\t\t\t\tthis.ccId,\n\t\t\t\t\t\tproperty,\n\t\t\t\t\t\t\"number\",\n\t\t\t\t\t\ttypeof value,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\t// We need to set both values together, so retrieve the other one from the value DB\n\t\t\t\tconst rf = valueDB?.getValue<RFProtectionState>(\n\t\t\t\t\tProtectionCCValues.rfProtectionState.endpoint(\n\t\t\t\t\t\tthis.endpoint.index,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\treturn this.set(value, rf);\n\t\t\t} else if (property === \"rf\") {\n\t\t\t\tif (typeof value !== \"number\") {\n\t\t\t\t\tthrowWrongValueType(\n\t\t\t\t\t\tthis.ccId,\n\t\t\t\t\t\tproperty,\n\t\t\t\t\t\t\"number\",\n\t\t\t\t\t\ttypeof value,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\t// We need to set both values together, so retrieve the other one from the value DB\n\t\t\t\tconst local = valueDB?.getValue<LocalProtectionState>(\n\t\t\t\t\tProtectionCCValues.localProtectionState.endpoint(\n\t\t\t\t\t\tthis.endpoint.index,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\treturn this.set(\n\t\t\t\t\tlocal ?? LocalProtectionState.Unprotected,\n\t\t\t\t\tvalue,\n\t\t\t\t);\n\t\t\t} else if (property === \"exclusiveControlNodeId\") {\n\t\t\t\tif (typeof value !== \"number\") {\n\t\t\t\t\tthrowWrongValueType(\n\t\t\t\t\t\tthis.ccId,\n\t\t\t\t\t\tproperty,\n\t\t\t\t\t\t\"number\",\n\t\t\t\t\t\ttypeof value,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn this.setExclusiveControl(value);\n\t\t\t} else {\n\t\t\t\tthrowUnsupportedProperty(this.ccId, property);\n\t\t\t}\n\t\t};\n\t}\n\n\tprotected get [POLL_VALUE](): PollValueImplementation {\n\t\treturn async function(this: ProtectionCCAPI, { property }) {\n\t\t\tswitch (property) {\n\t\t\t\tcase \"local\":\n\t\t\t\tcase \"rf\":\n\t\t\t\t\treturn (await this.get())?.[property];\n\t\t\t\tcase \"exclusiveControlNodeId\":\n\t\t\t\t\treturn this.getExclusiveControl();\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// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n\tpublic async get() {\n\t\tthis.assertSupportsCommand(ProtectionCommand, ProtectionCommand.Get);\n\n\t\tconst cc = new ProtectionCCGet({\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<ProtectionCCReport>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\tif (response) {\n\t\t\treturn pick(response, [\"local\", \"rf\"]);\n\t\t}\n\t}\n\n\t@validateArgs({ strictEnums: true })\n\tpublic async set(\n\t\tlocal: LocalProtectionState,\n\t\trf?: RFProtectionState,\n\t): Promise<SupervisionResult | undefined> {\n\t\tthis.assertSupportsCommand(ProtectionCommand, ProtectionCommand.Set);\n\n\t\tconst cc = new ProtectionCCSet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\tlocal,\n\t\t\trf,\n\t\t});\n\t\treturn this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n\tpublic async getSupported() {\n\t\tthis.assertSupportsCommand(\n\t\t\tProtectionCommand,\n\t\t\tProtectionCommand.SupportedGet,\n\t\t);\n\n\t\tconst cc = new ProtectionCCSupportedGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tconst response = await this.host.sendCommand<\n\t\t\tProtectionCCSupportedReport\n\t\t>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\tif (response) {\n\t\t\treturn pick(response, [\n\t\t\t\t\"supportsExclusiveControl\",\n\t\t\t\t\"supportsTimeout\",\n\t\t\t\t\"supportedLocalStates\",\n\t\t\t\t\"supportedRFStates\",\n\t\t\t]);\n\t\t}\n\t}\n\n\tpublic async getExclusiveControl(): Promise<MaybeNotKnown<number>> {\n\t\tthis.assertSupportsCommand(\n\t\t\tProtectionCommand,\n\t\t\tProtectionCommand.ExclusiveControlGet,\n\t\t);\n\n\t\tconst cc = new ProtectionCCExclusiveControlGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tconst response = await this.host.sendCommand<\n\t\t\tProtectionCCExclusiveControlReport\n\t\t>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\treturn response?.exclusiveControlNodeId;\n\t}\n\n\t@validateArgs()\n\tpublic async setExclusiveControl(\n\t\tnodeId: number,\n\t): Promise<SupervisionResult | undefined> {\n\t\tthis.assertSupportsCommand(\n\t\t\tProtectionCommand,\n\t\t\tProtectionCommand.ExclusiveControlSet,\n\t\t);\n\n\t\tconst cc = new ProtectionCCExclusiveControlSet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\texclusiveControlNodeId: nodeId,\n\t\t});\n\t\treturn this.host.sendCommand(cc, this.commandOptions);\n\t}\n\n\tpublic async getTimeout(): Promise<MaybeNotKnown<Timeout>> {\n\t\tthis.assertSupportsCommand(\n\t\t\tProtectionCommand,\n\t\t\tProtectionCommand.TimeoutGet,\n\t\t);\n\n\t\tconst cc = new ProtectionCCTimeoutGet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t});\n\t\tconst response = await this.host.sendCommand<\n\t\t\tProtectionCCTimeoutReport\n\t\t>(\n\t\t\tcc,\n\t\t\tthis.commandOptions,\n\t\t);\n\t\treturn response?.timeout;\n\t}\n\n\t@validateArgs()\n\tpublic async setTimeout(\n\t\ttimeout: Timeout,\n\t): Promise<SupervisionResult | undefined> {\n\t\tthis.assertSupportsCommand(\n\t\t\tProtectionCommand,\n\t\t\tProtectionCommand.TimeoutSet,\n\t\t);\n\n\t\tconst cc = new ProtectionCCTimeoutSet({\n\t\t\tnodeId: this.endpoint.nodeId,\n\t\t\tendpointIndex: this.endpoint.index,\n\t\t\ttimeout,\n\t\t});\n\t\treturn this.host.sendCommand(cc, this.commandOptions);\n\t}\n}\n\n@commandClass(CommandClasses.Protection)\n@implementedVersion(2)\n@ccValues(ProtectionCCValues)\nexport class ProtectionCC extends CommandClass {\n\tdeclare ccCommand: ProtectionCommand;\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.Protection,\n\t\t\tctx,\n\t\t\tendpoint,\n\t\t).withOptions({\n\t\t\tpriority: MessagePriority.NodeQuery,\n\t\t});\n\n\t\tctx.logNode(node.id, {\n\t\t\tendpoint: this.endpointIndex,\n\t\t\tmessage: `Interviewing ${this.ccName}...`,\n\t\t\tdirection: \"none\",\n\t\t});\n\n\t\t// We need to do some queries after a potential timeout\n\t\t// In this case, do now mark this CC as interviewed completely\n\t\tlet hadCriticalTimeout = false;\n\n\t\t// First find out what the device supports\n\t\tif (api.version >= 2) {\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tmessage: \"querying protection capabilities...\",\n\t\t\t\tdirection: \"outbound\",\n\t\t\t});\n\t\t\tconst resp = await api.getSupported();\n\t\t\tif (resp) {\n\t\t\t\tconst logMessage = `received protection capabilities:\nexclusive control: ${resp.supportsExclusiveControl}\ntimeout: ${resp.supportsTimeout}\nlocal protection states: ${\n\t\t\t\t\tresp.supportedLocalStates\n\t\t\t\t\t\t.map((local) =>\n\t\t\t\t\t\t\tgetEnumMemberName(LocalProtectionState, local)\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.map((str) => `\\n\u00B7 ${str}`)\n\t\t\t\t\t\t.join(\"\")\n\t\t\t\t}\nRF protection states: ${\n\t\t\t\t\tresp.supportedRFStates\n\t\t\t\t\t\t.map((local) =>\n\t\t\t\t\t\t\tgetEnumMemberName(RFProtectionState, local)\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.map((str) => `\\n\u00B7 ${str}`)\n\t\t\t\t\t\t.join(\"\")\n\t\t\t\t}`;\n\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\tmessage: logMessage,\n\t\t\t\t\tdirection: \"inbound\",\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\thadCriticalTimeout = true;\n\t\t\t}\n\t\t}\n\n\t\tawait this.refreshValues(ctx);\n\n\t\t// Remember that the interview is complete\n\t\tif (!hadCriticalTimeout) this.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.Protection,\n\t\t\tctx,\n\t\t\tendpoint,\n\t\t).withOptions({\n\t\t\tpriority: MessagePriority.NodeQuery,\n\t\t});\n\n\t\tconst supportsExclusiveControl = !!this.getValue(\n\t\t\tctx,\n\t\t\tProtectionCCValues.supportsExclusiveControl,\n\t\t);\n\t\tconst supportsTimeout = !!this.getValue(\n\t\t\tctx,\n\t\t\tProtectionCCValues.supportsTimeout,\n\t\t);\n\n\t\t// Query the current state\n\t\tctx.logNode(node.id, {\n\t\t\tmessage: \"querying protection status...\",\n\t\t\tdirection: \"outbound\",\n\t\t});\n\t\tconst protectionResp = await api.get();\n\t\tif (protectionResp) {\n\t\t\tlet logMessage = `received protection status:\nlocal: ${getEnumMemberName(LocalProtectionState, protectionResp.local)}`;\n\t\t\tif (protectionResp.rf != undefined) {\n\t\t\t\tlogMessage += `\nrf ${getEnumMemberName(RFProtectionState, protectionResp.rf)}`;\n\t\t\t}\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tmessage: logMessage,\n\t\t\t\tdirection: \"inbound\",\n\t\t\t});\n\t\t}\n\n\t\tif (supportsTimeout) {\n\t\t\t// Query the current timeout\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tmessage: \"querying protection timeout...\",\n\t\t\t\tdirection: \"outbound\",\n\t\t\t});\n\t\t\tconst timeout = await api.getTimeout();\n\t\t\tif (timeout) {\n\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\tmessage: `received timeout: ${timeout.toString()}`,\n\t\t\t\t\tdirection: \"inbound\",\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tif (supportsExclusiveControl) {\n\t\t\t// Query the current timeout\n\t\t\tctx.logNode(node.id, {\n\t\t\t\tmessage: \"querying exclusive control node...\",\n\t\t\t\tdirection: \"outbound\",\n\t\t\t});\n\t\t\tconst nodeId = await api.getExclusiveControl();\n\t\t\tif (nodeId != undefined) {\n\t\t\t\tctx.logNode(node.id, {\n\t\t\t\t\tmessage: (nodeId !== 0\n\t\t\t\t\t\t? `Node ${nodeId.toString().padStart(3, \"0\")}`\n\t\t\t\t\t\t: `no node`) + ` has exclusive control`,\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 ProtectionCCSetOptions {\n\tlocal: LocalProtectionState;\n\trf?: RFProtectionState;\n}\n\n@CCCommand(ProtectionCommand.Set)\n@useSupervision()\nexport class ProtectionCCSet extends ProtectionCC {\n\tpublic constructor(\n\t\toptions: WithAddress<ProtectionCCSetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.local = options.local;\n\t\tthis.rf = options.rf;\n\t}\n\n\tpublic static from(_raw: CCRaw, _ctx: CCParsingContext): ProtectionCCSet {\n\t\t// TODO: Deserialize payload\n\t\tthrow new ZWaveError(\n\t\t\t`${this.name}: deserialization not implemented`,\n\t\t\tZWaveErrorCodes.Deserialization_NotImplemented,\n\t\t);\n\n\t\t// return new ProtectionCCSet({\n\t\t// \tnodeId: ctx.sourceNodeId,\n\t\t// });\n\t}\n\n\tpublic local: LocalProtectionState;\n\tpublic rf?: RFProtectionState;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.from([\n\t\t\tthis.local & 0b1111,\n\t\t\t(this.rf ?? RFProtectionState.Unprotected) & 0b1111,\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 include the local state\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\tlocal: getEnumMemberName(LocalProtectionState, this.local),\n\t\t};\n\t\tif (this.rf != undefined) {\n\t\t\tmessage.rf = getEnumMemberName(RFProtectionState, this.rf);\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 ProtectionCCReportOptions {\n\tlocal: LocalProtectionState;\n\trf?: RFProtectionState;\n}\n\n@CCCommand(ProtectionCommand.Report)\n@ccValueProperty(\"local\", ProtectionCCValues.localProtectionState)\n@ccValueProperty(\"rf\", ProtectionCCValues.rfProtectionState)\nexport class ProtectionCCReport extends ProtectionCC {\n\tpublic constructor(\n\t\toptions: WithAddress<ProtectionCCReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\t// TODO: Check implementation:\n\t\tthis.local = options.local;\n\t\tthis.rf = options.rf;\n\t}\n\n\tpublic static from(raw: CCRaw, ctx: CCParsingContext): ProtectionCCReport {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst local: LocalProtectionState = raw.payload[0] & 0b1111;\n\t\tlet rf: RFProtectionState | undefined;\n\t\tif (raw.payload.length >= 2) {\n\t\t\trf = raw.payload[1] & 0b1111;\n\t\t}\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tlocal,\n\t\t\trf,\n\t\t});\n\t}\n\n\tpublic readonly local: LocalProtectionState;\n\n\tpublic readonly rf?: RFProtectionState;\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\tconst message: MessageRecord = {\n\t\t\tlocal: getEnumMemberName(LocalProtectionState, this.local),\n\t\t};\n\t\tif (this.rf != undefined) {\n\t\t\tmessage.rf = getEnumMemberName(RFProtectionState, this.rf);\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(ProtectionCommand.Get)\n@expectedCCResponse(ProtectionCCReport)\nexport class ProtectionCCGet extends ProtectionCC {}\n\n// @publicAPI\nexport interface ProtectionCCSupportedReportOptions {\n\tsupportsTimeout: boolean;\n\tsupportsExclusiveControl: boolean;\n\tsupportedLocalStates: LocalProtectionState[];\n\tsupportedRFStates: RFProtectionState[];\n}\n\n@CCCommand(ProtectionCommand.SupportedReport)\n@ccValueProperty(\n\t\"supportsExclusiveControl\",\n\tProtectionCCValues.supportsExclusiveControl,\n)\n@ccValueProperty(\"supportsTimeout\", ProtectionCCValues.supportsTimeout)\n@ccValueProperty(\n\t\"supportedLocalStates\",\n\tProtectionCCValues.supportedLocalStates,\n)\n@ccValueProperty(\"supportedRFStates\", ProtectionCCValues.supportedRFStates)\nexport class ProtectionCCSupportedReport extends ProtectionCC {\n\tpublic constructor(\n\t\toptions: WithAddress<ProtectionCCSupportedReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\t// TODO: Check implementation:\n\t\tthis.supportsTimeout = options.supportsTimeout;\n\t\tthis.supportsExclusiveControl = options.supportsExclusiveControl;\n\t\tthis.supportedLocalStates = options.supportedLocalStates;\n\t\tthis.supportedRFStates = options.supportedRFStates;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): ProtectionCCSupportedReport {\n\t\tvalidatePayload(raw.payload.length >= 5);\n\t\tconst supportsTimeout = !!(raw.payload[0] & 0b1);\n\t\tconst supportsExclusiveControl = !!(raw.payload[0] & 0b10);\n\t\tconst supportedLocalStates: LocalProtectionState[] = parseBitMask(\n\t\t\traw.payload.subarray(1, 3),\n\t\t\tLocalProtectionState.Unprotected,\n\t\t);\n\t\tconst supportedRFStates: RFProtectionState[] = parseBitMask(\n\t\t\traw.payload.subarray(3, 5),\n\t\t\tRFProtectionState.Unprotected,\n\t\t);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\tsupportsTimeout,\n\t\t\tsupportsExclusiveControl,\n\t\t\tsupportedLocalStates,\n\t\t\tsupportedRFStates,\n\t\t});\n\t}\n\n\tpublic persistValues(ctx: PersistValuesContext): boolean {\n\t\tif (!super.persistValues(ctx)) return false;\n\n\t\t// update metadata (partially) for the local and rf values\n\t\tconst localStateValue = ProtectionCCValues.localProtectionState;\n\t\tthis.setMetadata(ctx, localStateValue, {\n\t\t\t...localStateValue.meta,\n\t\t\tstates: enumValuesToMetadataStates(\n\t\t\t\tLocalProtectionState,\n\t\t\t\tthis.supportedLocalStates,\n\t\t\t),\n\t\t});\n\n\t\tconst rfStateValue = ProtectionCCValues.rfProtectionState;\n\t\tthis.setMetadata(ctx, rfStateValue, {\n\t\t\t...rfStateValue.meta,\n\t\t\tstates: enumValuesToMetadataStates(\n\t\t\t\tRFProtectionState,\n\t\t\t\tthis.supportedRFStates,\n\t\t\t),\n\t\t});\n\n\t\treturn true;\n\t}\n\n\tpublic readonly supportsExclusiveControl: boolean;\n\n\tpublic readonly supportsTimeout: boolean;\n\n\tpublic readonly supportedLocalStates: LocalProtectionState[];\n\n\tpublic readonly supportedRFStates: RFProtectionState[];\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\"supports exclusive control\": this.supportsExclusiveControl,\n\t\t\t\t\"supports timeout\": this.supportsTimeout,\n\t\t\t\t\"local protection states\": this.supportedLocalStates\n\t\t\t\t\t.map((local) =>\n\t\t\t\t\t\tgetEnumMemberName(LocalProtectionState, local)\n\t\t\t\t\t)\n\t\t\t\t\t.map((str) => `\\n\u00B7 ${str}`)\n\t\t\t\t\t.join(\"\"),\n\t\t\t\t\"RF protection states\": this.supportedRFStates\n\t\t\t\t\t.map((rf) => getEnumMemberName(RFProtectionState, rf))\n\t\t\t\t\t.map((str) => `\\n\u00B7 ${str}`)\n\t\t\t\t\t.join(\"\"),\n\t\t\t},\n\t\t};\n\t}\n}\n\n@CCCommand(ProtectionCommand.SupportedGet)\n@expectedCCResponse(ProtectionCCSupportedReport)\nexport class ProtectionCCSupportedGet extends ProtectionCC {}\n\n// @publicAPI\nexport interface ProtectionCCExclusiveControlReportOptions {\n\texclusiveControlNodeId: number;\n}\n\n@CCCommand(ProtectionCommand.ExclusiveControlReport)\n@ccValueProperty(\n\t\"exclusiveControlNodeId\",\n\tProtectionCCValues.exclusiveControlNodeId,\n)\nexport class ProtectionCCExclusiveControlReport extends ProtectionCC {\n\tpublic constructor(\n\t\toptions: WithAddress<ProtectionCCExclusiveControlReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\t// TODO: Check implementation:\n\t\tthis.exclusiveControlNodeId = options.exclusiveControlNodeId;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): ProtectionCCExclusiveControlReport {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst exclusiveControlNodeId = raw.payload[0];\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\texclusiveControlNodeId,\n\t\t});\n\t}\n\n\tpublic readonly exclusiveControlNodeId: number;\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\"exclusive control node id\": this.exclusiveControlNodeId,\n\t\t\t},\n\t\t};\n\t}\n}\n\n@CCCommand(ProtectionCommand.ExclusiveControlGet)\n@expectedCCResponse(ProtectionCCExclusiveControlReport)\nexport class ProtectionCCExclusiveControlGet extends ProtectionCC {}\n\n// @publicAPI\nexport interface ProtectionCCExclusiveControlSetOptions {\n\texclusiveControlNodeId: number;\n}\n\n@CCCommand(ProtectionCommand.ExclusiveControlSet)\n@expectedCCResponse(ProtectionCCReport)\n@useSupervision()\nexport class ProtectionCCExclusiveControlSet extends ProtectionCC {\n\tpublic constructor(\n\t\toptions: WithAddress<ProtectionCCExclusiveControlSetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.exclusiveControlNodeId = options.exclusiveControlNodeId;\n\t}\n\n\tpublic static from(\n\t\t_raw: CCRaw,\n\t\t_ctx: CCParsingContext,\n\t): ProtectionCCExclusiveControlSet {\n\t\t// TODO: Deserialize payload\n\t\tthrow new ZWaveError(\n\t\t\t`${this.name}: deserialization not implemented`,\n\t\t\tZWaveErrorCodes.Deserialization_NotImplemented,\n\t\t);\n\n\t\t// return new ProtectionCCExclusiveControlSet({\n\t\t// \tnodeId: ctx.sourceNodeId,\n\t\t// });\n\t}\n\n\tpublic exclusiveControlNodeId: number;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.from([this.exclusiveControlNodeId]);\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\"exclusive control node id\": this.exclusiveControlNodeId,\n\t\t\t},\n\t\t};\n\t}\n}\n\n// @publicAPI\nexport interface ProtectionCCTimeoutReportOptions {\n\ttimeout: Timeout;\n}\n\n@CCCommand(ProtectionCommand.TimeoutReport)\n@ccValueProperty(\"timeout\", ProtectionCCValues.timeout)\nexport class ProtectionCCTimeoutReport extends ProtectionCC {\n\tpublic constructor(\n\t\toptions: WithAddress<ProtectionCCTimeoutReportOptions>,\n\t) {\n\t\tsuper(options);\n\n\t\t// TODO: Check implementation:\n\t\tthis.timeout = options.timeout;\n\t}\n\n\tpublic static from(\n\t\traw: CCRaw,\n\t\tctx: CCParsingContext,\n\t): ProtectionCCTimeoutReport {\n\t\tvalidatePayload(raw.payload.length >= 1);\n\t\tconst timeout: Timeout = Timeout.parse(raw.payload[0]);\n\n\t\treturn new this({\n\t\t\tnodeId: ctx.sourceNodeId,\n\t\t\ttimeout,\n\t\t});\n\t}\n\n\tpublic readonly timeout: Timeout;\n\n\tpublic toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n\t\treturn {\n\t\t\t...super.toLogEntry(ctx),\n\t\t\tmessage: { timeout: this.timeout.toString() },\n\t\t};\n\t}\n}\n\n@CCCommand(ProtectionCommand.TimeoutGet)\n@expectedCCResponse(ProtectionCCTimeoutReport)\nexport class ProtectionCCTimeoutGet extends ProtectionCC {}\n\n// @publicAPI\nexport interface ProtectionCCTimeoutSetOptions {\n\ttimeout: Timeout;\n}\n\n@CCCommand(ProtectionCommand.TimeoutSet)\n@expectedCCResponse(ProtectionCCReport)\n@useSupervision()\nexport class ProtectionCCTimeoutSet extends ProtectionCC {\n\tpublic constructor(\n\t\toptions: WithAddress<ProtectionCCTimeoutSetOptions>,\n\t) {\n\t\tsuper(options);\n\t\tthis.timeout = options.timeout;\n\t}\n\n\tpublic static from(\n\t\t_raw: CCRaw,\n\t\t_ctx: CCParsingContext,\n\t): ProtectionCCTimeoutSet {\n\t\t// TODO: Deserialize payload\n\t\tthrow new ZWaveError(\n\t\t\t`${this.name}: deserialization not implemented`,\n\t\t\tZWaveErrorCodes.Deserialization_NotImplemented,\n\t\t);\n\n\t\t// return new ProtectionCCTimeoutSet({\n\t\t// \tnodeId: ctx.sourceNodeId,\n\t\t// });\n\t}\n\n\tpublic timeout: Timeout;\n\n\tpublic serialize(ctx: CCEncodingContext): Promise<Bytes> {\n\t\tthis.payload = Bytes.from([this.timeout.serialize()]);\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: { timeout: this.timeout.toString() },\n\t\t};\n\t}\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAA,UAAA,GAAA,MAAA,uBAAA;;;AAAa,wBAAA,YAAA,uBAAA;;;;;IAUA,0BAAsB,MAAA;8BAHlC,yCAAU,+BAAkB,UAAU,OACtC,kDAAmB,kBAAkB,OACrC,8CAAc,CAAE;;;;oBAC2B;8CAAA,YAAY;WAAA;;;;;;;;AAAxD,mBAAA,MAAA,mBAAA,EAAA,OAAA,WAAA,GAAA,kBAAA,EAAA,MAAA,SAAA,MAAA,WAAA,MAAA,UAAA,UAAA,GAAA,MAAA,uBAAA;;;AAAa,wBAAA,YAAA,uBAAA;;IACZ,YACC,SAAmD;AAEnD,YAAM,OAAO;AACb,WAAK,UAAU,QAAQ;IACxB;IAEO,OAAO,KACb,MACA,MAAsB;AAGtB,YAAM,IAAI,uBACT,GAAG,KAAK,IAAI,qCACZ,4BAAgB,8BAA8B;IAMhD;IAEO;IAEA,UAAU,KAAsB;AACtC,WAAK,UAAU,oBAAM,KAAK,CAAC,KAAK,QAAQ,UAAS,CAAE,CAAC;AACpD,aAAO,MAAM,UAAU,GAAG;IAC3B;IAEO,WAAW,KAAgB;AACjC,aAAO;QACN,GAAG,MAAM,WAAW,GAAG;QACvB,SAAS,EAAE,SAAS,KAAK,QAAQ,SAAQ,EAAE;;IAE7C;;;;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -85,10 +85,12 @@ export declare class SecurityCCSchemeReport extends SecurityCC {
|
|
|
85
85
|
toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry;
|
|
86
86
|
}
|
|
87
87
|
export declare class SecurityCCSchemeGet extends SecurityCC {
|
|
88
|
+
static from(raw: CCRaw, ctx: CCParsingContext): SecurityCCSchemeGet;
|
|
88
89
|
serialize(ctx: CCEncodingContext): Promise<Bytes>;
|
|
89
90
|
toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry;
|
|
90
91
|
}
|
|
91
92
|
export declare class SecurityCCSchemeInherit extends SecurityCC {
|
|
93
|
+
static from(raw: CCRaw, ctx: CCParsingContext): SecurityCCSchemeInherit;
|
|
92
94
|
serialize(ctx: CCEncodingContext): Promise<Bytes>;
|
|
93
95
|
toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry;
|
|
94
96
|
}
|