@matterbridge/core 3.7.2-dev-20260329-5cac980 → 3.7.2-dev-20260331-ac050d8
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/dist/behaviors/doorLockServer.d.ts +44 -2
- package/dist/behaviors/doorLockServer.js +396 -3
- package/dist/behaviors/export.d.ts +0 -2
- package/dist/behaviors/export.js +0 -2
- package/dist/export.d.ts +0 -2
- package/dist/export.js +0 -2
- package/dist/frontend.js +6 -6
- package/dist/helpers.js +0 -5
- package/dist/matterNode.js +10 -2
- package/dist/matterbridge.js +10 -2
- package/dist/matterbridgeEndpoint.d.ts +4 -5
- package/dist/matterbridgeEndpoint.js +9 -33
- package/dist/matterbridgeEndpointCommandHandler.d.ts +8 -2
- package/dist/matterbridgeEndpointCommandHandler.js +2 -1
- package/dist/matterbridgeEndpointHelpers.d.ts +1 -0
- package/dist/matterbridgeEndpointHelpers.js +8 -0
- package/package.json +5 -5
- package/dist/behaviors/pinDoorLockServer.d.ts +0 -32
- package/dist/behaviors/pinDoorLockServer.js +0 -168
- package/dist/behaviors/userPinDoorLockServer.d.ts +0 -57
- package/dist/behaviors/userPinDoorLockServer.js +0 -348
|
@@ -24,7 +24,7 @@ import { ClusterId, EndpointNumber } from '@matter/types/datatype';
|
|
|
24
24
|
import { Semtag } from '@matter/types/globals';
|
|
25
25
|
import { AnsiLogger, LogLevel } from 'node-ansi-logger';
|
|
26
26
|
import { DeviceTypeDefinition } from './matterbridgeDeviceTypes.js';
|
|
27
|
-
import { CommandHandler, CommandHandlerData, CommandHandlerFunction, CommandHandlers } from './matterbridgeEndpointCommandHandler.js';
|
|
27
|
+
import { CommandHandler, CommandHandlerData, CommandHandlerExecutionResult, CommandHandlerFunction, CommandHandlers } from './matterbridgeEndpointCommandHandler.js';
|
|
28
28
|
import { MatterbridgeEndpointOptions, SerializedMatterbridgeEndpoint } from './matterbridgeEndpointTypes.js';
|
|
29
29
|
type BehaviorCommandName<T extends Behavior.Type> = {
|
|
30
30
|
[K in keyof CommandsOfBehavior<T>]: K;
|
|
@@ -101,7 +101,7 @@ export declare class MatterbridgeEndpoint extends Endpoint {
|
|
|
101
101
|
addUserLabel(label: string, value: string): Promise<this>;
|
|
102
102
|
addCommandHandler<C extends CommandHandlers>(command: C, handler: CommandHandlerFunction<C>): this;
|
|
103
103
|
removeCommandHandler<C extends CommandHandlers>(command: C, handler: CommandHandlerFunction<C>): this;
|
|
104
|
-
executeCommandHandler<C extends CommandHandlers>(command: C, request: CommandHandlerData<C>['request'], cluster: CommandHandlerData<C>['cluster'], attributes: CommandHandlerData<C>['attributes'], endpoint: CommandHandlerData<C>['endpoint']): Promise<
|
|
104
|
+
executeCommandHandler<C extends CommandHandlers>(command: C, request: CommandHandlerData<C>['request'], cluster: CommandHandlerData<C>['cluster'], attributes: CommandHandlerData<C>['attributes'], endpoint: CommandHandlerData<C>['endpoint']): Promise<CommandHandlerExecutionResult<C>>;
|
|
105
105
|
invokeBehaviorCommand<T extends Behavior.Type, C extends BehaviorCommandName<T>>(cluster: T, command: C, params?: BehaviorCommandParams<T, C>): Promise<void>;
|
|
106
106
|
invokeBehaviorCommand<T extends ClusterType, C extends keyof ClusterType.CommandsOf<T>>(cluster: T, command: C, params?: ClusterType.CommandsOf<T>[C] extends {
|
|
107
107
|
requestSchema: infer S extends import('@matter/types/tlv').TlvSchema<unknown>;
|
|
@@ -182,9 +182,8 @@ export declare class MatterbridgeEndpoint extends Endpoint {
|
|
|
182
182
|
}, airflowDirection?: FanControl.AirflowDirection): this;
|
|
183
183
|
createDefaultHepaFilterMonitoringClusterServer(condition?: number, changeIndication?: ResourceMonitoring.ChangeIndication, inPlaceIndicator?: boolean | undefined, lastChangedTime?: number | null | undefined, replacementProductList?: ResourceMonitoring.ReplacementProduct[]): this;
|
|
184
184
|
createDefaultActivatedCarbonFilterMonitoringClusterServer(condition?: number, changeIndication?: ResourceMonitoring.ChangeIndication, inPlaceIndicator?: boolean | undefined, lastChangedTime?: number | null | undefined, replacementProductList?: ResourceMonitoring.ReplacementProduct[]): this;
|
|
185
|
-
createDefaultDoorLockClusterServer(lockState?: DoorLock.LockState, lockType?: DoorLock.LockType): this;
|
|
186
|
-
|
|
187
|
-
createUserPinDoorLockClusterServer(lockState?: DoorLock.LockState, lockType?: DoorLock.LockType): this;
|
|
185
|
+
createDefaultDoorLockClusterServer(lockState?: DoorLock.LockState, lockType?: DoorLock.LockType, autoRelockTime?: number): this;
|
|
186
|
+
createUserPinDoorLockClusterServer(lockState?: DoorLock.LockState, lockType?: DoorLock.LockType, autoRelockTime?: number, minPinCodeLength?: number, maxPinCodeLength?: number): this;
|
|
188
187
|
createDefaultModeSelectClusterServer(description: string, supportedModes: ModeSelect.ModeOption[], currentMode?: number, startUpMode?: number): this;
|
|
189
188
|
createDefaultValveConfigurationAndControlClusterServer(valveState?: ValveConfigurationAndControl.ValveState, valveLevel?: number): this;
|
|
190
189
|
createDefaultPumpConfigurationAndControlClusterServer(pumpMode?: PumpConfigurationAndControl.OperationMode): this;
|
|
@@ -76,12 +76,10 @@ import { MatterbridgeServer } from './behaviors/matterbridgeServer.js';
|
|
|
76
76
|
import { MatterbridgeModeSelectServer } from './behaviors/modeSelectServer.js';
|
|
77
77
|
import { MatterbridgeOnOffServer } from './behaviors/onOffServer.js';
|
|
78
78
|
import { MatterbridgeOperationalStateServer } from './behaviors/operationalStateServer.js';
|
|
79
|
-
import { MatterbridgePinDoorLockServer } from './behaviors/pinDoorLockServer.js';
|
|
80
79
|
import { MatterbridgePowerSourceServer } from './behaviors/powerSourceServer.js';
|
|
81
80
|
import { MatterbridgeSmokeCoAlarmServer } from './behaviors/smokeCoAlarmServer.js';
|
|
82
81
|
import { MatterbridgeSwitchServer } from './behaviors/switchServer.js';
|
|
83
82
|
import { MatterbridgeThermostatServer } from './behaviors/thermostatServer.js';
|
|
84
|
-
import { MatterbridgeUserPinDoorLockServer } from './behaviors/userPinDoorLockServer.js';
|
|
85
83
|
import { MatterbridgeValveConfigurationAndControlServer } from './behaviors/valveConfigurationAndControlServer.js';
|
|
86
84
|
import { MatterbridgeWindowCoveringServer } from './behaviors/windowCoveringServer.js';
|
|
87
85
|
import { CommandHandler } from './matterbridgeEndpointCommandHandler.js';
|
|
@@ -264,7 +262,7 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
264
262
|
return this;
|
|
265
263
|
}
|
|
266
264
|
async executeCommandHandler(command, request, cluster, attributes, endpoint) {
|
|
267
|
-
|
|
265
|
+
return this.commandHandler.executeHandler(command, { command, request, cluster, attributes, endpoint });
|
|
268
266
|
}
|
|
269
267
|
async invokeBehaviorCommand(cluster, command, params) {
|
|
270
268
|
await invokeBehaviorCommand(this, cluster, command, params);
|
|
@@ -1068,8 +1066,8 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1068
1066
|
});
|
|
1069
1067
|
return this;
|
|
1070
1068
|
}
|
|
1071
|
-
createDefaultDoorLockClusterServer(lockState = DoorLock.LockState.Locked, lockType = DoorLock.LockType.DeadBolt) {
|
|
1072
|
-
this.behaviors.require(MatterbridgeDoorLockServer.enable({
|
|
1069
|
+
createDefaultDoorLockClusterServer(lockState = DoorLock.LockState.Locked, lockType = DoorLock.LockType.DeadBolt, autoRelockTime = 0) {
|
|
1070
|
+
this.behaviors.require(MatterbridgeDoorLockServer.with().enable({
|
|
1073
1071
|
events: { doorLockAlarm: true, lockOperation: true, lockOperationError: true },
|
|
1074
1072
|
commands: { lockDoor: true, unlockDoor: true, unlockWithTimeout: true },
|
|
1075
1073
|
}), {
|
|
@@ -1078,33 +1076,12 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1078
1076
|
actuatorEnabled: true,
|
|
1079
1077
|
operatingMode: DoorLock.OperatingMode.Normal,
|
|
1080
1078
|
supportedOperatingModes: { normal: false, vacation: true, privacy: true, noRemoteLockUnlock: false, passage: true, alwaysSet: 2047 },
|
|
1081
|
-
autoRelockTime
|
|
1079
|
+
autoRelockTime,
|
|
1082
1080
|
});
|
|
1083
1081
|
return this;
|
|
1084
1082
|
}
|
|
1085
|
-
|
|
1086
|
-
this.behaviors.require(
|
|
1087
|
-
events: { doorLockAlarm: true, lockOperation: true, lockOperationError: true },
|
|
1088
|
-
commands: { lockDoor: true, unlockDoor: true, unlockWithTimeout: true, setUserStatus: true, getUserStatus: true, setUserType: true, getUserType: true },
|
|
1089
|
-
}), {
|
|
1090
|
-
lockState,
|
|
1091
|
-
lockType,
|
|
1092
|
-
actuatorEnabled: true,
|
|
1093
|
-
operatingMode: DoorLock.OperatingMode.Normal,
|
|
1094
|
-
supportedOperatingModes: { normal: false, vacation: true, privacy: true, noRemoteLockUnlock: false, passage: true, alwaysSet: 2047 },
|
|
1095
|
-
autoRelockTime: 0,
|
|
1096
|
-
numberOfPinUsersSupported: 10,
|
|
1097
|
-
maxPinCodeLength: 10,
|
|
1098
|
-
minPinCodeLength: 4,
|
|
1099
|
-
wrongCodeEntryLimit: 5,
|
|
1100
|
-
userCodeTemporaryDisableTime: 60,
|
|
1101
|
-
sendPinOverTheAir: true,
|
|
1102
|
-
requirePinForRemoteOperation: true,
|
|
1103
|
-
});
|
|
1104
|
-
return this;
|
|
1105
|
-
}
|
|
1106
|
-
createUserPinDoorLockClusterServer(lockState = DoorLock.LockState.Locked, lockType = DoorLock.LockType.DeadBolt) {
|
|
1107
|
-
this.behaviors.require(MatterbridgeUserPinDoorLockServer.with(DoorLock.Feature.User, DoorLock.Feature.PinCredential, DoorLock.Feature.CredentialOverTheAirAccess).enable({
|
|
1083
|
+
createUserPinDoorLockClusterServer(lockState = DoorLock.LockState.Locked, lockType = DoorLock.LockType.DeadBolt, autoRelockTime = 0, minPinCodeLength = 4, maxPinCodeLength = 10) {
|
|
1084
|
+
this.behaviors.require(MatterbridgeDoorLockServer.with(DoorLock.Feature.User, DoorLock.Feature.PinCredential).enable({
|
|
1108
1085
|
events: { doorLockAlarm: true, lockOperation: true, lockOperationError: true },
|
|
1109
1086
|
commands: { lockDoor: true, unlockDoor: true, unlockWithTimeout: true },
|
|
1110
1087
|
}), {
|
|
@@ -1113,13 +1090,12 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1113
1090
|
actuatorEnabled: true,
|
|
1114
1091
|
operatingMode: DoorLock.OperatingMode.Normal,
|
|
1115
1092
|
supportedOperatingModes: { normal: false, vacation: true, privacy: true, noRemoteLockUnlock: false, passage: true, alwaysSet: 2047 },
|
|
1116
|
-
autoRelockTime
|
|
1093
|
+
autoRelockTime,
|
|
1117
1094
|
numberOfPinUsersSupported: 10,
|
|
1118
|
-
|
|
1119
|
-
|
|
1095
|
+
minPinCodeLength,
|
|
1096
|
+
maxPinCodeLength,
|
|
1120
1097
|
wrongCodeEntryLimit: 5,
|
|
1121
1098
|
userCodeTemporaryDisableTime: 60,
|
|
1122
|
-
requirePinForRemoteOperation: true,
|
|
1123
1099
|
numberOfTotalUsersSupported: 10,
|
|
1124
1100
|
credentialRulesSupport: { single: true },
|
|
1125
1101
|
numberOfCredentialsSupportedPerUser: 10,
|
|
@@ -129,7 +129,10 @@ export type CommandHandlerData<T extends CommandHandlers = CommandHandlers> = Co
|
|
|
129
129
|
export type CommandHandlerPayload<T extends CommandHandlers = CommandHandlers> = CommandHandlerData<T> & {
|
|
130
130
|
context?: ActionContext;
|
|
131
131
|
};
|
|
132
|
-
|
|
132
|
+
type VoidReturn = ReturnType<() => void>;
|
|
133
|
+
export type CommandHandlerResponse<T extends CommandHandlers = CommandHandlers> = T extends keyof CommandHandlerResponseMap ? CommandHandlerResponseMap[T] : VoidReturn;
|
|
134
|
+
export type CommandHandlerExecutionResult<T extends CommandHandlers = CommandHandlers> = T extends keyof CommandHandlerResponseMap ? CommandHandlerResponseMap[T] | undefined : VoidReturn;
|
|
135
|
+
export type CommandHandlerFunction<T extends CommandHandlers = CommandHandlers> = (data: CommandHandlerPayload<T>) => CommandHandlerResponse<T> | Promise<CommandHandlerResponse<T>>;
|
|
133
136
|
export type CommandHandlerDataMap = {
|
|
134
137
|
'identify': CommandHandlerData<'Identify.identify'>;
|
|
135
138
|
'triggerEffect': CommandHandlerData<'Identify.triggerEffect'>;
|
|
@@ -918,11 +921,14 @@ export type CommandHandlerDataMap = {
|
|
|
918
921
|
endpoint: MatterbridgeEndpoint;
|
|
919
922
|
};
|
|
920
923
|
};
|
|
924
|
+
export type CommandHandlerResponseMap = {
|
|
925
|
+
'DoorLock.getUser': DoorLock.GetUserResponse;
|
|
926
|
+
};
|
|
921
927
|
export declare class CommandHandler {
|
|
922
928
|
private handler;
|
|
923
929
|
hasHandler<K extends CommandHandlers>(command: K): boolean;
|
|
924
930
|
addHandler<K extends CommandHandlers>(command: K, handler: CommandHandlerFunction<K>): void;
|
|
925
|
-
executeHandler<K extends CommandHandlers>(command: K, ...args: Parameters<CommandHandlerFunction<K>>): Promise<
|
|
931
|
+
executeHandler<K extends CommandHandlers>(command: K, ...args: Parameters<CommandHandlerFunction<K>>): Promise<CommandHandlerExecutionResult<K>>;
|
|
926
932
|
removeHandler<K extends CommandHandlers>(command: K, handler: CommandHandlerFunction<K>): void;
|
|
927
933
|
}
|
|
928
934
|
export {};
|
|
@@ -16,12 +16,13 @@ export class CommandHandler {
|
|
|
16
16
|
}
|
|
17
17
|
const fallbackCommand = command.includes('.') ? command.split('.').pop() : undefined;
|
|
18
18
|
if (fallbackCommand === undefined)
|
|
19
|
-
return;
|
|
19
|
+
return undefined;
|
|
20
20
|
for (const { command: registeredCommand, handler } of this.handler) {
|
|
21
21
|
if (registeredCommand === fallbackCommand) {
|
|
22
22
|
return await handler(...args);
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
+
return undefined;
|
|
25
26
|
}
|
|
26
27
|
removeHandler(command, handler) {
|
|
27
28
|
this.handler = this.handler.filter(({ command: registeredCommand, handler: registeredHandler }) => {
|
|
@@ -32,6 +32,7 @@ export declare function generateUniqueId(deviceName: string): string;
|
|
|
32
32
|
export declare function createUniqueId(param1: string, param2: string, param3: string, param4: string): string;
|
|
33
33
|
export declare function getSemtag(semtag: Semtag, label?: string | null | undefined, mfgCode?: VendorId | null): Semtag;
|
|
34
34
|
export declare function featuresFor(endpoint: MatterbridgeEndpoint, cluster: Behavior.Type | ClusterType | ClusterId | string): Record<string, boolean | undefined>;
|
|
35
|
+
export declare function internalFor<T extends object = Record<string, unknown>>(endpoint: MatterbridgeEndpoint, cluster: Behavior.Type | ClusterType | ClusterId | string): Promise<T | undefined>;
|
|
35
36
|
export declare function getBehaviourTypesFromClusterServerIds(clusterServerList: ClusterId[]): Behavior.Type[];
|
|
36
37
|
export declare function getBehaviourTypesFromClusterClientIds(clusterClientList: ClusterId[]): Behavior.Type[];
|
|
37
38
|
export declare function getBehaviourTypeFromClusterServerId(clusterId: ClusterId): Behavior.Type;
|
|
@@ -174,6 +174,14 @@ export function featuresFor(endpoint, cluster) {
|
|
|
174
174
|
}
|
|
175
175
|
return endpoint.behaviors.supported[lowercaseFirstLetter(behaviorId)]['cluster']['supportedFeatures'];
|
|
176
176
|
}
|
|
177
|
+
export async function internalFor(endpoint, cluster) {
|
|
178
|
+
const behaviorId = getBehavior(endpoint, cluster)?.id;
|
|
179
|
+
if (!behaviorId) {
|
|
180
|
+
endpoint.log?.error(`internalFor error: cluster not found on endpoint ${or}${endpoint.maybeId}${er}:${or}${endpoint.maybeNumber}${er}`);
|
|
181
|
+
return undefined;
|
|
182
|
+
}
|
|
183
|
+
return endpoint.act((agent) => agent[behaviorId]?.internal);
|
|
184
|
+
}
|
|
177
185
|
export function getBehaviourTypesFromClusterServerIds(clusterServerList) {
|
|
178
186
|
const behaviorTypes = [];
|
|
179
187
|
clusterServerList.forEach((clusterId) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@matterbridge/core",
|
|
3
|
-
"version": "3.7.2-dev-
|
|
3
|
+
"version": "3.7.2-dev-20260331-ac050d8",
|
|
4
4
|
"description": "Matterbridge core library",
|
|
5
5
|
"author": "https://github.com/Luligu",
|
|
6
6
|
"homepage": "https://matterbridge.io/",
|
|
@@ -126,10 +126,10 @@
|
|
|
126
126
|
],
|
|
127
127
|
"dependencies": {
|
|
128
128
|
"@matter/main": "0.16.10",
|
|
129
|
-
"@matterbridge/dgram": "3.7.2-dev-
|
|
130
|
-
"@matterbridge/thread": "3.7.2-dev-
|
|
131
|
-
"@matterbridge/types": "3.7.2-dev-
|
|
132
|
-
"@matterbridge/utils": "3.7.2-dev-
|
|
129
|
+
"@matterbridge/dgram": "3.7.2-dev-20260331-ac050d8",
|
|
130
|
+
"@matterbridge/thread": "3.7.2-dev-20260331-ac050d8",
|
|
131
|
+
"@matterbridge/types": "3.7.2-dev-20260331-ac050d8",
|
|
132
|
+
"@matterbridge/utils": "3.7.2-dev-20260331-ac050d8",
|
|
133
133
|
"express": "5.2.1",
|
|
134
134
|
"multer": "2.1.1",
|
|
135
135
|
"node-ansi-logger": "3.2.1-dev-20260327-7069fd7",
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { DoorLockServer } from '@matter/node/behaviors/door-lock';
|
|
2
|
-
import { DoorLock } from '@matter/types/clusters/door-lock';
|
|
3
|
-
declare const MatterbridgePinDoorLockServer_base: import("@matter/node").ClusterBehavior.Type<import("@matter/types").ClusterTypeModifier.WithAlterations<import("@matter/types").ClusterComposer.WithFeatures<DoorLock.Cluster, readonly [DoorLock.Feature.PinCredential, DoorLock.Feature.CredentialOverTheAirAccess]>, import("@matter/types").ClusterTypeModifier.ElementFlagAlterations<{
|
|
4
|
-
readonly events: {
|
|
5
|
-
readonly doorLockAlarm: true;
|
|
6
|
-
readonly lockOperation: true;
|
|
7
|
-
readonly lockOperationError: true;
|
|
8
|
-
};
|
|
9
|
-
readonly commands: {
|
|
10
|
-
readonly lockDoor: true;
|
|
11
|
-
readonly unlockDoor: true;
|
|
12
|
-
readonly unlockWithTimeout: true;
|
|
13
|
-
readonly setUserStatus: true;
|
|
14
|
-
readonly getUserStatus: true;
|
|
15
|
-
readonly setUserType: true;
|
|
16
|
-
readonly getUserType: true;
|
|
17
|
-
};
|
|
18
|
-
}>>, import("@matter/node").ClusterBehavior.Type<import("@matter/types").ClusterComposer.WithFeatures<DoorLock.Cluster, readonly [DoorLock.Feature.PinCredential, DoorLock.Feature.CredentialOverTheAirAccess]>, typeof DoorLockServer, import("@matter/node/behaviors/door-lock").DoorLockInterface>, import("@matter/node/behaviors/door-lock").DoorLockInterface>;
|
|
19
|
-
export declare class MatterbridgePinDoorLockServer extends MatterbridgePinDoorLockServer_base {
|
|
20
|
-
lockDoor(request: DoorLock.LockDoorRequest): Promise<void>;
|
|
21
|
-
unlockDoor(request: DoorLock.UnlockDoorRequest): Promise<void>;
|
|
22
|
-
unlockWithTimeout(request: DoorLock.UnlockWithTimeoutRequest): Promise<void>;
|
|
23
|
-
setPinCode(request: DoorLock.SetPinCodeRequest): Promise<void>;
|
|
24
|
-
getPinCode(request: DoorLock.GetPinCodeRequest): Promise<DoorLock.GetPinCodeResponse>;
|
|
25
|
-
clearPinCode(request: DoorLock.ClearPinCodeRequest): Promise<void>;
|
|
26
|
-
clearAllPinCodes(): Promise<void>;
|
|
27
|
-
setUserStatus(request: DoorLock.SetUserStatusRequest): Promise<void>;
|
|
28
|
-
getUserStatus(request: DoorLock.GetUserStatusRequest): Promise<DoorLock.GetUserStatusResponse>;
|
|
29
|
-
setUserType(request: DoorLock.SetUserTypeRequest): Promise<void>;
|
|
30
|
-
getUserType(request: DoorLock.GetUserTypeRequest): Promise<DoorLock.GetUserTypeResponse>;
|
|
31
|
-
}
|
|
32
|
-
export {};
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import { DoorLockServer } from '@matter/node/behaviors/door-lock';
|
|
2
|
-
import { DoorLock } from '@matter/types/clusters/door-lock';
|
|
3
|
-
import { getEnumDescription } from '@matterbridge/utils';
|
|
4
|
-
import { MatterbridgeServer } from './matterbridgeServer.js';
|
|
5
|
-
export class MatterbridgePinDoorLockServer extends DoorLockServer.with(DoorLock.Feature.PinCredential, DoorLock.Feature.CredentialOverTheAirAccess).enable({
|
|
6
|
-
events: { doorLockAlarm: true, lockOperation: true, lockOperationError: true },
|
|
7
|
-
commands: { lockDoor: true, unlockDoor: true, unlockWithTimeout: true, setUserStatus: true, getUserStatus: true, setUserType: true, getUserType: true },
|
|
8
|
-
}) {
|
|
9
|
-
async lockDoor(request) {
|
|
10
|
-
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
11
|
-
device.log.info(`Locking door with pincode ${request.pinCode ? '0x' + Buffer.from(request.pinCode).toString('hex') : 'N/A'} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
12
|
-
await device.commandHandler.executeHandler('DoorLock.lockDoor', {
|
|
13
|
-
command: 'lockDoor',
|
|
14
|
-
request,
|
|
15
|
-
cluster: DoorLockServer.id,
|
|
16
|
-
attributes: this.state,
|
|
17
|
-
endpoint: this.endpoint,
|
|
18
|
-
context: this.context,
|
|
19
|
-
});
|
|
20
|
-
device.log.debug(`MatterbridgeDoorLockServer: lockDoor called`);
|
|
21
|
-
await super.lockDoor(request);
|
|
22
|
-
}
|
|
23
|
-
async unlockDoor(request) {
|
|
24
|
-
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
25
|
-
device.log.info(`Unlocking door with pincode ${request.pinCode ? '0x' + Buffer.from(request.pinCode).toString('hex') : 'N/A'} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
26
|
-
await device.commandHandler.executeHandler('DoorLock.unlockDoor', {
|
|
27
|
-
command: 'unlockDoor',
|
|
28
|
-
request,
|
|
29
|
-
cluster: DoorLockServer.id,
|
|
30
|
-
attributes: this.state,
|
|
31
|
-
endpoint: this.endpoint,
|
|
32
|
-
context: this.context,
|
|
33
|
-
});
|
|
34
|
-
device.log.debug(`MatterbridgeDoorLockServer: unlockDoor called`);
|
|
35
|
-
await super.unlockDoor(request);
|
|
36
|
-
}
|
|
37
|
-
async unlockWithTimeout(request) {
|
|
38
|
-
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
39
|
-
device.log.info(`Unlocking door with pincode ${request.pinCode ? '0x' + Buffer.from(request.pinCode).toString('hex') : 'N/A'} timeout ${request.timeout} seconds (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
40
|
-
await device.commandHandler.executeHandler('DoorLock.unlockWithTimeout', {
|
|
41
|
-
command: 'unlockWithTimeout',
|
|
42
|
-
request,
|
|
43
|
-
cluster: DoorLockServer.id,
|
|
44
|
-
attributes: this.state,
|
|
45
|
-
endpoint: this.endpoint,
|
|
46
|
-
context: this.context,
|
|
47
|
-
});
|
|
48
|
-
device.log.debug(`MatterbridgeDoorLockServer: unlockWithTimeout called`);
|
|
49
|
-
this.state.lockState = DoorLock.LockState.Unlocked;
|
|
50
|
-
}
|
|
51
|
-
async setPinCode(request) {
|
|
52
|
-
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
53
|
-
device.log.info(`Setting pin code ${request.pin ? '0x' + Buffer.from(request.pin).toString('hex') : 'N/A'} for user ${request.userId} type ${getEnumDescription(DoorLock.UserType, request.userType)} status ${getEnumDescription(DoorLock.UserStatus, request.userStatus)} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
54
|
-
await device.commandHandler.executeHandler('DoorLock.setPinCode', {
|
|
55
|
-
command: 'setPinCode',
|
|
56
|
-
request,
|
|
57
|
-
cluster: DoorLockServer.id,
|
|
58
|
-
attributes: this.state,
|
|
59
|
-
endpoint: this.endpoint,
|
|
60
|
-
context: this.context,
|
|
61
|
-
});
|
|
62
|
-
device.log.debug(`MatterbridgeDoorLockServer: setPinCode called for user ${request.userId}`);
|
|
63
|
-
}
|
|
64
|
-
async getPinCode(request) {
|
|
65
|
-
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
66
|
-
device.log.info(`Getting pin code for user ${request.userId} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
67
|
-
await device.commandHandler.executeHandler('DoorLock.getPinCode', {
|
|
68
|
-
command: 'getPinCode',
|
|
69
|
-
request,
|
|
70
|
-
cluster: DoorLockServer.id,
|
|
71
|
-
attributes: this.state,
|
|
72
|
-
endpoint: this.endpoint,
|
|
73
|
-
context: this.context,
|
|
74
|
-
});
|
|
75
|
-
return {
|
|
76
|
-
userId: request.userId,
|
|
77
|
-
userStatus: DoorLock.UserStatus.Available,
|
|
78
|
-
userType: DoorLock.UserType.UnrestrictedUser,
|
|
79
|
-
pinCode: Buffer.from('1234'),
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
async clearPinCode(request) {
|
|
83
|
-
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
84
|
-
device.log.info(`Clearing pin code for ${request.pinSlotIndex === 0xfffe ? 'all slots' : 'slot ' + request.pinSlotIndex} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
85
|
-
await device.commandHandler.executeHandler('DoorLock.clearPinCode', {
|
|
86
|
-
command: 'clearPinCode',
|
|
87
|
-
request,
|
|
88
|
-
cluster: DoorLockServer.id,
|
|
89
|
-
attributes: this.state,
|
|
90
|
-
endpoint: this.endpoint,
|
|
91
|
-
context: this.context,
|
|
92
|
-
});
|
|
93
|
-
device.log.debug(`MatterbridgeDoorLockServer: clearPinCode called for ${request.pinSlotIndex === 0xfffe ? 'all PIN slots' : 'PIN slot ' + request.pinSlotIndex}`);
|
|
94
|
-
}
|
|
95
|
-
async clearAllPinCodes() {
|
|
96
|
-
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
97
|
-
device.log.info(`Clearing all pin codes (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
98
|
-
await device.commandHandler.executeHandler('DoorLock.clearAllPinCodes', {
|
|
99
|
-
command: 'clearAllPinCodes',
|
|
100
|
-
request: {},
|
|
101
|
-
cluster: DoorLockServer.id,
|
|
102
|
-
attributes: this.state,
|
|
103
|
-
endpoint: this.endpoint,
|
|
104
|
-
context: this.context,
|
|
105
|
-
});
|
|
106
|
-
device.log.debug('MatterbridgeDoorLockServer: clearAllPinCodes called');
|
|
107
|
-
}
|
|
108
|
-
async setUserStatus(request) {
|
|
109
|
-
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
110
|
-
device.log.info(`Setting user status for user ${request.userId} to ${getEnumDescription(DoorLock.UserStatus, request.userStatus)} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
111
|
-
await device.commandHandler.executeHandler('DoorLock.setUserStatus', {
|
|
112
|
-
command: 'setUserStatus',
|
|
113
|
-
request,
|
|
114
|
-
cluster: DoorLockServer.id,
|
|
115
|
-
attributes: this.state,
|
|
116
|
-
endpoint: this.endpoint,
|
|
117
|
-
context: this.context,
|
|
118
|
-
});
|
|
119
|
-
device.log.debug(`MatterbridgeDoorLockServer: setUserStatus called for user ${request.userId}`);
|
|
120
|
-
}
|
|
121
|
-
async getUserStatus(request) {
|
|
122
|
-
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
123
|
-
device.log.info(`Getting user status for user ${request.userId} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
124
|
-
await device.commandHandler.executeHandler('DoorLock.getUserStatus', {
|
|
125
|
-
command: 'getUserStatus',
|
|
126
|
-
request,
|
|
127
|
-
cluster: DoorLockServer.id,
|
|
128
|
-
attributes: this.state,
|
|
129
|
-
endpoint: this.endpoint,
|
|
130
|
-
context: this.context,
|
|
131
|
-
});
|
|
132
|
-
device.log.debug(`MatterbridgeDoorLockServer: getUserStatus called for user ${request.userId}`);
|
|
133
|
-
return {
|
|
134
|
-
userId: request.userId,
|
|
135
|
-
userStatus: DoorLock.UserStatus.Available,
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
async setUserType(request) {
|
|
139
|
-
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
140
|
-
device.log.info(`Setting user type for user ${request.userId} to ${getEnumDescription(DoorLock.UserType, request.userType)} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
141
|
-
await device.commandHandler.executeHandler('DoorLock.setUserType', {
|
|
142
|
-
command: 'setUserType',
|
|
143
|
-
request,
|
|
144
|
-
cluster: DoorLockServer.id,
|
|
145
|
-
attributes: this.state,
|
|
146
|
-
endpoint: this.endpoint,
|
|
147
|
-
context: this.context,
|
|
148
|
-
});
|
|
149
|
-
device.log.debug(`MatterbridgeDoorLockServer: setUserType called for user ${request.userId}`);
|
|
150
|
-
}
|
|
151
|
-
async getUserType(request) {
|
|
152
|
-
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
153
|
-
device.log.info(`Getting user type for user ${request.userId} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
154
|
-
await device.commandHandler.executeHandler('DoorLock.getUserType', {
|
|
155
|
-
command: 'getUserType',
|
|
156
|
-
request,
|
|
157
|
-
cluster: DoorLockServer.id,
|
|
158
|
-
attributes: this.state,
|
|
159
|
-
endpoint: this.endpoint,
|
|
160
|
-
context: this.context,
|
|
161
|
-
});
|
|
162
|
-
device.log.debug(`MatterbridgeDoorLockServer: getUserType called for user ${request.userId}`);
|
|
163
|
-
return {
|
|
164
|
-
userId: request.userId,
|
|
165
|
-
userType: DoorLock.UserType.UnrestrictedUser,
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { DoorLockServer } from '@matter/node/behaviors/door-lock';
|
|
2
|
-
import { DoorLock } from '@matter/types/clusters/door-lock';
|
|
3
|
-
import { FabricIndex } from '@matter/types/datatype';
|
|
4
|
-
declare const MatterbridgeUserPinDoorLockServer_base: import("@matter/node").ClusterBehavior.Type<import("@matter/types").ClusterTypeModifier.WithAlterations<import("@matter/types").ClusterComposer.WithFeatures<DoorLock.Cluster, readonly [DoorLock.Feature.User, DoorLock.Feature.PinCredential, DoorLock.Feature.CredentialOverTheAirAccess]>, import("@matter/types").ClusterTypeModifier.ElementFlagAlterations<{
|
|
5
|
-
readonly events: {
|
|
6
|
-
readonly doorLockAlarm: true;
|
|
7
|
-
readonly lockOperation: true;
|
|
8
|
-
readonly lockOperationError: true;
|
|
9
|
-
};
|
|
10
|
-
readonly commands: {
|
|
11
|
-
readonly lockDoor: true;
|
|
12
|
-
readonly unlockDoor: true;
|
|
13
|
-
readonly unlockWithTimeout: true;
|
|
14
|
-
};
|
|
15
|
-
}>>, import("@matter/node").ClusterBehavior.Type<import("@matter/types").ClusterComposer.WithFeatures<DoorLock.Cluster, readonly [DoorLock.Feature.User, DoorLock.Feature.PinCredential, DoorLock.Feature.CredentialOverTheAirAccess]>, typeof DoorLockServer, import("@matter/node/behaviors/door-lock").DoorLockInterface>, import("@matter/node/behaviors/door-lock").DoorLockInterface>;
|
|
16
|
-
export declare class MatterbridgeUserPinDoorLockServer extends MatterbridgeUserPinDoorLockServer_base {
|
|
17
|
-
protected internal: MatterbridgeUserPinDoorLockServer.Internal;
|
|
18
|
-
private getAccessingFabricIndex;
|
|
19
|
-
private findStoredCredential;
|
|
20
|
-
private getStoredCredentialStateDebug;
|
|
21
|
-
private logStoredCredentialState;
|
|
22
|
-
private hasMatchingPinCredential;
|
|
23
|
-
private validateRemotePinCode;
|
|
24
|
-
private getNextOccupiedCredentialIndex;
|
|
25
|
-
private upsertStoredCredential;
|
|
26
|
-
private clearStoredCredential;
|
|
27
|
-
lockDoor(request: DoorLock.LockDoorRequest): Promise<void>;
|
|
28
|
-
unlockDoor(request: DoorLock.UnlockDoorRequest): Promise<void>;
|
|
29
|
-
unlockWithTimeout(request: DoorLock.UnlockWithTimeoutRequest): Promise<void>;
|
|
30
|
-
setUser(request: DoorLock.SetUserRequest): Promise<void>;
|
|
31
|
-
getUser(request: DoorLock.GetUserRequest): Promise<DoorLock.GetUserResponse>;
|
|
32
|
-
clearUser(request: DoorLock.ClearUserRequest): Promise<void>;
|
|
33
|
-
setCredential(request: DoorLock.SetCredentialRequest): Promise<DoorLock.SetCredentialResponse>;
|
|
34
|
-
getCredentialStatus(request: DoorLock.GetCredentialStatusRequest): Promise<DoorLock.GetCredentialStatusResponse>;
|
|
35
|
-
clearCredential(request: DoorLock.ClearCredentialRequest): Promise<void>;
|
|
36
|
-
}
|
|
37
|
-
export declare namespace MatterbridgeUserPinDoorLockServer {
|
|
38
|
-
type StoredCredential = DoorLock.Credential & {
|
|
39
|
-
credentialData: Uint8Array;
|
|
40
|
-
};
|
|
41
|
-
type StoredUser = {
|
|
42
|
-
userIndex: number;
|
|
43
|
-
userName: string | null;
|
|
44
|
-
userUniqueId: number | null;
|
|
45
|
-
userStatus: DoorLock.UserStatus | null;
|
|
46
|
-
userType: DoorLock.UserType | null;
|
|
47
|
-
credentialRule: DoorLock.CredentialRule | null;
|
|
48
|
-
credentials: StoredCredential[] | null;
|
|
49
|
-
creatorFabricIndex: FabricIndex | null;
|
|
50
|
-
lastModifiedFabricIndex: FabricIndex | null;
|
|
51
|
-
nextUserIndex: number | null;
|
|
52
|
-
};
|
|
53
|
-
class Internal {
|
|
54
|
-
users: StoredUser[];
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
export {};
|