matterbridge 2.1.5-dev.3 → 2.1.5-dev.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.
package/CHANGELOG.md CHANGED
@@ -40,6 +40,8 @@ matterbridge-hass v. 0.0.8
40
40
  - [frontend]: Frontend v.2.4.1.
41
41
  - [frontend]: Optimized rendering of all pages.
42
42
  - [frontend]: Added cpuUsed, rss and heapUsed to SystemInformation.
43
+ - [frontend]: Added UiProvider.
44
+ - [frontend]: Added wssSendCpuUpdate, wssSendMemoryUpdate and wssSendSnackbarMessage.
43
45
 
44
46
  ### Changed
45
47
 
@@ -48,6 +50,8 @@ matterbridge-hass v. 0.0.8
48
50
 
49
51
  ### Fixed
50
52
 
53
+ - [matterbridge]: Refactor shutdown sequences for reset and factory reset.
54
+
51
55
  <a href="https://www.buymeacoffee.com/luligugithub">
52
56
  <img src="./yellow-button.png" alt="Buy me a coffee" width="120">
53
57
  </a>
package/dist/frontend.js CHANGED
@@ -15,6 +15,7 @@ export const WS_ID_REFRESH_NEEDED = 1;
15
15
  export const WS_ID_RESTART_NEEDED = 2;
16
16
  export const WS_ID_CPU_UPDATE = 3;
17
17
  export const WS_ID_MEMORY_UPDATE = 4;
