matterbridge 1.2.4 → 1.2.5

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 (34) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +81 -8
  3. package/TODO.md +7 -0
  4. package/dist/cli.js +6 -1
  5. package/dist/cli.js.map +1 -1
  6. package/dist/index.d.ts +2 -0
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +2 -0
  9. package/dist/index.js.map +1 -1
  10. package/dist/matterbridge.d.ts +8 -0
  11. package/dist/matterbridge.d.ts.map +1 -1
  12. package/dist/matterbridge.js +94 -12
  13. package/dist/matterbridge.js.map +1 -1
  14. package/dist/matterbridgeController.d.ts.map +1 -1
  15. package/dist/matterbridgeController.js +9 -0
  16. package/dist/matterbridgeController.js.map +1 -1
  17. package/dist/matterbridgeDevice.d.ts +1241 -9
  18. package/dist/matterbridgeDevice.d.ts.map +1 -1
  19. package/dist/matterbridgeDevice.js +314 -91
  20. package/dist/matterbridgeDevice.js.map +1 -1
  21. package/frontend/build/asset-manifest.json +14 -14
  22. package/frontend/build/index.html +1 -1
  23. package/frontend/build/matterbridge 32x32.png +0 -0
  24. package/frontend/build/matterbridge 64x64.png +0 -0
  25. package/frontend/build/static/css/main.61f6cf42.css +1 -1
  26. package/frontend/build/static/css/main.61f6cf42.css.map +1 -1
  27. package/frontend/build/static/js/main.6b861489.js +3 -0
  28. package/frontend/build/static/js/{main.e3553a4d.js.LICENSE.txt → main.6b861489.js.LICENSE.txt} +99 -99
  29. package/frontend/build/static/js/main.6b861489.js.map +1 -0
  30. package/matterbridge.service +18 -0
  31. package/package.json +6 -5
  32. package/frontend/build/Matterbridge.jpg +0 -0
  33. package/frontend/build/static/js/main.e3553a4d.js +0 -3
  34. package/frontend/build/static/js/main.e3553a4d.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [1.2.5] - 2024-04-08
6
+
7
+ ### Added
8
+ - [frontend]: Added update Matterbridge (spawn the command: 'npm -install -g matterbridge'). The console inherit the the spawned process running so you can check.
9
+ - [frontend]: Added install plugin (spawn the command: 'npm -install -g plugin-name'). The console inherit the the spawned process running so you can check.
10
+ - [frontend]: Added shutdown button.
11
+ - [frontend]: Added login with password (default no password). Change the password in the Settings page of frontend.
12
+ - [frontend]: Frontend got updated to 0.8.5.
13
+ - [Matterbridge]: Added configuration and guidelines in the readme to run Matterbridge like a daemon with systemctl on Linux machine.
14
+
5
15
  ## [1.2.4] - 2024-04-01
6
16
 
7
17
  ### Changed
package/README.md CHANGED
@@ -26,8 +26,11 @@ This project aims to allow the porting of homebridge plugins to matterbridge plu
26
26
  It creates a device to pair in any ecosystem like Apple Home, Google Home, Amazon Alexa, or
27
27
  any other ecosystem supporting Matter like Home Assistant.
28
28
 
29
+ You don't need a hub or a dedicated new machine.
30
+
31
+ No complex setup just copa paste the installation scripts.
32
+
29
33
  Matterbridge is light weight and run also on slow Linux machine with 512MB of memory.
30
- You don't need a dedicated new machine.
31
34
 
32
35
  It runs perfectly on Windows too.
33
36
 
@@ -80,16 +83,17 @@ Matterbridge exposes each registered plugins, and you have to pair each one by s
80
83
  matterbridge -help
81
84
  ```
82
85
 
83
-
84
86
  ## Frontend
85
87
 
86
88
  Matterbridge has a frontend available on http://localhost:3000
87
89
 
88
90
  You can change the default port by adding the frontend parameter when you launch it.
91
+
89
92
  Here's how to specify a different port number:
90
93
  ```
91
94
  matterbridge -bridge -frontend [port number]
92
95
  ```
96
+
93
97
  ```
94
98
  matterbridge -childbridge -frontend [port number]
