matterbridge 2.1.6-dev.4 → 2.1.6-dev.6
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 +8 -6
- package/README-DEV.md +1 -1
- package/README-DOCKER.md +1 -1
- package/README-EDGE.md +1 -1
- package/README-NGINX.md +1 -1
- package/README-PODMAN.md +1 -1
- package/README-SERVICE.md +1 -1
- package/README.md +18 -18
- package/dist/cli.js +91 -89
- package/dist/frontend.js +20 -6
- package/dist/index.js +6 -8
- package/dist/matterbridge.js +55 -64
- package/dist/matterbridgeEndpoint.js +1 -1
- package/dist/matterbridgeEndpointHelpers.js +2 -2
- package/dist/matterbridgePlatform.js +2 -2
- package/dist/utils/colorUtils.js +1 -1
- package/dist/utils/export.js +2 -0
- package/dist/utils/isvalid.js +50 -0
- package/dist/utils/parameter.js +26 -0
- package/dist/utils/utils.js +19 -81
- package/frontend/build/asset-manifest.json +3 -3
- package/frontend/build/index.html +1 -1
- package/frontend/build/static/js/{main.257513e8.js → main.438c6c47.js} +9 -9
- package/frontend/build/static/js/main.438c6c47.js.map +1 -0
- package/npm-shrinkwrap.json +50 -50
- package/package.json +2 -2
- package/frontend/build/static/js/main.257513e8.js.map +0 -1
- /package/frontend/build/static/js/{main.257513e8.js.LICENSE.txt → main.438c6c47.js.LICENSE.txt} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# <img src="
|
|
1
|
+
# <img src="frontend/public/matterbridge.svg" alt="Matterbridge Logo" width="64px" height="64px"> Matterbridge changelog
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
@@ -33,22 +33,24 @@ matterbridge-zigbee2mqtt v. 2.4.4
|
|
|
33
33
|
matterbridge-somfy-tahoma v. 1.2.3
|
|
34
34
|
matterbridge-hass v. 0.0.8
|
|
35
35
|
|
|
36
|
-
## [2.1.6] - 2025-02-
|
|
36
|
+
## [2.1.6] - 2025-02-18
|
|
37
37
|
|
|
38
38
|
### Added
|
|
39
39
|
|
|
40
|
-
- [docker]: Added health check directly in the docker image. No need to change configuration.
|
|
40
|
+
- [docker]: Added health check directly in the docker image. No need to change configuration of docker compose.
|
|
41
41
|
- [platform]: Saving in the storage the selects for faster loading of plugins.
|
|
42
42
|
- [icon]: Added matterbridge svg icon (thanks: https://github.com/robvanoostenrijk https://github.com/stuntguy3000).
|
|
43
43
|
- [frontend]: Added processUptime.
|
|
44
44
|
- [frontend]: Frontend v.2.4.2.
|
|
45
45
|
- [PluginManager]: Refactor PluginManager to optimize memory and load time.
|
|
46
|
+
- [frontend]: Added Share fabrics and Stop sharing to the menu. This allows to pair other controllers without the need to share from the first controller.
|
|
46
47
|
|
|
47
48
|
### Changed
|
|
48
49
|
|
|
49
50
|
- [package]: Update matter.js to 0.12.4-alpha.0-20250212-b2729c9eb
|
|
50
51
|
- [package]: Update matter.js to 0.12.4-alpha.0-20250213-1187f81eb
|
|
51
52
|
- [package]: Update matter.js to 0.12.4-alpha.0-20250215-5af08a8d6
|
|
53
|
+
- [package]: Update matter.js to 0.12.4-alpha.0-20250217-b0bba5179
|
|
52
54
|
|
|
53
55
|
<a href="https://www.buymeacoffee.com/luligugithub">
|
|
54
56
|
<img src="./yellow-button.png" alt="Buy me a coffee" width="120">
|
|
@@ -259,7 +261,7 @@ matterbridge-hass v. 0.0.8
|
|
|
259
261
|
|
|
260
262
|
### Added
|
|
261
263
|
|
|
262
|
-
- [edge]: Added guide
|
|
264
|
+
- [edge]: Added guide [README-EDGE.md](README-EDGE.md).
|
|
263
265
|
- [storage]: Added conversion from old matter storage to the new api format with fabrics, resumptionRecords, network, commissioning, operationalCredentials, acl and parts number. The conversion is triggered every time you shutdown or restart matterbridge till the new storage has been used with matterbridge edge.
|
|
264
266
|
- [storage]: Added conversion for child endpoint numbers.
|
|
265
267
|
- [storage]: Added conversion for childbridge mode.
|
|
@@ -396,7 +398,7 @@ It is possible that some controllers see them as new devices or need time to rea
|
|
|
396
398
|
### Added
|
|
397
399
|
|
|
398
400
|
- [matter.js]: Almost completed the phase 2 of migration to edge (matter.js new API).
|
|
399
|
-
- [nginx]: Added the route /matterbridge/ to be used with nginx proxy server
|
|
401
|
+
- [nginx]: Added the route /matterbridge/ to be used with nginx proxy server [README-NGINX.md](README-NGINX.md).
|
|
400
402
|
- [config]: Config and schema are loaded before loading the plugin to allow to configure the plugin even when it throws error on load.
|
|
401
403
|
- [config]: Added version to the config.
|
|
402
404
|
- [frontend]: Added badge "edge" when running in edge mode.
|
|
@@ -600,7 +602,7 @@ It is possible that some controllers see them as new devices or need time to rea
|
|
|
600
602
|
|
|
601
603
|
### Breaking Changes for developers
|
|
602
604
|
|
|
603
|
-
- please read this [Development guide lines](
|
|
605
|
+
- please read this [Development guide lines](README-DEV.md)
|
|
604
606
|
|
|
605
607
|
### Added
|
|
606
608
|
|
package/README-DEV.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# <img src="
|
|
1
|
+
# <img src="frontend/public/matterbridge.svg" alt="Matterbridge Logo" width="64px" height="64px"> Matterbridge
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/matterbridge)
|
|
4
4
|
[](https://www.npmjs.com/package/matterbridge)
|
package/README-DOCKER.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# <img src="
|
|
1
|
+
# <img src="frontend/public/matterbridge.svg" alt="Matterbridge Logo" width="64px" height="64px"> Matterbridge
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/matterbridge)
|
|
4
4
|
[](https://www.npmjs.com/package/matterbridge)
|
package/README-EDGE.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# <img src="
|
|
1
|
+
# <img src="frontend/public/matterbridge.svg" alt="Matterbridge Logo" width="64px" height="64px"> Matterbridge edge
|
|
2
2
|
|
|
3
3
|
Matterbridge Edge is the version of Matterbridge running with the new Matter.js API.
|
|
4
4
|
|
package/README-NGINX.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# <img src="
|
|
1
|
+
# <img src="frontend/public/matterbridge.svg" alt="Matterbridge Logo" width="64px" height="64px"> Matterbridge
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/matterbridge)
|
|
4
4
|
[](https://www.npmjs.com/package/matterbridge)
|
package/README-PODMAN.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# <img src="
|
|
1
|
+
# <img src="frontend/public/matterbridge.svg" alt="Matterbridge Logo" width="64px" height="64px"> Matterbridge
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/matterbridge)
|
|
4
4
|
[](https://www.npmjs.com/package/matterbridge)
|
package/README-SERVICE.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# <img src="
|
|
1
|
+
# <img src="frontend/public/matterbridge.svg" alt="Matterbridge Logo" width="64px" height="64px"> Matterbridge
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/matterbridge)
|
|
4
4
|
[](https://www.npmjs.com/package/matterbridge)
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# <img src="
|
|
1
|
+
# <img src="frontend/public/matterbridge.svg" alt="Matterbridge Logo" width="64px" height="64px"> Matterbridge
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/matterbridge)
|
|
4
4
|
[](https://www.npmjs.com/package/matterbridge)
|
|
@@ -121,34 +121,34 @@ To use the frontend with ssl place the certificates in the .matterbridge/certs d
|
|
|
121
121
|
From the frontend you can do all operations in an easy way.
|
|
122
122
|
|
|
123
123
|
Home page:
|
|
124
|
-

|
|
125
125
|
|
|
126
126
|
Devices page:
|
|
127
|
-
[See the screenshot here](
|
|
127
|
+
[See the screenshot here](screenshot/Screenshot%20devices.jpg)
|
|
128
128
|
|
|
129
129
|
Logs page:
|
|
130
|
-
[See the screenshot here](
|
|
130
|
+
[See the screenshot here](screenshot/Screenshot%20logs.jpg)
|
|
131
131
|
|
|
132
132
|
Config editor:
|
|
133
|
-
[See the screenshot here](
|
|
133
|
+
[See the screenshot here](screenshot/Screenshot%20config%20editor.jpg)
|
|
134
134
|
|
|
135
135
|
## Advanced configurations
|
|
136
136
|
|
|
137
137
|
### Run matterbridge as a daemon with systemctl (Linux only)
|
|
138
138
|
|
|
139
|
-
[Service configurations](
|
|
139
|
+
[Service configurations](README-SERVICE.md)
|
|
140
140
|
|
|
141
141
|
### Run matterbridge with docker and docker compose
|
|
142
142
|
|
|
143
|
-
[Docker configurations](
|
|
143
|
+
[Docker configurations](README-DOCKER.md)
|
|
144
144
|
|
|
145
145
|
### Run matterbridge with podman
|
|
146
146
|
|
|
147
|
-
[Podman configurations](
|
|
147
|
+
[Podman configurations](README-PODMAN.md)
|
|
148
148
|
|
|
149
149
|
### Run matterbridge with nginx
|
|
150
150
|
|
|
151
|
-
[Nginx configurations](
|
|
151
|
+
[Nginx configurations](README-NGINX.md)
|
|
152
152
|
|
|
153
153
|
### Run matterbridge as an home assistant add-on with the official add-on
|
|
154
154
|
|
|
@@ -160,14 +160,14 @@ The other Home Assistant Community Add-ons and plugins are not verified to work
|
|
|
160
160
|
|
|
161
161
|
## Development
|
|
162
162
|
|
|
163
|
-
[Development](
|
|
163
|
+
[Development](README-DEV.md)
|
|
164
164
|
|
|
165
165
|
## Plugins
|
|
166
166
|
|
|
167
167
|
### Shelly
|
|
168
168
|
|
|
169
169
|
<a href="https://github.com/Luligu/matterbridge-shelly">
|
|
170
|
-
<img src="
|
|
170
|
+
<img src="screenshot/Shelly.svg" alt="Shelly plugin logo" width="100" />
|
|
171
171
|
</a>
|
|
172
172
|
|
|
173
173
|
Matterbridge shelly plugin allows you to expose all Shelly Gen 1, Gen 2, Gen 3 and BLU devices to Matter.
|
|
@@ -196,7 +196,7 @@ Features:
|
|
|
196
196
|
### Zigbee2MQTT
|
|
197
197
|
|
|
198
198
|
<a href="https://github.com/Luligu/matterbridge-zigbee2mqtt">
|
|
199
|
-
<img src="
|
|
199
|
+
<img src="screenshot/Zigbee2MQTT.svg" alt="Zigbee2MQTT plugin logo" width="100" />
|
|
200
200
|
</a>
|
|
201
201
|
|
|
202
202
|
Matterbridge zigbee2mqtt is a matterbridge production-level plugin that expose all zigbee2mqtt devices and groups to Matter.
|
|
@@ -206,7 +206,7 @@ No hub or dedicated hardware needed.
|
|
|
206
206
|
### Somfy tahoma
|
|
207
207
|
|
|
208
208
|
<a href="https://github.com/Luligu/matterbridge-somfy-tahoma">
|
|
209
|
-
<img src="
|
|
209
|
+
<img src="screenshot/Somfy.svg" alt="Somfy plugin logo" width="100" />
|
|
210
210
|
</a>
|
|
211
211
|
|
|
212
212
|
Matterbridge Somfy Tahoma is a matterbridge production-level plugin that expose the Somfy Tahoma screen devices to Matter.
|
|
@@ -351,7 +351,7 @@ Place your own certificates in the `.matterbridge/cert` directory:
|
|
|
351
351
|
- `key.pem`
|
|
352
352
|
- `ca.pem` (optional)
|
|
353
353
|
|
|
354
|
-

|
|
355
355
|
|
|
356
356
|
### Change the command line
|
|
357
357
|
|
|
@@ -365,7 +365,7 @@ matterbridge -ssl -frontend 443
|
|
|
365
365
|
|
|
366
366
|
If the certificate are correctly configured, you will be able to connect with https to the frontend.
|
|
367
367
|
|
|
368
|
-

|
|
369
369
|
|
|
370
370
|
## How to send the debug log files
|
|
371
371
|
|
|
@@ -373,9 +373,9 @@ If the certificate are correctly configured, you will be able to connect with ht
|
|
|
373
373
|
|
|
374
374
|
In the frontend, go to settings and enable debug mode as shown below:
|
|
375
375
|
|
|
376
|
-

|
|
377
377
|
|
|
378
|
-

|
|
379
379
|
|
|
380
380
|
### Restart
|
|
381
381
|
|
|
@@ -383,7 +383,7 @@ Wait a few minutes to allow the logs to to accumulate.
|
|
|
383
383
|
|
|
384
384
|
Then, from the dots menu in the frontend, download the `matterbridge.log` and `matter.log` files.
|
|
385
385
|
|
|
386
|
-

|
|
387
387
|
|
|
388
388
|
# Known general issues
|
|
389
389
|
|
package/dist/cli.js
CHANGED
|
@@ -1,62 +1,48 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Matterbridge } from './matterbridge.js';
|
|
3
|
-
import {
|
|
3
|
+
import { getIntParameter, hasParameter } from './utils/export.js';
|
|
4
|
+
import { AnsiLogger, BRIGHT, CYAN, db, YELLOW } from './logger/export.js';
|
|
5
|
+
import { EventEmitter } from 'node:events';
|
|
4
6
|
export const cliEmitter = new EventEmitter();
|
|
5
7
|
export let instance;
|
|
6
8
|
let session;
|
|
7
9
|
let memoryCheckInterval;
|
|
8
10
|
let prevCpus;
|
|
9
11
|
export let lastCpuUsage = 0;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (
|
|
26
|
-
|
|
27
|
-
}
|
|
12
|
+
let peakCpu = 0;
|
|
13
|
+
let peakRss = 0;
|
|
14
|
+
const log = new AnsiLogger({ logName: 'Cli', logTimestampFormat: 4, logLevel: hasParameter('debug') ? "debug" : "info" });
|
|
15
|
+
const formatMemoryUsage = (bytes) => {
|
|
16
|
+
if (bytes >= 1024 ** 3) {
|
|
17
|
+
return `${(bytes / 1024 ** 3).toFixed(2)} GB`;
|
|
18
|
+
}
|
|
19
|
+
else if (bytes >= 1024 ** 2) {
|
|
20
|
+
return `${(bytes / 1024 ** 2).toFixed(2)} MB`;
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
return `${(bytes / 1024).toFixed(2)} KB`;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const formatOsUpTime = (seconds) => {
|
|
27
|
+
if (seconds >= 86400) {
|
|
28
|
+
const days = Math.floor(seconds / 86400);
|
|
29
|
+
return `${days} day${days !== 1 ? 's' : ''}`;
|
|
30
|
+
}
|
|
31
|
+
if (seconds >= 3600) {
|
|
32
|
+
const hours = Math.floor(seconds / 3600);
|
|
33
|
+
return `${hours} hour${hours !== 1 ? 's' : ''}`;
|
|
34
|
+
}
|
|
35
|
+
if (seconds >= 60) {
|
|
36
|
+
const minutes = Math.floor(seconds / 60);
|
|
37
|
+
return `${minutes} minute${minutes !== 1 ? 's' : ''}`;
|
|
38
|
+
}
|
|
39
|
+
return `${seconds} second${seconds !== 1 ? 's' : ''}`;
|
|
40
|
+
};
|
|
28
41
|
async function startCpuMemoryCheck() {
|
|
29
42
|
const os = await import('node:os');
|
|
30
|
-
|
|
31
|
-
console.log(cli + `CLI: Cpu memory check started` + rs);
|
|
43
|
+
log.debug(`Cpu memory check started`);
|
|
32
44
|
prevCpus = os.cpus();
|
|
33
45
|
clearInterval(memoryCheckInterval);
|
|
34
|
-
const formatMemoryUsage = (bytes) => {
|
|
35
|
-
if (bytes >= 1024 ** 3) {
|
|
36
|
-
return `${(bytes / 1024 ** 3).toFixed(2)} GB`;
|
|
37
|
-
}
|
|
38
|
-
else if (bytes >= 1024 ** 2) {
|
|
39
|
-
return `${(bytes / 1024 ** 2).toFixed(2)} MB`;
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
return `${(bytes / 1024).toFixed(2)} KB`;
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
const formatOsUpTime = (seconds) => {
|
|
46
|
-
if (seconds >= 86400) {
|
|
47
|
-
const days = Math.floor(seconds / 86400);
|
|
48
|
-
return `${days} day${days !== 1 ? 's' : ''}`;
|
|
49
|
-
}
|
|
50
|
-
if (seconds >= 3600) {
|
|
51
|
-
const hours = Math.floor(seconds / 3600);
|
|
52
|
-
return `${hours} hour${hours !== 1 ? 's' : ''}`;
|
|
53
|
-
}
|
|
54
|
-
if (seconds >= 60) {
|
|
55
|
-
const minutes = Math.floor(seconds / 60);
|
|
56
|
-
return `${minutes} minute${minutes !== 1 ? 's' : ''}`;
|
|
57
|
-
}
|
|
58
|
-
return `${seconds} second${seconds !== 1 ? 's' : ''}`;
|
|
59
|
-
};
|
|
60
46
|
const interval = () => {
|
|
61
47
|
const systemUptime = formatOsUpTime(Math.floor(os.uptime()));
|
|
62
48
|
const processUptime = formatOsUpTime(Math.floor(process.uptime()));
|
|
@@ -69,13 +55,14 @@ async function startCpuMemoryCheck() {
|
|
|
69
55
|
const heapUsed = formatMemoryUsage(memoryUsageRaw.heapUsed);
|
|
70
56
|
const external = formatMemoryUsage(memoryUsageRaw.external);
|
|
71
57
|
const arrayBuffers = formatMemoryUsage(memoryUsageRaw.arrayBuffers);
|
|
58
|
+
if (memoryUsageRaw.rss > peakRss)
|
|
59
|
+
peakRss = memoryUsageRaw.rss;
|
|
72
60
|
cliEmitter.emit('memory', totalMememory, freeMemory, rss, heapTotal, heapUsed, external, arrayBuffers);
|
|
73
61
|
const currCpus = os.cpus();
|
|
74
62
|
let cpuUsageLog;
|
|
75
63
|
if (currCpus.length !== prevCpus.length) {
|
|
76
64
|
prevCpus = currCpus;
|
|
77
|
-
|
|
78
|
-
console.log(cli + `CLI: Cpu check length failed, resetting previous cpus` + rs);
|
|
65
|
+
log.debug(`Cpu check length failed, resetting previous cpus`);
|
|
79
66
|
return;
|
|
80
67
|
}
|
|
81
68
|
let totalIdle = 0, totalTick = 0;
|
|
@@ -88,59 +75,63 @@ async function startCpuMemoryCheck() {
|
|
|
88
75
|
});
|
|
89
76
|
const cpuUsage = 100 - (totalIdle / totalTick) * 100;
|
|
90
77
|
if (totalTick === 0 || isNaN(cpuUsage) || !isFinite(cpuUsage) || cpuUsage <= 0) {
|
|
91
|
-
if (
|
|
92
|
-
|
|
78
|
+
if (lastCpuUsage != 0)
|
|
79
|
+
log.debug(`Cpu check failed, using previous cpus`);
|
|
93
80
|
cpuUsageLog = lastCpuUsage.toFixed(2);
|
|
94
81
|
}
|
|
95
82
|
else {
|
|
96
83
|
cpuUsageLog = cpuUsage.toFixed(2);
|
|
97
84
|
lastCpuUsage = cpuUsage;
|
|
85
|
+
if (lastCpuUsage > peakCpu)
|
|
86
|
+
peakCpu = lastCpuUsage;
|
|
98
87
|
cliEmitter.emit('cpu', lastCpuUsage);
|
|
99
88
|
}
|
|
100
89
|
prevCpus = currCpus;
|
|
101
|
-
|
|
102
|
-
console.log(`${YELLOW}${BRIGHT}Cpu usage:${db} ${CYAN}${cpuUsageLog.padStart(6, ' ')} %${db} ${YELLOW}${BRIGHT}Memory usage:${db} rss ${CYAN}${rss}${db} heapTotal ${CYAN}${heapTotal}${db} heapUsed ${CYAN}${heapUsed}${db} external ${external} arrayBuffers ${arrayBuffers}` +
|
|
103
|
-
rs);
|
|
90
|
+
log.debug(`***${YELLOW}${BRIGHT}Cpu usage:${db} ${CYAN}${cpuUsageLog.padStart(6, ' ')} %${db} ${YELLOW}${BRIGHT}Memory usage:${db} rss ${CYAN}${rss}${db} heapTotal ${CYAN}${heapTotal}${db} heapUsed ${CYAN}${heapUsed}${db} external ${external} arrayBuffers ${arrayBuffers}`);
|
|
104
91
|
};
|
|
105
92
|
interval();
|
|
106
|
-
memoryCheckInterval = setInterval(interval, 10 * 1000);
|
|
93
|
+
memoryCheckInterval = setInterval(interval, getIntParameter('memoryinterval') ?? 10 * 1000);
|
|
107
94
|
}
|
|
108
95
|
async function stopCpuMemoryCheck() {
|
|
109
|
-
|
|
110
|
-
console.log(cli + `CLI: Cpu memory check stopped` + rs);
|
|
96
|
+
log.debug(`***Cpu memory check stopped. Peak cpu: ${CYAN}${peakCpu.toFixed(2)} %${db}. Peak rss: ${CYAN}${formatMemoryUsage(peakRss)}${db}.`);
|
|
111
97
|
clearInterval(memoryCheckInterval);
|
|
112
98
|
}
|
|
113
99
|
async function startInspector() {
|
|
114
100
|
const { Session } = await import('node:inspector');
|
|
115
|
-
|
|
116
|
-
console.log(cli + `CLI: Starting heap sampling...` + rs);
|
|
101
|
+
log.debug(`Starting heap sampling...`);
|
|
117
102
|
session = new Session();
|
|
118
103
|
session.connect();
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
console.error(err);
|
|
122
|
-
else
|
|
123
|
-
console.log(cli + `CLI: Heap sampling started` + rs);
|
|
104
|
+
await new Promise((resolve, reject) => {
|
|
105
|
+
session?.post('HeapProfiler.startSampling', {}, (err) => (err ? reject(err) : resolve()));
|
|
124
106
|
});
|
|
107
|
+
log.debug(`Started heap sampling`);
|
|
125
108
|
}
|
|
126
109
|
async function stopInspector() {
|
|
127
110
|
const { writeFileSync } = await import('node:fs');
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
111
|
+
log.debug(`Stopping heap sampling...`);
|
|
112
|
+
if (!session) {
|
|
113
|
+
log.error('No active inspector session.');
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
try {
|
|
117
|
+
const result = await new Promise((resolve, reject) => {
|
|
118
|
+
session?.post('HeapProfiler.stopSampling', (err, result) => (err ? reject(err) : resolve(result)));
|
|
119
|
+
});
|
|
120
|
+
const profile = JSON.stringify(result.profile);
|
|
121
|
+
writeFileSync('Heap-sampling-profile.heapprofile', profile);
|
|
122
|
+
log.debug('Heap sampling profile saved to Heap-sampling-profile.heapprofile');
|
|
123
|
+
}
|
|
124
|
+
catch (err) {
|
|
125
|
+
log.error(`Failed to stop heap sampling: ${err instanceof Error ? err.message : err}`);
|
|
126
|
+
}
|
|
127
|
+
finally {
|
|
128
|
+
session.disconnect();
|
|
140
129
|
session = undefined;
|
|
141
|
-
|
|
130
|
+
log.debug(`Stopped heap sampling`);
|
|
131
|
+
}
|
|
142
132
|
}
|
|
143
133
|
function registerHandlers() {
|
|
134
|
+
log.debug('Registering event handlers...');
|
|
144
135
|
if (instance)
|
|
145
136
|
instance.on('shutdown', async () => shutdown());
|
|
146
137
|
if (instance)
|
|
@@ -151,38 +142,49 @@ function registerHandlers() {
|
|
|
151
142
|
instance.on('startmemorycheck', async () => start());
|
|
152
143
|
if (instance)
|
|
153
144
|
instance.on('stopmemorycheck', async () => stop());
|
|
145
|
+
log.debug('Registered event handlers');
|
|
154
146
|
}
|
|
155
147
|
async function shutdown() {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
if (process.argv.includes('-inspector'))
|
|
148
|
+
log.debug('Received shutdown event, exiting...');
|
|
149
|
+
if (hasParameter('inspect'))
|
|
159
150
|
await stopInspector();
|
|
160
151
|
await stopCpuMemoryCheck();
|
|
161
152
|
process.exit(0);
|
|
162
153
|
}
|
|
163
154
|
async function restart() {
|
|
164
|
-
|
|
165
|
-
console.log(cli + 'CLI: received restart event, loading...' + rs);
|
|
155
|
+
log.debug('Received restart event, loading...');
|
|
166
156
|
instance = await Matterbridge.loadInstance(true);
|
|
167
157
|
registerHandlers();
|
|
168
158
|
}
|
|
169
159
|
async function update() {
|
|
170
|
-
|
|
171
|
-
console.log(cli + 'CLI: received update event, updating...' + rs);
|
|
160
|
+
log.debug('Received update event, updating...');
|
|
172
161
|
instance = await Matterbridge.loadInstance(true);
|
|
173
162
|
registerHandlers();
|
|
174
163
|
}
|
|
175
164
|
async function start() {
|
|
176
|
-
|
|
177
|
-
console.log(cli + 'CLI: received start memory check event' + rs);
|
|
165
|
+
log.debug('Received start memory check event');
|
|
178
166
|
startCpuMemoryCheck();
|
|
179
167
|
}
|
|
180
168
|
async function stop() {
|
|
181
|
-
|
|
182
|
-
console.log(cli + 'CLI: received stop memory check event' + rs);
|
|
169
|
+
log.debug('Received stop memory check event');
|
|
183
170
|
stopCpuMemoryCheck();
|
|
184
171
|
}
|
|
172
|
+
async function main() {
|
|
173
|
+
log.debug(`Cli main() started`);
|
|
174
|
+
await startCpuMemoryCheck();
|
|
175
|
+
if (hasParameter('inspect'))
|
|
176
|
+
await startInspector();
|
|
177
|
+
log.debug(`***Matterbridge.loadInstance(true) called`);
|
|
178
|
+
instance = await Matterbridge.loadInstance(true);
|
|
179
|
+
log.debug(`***Matterbridge.loadInstance(true) exited`);
|
|
180
|
+
if (!instance || instance.shutdown) {
|
|
181
|
+
shutdown();
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
registerHandlers();
|
|
185
|
+
}
|
|
186
|
+
}
|
|
185
187
|
process.title = 'matterbridge';
|
|
186
188
|
main().catch((error) => {
|
|
187
|
-
|
|
189
|
+
log.error(`Matterbridge.loadInstance() failed with error: ${error instanceof Error ? error.message : error}`);
|
|
188
190
|
});
|
package/dist/frontend.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { EndpointServer, Logger, LogLevel as MatterLogLevel, LogFormat as MatterLogFormat } from '@matter/main';
|
|
2
|
-
import { createServer } from 'http';
|
|
2
|
+
import { createServer } from 'node:http';
|
|
3
3
|
import https from 'https';
|
|
4
4
|
import express from 'express';
|
|
5
5
|
import WebSocket, { WebSocketServer } from 'ws';
|
|
6
|
-
import os from 'os';
|
|
7
|
-
import path from 'path';
|
|
8
|
-
import { promises as fs } from 'fs';
|
|
6
|
+
import os from 'node:os';
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
import { promises as fs } from 'node:fs';
|
|
9
9
|
import { AnsiLogger, stringify, debugStringify, CYAN, db, er, nf, rs, UNDERLINE, UNDERLINEOFF, wr, YELLOW } from './logger/export.js';
|
|
10
|
-
import { createZip, deepCopy,
|
|
10
|
+
import { createZip, deepCopy, isValidNumber, isValidObject, isValidString } from './utils/export.js';
|
|
11
11
|
import { plg } from './matterbridgeTypes.js';
|
|
12
|
+
import { hasParameter } from './utils/export.js';
|
|
12
13
|
export const WS_ID_LOG = 0;
|
|
13
14
|
export const WS_ID_REFRESH_NEEDED = 1;
|
|
14
15
|
export const WS_ID_RESTART_NEEDED = 2;
|
|
@@ -236,7 +237,7 @@ export class Frontend {
|
|
|
236
237
|
space_available_size: this.formatMemoryUsage(space.space_available_size),
|
|
237
238
|
physical_space_size: this.formatMemoryUsage(space.physical_space_size),
|
|
238
239
|
}));
|
|
239
|
-
const { default: module } = await import('module');
|
|
240
|
+
const { default: module } = await import('node:module');
|
|
240
241
|
const loadedModules = module._cache ? Object.keys(module._cache).sort() : [];
|
|
241
242
|
const memoryReport = {
|
|
242
243
|
memoryUsage,
|
|
@@ -1086,9 +1087,22 @@ export class Frontend {
|
|
|
1086
1087
|
}
|
|
1087
1088
|
else if (data.method === '/api/advertise') {
|
|
1088
1089
|
const pairingCodes = await this.matterbridge.advertiseServerNode(this.matterbridge.serverNode);
|
|
1090
|
+
this.matterbridge.matterbridgeInformation.matterbridgeAdvertise = true;
|
|
1091
|
+
this.matterbridge.matterbridgeQrPairingCode = pairingCodes?.qrPairingCode;
|
|
1092
|
+
this.matterbridge.matterbridgeManualPairingCode = pairingCodes?.manualPairingCode;
|
|
1093
|
+
this.wssSendRefreshRequired();
|
|
1094
|
+
this.wssSendSnackbarMessage(`Started fabrics share`, 0);
|
|
1089
1095
|
client.send(JSON.stringify({ id: data.id, method: data.method, src: 'Matterbridge', dst: data.src, response: pairingCodes }));
|
|
1090
1096
|
return;
|
|
1091
1097
|
}
|
|
1098
|
+
else if (data.method === '/api/stopadvertise') {
|
|
1099
|
+
await this.matterbridge.stopAdvertiseServerNode(this.matterbridge.serverNode);
|
|
1100
|
+
this.matterbridge.matterbridgeInformation.matterbridgeAdvertise = false;
|
|
1101
|
+
this.wssSendRefreshRequired();
|
|
1102
|
+
this.wssSendSnackbarMessage(`Stopped fabrics share`, 0);
|
|
1103
|
+
client.send(JSON.stringify({ id: data.id, method: data.method, src: 'Matterbridge', dst: data.src }));
|
|
1104
|
+
return;
|
|
1105
|
+
}
|
|
1092
1106
|
else if (data.method === '/api/settings') {
|
|
1093
1107
|
client.send(JSON.stringify({ id: data.id, method: data.method, src: 'Matterbridge', dst: data.src, response: await this.getApiSettings() }));
|
|
1094
1108
|
return;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { Matterbridge } from './matterbridge.js';
|
|
2
|
+
import { hasParameter } from './utils/export.js';
|
|
3
|
+
import { AnsiLogger } from './logger/export.js';
|
|
2
4
|
export { SemanticNamespace, ClosureTag, CompassDirectionTag, CompassLocationTag, DirectionTag, ElectricalMeasurementTag, LaundryTag, LevelTag, LocationTag, NumberTag, PositionTag, PowerSourceTag, RefrigeratorTag, RoomAirConditionerTag, SwitchesTag, } from '@matter/main';
|
|
3
5
|
export * from '@matter/main/clusters';
|
|
4
6
|
export * from '@matter/main/types';
|
|
@@ -11,16 +13,12 @@ export * from './matterbridgeDeviceTypes.js';
|
|
|
11
13
|
export * from './matterbridgePlatform.js';
|
|
12
14
|
export * from './matterbridgeAccessoryPlatform.js';
|
|
13
15
|
export * from './matterbridgeDynamicPlatform.js';
|
|
14
|
-
const
|
|
15
|
-
const er = '\u001B[38;5;9m';
|
|
16
|
-
const rs = '\u001B[40;0m';
|
|
16
|
+
const log = new AnsiLogger({ logName: 'Main', logTimestampFormat: 4, logLevel: hasParameter('debug') ? "debug" : "info" });
|
|
17
17
|
async function main() {
|
|
18
|
-
|
|
19
|
-
console.log(cli + 'MAIN: Matterbridge.loadInstance() called' + rs);
|
|
18
|
+
log.debug('***Matterbridge.loadInstance() called');
|
|
20
19
|
await Matterbridge.loadInstance();
|
|
21
|
-
|
|
22
|
-
console.log(cli + 'MAIN: Matterbridge.loadInstance() exited' + rs);
|
|
20
|
+
log.debug('***Matterbridge.loadInstance() exited');
|
|
23
21
|
}
|
|
24
22
|
main().catch((error) => {
|
|
25
|
-
|
|
23
|
+
log.error(`Matterbridge.loadInstance() failed with error: ${error instanceof Error ? error.message : error}`);
|
|
26
24
|
});
|