matterbridge 1.1.2 → 1.1.4

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 (39) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +90 -3
  3. package/Screenshot devices page.png +0 -0
  4. package/Screenshot home page.png +0 -0
  5. package/dist/cli.d.ts +3 -0
  6. package/dist/cli.d.ts.map +1 -0
  7. package/dist/cli.js +13 -0
  8. package/dist/cli.js.map +1 -0
  9. package/dist/index.d.ts +0 -1
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +2 -1
  12. package/dist/index.js.map +1 -1
  13. package/dist/matterbridge.d.ts +2 -2
  14. package/dist/matterbridge.d.ts.map +1 -1
  15. package/dist/matterbridge.js +66 -26
  16. package/dist/matterbridge.js.map +1 -1
  17. package/dist/matterbridgeAccessoryPlatform.d.ts +15 -0
  18. package/dist/matterbridgeAccessoryPlatform.d.ts.map +1 -1
  19. package/dist/matterbridgeAccessoryPlatform.js +19 -0
  20. package/dist/matterbridgeAccessoryPlatform.js.map +1 -1
  21. package/dist/matterbridgeController.d.ts +2 -0
  22. package/dist/matterbridgeController.d.ts.map +1 -0
  23. package/dist/matterbridgeController.js +309 -0
  24. package/dist/matterbridgeController.js.map +1 -0
  25. package/dist/matterbridgeDynamicPlatform.d.ts +15 -0
  26. package/dist/matterbridgeDynamicPlatform.d.ts.map +1 -1
  27. package/dist/matterbridgeDynamicPlatform.js +19 -0
  28. package/dist/matterbridgeDynamicPlatform.js.map +1 -1
  29. package/dist/utils.d.ts +2 -0
  30. package/dist/utils.d.ts.map +1 -0
  31. package/dist/utils.js +33 -0
  32. package/dist/utils.js.map +1 -0
  33. package/frontend/build/asset-manifest.json +3 -3
  34. package/frontend/build/index.html +1 -1
  35. package/frontend/build/static/js/{main.21c55a60.js → main.b5a876cf.js} +3 -3
  36. package/frontend/build/static/js/main.b5a876cf.js.map +1 -0
  37. package/package.json +11 -11
  38. package/frontend/build/static/js/main.21c55a60.js.map +0 -1
  39. /package/frontend/build/static/js/{main.21c55a60.js.LICENSE.txt → main.b5a876cf.js.LICENSE.txt} +0 -0
package/CHANGELOG.md CHANGED
@@ -2,6 +2,28 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [1.1.4] - 2024-03-10
6
+
7
+ ### Changed
8
+
9
+ - [cli]: Updated the loading from cli.
10
+
11
+
12
+ ## [1.1.3] - 2024-03-10
13
+
14
+ ### Added
15
+
16
+ - [onMatterStarted]: onMatterStarted() is called after matter server started.
17
+ - [onConfigure]: onConfigure() is called after the platform controller is commissioned.
18
+
19
+ ### Changed
20
+
21
+ - [dependencies]: Updated dependencies.
22
+
23
+ ### Fixed
24
+
25
+ - [Plugin route]: Fixed the plugin device route in frontend.
26
+
5
27
  ## [1.1.2] - 2024-03-08
6
28
 
7
29
  ### Added
