matterbridge 1.2.7 → 1.2.8
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 +16 -0
- package/dist/AirQualityCluster.d.ts +1 -1
- package/dist/AirQualityCluster.d.ts.map +1 -1
- package/dist/TvocCluster.d.ts +1 -1
- package/dist/TvocCluster.d.ts.map +1 -1
- package/dist/matterbridge.d.ts +21 -7
- package/dist/matterbridge.d.ts.map +1 -1
- package/dist/matterbridge.js +215 -88
- package/dist/matterbridge.js.map +1 -1
- package/dist/matterbridgeDevice.d.ts +13 -5
- package/dist/matterbridgeDevice.d.ts.map +1 -1
- package/dist/matterbridgeDevice.js +3 -3
- package/dist/matterbridgeDevice.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.61f6cf42.css → main.4c325919.css} +2 -2
- package/frontend/build/static/css/main.4c325919.css.map +1 -0
- package/frontend/build/static/js/{main.491fc08f.js → main.90cbbf6e.js} +3 -3
- package/frontend/build/static/js/main.90cbbf6e.js.map +1 -0
- package/package.json +12 -10
- package/dist/EveHistoryCluster.d.ts +0 -426
- package/dist/EveHistoryCluster.d.ts.map +0 -1
- package/dist/EveHistoryCluster.js +0 -162
- package/dist/EveHistoryCluster.js.map +0 -1
- package/frontend/build/static/css/main.61f6cf42.css.map +0 -1
- package/frontend/build/static/js/main.491fc08f.js.map +0 -1
- /package/frontend/build/static/js/{main.491fc08f.js.LICENSE.txt → main.90cbbf6e.js.LICENSE.txt} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [1.2.8] - 2024-04-16
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
- [matter.js]: Update to @project-chip/matter-node.js v. 0.8.1
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- [frontend]: Added logs in the Home page and in the Log page.
|
|
13
|
+
- [frontend]: Frontend got updated to 0.8.5.
|
|
14
|
+
- [frontend]: Added log for update and plugin install.
|
|
15
|
+
- [extension]: Started implementation of zigbee2MQTT internal extension.
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
|
|
19
|
+
- [spawn]: Fixed under windows.
|
|
20
|
+
|
|
5
21
|
## [1.2.7] - 2024-04-14
|
|
6
22
|
|
|
7
23
|
### Changed
|
|
@@ -183,6 +183,6 @@ export declare namespace AirQuality {
|
|
|
183
183
|
}
|
|
184
184
|
const Complete: Complete;
|
|
185
185
|
}
|
|
186
|
-
export type AirQualityCluster =
|
|
186
|
+
export type AirQualityCluster = AirQuality.Cluster;
|
|
187
187
|
export declare const AirQualityCluster: AirQuality.Cluster;
|
|
188
188
|
//# sourceMappingURL=AirQualityCluster.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AirQualityCluster.d.ts","sourceRoot":"","sources":["../src/AirQualityCluster.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,EAAmB,cAAc,EAAE,MAAM,sCAAsC,CAAC;AACvF,OAAO,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,qCAAqC,CAAC;AAE9D,OAAO,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAE7D,yBAAiB,UAAU,CAAC;IAC1B,KAAY,cAAc;QACxB,OAAO,IAAI;QACX,IAAI,IAAI;QACR,IAAI,IAAI;QACR,QAAQ,IAAI;QACZ,IAAI,IAAI;QACR,QAAQ,IAAI;QACZ,aAAa,IAAI;KAClB;IAEM,MAAM,uBAAuB;;;;KAIlC,CAAC;IACI,MAAM,2BAA2B;;;;KAItC,CAAC;IACI,MAAM,2BAA2B;;;;KAItC,CAAC;IACI,MAAM,gCAAgC;;;;KAI3C,CA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;;KAI3C,CAAC;IAEH,KAAY,OAAO;QACjB,cAAc,mBAAmB;QACjC,kBAAkB,uBAAuB;QACzC,kBAAkB,uBAAuB;QACzC,uBAAuB,4BAA4B;KACpD;IAEM,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAsBf,CAAC;IAEI,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAAsC,CAAC;IAEnE,UAAiB,OAAQ,SAAQ,QAAQ,CAAC,OAAO,eAAe,CAAC;KAAG;IAE7D,MAAM,OAAO,EAAE,OAAyB,CAAC;IAEzC,MAAM,gBAAgB;;;;;;;;;;;;;MAS3B,CAAC;IAEH,UAAiB,QAAS,SAAQ,QAAQ,CAAC,OAAO,gBAAgB,CAAC;KAAG;IAE/D,MAAM,QAAQ,EAAE,QAA2B,CAAC;CACpD;AAED,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,OAAO,CAAC;AACnD,eAAO,MAAM,iBAAiB,oBAAqB,CAAC"}
|
package/dist/TvocCluster.d.ts
CHANGED
|
@@ -460,6 +460,6 @@ export declare namespace TvocMeasurement {
|
|
|
460
460
|
}
|
|
461
461
|
const Complete: Complete;
|
|
462
462
|
}
|
|
463
|
-
export type TvocMeasurementCluster =
|
|
463
|
+
export type TvocMeasurementCluster = TvocMeasurement.Cluster;
|
|
464
464
|
export declare const TvocMeasurementCluster: TvocMeasurement.Cluster;
|
|
465
465
|
//# sourceMappingURL=TvocCluster.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TvocCluster.d.ts","sourceRoot":"","sources":["../src/TvocCluster.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,EAAmB,cAAc,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAC1G,OAAO,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AAC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|
|
76
76
|
private expressServer;
|
|
77
|
+
private webSocketServer;
|
|
77
78
|
private storageManager;
|
|
78
79
|
private matterbridgeContext;
|
|
79
80
|
private mattercontrollerContext;
|
|
@@ -91,6 +92,18 @@ export declare class Matterbridge extends EventEmitter {
|
|
|
91
92
|
* @returns The loaded Matterbridge instance.
|
|
92
93
|
*/
|
|
93
94
|
static loadInstance(initialize?: boolean): Promise<Matterbridge>;
|
|
95
|
+
/**
|
|
96
|
+
* Initializes the Matterbridge instance as extension for zigbee2mqtt.
|
|
97
|
+
*
|
|
98
|
+
* @returns A Promise that resolves when the initialization is complete.
|
|
99
|
+
*/
|
|
100
|
+
initializeAsExtension(dataPath: string, debugEnabled: boolean): Promise<void>;
|
|
101
|
+
/**
|
|
102
|
+
* Close the Matterbridge instance as extension for zigbee2mqtt.
|
|
103
|
+
*
|
|
104
|
+
* @returns A Promise that resolves when the initialization is complete.
|
|
105
|
+
*/
|
|
106
|
+
closeAsExtension(): Promise<void>;
|
|
94
107
|
/**
|
|
95
108
|
* Initializes the Matterbridge application.
|
|
96
109
|
*
|
|
@@ -102,13 +115,6 @@ export declare class Matterbridge extends EventEmitter {
|
|
|
102
115
|
* @returns A Promise that resolves when the initialization is complete.
|
|
103
116
|
*/
|
|
104
117
|
initialize(): Promise<void>;
|
|
105
|
-
/**
|
|
106
|
-
* Spawns a child process with the given command and arguments.
|
|
107
|
-
* @param command - The command to execute.
|
|
108
|
-
* @param args - The arguments to pass to the command (default: []).
|
|
109
|
-
* @returns A promise that resolves when the child process exits successfully, or rejects if there is an error.
|
|
110
|
-
*/
|
|
111
|
-
private spawnCommand;
|
|
112
118
|
/**
|
|
113
119
|
* Parses the command line arguments and performs the corresponding actions.
|
|
114
120
|
* @private
|
|
@@ -371,6 +377,14 @@ export declare class Matterbridge extends EventEmitter {
|
|
|
371
377
|
* @returns {BaseRegisteredPlugin[]} An array of base registered devices.
|
|
372
378
|
*/
|
|
373
379
|
private getBaseRegisteredDevices;
|
|
380
|
+
/**
|
|
381
|
+
* Spawns a child process with the given command and arguments.
|
|
382
|
+
* @param command - The command to execute.
|
|
383
|
+
* @param args - The arguments to pass to the command (default: []).
|
|
384
|
+
* @returns A promise that resolves when the child process exits successfully, or rejects if there is an error.
|
|
385
|
+
*/
|
|
386
|
+
private spawnCommand;
|
|
387
|
+
private wssSendMessage;
|
|
374
388
|
/**
|
|
375
389
|
* Initializes the frontend of Matterbridge.
|
|
376
390
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matterbridge.d.ts","sourceRoot":"","sources":["../src/matterbridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;;AAEH,OAAO,EAAE,kBAAkB,EAAgC,MAAM,yBAAyB,CAAC;AAQ3F,OAAO,YAAY,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"matterbridge.d.ts","sourceRoot":"","sources":["../src/matterbridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;;AAEH,OAAO,EAAE,kBAAkB,EAAgC,MAAM,yBAAyB,CAAC;AAQ3F,OAAO,YAAY,MAAM,QAAQ,CAAC;AA2ClC,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;AAEjG,MAAM,MAAM,cAAc,GAAG;IAC3B,CAAC,GAAG,EAAE,MAAM,GAAG,mBAAmB,CAAC;CACpC,CAAC;AAwCF,UAAU,iBAAiB;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC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AgC;IA0C9C;;;;;;;OAOG;YACW,uBAAuB;IAgCrC;;;;;OAKG;IACH,OAAO,CAAC,UAAU;IASlB;;;;;;OAMG;YACW,wBAAwB;IAkItC;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;IAM1B;;;;OAIG;YACW,sBAAsB;IAuCpC;;OAEG;YACW,UAAU;IAcxB;;;;OAIG;YACW,gBAAgB;IAY9B;;;OAGG;YACW,oBAAoB;IAYlC;;OAEG;YACW,oBAAoB;IAyJlC;;;;OAIG;IACH,OAAO,CAAC,wBAAwB;IAqBhC;;;OAGG;IACH,OAAO,CAAC,wBAAwB;IAkBhC;;;;;OAKG;YACW,YAAY;IA0E1B,OAAO,CAAC,cAAc;IActB;;;;OAIG;IACG,kBAAkB,CAAC,IAAI,GAAE,MAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAgY5D;;;;OAIG;IACH,OAAO,CAAC,wBAAwB;CAwBjC"}
|
package/dist/matterbridge.js
CHANGED
|
@@ -30,6 +30,7 @@ import EventEmitter from 'events';
|
|
|
30
30
|
import express from 'express';
|
|
31
31
|
import os from 'os';
|
|
32
32
|
import path from 'path';
|
|
33
|
+
import WebSocket, { WebSocketServer } from 'ws';
|
|
33
34
|
import { CommissioningController, CommissioningServer, MatterServer } from '@project-chip/matter-node.js';
|
|
34
35
|
import { BasicInformationCluster, BooleanStateCluster,
|
|
35
36
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -90,6 +91,7 @@ export class Matterbridge extends EventEmitter {
|
|
|
90
91
|
nodeContext;
|
|
91
92
|
expressApp;
|
|
92
93
|
expressServer;
|
|
94
|
+
webSocketServer;
|
|
93
95
|
storageManager;
|
|
94
96
|
matterbridgeContext;
|
|
95
97
|
mattercontrollerContext;
|
|
@@ -112,13 +114,74 @@ export class Matterbridge extends EventEmitter {
|
|
|
112
114
|
static async loadInstance(initialize = false) {
|
|
113
115
|
if (!Matterbridge.instance) {
|
|
114
116
|
// eslint-disable-next-line no-console
|
|
115
|
-
|
|
117
|
+
if (hasParameter('debug'))
|
|
118
|
+
console.log(wr + 'Creating a new instance of Matterbridge.', initialize ? 'Initializing...' : 'Not initializing...', rs);
|
|
116
119
|
Matterbridge.instance = new Matterbridge();
|
|
117
120
|
if (initialize)
|
|
118
121
|
await Matterbridge.instance.initialize();
|
|
119
122
|
}
|
|
120
123
|
return Matterbridge.instance;
|
|
121
124
|
}
|
|
125
|
+
/**
|
|
126
|
+
* Initializes the Matterbridge instance as extension for zigbee2mqtt.
|
|
127
|
+
*
|
|
128
|
+
* @returns A Promise that resolves when the initialization is complete.
|
|
129
|
+
*/
|
|
130
|
+
async initializeAsExtension(dataPath, debugEnabled) {
|
|
131
|
+
// Set the first port to use
|
|
132
|
+
this.port = 5560;
|
|
133
|
+
// Set Matterbridge logger
|
|
134
|
+
this.debugEnabled = debugEnabled;
|
|
135
|
+
this.log = new AnsiLogger({ logName: 'Matterbridge', logTimestampFormat: 4 /* TimestampFormat.TIME_MILLIS */, logDebug: this.debugEnabled });
|
|
136
|
+
this.log.debug('Matterbridge extension is starting...');
|
|
137
|
+
// Initialize NodeStorage
|
|
138
|
+
this.matterbridgeDirectory = dataPath;
|
|
139
|
+
this.log.debug('Creating node storage manager dir: ' + path.join(this.matterbridgeDirectory, 'node_storage'));
|
|
140
|
+
this.nodeStorage = new NodeStorageManager({ dir: path.join(this.matterbridgeDirectory, 'node_storage'), logging: false });
|
|
141
|
+
this.log.debug('Creating node storage context for matterbridge: matterbridge');
|
|
142
|
+
this.nodeContext = await this.nodeStorage.createStorage('matterbridge');
|
|
143
|
+
// Log system info and create .matterbridge directory
|
|
144
|
+
await this.logNodeAndSystemInfo();
|
|
145
|
+
this.matterbridgeDirectory = dataPath;
|
|
146
|
+
// Set matter.js logger level and format
|
|
147
|
+
Logger.defaultLogLevel = this.debugEnabled ? Level.DEBUG : Level.INFO;
|
|
148
|
+
Logger.format = Format.ANSI;
|
|
149
|
+
// Start the storage and create matterbridgeContext
|
|
150
|
+
await this.startStorage('json', path.join(this.matterbridgeDirectory, 'matterbridge.json'));
|
|
151
|
+
this.matterbridgeContext = await this.createCommissioningServerContext('Matterbridge', 'Matterbridge', DeviceTypes.AGGREGATOR.code, 0xfff1, 'Matterbridge', 0x8000, 'Matterbridge aggregator');
|
|
152
|
+
if (!this.storageManager || !this.matterbridgeContext)
|
|
153
|
+
return;
|
|
154
|
+
await this.matterbridgeContext.set('softwareVersion', 1);
|
|
155
|
+
await this.matterbridgeContext.set('softwareVersionString', this.matterbridgeVersion);
|
|
156
|
+
await this.matterbridgeContext.set('hardwareVersion', 0);
|
|
157
|
+
await this.matterbridgeContext.set('hardwareVersionString', '0.0.1');
|
|
158
|
+
this.createMatterServer(this.storageManager);
|
|
159
|
+
this.log.debug(`Creating commissioning server for ${plg}Matterbridge${db}`);
|
|
160
|
+
this.commissioningServer = await this.createCommisioningServer(this.matterbridgeContext, 'Matterbridge');
|
|
161
|
+
this.log.debug(`Creating matter aggregator for ${plg}Matterbridge${db}`);
|
|
162
|
+
this.matterAggregator = await this.createMatterAggregator(this.matterbridgeContext);
|
|
163
|
+
this.log.debug('Adding matterbridge aggregator to commissioning server');
|
|
164
|
+
this.commissioningServer.addDevice(this.matterAggregator);
|
|
165
|
+
this.log.debug('Adding matterbridge commissioning server to matter server');
|
|
166
|
+
await this.matterServer?.addCommissioningServer(this.commissioningServer, { uniqueStorageKey: 'Matterbridge' });
|
|
167
|
+
this.log.debug(`Setting reachability to true for ${plg}Matterbridge${db}`);
|
|
168
|
+
this.commissioningServer.setReachability(true);
|
|
169
|
+
this.log.debug('Starting matter server...');
|
|
170
|
+
await this.startMatterServer();
|
|
171
|
+
this.log.info('Matter server started');
|
|
172
|
+
await this.showCommissioningQRCode(this.commissioningServer, this.matterbridgeContext, this.nodeContext, 'Matterbridge');
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Close the Matterbridge instance as extension for zigbee2mqtt.
|
|
176
|
+
*
|
|
177
|
+
* @returns A Promise that resolves when the initialization is complete.
|
|
178
|
+
*/
|
|
179
|
+
async closeAsExtension() {
|
|
180
|
+
// Closing matter
|
|
181
|
+
await this.stopMatter();
|
|
182
|
+
// Closing storage
|
|
183
|
+
await this.stopStorage();
|
|
184
|
+
}
|
|
122
185
|
/**
|
|
123
186
|
* Initializes the Matterbridge application.
|
|
124
187
|
*
|
|
@@ -202,66 +265,6 @@ export class Matterbridge extends EventEmitter {
|
|
|
202
265
|
// Parse command line
|
|
203
266
|
this.parseCommandLine();
|
|
204
267
|
}
|
|
205
|
-
/**
|
|
206
|
-
* Spawns a child process with the given command and arguments.
|
|
207
|
-
* @param command - The command to execute.
|
|
208
|
-
* @param args - The arguments to pass to the command (default: []).
|
|
209
|
-
* @returns A promise that resolves when the child process exits successfully, or rejects if there is an error.
|
|
210
|
-
*/
|
|
211
|
-
async spawnCommand(command, args = []) {
|
|
212
|
-
/*
|
|
213
|
-
npm > npm.cmd on windows
|
|
214
|
-
*/
|
|
215
|
-
if (process.platform === 'win32' && command === 'npm') {
|
|
216
|
-
command = command + '.cmd';
|
|
217
|
-
}
|
|
218
|
-
if (process.platform === 'linux' && command === 'npm' && !hasParameter('docker')) {
|
|
219
|
-
args.unshift(command);
|
|
220
|
-
command = 'sudo';
|
|
221
|
-
}
|
|
222
|
-
return new Promise((resolve, reject) => {
|
|
223
|
-
const childProcess = spawn(command, args, {
|
|
224
|
-
stdio: ['inherit', 'pipe', 'pipe'],
|
|
225
|
-
});
|
|
226
|
-
childProcess.on('error', (err) => {
|
|
227
|
-
this.log.error(`Failed to start child process: ${err.message}`);
|
|
228
|
-
reject(err); // Reject the promise on error
|
|
229
|
-
});
|
|
230
|
-
childProcess.on('close', (code) => {
|
|
231
|
-
if (code === 0) {
|
|
232
|
-
this.log.info(`Child process stdio streams have closed with code ${code}`);
|
|
233
|
-
resolve();
|
|
234
|
-
}
|
|
235
|
-
else {
|
|
236
|
-
this.log.error(`Child process stdio streams have closed with code ${code}`);
|
|
237
|
-
reject(new Error(`Process exited with code ${code}`));
|
|
238
|
-
}
|
|
239
|
-
});
|
|
240
|
-
// The 'exit' event might be redundant here since 'close' is also being handled
|
|
241
|
-
childProcess.on('exit', (code, signal) => {
|
|
242
|
-
this.log.info(`Child process exited with code ${code} and signal ${signal}`);
|
|
243
|
-
});
|
|
244
|
-
childProcess.on('disconnect', () => {
|
|
245
|
-
this.log.info('Child process has been disconnected from the parent');
|
|
246
|
-
});
|
|
247
|
-
if (childProcess.stdout) {
|
|
248
|
-
childProcess.stdout.on('data', (data) => {
|
|
249
|
-
// Convert the Buffer data to a string.
|
|
250
|
-
const message = data.toString();
|
|
251
|
-
this.log.info(message);
|
|
252
|
-
// TODO: Send this message to the frontend.
|
|
253
|
-
});
|
|
254
|
-
}
|
|
255
|
-
if (childProcess.stderr) {
|
|
256
|
-
childProcess.stderr.on('data', (data) => {
|
|
257
|
-
// Convert the Buffer data to a string.
|
|
258
|
-
const message = data.toString();
|
|
259
|
-
this.log.error(message);
|
|
260
|
-
// TODO: Handle the error message.
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
});
|
|
264
|
-
}
|
|
265
268
|
/**
|
|
266
269
|
* Parses the command line arguments and performs the corresponding actions.
|
|
267
270
|
* @private
|
|
@@ -640,6 +643,24 @@ export class Matterbridge extends EventEmitter {
|
|
|
640
643
|
this.expressApp.removeAllListeners();
|
|
641
644
|
this.expressApp = undefined;
|
|
642
645
|
}
|
|
646
|
+
// Close the WebSocket server
|
|
647
|
+
if (this.webSocketServer) {
|
|
648
|
+
// Close all active connections
|
|
649
|
+
this.webSocketServer.clients.forEach((client) => {
|
|
650
|
+
if (client.readyState === WebSocket.OPEN) {
|
|
651
|
+
client.close();
|
|
652
|
+
}
|
|
653
|
+
});
|
|
654
|
+
this.webSocketServer.close((error) => {
|
|
655
|
+
if (error) {
|
|
656
|
+
this.log.error(`Error closing WebSocket server: ${error}`);
|
|
657
|
+
}
|
|
658
|
+
else {
|
|
659
|
+
this.log.debug('WebSocket server closed successfully');
|
|
660
|
+
}
|
|
661
|
+
});
|
|
662
|
+
this.webSocketServer = undefined;
|
|
663
|
+
}
|
|
643
664
|
/*const cleanupTimeout1 =*/ setTimeout(async () => {
|
|
644
665
|
// Closing matter
|
|
645
666
|
await this.stopMatter();
|
|
@@ -688,7 +709,7 @@ export class Matterbridge extends EventEmitter {
|
|
|
688
709
|
Matterbridge.instance = undefined;
|
|
689
710
|
this.emit('shutdown');
|
|
690
711
|
}
|
|
691
|
-
},
|
|
712
|
+
}, 2 * 1000);
|
|
692
713
|
//cleanupTimeout2.unref();
|
|
693
714
|
}, 3 * 1000);
|
|
694
715
|
//cleanupTimeout1.unref();
|
|
@@ -1220,7 +1241,9 @@ export class Matterbridge extends EventEmitter {
|
|
|
1220
1241
|
// Call the default export function of the plugin, passing this MatterBridge instance
|
|
1221
1242
|
if (pluginInstance.default) {
|
|
1222
1243
|
const config = await this.loadPluginConfig(plugin);
|
|
1223
|
-
const
|
|
1244
|
+
const log = new AnsiLogger({ logName: plugin.description, logTimestampFormat: 4 /* TimestampFormat.TIME_MILLIS */, logDebug: this.debugEnabled });
|
|
1245
|
+
//log.setCallback(this.wssSendMessage.bind(this));
|
|
1246
|
+
const platform = pluginInstance.default(this, log, config);
|
|
1224
1247
|
platform.name = packageJson.name;
|
|
1225
1248
|
platform.config = config;
|
|
1226
1249
|
plugin.name = packageJson.name;
|
|
@@ -2028,11 +2051,6 @@ export class Matterbridge extends EventEmitter {
|
|
|
2028
2051
|
this.matterbridgeInformation.rootDirectory = this.rootDirectory;
|
|
2029
2052
|
this.log.debug(`Root Directory: ${this.rootDirectory}`);
|
|
2030
2053
|
// Global node_modules directory
|
|
2031
|
-
/*
|
|
2032
|
-
this.globalModulesDirectory = await this.getGlobalNodeModules();
|
|
2033
|
-
this.matterbridgeInformation.globalModulesDirectory = this.globalModulesDirectory;
|
|
2034
|
-
this.log.debug(`Global node_modules Directory: ${this.globalModulesDirectory}`);
|
|
2035
|
-
*/
|
|
2036
2054
|
if (this.nodeContext)
|
|
2037
2055
|
this.globalModulesDirectory = await this.nodeContext.get('globalModulesDirectory', '');
|
|
2038
2056
|
this.log.debug(`Global node_modules Directory: ${this.globalModulesDirectory}`);
|
|
@@ -2100,11 +2118,6 @@ export class Matterbridge extends EventEmitter {
|
|
|
2100
2118
|
this.matterbridgeInformation.matterbridgeVersion = this.matterbridgeVersion;
|
|
2101
2119
|
this.log.debug(`Matterbridge Version: ${this.matterbridgeVersion}`);
|
|
2102
2120
|
// Matterbridge latest version
|
|
2103
|
-
/*
|
|
2104
|
-
this.matterbridgeLatestVersion = await this.getLatestVersion('matterbridge');
|
|
2105
|
-
this.matterbridgeInformation.matterbridgeLatestVersion = this.matterbridgeLatestVersion;
|
|
2106
|
-
this.log.debug(`Matterbridge Latest Version: ${this.matterbridgeLatestVersion}`);
|
|
2107
|
-
*/
|
|
2108
2121
|
if (this.nodeContext)
|
|
2109
2122
|
this.matterbridgeLatestVersion = await this.nodeContext.get('matterbridgeLatestVersion', '');
|
|
2110
2123
|
this.log.debug(`Matterbridge Latest Version: ${this.matterbridgeLatestVersion}`);
|
|
@@ -2174,6 +2187,92 @@ export class Matterbridge extends EventEmitter {
|
|
|
2174
2187
|
}));
|
|
2175
2188
|
return baseRegisteredPlugins;
|
|
2176
2189
|
}
|
|
2190
|
+
/**
|
|
2191
|
+
* Spawns a child process with the given command and arguments.
|
|
2192
|
+
* @param command - The command to execute.
|
|
2193
|
+
* @param args - The arguments to pass to the command (default: []).
|
|
2194
|
+
* @returns A promise that resolves when the child process exits successfully, or rejects if there is an error.
|
|
2195
|
+
*/
|
|
2196
|
+
async spawnCommand(command, args = []) {
|
|
2197
|
+
/*
|
|
2198
|
+
npm > npm.cmd on windows
|
|
2199
|
+
cmd.exe ['dir'] on windows
|
|
2200
|
+
await this.spawnCommand('npm', ['install', '-g', 'matterbridge']);
|
|
2201
|
+
process.on('unhandledRejection', (reason, promise) => {
|
|
2202
|
+
this.log.error('Unhandled Rejection at:', promise, 'reason:', reason);
|
|
2203
|
+
});
|
|
2204
|
+
*/
|
|
2205
|
+
if (process.platform === 'win32' && command === 'npm') {
|
|
2206
|
+
// Must be spawn('cmd.exe', ['/c', 'npm -g install <package>']);
|
|
2207
|
+
const argstring = 'npm ' + args.join(' ');
|
|
2208
|
+
args.splice(0, args.length, '/c', argstring);
|
|
2209
|
+
command = 'cmd.exe';
|
|
2210
|
+
}
|
|
2211
|
+
if (process.platform === 'linux' && command === 'npm' && !hasParameter('docker')) {
|
|
2212
|
+
args.unshift(command);
|
|
2213
|
+
command = 'sudo';
|
|
2214
|
+
}
|
|
2215
|
+
this.log.debug(`Spawning command ${command} with ${debugStringify(args)}`);
|
|
2216
|
+
return new Promise((resolve, reject) => {
|
|
2217
|
+
const childProcess = spawn(command, args, {
|
|
2218
|
+
stdio: ['inherit', 'pipe', 'pipe'],
|
|
2219
|
+
});
|
|
2220
|
+
childProcess.on('error', (err) => {
|
|
2221
|
+
this.log.error(`Failed to start child process: ${err.message}`);
|
|
2222
|
+
reject(err); // Reject the promise on error
|
|
2223
|
+
});
|
|
2224
|
+
childProcess.on('close', (code) => {
|
|
2225
|
+
if (code === 0) {
|
|
2226
|
+
this.log.debug(`Child process stdio streams have closed with code ${code}`);
|
|
2227
|
+
resolve();
|
|
2228
|
+
}
|
|
2229
|
+
else {
|
|
2230
|
+
this.log.error(`Child process stdio streams have closed with code ${code}`);
|
|
2231
|
+
reject(new Error(`Child process stdio streams have closed with code ${code}`));
|
|
2232
|
+
}
|
|
2233
|
+
});
|
|
2234
|
+
childProcess.on('exit', (code, signal) => {
|
|
2235
|
+
if (code === 0) {
|
|
2236
|
+
this.log.debug(`Child process exited with code ${code} and signal ${signal}`);
|
|
2237
|
+
resolve();
|
|
2238
|
+
}
|
|
2239
|
+
else {
|
|
2240
|
+
this.log.error(`Child process exited with code ${code} and signal ${signal}`);
|
|
2241
|
+
reject(new Error(`Child process exited with code ${code} and signal ${signal}`));
|
|
2242
|
+
}
|
|
2243
|
+
});
|
|
2244
|
+
childProcess.on('disconnect', () => {
|
|
2245
|
+
this.log.debug('Child process has been disconnected from the parent');
|
|
2246
|
+
resolve();
|
|
2247
|
+
});
|
|
2248
|
+
if (childProcess.stdout) {
|
|
2249
|
+
childProcess.stdout.on('data', (data) => {
|
|
2250
|
+
const message = data.toString().trim();
|
|
2251
|
+
//this.log.info('\n' + message);
|
|
2252
|
+
this.wssSendMessage('spawn', 'stdout', message);
|
|
2253
|
+
});
|
|
2254
|
+
}
|
|
2255
|
+
if (childProcess.stderr) {
|
|
2256
|
+
childProcess.stderr.on('data', (data) => {
|
|
2257
|
+
const message = data.toString().trim();
|
|
2258
|
+
//this.log.debug('\n' + message);
|
|
2259
|
+
this.wssSendMessage('spawn', 'stderr', message);
|
|
2260
|
+
});
|
|
2261
|
+
}
|
|
2262
|
+
});
|
|
2263
|
+
}
|
|
2264
|
+
wssSendMessage(type, subType, message) {
|
|
2265
|
+
// Remove ANSI escape codes from the message
|
|
2266
|
+
// eslint-disable-next-line no-control-regex
|
|
2267
|
+
const cleanMessage = message.replace(/\x1B\[[0-9;]*[m|s|u|K]/g, '');
|
|
2268
|
+
// Remove leading asterisks from the message
|
|
2269
|
+
const finalMessage = cleanMessage.replace(/^\*+/, '');
|
|
2270
|
+
this.webSocketServer?.clients.forEach((client) => {
|
|
2271
|
+
if (client.readyState === WebSocket.OPEN) {
|
|
2272
|
+
client.send(JSON.stringify({ type, subType, message: finalMessage }));
|
|
2273
|
+
}
|
|
2274
|
+
});
|
|
2275
|
+
}
|
|
2177
2276
|
/**
|
|
2178
2277
|
* Initializes the frontend of Matterbridge.
|
|
2179
2278
|
*
|
|
@@ -2181,8 +2280,28 @@ export class Matterbridge extends EventEmitter {
|
|
|
2181
2280
|
*/
|
|
2182
2281
|
async initializeFrontend(port = 8283) {
|
|
2183
2282
|
this.log.debug(`Initializing the frontend on port ${YELLOW}${port}${db} static ${UNDERLINE}${path.join(this.rootDirectory, 'frontend/build')}${UNDERLINEOFF}${rs}`);
|
|
2184
|
-
|
|
2283
|
+
// Create a WebSocket server
|
|
2284
|
+
this.webSocketServer = new WebSocketServer({ port: 8284 });
|
|
2285
|
+
this.webSocketServer.on('connection', (ws) => {
|
|
2286
|
+
this.log.debug('WebSocketServer client connected');
|
|
2287
|
+
this.log.setGlobalCallback(this.wssSendMessage.bind(this));
|
|
2288
|
+
this.log.debug('WebSocketServer activated logger callback');
|
|
2289
|
+
ws.on('message', (message) => {
|
|
2290
|
+
this.log.debug(`WebSocketServer received message => ${message}`);
|
|
2291
|
+
});
|
|
2292
|
+
ws.on('close', () => {
|
|
2293
|
+
this.log.debug('WebSocketServer client disconnected');
|
|
2294
|
+
if (this.webSocketServer?.clients.size === 0) {
|
|
2295
|
+
this.log.setGlobalCallback(undefined);
|
|
2296
|
+
this.log.debug('WebSocketServer deactivated logger callback');
|
|
2297
|
+
}
|
|
2298
|
+
});
|
|
2299
|
+
ws.on('error', (error) => {
|
|
2300
|
+
this.log.error(`WebSocketServer error: ${error}`);
|
|
2301
|
+
});
|
|
2302
|
+
});
|
|
2185
2303
|
// Serve React build directory
|
|
2304
|
+
this.expressApp = express();
|
|
2186
2305
|
this.expressApp.use(express.static(path.join(this.rootDirectory, 'frontend/build')));
|
|
2187
2306
|
// Endpoint to provide login code
|
|
2188
2307
|
this.expressApp.post('/api/login', express.json(), async (req, res) => {
|
|
@@ -2204,6 +2323,16 @@ export class Matterbridge extends EventEmitter {
|
|
|
2204
2323
|
res.json({ valid: false });
|
|
2205
2324
|
}
|
|
2206
2325
|
});
|
|
2326
|
+
// Endpoint to provide host
|
|
2327
|
+
this.expressApp.get('/api/wsshost', express.json(), async (req, res) => {
|
|
2328
|
+
this.log.debug('The frontend sent /api/wsshost');
|
|
2329
|
+
res.json({ host: os.hostname() });
|
|
2330
|
+
});
|
|
2331
|
+
// Endpoint to provide port
|
|
2332
|
+
this.expressApp.get('/api/wssport', express.json(), async (req, res) => {
|
|
2333
|
+
this.log.debug('The frontend sent /api/wssport');
|
|
2334
|
+
res.json({ port: 8284 });
|
|
2335
|
+
});
|
|
2207
2336
|
// Endpoint to provide manual pairing code
|
|
2208
2337
|
this.expressApp.get('/api/pairing-code', (req, res) => {
|
|
2209
2338
|
this.log.debug('The frontend sent /api/pairing-code');
|
|
@@ -2336,7 +2465,7 @@ export class Matterbridge extends EventEmitter {
|
|
|
2336
2465
|
res.status(400).json({ error: 'No command provided' });
|
|
2337
2466
|
return;
|
|
2338
2467
|
}
|
|
2339
|
-
this.log.
|
|
2468
|
+
this.log.debug(`Received frontend command: ${command}:${param}`);
|
|
2340
2469
|
// Handle the command setpassword from Settings
|
|
2341
2470
|
if (command === 'setpassword') {
|
|
2342
2471
|
const password = param.slice(1, -1); // Remove the first and last characters
|
|
@@ -2374,13 +2503,16 @@ export class Matterbridge extends EventEmitter {
|
|
|
2374
2503
|
}
|
|
2375
2504
|
// Handle the command update from Header
|
|
2376
2505
|
if (command === 'update') {
|
|
2377
|
-
this.log.
|
|
2506
|
+
this.log.info('Updating matterbridge...');
|
|
2507
|
+
//this.wssSendMessage('cmd', 'update', 'Updating matterbridge');
|
|
2378
2508
|
try {
|
|
2379
|
-
await this.spawnCommand('npm', ['install', '-g', 'matterbridge']);
|
|
2509
|
+
await this.spawnCommand('npm', ['install', '-g', 'matterbridge', '--loglevel=verbose']);
|
|
2380
2510
|
this.log.info('Matterbridge has been updated. Full restart required.');
|
|
2511
|
+
//this.wssSendMessage('cmd', 'update', 'Matterbridge has been updated. Full restart required.');
|
|
2381
2512
|
}
|
|
2382
2513
|
catch (error) {
|
|
2383
2514
|
this.log.error('Error updating matterbridge');
|
|
2515
|
+
//this.wssSendMessage('cmd', 'update', 'Error updating matterbridge');
|
|
2384
2516
|
res.json({ message: 'Command received' });
|
|
2385
2517
|
return;
|
|
2386
2518
|
}
|
|
@@ -2389,13 +2521,16 @@ export class Matterbridge extends EventEmitter {
|
|
|
2389
2521
|
// Handle the command installplugin from Home
|
|
2390
2522
|
if (command === 'installplugin') {
|
|
2391
2523
|
param = param.replace(/\*/g, '\\');
|
|
2392
|
-
this.log.
|
|
2524
|
+
this.log.info(`Installing plugin ${plg}${param}${db}...`);
|
|
2525
|
+
//this.wssSendMessage('cmd', 'installplugin', `Installing plugin ${param}`);
|
|
2393
2526
|
try {
|
|
2394
|
-
await this.spawnCommand('npm', ['install', '-g', param]);
|
|
2395
|
-
this.log.info(`Plugin ${plg}${param}${nf} installed.
|
|
2527
|
+
await this.spawnCommand('npm', ['install', '-g', param, '--loglevel=verbose']);
|
|
2528
|
+
this.log.info(`Plugin ${plg}${param}${nf} installed. Full restart required.`);
|
|
2529
|
+
//this.wssSendMessage('cmd', 'installplugin', `Plugin ${param} installed. Full restart required.`);
|
|
2396
2530
|
}
|
|
2397
2531
|
catch (error) {
|
|
2398
2532
|
this.log.error(`Error installing plugin ${plg}${param}${er}`);
|
|
2533
|
+
//this.wssSendMessage('cmd', 'installplugin', `Error installing plugin${param}`);
|
|
2399
2534
|
res.json({ message: 'Command received' });
|
|
2400
2535
|
return;
|
|
2401
2536
|
}
|
|
@@ -2588,7 +2723,6 @@ function restartProcess() {
|
|
|
2588
2723
|
}
|
|
2589
2724
|
|
|
2590
2725
|
import * as WebSocket from 'ws';
|
|
2591
|
-
const globalModulesDir = require('global-modules');
|
|
2592
2726
|
|
|
2593
2727
|
const wss = new WebSocket.Server({ port: 8080 });
|
|
2594
2728
|
|
|
@@ -2607,13 +2741,6 @@ ws.onmessage = (event) => {
|
|
|
2607
2741
|
console.log(`Received message => ${event.data}`);
|
|
2608
2742
|
};
|
|
2609
2743
|
|
|
2610
|
-
*/
|
|
2611
|
-
/*
|
|
2612
|
-
// In Matterbridge
|
|
2613
|
-
global.matterbridgeInstance = Matterbridge.loadInstance();
|
|
2614
|
-
|
|
2615
|
-
// In plugins
|
|
2616
|
-
const matterbridge = global.matterbridgeInstance;
|
|
2617
2744
|
*/
|
|
2618
2745
|
/*
|
|
2619
2746
|
npx create-react-app matterbridge-frontend
|