18
+ export const WS_ID_SNACKBAR = 5;
18
19
  export class Frontend {
19
20
  matterbridge;
20
21
  log;
@@ -749,9 +750,11 @@ export class Frontend {
749
750
  }
750
751
  async stop() {
751
752
  if (hasParameter('memorycheck')) {
753
+ this.wssSendSnackbarMessage('Memory check started', getIntParameter('memorycheck') ?? 5 * 60 * 1000);
752
754
  await new Promise((resolve) => {
753
755
  this.log.debug(`***Memory check started for ${getIntParameter('memorycheck') ?? 5 * 60 * 1000} ms`);
754
756
  setTimeout(() => {
757
+ this.wssSendSnackbarMessage('Memory check stopped', 10);
755
758
  this.log.debug(`***Memory check stopped after ${getIntParameter('memorycheck') ?? 5 * 60 * 1000} ms`);
756
759
  resolve();
757
760
  }, getIntParameter('memorycheck') ?? 5 * 60 * 1000);
@@ -1384,4 +1387,12 @@ export class Frontend {
1384
1387
  }
1385
1388
  });
1386
1389
  }
1390
+ wssSendSnackbarMessage(message, timeout) {
1391
+ this.log.debug('Sending a snackbar message to all connected clients');
1392
+ this.webSocketServer?.clients.forEach((client) => {
1393
+ if (client.readyState === WebSocket.OPEN) {
1394
+ client.send(JSON.stringify({ id: WS_ID_SNACKBAR, src: 'Matterbridge', dst: 'Frontend', method: 'memory_update', params: { message, timeout } }));
1395
+ }
1396
+ });
1397
+ }
1387
1398
  }
@@ -929,61 +929,9 @@ export class Matterbridge extends EventEmitter {
929
929
  await this.cleanup('unregistered all devices and shutting down...', false);
930
930
  }
931
931
  async shutdownProcessAndReset() {
932
- this.log.info('Resetting Matterbridge commissioning information...');
933
- await this.matterStorageManager?.createContext('events')?.clearAll();
934
- await this.matterStorageManager?.createContext('fabrics')?.clearAll();
935
- await this.matterStorageManager?.createContext('root')?.clearAll();
936
- await this.matterStorageManager?.createContext('sessions')?.clearAll();
937
- await this.matterbridgeContext?.clearAll();
938
- await this.stopMatterStorage();
939
- this.log.info('Matter storage reset done! Remove the bridge from the controller.');
940
932
  await this.cleanup('shutting down with reset...', false);
941
933
  }
942
934
  async shutdownProcessAndFactoryReset() {
943
- try {
944
- const file = path.join(this.matterbridgeDirectory, 'matterbridge' + (getParameter('profile') ? '.' + getParameter('profile') : '') + '.json');
945
- this.log.info(`Unlinking old matter storage file: ${file}`);
946
- await fs.unlink(file);
947
- const backup = path.join(this.matterbridgeDirectory, 'matterbridge' + (getParameter('profile') ? '.' + getParameter('profile') : '') + '.backup.json');
948
- this.log.info(`Unlinking old matter storage backup file: ${backup}`);
949
- await fs.unlink(backup);
950
- }
951
- catch (err) {
952
- if (err instanceof Error && err.code !== 'ENOENT') {
953
- this.log.error(`Error unlinking old matter storage file: ${err}`);
954
- }
955
- }
956
- try {
957
- const dir = path.join(this.matterbridgeDirectory, 'matterstorage' + (getParameter('profile') ? '.' + getParameter('profile') : ''));
958
- this.log.info(`Removing matter node storage directory: ${dir}`);
959
- await fs.rm(dir, { recursive: true });
960
- const backup = path.join(this.matterbridgeDirectory, 'matterstorage' + (getParameter('profile') ? '.' + getParameter('profile') : '') + '.backup');
961
- this.log.info(`Removing matter node storage backup directory: ${backup}`);
962
- await fs.rm(backup, { recursive: true });
963
- }
964
- catch (err) {
965
- if (err instanceof Error && err.code !== 'ENOENT') {
966
- this.log.error(`Error removing matter storage directory: ${err}`);
967
- }
968
- }
969
- try {
970
- const dir = path.join(this.matterbridgeDirectory, 'storage' + (getParameter('profile') ? '.' + getParameter('profile') : ''));
971
- this.log.info(`Removing storage directory: ${dir}`);
972
- await fs.rm(dir, { recursive: true });
973
- const backup = path.join(this.matterbridgeDirectory, 'storage' + (getParameter('profile') ? '.' + getParameter('profile') : '') + '.backup');
974
- this.log.info(`Removing storage backup directory: ${backup}`);
975
- await fs.rm(backup, { recursive: true });
976
- }
977
- catch (err) {
978
- if (err instanceof Error && err.code !== 'ENOENT') {
979
- this.log.error(`Error removing storage directory: ${err}`);
980
- }
981
- }
982
- this.log.info('Factory reset done! Remove all paired fabrics from the controllers.');
983
- this.nodeContext = undefined;
984
- this.nodeStorage = undefined;
985
- this.plugins.clear();
986
- this.devices.clear();
987
935
  await this.cleanup('shutting down with factory reset...', false);
988
936
  }
989
937
  async cleanup(message, restart = false) {
@@ -1036,6 +984,15 @@ export class Matterbridge extends EventEmitter {
1036
984
  }
1037
985
  }
1038
986
  this.log.notice('Stopped matter server nodes');
987
+ if (message === 'shutting down with reset...') {
988
+ this.log.info('Resetting Matterbridge commissioning information...');
989
+ await this.matterStorageManager?.createContext('events')?.clearAll();
990
+ await this.matterStorageManager?.createContext('fabrics')?.clearAll();
991
+ await this.matterStorageManager?.createContext('root')?.clearAll();
992
+ await this.matterStorageManager?.createContext('sessions')?.clearAll();
993
+ await this.matterbridgeContext?.clearAll();
994
+ this.log.info('Matter storage reset done! Remove the bridge from the controller.');
995
+ }
1039
996
  await this.stopMatterStorage();
1040
997
  await this.frontend.stop();
1041
998
  try {
@@ -1063,6 +1020,48 @@ export class Matterbridge extends EventEmitter {
1063
1020
  }
1064
1021
  this.plugins.clear();
1065
1022
  this.devices.clear();
1023
+ if (message === 'shutting down with factory reset...') {
1024
+ try {
1025
+ const file = path.join(this.matterbridgeDirectory, 'matterbridge' + (getParameter('profile') ? '.' + getParameter('profile') : '') + '.json');
1026
+ this.log.info(`Unlinking old matter storage file: ${file}`);
1027
+ await fs.unlink(file);
1028
+ const backup = path.join(this.matterbridgeDirectory, 'matterbridge' + (getParameter('profile') ? '.' + getParameter('profile') : '') + '.backup.json');
1029
+ this.log.info(`Unlinking old matter storage backup file: ${backup}`);
1030
+ await fs.unlink(backup);
1031
+ }
1032
+ catch (err) {
1033
+ if (err instanceof Error && err.code !== 'ENOENT') {
1034
+ this.log.error(`Error unlinking old matter storage file: ${err}`);
1035
+ }
1036
+ }
1037
+ try {
1038
+ const dir = path.join(this.matterbridgeDirectory, 'matterstorage' + (getParameter('profile') ? '.' + getParameter('profile') : ''));
1039
+ this.log.info(`Removing matter node storage directory: ${dir}`);
1040
+ await fs.rm(dir, { recursive: true });
1041
+ const backup = path.join(this.matterbridgeDirectory, 'matterstorage' + (getParameter('profile') ? '.' + getParameter('profile') : '') + '.backup');
1042
+ this.log.info(`Removing matter node storage backup directory: ${backup}`);
1043
+ await fs.rm(backup, { recursive: true });
1044
+ }
1045
+ catch (err) {
1046
+ if (err instanceof Error && err.code !== 'ENOENT') {
1047
+ this.log.error(`Error removing matter storage directory: ${err}`);
1048
+ }
1049
+ }
1050
+ try {
1051
+ const dir = path.join(this.matterbridgeDirectory, 'storage' + (getParameter('profile') ? '.' + getParameter('profile') : ''));
1052
+ this.log.info(`Removing storage directory: ${dir}`);
1053
+ await fs.rm(dir, { recursive: true });
1054
+ const backup = path.join(this.matterbridgeDirectory, 'storage' + (getParameter('profile') ? '.' + getParameter('profile') : '') + '.backup');
1055
+ this.log.info(`Removing storage backup directory: ${backup}`);
1056
+ await fs.rm(backup, { recursive: true });
1057
+ }
1058
+ catch (err) {
1059
+ if (err instanceof Error && err.code !== 'ENOENT') {
1060
+ this.log.error(`Error removing storage directory: ${err}`);
1061
+ }
1062
+ }
1063
+ this.log.info('Factory reset done! Remove all paired fabrics from the controllers.');
1064
+ }
1066
1065
  this.deregisterProcesslHandlers();
1067
1066
  if (restart) {
1068
1067
  if (message === 'updating...') {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "files": {
3
3
  "main.css": "./static/css/main.cf25d33e.css",
4
- "main.js": "./static/js/main.1c3bc5a8.js",
4
+ "main.js": "./static/js/main.aeec898e.js",
5
5
  "static/js/453.abd36b29.chunk.js": "./static/js/453.abd36b29.chunk.js",
6
6
  "static/media/roboto-latin-700-normal.woff2": "./static/media/roboto-latin-700-normal.4535474e1cf8598695ad.woff2",
7
7
  "static/media/roboto-latin-500-normal.woff2": "./static/media/roboto-latin-500-normal.7077203b1982951ecf76.woff2",
@@ -61,11 +61,11 @@
61
61
  "static/media/roboto-greek-ext-400-normal.woff": "./static/media/roboto-greek-ext-400-normal.16eb83b4a3b1ea994243.woff",
62
62
  "index.html": "./index.html",
63
63
  "main.cf25d33e.css.map": "./static/css/main.cf25d33e.css.map",
64
- "main.1c3bc5a8.js.map": "./static/js/main.1c3bc5a8.js.map",
64
+ "main.aeec898e.js.map": "./static/js/main.aeec898e.js.map",
65
65
  "453.abd36b29.chunk.js.map": "./static/js/453.abd36b29.chunk.js.map"
66
66
  },
67
67
  "entrypoints": [
68
68
  "static/css/main.cf25d33e.css",
69
- "static/js/main.1c3bc5a8.js"
69
+ "static/js/main.aeec898e.js"
70
70
  ]
71
71
  }
@@ -1 +1 @@
1
- <!doctype html><html lang="en"><head><meta charset="utf-8"/><base href="./"><link rel="icon" href="./matterbridge 32x32.png"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><title>Matterbridge</title><link rel="manifest" href="./manifest.json"/><script defer="defer" src="./static/js/main.1c3bc5a8.js"></script><link href="./static/css/main.cf25d33e.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
1
+ <!doctype html><html lang="en"><head><meta charset="utf-8"/><base href="./"><link rel="icon" href="./matterbridge 32x32.png"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><title>Matterbridge</title><link rel="manifest" href="./manifest.json"/><script defer="defer" src="./static/js/main.aeec898e.js"></script><link href="./static/css/main.cf25d33e.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>