matterbridge 1.1.2 → 1.1.3

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.
@@ -0,0 +1,309 @@
1
+ export {};
2
+ /* eslint-disable max-len */
3
+ /*
4
+ async function startMatterController() {
5
+ log.info('Creating mattercontrollerContext: mattercontrollerContext');
6
+ mattercontrollerContext = storageManager.createContext('mattercontrollerContext');
7
+
8
+ await createMatterServer(storageManager);
9
+
10
+ log.info('Creating matter commissioning controller');
11
+ commissioningController = new CommissioningController({
12
+ autoConnect: false,
13
+ });
14
+ await matterServer.addCommissioningController(commissioningController);
15
+
16
+ log.info('Starting matter server');
17
+ await matterServer.start();
18
+ log.info('Started matter server');
19
+
20
+ AllClustersMap[EveHistoryCluster.id] = EveHistoryCluster;
21
+ log.info('Added custom cluster:', getClusterNameById(EveHistoryCluster.id));
22
+
23
+ if (hasParameter('ble')) {
24
+ //
25
+ }
26
+
27
+ if (hasParameter('pairingcode')) {
28
+ const pairingCode = getParameter('pairingcode');
29
+ const ip = mattercontrollerContext.has('ip') ? mattercontrollerContext.get<string>('ip') : undefined;
30
+ const port = mattercontrollerContext.has('port') ? mattercontrollerContext.get<number>('port') : undefined;
31
+
32
+ let longDiscriminator, setupPin, shortDiscriminator;
33
+ if (pairingCode !== undefined) {
34
+ const pairingCodeCodec = ManualPairingCodeCodec.decode(pairingCode);
35
+ shortDiscriminator = pairingCodeCodec.shortDiscriminator;
36
+ longDiscriminator = undefined;
37
+ setupPin = pairingCodeCodec.passcode;
38
+ logger.debug(`Data extracted from pairing code: ${Logger.toJSON(pairingCodeCodec)}`);
39
+ } else {
40
+ longDiscriminator = mattercontrollerContext.get('longDiscriminator', 3840);
41
+ if (longDiscriminator > 4095) throw new Error('Discriminator value must be less than 4096');
42
+ setupPin = mattercontrollerContext.get('pin', 20202021);
43
+ }
44
+ if ((shortDiscriminator === undefined && longDiscriminator === undefined) || setupPin === undefined) {
45
+ throw new Error('Please specify the longDiscriminator of the device to commission with -longDiscriminator or provide a valid passcode with -passcode');
46
+ }
47
+
48
+ const commissioningOptions: CommissioningOptions = {
49
+ regulatoryLocation: GeneralCommissioning.RegulatoryLocationType.IndoorOutdoor,
50
+ regulatoryCountryCode: 'XX',
51
+ };
52
+ const options = {
53
+ commissioning: commissioningOptions,
54
+ discovery: {
55
+ knownAddress: ip !== undefined && port !== undefined ? { ip, port, type: 'udp' } : undefined,
56
+ identifierData: longDiscriminator !== undefined ? { longDiscriminator } : shortDiscriminator !== undefined ? { shortDiscriminator } : {},
57
+ },
58
+ passcode: setupPin,
59
+ } as NodeCommissioningOptions;
60
+ log.info(`Commissioning ... ${JSON.stringify(options)}`);
61
+ const nodeId = await commissioningController.commissionNode(options);
62
+ mattercontrollerContext.set('nodeId', nodeId.nodeId);
63
+ log.info(`Commissioning successfully done with nodeId: ${nodeId.nodeId}`);
64
+ console.log('ActiveSessionInformation:', commissioningController.getActiveSessionInformation());
65
+ } // (hasParameter('pairingcode'))
66
+
67
+ if (hasParameter('discover')) {
68
+ Logger.defaultLogLevel = Level.DEBUG;
69
+ const discover = await commissioningController.discoverCommissionableDevices({});
70
+ console.log(discover);
71
+ Logger.defaultLogLevel = Level.INFO;
72
+ }
73
+
74
+ log.info(`Commissioning controller is already commisioned: ${commissioningController.isCommissioned()}`);
75
+ const nodes = commissioningController.getCommissionedNodes();
76
+ nodes.forEach(async (nodeId) => {
77
+ log.warn(`Connecting to commissioned node: ${nodeId}`);
78
+ const node = await commissioningController.connectNode(nodeId, {
79
+ attributeChangedCallback: (peerNodeId, { path: { nodeId, clusterId, endpointId, attributeName }, value }) =>
80
+ console.log(`\x1b[37;44mattributeChangedCallback ${peerNodeId}: Attribute ${nodeId}/${endpointId}/${clusterId}/${attributeName} changed to ${Logger.toJSON(value)}\x1b[40;0m`),
81
+ eventTriggeredCallback: (peerNodeId, { path: { nodeId, clusterId, endpointId, eventName }, events }) =>
82
+ console.log(`\x1b[37;44meventTriggeredCallback ${peerNodeId}: Event ${nodeId}/${endpointId}/${clusterId}/${eventName} triggered with ${Logger.toJSON(events)}\x1b[40;0m`),
83
+ stateInformationCallback: (peerNodeId, info) => {
84
+ switch (info) {
85
+ case NodeStateInformation.Connected:
86
+ console.log(`\x1b[37;44mstateInformationCallback ${peerNodeId}: Node ${nodeId} connected\x1b[40;0m`);
87
+ break;
88
+ case NodeStateInformation.Disconnected:
89
+ console.log(`\x1b[37;44mstateInformationCallback ${peerNodeId}: Node ${nodeId} disconnected\x1b[40;0m`);
90
+ break;
91
+ case NodeStateInformation.Reconnecting:
92
+ console.log(`\x1b[37;44mstateInformationCallback ${peerNodeId}: Node ${nodeId} reconnecting\x1b[40;0m`);
93
+ break;
94
+ case NodeStateInformation.WaitingForDeviceDiscovery:
95
+ console.log(`\x1b[37;44mstateInformationCallback ${peerNodeId}: Node ${nodeId} waiting for device discovery\x1b[40;0m`);
96
+ break;
97
+ case NodeStateInformation.StructureChanged:
98
+ console.log(`\x1b[37;44mstateInformationCallback ${peerNodeId}: Node ${nodeId} structure changed\x1b[40;0m`);
99
+ break;
100
+ case NodeStateInformation.Decommissioned:
101
+ console.log(`\x1b[37;44mstateInformationCallback ${peerNodeId}: Node ${nodeId} decommissioned\x1b[40;0m`);
102
+ break;
103
+ default:
104
+ console.log(`\x1b[37;44mstateInformationCallback ${peerNodeId}: Node ${nodeId} NodeStateInformation.${info}\x1b[40;0m`);
105
+ break;
106
+ }
107
+ },
108
+ });
109
+
110
+ const info = node.getRootClusterClient(BasicInformationCluster);
111
+ let name = '';
112
+ if (info !== undefined) {
113
+ log.info(`Node ${nodeId} VendorName ${await info.getVendorNameAttribute()}`); // This call is executed remotely
114
+ log.info(`Node ${nodeId} ProductName ${(name = await info.getProductNameAttribute())}`); // This call is executed remotely
115
+ log.info(`Node ${nodeId} NodeLabel ${await info.getNodeLabelAttribute()}`); // This call is executed remotely
116
+ log.info(`Node ${nodeId} ProductLabel ${await info.getProductLabelAttribute()}`); // This call is executed remotely
117
+ log.info(`Node ${nodeId} SerialNumber ${await info.getSerialNumberAttribute()}`); // This call is executed remotely
118
+ log.info(`Node ${nodeId} UniqueId ${await info.getUniqueIdAttribute()}`); // This call is executed remotely
119
+ } else {
120
+ log.error('No BasicInformation Cluster found. This should never happen!');
121
+ }
122
+
123
+ log.warn(`Logging commissioned node: ${nodeId} name: ${name}`);
124
+ //node.logStructure();
125
+
126
+ const mattercontrollerNodeContext = storageManager.createContext(name);
127
+ const interactionClient = await node.getInteractionClient();
128
+
129
+ // Log BasicInformationCluster
130
+ const attributesInfoCluster = await interactionClient.getMultipleAttributes({
131
+ attributes: [{ clusterId: BasicInformationCluster.id }],
132
+ });
133
+ attributesInfoCluster.forEach((attribute) => {
134
+ log.info(
135
+ `${name}:BasicInformationCluster ${attribute.path.nodeId}-${attribute.path.endpointId}-${attribute.path.clusterId} id: ${attribute.path.attributeId} name: ${attribute.path.attributeName}: ${typeof attribute.value === 'object' ? stringify(attribute.value) : attribute.value}`,
136
+ );
137
+ });
138
+
139
+ // Log PowerSourceConfigurationCluster
140
+ const attributesPowerConfigCluster = await interactionClient.getMultipleAttributes({
141
+ attributes: [{ clusterId: PowerSourceConfigurationCluster.id }],
142
+ });
143
+ attributesPowerConfigCluster.forEach((attribute) => {
144
+ log.info(
145
+ `${name}:PowerSourceConfigurationCluster ${attribute.path.nodeId}-${attribute.path.endpointId}-${attribute.path.clusterId} id: ${attribute.path.attributeId} name: ${attribute.path.attributeName}: ${typeof attribute.value === 'object' ? stringify(attribute.value) : attribute.value}`,
146
+ );
147
+ });
148
+
149
+ // Log PowerSourceCluster
150
+ const attributesPowerCluster = await interactionClient.getMultipleAttributes({
151
+ attributes: [{ clusterId: PowerSourceCluster.id }],
152
+ });
153
+ attributesPowerCluster.forEach((attribute) => {
154
+ log.info(
155
+ `${name}:PowerSourceCluster ${attribute.path.nodeId}-${attribute.path.endpointId}-${attribute.path.clusterId} id: ${attribute.path.attributeId} name: ${attribute.path.attributeName}: ${typeof attribute.value === 'object' ? stringify(attribute.value) : attribute.value}`,
156
+ );
157
+ });
158
+
159
+ // Log ThreadNetworkDiagnostics
160
+ const attributesThreadCluster = await interactionClient.getMultipleAttributes({
161
+ attributes: [{ clusterId: ThreadNetworkDiagnosticsCluster.id }]
162
+ });
163
+ attributesThreadCluster.forEach(attribute => {
164
+ log.info(`${name}:ThreadNetworkDiagnosticsCluster ${attribute.path.nodeId}-${attribute.path.endpointId}-${attribute.path.clusterId} id: ${attribute.path.attributeId} name: ${attribute.path.attributeName}: ${typeof attribute.value === 'object' ? stringify(attribute.value) : attribute.value}`);
165
+ });
166
+
167
+ const devices = node.getDevices();
168
+ devices.forEach(async (device) => {
169
+ log.info(`Device id: ${device.id} name: ${device.name}`);
170
+ //logEndpoint(device);
171
+
172
+ const eveHistory = device.getClusterClient(EveHistoryCluster);
173
+ if (eveHistory !== undefined) {
174
+ log.info(`EveHistory found on id: ${device.id} name: ${device.name}`);
175
+
176
+ // Log EveHistoryCluster
177
+ const attributesEveHistoryCluster = await interactionClient.getMultipleAttributes({
178
+ attributes: [{ clusterId: EveHistoryCluster.id }],
179
+ });
180
+ attributesEveHistoryCluster.forEach((attribute) => {
181
+ log.info(
182
+ `${name}:EveHistoryCluster ${attribute.path.nodeId}-${attribute.path.endpointId}-${attribute.path.clusterId} id: ${attribute.path.attributeId} name: ${attribute.path.attributeName}: ${typeof attribute.value === 'object' ? stringify(attribute.value) : attribute.value}`,
183
+ );
184
+ });
185
+
186
+ const history = new MatterHistory(log, name, { fileName: name + '_history.json' });
187
+ let logMessage = '';
188
+
189
+ // Get and decode HistoryStatus
190
+ const historyStatus: Uint8Array = await eveHistory.getHistoryStatusAttribute();
191
+ log.info((logMessage = history.decodeHistoryStatus(Buffer.from(historyStatus))));
192
+ fs.appendFileSync(name + '.log', logMessage + '\n');
193
+
194
+ // Set HistorySetTime
195
+ const bufferSetTime = history.encodeHistorySetTime();
196
+ log.info((logMessage = history.decodeHistorySetTime(bufferSetTime)));
197
+ fs.appendFileSync(name + '.log', logMessage + '\n');
198
+ await eveHistory.setHistorySetTimeAttribute(bufferSetTime);
199
+
200
+ // Set HistoryRequest
201
+ const entryNumber = mattercontrollerNodeContext.get('nextEntry', history.getFirstEntry());
202
+ const bufferRequest = history.encodeHistoryRequest(history.clamp(entryNumber, history.getFirstEntry(), history.getLastEntry()));
203
+ log.info((logMessage = history.decodeHistoryRequest(bufferRequest)));
204
+ fs.appendFileSync(name + '.log', logMessage + '\n');
205
+ await eveHistory.setHistoryRequestAttribute(bufferRequest);
206
+
207
+ // Get HistoryEntries
208
+ let historyEntries: Uint8Array = await eveHistory.getHistoryEntriesAttribute();
209
+ let bufferHistoryEntries = Buffer.from(historyEntries);
210
+ //console.log(history.historyEntriesToString(bufferHistoryEntries));
211
+ while (bufferHistoryEntries.length > 0) {
212
+ for (let i = 0; i < bufferHistoryEntries.length; ) {
213
+ const bufferHistoryEntry = Buffer.copyBytesFrom(bufferHistoryEntries, i, bufferHistoryEntries.readUInt8(i));
214
+ i += bufferHistoryEntries.readUInt8(i);
215
+ history.decodeHistoryEntry(bufferHistoryEntry);
216
+ log.info((logMessage = history.historyEntryToString(bufferHistoryEntry)));
217
+ fs.appendFileSync(name + '.log', logMessage + '\n');
218
+ mattercontrollerNodeContext.set('nextEntry', bufferHistoryEntry.readUInt32LE(1) + 1);
219
+ }
220
+ historyEntries = await eveHistory.getHistoryEntriesAttribute();
221
+ bufferHistoryEntries = Buffer.from(historyEntries);
222
+ //console.log(history.historyEntriesToString(bufferHistoryEntries));
223
+ }
224
+ history.writeHistoryFile();
225
+ //history.logHistory(true);
226
+
227
+ eveHistory.subscribeHistoryStatusAttribute(
228
+ (value: Uint8Array) => { log.warn('Received EveHistoryStatus:', value.toHex()) }, 0, 30)
229
+ .then(() => { log.warn('Subscription successful to EveHistoryStatus.') })
230
+ .catch((error) => { log.error('Error during subscription to EveHistoryStatus:', error) });
231
+
232
+ eveHistory.subscribeHistoryEntriesAttribute(
233
+ (value: Uint8Array) => { log.warn('Received EveHistoryEntries:', value.toHex()) }, 0, 30)
234
+ .then(() => { log.warn('Subscription successful to EveHistoryEntries.') })
235
+ .catch((error) => { log.error('Error during subscription to EveHistoryEntries:', error) });
236
+
237
+ setInterval(async () => {
238
+ try {
239
+ const attributesEveCluster = await interactionClient.getMultipleAttributes({
240
+ attributes: [{ clusterId: EveHistoryCluster.id }],
241
+ });
242
+ log.info('\x1b[97;45mEve device: ' + name + '\x1b[40;0m');
243
+
244
+ attributesEveCluster.forEach((attribute) => {
245
+ if (attribute.path.attributeId === EveHistoryCluster.attributes.ConfigDataGet.id) {
246
+ const data = Buffer.from(attribute.value);
247
+ logMessage = `ConfigDataGet(${data.length}): [${data.toHex()}]`;
248
+ log.info(logMessage);
249
+ log.info('*' + history.decodeConfigData(data));
250
+ fs.appendFileSync(name + '.config.log', logMessage + '\n');
251
+ } else if (attribute.path.attributeId === EveHistoryCluster.attributes.HistoryStatus.id) {
252
+ logMessage = history.decodeHistoryStatus(Buffer.from(attribute.value));
253
+ log.info(logMessage);
254
+ fs.appendFileSync(name + '.log', logMessage + '\n');
255
+ } else if (attribute.path.attributeId === EveHistoryCluster.attributes.HistoryEntries.id) {
256
+ const bufferHistoryEntries = Buffer.from(attribute.value);
257
+ for (let i = 0; i < bufferHistoryEntries.length; ) {
258
+ const bufferHistoryEntry = Buffer.copyBytesFrom(bufferHistoryEntries, i, bufferHistoryEntries.readUInt8(i));
259
+ i += bufferHistoryEntries.readUInt8(i);
260
+ history.decodeHistoryEntry(bufferHistoryEntry);
261
+ log.info((logMessage = history.historyEntryToString(bufferHistoryEntry)));
262
+ fs.appendFileSync(name + '.log', logMessage + '\n');
263
+ }
264
+ history.writeHistoryFile();
265
+ } else if (attribute.path.attributeId === EveHistoryCluster.attributes.TimesOpened.id) {
266
+ log.info(`TimesOpened: ${attribute.value}`);
267
+ } else if (attribute.path.attributeId === EveHistoryCluster.attributes.LastEvent.id) {
268
+ log.info(`LastEvent: ${attribute.value}=${history.secsToDateString(attribute.value + history.getInitialTime() - history.getTimeOffset())}`);
269
+ } else if (attribute.path.attributeId === EveHistoryCluster.attributes.ResetTotal.id) {
270
+ log.info(`ResetTotal: ${attribute.value}=${history.secsToDateStringSinceEveEpoch(attribute.value)}`);
271
+ } else if (attribute.path.attributeId === EveHistoryCluster.attributes.Voltage.id) {
272
+ log.info(`Voltage: ${attribute.value}`);
273
+ } else if (attribute.path.attributeId === EveHistoryCluster.attributes.Current.id) {
274
+ log.info(`Current: ${attribute.value}`);
275
+ } else if (attribute.path.attributeId === EveHistoryCluster.attributes.Consumption.id) {
276
+ log.info(`Consumption: ${attribute.value}`);
277
+ } else if (attribute.path.attributeId === EveHistoryCluster.attributes.TotalConsumption.id) {
278
+ log.info(`TotalConsumption: ${attribute.value}`);
279
+ } else if (attribute.path.attributeId === EveHistoryCluster.attributes.ChildLock.id) {
280
+ log.info(`ChildLock: ${attribute.value}`);
281
+ } else if (attribute.path.attributeId === EveHistoryCluster.attributes.MotionSensitivity.id) {
282
+ log.info(`MotionSensitivity: ${attribute.value}`);
283
+ } else if (attribute.path.attributeId === EveHistoryCluster.attributes.RLoc.id) {
284
+ log.info((logMessage = `RLoc: 0x${attribute.value.toString(16)}`));
285
+ } else {
286
+ if (attribute.path.attributeId >= 0x130a0000) {
287
+ log.info(`Unknown attribute ${attribute.path.attributeName} type: ${typeof attribute.value} value: [${attribute.value.toString(16)}]${attribute.value}`);
288
+ }
289
+ }
290
+ });
291
+ } catch (error) {
292
+ console.error(error);
293
+ }
294
+ }, 30000);
295
+ } else {
296
+ log.info(`EveHistory not found on ${device.id} name: ${device.name}`);
297
+ }
298
+ }); // devices.forEach(async device => {
299
+ }); // nodes.forEach(async nodeId => {
300
+
301
+ if (hasParameter('unpairall')) {
302
+ nodes.forEach(async (nodeId) => {
303
+ await commissioningController.removeNode(nodeId);
304
+ });
305
+ process.exit(0);
306
+ }
307
+ }
308
+ */
309
+ //# sourceMappingURL=matterbridgeController.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matterbridgeController.js","sourceRoot":"","sources":["../src/matterbridgeController.ts"],"names":[],"mappings":";AAAA,4BAA4B;AAC5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiTE"}
@@ -40,16 +40,31 @@ export declare class MatterbridgeDynamicPlatform {
40
40
  constructor(matterbridge: Matterbridge, log: AnsiLogger);
41
41
  /**
42
42
  * This method must be overridden in the extended class.
43
+ * It is called when the platform is started.
44
+ * Use this method to create all the MatterbridgeDevice and call this.registerDevice() for each device.
43
45
  * @param {string} [reason] - The reason for starting.
44
46
  * @throws {Error} - Throws an error if not overridden.
45
47
  */
46
48
  onStart(reason?: string): Promise<void>;
47
49
  /**
48
50
  * This method must be overridden in the extended class.
51
+ * It is called when the platform is shutting down.
52
+ * Use this method to clean up any resources.
49
53
  * @param {string} [reason] - The reason for shutting down.
50
54
  * @throws {Error} - Throws an error if not overridden.
51
55
  */
52
56
  onShutdown(reason?: string): Promise<void>;
57
+ /**
58
+ * This method can be overridden in the extended class.
59
+ * It is called after matter server started.
60
+ */
61
+ onMatterStarted(): Promise<void>;
62
+ /**
63
+ * This method can be overridden in the extended class.
64
+ * It is called after the platform has been commissioned.
65
+ * Use this method to perform any configuration of your devices.
66
+ */
67
+ onConfigure(): Promise<void>;
53
68
  /**
54
69
  * Registers a device with the Matterbridge platform.
55
70
  * @param {MatterbridgeDevice} device - The device to register.
@@ -1 +1 @@
1
- {"version":3,"file":"matterbridgeDynamicPlatform.d.ts","sourceRoot":"","sources":["../src/matterbridgeDynamicPlatform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C;;;GAGG;AACH,qBAAa,2BAA2B;IACtC,SAAS,CAAC,YAAY,EAAE,YAAY,CAAC;IACrC,SAAS,CAAC,GAAG,EAAE,UAAU,CAAC;IAC1B,OAAO,CAAC,IAAI,CAAM;IAClB,OAAO,CAAC,IAAI,CAAqB;IAEjC;;;;OAIG;gBACS,YAAY,EAAE,YAAY,EAAE,GAAG,EAAE,UAAU;IAOvD;;;;OAIG;IACG,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM;IAK7B;;;;OAIG;IACG,UAAU,CAAC,MAAM,CAAC,EAAE,MAAM;IAKhC;;;OAGG;IACG,cAAc,CAAC,MAAM,EAAE,kBAAkB;CAGhD"}
1
+ {"version":3,"file":"matterbridgeDynamicPlatform.d.ts","sourceRoot":"","sources":["../src/matterbridgeDynamicPlatform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C;;;GAGG;AACH,qBAAa,2BAA2B;IACtC,SAAS,CAAC,YAAY,EAAE,YAAY,CAAC;IACrC,SAAS,CAAC,GAAG,EAAE,UAAU,CAAC;IAC1B,OAAO,CAAC,IAAI,CAAM;IAClB,OAAO,CAAC,IAAI,CAAqB;IAEjC;;;;OAIG;gBACS,YAAY,EAAE,YAAY,EAAE,GAAG,EAAE,UAAU;IAOvD;;;;;;OAMG;IACG,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM;IAK7B;;;;;;OAMG;IACG,UAAU,CAAC,MAAM,CAAC,EAAE,MAAM;IAKhC;;;OAGG;IACG,eAAe;IAIrB;;;;OAIG;IACG,WAAW;IAIjB;;;OAGG;IACG,cAAc,CAAC,MAAM,EAAE,kBAAkB;CAGhD"}
@@ -41,6 +41,8 @@ export class MatterbridgeDynamicPlatform {
41
41
  }
42
42
  /**
43
43
  * This method must be overridden in the extended class.
44
+ * It is called when the platform is started.
45
+ * Use this method to create all the MatterbridgeDevice and call this.registerDevice() for each device.
44
46
  * @param {string} [reason] - The reason for starting.
45
47
  * @throws {Error} - Throws an error if not overridden.
46
48
  */
@@ -50,6 +52,8 @@ export class MatterbridgeDynamicPlatform {
50
52
  }
51
53
  /**
52
54
  * This method must be overridden in the extended class.
55
+ * It is called when the platform is shutting down.
56
+ * Use this method to clean up any resources.
53
57
  * @param {string} [reason] - The reason for shutting down.
54
58
  * @throws {Error} - Throws an error if not overridden.
55
59
  */
@@ -57,6 +61,21 @@ export class MatterbridgeDynamicPlatform {
57
61
  this.log.error('Plugins must override onShutdown.', reason);
58
62
  throw new Error('Plugins must override onShutdown.');
59
63
  }
64
+ /**
65
+ * This method can be overridden in the extended class.
66
+ * It is called after matter server started.
67
+ */
68
+ async onMatterStarted() {
69
+ this.log.debug("The plugin doesn't override onMatterStarted.");
70
+ }
71
+ /**
72
+ * This method can be overridden in the extended class.
73
+ * It is called after the platform has been commissioned.
74
+ * Use this method to perform any configuration of your devices.
75
+ */
76
+ async onConfigure() {
77
+ this.log.debug("The plugin doesn't override onConfigure.");
78
+ }
60
79
  /**
61
80
  * Registers a device with the Matterbridge platform.
62
81
  * @param {MatterbridgeDevice} device - The device to register.
@@ -1 +1 @@
1
- {"version":3,"file":"matterbridgeDynamicPlatform.js","sourceRoot":"","sources":["../src/matterbridgeDynamicPlatform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAMH;;;GAGG;AACH,MAAM,OAAO,2BAA2B;IAC5B,YAAY,CAAe;IAC3B,GAAG,CAAa;IAClB,IAAI,GAAG,EAAE,CAAC,CAAC,uEAAuE;IAClF,IAAI,GAAG,iBAAiB,CAAC;IAEjC;;;;OAIG;IACH,YAAY,YAA0B,EAAE,GAAe;QACrD,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QAEf,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,eAAe,IAAI,CAAC,IAAI,SAAS,CAAC,CAAC;IACpD,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,OAAO,CAAC,MAAe;QAC3B,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,gCAAgC,EAAE,MAAM,CAAC,CAAC;QACzD,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACpD,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,UAAU,CAAC,MAAe;QAC9B,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,mCAAmC,EAAE,MAAM,CAAC,CAAC;QAC5D,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;IACvD,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,cAAc,CAAC,MAA0B;QAC7C,MAAM,IAAI,CAAC,YAAY,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC9D,CAAC;CACF"}
1
+ {"version":3,"file":"matterbridgeDynamicPlatform.js","sourceRoot":"","sources":["../src/matterbridgeDynamicPlatform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAMH;;;GAGG;AACH,MAAM,OAAO,2BAA2B;IAC5B,YAAY,CAAe;IAC3B,GAAG,CAAa;IAClB,IAAI,GAAG,EAAE,CAAC,CAAC,uEAAuE;IAClF,IAAI,GAAG,iBAAiB,CAAC;IAEjC;;;;OAIG;IACH,YAAY,YAA0B,EAAE,GAAe;QACrD,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QAEf,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,eAAe,IAAI,CAAC,IAAI,SAAS,CAAC,CAAC;IACpD,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,OAAO,CAAC,MAAe;QAC3B,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,gCAAgC,EAAE,MAAM,CAAC,CAAC;QACzD,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACpD,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,UAAU,CAAC,MAAe;QAC9B,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,mCAAmC,EAAE,MAAM,CAAC,CAAC;QAC5D,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;IACvD,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,eAAe;QACnB,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,8CAA8C,CAAC,CAAC;IACjE,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,WAAW;QACf,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC7D,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,cAAc,CAAC,MAA0B;QAC7C,MAAM,IAAI,CAAC,YAAY,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC9D,CAAC;CACF"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":""}
package/dist/utils.js ADDED
@@ -0,0 +1,33 @@
1
+ export {};
2
+ // Http server use with:
3
+ /*
4
+ Invoke-WebRequest -Uri "http://localhost:3030/LogAggregator"
5
+ Invoke-WebRequest -Uri "http://localhost:3030/RegisterAll"
6
+ Invoke-WebRequest -Uri "http://localhost:3030/UnregisterAll"
7
+ Invoke-WebRequest -Uri "http://localhost:3030/LogRootEndpoint"
8
+
9
+ const server = http.createServer((req, res) => {
10
+ if (req.url === '/UnregisterAll') {
11
+ logger.warn('UnregisterAll signal received.');
12
+ matterAggregator.removeBridgedDevice(matterDevice1!);
13
+ matterAggregator.removeBridgedDevice(matterDevice2!);
14
+ matterAggregator.removeBridgedDevice(matterDevice3!);
15
+ } else if (req.url === '/RegisterAll') {
16
+ logger.warn('RegisterAll signal received.');
17
+ matterAggregator.addChildEndpoint(matterDevice1!);
18
+ matterAggregator.addChildEndpoint(matterDevice2!);
19
+ matterAggregator.addChildEndpoint(matterDevice3!);
20
+ } else if (req.url === '/LogRootEndpoint') {
21
+ logger.warn('LogRootEndpoint signal received.');
22
+ logEndpoint(commissioningServer.getRootEndpoint());
23
+ } else if (req.url === '/LogAggregator') {
24
+ logger.warn('LogAggregator signal received.');
25
+ logEndpoint(matterAggregator);
26
+ }
27
+ res.end('Signal processed');
28
+ });
29
+
30
+ server.listen(3030);
31
+
32
+ */
33
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";AAAA,wBAAwB;AACxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6BE"}
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "files": {
3
3
  "main.css": "/static/css/main.6d93e0db.css",
4
- "main.js": "/static/js/main.21c55a60.js",
4
+ "main.js": "/static/js/main.b5a876cf.js",
5
5
  "static/js/453.8ab44547.chunk.js": "/static/js/453.8ab44547.chunk.js",
6
6
  "index.html": "/index.html",
7
7
  "main.6d93e0db.css.map": "/static/css/main.6d93e0db.css.map",
8
- "main.21c55a60.js.map": "/static/js/main.21c55a60.js.map",
8
+ "main.b5a876cf.js.map": "/static/js/main.b5a876cf.js.map",
9
9
  "453.8ab44547.chunk.js.map": "/static/js/453.8ab44547.chunk.js.map"
10
10
  },
11
11
  "entrypoints": [
12
12
  "static/css/main.6d93e0db.css",
13
- "static/js/main.21c55a60.js"
13
+ "static/js/main.b5a876cf.js"
14
14
  ]
15
15
  }
@@ -1 +1 @@
1
- <!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><title>Matterbridge</title><link rel="manifest" href="/manifest.json"/><script defer="defer" src="/static/js/main.21c55a60.js"></script><link href="/static/css/main.6d93e0db.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
1
+ <!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><title>Matterbridge</title><link rel="manifest" href="/manifest.json"/><script defer="defer" src="/static/js/main.b5a876cf.js"></script><link href="/static/css/main.6d93e0db.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>