95
99
  ```
@@ -106,7 +110,7 @@ Devices page:
106
110
 
107
111
  This an example of an accessory platform plugin.
108
112
 
109
- It exposes a cover device that continuously moves position and shows how to use the command handlers (you can control the device).
113
+ It exposes a virtual cover device that continuously moves position and shows how to use the command handlers (you can control the device).
110
114
 
111
115
  An Accessory platform plugin only exposes one device.
112
116
 
@@ -118,7 +122,7 @@ This an example of a dynamic platform plugin.
118
122
 
119
123
  It exposes a switch with onOff, a light with onOff-levelControl-colorControl, an outlet with onOff and a WindoweCovering device.
120
124
 
121
- All these devices continuously change state and position. The plugin also shows how to use all the command handlers (you can control all the devices).
125
+ All these virtual devices continuously change state and position. The plugin also shows how to use all the command handlers (you can control all the devices).
122
126
 
123
127
  A Dynamic platform plugin exposes as many devices as you need (the limit for the Home app is 150 accessories for bridge).
124
128
 
@@ -139,7 +143,8 @@ Matterbridge can run as many plugins as you want.
139
143
  [Room plugin with history](https://github.com/Luligu/matterbridge-eve-room)
140
144
 
141
145
  The history works in both bridge and childbridge mode.
142
- The Eve app only shows the history when the plugins run like an AccessoryPlatform in childbridge mode.
146
+
147
+ The Eve app only shows the history when the plugins run like an AccessoryPlatform in childbridge mode (this means the plugin is paired directly).
143
148
 
144
149
  ### Production-level plugins
145
150
 
@@ -231,13 +236,13 @@ Add your plugin logic in platform.ts.
231
236
 
232
237
  ## MatterbridgeDynamicPlatform and MatterbridgeAccessoryPlatform api
233
238
 
234
- ### name: string
239
+ ### public name: string
235
240
  The plugin name.
236
241
 
237
- ### type: string
242
+ ### public type: string
238
243
  The plugin platform type.
239
244
 
240
- ### config: object
245
+ ### public config: object
241
246
  The plugin config (loaded before the platform constructor is called and saved after onShutdown() is called).
242
247
  Here you can store your plugin configuration (see matterbridge-zigbee2mqtt for example)
243
248
 
@@ -271,6 +276,74 @@ It can be useful to call this method from onShutdown() if you don't want to keep
271
276
 
272
277
  ## MatterbridgeDevice api
273
278
 
279
+ # Advanced configuration
280
+
281
+ ## Run matterbridge as a daemon with systemctl (Linux only)
282
+
283
+ Create a systemctl configuration file for Matterbridge
284
+
285
+ ```
286
+ sudo nano /etc/systemd/system/matterbridge.service
287
+ ```
288
+
289
+ Add the following to this file, replacing twice USER with your user name (e.g. pi):
290
+
291
+ ```
292
+ [Unit]
293
+ Description=matterbridge
294
+ After=network.target
295
+
296
+ [Service]
297
+ Type=simple
298
+ ExecStart=/usr/bin/matterbridge -bridge
299
+ WorkingDirectory=/home/<USER>/Matterbridge
300
+ StandardOutput=inherit
301
+ StandardError=inherit
302
+ Restart=always
303
+ RestartSec=10s
304
+ TimeoutStopSec=30s
305
+ User=<USER>
306
+
307
+ [Install]
308
+ WantedBy=multi-user.target
309
+ ```
310
+
311
+ If you modify it after, then run:
312
+ ```
313
+ sudo systemctl daemon-reload
314
+ ```
315
+
316
+ ### Start Matterbridge
317
+ ```
318
+ sudo systemctl start matterbridge
319
+ ```
320
+
321
+ ### Stop Matterbridge
322
+ ```
323
+ sudo systemctl stop matterbridge
324
+ ```
325
+
326
+ ### Show Matterbridge status
327
+ ```
328
+ sudo systemctl status matterbridge.service
329
+ ```
330
+
331
+ ### View the log of Matterbridge (this will keep the log colors)
332
+ ```
333
+ sudo journalctl -u matterbridge.service -f --output cat
334
+ ```
335
+
336
+ ### Enable Matterbridge to start automatically on boot
337
+
338
+ ```
339
+ sudo systemctl enable matterbridge.service
340
+ ```
341
+
342
+ ### Disable Matterbridge to start automatically on boot
343
+
344
+ ```
345
+ sudo systemctl disable matterbridge.service
346
+ ```
274
347
 
275
348
  # Contribution Guidelines
276
349
 
package/TODO.md ADDED
@@ -0,0 +1,7 @@
1
+ # TODO list
2
+
3
+ ## systemd
4
+
5
+ ## frontend password
6
+
7
+ ## docker
package/dist/cli.js CHANGED
@@ -34,6 +34,7 @@ async function main() {
34
34
  function registerHandlers() {
35
35
  instance.on('shutdown', async () => shutdown());
36
36
  instance.on('restart', async () => restart());
37
+ instance.on('update', async () => update());
37
38
  }
38
39
  async function shutdown() {
39
40
  console.log('CLI: received shutdown event, exiting...');
@@ -42,7 +43,11 @@ async function shutdown() {
42
43
  }
43
44
  async function restart() {
44
45
  console.log('CLI: received restart event, loading...');
45
- //wtf.dump();
46
+ instance = await Matterbridge.loadInstance(true);
47
+ registerHandlers();
48
+ }
49
+ async function update() {
50
+ console.log('CLI: received update event, updating...');
46
51
  instance = await Matterbridge.loadInstance(true);
47
52
  registerHandlers();
48
53
  }
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,+BAA+B;AAC/B,4BAA4B;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,IAAI,QAAkC,CAAC;AAEvC,KAAK,UAAU,IAAI;IACjB,OAAO,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAC;IACvD,QAAQ,GAAG,MAAM,YAAY,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IACjD,gBAAgB,EAAE,CAAC;IACnB,OAAO,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAC;AACzD,CAAC;AAED,SAAS,gBAAgB;IACvB,QAAS,CAAC,EAAE,CAAC,UAAU,EAAE,KAAK,IAAI,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC;IACjD,QAAS,CAAC,EAAE,CAAC,SAAS,EAAE,KAAK,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;AACjD,CAAC;AAED,KAAK,UAAU,QAAQ;IACrB,OAAO,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAC;IACxD,aAAa;IACb,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,KAAK,UAAU,OAAO;IACpB,OAAO,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAC;IACvD,aAAa;IACb,QAAQ,GAAG,MAAM,YAAY,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IACjD,gBAAgB,EAAE,CAAC;AACrB,CAAC;AAED,OAAO,CAAC,KAAK,GAAG,cAAc,CAAC;AAE/B,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,uDAAuD,KAAK,EAAE,CAAC,CAAC;AAChF,CAAC,CA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BAAgB,EAAE,CAAC;AACrB,CAAC;AAED,OAAO,CAAC,KAAK,GAAG,cAAc,CAAC;AAE/B,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,uDAAuD,KAAK,EAAE,CAAC,CAAC;AAChF,CAAC,CAAC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -26,6 +26,8 @@ export * from '@project-chip/matter-node.js/cluster';
26
26
  export * from '@project-chip/matter-node.js/log';
27
27
  export * from '@project-chip/matter-node.js/datatype';
28
28
  export * from '@project-chip/matter.js/util';
29
+ export * from '@project-chip/matter.js/schema';
30
+ export * from '@project-chip/matter.js/tlv';
29
31
  export * from 'matter-history';
30
32
  export * from './matterbridge.js';
31
33
  export * from './matterbridgeDevice.js';
@@ -1 +1 @@
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;AACtD,cAAc,8BAA8B,CAAC;AAE7C,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,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;AACtD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,6BAA6B,CAAC;AAE5C,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,kBAAkB,CAAC"}
package/dist/index.js CHANGED
@@ -27,6 +27,8 @@ export * from '@project-chip/matter-node.js/cluster';
27
27
  export * from '@project-chip/matter-node.js/log';
28
28
  export * from '@project-chip/matter-node.js/datatype';
29
29
  export * from '@project-chip/matter.js/util';
30
+ export * from '@project-chip/matter.js/schema';
31
+ export * from '@project-chip/matter.js/tlv';
30
32
  export * from 'matter-history';
31
33
  export * from './matterbridge.js';
32
34
  export * from './matterbridgeDevice.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
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;AACtD,cAAc,8BAA8B,CAAC;AAE7C,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,kBAAkB,CAAC;AAEjC,KAAK,UAAU,IAAI;IACjB,sCAAsC;IACtC,OAAO,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAC;IACxD,MAAM,YAAY,CAAC,YAAY,EAAE,CAAC;IAClC,sCAAsC;IACtC,OAAO,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAC;AAC1D,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,sCAAsC;IACtC,OAAO,CAAC,KAAK,CAAC,wDAAwD,KAAK,EAAE,CAAC,CAAC;AACjF,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;AACtD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,6BAA6B,CAAC;AAE5C,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,kBAAkB,CAAC;AAEjC,KAAK,UAAU,IAAI;IACjB,sCAAsC;IACtC,OAAO,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAC;IACxD,MAAM,YAAY,CAAC,YAAY,EAAE,CAAC;IAClC,sCAAsC;IACtC,OAAO,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAC;AAC1D,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,sCAAsC;IACtC,OAAO,CAAC,KAAK,CAAC,wDAAwD,KAAK,EAAE,CAAC,CAAC;AACjF,CAAC,CAAC,CAAC"}
@@ -132,10 +132,18 @@ export declare class Matterbridge extends EventEmitter {
132
132
  * When either of these signals are received, the cleanup method is called with an appropriate message.
133
133
  */
134
134
  private registerSignalHandlers;
135
+ /**
136
+ * Update matterbridge.
137
+ */
138
+ private updateProcess;
135
139
  /**
136
140
  * Restarts the process by spawning a new process and exiting the current process.
137
141
  */
138
142
  private restartProcess;
143
+ /**
144
+ * Shut down the process by exiting the current process.
145
+ */
146
+ private shutdownProcess;
139
147
  /**
140
148
  * Cleans up the Matterbridge instance.
141
149
  * @param message - The cleanup message.
@@ -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;AA6BlC,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;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;CACtB;AAMD;;GAEG;AACH,qBAAa,YAAa,SAAQ,YAAY;IACrC,iBAAiB,EAAE,iBAAiB,CAYzC;IAEK,uBAAuB;;;;;;;;;;MAU5B;IAEK,aAAa,EAAE,MAAM,CAAM;IAC3B,aAAa,EAAE,MAAM,CAAM;IAC3B,qBAAqB,EAAE,MAAM,CAAM;IACnC,2B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OAAO,CAAC,IAAI,CAAC;IAuDxF;;;;;OAKG;IACG,uBAAuB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBhE;;;;;OAKG;YACW,YAAY;IA0B1B;;;;;OAKG;YACW,iBAAiB;IAkB/B;;;OAGG;YACW,WAAW;YASX,qBAAqB;IAmGnC;;;;;;;;OAQG;YACW,gBAAgB;IAgC9B;;;;;OAKG;YACW,gBAAgB;IAe9B;;;;;;OAMG;YACW,SAAS;IAYvB;;;;;;;OAOG;YACW,WAAW;IA6BzB;;;;;OAKG;YACW,eAAe;IA4B7B;;;;;;;OAOG;YACW,UAAU;IAmDxB;;;;;;;;OAQG;YACW,iBAAiB;IAuU/B;;;OAGG;YACW,iBAAiB;IAW/B;;;;;;OAMG;YACW,gCAAgC;IAwB9C;;;;;;;;;;;;;;;;;OAiBG;YACW,gCAAgC;IA0C9C;;;;;;;OAOG;YACW,uBAAuB;IAgCrC;;;;;OAKG;IACH,OAAO,CAAC,UAAU;IASlB;;;;;;OAMG;YACW,wBAAwB;IAsItC;;;;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;IAmKlC;;;;OAIG;IACH,OAAO,CAAC,wBAAwB;IAqBhC;;;OAGG;IACH,OAAO,CAAC,wBAAwB;IAkBhC;;;;OAIG;IACG,kBAAkB,CAAC,IAAI,GAAE,MAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAwU5D;;;;OAIG;IACH,OAAO,CAAC,wBAAwB;CAwBjC"}
@@ -222,6 +222,9 @@ export class Matterbridge extends EventEmitter {
222
222
  /*
223
223
  npm > npm.cmd on windows
224
224
  */
225
+ if (process.platform === 'win32' && command === 'npm') {
226
+ command = command + '.cmd';
227
+ }
225
228
  return new Promise((resolve, reject) => {
226
229
  const childProcess = spawn(command, args, {
227
230
  stdio: 'inherit',
@@ -478,6 +481,13 @@ export class Matterbridge extends EventEmitter {
478
481
  await this.cleanup('SIGTERM received, cleaning up...');
479
482
  });
480
483
  }
484
+ /**
485
+ * Update matterbridge.
486
+ */
487
+ async updateProcess() {
488
+ await this.cleanup('updating...', false);
489
+ this.hasCleanupStarted = false;
490
+ }
481
491
  /**
482
492
  * Restarts the process by spawning a new process and exiting the current process.
483
493
  */
@@ -485,6 +495,13 @@ export class Matterbridge extends EventEmitter {
485
495
  await this.cleanup('restarting...', true);
486
496
  this.hasCleanupStarted = false;
487
497
  }
498
+ /**
499
+ * Shut down the process by exiting the current process.
500
+ */
501
+ async shutdownProcess() {
502
+ await this.cleanup('shutting down...', false);
503
+ this.hasCleanupStarted = false;
504
+ }
488
505
  /**
489
506
  * Cleans up the Matterbridge instance.
490
507
  * @param message - The cleanup message.
@@ -536,7 +553,7 @@ export class Matterbridge extends EventEmitter {
536
553
  this.expressApp.removeAllListeners();
537
554
  this.expressApp = undefined;
538
555
  }
539
- const cleanupTimeout1 = setTimeout(async () => {
556
+ /*const cleanupTimeout1 =*/ setTimeout(async () => {
540
557
  // Closing matter
541
558
  await this.stopMatter();
542
559
  // Closing storage
@@ -564,21 +581,28 @@ export class Matterbridge extends EventEmitter {
564
581
  this.registeredPlugins = [];
565
582
  this.registeredDevices = [];
566
583
  this.log.info('Waiting for matter to deliver last messages...');
567
- const cleanupTimeout2 = setTimeout(async () => {
584
+ /*const cleanupTimeout2 =*/ setTimeout(async () => {
568
585
  if (restart) {
569
- this.log.info('Cleanup completed. Restarting...');
570
- Matterbridge.instance = undefined;
571
- this.emit('restart');
586
+ if (message === 'updating...') {
587
+ this.log.info('Cleanup completed. Updating...');
588
+ Matterbridge.instance = undefined;
589
+ this.emit('update');
590
+ }
591
+ else if (message === 'restarting...') {
592
+ this.log.info('Cleanup completed. Restarting...');
593
+ Matterbridge.instance = undefined;
594
+ this.emit('restart');
595
+ }
572
596
  }
573
597
  else {
574
598
  this.log.info('Cleanup completed. Shutting down...');
575
599
  Matterbridge.instance = undefined;
576
600
  this.emit('shutdown');
577
601
  }
578
- }, 2 * 1000);
579
- cleanupTimeout2.unref();
602
+ }, 1 * 1000);
603
+ //cleanupTimeout2.unref();
580
604
  }, 3 * 1000);
581
- cleanupTimeout1.unref();
605
+ //cleanupTimeout1.unref();
582
606
  }
583
607
  }
584
608
  /**
@@ -2038,6 +2062,26 @@ export class Matterbridge extends EventEmitter {
2038
2062
  this.expressApp = express();
2039
2063
  // Serve React build directory
2040
2064
  this.expressApp.use(express.static(path.join(this.rootDirectory, 'frontend/build')));
2065
+ // Endpoint to provide login code
2066
+ this.expressApp.post('/api/login', express.json(), async (req, res) => {
2067
+ const { password } = req.body;
2068
+ this.log.debug('The frontend sent /api/login', password);
2069
+ if (!this.nodeContext) {
2070
+ this.log.error('/api/login nodeContext not found');
2071
+ res.json({ valid: false });
2072
+ return;
2073
+ }
2074
+ try {
2075
+ const storedPassword = await this.nodeContext.get('password', '');
2076
+ if (storedPassword === '' || password === storedPassword)
2077
+ res.json({ valid: true });
2078
+ else
2079
+ res.json({ valid: false });
2080
+ }
2081
+ catch (error) {
2082
+ res.json({ valid: false });
2083
+ }
2084
+ });
2041
2085
  // Endpoint to provide QR pairing code
2042
2086
  this.expressApp.get('/api/qr-code', (req, res) => {
2043
2087
  this.log.debug('The frontend sent /api/qr-code');
@@ -2152,7 +2196,13 @@ export class Matterbridge extends EventEmitter {
2152
2196
  res.status(400).json({ error: 'No command provided' });
2153
2197
  return;
2154
2198
  }
2155
- this.log.info(`***Received command: ${command}:${param}`);
2199
+ this.log.debug(`*Received frontend command: ${command}:${param}`);
2200
+ // Handle the command setpassword from Settings
2201
+ if (command === 'setpassword') {
2202
+ const password = param.slice(1, -1); // Remove the first and last characters
2203
+ this.log.info('setpassword', param, password);
2204
+ await this.nodeContext?.set('password', password);
2205
+ }
2156
2206
  // Handle the command debugLevel from Settings
2157
2207
  if (command === 'setloglevel') {
2158
2208
  if (param === 'Debug') {
@@ -2174,15 +2224,47 @@ export class Matterbridge extends EventEmitter {
2174
2224
  plugin.platform?.log.setLogDebug(this.debugEnabled);
2175
2225
  });
2176
2226
  }
2177
- // Handle the command debugLevel from Header
2227
+ // Handle the command shutdown from Header
2228
+ if (command === 'shutdown') {
2229
+ this.shutdownProcess();
2230
+ }
2231
+ // Handle the command restart from Header
2178
2232
  if (command === 'restart') {
2179
2233
  this.restartProcess();
2180
2234
  }
2181
2235
  // Handle the command update from Header
2236
+ if (command === 'update') {
2237
+ this.log.warn(`***Updating matterbridge ${plg}${param}${db}`);
2238
+ try {
2239
+ await this.spawnCommand('npm', ['install', '-g', 'matterbridge']);
2240
+ this.log.info('Matterbridge has been updated. Full restart required.');
2241
+ }
2242
+ catch (error) {
2243
+ this.log.error('Error updating matterbridge');
2244
+ res.json({ message: 'Command received' });
2245
+ return;
2246
+ }
2247
+ this.updateProcess();
2248
+ }
2249
+ // Handle the command update from Header
2182
2250
  if (command === 'update') {
2183
2251
  this.log.warn(`The /api/command/${command} is not yet implemented`);
2184
2252
  }
2185
- // Handle the command addplugin from Home C:\Users\lligu\GitHub\matterbridge-example-accessory-platform
2253
+ // Handle the command installplugin from Home
2254
+ if (command === 'installplugin') {
2255
+ param = param.replace(/\*/g, '\\');
2256
+ this.log.warn(`***Installing plugin ${plg}${param}${db}`);
2257
+ try {
2258
+ await this.spawnCommand('npm', ['install', '-g', param]);
2259
+ this.log.info(`Plugin ${plg}${param}${nf} installed. Restart required.`);
2260
+ }
2261
+ catch (error) {
2262
+ this.log.error(`Error installing plugin ${plg}${param}${er}`);
2263
+ res.json({ message: 'Command received' });
2264
+ return;
2265
+ }
2266
+ }
2267
+ // Handle the command addplugin from Home
2186
2268
  if (command === 'addplugin') {
2187
2269
  param = param.replace(/\*/g, '\\');
2188
2270
  if (this.registeredPlugins.find((plugin) => plugin.name === param)) {
@@ -2297,7 +2379,7 @@ export class Matterbridge extends EventEmitter {
2297
2379
  });
2298
2380
  // Fallback for routing
2299
2381
  this.expressApp.get('*', (req, res) => {
2300
- this.log.warn('The frontend sent *', req.url);
2382
+ this.log.debug('The frontend sent *', req.url);
2301
2383
  res.sendFile(path.join(this.rootDirectory, 'frontend/build/index.html'));
2302
2384
  });
2303
2385
  this.expressServer = this.expressApp.listen(port, () => {