matterbridge 1.3.9 → 1.3.10
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/CHANGELOG.md +19 -0
- package/__mocks__/@project-chip/matter-node.js/util.js +41 -0
- package/dist/matterbridge.d.ts +55 -6
- package/dist/matterbridge.d.ts.map +1 -1
- package/dist/matterbridge.js +167 -53
- package/dist/matterbridge.js.map +1 -1
- package/dist/utils.d.ts +21 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +23 -2
- package/dist/utils.js.map +1 -1
- package/frontend/build/asset-manifest.json +6 -6
- package/frontend/build/index.html +1 -1
- package/frontend/build/static/css/main.8e9f022b.css +2 -0
- package/frontend/build/static/css/main.8e9f022b.css.map +1 -0
- package/frontend/build/static/js/{main.942a74a2.js → main.cf22e7af.js} +3 -3
- package/frontend/build/static/js/{main.942a74a2.js.map → main.cf22e7af.js.map} +1 -1
- package/package.json +3 -2
- package/frontend/build/static/css/main.abff2627.css +0 -8
- package/frontend/build/static/css/main.abff2627.css.map +0 -1
- /package/frontend/build/static/js/{main.942a74a2.js.LICENSE.txt → main.cf22e7af.js.LICENSE.txt} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,25 @@ All notable changes to this project will be documented in this file.
|
|
|
4
4
|
|
|
5
5
|
If you like this project and find it useful, please consider giving it a star on GitHub at https://github.com/Luligu/matterbridge and sponsoring it.
|
|
6
6
|
|
|
7
|
+
## [1.3.10] - 2024-07-05
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- [fabrics]: Added fabricInfo to matterbridge in bridge mode and to the plugins in childbridge mode.
|
|
12
|
+
- [sessions]: Added sessionInfo to matterbridge in bridge mode and to the plugins in childbridge mode.
|
|
13
|
+
- [frontend]: Added fabricInfo in bridge mode and in childbridge mode instead of QRCode if already paired.
|
|
14
|
+
- [frontend]: Added sessionInfo in bridge mode and in childbridge mode instead of QRCode if already paired.
|
|
15
|
+
- [matterbridge]: Added parsePlugin to load the updated data from the plugin even when is disabled.
|
|
16
|
+
- [matterbridge]: Added an automatic plugin reinstall from npm when the plugin is not found. (e.g. when the docker image is updated and the plugin is not an official plugin)
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
|
|
20
|
+
- [dependencies]: Update dependencies.
|
|
21
|
+
|
|
22
|
+
<a href="https://www.buymeacoffee.com/luligugithub">
|
|
23
|
+
<img src="./yellow-button.png" alt="Buy me a coffee" width="120">
|
|
24
|
+
</a>
|
|
25
|
+
|
|
7
26
|
## [1.3.9] - 2024-07-02
|
|
8
27
|
|
|
9
28
|
### Fixed
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022-2024 Matter.js Authors
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { ValidationError } from '@project-chip/matter.js/common';
|
|
7
|
+
import { execSync } from 'child_process';
|
|
8
|
+
function getParameter(name) {
|
|
9
|
+
const commandArguments = process.argv.slice(2);
|
|
10
|
+
let markerIndex = commandArguments.indexOf(`-${name}`);
|
|
11
|
+
if (markerIndex === -1) markerIndex = commandArguments.indexOf(`--${name}`);
|
|
12
|
+
if (markerIndex === -1 || markerIndex + 1 === commandArguments.length) return void 0;
|
|
13
|
+
return commandArguments[markerIndex + 1];
|
|
14
|
+
}
|
|
15
|
+
function hasParameter(name) {
|
|
16
|
+
const commandArguments = process.argv.slice(2);
|
|
17
|
+
let markerIncluded = commandArguments.includes(`-${name}`);
|
|
18
|
+
if (!markerIncluded) markerIncluded = commandArguments.includes(`--${name}`);
|
|
19
|
+
return markerIncluded;
|
|
20
|
+
}
|
|
21
|
+
function getIntParameter(name) {
|
|
22
|
+
const value = getParameter(name);
|
|
23
|
+
if (value === void 0) return void 0;
|
|
24
|
+
const intValue = parseInt(value, 10);
|
|
25
|
+
if (isNaN(intValue)) throw new ValidationError(`Invalid value for parameter ${name}: ${value} is not a number`);
|
|
26
|
+
return intValue;
|
|
27
|
+
}
|
|
28
|
+
function commandExecutor(scriptParamName) {
|
|
29
|
+
const script = getParameter(scriptParamName);
|
|
30
|
+
if (script === void 0) return void 0;
|
|
31
|
+
// eslint-disable-next-line no-console
|
|
32
|
+
return () => console.log(`${scriptParamName}: ${execSync(script).toString().slice(0, -1)}`);
|
|
33
|
+
}
|
|
34
|
+
function requireMinNodeVersion(minVersion) {
|
|
35
|
+
const version = process.versions.node;
|
|
36
|
+
const versionMajor = parseInt(version.split('.')[0]);
|
|
37
|
+
if (versionMajor < minVersion) throw new MatterError(`Node version ${versionMajor} is not supported. Please upgrade to ${minVersion} or above.`);
|
|
38
|
+
}
|
|
39
|
+
export { commandExecutor, getIntParameter, getParameter, hasParameter, requireMinNodeVersion };
|
|
40
|
+
export * from '@project-chip/matter.js/util';
|
|
41
|
+
// # sourceMappingURL=CommandLine.js.map
|
package/dist/matterbridge.d.ts
CHANGED
|
@@ -25,9 +25,9 @@ import EventEmitter from 'events';
|
|
|
25
25
|
import { MatterbridgeDevice } from './matterbridgeDevice.js';
|
|
26
26
|
import { MatterbridgePlatform, PlatformConfig, PlatformSchema } from './matterbridgePlatform.js';
|
|
27
27
|
import { CommissioningServer } from '@project-chip/matter-node.js';
|
|
28
|
+
import { FabricIndex, VendorId } from '@project-chip/matter-node.js/datatype';
|
|
28
29
|
import { Aggregator } from '@project-chip/matter-node.js/device';
|
|
29
30
|
import { StorageContext } from '@project-chip/matter-node.js/storage';
|
|
30
|
-
import { ExposedFabricInformation } from '@project-chip/matter-node.js/fabric';
|
|
31
31
|
export interface RegisteredPlugin extends BaseRegisteredPlugin {
|
|
32
32
|
nodeContext?: NodeStorage;
|
|
33
33
|
storageContext?: StorageContext;
|
|
@@ -52,7 +52,8 @@ export interface BaseRegisteredPlugin {
|
|
|
52
52
|
configured?: boolean;
|
|
53
53
|
paired?: boolean;
|
|
54
54
|
connected?: boolean;
|
|
55
|
-
|
|
55
|
+
fabricInformations?: SanitizedExposedFabricInformation[];
|
|
56
|
+
sessionInformations?: SanitizedSessionInformation[];
|
|
56
57
|
registeredDevices?: number;
|
|
57
58
|
addedDevices?: number;
|
|
58
59
|
qrPairingCode?: string;
|
|
@@ -84,13 +85,34 @@ interface MatterbridgeInformation {
|
|
|
84
85
|
globalModulesDirectory: string;
|
|
85
86
|
matterbridgeVersion: string;
|
|
86
87
|
matterbridgeLatestVersion: string;
|
|
87
|
-
|
|
88
|
+
matterbridgeFabricInformations: SanitizedExposedFabricInformation[];
|
|
89
|
+
matterbridgeSessionInformations: SanitizedSessionInformation[];
|
|
88
90
|
matterbridgePaired: boolean;
|
|
89
91
|
matterbridgeConnected: boolean;
|
|
90
92
|
bridgeMode: string;
|
|
91
93
|
restartMode: string;
|
|
92
94
|
debugEnabled: boolean;
|
|
93
95
|
}
|
|
96
|
+
interface SanitizedExposedFabricInformation {
|
|
97
|
+
fabricIndex: FabricIndex;
|
|
98
|
+
fabricId: string;
|
|
99
|
+
nodeId: string;
|
|
100
|
+
rootNodeId: string;
|
|
101
|
+
rootVendorId: VendorId;
|
|
102
|
+
rootVendorName: string;
|
|
103
|
+
label: string;
|
|
104
|
+
}
|
|
105
|
+
interface SanitizedSessionInformation {
|
|
106
|
+
name: string;
|
|
107
|
+
nodeId: string;
|
|
108
|
+
peerNodeId: string;
|
|
109
|
+
fabric?: SanitizedExposedFabricInformation;
|
|
110
|
+
isPeerActive: boolean;
|
|
111
|
+
secure: boolean;
|
|
112
|
+
lastInteractionTimestamp?: number;
|
|
113
|
+
lastActiveTimestamp?: number;
|
|
114
|
+
numberOfActiveSubscriptions: number;
|
|
115
|
+
}
|
|
94
116
|
/**
|
|
95
117
|
* Represents the Matterbridge application.
|
|
96
118
|
*/
|
|
@@ -104,9 +126,10 @@ export declare class Matterbridge extends EventEmitter {
|
|
|
104
126
|
globalModulesDirectory: string;
|
|
105
127
|
matterbridgeVersion: string;
|
|
106
128
|
matterbridgeLatestVersion: string;
|
|
107
|
-
|
|
129
|
+
matterbridgeFabricInformations: SanitizedExposedFabricInformation[];
|
|
108
130
|
matterbridgePaired: boolean;
|
|
109
131
|
matterbridgeConnected: boolean;
|
|
132
|
+
matterbridgeSessionInformations: SanitizedSessionInformation[];
|
|
110
133
|
private checkUpdateInterval?;
|
|
111
134
|
bridgeMode: 'bridge' | 'childbridge' | 'controller' | '';
|
|
112
135
|
restartMode: 'service' | 'docker' | '';
|
|
@@ -143,6 +166,12 @@ export declare class Matterbridge extends EventEmitter {
|
|
|
143
166
|
* @returns The loaded Matterbridge instance.
|
|
144
167
|
*/
|
|
145
168
|
static loadInstance(initialize?: boolean): Promise<Matterbridge>;
|
|
169
|
+
/**
|
|
170
|
+
* Call shutdownProcess.
|
|
171
|
+
* @deprecated This method is deprecated and is only used for jest.
|
|
172
|
+
*
|
|
173
|
+
*/
|
|
174
|
+
destroyInstance(): Promise<void>;
|
|
146
175
|
/**
|
|
147
176
|
* Initializes the Matterbridge instance as extension for zigbee2mqtt.
|
|
148
177
|
* @deprecated This method is deprecated and will be removed in a future version.
|
|
@@ -181,8 +210,8 @@ export declare class Matterbridge extends EventEmitter {
|
|
|
181
210
|
* @returns {Promise<void>} A promise that resolves when the command line arguments have been processed.
|
|
182
211
|
*/
|
|
183
212
|
private parseCommandLine;
|
|
184
|
-
savePluginsToStorage
|
|
185
|
-
loadPluginsFromStorage
|
|
213
|
+
private savePluginsToStorage;
|
|
214
|
+
private loadPluginsFromStorage;
|
|
186
215
|
/**
|
|
187
216
|
* Resolves the name of a plugin by loading and parsing its package.json file.
|
|
188
217
|
* @param pluginPath - The path to the plugin or the path to the plugin's package.json file.
|
|
@@ -330,6 +359,12 @@ export declare class Matterbridge extends EventEmitter {
|
|
|
330
359
|
* @returns {Promise<void>} A promise that resolves when the plugin is configured successfully, or rejects with an error if configuration fails.
|
|
331
360
|
*/
|
|
332
361
|
private configurePlugin;
|
|
362
|
+
/**
|
|
363
|
+
* Loads and parse the plugin package.json and returns it.
|
|
364
|
+
* @param plugin - The plugin to load the package from.
|
|
365
|
+
* @returns A Promise that resolves to the package.json object or undefined if the package.json could not be loaded.
|
|
366
|
+
*/
|
|
367
|
+
private parsePlugin;
|
|
333
368
|
/**
|
|
334
369
|
* Loads a plugin and returns the corresponding MatterbridgePlatform instance.
|
|
335
370
|
* @param plugin - The plugin to load.
|
|
@@ -396,6 +431,20 @@ export declare class Matterbridge extends EventEmitter {
|
|
|
396
431
|
* @returns {Promise<void>} - A promise that resolves when the QR code is shown.
|
|
397
432
|
*/
|
|
398
433
|
private showCommissioningQRCode;
|
|
434
|
+
/**
|
|
435
|
+
* Sanitizes the fabric information by converting bigint properties to string cause res..
|
|
436
|
+
*
|
|
437
|
+
* @param fabricInfo - The array of exposed fabric information objects.
|
|
438
|
+
* @returns An array of sanitized exposed fabric information objects.
|
|
439
|
+
*/
|
|
440
|
+
private sanitizeFabricInformations;
|
|
441
|
+
/**
|
|
442
|
+
* Sanitizes the session information by converting bigint properties to string.
|
|
443
|
+
*
|
|
444
|
+
* @param sessionInfo - The array of session information objects.
|
|
445
|
+
* @returns An array of sanitized session information objects.
|
|
446
|
+
*/
|
|
447
|
+
private sanitizeSessionInformation;
|
|
399
448
|
/**
|
|
400
449
|
* Finds a plugin by its name.
|
|
401
450
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matterbridge.d.ts","sourceRoot":"","sources":["../src/matterbridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAsB,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAQvE,OAAO,YAAY,MAAM,QAAQ,CAAC;AAOlC,OAAO,EAAE,kBAAkB,EAAgC,MAAM,yBAAyB,CAAC;AAC3F,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAMjG,OAAO,EAA2B,mBAAmB,EAA0C,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":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AO,CAAC,0BAA0B;IAclC;;;;;OAKG;IACH,OAAO,CAAC,0BAA0B;IA0BlC;;;;;OAKG;IACH,OAAO,CAAC,UAAU;IASlB;;;;;OAKG;IACH,OAAO,CAAC,kCAAkC;IAM1C;;;;OAIG;IACH,OAAO,CAAC,yBAAyB;IAWjC;;;;;OAKG;IACH,OAAO,CAAC,qBAAqB;IAM7B,OAAO,CAAC,eAAe,CAoCrB;IAEF;;;;;;OAMG;YACW,wBAAwB;IAwJtC;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;IAmB1B;;;;OAIG;YACW,sBAAsB;IA2CpC;;OAEG;YACW,UAAU;IAcxB;;;;OAIG;YACW,gBAAgB;IAY9B;;;OAGG;YACW,oBAAoB;IAYlC;;OAEG;YACW,oBAAoB;IAmKlC;;;;OAIG;YACW,4BAA4B;IAiB1C;;;;;;;;;OASG;YACW,sBAAsB;IAcpC;;;;OAIG;YACW,wBAAwB;IAgCtC;;;;;OAKG;YACW,YAAY;IA0E1B;;;;;;OAMG;IACH,OAAO,CAAC,cAAc;IActB;;;;OAIG;IACG,kBAAkB,CAAC,IAAI,SAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IA4gBpD;;;;OAIG;IACH,OAAO,CAAC,wBAAwB;CAkCjC"}
|
package/dist/matterbridge.js
CHANGED
|
@@ -79,7 +79,8 @@ export class Matterbridge extends EventEmitter {
|
|
|
79
79
|
globalModulesDirectory: '',
|
|
80
80
|
matterbridgeVersion: '',
|
|
81
81
|
matterbridgeLatestVersion: '',
|
|
82
|
-
|
|
82
|
+
matterbridgeFabricInformations: [],
|
|
83
|
+
matterbridgeSessionInformations: [],
|
|
83
84
|
matterbridgePaired: false,
|
|
84
85
|
matterbridgeConnected: false,
|
|
85
86
|
bridgeMode: '',
|
|
@@ -93,9 +94,10 @@ export class Matterbridge extends EventEmitter {
|
|
|
93
94
|
globalModulesDirectory = '';
|
|
94
95
|
matterbridgeVersion = '';
|
|
95
96
|
matterbridgeLatestVersion = '';
|
|
96
|
-
|
|
97
|
+
matterbridgeFabricInformations = [];
|
|
97
98
|
matterbridgePaired = false;
|
|
98
99
|
matterbridgeConnected = false;
|
|
100
|
+
matterbridgeSessionInformations = [];
|
|
99
101
|
checkUpdateInterval; // = 24 * 60 * 60 * 1000; // 24 hours
|
|
100
102
|
bridgeMode = '';
|
|
101
103
|
restartMode = '';
|
|
@@ -147,6 +149,14 @@ export class Matterbridge extends EventEmitter {
|
|
|
147
149
|
}
|
|
148
150
|
return Matterbridge.instance;
|
|
149
151
|
}
|
|
152
|
+
/**
|
|
153
|
+
* Call shutdownProcess.
|
|
154
|
+
* @deprecated This method is deprecated and is only used for jest.
|
|
155
|
+
*
|
|
156
|
+
*/
|
|
157
|
+
async destroyInstance() {
|
|
158
|
+
await this.shutdownProcess();
|
|
159
|
+
}
|
|
150
160
|
/**
|
|
151
161
|
* Initializes the Matterbridge instance as extension for zigbee2mqtt.
|
|
152
162
|
* @deprecated This method is deprecated and will be removed in a future version.
|
|
@@ -273,7 +283,7 @@ export class Matterbridge extends EventEmitter {
|
|
|
273
283
|
- reset: remove the commissioning for Matterbridge (bridge mode). Shutdown Matterbridge before using it!
|
|
274
284
|
- factoryreset: remove all commissioning information and reset all internal storages. Shutdown Matterbridge before using it!
|
|
275
285
|
- list: list the registered plugins
|
|
276
|
-
- loginterfaces: log the network interfaces
|
|
286
|
+
- loginterfaces: log the network interfaces (usefull for finding the name of the interface to use with -mdnsinterface option)
|
|
277
287
|
- logstorage: log the node storage
|
|
278
288
|
- ssl: enable SSL for the frontend and WebSockerServer (certificates in .matterbridge/certs directory cert.pem, key.pem and ca.pem (optional))
|
|
279
289
|
- add [plugin path]: register the plugin from the given absolute or relative path
|
|
@@ -316,6 +326,27 @@ export class Matterbridge extends EventEmitter {
|
|
|
316
326
|
// Get the plugins from node storage and create the plugin node storage contexts
|
|
317
327
|
this.registeredPlugins = await this.nodeContext.get('plugins', []);
|
|
318
328
|
for (const plugin of this.registeredPlugins) {
|
|
329
|
+
const packageJson = await this.parsePlugin(plugin);
|
|
330
|
+
if (packageJson) {
|
|
331
|
+
// Update the plugin information
|
|
332
|
+
plugin.name = packageJson.name;
|
|
333
|
+
plugin.version = packageJson.version;
|
|
334
|
+
plugin.description = packageJson.description;
|
|
335
|
+
plugin.author = packageJson.author;
|
|
336
|
+
}
|
|
337
|
+
else {
|
|
338
|
+
this.log.info(`Error parsing plugin ${plg}${plugin.name}${nf}. Trying to reinstall it from npm.`);
|
|
339
|
+
try {
|
|
340
|
+
await this.spawnCommand('npm', ['install', '-g', plugin.name]);
|
|
341
|
+
this.log.info(`Plugin ${plg}${plugin.name}${nf} reinstalled.`);
|
|
342
|
+
plugin.error = false;
|
|
343
|
+
}
|
|
344
|
+
catch (error) {
|
|
345
|
+
plugin.error = true;
|
|
346
|
+
plugin.enabled = false;
|
|
347
|
+
this.log.error(`Error installing plugin ${plg}${plugin.name}${er}. The plugin is disabled.`);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
319
350
|
this.log.debug(`Creating node storage context for plugin ${plugin.name}`);
|
|
320
351
|
plugin.nodeContext = await this.nodeStorage.createStorage(plugin.name);
|
|
321
352
|
await plugin.nodeContext.set('name', plugin.name);
|
|
@@ -328,7 +359,7 @@ export class Matterbridge extends EventEmitter {
|
|
|
328
359
|
// Log system info and create .matterbridge directory
|
|
329
360
|
await this.logNodeAndSystemInfo();
|
|
330
361
|
this.log.info(`Matterbridge version ${this.matterbridgeVersion} mode ${hasParameter('bridge') ? 'bridge' : ''}${hasParameter('childbridge') ? 'childbridge' : ''}${hasParameter('controller') ? 'controller' : ''} ` +
|
|
331
|
-
`${this.restartMode !== '' ? 'restart mode ' + this.restartMode + ' ' : ''}running on ${this.systemInformation.osType} ${this.systemInformation.osRelease} ${this.systemInformation.osPlatform} ${this.systemInformation.osArch}`);
|
|
362
|
+
`${this.restartMode !== '' ? 'restart mode ' + this.restartMode + ' ' : ''}running on ${this.systemInformation.osType} ${this.systemInformation.osRelease} ${this.systemInformation.osPlatform} ${this.systemInformation.osArch} `);
|
|
332
363
|
// Check node version and throw error
|
|
333
364
|
requireMinNodeVersion(18);
|
|
334
365
|
// Register SIGINT SIGTERM signal handlers
|
|
@@ -477,7 +508,8 @@ export class Matterbridge extends EventEmitter {
|
|
|
477
508
|
process.exit(0);
|
|
478
509
|
}
|
|
479
510
|
// Initialize frontend
|
|
480
|
-
|
|
511
|
+
if (getIntParameter('frontend') !== 0 || getIntParameter('frontend') === undefined)
|
|
512
|
+
await this.initializeFrontend(getIntParameter('frontend'));
|
|
481
513
|
// Check each 60 minutes the latest versions
|
|
482
514
|
this.checkUpdateInterval = setInterval(() => {
|
|
483
515
|
this.getMatterbridgeLatestVersion();
|
|
@@ -527,6 +559,14 @@ export class Matterbridge extends EventEmitter {
|
|
|
527
559
|
for (const plugin of this.registeredPlugins) {
|
|
528
560
|
plugin.configJson = await this.loadPluginConfig(plugin);
|
|
529
561
|
plugin.schemaJson = await this.loadPluginSchema(plugin);
|
|
562
|
+
// Check if the plugin is available
|
|
563
|
+
if (!(await this.resolvePluginName(plugin.path))) {
|
|
564
|
+
this.log.error(`Plugin ${plg}${plugin.name}${er} not found. Disabling it.`);
|
|
565
|
+
plugin.enabled = false;
|
|
566
|
+
plugin.error = true;
|
|
567
|
+
continue;
|
|
568
|
+
}
|
|
569
|
+
// Check if the plugin has a new version
|
|
530
570
|
this.getPluginLatestVersion(plugin);
|
|
531
571
|
if (!plugin.enabled) {
|
|
532
572
|
this.log.info(`Plugin ${plg}${plugin.name}${nf} not enabled`);
|
|
@@ -560,6 +600,14 @@ export class Matterbridge extends EventEmitter {
|
|
|
560
600
|
for (const plugin of this.registeredPlugins) {
|
|
561
601
|
plugin.configJson = await this.loadPluginConfig(plugin);
|
|
562
602
|
plugin.schemaJson = await this.loadPluginSchema(plugin);
|
|
603
|
+
// Check if the plugin is available
|
|
604
|
+
if (!(await this.resolvePluginName(plugin.path))) {
|
|
605
|
+
this.log.error(`Plugin ${plg}${plugin.name}${er} not found. Disabling it.`);
|
|
606
|
+
plugin.enabled = false;
|
|
607
|
+
plugin.error = true;
|
|
608
|
+
continue;
|
|
609
|
+
}
|
|
610
|
+
// Check if the plugin has a new version
|
|
563
611
|
this.getPluginLatestVersion(plugin);
|
|
564
612
|
if (!plugin.enabled) {
|
|
565
613
|
this.log.info(`Plugin ${plg}${plugin.name}${nf} not enabled`);
|
|
@@ -912,7 +960,7 @@ export class Matterbridge extends EventEmitter {
|
|
|
912
960
|
});
|
|
913
961
|
this.webSocketServer = undefined;
|
|
914
962
|
}
|
|
915
|
-
setTimeout(async () => {
|
|
963
|
+
const clenupTimeout1 = setTimeout(async () => {
|
|
916
964
|
// Closing matter
|
|
917
965
|
await this.stopMatter();
|
|
918
966
|
// Closing storage
|
|
@@ -943,7 +991,7 @@ export class Matterbridge extends EventEmitter {
|
|
|
943
991
|
this.registeredPlugins = [];
|
|
944
992
|
this.registeredDevices = [];
|
|
945
993
|
this.log.info('Waiting for matter to deliver last messages...');
|
|
946
|
-
setTimeout(async () => {
|
|
994
|
+
const clenupTimeout2 = setTimeout(async () => {
|
|
947
995
|
if (restart) {
|
|
948
996
|
if (message === 'updating...') {
|
|
949
997
|
this.log.info('Cleanup completed. Updating...');
|
|
@@ -977,7 +1025,9 @@ export class Matterbridge extends EventEmitter {
|
|
|
977
1025
|
this.emit('shutdown');
|
|
978
1026
|
}
|
|
979
1027
|
}, 2 * 1000);
|
|
1028
|
+
clenupTimeout2.unref();
|
|
980
1029
|
}, 3 * 1000);
|
|
1030
|
+
clenupTimeout1.unref();
|
|
981
1031
|
}
|
|
982
1032
|
}
|
|
983
1033
|
/**
|
|
@@ -1460,6 +1510,23 @@ export class Matterbridge extends EventEmitter {
|
|
|
1460
1510
|
return Promise.resolve();
|
|
1461
1511
|
}
|
|
1462
1512
|
}
|
|
1513
|
+
/**
|
|
1514
|
+
* Loads and parse the plugin package.json and returns it.
|
|
1515
|
+
* @param plugin - The plugin to load the package from.
|
|
1516
|
+
* @returns A Promise that resolves to the package.json object or undefined if the package.json could not be loaded.
|
|
1517
|
+
*/
|
|
1518
|
+
async parsePlugin(plugin) {
|
|
1519
|
+
this.log.debug(`Parsing package.json of plugin ${plg}${plugin.name}${nf} type ${typ}${plugin.type}${nf}`);
|
|
1520
|
+
try {
|
|
1521
|
+
const packageJson = JSON.parse(await fs.readFile(plugin.path, 'utf8'));
|
|
1522
|
+
return packageJson;
|
|
1523
|
+
}
|
|
1524
|
+
catch (err) {
|
|
1525
|
+
this.log.error(`Failed to parse plugin ${plg}${plugin.name}${er} package.json: ${err}`);
|
|
1526
|
+
plugin.error = true;
|
|
1527
|
+
return undefined;
|
|
1528
|
+
}
|
|
1529
|
+
}
|
|
1463
1530
|
/**
|
|
1464
1531
|
* Loads a plugin and returns the corresponding MatterbridgePlatform instance.
|
|
1465
1532
|
* @param plugin - The plugin to load.
|
|
@@ -1944,12 +2011,21 @@ export class Matterbridge extends EventEmitter {
|
|
|
1944
2011
|
const QrCode = new QrCodeSchema();
|
|
1945
2012
|
this.log.info(`***The commissioning server on port ${commissioningServer.getPort()} for ${plg}${pluginName}${nf} is not commissioned. Pair it scanning the QR code:\n\n` +
|
|
1946
2013
|
`${QrCode.encode(qrPairingCode)}\n${plg}${pluginName}${nf}\n\nqrPairingCode: ${qrPairingCode}\n\nManual pairing code: ${manualPairingCode}\n`);
|
|
2014
|
+
if (pluginName === 'Matterbridge') {
|
|
2015
|
+
this.matterbridgeFabricInformations = [];
|
|
2016
|
+
this.matterbridgeSessionInformations = [];
|
|
2017
|
+
this.matterbridgePaired = false;
|
|
2018
|
+
this.matterbridgeConnected = false;
|
|
2019
|
+
}
|
|
1947
2020
|
if (pluginName !== 'Matterbridge') {
|
|
1948
2021
|
const plugin = this.findPlugin(pluginName);
|
|
1949
2022
|
if (plugin) {
|
|
1950
2023
|
plugin.qrPairingCode = qrPairingCode;
|
|
1951
2024
|
plugin.manualPairingCode = manualPairingCode;
|
|
2025
|
+
plugin.fabricInformations = [];
|
|
2026
|
+
plugin.sessionInformations = [];
|
|
1952
2027
|
plugin.paired = false;
|
|
2028
|
+
plugin.connected = false;
|
|
1953
2029
|
}
|
|
1954
2030
|
}
|
|
1955
2031
|
await this.nodeContext?.set('plugins', await this.getBaseRegisteredPlugins());
|
|
@@ -1963,19 +2039,71 @@ export class Matterbridge extends EventEmitter {
|
|
|
1963
2039
|
this.log.info(`- fabric index ${zb}${info.fabricIndex}${nf} id ${zb}${info.fabricId}${nf} vendor ${zb}${info.rootVendorId}${nf} ${this.getVendorIdName(info.rootVendorId)} ${info.label}`);
|
|
1964
2040
|
});
|
|
1965
2041
|
if (pluginName === 'Matterbridge') {
|
|
1966
|
-
this.
|
|
2042
|
+
this.matterbridgeFabricInformations = this.sanitizeFabricInformations(fabricInfo);
|
|
2043
|
+
this.matterbridgeSessionInformations = [];
|
|
1967
2044
|
this.matterbridgePaired = true;
|
|
1968
2045
|
}
|
|
1969
2046
|
if (pluginName !== 'Matterbridge') {
|
|
1970
2047
|
const plugin = this.findPlugin(pluginName);
|
|
1971
2048
|
if (plugin) {
|
|
1972
|
-
plugin.
|
|
2049
|
+
plugin.fabricInformations = this.sanitizeFabricInformations(fabricInfo);
|
|
2050
|
+
plugin.sessionInformations = [];
|
|
1973
2051
|
plugin.paired = true;
|
|
1974
2052
|
}
|
|
1975
2053
|
}
|
|
1976
2054
|
await this.nodeContext?.set('plugins', await this.getBaseRegisteredPlugins());
|
|
1977
2055
|
}
|
|
1978
2056
|
}
|
|
2057
|
+
/**
|
|
2058
|
+
* Sanitizes the fabric information by converting bigint properties to string cause res..
|
|
2059
|
+
*
|
|
2060
|
+
* @param fabricInfo - The array of exposed fabric information objects.
|
|
2061
|
+
* @returns An array of sanitized exposed fabric information objects.
|
|
2062
|
+
*/
|
|
2063
|
+
sanitizeFabricInformations(fabricInfo) {
|
|
2064
|
+
return fabricInfo.map((info) => {
|
|
2065
|
+
return {
|
|
2066
|
+
fabricIndex: info.fabricIndex,
|
|
2067
|
+
fabricId: info.fabricId.toString(),
|
|
2068
|
+
nodeId: info.nodeId.toString(),
|
|
2069
|
+
rootNodeId: info.rootNodeId.toString(),
|
|
2070
|
+
rootVendorId: info.rootVendorId,
|
|
2071
|
+
rootVendorName: this.getVendorIdName(info.rootVendorId),
|
|
2072
|
+
label: info.label,
|
|
2073
|
+
};
|
|
2074
|
+
});
|
|
2075
|
+
}
|
|
2076
|
+
/**
|
|
2077
|
+
* Sanitizes the session information by converting bigint properties to string.
|
|
2078
|
+
*
|
|
2079
|
+
* @param sessionInfo - The array of session information objects.
|
|
2080
|
+
* @returns An array of sanitized session information objects.
|
|
2081
|
+
*/
|
|
2082
|
+
sanitizeSessionInformation(sessionInfo) {
|
|
2083
|
+
return sessionInfo.map((info) => {
|
|
2084
|
+
return {
|
|
2085
|
+
name: info.name,
|
|
2086
|
+
nodeId: info.nodeId.toString(),
|
|
2087
|
+
peerNodeId: info.peerNodeId.toString(),
|
|
2088
|
+
fabric: info.fabric
|
|
2089
|
+
? {
|
|
2090
|
+
fabricIndex: info.fabric.fabricIndex,
|
|
2091
|
+
fabricId: info.fabric.fabricId.toString(),
|
|
2092
|
+
nodeId: info.fabric.nodeId.toString(),
|
|
2093
|
+
rootNodeId: info.fabric.rootNodeId.toString(),
|
|
2094
|
+
rootVendorId: info.fabric.rootVendorId,
|
|
2095
|
+
rootVendorName: this.getVendorIdName(info.fabric.rootVendorId),
|
|
2096
|
+
label: info.fabric.label,
|
|
2097
|
+
}
|
|
2098
|
+
: undefined,
|
|
2099
|
+
isPeerActive: info.isPeerActive,
|
|
2100
|
+
secure: info.secure,
|
|
2101
|
+
lastInteractionTimestamp: info.lastInteractionTimestamp,
|
|
2102
|
+
lastActiveTimestamp: info.lastActiveTimestamp,
|
|
2103
|
+
numberOfActiveSubscriptions: info.numberOfActiveSubscriptions,
|
|
2104
|
+
};
|
|
2105
|
+
});
|
|
2106
|
+
}
|
|
1979
2107
|
/**
|
|
1980
2108
|
* Finds a plugin by its name.
|
|
1981
2109
|
*
|
|
@@ -2062,6 +2190,9 @@ export class Matterbridge extends EventEmitter {
|
|
|
2062
2190
|
case 4742:
|
|
2063
2191
|
vendorName = '(eWeLink)';
|
|
2064
2192
|
break;
|
|
2193
|
+
case 65521:
|
|
2194
|
+
vendorName = '(PythonMatterServer)';
|
|
2195
|
+
break;
|
|
2065
2196
|
default:
|
|
2066
2197
|
vendorName = '(unknown)';
|
|
2067
2198
|
break;
|
|
@@ -2118,9 +2249,9 @@ export class Matterbridge extends EventEmitter {
|
|
|
2118
2249
|
reachable: true,
|
|
2119
2250
|
},
|
|
2120
2251
|
activeSessionsChangedCallback: (fabricIndex) => {
|
|
2121
|
-
const
|
|
2252
|
+
const sessionInformations = commissioningServer.getActiveSessionInformation(fabricIndex);
|
|
2122
2253
|
let connected = false;
|
|
2123
|
-
|
|
2254
|
+
sessionInformations.forEach((session) => {
|
|
2124
2255
|
this.log.info(`*Active session changed on fabric ${zb}${fabricIndex}${nf} id ${zb}${session.fabric?.fabricId}${nf} vendor ${zb}${session.fabric?.rootVendorId}${nf} ${this.getVendorIdName(session.fabric?.rootVendorId)} ${session.fabric?.label} for ${plg}${pluginName}${nf}`, debugStringify(session));
|
|
2125
2256
|
if (session.isPeerActive === true && session.secure === true && session.numberOfActiveSubscriptions >= 1) {
|
|
2126
2257
|
this.log.info(`*Controller ${zb}${session.fabric?.rootVendorId}${nf} ${this.getVendorIdName(session.fabric?.rootVendorId)} ${session.fabric?.label} connected to ${plg}${pluginName}${nf} on session ${session.name}`);
|
|
@@ -2131,12 +2262,14 @@ export class Matterbridge extends EventEmitter {
|
|
|
2131
2262
|
if (this.bridgeMode === 'bridge') {
|
|
2132
2263
|
this.matterbridgePaired = true;
|
|
2133
2264
|
this.matterbridgeConnected = true;
|
|
2265
|
+
this.matterbridgeSessionInformations = this.sanitizeSessionInformation(sessionInformations);
|
|
2134
2266
|
}
|
|
2135
2267
|
if (this.bridgeMode === 'childbridge') {
|
|
2136
2268
|
const plugin = this.findPlugin(pluginName);
|
|
2137
2269
|
if (plugin) {
|
|
2138
2270
|
plugin.paired = true;
|
|
2139
2271
|
plugin.connected = true;
|
|
2272
|
+
plugin.sessionInformations = this.sanitizeSessionInformation(sessionInformations);
|
|
2140
2273
|
}
|
|
2141
2274
|
}
|
|
2142
2275
|
setTimeout(() => {
|
|
@@ -2179,7 +2312,8 @@ export class Matterbridge extends EventEmitter {
|
|
|
2179
2312
|
await commissioningServer.factoryReset();
|
|
2180
2313
|
if (pluginName === 'Matterbridge') {
|
|
2181
2314
|
await this.matterbridgeContext?.clearAll();
|
|
2182
|
-
this.
|
|
2315
|
+
this.matterbridgeFabricInformations = [];
|
|
2316
|
+
this.matterbridgeSessionInformations = [];
|
|
2183
2317
|
this.matterbridgePaired = false;
|
|
2184
2318
|
this.matterbridgeConnected = false;
|
|
2185
2319
|
}
|
|
@@ -2187,14 +2321,29 @@ export class Matterbridge extends EventEmitter {
|
|
|
2187
2321
|
for (const plugin of this.registeredPlugins) {
|
|
2188
2322
|
if (plugin.name === pluginName) {
|
|
2189
2323
|
await plugin.platform?.onShutdown('Commissioning removed by the controller');
|
|
2190
|
-
plugin.
|
|
2324
|
+
plugin.fabricInformations = [];
|
|
2325
|
+
plugin.sessionInformations = [];
|
|
2191
2326
|
plugin.paired = false;
|
|
2192
2327
|
plugin.connected = false;
|
|
2193
2328
|
await plugin.storageContext?.clearAll();
|
|
2194
2329
|
}
|
|
2195
2330
|
}
|
|
2196
2331
|
}
|
|
2197
|
-
this.log.warn(`*Restart to activate the pairing for ${plg}${pluginName}${wr}
|
|
2332
|
+
this.log.warn(`*Restart to activate the pairing for ${plg}${pluginName}${wr}.`);
|
|
2333
|
+
}
|
|
2334
|
+
else {
|
|
2335
|
+
const fabricInfo = commissioningServer.getCommissionedFabricInformation();
|
|
2336
|
+
if (pluginName === 'Matterbridge') {
|
|
2337
|
+
this.matterbridgeFabricInformations = this.sanitizeFabricInformations(fabricInfo);
|
|
2338
|
+
this.matterbridgePaired = true;
|
|
2339
|
+
}
|
|
2340
|
+
else {
|
|
2341
|
+
const plugin = this.findPlugin(pluginName);
|
|
2342
|
+
if (plugin) {
|
|
2343
|
+
plugin.fabricInformations = this.sanitizeFabricInformations(fabricInfo);
|
|
2344
|
+
plugin.paired = true;
|
|
2345
|
+
}
|
|
2346
|
+
}
|
|
2198
2347
|
}
|
|
2199
2348
|
},
|
|
2200
2349
|
});
|
|
@@ -2549,7 +2698,8 @@ export class Matterbridge extends EventEmitter {
|
|
|
2549
2698
|
configured: plugin.configured,
|
|
2550
2699
|
paired: plugin.paired,
|
|
2551
2700
|
connected: plugin.connected,
|
|
2552
|
-
|
|
2701
|
+
fabricInformations: plugin.fabricInformations,
|
|
2702
|
+
sessionInformations: plugin.sessionInformations,
|
|
2553
2703
|
registeredDevices: plugin.registeredDevices,
|
|
2554
2704
|
addedDevices: plugin.addedDevices,
|
|
2555
2705
|
qrPairingCode: plugin.qrPairingCode,
|
|
@@ -2773,43 +2923,6 @@ export class Matterbridge extends EventEmitter {
|
|
|
2773
2923
|
this.webSocketServer.on('error', (ws, error) => {
|
|
2774
2924
|
this.log.error(`WebSocketServer error: ${error}`);
|
|
2775
2925
|
});
|
|
2776
|
-
/*
|
|
2777
|
-
// Create a WebSocket server
|
|
2778
|
-
const wssPort = 8284;
|
|
2779
|
-
const wssHost = `ws://${this.systemInformation.ipv4Address}:${wssPort}`;
|
|
2780
|
-
this.webSocketServer = new WebSocketServer({ port: wssPort, host: this.systemInformation.ipv4Address });
|
|
2781
|
-
this.log.debug(`WebSocket server created on ${UNDERLINE}${wssHost}${UNDERLINEOFF}${rs}`);
|
|
2782
|
-
|
|
2783
|
-
this.webSocketServer.on('listening', () => {
|
|
2784
|
-
this.log.info(`WebSocketServer is listening on ${UNDERLINE}${wssHost}${UNDERLINEOFF}${rs}`);
|
|
2785
|
-
return;
|
|
2786
|
-
});
|
|
2787
|
-
*/
|
|
2788
|
-
/*
|
|
2789
|
-
// Serve React build directory
|
|
2790
|
-
this.expressApp = express();
|
|
2791
|
-
this.expressApp.use(express.static(path.join(this.rootDirectory, 'frontend/build')));
|
|
2792
|
-
|
|
2793
|
-
// Listen on HTTP
|
|
2794
|
-
this.expressServer = this.expressApp.listen(port, () => {
|
|
2795
|
-
this.log.info(`The frontend is listening on ${UNDERLINE}http://${this.systemInformation.ipv4Address}:${port}${UNDERLINEOFF}${rs}`);
|
|
2796
|
-
this.log.debug(`The frontend is listening on ${UNDERLINE}http://[${this.systemInformation.ipv6Address}]:${port}${UNDERLINEOFF}${rs}`);
|
|
2797
|
-
});
|
|
2798
|
-
|
|
2799
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2800
|
-
this.expressServer.on('error', (error: any) => {
|
|
2801
|
-
this.log.error(`Frontend error listening on ${UNDERLINE}http://${this.systemInformation.ipv4Address}:${port}${UNDERLINEOFF}${rs}`);
|
|
2802
|
-
switch (error.code) {
|
|
2803
|
-
case 'EACCES':
|
|
2804
|
-
this.log.error(`Port ${port} requires elevated privileges`);
|
|
2805
|
-
break;
|
|
2806
|
-
case 'EADDRINUSE':
|
|
2807
|
-
this.log.error(`Port ${port} is already in use`);
|
|
2808
|
-
break;
|
|
2809
|
-
}
|
|
2810
|
-
process.exit(1);
|
|
2811
|
-
});
|
|
2812
|
-
*/
|
|
2813
2926
|
// Endpoint to validate login code
|
|
2814
2927
|
this.expressApp.post('/api/login', express.json(), async (req, res) => {
|
|
2815
2928
|
const { password } = req.body;
|
|
@@ -2858,7 +2971,8 @@ export class Matterbridge extends EventEmitter {
|
|
|
2858
2971
|
this.matterbridgeInformation.debugEnabled = this.debugEnabled;
|
|
2859
2972
|
this.matterbridgeInformation.matterbridgePaired = this.matterbridgePaired;
|
|
2860
2973
|
this.matterbridgeInformation.matterbridgeConnected = this.matterbridgeConnected;
|
|
2861
|
-
|
|
2974
|
+
this.matterbridgeInformation.matterbridgeFabricInformations = this.matterbridgeFabricInformations;
|
|
2975
|
+
this.matterbridgeInformation.matterbridgeSessionInformations = this.matterbridgeSessionInformations;
|
|
2862
2976
|
const response = { wssHost, qrPairingCode, manualPairingCode, systemInformation: this.systemInformation, matterbridgeInformation: this.matterbridgeInformation };
|
|
2863
2977
|
// this.log.debug('Response:', debugStringify(response));
|
|
2864
2978
|
res.json(response);
|