package/README.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Matterbridge
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/matterbridge.svg)](https://www.npmjs.com/package/matterbridge)
4
+ [![npm downloads](https://img.shields.io/npm/dt/matterbridge.svg)](https://www.npmjs.com/package/matterbridge)
5
+
6
+
7
+ [![power by](https://img.shields.io/badge/powered%20by-node--ansi--logger-blue)](https://www.npmjs.com/package/node-ansi-logger)
8
+
9
+ [![power by](https://img.shields.io/badge/powered%20by-node--persist--manager-blue)](https://www.npmjs.com/package/node-persist-manager)
10
+
11
+ ---
12
+
13
+
3
14
  Matterbridge is a Matter.js plugin manager.
4
15
 
5
16
  It allows you to have all your Matter devices up and running in a couple of minutes without
@@ -24,10 +35,14 @@ Follow these steps to install Matterbridge:
24
35
  ```
25
36
  npm install -g matterbridge
26
37
  ```
38
+ or
39
+ ```
40
+ sudo npm install -g matterbridge
41
+ ```
27
42
 
28
43
  Test the installation with:
29
44
  ```
30
- matterbridge
45
+ matterbridge -bridge
31
46
  ```
32
47
  Now it is possible to open the frontend at the link provided (default: http://localhost:3000)
33
48
 
@@ -60,7 +75,7 @@ matterbridge -help
60
75
 
61
76
  Matterbridge has a frontend (currently under development) available http://localhost:3000
62
77
 
63
- You can change the port by adding the frontend parameter when you launch it.
78
+ You can change the default port by adding the frontend parameter when you launch it.
64
79
  Here's how to specify a different port number:
65
80
  ```
66
81
  matterbridge -bridge -frontend [port number]
@@ -95,10 +110,82 @@ Matterbridge can run as many plugins as you want.
95
110
 
96
111
  [See the plugin homepage here](https://github.com/Luligu/matterbridge-example-dynamic-platform)
97
112
 
98
- ### Example plugins to show the usage of history
113
+ ### Example plugins to show the usage of history in matter
99
114
 
100
115
  [Contact plugin with history](https://github.com/Luligu/matterbridge-eve-door)
101
116
 
102
117
  [Motion plugin with history](https://github.com/Luligu/matterbridge-eve-motion)
103
118
 
104
119
  [Energy plugin with history](https://github.com/Luligu/matterbridge-eve-energy)
120
+
121
+ [Weather plugin with history](https://github.com/Luligu/matterbridge-eve-weather)
122
+
123
+ [Room plugin with history](https://github.com/Luligu/matterbridge-eve-room)
124
+
125
+ ## How to install a plugin
126
+
127
+ To install i.e. https://github.com/Luligu/matterbridge-example-accessory-platform
128
+ ```
129
+ git clone https://github.com/Luligu/matterbridge-example-accessory-platform
130
+ cd matterbridge-example-accessory-platform
131
+ npm install
132
+ npm run build
133
+ ```
134
+ Then add the plugin to Matterbridge
135
+ ```
136
+ matterbridge -add .\
137
+ ```
138
+
139
+ ### How to add a plugin to Matterbridge
140
+
141
+ ```
142
+ matterbridge -add .\
143
+ ```
144
+
145
+ ### How to remove a plugin from Matterbridge
146
+
147
+ ```
148
+ matterbridge -remove .\
149
+ ```
150
+
151
+ ### How to disable a registerd plugin
152
+
153
+ ```
154
+ matterbridge -disable .\
155
+ ```
156
+
157
+ ### How to enable a registerd plugin
158
+
159
+ ```
160
+ matterbridge -enable .\
161
+ ```
162
+
163
+ ## How to create your plugin
164
+
165
+ The easiest way is to clone:
166
+
167
+ - https://github.com/Luligu/matterbridge-example-accessory-platform if you want to create an Accessory Platform Plugin.
168
+
169
+
170
+ - https://github.com/Luligu/matterbridge-example-dynamic-platform if you want to create a Dynamic Platform Plugin.
171
+
172
+ Then change the name, version, description and author in the package.json.
173
+
174
+ Add your plugin logic in platform.ts:
175
+
176
+ ### onStart(reason?: string)
177
+ The method onStart() is where you have to create your MatterbridgeDevice and add all needed clusters and command handlers.
178
+
179
+ The MatterbridgeDevice class has the create cluster methods already done and all command handlers needed (see plugin examples).
180
+
181
+ The method is called when Matterbridge load the plugin.
182
+
183
+ ### onConfigure()
184
+ The method onConfigure() is where you can configure or initialize your device.
185
+
186
+ The method is called when the platform is commissioned.
187
+
188
+ ### onShutdown(reason?: string)
189
+ The method onShutdown() is where you have to eventually cleanup some resources.
190
+
191
+ The method is called when Matterbridge is shutting down.
Binary file
Binary file
package/dist/cli.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
package/dist/cli.js ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env node
2
+ import { Matterbridge } from './matterbridge.js';
3
+ async function main() {
4
+ // eslint-disable-next-line no-console
5
+ console.log('Loading Matterbridge from cli');
6
+ await Matterbridge.loadInstance(true);
7
+ }
8
+ process.title = 'matterbridge';
9
+ main().catch((error) => {
10
+ // eslint-disable-next-line no-console
11
+ console.error(`Failed to initialize Matterbridge from cli: ${error}`);
12
+ });
13
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,KAAK,UAAU,IAAI;IACjB,sCAAsC;IACtC,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;IAC7C,MAAM,YAAY,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;AACxC,CAAC;AAED,OAAO,CAAC,KAAK,GAAG,cAAc,CAAC;AAE/B,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,sCAAsC;IACtC,OAAO,CAAC,KAAK,CAAC,+CAA+C,KAAK,EAAE,CAAC,CAAC;AACxE,CAAC,CAAC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- #!/usr/bin/env node
2
1
  /**
3
2
  * This file contains the entry point of Matterbridge.
4
3
  *
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,8BAA8B,CAAC;AAGtC,cAAc,qCAAqC,CAAC;AACpD,cAAc,sCAAsC,CAAC;AACrD,cAAc,kCAAkC,CAAC;AACjD,cAAc,uCAAuC,CAAC;AAEtD,cAAc,gBAAgB,CAAC;AAE/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,oCAAoC,CAAC;AACnD,cAAc,kCAAkC,CAAC;AACjD,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,8BAA8B,CAAC;AAGtC,cAAc,qCAAqC,CAAC;AACpD,cAAc,sCAAsC,CAAC;AACrD,cAAc,kCAAkC,CAAC;AACjD,cAAc,uCAAuC,CAAC;AAEtD,cAAc,gBAAgB,CAAC;AAE/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,oCAAoC,CAAC;AACnD,cAAc,kCAAkC,CAAC;AACjD,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC"}
package/dist/index.js CHANGED
@@ -1,4 +1,3 @@
1
- #!/usr/bin/env node
2
1
  /**
3
2
  * This file contains the entry point of Matterbridge.
4
3
  *
@@ -36,6 +35,8 @@ export * from './AirQualityCluster.js';
36
35
  export * from './ColorControlServer.js';
37
36
  export * from './TvocCluster.js';
38
37
  async function main() {
38
+ // eslint-disable-next-line no-console
39
+ console.log('Loading Matterbridge instance');
39
40
  await Matterbridge.loadInstance();
40
41
  }
41
42
  main().catch((error) => {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,8BAA8B,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,cAAc,qCAAqC,CAAC;AACpD,cAAc,sCAAsC,CAAC;AACrD,cAAc,kCAAkC,CAAC;AACjD,cAAc,uCAAuC,CAAC;AAEtD,cAAc,gBAAgB,CAAC;AAE/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,oCAAoC,CAAC;AACnD,cAAc,kCAAkC,CAAC;AACjD,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AAEjC,KAAK,UAAU,IAAI;IACjB,MAAM,YAAY,CAAC,YAAY,EAAE,CAAC;AACpC,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,sCAAsC;IACtC,OAAO,CAAC,KAAK,CAAC,sCAAsC,KAAK,EAAE,CAAC,CAAC;AAC/D,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,8BAA8B,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,cAAc,qCAAqC,CAAC;AACpD,cAAc,sCAAsC,CAAC;AACrD,cAAc,kCAAkC,CAAC;AACjD,cAAc,uCAAuC,CAAC;AAEtD,cAAc,gBAAgB,CAAC;AAE/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,oCAAoC,CAAC;AACnD,cAAc,kCAAkC,CAAC;AACjD,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AAEjC,KAAK,UAAU,IAAI;IACjB,sCAAsC;IACtC,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;IAC7C,MAAM,YAAY,CAAC,YAAY,EAAE,CAAC;AACpC,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,sCAAsC;IACtC,OAAO,CAAC,KAAK,CAAC,sCAAsC,KAAK,EAAE,CAAC,CAAC;AAC/D,CAAC,CAAC,CAAC"}
@@ -63,9 +63,8 @@ export declare class Matterbridge {
63
63
  * Loads an instance of the Matterbridge class.
64
64
  * If an instance already exists, an error will be thrown.
65
65
  * @returns The loaded instance of the Matterbridge class.
66
- * @throws Error if an instance of Matterbridge already exists.
67
66
  */
68
- static loadInstance(): Promise<Matterbridge>;
67
+ static loadInstance(cli?: boolean): Promise<Matterbridge>;
69
68
  /**
70
69
  * Initializes the Matterbridge application.
71
70
  *
@@ -148,6 +147,7 @@ export declare class Matterbridge {
148
147
  * @returns {Promise<void>} A promise that resolves when the Matterbridge is started.
149
148
  */
150
149
  private startMatterBridge;
150
+ private startMatterServer;
151
151
  /**
152
152
  * Imports the commissioning server context for a specific plugin and device.
153
153
  * @param pluginName - The name of the plugin.
@@ -1 +1 @@
1
- {"version":3,"file":"matterbridge.d.ts","sourceRoot":"","sources":["../src/matterbridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;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CrB;;;;;OAKG;IACH,OAAO,CAAC,qBAAqB;IAS7B;;;;OAIG;IACG,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,kBAAkB;IAyC9D;;;;OAIG;IACG,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,kBAAkB;IA2BrE;;;;;OAKG;YACW,YAAY;IAyB1B;;;;;OAKG;YACW,iBAAiB;IAkB/B;;;OAGG;YACW,WAAW;IAMzB;;;;;;;;OAQG;YACW,iBAAiB;YA2HjB,iBAAiB;IAK/B;;;;;;OAMG;IACH,OAAO,CAAC,gCAAgC;IAwBxC;;;;;;;;;;;;;;;;;OAiBG;IACH,OAAO,CAAC,gCAAgC;IAmCxC;;;;;;;;;;OAUG;IACH,OAAO,CAAC,uBAAuB;IAkB/B;;;;;OAKG;IACH,OAAO,CAAC,UAAU;IASlB;;;;;;OAMG;IACH,OAAO,CAAC,wBAAwB;IA2GhC;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;IAK1B;;;;OAIG;IACH,OAAO,CAAC,sBAAsB;IAuC9B;;OAEG;YACW,UAAU;IAUxB;;OAEG;YACW,oBAAoB;IA+ElC,OAAO,CAAC,uBAAuB;IAkB/B;;;;OAIG;IACG,kBAAkB,CAAC,IAAI,GAAE,MAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAgH5D;;;;OAIG;IACH,OAAO,CAAC,wBAAwB;CAsBjC"}
@@ -81,15 +81,20 @@ export class Matterbridge {
81
81
  * Loads an instance of the Matterbridge class.
82
82
  * If an instance already exists, an error will be thrown.
83
83
  * @returns The loaded instance of the Matterbridge class.
84
- * @throws Error if an instance of Matterbridge already exists.
85
84
  */
86
- static async loadInstance() {
85
+ static async loadInstance(cli = false) {
86
+ // eslint-disable-next-line no-console
87
+ console.error('loadInstance cli:', cli);
87
88
  if (!Matterbridge.instance) {
89
+ // eslint-disable-next-line no-console
90
+ console.error('Matterbridge instance does not exists');
88
91
  Matterbridge.instance = new Matterbridge();
89
- await Matterbridge.instance.initialize();
92
+ if (cli)
93
+ await Matterbridge.instance.initialize();
90
94
  }
91
95
  else {
92
- throw new Error('Matterbridge instance already exists');
96
+ // eslint-disable-next-line no-console
97
+ console.error('Matterbridge instance already exists');
93
98
  }
94
99
  return Matterbridge.instance;
95
100
  }
@@ -184,6 +189,8 @@ export class Matterbridge {
184
189
  }
185
190
  // Start the storage (we need it now for frontend and later for matterbridge)
186
191
  await this.startStorage('json', path.join(this.matterbridgeDirectory, 'matterbridge.json'));
192
+ this.log.debug(`Creating commissioning server context for ${plg}Matterbridge${db}`);
193
+ this.matterbridgeContext = this.createCommissioningServerContext('Matterbridge', 'Matterbridge', DeviceTypes.AGGREGATOR.code, 0xfff1, 'Matterbridge', 0x8000, 'Matterbridge aggregator');
187
194
  // Initialize frontend
188
195
  await this.initializeFrontend(getIntParameter('frontend'));
189
196
  if (hasParameter('childbridge')) {
@@ -517,23 +524,26 @@ export class Matterbridge {
517
524
  */
518
525
  async startMatterBridge() {
519
526
  this.log.debug('Starting matterbridge in mode', this.bridgeMode);
520
- await this.createMatterServer(this.storageManager);
527
+ this.createMatterServer(this.storageManager);
521
528
  if (this.bridgeMode === 'bridge') {
522
529
  // Plugins are loaded by loadPlugin on startup and plugin.loaded is set to true
523
530
  // Plugins are started by callback when Matterbridge is commissioned and plugin.started is set to true
524
- this.log.debug('Creating commissioning server context for Matterbridge');
525
- this.matterbridgeContext = this.createCommissioningServerContext('Matterbridge', 'Matterbridge', DeviceTypes.AGGREGATOR.code, 0xfff1, 'Matterbridge', 0x8000, 'Matterbridge aggragator');
526
- this.log.debug('Creating commissioning server for Matterbridge');
531
+ this.log.debug(`Creating commissioning server context for ${plg}Matterbridge${db}`);
532
+ this.matterbridgeContext = this.createCommissioningServerContext('Matterbridge', 'Matterbridge', DeviceTypes.AGGREGATOR.code, 0xfff1, 'Matterbridge', 0x8000, 'Matterbridge aggregator');
533
+ this.log.debug(`Creating commissioning server for ${plg}Matterbridge${db}`);
527
534
  this.commissioningServer = this.createCommisioningServer(this.matterbridgeContext, 'Matterbridge');
528
- this.log.debug('Creating matter aggregator for matterbridge');
535
+ this.log.debug(`Creating matter aggregator for ${plg}Matterbridge${db}`);
529
536
  this.matterAggregator = this.createMatterAggregator(this.matterbridgeContext);
530
- this.log.debug('Adding matterbridge aggregator to matterbridge commissioning server');
537
+ this.log.debug('Adding matterbridge aggregator to commissioning server');
531
538
  this.commissioningServer.addDevice(this.matterAggregator);
532
539
  this.log.debug('Adding matterbridge commissioning server to matter server');
533
540
  await this.matterServer.addCommissioningServer(this.commissioningServer, { uniqueStorageKey: 'Matterbridge' });
534
541
  this.log.debug('Starting matter server');
535
- await this.matterServer.start();
536
- this.log.debug('Started matter server');
542
+ await this.startMatterServer();
543
+ this.registeredPlugins.forEach(async (plugin) => {
544
+ if (plugin.platform)
545
+ await plugin.platform.onMatterStarted();
546
+ });
537
547
  this.showCommissioningQRCode(this.commissioningServer, this.matterbridgeContext, 'Matterbridge');
538
548
  }
539
549
  if (this.bridgeMode === 'childbridge') {
@@ -626,9 +636,10 @@ export class Matterbridge {
626
636
  });
627
637
  });
628
638
  this.log.debug('Starting matter server');
629
- await this.matterServer.start();
630
- this.log.debug('Started matter server');
639
+ await this.startMatterServer();
631
640
  this.registeredPlugins.forEach(async (plugin) => {
641
+ if (plugin.platform)
642
+ await plugin.platform.onMatterStarted();
632
643
  this.showCommissioningQRCode(plugin.commissioningServer, plugin.storageContext, plugin.name);
633
644
  });
634
645
  Logger.defaultLogLevel = Level.DEBUG;
@@ -637,6 +648,10 @@ export class Matterbridge {
637
648
  return;
638
649
  }
639
650
  }
651
+ async startMatterServer() {
652
+ await this.matterServer.start();
653
+ this.log.debug('Started matter server');
654
+ }
640
655
  /**
641
656
  * Imports the commissioning server context for a specific plugin and device.
642
657
  * @param pluginName - The name of the plugin.
@@ -829,6 +844,10 @@ export class Matterbridge {
829
844
  });
830
845
  Logger.defaultLogLevel = Level.DEBUG;
831
846
  }
847
+ this.registeredPlugins.forEach(async (plugin) => {
848
+ if (plugin.name === name && plugin.platform)
849
+ plugin.platform.onConfigure();
850
+ });
832
851
  //logEndpoint(commissioningServer.getRootEndpoint());
833
852
  }, 2000);
834
853
  }
@@ -998,24 +1017,22 @@ export class Matterbridge {
998
1017
  * @param port The port number to run the frontend server on. Default is 3000.
999
1018
  */
1000
1019
  async initializeFrontend(port = 3000) {
1001
- this.log.debug(`Initializing the frontend on port ${YELLOW}${port}${db} static ${UNDERLINE}${path.join(this.rootDirectory, 'frontend/build')}${rs}`);
1020
+ this.log.debug(`Initializing the frontend on port ${YELLOW}${port}${db} static ${UNDERLINE}${path.join(this.rootDirectory, 'frontend/build')}${UNDERLINEOFF}${rs}`);
1002
1021
  this.app = express();
1003
1022
  // Serve React build directory
1004
1023
  this.app.use(express.static(path.join(this.rootDirectory, 'frontend/build')));
1005
1024
  // Endpoint to provide QR pairing code
1006
1025
  this.app.get('/api/qr-code', (req, res) => {
1007
1026
  this.log.debug('The frontend sent /api/qr-code');
1008
- if (this.bridgeMode === 'childbridge') {
1009
- this.log.debug('qrPairingCode for /api/qr-code not available in childbridge mode');
1010
- res.json({});
1011
- return;
1012
- }
1027
+ if (!this.matterbridgeContext)
1028
+ this.matterbridgeContext = this.createCommissioningServerContext('Matterbridge', 'Matterbridge', DeviceTypes.AGGREGATOR.code, 0xfff1, 'Matterbridge', 0x8000, 'Matterbridge aggregator');
1013
1029
  try {
1014
1030
  const qrData = { qrPairingCode: this.matterbridgeContext.get('qrPairingCode'), manualPairingCode: this.matterbridgeContext.get('manualPairingCode') };
1015
1031
  res.json(qrData);
1016
1032
  }
1017
1033
  catch (error) {
1018
- this.log.error('qrPairingCode for /api/qr-code not found');
1034
+ if (this.bridgeMode === 'bridge')
1035
+ this.log.error('qrPairingCode for /api/qr-code not found');
1019
1036
  res.json({});
1020
1037
  }
1021
1038
  });
@@ -1058,10 +1075,11 @@ export class Matterbridge {
1058
1075
  res.json(data);
1059
1076
  });
1060
1077
  // Endpoint to provide the cluster servers of the devices
1061
- this.app.get('/api/devices_clusters/:selectedPluginName', (req, res) => {
1078
+ this.app.get('/api/devices_clusters/:selectedPluginName/:selectedDeviceEndpoint', (req, res) => {
1062
1079
  const selectedPluginName = req.params.selectedPluginName;
1063
- this.log.debug('The frontend sent /api/devices_clusters', selectedPluginName);
1064
- if (selectedPluginName === 'none') {
1080
+ const selectedDeviceEndpoint = req.params.selectedDeviceEndpoint;
1081
+ this.log.debug(`The frontend sent /api/devices_clusters plugin:${selectedPluginName} endpoint:${selectedDeviceEndpoint}`);
1082
+ if (selectedPluginName === 'none' /* || selectedDeviceEndpoint === 'none'*/) {
1065
1083
  res.json([]);
1066
1084
  return;
1067
1085
  }
@@ -1105,9 +1123,9 @@ export class Matterbridge {
1105
1123
  res.sendFile(path.join(this.rootDirectory, 'frontend/build/index.html'));
1106
1124
  });
1107
1125
  this.app.listen(port, () => {
1108
- this.log.info(`The frontend is running on ${UNDERLINE}http://localhost:${port}${rs}`);
1126
+ this.log.info(`The frontend is running on ${UNDERLINE}http://localhost:${port}${UNDERLINEOFF}${rs}`);
1109
1127
  });
1110
- this.log.debug(`Frontend initialized on port ${YELLOW}${port}${db} static ${UNDERLINE}${path.join(this.rootDirectory, 'frontend/build')}${rs}`);
1128
+ this.log.debug(`Frontend initialized on port ${YELLOW}${port}${db} static ${UNDERLINE}${path.join(this.rootDirectory, 'frontend/build')}${UNDERLINEOFF}${rs}`);
1111
1129
  }
1112
1130
  /**
1113
1131
  * Retrieves the cluster text from a given device.
@@ -1151,6 +1169,28 @@ export class Matterbridge {
1151
1169
  }
1152
1170
  }
1153
1171
  /*
1172
+ TO IMPLEMENT
1173
+ import * as WebSocket from 'ws';
1174
+
1175
+ const wss = new WebSocket.Server({ port: 8080 });
1176
+
1177
+ wss.on('connection', ws => {
1178
+ ws.on('message', message => {
1179
+ console.log(`Received message => ${message}`)
1180
+ });
1181
+
1182
+ // Send a message to the frontend
1183
+ ws.send('Hello from backend!');
1184
+ });
1185
+
1186
+ const ws = new WebSocket('ws://localhost:8080');
1187
+
1188
+ ws.onmessage = (event) => {
1189
+ console.log(`Received message => ${event.data}`);
1190
+ };
1191
+
1192
+ */
1193
+ /*
1154
1194
  npx create-react-app matterbridge-frontend
1155
1195
  cd matterbridge-frontend
1156
1196
  npm install react-router-dom