matterbridge 1.5.0 → 1.5.2

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 (42) hide show
  1. package/CHANGELOG.md +33 -2
  2. package/README-DEV.md +2 -2
  3. package/{README-ADVANCED.md → README-DOCKER.md} +1 -82
  4. package/README-SERVICE.md +96 -0
  5. package/README.md +56 -19
  6. package/dist/cluster/export.d.ts +23 -0
  7. package/dist/cluster/export.d.ts.map +1 -0
  8. package/dist/cluster/export.js +23 -0
  9. package/dist/cluster/export.js.map +1 -0
  10. package/dist/index.d.ts +0 -3
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +2 -0
  13. package/dist/index.js.map +1 -1
  14. package/dist/matterbridge.d.ts +2 -2
  15. package/dist/matterbridge.d.ts.map +1 -1
  16. package/dist/matterbridge.js +28 -13
  17. package/dist/matterbridge.js.map +1 -1
  18. package/dist/matterbridgeDevice.d.ts +190 -114
  19. package/dist/matterbridgeDevice.d.ts.map +1 -1
  20. package/dist/matterbridgeDevice.js +379 -189
  21. package/dist/matterbridgeDevice.js.map +1 -1
  22. package/dist/matterbridgeTypes.d.ts +2 -0
  23. package/dist/matterbridgeTypes.d.ts.map +1 -1
  24. package/dist/pluginManager.d.ts.map +1 -1
  25. package/dist/pluginManager.js +16 -0
  26. package/dist/pluginManager.js.map +1 -1
  27. package/dist/utils/utils.d.ts +1 -6
  28. package/dist/utils/utils.d.ts.map +1 -1
  29. package/dist/utils/utils.js +22 -29
  30. package/dist/utils/utils.js.map +1 -1
  31. package/frontend/build/asset-manifest.json +6 -6
  32. package/frontend/build/index.html +1 -1
  33. package/frontend/build/static/css/main.1cf003ae.css +2 -0
  34. package/frontend/build/static/css/main.1cf003ae.css.map +1 -0
  35. package/frontend/build/static/js/main.cfcfbb06.js +3 -0
  36. package/frontend/build/static/js/main.cfcfbb06.js.map +1 -0
  37. package/package.json +16 -17
  38. package/frontend/build/static/css/main.ee3183e2.css +0 -2
  39. package/frontend/build/static/css/main.ee3183e2.css.map +0 -1
  40. package/frontend/build/static/js/main.4c5271fd.js +0 -3
  41. package/frontend/build/static/js/main.4c5271fd.js.map +0 -1
  42. /package/frontend/build/static/js/{main.4c5271fd.js.LICENSE.txt → main.cfcfbb06.js.LICENSE.txt} +0 -0
@@ -4,9 +4,9 @@
4
4
  * @file matterbridge.ts
5
5
  * @author Luca Liguori
6
6
  * @date 2023-12-29
7
- * @version 1.4.0
7
+ * @version 1.5.2
8
8
  *
9
- * Copyright 2023, 2024 Luca Liguori.
9
+ * Copyright 2023, 2024, 2025 Luca Liguori.
10
10
  *
11
11
  * Licensed under the Apache License, Version 2.0 (the "License");
12
12
  * you may not use this file except in compliance with the License.
