@matterbridge/core 3.11.2-dev-20261106-98b10ca → 3.11.3-dev-20261107-92e4713
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/dist/backend.d.ts +3 -2
- package/dist/backend.js +8 -1
- package/dist/backendExpress.js +8 -8
- package/dist/backendWsServer.js +13 -2
- package/dist/deviceManager.d.ts +2 -4
- package/dist/deviceManager.js +7 -24
- package/dist/frontend.d.ts +1 -2
- package/dist/frontend.js +45 -54
- package/dist/matterNode.js +5 -5
- package/dist/matterNodeHelpers.d.ts +2 -2
- package/dist/matterNodeHelpers.js +1 -1
- package/package.json +6 -6
package/dist/backend.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import EventEmitter from 'node:events';
|
|
2
|
-
import { type ApiClusters, type ApiDevice, type ApiPlugin, type ApiSettings, type SharedMatterbridge, type ApiMatter } from '@matterbridge/types';
|
|
2
|
+
import { type ApiClusters, type ApiDevice, type ApiPlugin, type ApiSettings, type Device, type SharedMatterbridge, type ApiMatter } from '@matterbridge/types';
|
|
3
3
|
import type { BackendExpress } from './backendExpress.js';
|
|
4
4
|
import type { BackendWsServer } from './backendWsServer.js';
|
|
5
5
|
interface BackendEvents {
|
|
@@ -34,7 +34,8 @@ export declare class Backend extends EventEmitter<BackendEvents> {
|
|
|
34
34
|
stop(): Promise<void>;
|
|
35
35
|
getApiSettings(): Promise<ApiSettings>;
|
|
36
36
|
getApiPlugins(): Promise<ApiPlugin[]>;
|
|
37
|
-
|
|
37
|
+
getDevices(pluginName?: string): Promise<Device[]>;
|
|
38
|
+
getApiDevices(pluginName: string, extended?: boolean): Promise<ApiDevice[]>;
|
|
38
39
|
getApiCluster(pluginName: string, number: number, serialNumber: string, uniqueId: string): Promise<ApiClusters>;
|
|
39
40
|
generateDiagnostic(): Promise<void>;
|
|
40
41
|
getApiMatter(id: string): Promise<ApiMatter | undefined>;
|
package/dist/backend.js
CHANGED
|
@@ -341,9 +341,16 @@ export class Backend extends EventEmitter {
|
|
|
341
341
|
writeDiagnostic('Backend', `getApiPlugins() took ${(performance.now() - start).toFixed(2)} ms`);
|
|
342
342
|
return response.result.plugins;
|
|
343
343
|
}
|
|
344
|
+
async getDevices(pluginName) {
|
|
345
|
+
const start = performance.now();
|
|
346
|
+
const response = await this.server.fetch({ type: 'devices_array', src: 'frontend', dst: 'devices', params: { pluginName } });
|
|
347
|
+
if (this.diagnostic)
|
|
348
|
+
writeDiagnostic('Backend', `getDevices() took ${(performance.now() - start).toFixed(2)} ms`);
|
|
349
|
+
return response.result.devices;
|
|
350
|
+
}
|
|
344
351
|
async getApiDevices(pluginName, extended = false) {
|
|
345
352
|
const start = performance.now();
|
|
346
|
-
const response = await this.server.fetch({ type: '
|
|
353
|
+
const response = await this.server.fetch({ type: 'platform_get_apidevices', src: 'frontend', dst: 'platform', params: { pluginName, extended } });
|
|
347
354
|
if (this.diagnostic)
|
|
348
355
|
writeDiagnostic('Backend', `getApiDevices() took ${(performance.now() - start).toFixed(2)} ms`);
|
|
349
356
|
return response.result.devices;
|
package/dist/backendExpress.js
CHANGED
|
@@ -160,7 +160,7 @@ export class BackendExpress {
|
|
|
160
160
|
this.log.debug('The frontend sent /api/devices');
|
|
161
161
|
if (!this.validateReq(req, res))
|
|
162
162
|
return;
|
|
163
|
-
res.json(await this.backend.
|
|
163
|
+
res.json(await this.backend.getDevices());
|
|
164
164
|
});
|
|
165
165
|
this.expressApp.get('/api/view-mblog', async (req, res) => {
|
|
166
166
|
this.log.debug('The frontend sent /api/view-mblog');
|
|
@@ -283,8 +283,8 @@ export class BackendExpress {
|
|
|
283
283
|
}
|
|
284
284
|
});
|
|
285
285
|
});
|
|
286
|
-
this.expressApp.get('/api/
|
|
287
|
-
this.log.debug('The frontend sent /api/
|
|
286
|
+
this.expressApp.get('/api/view-history', async (req, res) => {
|
|
287
|
+
this.log.debug('The frontend sent /api/view-history');
|
|
288
288
|
if (!this.validateReq(req, res))
|
|
289
289
|
return;
|
|
290
290
|
try {
|
|
@@ -294,12 +294,12 @@ export class BackendExpress {
|
|
|
294
294
|
res.send(data);
|
|
295
295
|
}
|
|
296
296
|
catch (error) {
|
|
297
|
-
this.log.error(`Error in /api/
|
|
297
|
+
this.log.error(`Error in /api/view-history reading history file ${MATTERBRIDGE_HISTORY_FILE}: ${getErrorMessage(error)}`);
|
|
298
298
|
res.status(500).send('Error reading history file.');
|
|
299
299
|
}
|
|
300
300
|
});
|
|
301
|
-
this.expressApp.get('/api/
|
|
302
|
-
this.log.debug(`The frontend sent /api/
|
|
301
|
+
this.expressApp.get('/api/download-history', this.fileLimiter, async (req, res) => {
|
|
302
|
+
this.log.debug(`The frontend sent /api/download-history`);
|
|
303
303
|
if (!this.validateReq(req, res))
|
|
304
304
|
return;
|
|
305
305
|
try {
|
|
@@ -310,7 +310,7 @@ export class BackendExpress {
|
|
|
310
310
|
res.type('text/html; charset=utf-8');
|
|
311
311
|
res.download(path.join(os.tmpdir(), MATTERBRIDGE_HISTORY_FILE), MATTERBRIDGE_HISTORY_FILE, (error) => {
|
|
312
312
|
if (error) {
|
|
313
|
-
this.log.error(`Error in /api/
|
|
313
|
+
this.log.error(`Error in /api/download-history downloading history file ${MATTERBRIDGE_HISTORY_FILE}: ${getErrorMessage(error)}`);
|
|
314
314
|
sendDownloadError(res, error, 'Error downloading history file');
|
|
315
315
|
}
|
|
316
316
|
else {
|
|
@@ -319,7 +319,7 @@ export class BackendExpress {
|
|
|
319
319
|
});
|
|
320
320
|
}
|
|
321
321
|
catch (error) {
|
|
322
|
-
this.log.error(`Error in /api/
|
|
322
|
+
this.log.error(`Error in /api/download-history reading history file ${MATTERBRIDGE_HISTORY_FILE}: ${getErrorMessage(error)}`);
|
|
323
323
|
res.status(500).send('Error reading history file.');
|
|
324
324
|
}
|
|
325
325
|
});
|
package/dist/backendWsServer.js
CHANGED
|
@@ -209,11 +209,22 @@ export class BackendWsServer {
|
|
|
209
209
|
}
|
|
210
210
|
else if (data.method === '/api/devices') {
|
|
211
211
|
const start = performance.now();
|
|
212
|
-
const devices = await this.backend.
|
|
212
|
+
const devices = await this.backend.getDevices(isValidString(data.params.pluginName) ? data.params.pluginName : undefined);
|
|
213
213
|
if (this.diagnostic)
|
|
214
|
-
writeDiagnostic(`Frontend:${data.sender}`, `
|
|
214
|
+
writeDiagnostic(`Frontend:${data.sender}`, `getDevices() took ${(performance.now() - start).toFixed(2)} ms`);
|
|
215
215
|
sendResponse({ id: data.id, method: data.method, src: 'Matterbridge', dst: data.src, success: true, response: devices });
|
|
216
216
|
}
|
|
217
|
+
else if (data.method === '/api/platform-devices') {
|
|
218
|
+
if (!isValidString(data.params.pluginName, 10)) {
|
|
219
|
+
sendResponse({ id: data.id, method: data.method, src: 'Matterbridge', dst: data.src, error: 'Wrong parameter pluginName in /api/platform-devices' });
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
const start = performance.now();
|
|
223
|
+
const devices = await this.backend.getApiDevices(data.params.pluginName, data.params.extended);
|
|
224
|
+
if (this.diagnostic)
|
|
225
|
+
writeDiagnostic(`Frontend:${data.sender}`, `getApiDevices() took ${(performance.now() - start).toFixed(2)} ms`);
|
|
226
|
+
sendResponse({ id: data.id, method: data.method, src: 'Matterbridge', dst: data.src, success: true, pluginName: data.params.pluginName, response: devices });
|
|
227
|
+
}
|
|
217
228
|
else if (data.method === '/api/clusters') {
|
|
218
229
|
if (!isValidString(data.params.pluginName, 10)) {
|
|
219
230
|
sendResponse({ id: data.id, method: data.method, src: 'Matterbridge', dst: data.src, error: 'Wrong parameter pluginName in /api/clusters' });
|
package/dist/deviceManager.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Device } from '@matterbridge/types';
|
|
2
2
|
import { LogLevel } from 'node-ansi-logger';
|
|
3
3
|
import type { MatterbridgeEndpoint } from './matterbridgeEndpoint.js';
|
|
4
4
|
export declare class DeviceManager {
|
|
@@ -17,10 +17,8 @@ export declare class DeviceManager {
|
|
|
17
17
|
set(device: MatterbridgeEndpoint): MatterbridgeEndpoint;
|
|
18
18
|
remove(device: MatterbridgeEndpoint): boolean;
|
|
19
19
|
clear(): void;
|
|
20
|
-
private toBaseDevice;
|
|
21
20
|
array(): MatterbridgeEndpoint[];
|
|
22
|
-
baseArray(pluginName?: string):
|
|
23
|
-
apiDeviceArray(pluginName?: string, extended?: boolean): ApiDevice[];
|
|
21
|
+
baseArray(pluginName?: string): Device[];
|
|
24
22
|
[Symbol.iterator](): IterableIterator<MatterbridgeEndpoint>;
|
|
25
23
|
forEach(callback: (device: MatterbridgeEndpoint) => Promise<void>): Promise<void>;
|
|
26
24
|
set logLevel(logLevel: LogLevel);
|
package/dist/deviceManager.js
CHANGED
|
@@ -3,7 +3,7 @@ import { dev } from '@matterbridge/types';
|
|
|
3
3
|
import { hasParameter } from '@matterbridge/utils/cli';
|
|
4
4
|
import { logModuleLoaded } from '@matterbridge/utils/loader';
|
|
5
5
|
import { AnsiLogger, BLUE, CYAN, db, debugStringify, er } from 'node-ansi-logger';
|
|
6
|
-
import {
|
|
6
|
+
import { toDevice } from './matterNodeHelpers.js';
|
|
7
7
|
logModuleLoaded('Device Manager');
|
|
8
8
|
export class DeviceManager {
|
|
9
9
|
_devices = new Map();
|
|
@@ -45,34 +45,31 @@ export class DeviceManager {
|
|
|
45
45
|
case 'devices_get':
|
|
46
46
|
{
|
|
47
47
|
const endpoint = this.get(msg.params.uniqueId);
|
|
48
|
-
this.server.respond({ ...msg, result: { device: endpoint ?
|
|
48
|
+
this.server.respond({ ...msg, result: { device: endpoint ? toDevice(endpoint) : undefined } });
|
|
49
49
|
}
|
|
50
50
|
break;
|
|
51
51
|
case 'devices_set':
|
|
52
52
|
{
|
|
53
53
|
const device = msg.params.device.uniqueId ? this._devices.get(msg.params.device.uniqueId) : undefined;
|
|
54
54
|
if (device) {
|
|
55
|
-
Object.assign(device, Object.fromEntries(Object.entries(
|
|
55
|
+
Object.assign(device, Object.fromEntries(Object.entries(toDevice(msg.params.device)).filter(([, value]) => value !== undefined)));
|
|
56
56
|
this.server.respond({ ...msg, result: { device: device } });
|
|
57
57
|
}
|
|
58
58
|
else {
|
|
59
|
-
this.server.respond({ ...msg, result: { device: this.set(
|
|
59
|
+
this.server.respond({ ...msg, result: { device: this.set(toDevice(msg.params.device)) } });
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
break;
|
|
63
63
|
case 'devices_remove':
|
|
64
|
-
this.server.respond({ ...msg, result: { success: this.remove(
|
|
64
|
+
this.server.respond({ ...msg, result: { success: this.remove(toDevice(msg.params.device)) } });
|
|
65
65
|
break;
|
|
66
66
|
case 'devices_clear':
|
|
67
67
|
this.clear();
|
|
68
68
|
this.server.respond({ ...msg, result: { success: true } });
|
|
69
69
|
break;
|
|
70
|
-
case '
|
|
70
|
+
case 'devices_array':
|
|
71
71
|
this.server.respond({ ...msg, result: { devices: this.baseArray(msg.params.pluginName) } });
|
|
72
72
|
break;
|
|
73
|
-
case 'devices_apidevicearray':
|
|
74
|
-
this.server.respond({ ...msg, result: { devices: this.apiDeviceArray(msg.params.pluginName, msg.params.extended) } });
|
|
75
|
-
break;
|
|
76
73
|
default:
|
|
77
74
|
if (this.verbose)
|
|
78
75
|
this.log.debug(`Unknown broadcast message ${CYAN}${msg.type}${db} from ${CYAN}${msg.src}${db}`);
|
|
@@ -109,9 +106,6 @@ export class DeviceManager {
|
|
|
109
106
|
clear() {
|
|
110
107
|
this._devices.clear();
|
|
111
108
|
}
|
|
112
|
-
toBaseDevice(device) {
|
|
113
|
-
return toBaseDevice(device);
|
|
114
|
-
}
|
|
115
109
|
array() {
|
|
116
110
|
return Array.from(this._devices.values());
|
|
117
111
|
}
|
|
@@ -120,18 +114,7 @@ export class DeviceManager {
|
|
|
120
114
|
for (const device of Array.from(this._devices.values())) {
|
|
121
115
|
if (pluginName && pluginName !== device.plugin)
|
|
122
116
|
continue;
|
|
123
|
-
devices.push(
|
|
124
|
-
}
|
|
125
|
-
return devices;
|
|
126
|
-
}
|
|
127
|
-
apiDeviceArray(pluginName, extended) {
|
|
128
|
-
const devices = [];
|
|
129
|
-
for (const device of this._devices.values()) {
|
|
130
|
-
if (pluginName && pluginName !== device.plugin)
|
|
131
|
-
continue;
|
|
132
|
-
const apiDevice = toApiDevice(device, extended);
|
|
133
|
-
if (apiDevice)
|
|
134
|
-
devices.push(apiDevice);
|
|
117
|
+
devices.push(toDevice(device));
|
|
135
118
|
}
|
|
136
119
|
return devices;
|
|
137
120
|
}
|
package/dist/frontend.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import EventEmitter from 'node:events';
|
|
2
|
-
import type { ApiClusters,
|
|
2
|
+
import type { ApiClusters, ApiMatter, BridgeStatus, PluginStatusUpdate, RefreshRequiredChanged, WsMessageBroadcast } from '@matterbridge/types';
|
|
3
3
|
import { LogLevel } from 'node-ansi-logger';
|
|
4
4
|
import type { Matterbridge } from './matterbridge.js';
|
|
5
5
|
interface FrontendEvents {
|
|
@@ -34,7 +34,6 @@ export declare class Frontend extends EventEmitter<FrontendEvents> {
|
|
|
34
34
|
private validateReq;
|
|
35
35
|
start(port?: number): Promise<void>;
|
|
36
36
|
stop(): Promise<void>;
|
|
37
|
-
getApiDevices(pluginName?: string, extended?: boolean): ApiDevice[];
|
|
38
37
|
getApiCluster(pluginName: string, endpointNumber: number, serialNumber: string, uniqueId: string): ApiClusters | undefined;
|
|
39
38
|
generateDiagnostic(): Promise<void>;
|
|
40
39
|
private wsMessageHandler;
|
package/dist/frontend.js
CHANGED
|
@@ -18,7 +18,7 @@ import { fireAndForget, withTimeout } from '@matterbridge/utils/wait';
|
|
|
18
18
|
import { AnsiLogger, bgHex, CYAN, db, debugStringify, er, GREEN, nf, nt, rs, UNDERLINE, UNDERLINEOFF, wr, YELLOW } from 'node-ansi-logger';
|
|
19
19
|
import { generateHistoryPage } from './cliHistory.js';
|
|
20
20
|
import { matterToAnsiLogLevel } from './matterLogger.js';
|
|
21
|
-
import { deleteAdvertisingNode,
|
|
21
|
+
import { deleteAdvertisingNode, getServerNodeData, setAdvertisingNode, toApiClusters } from './matterNodeHelpers.js';
|
|
22
22
|
logModuleLoaded('Frontend');
|
|
23
23
|
function sendDownloadError(res, error, message) {
|
|
24
24
|
if (error.code === 'ECONNABORTED' || res.headersSent)
|
|
@@ -541,11 +541,17 @@ export class Frontend extends EventEmitter {
|
|
|
541
541
|
res.status(500).send('Error fetching the plugins.');
|
|
542
542
|
}
|
|
543
543
|
});
|
|
544
|
-
this.expressApp.get('/api/devices', (req, res) => {
|
|
544
|
+
this.expressApp.get('/api/devices', async (req, res) => {
|
|
545
545
|
this.log.debug('The frontend sent /api/devices');
|
|
546
546
|
if (!this.validateReq(req, res))
|
|
547
547
|
return;
|
|
548
|
-
|
|
548
|
+
try {
|
|
549
|
+
res.json((await this.server.fetch({ type: 'devices_array', src: this.server.name, dst: 'devices', params: {} }, this.serverFetchTimeout)).result.devices);
|
|
550
|
+
}
|
|
551
|
+
catch (error) {
|
|
552
|
+
logError(this.log, 'Error in /api/devices fetching the devices from the device manager', error);
|
|
553
|
+
res.status(500).send('Error fetching the devices.');
|
|
554
|
+
}
|
|
549
555
|
});
|
|
550
556
|
this.expressApp.get('/api/view-mblog', async (req, res) => {
|
|
551
557
|
this.log.debug('The frontend sent /api/view-mblog');
|
|
@@ -668,8 +674,8 @@ export class Frontend extends EventEmitter {
|
|
|
668
674
|
}
|
|
669
675
|
});
|
|
670
676
|
});
|
|
671
|
-
this.expressApp.get('/api/
|
|
672
|
-
this.log.debug('The frontend sent /api/
|
|
677
|
+
this.expressApp.get('/api/view-history', async (req, res) => {
|
|
678
|
+
this.log.debug('The frontend sent /api/view-history');
|
|
673
679
|
if (!this.validateReq(req, res))
|
|
674
680
|
return;
|
|
675
681
|
try {
|
|
@@ -679,12 +685,12 @@ export class Frontend extends EventEmitter {
|
|
|
679
685
|
res.send(data);
|
|
680
686
|
}
|
|
681
687
|
catch (error) {
|
|
682
|
-
logError(this.log, `Error in /api/
|
|
688
|
+
logError(this.log, `Error in /api/view-history reading history file ${MATTERBRIDGE_HISTORY_FILE}`, error);
|
|
683
689
|
res.status(500).send('Error reading history file.');
|
|
684
690
|
}
|
|
685
691
|
});
|
|
686
|
-
this.expressApp.get('/api/
|
|
687
|
-
this.log.debug(`The frontend sent /api/
|
|
692
|
+
this.expressApp.get('/api/download-history', async (req, res) => {
|
|
693
|
+
this.log.debug(`The frontend sent /api/download-history`);
|
|
688
694
|
if (!this.validateReq(req, res))
|
|
689
695
|
return;
|
|
690
696
|
try {
|
|
@@ -695,7 +701,7 @@ export class Frontend extends EventEmitter {
|
|
|
695
701
|
res.type('text/html; charset=utf-8');
|
|
696
702
|
res.download(path.join(os.tmpdir(), MATTERBRIDGE_HISTORY_FILE), MATTERBRIDGE_HISTORY_FILE, (error) => {
|
|
697
703
|
if (error) {
|
|
698
|
-
logError(this.log, `Error in /api/
|
|
704
|
+
logError(this.log, `Error in /api/download-history downloading history file ${MATTERBRIDGE_HISTORY_FILE}`, error);
|
|
699
705
|
sendDownloadError(res, error, 'Error downloading history file');
|
|
700
706
|
}
|
|
701
707
|
else {
|
|
@@ -704,7 +710,7 @@ export class Frontend extends EventEmitter {
|
|
|
704
710
|
});
|
|
705
711
|
}
|
|
706
712
|
catch (error) {
|
|
707
|
-
logError(this.log, `Error in /api/
|
|
713
|
+
logError(this.log, `Error in /api/download-history reading history file ${MATTERBRIDGE_HISTORY_FILE}`, error);
|
|
708
714
|
res.status(500).send('Error reading history file.');
|
|
709
715
|
}
|
|
710
716
|
});
|
|
@@ -932,34 +938,6 @@ export class Frontend extends EventEmitter {
|
|
|
932
938
|
}
|
|
933
939
|
this.log.debug('Frontend stopped successfully');
|
|
934
940
|
}
|
|
935
|
-
getApiDevices(pluginName, extended = false) {
|
|
936
|
-
if (this.matterbridge.hasCleanupStarted)
|
|
937
|
-
return [];
|
|
938
|
-
const devices = [];
|
|
939
|
-
for (const device of this.matterbridge.devices.array()) {
|
|
940
|
-
if (pluginName && pluginName !== device.plugin)
|
|
941
|
-
continue;
|
|
942
|
-
if (!device.plugin || !device.deviceType || !device.name || !device.deviceName || !device.serialNumber || !device.uniqueId || !device.lifecycle.isReady)
|
|
943
|
-
continue;
|
|
944
|
-
devices.push({
|
|
945
|
-
plugin: device.plugin,
|
|
946
|
-
type: device.name + ' (0x' + device.deviceType.toString(16).padStart(4, '0') + ')',
|
|
947
|
-
number: device.number,
|
|
948
|
-
id: device.id,
|
|
949
|
-
deviceName: device.deviceName,
|
|
950
|
-
serialNumber: device.serialNumber,
|
|
951
|
-
productUrl: device.productUrl,
|
|
952
|
-
configUrl: device.configUrl,
|
|
953
|
-
uniqueId: device.uniqueId,
|
|
954
|
-
reachable: extended ? getReachability(device) : true,
|
|
955
|
-
powerSource: extended ? getPowerSource(device) : undefined,
|
|
956
|
-
batteryLevel: extended ? getBatteryLevel(device) : undefined,
|
|
957
|
-
matter: extended && device.mode === 'server' && device.serverNode ? getServerNodeData(device.serverNode) : undefined,
|
|
958
|
-
cluster: extended ? getClusterTextFromDevice(device) : '',
|
|
959
|
-
});
|
|
960
|
-
}
|
|
961
|
-
return devices;
|
|
962
|
-
}
|
|
963
941
|
getApiCluster(pluginName, endpointNumber, serialNumber, uniqueId) {
|
|
964
942
|
if (this.matterbridge.hasCleanupStarted)
|
|
965
943
|
return;
|
|
@@ -1119,7 +1097,7 @@ export class Frontend extends EventEmitter {
|
|
|
1119
1097
|
}
|
|
1120
1098
|
this.wssSendSnackbarMessage(`Removing plugin ${data.params.pluginName}...`, 0);
|
|
1121
1099
|
this.log.debug(`Removing plugin ${data.params.pluginName}...`);
|
|
1122
|
-
const devices = (await this.server.fetch({ type: '
|
|
1100
|
+
const devices = (await this.server.fetch({ type: 'devices_array', src: this.server.name, dst: 'devices', params: { pluginName: data.params.pluginName } }, this.serverFetchTimeout)).result.devices;
|
|
1123
1101
|
for (const device of devices.filter((d) => d.mode === 'server')) {
|
|
1124
1102
|
if (device.uniqueId)
|
|
1125
1103
|
await this.server.fetch({ type: 'matterbridge_stop_device_server', src: this.server.name, dst: 'matterbridge', params: { deviceUniqueId: device.uniqueId } }, this.serverFetchTimeout);
|
|
@@ -1145,7 +1123,7 @@ export class Frontend extends EventEmitter {
|
|
|
1145
1123
|
await this.server.fetch({ type: 'plugins_start', src: this.server.name, dst: 'plugins', params: { plugin: data.params.pluginName } }, this.serverFetchTimeout * 10);
|
|
1146
1124
|
await this.server.fetch({ type: 'plugins_configure', src: this.server.name, dst: 'plugins', params: { plugin: data.params.pluginName } }, this.serverFetchTimeout * 10);
|
|
1147
1125
|
await this.server.fetch({ type: 'matterbridge_start_plugin_server', src: this.server.name, dst: 'matterbridge', params: { pluginName: data.params.pluginName } }, this.serverFetchTimeout);
|
|
1148
|
-
const devices = (await this.server.fetch({ type: '
|
|
1126
|
+
const devices = (await this.server.fetch({ type: 'devices_array', src: this.server.name, dst: 'devices', params: { pluginName: data.params.pluginName } }, this.serverFetchTimeout)).result.devices;
|
|
1149
1127
|
for (const device of devices.filter((d) => d.mode === 'server')) {
|
|
1150
1128
|
if (device.uniqueId)
|
|
1151
1129
|
await this.server.fetch({ type: 'matterbridge_start_device_server', src: this.server.name, dst: 'matterbridge', params: { deviceUniqueId: device.uniqueId } }, this.serverFetchTimeout);
|
|
@@ -1160,7 +1138,7 @@ export class Frontend extends EventEmitter {
|
|
|
1160
1138
|
sendResponse({ id: data.id, method: data.method, src: 'Matterbridge', dst: data.src, error: 'Wrong parameter pluginName in /api/disableplugin' });
|
|
1161
1139
|
return;
|
|
1162
1140
|
}
|
|
1163
|
-
const devices = (await this.server.fetch({ type: '
|
|
1141
|
+
const devices = (await this.server.fetch({ type: 'devices_array', src: this.server.name, dst: 'devices', params: { pluginName: data.params.pluginName } }, this.serverFetchTimeout)).result.devices;
|
|
1164
1142
|
for (const device of devices.filter((d) => d.mode === 'server')) {
|
|
1165
1143
|
if (device.uniqueId)
|
|
1166
1144
|
await this.server.fetch({ type: 'matterbridge_stop_device_server', src: this.server.name, dst: 'matterbridge', params: { deviceUniqueId: device.uniqueId } }, this.serverFetchTimeout);
|
|
@@ -1214,13 +1192,13 @@ export class Frontend extends EventEmitter {
|
|
|
1214
1192
|
this.wssSendRefreshRequired('devices');
|
|
1215
1193
|
sendResponse({ id: data.id, method: data.method, src: 'Matterbridge', dst: data.src, success: true });
|
|
1216
1194
|
}
|
|
1217
|
-
else if (data.method === '/api/
|
|
1195
|
+
else if (data.method === '/api/save-plugin-config') {
|
|
1218
1196
|
if (!isValidString(data.params.pluginName, 10) || !this.matterbridge.plugins.has(data.params.pluginName)) {
|
|
1219
|
-
sendResponse({ id: data.id, method: data.method, src: 'Matterbridge', dst: data.src, error: 'Wrong parameter pluginName in /api/
|
|
1197
|
+
sendResponse({ id: data.id, method: data.method, src: 'Matterbridge', dst: data.src, error: 'Wrong parameter pluginName in /api/save-plugin-config' });
|
|
1220
1198
|
return;
|
|
1221
1199
|
}
|
|
1222
1200
|
if (!isValidObject(data.params.formData, 5)) {
|
|
1223
|
-
sendResponse({ id: data.id, method: data.method, src: 'Matterbridge', dst: data.src, error: 'Wrong parameter formData in /api/
|
|
1201
|
+
sendResponse({ id: data.id, method: data.method, src: 'Matterbridge', dst: data.src, error: 'Wrong parameter formData in /api/save-plugin-config' });
|
|
1224
1202
|
return;
|
|
1225
1203
|
}
|
|
1226
1204
|
this.log.info(`Saving config for plugin ${plg}${data.params.pluginName}${nf}...`);
|
|
@@ -1311,11 +1289,11 @@ export class Frontend extends EventEmitter {
|
|
|
1311
1289
|
this.server.request({ type: 'platform_rename_device', src: this.server.name, dst: 'platform', params: { pluginName, serialNumber, uniqueId, label } });
|
|
1312
1290
|
sendResponse({ id: data.id, method: data.method, src: 'Matterbridge', dst: data.src, success: true });
|
|
1313
1291
|
}
|
|
1314
|
-
else if (data.method === '/api/
|
|
1292
|
+
else if (data.method === '/api/view-historypage') {
|
|
1315
1293
|
generateHistoryPage({ outputPath: path.join(this.matterbridge.matterbridgeDirectory, MATTERBRIDGE_HISTORY_FILE), pageTitle: `Matterbridge Cpu & Memory History` });
|
|
1316
1294
|
sendResponse({ id: data.id, method: data.method, src: 'Matterbridge', dst: data.src, success: true });
|
|
1317
1295
|
}
|
|
1318
|
-
else if (data.method === '/api/
|
|
1296
|
+
else if (data.method === '/api/download-historypage') {
|
|
1319
1297
|
generateHistoryPage({ outputPath: path.join(this.matterbridge.matterbridgeDirectory, MATTERBRIDGE_HISTORY_FILE), pageTitle: `Matterbridge Cpu & Memory History` });
|
|
1320
1298
|
sendResponse({ id: data.id, method: data.method, src: 'Matterbridge', dst: data.src, success: true });
|
|
1321
1299
|
}
|
|
@@ -1386,11 +1364,24 @@ export class Frontend extends EventEmitter {
|
|
|
1386
1364
|
}
|
|
1387
1365
|
else if (data.method === '/api/devices') {
|
|
1388
1366
|
const start = performance.now();
|
|
1389
|
-
const
|
|
1367
|
+
const pluginName = isValidString(data.params.pluginName) ? data.params.pluginName : undefined;
|
|
1368
|
+
const devices = (await this.server.fetch({ type: 'devices_array', src: this.server.name, dst: 'devices', params: { pluginName } }, this.serverFetchTimeout)).result.devices;
|
|
1390
1369
|
if (this.diagnostic)
|
|
1391
|
-
writeDiagnostic(`Frontend:${data.sender}`, `
|
|
1370
|
+
writeDiagnostic(`Frontend:${data.sender}`, `devices_array() took ${(performance.now() - start).toFixed(2)} ms`);
|
|
1392
1371
|
sendResponse({ id: data.id, method: data.method, src: 'Matterbridge', dst: data.src, success: true, response: devices });
|
|
1393
1372
|
}
|
|
1373
|
+
else if (data.method === '/api/platform-devices') {
|
|
1374
|
+
if (!isValidString(data.params.pluginName, 10)) {
|
|
1375
|
+
sendResponse({ id: data.id, method: data.method, src: 'Matterbridge', dst: data.src, error: 'Wrong parameter pluginName in /api/platform-devices' });
|
|
1376
|
+
return;
|
|
1377
|
+
}
|
|
1378
|
+
const start = performance.now();
|
|
1379
|
+
const { pluginName, extended } = data.params;
|
|
1380
|
+
const devices = (await this.server.fetch({ type: 'platform_get_apidevices', src: this.server.name, dst: 'platform', params: { pluginName, extended } }, this.serverFetchTimeout)).result.devices;
|
|
1381
|
+
if (this.diagnostic)
|
|
1382
|
+
writeDiagnostic(`Frontend:${data.sender}`, `platform_get_apidevices(${pluginName}) took ${(performance.now() - start).toFixed(2)} ms`);
|
|
1383
|
+
sendResponse({ id: data.id, method: data.method, src: 'Matterbridge', dst: data.src, success: true, pluginName, response: devices });
|
|
1384
|
+
}
|
|
1394
1385
|
else if (data.method === '/api/clusters') {
|
|
1395
1386
|
if (!isValidString(data.params.pluginName, 10)) {
|
|
1396
1387
|
sendResponse({ id: data.id, method: data.method, src: 'Matterbridge', dst: data.src, error: 'Wrong parameter pluginName in /api/clusters' });
|
|
@@ -1426,14 +1417,14 @@ export class Frontend extends EventEmitter {
|
|
|
1426
1417
|
sendResponse({ id: data.id, method: data.method, src: 'Matterbridge', dst: data.src, error: 'Endpoint not found in /api/clusters' });
|
|
1427
1418
|
}
|
|
1428
1419
|
}
|
|
1429
|
-
else if (data.method === '/api/select
|
|
1420
|
+
else if (data.method === '/api/select-devices') {
|
|
1430
1421
|
if (!isValidString(data.params.plugin, 10)) {
|
|
1431
|
-
sendResponse({ id: data.id, method: data.method, src: 'Matterbridge', dst: data.src, error: 'Wrong parameter plugin in /api/select
|
|
1422
|
+
sendResponse({ id: data.id, method: data.method, src: 'Matterbridge', dst: data.src, error: 'Wrong parameter plugin in /api/select-devices' });
|
|
1432
1423
|
return;
|
|
1433
1424
|
}
|
|
1434
1425
|
const plugin = this.matterbridge.plugins.get(data.params.plugin);
|
|
1435
1426
|
if (!plugin) {
|
|
1436
|
-
sendResponse({ id: data.id, method: data.method, src: 'Matterbridge', dst: data.src, error: 'Plugin not found in /api/select
|
|
1427
|
+
sendResponse({ id: data.id, method: data.method, src: 'Matterbridge', dst: data.src, error: 'Plugin not found in /api/select-devices' });
|
|
1437
1428
|
return;
|
|
1438
1429
|
}
|
|
1439
1430
|
const start = performance.now();
|
|
@@ -1442,14 +1433,14 @@ export class Frontend extends EventEmitter {
|
|
|
1442
1433
|
writeDiagnostic(`Frontend:${data.sender}`, `getSelectDevices() took ${(performance.now() - start).toFixed(2)} ms`);
|
|
1443
1434
|
sendResponse({ id: data.id, method: data.method, src: 'Matterbridge', dst: data.src, success: true, response: selectDevices });
|
|
1444
1435
|
}
|
|
1445
|
-
else if (data.method === '/api/select
|
|
1436
|
+
else if (data.method === '/api/select-entities') {
|
|
1446
1437
|
if (!isValidString(data.params.plugin, 10)) {
|
|
1447
|
-
sendResponse({ id: data.id, method: data.method, src: 'Matterbridge', dst: data.src, error: 'Wrong parameter plugin in /api/select
|
|
1438
|
+
sendResponse({ id: data.id, method: data.method, src: 'Matterbridge', dst: data.src, error: 'Wrong parameter plugin in /api/select-entities' });
|
|
1448
1439
|
return;
|
|
1449
1440
|
}
|
|
1450
1441
|
const plugin = this.matterbridge.plugins.get(data.params.plugin);
|
|
1451
1442
|
if (!plugin) {
|
|
1452
|
-
sendResponse({ id: data.id, method: data.method, src: 'Matterbridge', dst: data.src, error: 'Plugin not found in /api/select
|
|
1443
|
+
sendResponse({ id: data.id, method: data.method, src: 'Matterbridge', dst: data.src, error: 'Plugin not found in /api/select-entities' });
|
|
1453
1444
|
return;
|
|
1454
1445
|
}
|
|
1455
1446
|
const start = performance.now();
|
package/dist/matterNode.js
CHANGED
|
@@ -24,7 +24,7 @@ import { NodeStorageManager } from 'node-persist-manager';
|
|
|
24
24
|
import { addVirtualDevice } from './helpers.js';
|
|
25
25
|
import { bridge } from './matterbridgeDeviceTypes.js';
|
|
26
26
|
import { setupLoggers } from './matterLogger.js';
|
|
27
|
-
import { deleteAdvertisingNode, getServerNodeData, setAdvertisingNode,
|
|
27
|
+
import { deleteAdvertisingNode, getServerNodeData, setAdvertisingNode, toDevice } from './matterNodeHelpers.js';
|
|
28
28
|
import { startMatterStorage, stopMatterStorage } from './matterStorage.js';
|
|
29
29
|
import { PluginManager } from './pluginManager.js';
|
|
30
30
|
logModuleLoaded('MatterNode');
|
|
@@ -751,7 +751,7 @@ export class MatterNode extends EventEmitter {
|
|
|
751
751
|
if (plugin.registeredDevices !== undefined)
|
|
752
752
|
plugin.registeredDevices++;
|
|
753
753
|
await device.construction.ready;
|
|
754
|
-
await this.server.fetch({ type: 'devices_set', src: this.server.name, dst: 'devices', params: { device:
|
|
754
|
+
await this.server.fetch({ type: 'devices_set', src: this.server.name, dst: 'devices', params: { device: toDevice(device) } });
|
|
755
755
|
await this.subscribeAttributeChanged(plugin, device);
|
|
756
756
|
this.log.info(`Added endpoint #${plugin.registeredDevices} ${plg}${pluginName}${nf}:${dev}${device.deviceName}${nf} (${zb}${device.name}${nf})`);
|
|
757
757
|
await this.yieldToNode(10);
|
|
@@ -792,7 +792,7 @@ export class MatterNode extends EventEmitter {
|
|
|
792
792
|
this.log.info(`Removed bridged endpoint #${plugin.registeredDevices} ${plg}${pluginName}${nf}:${dev}${device.deviceName}${nf} (${zb}${device.name}${nf})`);
|
|
793
793
|
if (plugin.registeredDevices !== undefined)
|
|
794
794
|
plugin.registeredDevices--;
|
|
795
|
-
await this.server.fetch({ type: 'devices_remove', src: this.server.name, dst: 'devices', params: { device:
|
|
795
|
+
await this.server.fetch({ type: 'devices_remove', src: this.server.name, dst: 'devices', params: { device: toDevice(device) } });
|
|
796
796
|
await this.yieldToNode(10);
|
|
797
797
|
return device;
|
|
798
798
|
}
|
|
@@ -801,7 +801,7 @@ export class MatterNode extends EventEmitter {
|
|
|
801
801
|
if (!plugin)
|
|
802
802
|
throw new Error(`Error removing all bridged endpoints for plugin ${plg}${pluginName}${er}: plugin not found`);
|
|
803
803
|
this.log.debug(`Removing all #${plugin.registeredDevices} bridged endpoints for plugin ${plg}${pluginName}${db}${delay > 0 ? ` with delay ${delay} ms` : ''}...`);
|
|
804
|
-
const devices = (await this.server.fetch({ type: '
|
|
804
|
+
const devices = (await this.server.fetch({ type: 'devices_array', src: this.server.name, dst: 'devices', params: { pluginName } })).result.devices;
|
|
805
805
|
for (const device of devices) {
|
|
806
806
|
const endpoint = (this.aggregatorNode?.parts.get(device.id || '') || this.serverNode?.parts.get(device.id || ''));
|
|
807
807
|
if (!endpoint)
|
|
@@ -811,7 +811,7 @@ export class MatterNode extends EventEmitter {
|
|
|
811
811
|
this.log.info(`Removed bridged endpoint #${plugin.registeredDevices} ${plg}${pluginName}${nf}:${dev}${device.deviceName}${nf} (${zb}${endpoint?.name}${nf})`);
|
|
812
812
|
if (plugin.registeredDevices !== undefined)
|
|
813
813
|
plugin.registeredDevices--;
|
|
814
|
-
await this.server.fetch({ type: 'devices_remove', src: this.server.name, dst: 'devices', params: { device:
|
|
814
|
+
await this.server.fetch({ type: 'devices_remove', src: this.server.name, dst: 'devices', params: { device: toDevice(device) } });
|
|
815
815
|
await this.yieldToNode(10);
|
|
816
816
|
if (delay > 0)
|
|
817
817
|
await wait(delay);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ServerNode, type SessionsBehavior } from '@matter/node';
|
|
2
2
|
import type { ExposedFabricInformation } from '@matter/protocol';
|
|
3
|
-
import type { ApiClusters, ApiDevice, ApiMatter,
|
|
3
|
+
import type { ApiClusters, ApiDevice, ApiMatter, Device, SanitizedExposedFabricInformation, SanitizedSession } from '@matterbridge/types';
|
|
4
4
|
import { type AnsiLogger } from 'node-ansi-logger';
|
|
5
5
|
import type { MatterbridgeEndpoint } from './matterbridgeEndpoint.js';
|
|
6
6
|
export declare function toApiClusters(endpoint: MatterbridgeEndpoint, log: AnsiLogger): ApiClusters | undefined;
|
|
7
|
-
export declare function
|
|
7
|
+
export declare function toDevice(device: MatterbridgeEndpoint | Device): Device;
|
|
8
8
|
export declare function toApiDevice(device: MatterbridgeEndpoint, extended?: boolean): ApiDevice | undefined;
|
|
9
9
|
export declare function getReachability(device: MatterbridgeEndpoint): boolean;
|
|
10
10
|
export declare function getPowerSource(endpoint: MatterbridgeEndpoint): 'ac' | 'dc' | 'ok' | 'warning' | 'critical' | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@matterbridge/core",
|
|
3
|
-
"version": "3.11.
|
|
3
|
+
"version": "3.11.3-dev-20261107-92e4713",
|
|
4
4
|
"description": "Matterbridge core library",
|
|
5
5
|
"author": "https://github.com/Luligu",
|
|
6
6
|
"homepage": "https://matterbridge.io/",
|
|
@@ -136,13 +136,13 @@
|
|
|
136
136
|
},
|
|
137
137
|
"dependencies": {
|
|
138
138
|
"@matter/main": "0.18.0",
|
|
139
|
-
"@matterbridge/dgram": "3.11.
|
|
140
|
-
"@matterbridge/thread": "3.11.
|
|
141
|
-
"@matterbridge/types": "3.11.
|
|
142
|
-
"@matterbridge/utils": "3.11.
|
|
139
|
+
"@matterbridge/dgram": "3.11.3-dev-20261107-92e4713",
|
|
140
|
+
"@matterbridge/thread": "3.11.3-dev-20261107-92e4713",
|
|
141
|
+
"@matterbridge/types": "3.11.3-dev-20261107-92e4713",
|
|
142
|
+
"@matterbridge/utils": "3.11.3-dev-20261107-92e4713",
|
|
143
143
|
"escape-html": "1.0.3",
|
|
144
144
|
"express": "5.3.0",
|
|
145
|
-
"express-rate-limit": "8.7.
|
|
145
|
+
"express-rate-limit": "8.7.3",
|
|
146
146
|
"multer": "2.5.0",
|
|
147
147
|
"node-ansi-logger": "3.3.1",
|
|
148
148
|
"node-persist-manager": "2.1.1",
|