matterbridge 2.0.0-edge1 → 2.0.0

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.
Files changed (67) hide show
  1. package/CHANGELOG.md +15 -2
  2. package/dist/cli.d.ts +25 -0
  3. package/dist/cli.js +0 -0
  4. package/dist/cluster/export.d.ts +2 -0
  5. package/dist/defaultConfigSchema.d.ts +27 -0
  6. package/dist/deviceManager.d.ts +3 -3
  7. package/dist/deviceManager.d.ts.map +1 -1
  8. package/dist/deviceManager.js +2 -2
  9. package/dist/deviceManager.js.map +1 -1
  10. package/dist/frontend.d.ts +3 -3
  11. package/dist/frontend.d.ts.map +1 -1
  12. package/dist/frontend.js +60 -21
  13. package/dist/frontend.js.map +1 -1
  14. package/dist/index.d.ts +34 -0
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +2 -4
  17. package/dist/index.js.map +1 -1
  18. package/dist/logger/export.d.ts +2 -0
  19. package/dist/matter/export.d.ts +10 -0
  20. package/dist/matterbridge.d.ts +21 -22
  21. package/dist/matterbridge.d.ts.map +1 -1
  22. package/dist/matterbridge.js +68 -54
  23. package/dist/matterbridge.js.map +1 -1
  24. package/dist/matterbridgeAccessoryPlatform.d.ts +39 -0
  25. package/dist/matterbridgeAccessoryPlatform.d.ts.map +1 -1
  26. package/dist/matterbridgeBehaviors.d.ts +870 -30
  27. package/dist/matterbridgeBehaviors.d.ts.map +1 -1
  28. package/dist/matterbridgeBehaviors.js +18 -3
  29. package/dist/matterbridgeBehaviors.js.map +1 -1
  30. package/dist/matterbridgeDeviceTypes.d.ts +72 -4
  31. package/dist/matterbridgeDeviceTypes.d.ts.map +1 -1
  32. package/dist/matterbridgeDeviceTypes.js +110 -3
  33. package/dist/matterbridgeDeviceTypes.js.map +1 -1
  34. package/dist/matterbridgeDynamicPlatform.d.ts +39 -0
  35. package/dist/matterbridgeDynamicPlatform.d.ts.map +1 -1
  36. package/dist/matterbridgeEndpoint.d.ts +9155 -68
  37. package/dist/matterbridgeEndpoint.d.ts.map +1 -1
  38. package/dist/matterbridgeEndpoint.js +115 -23
  39. package/dist/matterbridgeEndpoint.js.map +1 -1
  40. package/dist/matterbridgeEndpointDefault.d.ts +2 -0
  41. package/dist/matterbridgeEndpointDefault.d.ts.map +1 -0
  42. package/dist/matterbridgeEndpointDefault.js +159 -0
  43. package/dist/matterbridgeEndpointDefault.js.map +1 -0
  44. package/dist/matterbridgePlatform.d.ts +26 -16
  45. package/dist/matterbridgePlatform.d.ts.map +1 -1
  46. package/dist/matterbridgePlatform.js +8 -7
  47. package/dist/matterbridgePlatform.js.map +1 -1
  48. package/dist/matterbridgeTypes.d.ts +167 -0
  49. package/dist/matterbridgeTypes.d.ts.map +1 -1
  50. package/dist/pluginManager.d.ts +2 -2
  51. package/dist/pluginManager.d.ts.map +1 -1
  52. package/dist/pluginManager.js +9 -16
  53. package/dist/pluginManager.js.map +1 -1
  54. package/dist/storage/export.d.ts +2 -0
  55. package/dist/utils/colorUtils.d.ts +61 -0
  56. package/dist/utils/export.d.ts +3 -0
  57. package/dist/utils/utils.d.ts +1 -1
  58. package/dist/utils/utils.d.ts.map +1 -1
  59. package/dist/utils/utils.js +8 -9
  60. package/dist/utils/utils.js.map +1 -1
  61. package/frontend/build/asset-manifest.json +3 -3
  62. package/frontend/build/index.html +1 -1
  63. package/frontend/build/static/js/{main.ea28015b.js → main.6df4ebe4.js} +3 -3
  64. package/frontend/build/static/js/{main.ea28015b.js.map → main.6df4ebe4.js.map} +1 -1
  65. package/npm-shrinkwrap.json +16 -13
  66. package/package.json +2 -2
  67. /package/frontend/build/static/js/{main.ea28015b.js.LICENSE.txt → main.6df4ebe4.js.LICENSE.txt} +0 -0
