matterbridge 1.1.10 → 1.1.11

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 CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [1.1.11] - 2024-03-15
6
+
7
+ ### Added
8
+
9
+ - [frontend]: Frontend got updated to 0.8.3.
10
+
5
11
  ## [1.1.10] - 2024-03-15
6
12
 
7
13
  ### Added
@@ -41,13 +41,24 @@ interface SystemInformation {
41
41
  */
42
42
  export declare class Matterbridge extends EventEmitter {
43
43
  systemInformation: SystemInformation;
44
+ matterbridgeInformation: {
45
+ homeDirectory: string;
46
+ rootDirectory: string;
47
+ matterbridgeDirectory: string;
48
+ matterbridgePluginDirectory: string;
49
+ globalModulesDirectory: string;
50
+ matterbridgeVersion: string;
51
+ matterbridgeLatestVersion: string;
52
+ bridgeMode: string;
53
+ debugEnabled: boolean;
54
+ };
44
55
  homeDirectory: string;
45
56
  rootDirectory: string;
46
57
  matterbridgeDirectory: string;
47
58
  matterbridgePluginDirectory: string;
59
+ globalModulesDirectory: string;
48
60
  matterbridgeVersion: string;
49
61
  matterbridgeLatestVersion: string;
50
- globalModulesDir: string;
51
62
  bridgeMode: 'bridge' | 'childbridge' | 'controller' | '';
52
63
  debugEnabled: boolean;
53
64
  private log;
@@ -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;AAkElC,UAAU,iBAAiB;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,M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GAAG,OAAO,CAAC,IAAI,CAAC;IAgBhE;;;;;OAKG;YACW,YAAY;IA0B1B;;;;;OAKG;YACW,iBAAiB;IAkB/B;;;OAGG;YACW,WAAW;YASX,qBAAqB;YA+CrB,WAAW;YA6BX,eAAe;YA4Bf,UAAU;IA+CxB;;;;;;;;OAQG;YACW,iBAAiB;YA2JjB,iBAAiB;IAW/B;;;;;;OAMG;IACH,OAAO,CAAC,gCAAgC;IAwBxC;;;;;;;;;;;;;;;;;OAiBG;IACH,OAAO,CAAC,gCAAgC;IAuCxC;;;;;;;;;;OAUG;YACW,uBAAuB;IA4CrC;;;;;OAKG;IACH,OAAO,CAAC,UAAU;IASlB;;;;;;OAMG;IACH,OAAO,CAAC,wBAAwB;IAmHhC;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;IAM1B;;;;OAIG;IACH,OAAO,CAAC,sBAAsB;IAuC9B;;OAEG;YACW,UAAU;IAcxB;;;;OAIG;YACW,gBAAgB;IAY9B;;;OAGG;YACW,oBAAoB;IAYlC;;OAEG;YACW,oBAAoB;IAuIlC,OAAO,CAAC,wBAAwB;IAqBhC,OAAO,CAAC,wBAAwB;IAkBhC;;;;OAIG;IACG,kBAAkB,CAAC,IAAI,GAAE,MAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAwM5D;;;;OAIG;IACH,OAAO,CAAC,wBAAwB;CAsBjC"}
@@ -30,7 +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 { CommissioningServer, MatterServer } from '@project-chip/matter-node.js';
33
+ import { CommissioningController, CommissioningServer, MatterServer } from '@project-chip/matter-node.js';
34
34
  import { BasicInformationCluster, BridgedDeviceBasicInformationCluster, ClusterServer } from '@project-chip/matter-node.js/cluster';
35
35
  import { DeviceTypeId, VendorId } from '@project-chip/matter-node.js/datatype';
36
36
  import { Aggregator, DeviceTypes } from '@project-chip/matter-node.js/device';
@@ -59,13 +59,24 @@ export class Matterbridge extends EventEmitter {
59
59
  freeMemory: '',
60
60
  systemUptime: '',
61
61
  };
62
+ matterbridgeInformation = {
63
+ homeDirectory: '',
64
+ rootDirectory: '',
65
+ matterbridgeDirectory: '',
66
+ matterbridgePluginDirectory: '',
67
+ globalModulesDirectory: '',
68
+ matterbridgeVersion: '',
69
+ matterbridgeLatestVersion: '',
70
+ bridgeMode: '',
71
+ debugEnabled: false,
72
+ };
62
73
  homeDirectory = '';
63
74
  rootDirectory = '';
64
75
  matterbridgeDirectory = '';
65
76
  matterbridgePluginDirectory = '';
77
+ globalModulesDirectory = '';
66
78
  matterbridgeVersion = '';
67
79
  matterbridgeLatestVersion = '';
68
- globalModulesDir = '';
69
80
  bridgeMode = '';
70
81
  debugEnabled = false;
71
82
  log;
@@ -272,6 +283,12 @@ export class Matterbridge extends EventEmitter {
272
283
  MatterbridgeDevice.bridgeMode = 'childbridge';
273
284
  await this.testStartMatterBridge(); // No await do it asyncronously
274
285
  }
286
+ if (hasParameter('controller')) {
287
+ this.bridgeMode = 'controller';
288
+ this.log.info('Creating mattercontrollerContext: mattercontrollerContext');
289
+ this.mattercontrollerContext = this.storageManager?.createContext('mattercontrollerContext');
290
+ await this.startMatterBridge();
291
+ }
275
292
  if (hasParameter('bridge')) {
276
293
  this.bridgeMode = 'bridge';
277
294
  MatterbridgeDevice.bridgeMode = 'bridge';
@@ -326,8 +343,8 @@ export class Matterbridge extends EventEmitter {
326
343
  }
327
344
  if (!packageJsonExists) {
328
345
  this.log.debug(`Package.json not found at ${packageJsonPath}`);
329
- this.log.debug(`Trying at ${this.globalModulesDir}`);
330
- packageJsonPath = path.join(this.globalModulesDir, pluginPath);
346
+ this.log.debug(`Trying at ${this.globalModulesDirectory}`);
347
+ packageJsonPath = path.join(this.globalModulesDirectory, pluginPath);
331
348
  //this.log.debug(`Got ${packageJsonPath}`);
332
349
  }
333
350
  try {
@@ -449,7 +466,7 @@ export class Matterbridge extends EventEmitter {
449
466
  this.log.info(message);
450
467
  process.removeAllListeners('SIGINT');
451
468
  process.removeAllListeners('SIGTERM');
452
- // Callint the shutdown functions with a reason
469
+ // Calling the shutdown functions with a reason
453
470
  for (const plugin of this.registeredPlugins) {
454
471
  if (plugin.platform)
455
472
  await plugin.platform.onShutdown('Matterbridge is closing: ' + message);
@@ -487,17 +504,20 @@ export class Matterbridge extends EventEmitter {
487
504
  // Closing storage
488
505
  await this.stopStorage();
489
506
  // Serialize registeredDevices
490
- if (this.nodeContext) {
507
+ if (this.nodeStorage && this.nodeContext) {
491
508
  this.log.info('Saving registered devices...');
492
509
  const serializedRegisteredDevices = [];
493
510
  this.registeredDevices.forEach((registeredDevice) => {
494
511
  serializedRegisteredDevices.push(registeredDevice.device.serialize(registeredDevice.plugin));
495
512
  });
496
- //console.log('serializedRegisteredDevices:', serializedRegisteredDevices);
497
513
  await this.nodeContext.set('devices', serializedRegisteredDevices);
498
514
  this.log.info('Saved registered devices');
499
515
  // Clear nodeContext and nodeStorage (they just need 1000ms to write the data to disk)
516
+ this.log.debug('Closing node storage context...');
517
+ this.nodeContext.close();
500
518
  this.nodeContext = undefined;
519
+ this.log.debug('Closing node storage manager...');
520
+ this.nodeStorage.close();
501
521
  this.nodeStorage = undefined;
502
522
  }
503
523
  else {
@@ -505,6 +525,7 @@ export class Matterbridge extends EventEmitter {
505
525
  }
506
526
  this.registeredPlugins = [];
507
527
  this.registeredDevices = [];
528
+ this.log.info('Waiting for matter to deliver last messages...');
508
529
  const cleanupTimeout2 = setTimeout(async () => {
509
530
  if (restart) {
510
531
  this.log.info('Cleanup completed. Restarting...');
@@ -934,13 +955,33 @@ export class Matterbridge extends EventEmitter {
934
955
  await this.cleanup('No matter server initialized');
935
956
  return;
936
957
  }
958
+ if (this.bridgeMode === 'controller') {
959
+ this.log.info('Creating matter commissioning controller');
960
+ this.commissioningController = new CommissioningController({
961
+ autoConnect: false,
962
+ });
963
+ this.log.info('Adding matter commissioning controller to matter server');
964
+ await this.matterServer.addCommissioningController(this.commissioningController);
965
+ this.log.info('Starting matter server');
966
+ await this.matterServer.start();
967
+ this.log.info('Matter server started');
968
+ if (hasParameter('discover')) {
969
+ const discover = await this.commissioningController.discoverCommissionableDevices({ productId: 0x8000, deviceType: 0xfff1 });
970
+ console.log(discover);
971
+ }
972
+ this.log.info(`Commissioning controller is already commisioned: ${this.commissioningController.isCommissioned()}`);
973
+ const nodes = this.commissioningController.getCommissionedNodes();
974
+ nodes.forEach(async (nodeId) => {
975
+ this.log.warn(`Connecting to commissioned node: ${nodeId}`);
976
+ });
977
+ }
937
978
  if (this.bridgeMode === 'bridge') {
938
979
  // Plugins are loaded by loadPlugin on startup and plugin.loaded is set to true
939
980
  // Plugins are started and configured by callback when Matterbridge is commissioned
940
981
  this.log.debug(`Creating commissioning server context for ${plg}Matterbridge${db}`);
941
982
  this.matterbridgeContext = this.createCommissioningServerContext('Matterbridge', 'Matterbridge', DeviceTypes.AGGREGATOR.code, 0xfff1, 'Matterbridge', 0x8000, 'Matterbridge aggregator');
942
983
  if (!this.matterbridgeContext) {
943
- this.log.error(`Error creating storage context${er}`);
984
+ this.log.error(`Error creating storage context for ${plg}Matterbridge${er}`);
944
985
  return;
945
986
  }
946
987
  this.log.debug(`Creating commissioning server for ${plg}Matterbridge${db}`);
@@ -951,8 +992,9 @@ export class Matterbridge extends EventEmitter {
951
992
  this.commissioningServer.addDevice(this.matterAggregator);
952
993
  this.log.debug('Adding matterbridge commissioning server to matter server');
953
994
  await this.matterServer.addCommissioningServer(this.commissioningServer, { uniqueStorageKey: 'Matterbridge' });
954
- this.log.debug('Starting matter server');
995
+ this.log.debug('Starting matter server...');
955
996
  await this.startMatterServer();
997
+ this.log.info('Matter server started');
956
998
  this.showCommissioningQRCode(this.commissioningServer, this.matterbridgeContext, 'Matterbridge');
957
999
  }
958
1000
  if (this.bridgeMode === 'childbridge') {
@@ -1018,7 +1060,7 @@ export class Matterbridge extends EventEmitter {
1018
1060
  });
1019
1061
  if (!allStarted)
1020
1062
  return;
1021
- this.log.info('Starting matter server');
1063
+ this.log.info('Starting matter server...');
1022
1064
  // Setting reachability to true
1023
1065
  this.registeredPlugins.forEach((plugin) => {
1024
1066
  if (!plugin.enabled)
@@ -1035,13 +1077,13 @@ export class Matterbridge extends EventEmitter {
1035
1077
  });
1036
1078
  });
1037
1079
  await this.startMatterServer();
1080
+ this.log.info('Matter server started');
1038
1081
  for (const plugin of this.registeredPlugins) {
1039
1082
  this.showCommissioningQRCode(plugin.commissioningServer, plugin.storageContext, plugin.name);
1040
1083
  }
1041
1084
  Logger.defaultLogLevel = this.debugEnabled ? Level.DEBUG : Level.INFO;
1042
1085
  clearInterval(startMatterInterval);
1043
1086
  }, 1000);
1044
- return;
1045
1087
  }
1046
1088
  }
1047
1089
  async startMatterServer() {
@@ -1107,9 +1149,9 @@ export class Matterbridge extends EventEmitter {
1107
1149
  storageContext.set('serialNumber', storageContext.get('serialNumber', random));
1108
1150
  storageContext.set('uniqueId', storageContext.get('uniqueId', random));
1109
1151
  storageContext.set('softwareVersion', softwareVersion ?? 1);
1110
- storageContext.set('softwareVersionString', softwareVersionString ?? '1.0.0');
1152
+ storageContext.set('softwareVersionString', softwareVersionString ?? '1.0');
1111
1153
  storageContext.set('hardwareVersion', hardwareVersion ?? 1);
1112
- storageContext.set('hardwareVersionString', hardwareVersionString ?? '1.0.0');
1154
+ storageContext.set('hardwareVersionString', hardwareVersionString ?? '1.0');
1113
1155
  return storageContext;
1114
1156
  }
1115
1157
  /**
@@ -1444,16 +1486,20 @@ export class Matterbridge extends EventEmitter {
1444
1486
  this.log.debug(`- System Uptime: ${this.systemInformation.systemUptime}`);
1445
1487
  // Home directory
1446
1488
  this.homeDirectory = os.homedir();
1489
+ this.matterbridgeInformation.homeDirectory = this.homeDirectory;
1447
1490
  this.log.debug(`Home Directory: ${this.homeDirectory}`);
1448
1491
  // Package root directory
1449
1492
  const currentFileDirectory = path.dirname(fileURLToPath(import.meta.url));
1450
1493
  this.rootDirectory = path.resolve(currentFileDirectory, '../');
1494
+ this.matterbridgeInformation.rootDirectory = this.rootDirectory;
1451
1495
  this.log.debug(`Root Directory: ${this.rootDirectory}`);
1452
1496
  // Global node_modules directory
1453
- this.globalModulesDir = await this.getGlobalNodeModules();
1454
- this.log.debug(`Global node_modules Directory: ${this.globalModulesDir}`);
1497
+ this.globalModulesDirectory = await this.getGlobalNodeModules();
1498
+ this.matterbridgeInformation.globalModulesDirectory = this.globalModulesDirectory;
1499
+ this.log.debug(`Global node_modules Directory: ${this.globalModulesDirectory}`);
1455
1500
  // Create the data directory .matterbridge in the home directory
1456
1501
  this.matterbridgeDirectory = path.join(this.homeDirectory, '.matterbridge');
1502
+ this.matterbridgeInformation.matterbridgeDirectory = this.matterbridgeDirectory;
1457
1503
  try {
1458
1504
  await fs.access(this.matterbridgeDirectory);
1459
1505
  }
@@ -1477,6 +1523,7 @@ export class Matterbridge extends EventEmitter {
1477
1523
  this.log.debug(`Matterbridge Directory: ${this.matterbridgeDirectory}`);
1478
1524
  // Create the data directory .matterbridge in the home directory
1479
1525
  this.matterbridgePluginDirectory = path.join(this.homeDirectory, 'Matterbridge');
1526
+ this.matterbridgeInformation.matterbridgePluginDirectory = this.matterbridgePluginDirectory;
1480
1527
  try {
1481
1528
  await fs.access(this.matterbridgePluginDirectory);
1482
1529
  }
@@ -1501,8 +1548,10 @@ export class Matterbridge extends EventEmitter {
1501
1548
  // Matterbridge version
1502
1549
  const packageJson = JSON.parse(await fs.readFile(path.join(this.rootDirectory, 'package.json'), 'utf-8'));
1503
1550
  this.matterbridgeVersion = packageJson.version;
1551
+ this.matterbridgeInformation.matterbridgeVersion = this.matterbridgeVersion;
1504
1552
  this.log.debug(`Matterbridge Version: ${this.matterbridgeVersion}`);
1505
1553
  this.matterbridgeLatestVersion = await this.getLatestVersion('matterbridge');
1554
+ this.matterbridgeInformation.matterbridgeLatestVersion = this.matterbridgeLatestVersion;
1506
1555
  this.log.debug(`Matterbridge Latest Version: ${this.matterbridgeLatestVersion}`);
1507
1556
  if (this.matterbridgeVersion !== this.matterbridgeLatestVersion) {
1508
1557
  this.log.warn(`Matterbridge is out of date. Current version: ${this.matterbridgeVersion}, Latest version: ${this.matterbridgeLatestVersion}`);
@@ -1583,6 +1632,13 @@ export class Matterbridge extends EventEmitter {
1583
1632
  this.log.debug('The frontend sent /api/system-info');
1584
1633
  res.json(this.systemInformation);
1585
1634
  });
1635
+ // Endpoint to provide matterbridge information
1636
+ this.expressApp.get('/api/matterbridge-info', (req, res) => {
1637
+ this.log.debug('The frontend sent /api/matterbridge-info');
1638
+ this.matterbridgeInformation.bridgeMode = this.bridgeMode;
1639
+ this.matterbridgeInformation.debugEnabled = this.debugEnabled;
1640
+ res.json(this.matterbridgeInformation);
1641
+ });
1586
1642
  // Endpoint to provide plugins
1587
1643
  this.expressApp.get('/api/plugins', (req, res) => {
1588
1644
  this.log.debug('The frontend sent /api/plugins');
@@ -1703,27 +1759,33 @@ export class Matterbridge extends EventEmitter {
1703
1759
  }
1704
1760
  // Handle the command enableplugin from Home
1705
1761
  if (command === 'enableplugin') {
1706
- const plugin = this.findPlugin(param);
1762
+ const plugins = await this.nodeContext?.get('plugins');
1763
+ if (!plugins)
1764
+ return;
1765
+ const plugin = plugins.find((plugin) => plugin.name === param);
1707
1766
  if (plugin) {
1708
1767
  plugin.enabled = true;
1709
1768
  plugin.loaded = undefined;
1710
1769
  plugin.started = undefined;
1711
1770
  plugin.configured = undefined;
1712
1771
  plugin.connected = undefined;
1713
- await this.nodeContext?.set('plugins', this.getBaseRegisteredPlugins());
1772
+ await this.nodeContext?.set('plugins', plugins);
1714
1773
  this.log.info(`Enabled plugin ${plg}${param}${nf}`);
1715
1774
  }
1716
1775
  }
1717
1776
  // Handle the command disableplugin from Home
1718
1777
  if (command === 'disableplugin') {
1719
- const plugin = this.findPlugin(param);
1778
+ const plugins = await this.nodeContext?.get('plugins');
1779
+ if (!plugins)
1780
+ return;
1781
+ const plugin = plugins.find((plugin) => plugin.name === param);
1720
1782
  if (plugin) {
1721
1783
  plugin.enabled = false;
1722
1784
  plugin.loaded = undefined;
1723
1785
  plugin.started = undefined;
1724
1786
  plugin.configured = undefined;
1725
1787
  plugin.connected = undefined;
1726
- await this.nodeContext?.set('plugins', this.getBaseRegisteredPlugins());
1788
+ await this.nodeContext?.set('plugins', plugins);
1727
1789
  this.log.info(`Disabled plugin ${plg}${param}${nf}`);
1728
1790
  }
1729
1791
  }