matterbridge 2.2.0-dev.6 → 2.2.0-dev.7

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
@@ -51,14 +51,7 @@ matterbridge-hass v. 0.0.8
51
51
 
52
52
  ### Changed
53
53
 
54
- - [package]: Update matter.js to 0.12.4-alpha.0-20250212-b2729c9eb
55
- - [package]: Update matter.js to 0.12.4-alpha.0-20250213-1187f81eb
56
- - [package]: Update matter.js to 0.12.4-alpha.0-20250215-5af08a8d6
57
- - [package]: Update matter.js to 0.12.4-alpha.0-20250217-b0bba5179
58
- - [package]: Update matter.js to 0.12.4-alpha.0-20250223-1e0341a1a
59
- - [package]: Update matter.js to 0.12.4-alpha.0-20250224-46934b522
60
- - [package]: Update matter.js to 0.12.4-alpha.0-20250225-52ac4166b
61
- - [package]: Update matter.js to 0.12.4-alpha.0-20250226-e4ba47db7
54
+ - [package]: Update matter.js to 0.12.4
62
55
  - [matterbridge]: The check for available updates now runs at restart and each 24 hours after.
63
56
 
64
57
  ### Fixed
package/dist/frontend.js CHANGED
@@ -402,6 +402,21 @@ export class Frontend {
402
402
  }
403
403
  });
404
404
  });
405
+ this.expressApp.get('/api/shellydownloadsystemlog', async (req, res) => {
406
+ this.log.debug('The frontend sent /api/shellydownloadsystemlog');
407
+ try {
408
+ await fs.access(path.join(this.matterbridge.matterbridgeDirectory, 'shelly.log'), fs.constants.F_OK);
409
+ }
410
+ catch (error) {
411
+ fs.appendFile(path.join(this.matterbridge.matterbridgeDirectory, 'shelly.log'), 'Create the Shelly system log before downloading it.');
412
+ }
413
+ res.download(path.join(this.matterbridge.matterbridgeDirectory, 'shelly.log'), 'shelly.log', (error) => {
414
+ if (error) {
415
+ this.log.error(`Error downloading Shelly system log file: ${error instanceof Error ? error.message : error}`);
416
+ res.status(500).send('Error downloading Shelly system log file');
417
+ }
418
+ });
419
+ });
405
420
  this.expressApp.get('/api/download-mjstorage', async (req, res) => {
406
421
  this.log.debug('The frontend sent /api/download-mjstorage');
407
422
  await createZip(path.join(os.tmpdir(), `matterbridge.${this.matterbridge.matterStorageName}.zip`), path.join(this.matterbridge.matterbridgeDirectory, this.matterbridge.matterStorageName));
@@ -1088,6 +1103,11 @@ export class Frontend {
1088
1103
  triggerShellyMainUpdate(this.matterbridge);
1089
1104
  return;
1090
1105
  }
1106
+ else if (data.method === '/api/shellycreatesystemlog') {
1107
+ const { createShellySystemLog } = await import('./shelly.js');
1108
+ createShellySystemLog(this.matterbridge);
1109
+ return;
1110
+ }
1091
1111
  else if (data.method === '/api/shellynetconfig') {
1092
1112
  this.log.debug('/api/shellynetconfig:', data.params);
1093
1113
  const { triggerShellyChangeIp: triggerShellyChangeNet } = await import('./shelly.js');
@@ -914,7 +914,7 @@ export class Matterbridge extends EventEmitter {
914
914
  async unregisterAndShutdownProcess() {
915
915
  this.log.info('Unregistering all devices and shutting down...');
916
916
  for (const plugin of this.plugins) {
917
- await this.removeAllBridgedEndpoints(plugin.name);
917
+ await this.removeAllBridgedEndpoints(plugin.name, 200);
918
918
  }
919
919
  this.log.debug('Waiting for the MessageExchange to finish...');
920
920
  await new Promise((resolve) => setTimeout(resolve, 1000));
@@ -1597,10 +1597,12 @@ export class Matterbridge extends EventEmitter {
1597
1597
  }
1598
1598
  this.devices.remove(device);
1599
1599
  }
1600
- async removeAllBridgedEndpoints(pluginName) {
1600
+ async removeAllBridgedEndpoints(pluginName, delay = 0) {
1601
1601
  this.log.debug(`Removing all bridged endpoints for plugin ${plg}${pluginName}${db}`);
1602
1602
  for (const device of this.devices.array().filter((device) => device.plugin === pluginName)) {
1603
1603
  await this.removeBridgedEndpoint(pluginName, device);
1604
+ if (delay > 0)
1605
+ await new Promise((resolve) => setTimeout(resolve, delay));
1604
1606
  }
1605
1607
  }
1606
1608
  sanitizeFabricInformations(fabricInfo) {
package/dist/shelly.js CHANGED
@@ -102,6 +102,25 @@ export async function triggerShellyReboot(matterbridge) {
102
102
  matterbridge.frontend.wssSendSnackbarMessage('Rebooting Shelly board...');
103
103
  });
104
104
  }
105
+ export async function createShellySystemLog(matterbridge) {
106
+ const { promises: fs } = await import('node:fs');
107
+ const path = await import('node:path');
108
+ matterbridge.log.debug(`Downloading Shelly system log...`);
109
+ getShelly('/api/logs/system', 60 * 1000)
110
+ .then(async (data) => {
111
+ fs.writeFile(path.join(matterbridge.matterbridgeDirectory, 'shelly.log'), data)
112
+ .then(() => {
113
+ matterbridge.log.notice(`Shelly system log ready for download`);
114
+ matterbridge.frontend.wssSendSnackbarMessage('Shelly system log ready for download');
115
+ })
116
+ .catch((error) => {
117
+ matterbridge.log.warn(`Error writing Shelly system log to file: ${error instanceof Error ? error.message : error}`);
118
+ });
119
+ })
120
+ .catch((error) => {
121
+ matterbridge.log.warn(`Error getting Shelly system log: ${error instanceof Error ? error.message : error}`);
122
+ });
123
+ }
105
124
  async function getShelly(api, timeout = 60000) {
106
125
  const http = await import('node:http');
107
126
  return new Promise((resolve, reject) => {
@@ -125,12 +144,17 @@ async function getShelly(api, timeout = 60000) {
125
144
  });
126
145
  res.on('end', () => {
127
146
  clearTimeout(timeoutId);
128
- try {
129
- const jsonData = JSON.parse(data);
130
- resolve(jsonData);
147
+ if (api !== '/api/logs/system') {
148
+ try {
149
+ const jsonData = JSON.parse(data);
150
+ resolve(jsonData);
151
+ }
152
+ catch (error) {
153
+ reject(new Error(`Failed to parse response JSON: ${error instanceof Error ? error.message : error}`));
154
+ }
131
155
  }
132
- catch (error) {
133
- reject(new Error(`Failed to parse response JSON: ${error instanceof Error ? error.message : error}`));
156
+ else {
157
+ resolve(data);
134
158
  }
135
159
  });
136
160
  });
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "files": {
3
3
  "main.css": "./static/css/main.cf25d33e.css",
4
- "main.js": "./static/js/main.f60aae10.js",
4
+ "main.js": "./static/js/main.8240902c.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.f60aae10.js.map": "./static/js/main.f60aae10.js.map",
64
+ "main.8240902c.js.map": "./static/js/main.8240902c.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.f60aae10.js"
69
+ "static/js/main.8240902c.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.f60aae10.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.8240902c.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>