package/CHANGELOG.md CHANGED
@@ -16,16 +16,17 @@ Tamer (https://github.com/tammeryousef1006) has created the Matterbridge Discord
16
16
  ### Breaking Changes
17
17
 
18
18
  Starting from v. 2.0.0 Matterbridge is running only in mode edge (no parameter needed).
19
- The legacy old api have been completely removed.
19
+ The legacy old api have been removed.
20
20
 
21
21
  The frontend has a new dark and light mode. The dark mode is now the default mode.
22
22
  It is possible to change the mode (Classic, Dark or Light) in Settings, Matterbridge settings.
23
23
 
24
- ## [2.0.0-edge.1] - 2025-01-14
24
+ ## [2.0.0] - 2025-01-20
25
25
 
26
26
  ### Added
27
27
 
28
28
  - [behavior]: Added MatterbridgeValveConfigurationAndControlServer behavior with open close command.
29
+ - [matterbridge]: Added /memory endpoint for debugging memory use.
29
30
 
30
31
  ### Changed
31
32
 
@@ -33,8 +34,20 @@ It is possible to change the mode (Classic, Dark or Light) in Settings, Matterbr
33
34
  - [factoryreset]: Now it deletes also the backup files and backup directories.
34
35
  - [mattebridge]: Restyled the Matterbridge class and created the Frontend class that manages the frontend express and websocket api calls.
35
36
  - [frontend]: Frontend v.2.3.12.
37
+ - [iconView]: Improved render for energySensor adding voltage, current and power.
38
+ - [iconView]: Improved render for PowerSource adding battery voltage.
39
+ - [jest]: Refactor all tests for edge.
40
+ - [frontend]: WebSocketProvider added a startTimeout of 300 sec. to start ping.
41
+ - [frontend]: WebSocketProvider changed pingIntervalSeconds to 60 sec. and offlineTimeoutSeconds to 50 sec.
42
+ - [frontend]: Search on select is no more case sensitive.
43
+ - [matterbridge]: Deferred memory intensive tasks after initialization.
44
+ - [package]: Optimized all imports from matter.js.
36
45
  - [package]: Update dependencies.
37
46
 
47
+ ### Fixed
48
+
49
+ - [sessions]: Fixed the case when Active session was not reporting correctly.
50
+
38
51
  <a href="https://www.buymeacoffee.com/luligugithub">
39
52
  <img src="./yellow-button.png" alt="Buy me a coffee" width="120">
40
53
  </a>
package/dist/cli.d.ts ADDED
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * This file contains the CLI entry point of Matterbridge.
4
+ *
5
+ * @file cli.ts
6
+ * @author Luca Liguori
7
+ * @date 2023-12-29
8
+ * @version 1.0.11
9
+ *
10
+ * Copyright 2023, 2024, 2025 Luca Liguori.
11
+ *
12
+ * Licensed under the Apache License, Version 2.0 (the "License");
13
+ * you may not use this file except in compliance with the License.
14
+ * You may obtain a copy of the License at
15
+ *
16
+ * http://www.apache.org/licenses/LICENSE-2.0
17
+ *
18
+ * Unless required by applicable law or agreed to in writing, software
19
+ * distributed under the License is distributed on an "AS IS" BASIS,
20
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
+ * See the License for the specific language governing permissions and
22
+ * limitations under the License. *
23
+ */
24
+ export {};
25
+ //# sourceMappingURL=cli.d.ts.map
package/dist/cli.js CHANGED
File without changes
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=export.d.ts.map
@@ -0,0 +1,27 @@
1
+ /**
2
+ * This file contains the default config for the plugins.
3
+ *
4
+ * @file defaultConfigSchema.ts
5
+ * @author Luca Liguori
6
+ * @date 2024-05-07
7
+ * @version 1.0.1
8
+ *
9
+ * Copyright 2024, 2025, 2026 Luca Liguori.
10
+ *
11
+ * Licensed under the Apache License, Version 2.0 (the "License");
12
+ * you may not use this file except in compliance with the License.
13
+ * You may obtain a copy of the License at
14
+ *
15
+ * http://www.apache.org/licenses/LICENSE-2.0
16
+ *
17
+ * Unless required by applicable law or agreed to in writing, software
18
+ * distributed under the License is distributed on an "AS IS" BASIS,
19
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
+ * See the License for the specific language governing permissions and
21
+ * limitations under the License. *
22
+ */
23
+ import { PlatformConfig } from './matterbridgePlatform.js';
24
+ export declare const zigbee2mqtt_config: PlatformConfig;
25
+ export declare const somfytahoma_config: PlatformConfig;
26
+ export declare const shelly_config: PlatformConfig;
27
+ //# sourceMappingURL=defaultConfigSchema.d.ts.map
@@ -20,12 +20,11 @@
20
20
  * See the License for the specific language governing permissions and
21
21
  * limitations under the License. *
22
22
  */
23
- import { LogLevel } from 'node-ansi-logger';
24
- import { NodeStorage } from 'node-persist-manager';
23
+ import { LogLevel } from './logger/export.js';
24
+ import { NodeStorage } from './storage/export.js';
25
25
  import { Matterbridge } from './matterbridge.js';
26
26
  import { MatterbridgeEndpoint } from './matterbridgeEndpoint.js';
27
27
  export declare class DeviceManager {
28
- [x: number]: () => any;
29
28
  private readonly _devices;
30
29
  private readonly matterbridge;
31
30
  private readonly nodeContext;
@@ -39,6 +38,7 @@ export declare class DeviceManager {
39
38
  remove(device: MatterbridgeEndpoint): boolean;
40
39
  clear(): void;
41
40
  array(): MatterbridgeEndpoint[];
41
+ [Symbol.iterator](): MapIterator<MatterbridgeEndpoint>;
42
42
  forEach(callback: (device: MatterbridgeEndpoint) => Promise<void>): Promise<void>;
43
43
  get logLevel(): LogLevel;
44
44
  set logLevel(logLevel: LogLevel);
@@ -1 +1 @@
1
- {"version":3,"file":"deviceManager.d.ts","sourceRoot":"","sources":["../src/deviceManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,EAAwB,QAAQ,EAAmB,MAAM,kBAAkB,CAAC;AACnF,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGnD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAGjE,qBAAa,aAAa;;IACxB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA2C;IACpE,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAe;IAC5C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAc;IAC1C,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAa;gBAErB,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW;IAOhE,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAI9B,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,oBAAoB,GAAG,SAAS;IAIvD,GAAG,CAAC,MAAM,E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K,IAAI,IAAI;IAIb,KAAK,IAAI,oBAAoB,EAAE;IAI/B,CAAC,MAAM,CAAC,QAAQ,CAAC;IAIX,OAAO,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,oBAAoB,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAYvF,IAAI,QAAQ,IAAI,QAAQ,CAEvB;IAED,IAAI,QAAQ,CAAC,QAAQ,EAAE,QAAQ,EAE9B;CAgCF"}
@@ -21,7 +21,7 @@
21
21
  * limitations under the License. *
22
22
  */
23
23
  // NodeStorage and AnsiLogger modules
24
- import { AnsiLogger, BLUE, er, TimestampFormat } from 'node-ansi-logger';
24
+ import { AnsiLogger, BLUE, er } from './logger/export.js';
25
25
  import { dev } from './matterbridgeTypes.js';
26
26
  export class DeviceManager {
27
27
  _devices = new Map();
@@ -31,7 +31,7 @@ export class DeviceManager {
31
31
  constructor(matterbridge, nodeContext) {
32
32
  this.matterbridge = matterbridge;
33
33
  this.nodeContext = nodeContext;
34
- this.log = new AnsiLogger({ logName: 'DeviceManager', logTimestampFormat: TimestampFormat.TIME_MILLIS, logLevel: matterbridge.log.logLevel });
34
+ this.log = new AnsiLogger({ logName: 'DeviceManager', logTimestampFormat: 4 /* TimestampFormat.TIME_MILLIS */, logLevel: matterbridge.log.logLevel });
35
35
  this.log.debug('Matterbridge device manager starting...');
36
36
  }
37
37
  get length() {
@@ -1 +1 @@
1
- {"version":3,"file":"deviceManager.js","sourceRoot":"","sources":["../src/deviceManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,qCAAqC;AACrC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,EAAY,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAMnF,OAAO,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAE7C,MAAM,OAAO,aAAa;IACP,QAAQ,GAAG,IAAI,GAAG,EAAgC,CAAC;IACnD,YAAY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AG,CAAC,QAAQ,CAAC;IAC3B,CAAC;IAED,IAAI,QAAQ,CAAC,QAAkB;QAC7B,IAAI,CAAC,GAAG,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC/B,CAAC;CAgCF"}
@@ -53,8 +53,8 @@ export declare class Frontend {
53
53
  private httpsServer;
54
54
  private webSocketServer;
55
55
  constructor(matterbridge: Matterbridge);
56
- start(port?: number): any;
57
- stop(): any;
56
+ start(port?: number): Promise<void>;
57
+ stop(): Promise<void>;
58
58
  /**
59
59
  * Retrieves the cluster text description from a given device.
60
60
  * @param {MatterbridgeDevice} device - The MatterbridgeDevice object.
@@ -76,7 +76,7 @@ export declare class Frontend {
76
76
  */
77
77
  private wsMessageHandler;
78
78
  /**
79
- * Sends a WebSocket message to all connected clients.
79
+ * Sends a WebSocket message to all connected clients. The function is called by AnsiLogger.setGlobalCallback.
80
80
  *
81
81
  * @param {string} level - The logger level of the message: debug info notice warn error fatal...
82
82
  * @param {string} time - The time string of the message
@@ -1 +1 @@
1
- {"version":3,"file":"frontend.d.ts","sourceRoot":"","sources":["../src/frontend.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAmBH,OAAO,EAA2B,oBAAoB,EAAyB,MAAM,wBAAwB,CAAC;AAC9G,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE;;;GAGG;AACH,eAAO,MAAM,SAAS,IAAI,CAAC;AAE3B;;;GAGG;AACH,eAAO,MAAM,oBAAoB,IAAI,CAAC;AAEtC;;;GAGG;AACH,eAAO,MAAM,oBAAoB,IAAI,CAAC;AAEtC;;;;GAIG;AACH,qBAAa,QAAQ;IACnB,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,GAAG,CAAa;IACxB,OAAO,CAAC,IAAI,CAAQ;IACpB,OAAO,CAAC,eAAe,CAAS;IAEhC,OAAO,CAAC,UAAU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AA2B;IAC9C,OAAO,CAAC,eAAe,CAA8B;gBAEzC,YAAY,EAAE,YAAY;IAKhC,KAAK,CAAC,IAAI,SAAO;IA8zBjB,IAAI;IA2CV;;;;OAIG;IACH,SAAS,CAAC,wBAAwB,CAAC,MAAM,EAAE,oBAAoB,GAAG,MAAM;IAmFxE;;;OAGG;IACG,wBAAwB,IAAI,OAAO,CAAC,oBAAoB,EAAE,CAAC;IA+BjE;;;;;;;OAOG;YACW,gBAAgB;IAoP9B;;;;;;;OAOG;IACH,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;IAuCzE;;;OAGG;IACH,sBAAsB;IAWtB;;;OAGG;IACH,sBAAsB;CAUvB"}
package/dist/frontend.js CHANGED
@@ -31,7 +31,7 @@ import os from 'os';
31
31
  import path from 'path';
32
32
  import { promises as fs } from 'fs';
33
33
  // AnsiLogger module
34
- import { AnsiLogger, CYAN, db, debugStringify, er, LogLevel, nf, rs, stringify, TimestampFormat, UNDERLINE, UNDERLINEOFF, wr, YELLOW } from 'node-ansi-logger';
34
+ import { AnsiLogger, CYAN, db, debugStringify, er, nf, rs, stringify, UNDERLINE, UNDERLINEOFF, wr, YELLOW } from './logger/export.js';
35
35
  // Matterbridge
36
36
  import { createZip, hasParameter, isValidNumber, isValidObject, isValidString } from './utils/utils.js';
37
37
  import { plg } from './matterbridgeTypes.js';
@@ -67,7 +67,7 @@ export class Frontend {
67
67
  webSocketServer;
68
68
  constructor(matterbridge) {
69
69
  this.matterbridge = matterbridge;
70
- this.log = new AnsiLogger({ logName: 'Frontend', logTimestampFormat: TimestampFormat.TIME_MILLIS, logLevel: hasParameter('debug') ? LogLevel.DEBUG : LogLevel.INFO });
70
+ this.log = new AnsiLogger({ logName: 'Frontend', logTimestampFormat: 4 /* TimestampFormat.TIME_MILLIS */, logLevel: hasParameter('debug') ? "debug" /* LogLevel.DEBUG */ : "info" /* LogLevel.INFO */ });
71
71
  }
72
72
  async start(port = 8283) {
73
73
  this.port = port;
@@ -183,7 +183,7 @@ export class Frontend {
183
183
  this.webSocketServer = new WebSocketServer(hasParameter('ssl') ? { server: this.httpsServer } : { server: this.httpServer });
184
184
  this.webSocketServer.on('connection', (ws, request) => {
185
185
  const clientIp = request.socket.remoteAddress;
186
- AnsiLogger.setGlobalCallback(this.wssSendMessage.bind(this), LogLevel.DEBUG);
186
+ AnsiLogger.setGlobalCallback(this.wssSendMessage.bind(this), "debug" /* LogLevel.DEBUG */);
187
187
  this.log.info(`WebSocketServer client "${clientIp}" connected to Matterbridge`);
188
188
  ws.on('message', (message) => {
189
189
  this.wsMessageHandler(ws, message);
@@ -251,6 +251,48 @@ export class Frontend {
251
251
  };
252
252
  res.status(200).json(healthStatus);
253
253
  });
254
+ // Endpoint to provide memory usage details
255
+ this.expressApp.get('/memory', async (req, res) => {
256
+ this.log.debug('Express received /memory');
257
+ // Function to format bytes to KB or MB
258
+ const formatMemoryUsage = (bytes) => {
259
+ const kb = bytes / 1024;
260
+ const mb = kb / 1024;
261
+ return mb >= 1 ? `${mb.toFixed(2)} MB` : `${kb.toFixed(2)} KB`;
262
+ };
263
+ // Memory usage from process
264
+ const memoryUsageRaw = process.memoryUsage();
265
+ const memoryUsage = {
266
+ rss: formatMemoryUsage(memoryUsageRaw.rss),
267
+ heapTotal: formatMemoryUsage(memoryUsageRaw.heapTotal),
268
+ heapUsed: formatMemoryUsage(memoryUsageRaw.heapUsed),
269
+ external: formatMemoryUsage(memoryUsageRaw.external),
270
+ arrayBuffers: formatMemoryUsage(memoryUsageRaw.arrayBuffers),
271
+ };
272
+ // V8 heap statistics
273
+ const { default: v8 } = await import('node:v8');
274
+ const heapStatsRaw = v8.getHeapStatistics();
275
+ const heapSpacesRaw = v8.getHeapSpaceStatistics();
276
+ // Format heapStats
277
+ const heapStats = Object.fromEntries(Object.entries(heapStatsRaw).map(([key, value]) => [key, formatMemoryUsage(value)]));
278
+ // Format heapSpaces
279
+ const heapSpaces = heapSpacesRaw.map((space) => ({
280
+ ...space,
281
+ space_size: formatMemoryUsage(space.space_size),
282
+ space_used_size: formatMemoryUsage(space.space_used_size),
283
+ space_available_size: formatMemoryUsage(space.space_available_size),
284
+ physical_space_size: formatMemoryUsage(space.physical_space_size),
285
+ }));
286
+ const { default: module } = await import('module');
287
+ const loadedModules = module._cache ? Object.keys(module._cache).sort() : [];
288
+ const memoryReport = {
289
+ memoryUsage,
290
+ heapStats,
291
+ heapSpaces,
292
+ loadedModules,
293
+ };
294
+ res.status(200).json(memoryReport);
295
+ });
254
296
  // Endpoint to provide settings
255
297
  this.expressApp.get('/api/settings', express.json(), async (req, res) => {
256
298
  this.log.debug('The frontend sent /api/settings');
@@ -265,7 +307,6 @@ export class Frontend {
265
307
  this.matterbridge.matterbridgeInformation.matterDiscriminator = await this.matterbridge.nodeContext?.get('matterdiscriminator');
266
308
  this.matterbridge.matterbridgeInformation.matterPasscode = await this.matterbridge.nodeContext?.get('matterpasscode');
267
309
  this.matterbridge.matterbridgeInformation.matterbridgePaired = this.matterbridge.matterbridgePaired;
268
- this.matterbridge.matterbridgeInformation.matterbridgeConnected = this.matterbridge.matterbridgeConnected;
269
310
  this.matterbridge.matterbridgeInformation.matterbridgeQrPairingCode = this.matterbridge.matterbridgeQrPairingCode;
270
311
  this.matterbridge.matterbridgeInformation.matterbridgeManualPairingCode = this.matterbridge.matterbridgeManualPairingCode;
271
312
  this.matterbridge.matterbridgeInformation.matterbridgeFabricInformations = this.matterbridge.matterbridgeFabricInformations;
@@ -427,12 +468,13 @@ export class Frontend {
427
468
  });
428
469
  });
429
470
  // Endpoint to download the matter storage file
430
- this.expressApp.get('/api/download-mjstorage', (req, res) => {
471
+ this.expressApp.get('/api/download-mjstorage', async (req, res) => {
431
472
  this.log.debug('The frontend sent /api/download-mjstorage');
432
- res.download(path.join(this.matterbridge.matterbridgeDirectory, this.matterbridge.matterStorageName), 'matterbridge.json', (error) => {
473
+ await createZip(path.join(os.tmpdir(), `matterbridge.${this.matterbridge.matterStorageName}.zip`), path.join(this.matterbridge.matterbridgeDirectory, this.matterbridge.matterStorageName));
474
+ res.download(path.join(os.tmpdir(), `matterbridge.${this.matterbridge.matterStorageName}.zip`), `matterbridge.${this.matterbridge.matterStorageName}.zip`, (error) => {
433
475
  if (error) {
434
- this.log.error(`Error downloading log file ${this.matterbridge.matterStorageName}: ${error instanceof Error ? error.message : error}`);
435
- res.status(500).send('Error downloading the matter storage file');
476
+ this.log.error(`Error downloading the matter storage matterbridge.${this.matterbridge.matterStorageName}.zip: ${error instanceof Error ? error.message : error}`);
477
+ res.status(500).send('Error downloading the matter storage zip file');
436
478
  }
437
479
  });
438
480
  });
@@ -518,22 +560,22 @@ export class Frontend {
518
560
  if (command === 'setmbloglevel') {
519
561
  this.log.debug('Matterbridge log level:', param);
520
562
  if (param === 'Debug') {
521
- this.log.logLevel = LogLevel.DEBUG;
563
+ this.log.logLevel = "debug" /* LogLevel.DEBUG */;
522
564
  }
523
565
  else if (param === 'Info') {
524
- this.log.logLevel = LogLevel.INFO;
566
+ this.log.logLevel = "info" /* LogLevel.INFO */;
525
567
  }
526
568
  else if (param === 'Notice') {
527
- this.log.logLevel = LogLevel.NOTICE;
569
+ this.log.logLevel = "notice" /* LogLevel.NOTICE */;
528
570
  }
529
571
  else if (param === 'Warn') {
530
- this.log.logLevel = LogLevel.WARN;
572
+ this.log.logLevel = "warn" /* LogLevel.WARN */;
531
573
  }
532
574
  else if (param === 'Error') {
533
- this.log.logLevel = LogLevel.ERROR;
575
+ this.log.logLevel = "error" /* LogLevel.ERROR */;
534
576
  }
535
577
  else if (param === 'Fatal') {
536
- this.log.logLevel = LogLevel.FATAL;
578
+ this.log.logLevel = "fatal" /* LogLevel.FATAL */;
537
579
  }
538
580
  await this.matterbridge.nodeContext?.set('matterbridgeLogLevel', this.log.logLevel);
539
581
  MatterbridgeEndpoint.logLevel = this.log.logLevel;
@@ -541,8 +583,8 @@ export class Frontend {
541
583
  for (const plugin of this.matterbridge.plugins) {
542
584
  if (!plugin.platform || !plugin.platform.config)
543
585
  continue;
544
- plugin.platform.log.logLevel = plugin.platform.config.debug ? LogLevel.DEBUG : this.log.logLevel;
545
- await plugin.platform.onChangeLoggerLevel(plugin.platform.config.debug ? LogLevel.DEBUG : this.log.logLevel);
586
+ plugin.platform.log.logLevel = plugin.platform.config.debug ? "debug" /* LogLevel.DEBUG */ : this.log.logLevel;
587
+ await plugin.platform.onChangeLoggerLevel(plugin.platform.config.debug ? "debug" /* LogLevel.DEBUG */ : this.log.logLevel);
546
588
  }
547
589
  res.json({ message: 'Command received' });
548
590
  return;
@@ -633,7 +675,7 @@ export class Frontend {
633
675
  await this.matterbridge.nodeContext?.set('matterbridgeFileLog', param === 'true');
634
676
  // Create the file logger for matterbridge
635
677
  if (param === 'true')
636
- AnsiLogger.setGlobalLogfile(path.join(this.matterbridge.matterbridgeDirectory, this.matterbridge.matterbrideLoggerFile), LogLevel.DEBUG, true);
678
+ AnsiLogger.setGlobalLogfile(path.join(this.matterbridge.matterbridgeDirectory, this.matterbridge.matterbrideLoggerFile), "debug" /* LogLevel.DEBUG */, true);
637
679
  else
638
680
  AnsiLogger.setGlobalLogfile(undefined);
639
681
  res.json({ message: 'Command received' });
@@ -794,7 +836,6 @@ export class Frontend {
794
836
  plugin.loaded = undefined;
795
837
  plugin.started = undefined;
796
838
  plugin.configured = undefined;
797
- plugin.connected = undefined;
798
839
  plugin.platform = undefined;
799
840
  plugin.registeredDevices = undefined;
800
841
  plugin.addedDevices = undefined;
@@ -1013,7 +1054,6 @@ export class Frontend {
1013
1054
  started: plugin.started,
1014
1055
  configured: plugin.configured,
1015
1056
  paired: plugin.paired,
1016
- connected: plugin.connected,
1017
1057
  fabricInformations: plugin.fabricInformations,
1018
1058
  sessionInformations: plugin.sessionInformations,
1019
1059
  registeredDevices: plugin.registeredDevices,
@@ -1116,7 +1156,6 @@ export class Frontend {
1116
1156
  this.matterbridge.matterbridgeInformation.matterDiscriminator = await this.matterbridge.nodeContext?.get('matterdiscriminator');
1117
1157
  this.matterbridge.matterbridgeInformation.matterPasscode = await this.matterbridge.nodeContext?.get('matterpasscode');
1118
1158
  this.matterbridge.matterbridgeInformation.matterbridgePaired = this.matterbridge.matterbridgePaired;
1119
- this.matterbridge.matterbridgeInformation.matterbridgeConnected = this.matterbridge.matterbridgeConnected;
1120
1159
  this.matterbridge.matterbridgeInformation.matterbridgeQrPairingCode = this.matterbridge.matterbridgeQrPairingCode;
1121
1160
  this.matterbridge.matterbridgeInformation.matterbridgeManualPairingCode = this.matterbridge.matterbridgeManualPairingCode;
1122
1161
  this.matterbridge.matterbridgeInformation.matterbridgeFabricInformations = this.matterbridge.matterbridgeFabricInformations;
@@ -1301,7 +1340,7 @@ export class Frontend {
1301
1340
  }
1302
1341
  }
1303
1342
  /**
1304
- * Sends a WebSocket message to all connected clients.
1343
+ * Sends a WebSocket message to all connected clients. The function is called by AnsiLogger.setGlobalCallback.
1305
1344
  *
1306
1345
  * @param {string} level - The logger level of the message: debug info notice warn error fatal...
1307
1346
  * @param {string} time - The time string of the message