@@ -38,6 +38,8 @@ import { AnsiLogger, UNDERLINE, UNDERLINEOFF, YELLOW, db, debugStringify, string
38
38
  import { MatterbridgeDevice } from './matterbridgeDevice.js';
39
39
  import { BridgedDeviceBasicInformation, BridgedDeviceBasicInformationCluster } from './cluster/BridgedDeviceBasicInformationCluster.js';
40
40
  import { logInterfaces, wait, waiter, createZip } from './utils/utils.js';
41
+ import { PluginManager } from './pluginManager.js';
42
+ import { DeviceManager } from './deviceManager.js';
41
43
  // @project-chip/matter-node.js
42
44
  import { CommissioningController, CommissioningServer, MatterServer } from '@project-chip/matter-node.js';
43
45
  import { BasicInformationCluster, ClusterServer, FixedLabelCluster, GeneralCommissioning, PowerSourceCluster, SwitchCluster, ThreadNetworkDiagnosticsCluster, getClusterNameById } from '@project-chip/matter-node.js/cluster';
@@ -48,8 +50,6 @@ import { ManualPairingCodeCodec, QrCodeSchema } from '@project-chip/matter-node.
48
50
  import { StorageBackendDisk, StorageBackendJsonFile, StorageManager } from '@project-chip/matter-node.js/storage';
49
51
  import { getParameter, getIntParameter, hasParameter } from '@project-chip/matter-node.js/util';
50
52
  import { CryptoNode } from '@project-chip/matter-node.js/crypto';
51
- import { PluginManager } from './pluginManager.js';
52
- import { DeviceManager } from './deviceManager.js';
53
53
  // Default colors
54
54
  const plg = '\u001B[38;5;33m';
55
55
  const dev = '\u001B[38;5;79m';
@@ -94,6 +94,8 @@ export class Matterbridge extends EventEmitter {
94
94
  fileLogger: false,
95
95
  matterLoggerLevel: Level.INFO,
96
96
  matterFileLogger: false,
97
+ restartRequired: false,
98
+ refreshRequired: false,
97
99
  };
98
100
  homeDirectory = '';
99
101
  rootDirectory = '';
@@ -378,6 +380,8 @@ export class Matterbridge extends EventEmitter {
378
380
  - list: list the registered plugins
379
381
  - loginterfaces: log the network interfaces (usefull for finding the name of the interface to use with -mdnsinterface option)
380
382
  - logstorage: log the node storage
383
+ - sudo: force the use of sudo to install or update packages
384
+ - nosudo: force not to use sudo to install or update packages
381
385
  - ssl: enable SSL for the frontend and WebSockerServer (certificates in .matterbridge/certs directory cert.pem, key.pem and ca.pem (optional))
382
386
  - add [plugin path]: register the plugin from the given absolute or relative path
383
387
  - add [plugin name]: register the globally installed plugin with the given name
@@ -2382,7 +2386,10 @@ export class Matterbridge extends EventEmitter {
2382
2386
  args.splice(0, args.length, '/c', argstring);
2383
2387
  command = 'cmd.exe';
2384
2388
  }
2385
- if (process.platform === 'linux' && command === 'npm' && !hasParameter('docker')) {
2389
+ // Decide when using sudo on linux
2390
+ // When you need sudo: Spawn stderr: npm error Error: EACCES: permission denied
2391
+ // When you don't need sudo: Failed to start child process "npm install -g matterbridge-eve-door": spawn sudo ENOENT
2392
+ if (hasParameter('sudo') || (process.platform === 'linux' && command === 'npm' && !hasParameter('docker') && !hasParameter('nosudo'))) {
2386
2393
  args.unshift(command);
2387
2394
  command = 'sudo';
2388
2395
  }
@@ -2392,44 +2399,48 @@ export class Matterbridge extends EventEmitter {
2392
2399
  stdio: ['inherit', 'pipe', 'pipe'],
2393
2400
  });
2394
2401
  childProcess.on('error', (err) => {
2395
- this.log.error(`Failed to start child process: ${err.message}`);
2396
- reject(err); // Reject the promise on error
2402
+ this.log.error(`Failed to start child process "${cmdLine}": ${err.message}`);
2403
+ reject(err);
2397
2404
  });
2398
2405
  childProcess.on('close', (code, signal) => {
2399
2406
  this.wssSendMessage('spawn', this.log.now(), 'Matterbridge:spawn', `child process closed with code ${code} and signal ${signal}`);
2400
2407
  if (code === 0) {
2401
2408
  if (cmdLine.startsWith('npm install -g'))
2402
2409
  this.log.notice(`${cmdLine.replace('npm install -g ', '')} installed correctly`);
2410
+ this.log.debug(`Child process "${cmdLine}" closed with code ${code} and signal ${signal}`);
2403
2411
  resolve();
2404
2412
  }
2405
2413
  else {
2406
- this.log.error(`Child process stdio streams have closed with code ${code}`);
2407
- reject(new Error(`Child process stdio streams have closed with code ${code}`));
2414
+ this.log.error(`Child process "${cmdLine}" closed with code ${code} and signal ${signal}`);
2415
+ reject(new Error(`Child process "${cmdLine}" closed with code ${code} and signal ${signal}`));
2408
2416
  }
2409
2417
  });
2410
2418
  childProcess.on('exit', (code, signal) => {
2411
2419
  this.wssSendMessage('spawn', this.log.now(), 'Matterbridge:spawn', `child process exited with code ${code} and signal ${signal}`);
2412
2420
  if (code === 0) {
2421
+ this.log.debug(`Child process "${cmdLine}" exited with code ${code} and signal ${signal}`);
2413
2422
  resolve();
2414
2423
  }
2415
2424
  else {
2416
- this.log.error(`Child process exited with code ${code} and signal ${signal}`);
2417
- reject(new Error(`Child process exited with code ${code} and signal ${signal}`));
2425
+ this.log.error(`Child process "${cmdLine}" exited with code ${code} and signal ${signal}`);
2426
+ reject(new Error(`Child process "${cmdLine}" exited with code ${code} and signal ${signal}`));
2418
2427
  }
2419
2428
  });
2420
2429
  childProcess.on('disconnect', () => {
2421
- this.log.debug('Child process has been disconnected from the parent');
2430
+ this.log.debug(`Child process "${cmdLine}" has been disconnected from the parent`);
2422
2431
  resolve();
2423
2432
  });
2424
2433
  if (childProcess.stdout) {
2425
2434
  childProcess.stdout.on('data', (data) => {
2426
2435
  const message = data.toString().trim();
2436
+ this.log.debug(`Spawn stdout: ${message}`);
2427
2437
  this.wssSendMessage('spawn', this.log.now(), 'Matterbridge:spawn', message);
2428
2438
  });
2429
2439
  }
2430
2440
  if (childProcess.stderr) {
2431
2441
  childProcess.stderr.on('data', (data) => {
2432
2442
  const message = data.toString().trim();
2443
+ this.log.debug(`Spawn stderr: ${message}`);
2433
2444
  this.wssSendMessage('spawn', this.log.now(), 'Matterbridge:spawn', message);
2434
2445
  });
2435
2446
  }
@@ -2882,6 +2893,7 @@ export class Matterbridge extends EventEmitter {
2882
2893
  // Handle the command setbridgemode from Settings
2883
2894
  if (command === 'setbridgemode') {
2884
2895
  this.log.debug(`setbridgemode: ${param}`);
2896
+ this.matterbridgeInformation.restartRequired = true;
2885
2897
  await this.nodeContext?.set('bridgeMode', param);
2886
2898
  res.json({ message: 'Command received' });
2887
2899
  return;
@@ -3034,6 +3046,7 @@ export class Matterbridge extends EventEmitter {
3034
3046
  this.log.error('Error updating matterbridge');
3035
3047
  }
3036
3048
  await this.updateProcess();
3049
+ this.matterbridgeInformation.restartRequired = true;
3037
3050
  res.json({ message: 'Command received' });
3038
3051
  return;
3039
3052
  }
@@ -3051,6 +3064,7 @@ export class Matterbridge extends EventEmitter {
3051
3064
  return;
3052
3065
  this.plugins.saveConfigFromJson(plugin, req.body);
3053
3066
  }
3067
+ this.matterbridgeInformation.restartRequired = true;
3054
3068
  res.json({ message: 'Command received' });
3055
3069
  return;
3056
3070
  }
@@ -3066,7 +3080,8 @@ export class Matterbridge extends EventEmitter {
3066
3080
  catch (error) {
3067
3081
  this.log.error(`Error installing plugin ${plg}${param}${er}`);
3068
3082
  }
3069
- // Also add the plugin to matterbridge
3083
+ this.matterbridgeInformation.restartRequired = true;
3084
+ // Also add the plugin to matterbridge so no return!
3070
3085
  // res.json({ message: 'Command received' });
3071
3086
  // return;
3072
3087
  }