matterbridge 1.2.9 → 1.2.10
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 +11 -0
- package/README.md +1 -1
- package/dist/matterbridge.d.ts +4 -2
- package/dist/matterbridge.d.ts.map +1 -1
- package/dist/matterbridge.js +51 -60
- package/dist/matterbridge.js.map +1 -1
- package/dist/matterbridgeDevice.d.ts +16 -41
- package/dist/matterbridgeDevice.d.ts.map +1 -1
- package/dist/matterbridgeDevice.js +10 -3
- package/dist/matterbridgeDevice.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -2,10 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [1.2.10] - 2024-04-22
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- [extension]: Finalized implementation of zigbee2MQTT internal extension v. 1.0.0.
|
|
10
|
+
|
|
11
|
+
|
|
5
12
|
## [1.2.9] - 2024-04-19
|
|
6
13
|
|
|
7
14
|
### Added
|
|
8
15
|
|
|
16
|
+
- [Matterbridge]: Added call to set reachability at start.
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
|
|
9
20
|
- [Matterbridge]: Added call to set reachability at start.
|
|
10
21
|
- [frontend]: Added filter for log level and search criteria in the Logs page.
|
|
11
22
|
- [frontend]: Added colors to the logs in the Home page and in the Logs page.
|
package/README.md
CHANGED
|
@@ -85,7 +85,7 @@ matterbridge -help
|
|
|
85
85
|
|
|
86
86
|
## Frontend
|
|
87
87
|
|
|
88
|
-
Matterbridge has a frontend available on http://localhost:
|
|
88
|
+
Matterbridge has a frontend available on http://localhost:8283
|
|
89
89
|
|
|
90
90
|
You can change the default port by adding the frontend parameter when you launch it.
|
|
91
91
|
|
package/dist/matterbridge.d.ts
CHANGED
|
@@ -65,6 +65,7 @@ export declare class Matterbridge extends EventEmitter {
|
|
|
65
65
|
matterbridgeVersion: string;
|
|
66
66
|
matterbridgeLatestVersion: string;
|
|
67
67
|
bridgeMode: 'bridge' | 'childbridge' | 'controller' | '';
|
|
68
|
+
restartMode: 'service' | 'docker' | '';
|
|
68
69
|
debugEnabled: boolean;
|
|
69
70
|
private port;
|
|
70
71
|
private log;
|
|
@@ -98,13 +99,14 @@ export declare class Matterbridge extends EventEmitter {
|
|
|
98
99
|
*
|
|
99
100
|
* @returns A Promise that resolves when the initialization is complete.
|
|
100
101
|
*/
|
|
101
|
-
|
|
102
|
+
startExtension(dataPath: string, debugEnabled: boolean, extensionVersion: string, port?: number): Promise<boolean>;
|
|
102
103
|
/**
|
|
103
104
|
* Close the Matterbridge instance as extension for zigbee2mqtt.
|
|
104
105
|
*
|
|
105
106
|
* @returns A Promise that resolves when the initialization is complete.
|
|
106
107
|
*/
|
|
107
|
-
|
|
108
|
+
stopExtension(): Promise<void>;
|
|
109
|
+
isExtensionCommissioned(): boolean;
|
|
108
110
|
/**
|
|
109
111
|
* Initializes the Matterbridge application.
|
|
110
112
|
*
|
|
@@ -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;AAS3F,OAAO,YAAY,MAAM,QAAQ,CAAC;AA2ClC,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;AA0CF,UAAU,iBAAiB;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB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QG;YACW,gBAAgB;IAgC9B;;;;;OAKG;YACW,gBAAgB;IAe9B;;;;;;OAMG;YACW,SAAS;IAYvB;;;;;;;OAOG;YACW,WAAW;IA6BzB;;;;;OAKG;YACW,eAAe;IA4B7B;;;;;;;OAOG;YACW,UAAU;IAsDxB;;;;OAIG;YACW,qBAAqB;IA2KnC;;;;;;;;OAQG;YACW,iBAAiB;IAoK/B;;;OAGG;YACW,iBAAiB;IAW/B;;;;;;OAMG;YACW,gCAAgC;IAwB9C;;;;;;;;;;;;;;;;;OAiBG;YACW,gCAAgC;IA0C9C;;;;;;;OAOG;YACW,uBAAuB;IAgCrC;;;;;OAKG;IACH,OAAO,CAAC,UAAU;IASlB;;;;;OAKG;IACH,OAAO,CAAC,kCAAkC;IAM1C;;;;OAIG;IACH,OAAO,CAAC,yBAAyB;IAWjC;;;;;OAKG;IACH,OAAO,CAAC,qBAAqB;IAM7B;;;;;;OAMG;YACW,wBAAwB;IAuItC;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;IAO1B;;;;OAIG;YACW,sBAAsB;IAuCpC;;OAEG;YACW,UAAU;IAcxB;;;;OAIG;YACW,gBAAgB;IAY9B;;;OAGG;YACW,oBAAoB;IAYlC;;OAEG;YACW,oBAAoB;IAyJlC;;;;OAIG;IACH,OAAO,CAAC,wBAAwB;IAqBhC;;;OAGG;IACH,OAAO,CAAC,wBAAwB;IAkBhC;;;;;OAKG;YACW,YAAY;IA0E1B;;;;;;OAMG;IACH,OAAO,CAAC,cAAc;IActB;;;;OAIG;IACG,kBAAkB,CAAC,IAAI,GAAE,MAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAiY5D;;;;OAIG;IACH,OAAO,CAAC,wBAAwB;CAyBjC"}
|
package/dist/matterbridge.js
CHANGED
|
@@ -82,6 +82,7 @@ export class Matterbridge extends EventEmitter {
|
|
|
82
82
|
matterbridgeVersion = '';
|
|
83
83
|
matterbridgeLatestVersion = '';
|
|
84
84
|
bridgeMode = '';
|
|
85
|
+
restartMode = '';
|
|
85
86
|
debugEnabled = false;
|
|
86
87
|
port = 5540;
|
|
87
88
|
log;
|
|
@@ -128,11 +129,11 @@ export class Matterbridge extends EventEmitter {
|
|
|
128
129
|
*
|
|
129
130
|
* @returns A Promise that resolves when the initialization is complete.
|
|
130
131
|
*/
|
|
131
|
-
async
|
|
132
|
+
async startExtension(dataPath, debugEnabled, extensionVersion, port = 5560) {
|
|
132
133
|
// Set the bridge mode
|
|
133
134
|
this.bridgeMode = 'bridge';
|
|
134
135
|
// Set the first port to use
|
|
135
|
-
this.port =
|
|
136
|
+
this.port = port;
|
|
136
137
|
// Set Matterbridge logger
|
|
137
138
|
this.debugEnabled = debugEnabled;
|
|
138
139
|
this.log = new AnsiLogger({ logName: 'Matterbridge', logTimestampFormat: 4 /* TimestampFormat.TIME_MILLIS */, logDebug: this.debugEnabled });
|
|
@@ -164,14 +165,16 @@ export class Matterbridge extends EventEmitter {
|
|
|
164
165
|
Logger.format = Format.ANSI;
|
|
165
166
|
// Start the storage and create matterbridgeContext
|
|
166
167
|
await this.startStorage('json', path.join(this.matterbridgeDirectory, 'matterbridge.json'));
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
168
|
+
if (!this.storageManager)
|
|
169
|
+
return false;
|
|
170
|
+
this.matterbridgeContext = await this.createCommissioningServerContext('Matterbridge', 'Matterbridge zigbee2MQTT', DeviceTypes.AGGREGATOR.code, 0xfff1, 'Matterbridge', 0x8000, 'zigbee2MQTT Matter extension');
|
|
171
|
+
if (!this.matterbridgeContext)
|
|
172
|
+
return false;
|
|
170
173
|
await this.matterbridgeContext.set('softwareVersion', 1);
|
|
171
174
|
await this.matterbridgeContext.set('softwareVersionString', this.matterbridgeVersion);
|
|
172
|
-
await this.matterbridgeContext.set('hardwareVersion',
|
|
173
|
-
await this.matterbridgeContext.set('hardwareVersionString',
|
|
174
|
-
this.createMatterServer(this.storageManager);
|
|
175
|
+
await this.matterbridgeContext.set('hardwareVersion', 1);
|
|
176
|
+
await this.matterbridgeContext.set('hardwareVersionString', extensionVersion); // Update with the extension version
|
|
177
|
+
this.matterServer = this.createMatterServer(this.storageManager);
|
|
175
178
|
this.log.debug(`Creating commissioning server for ${plg}Matterbridge${db}`);
|
|
176
179
|
this.commissioningServer = await this.createCommisioningServer(this.matterbridgeContext, 'Matterbridge');
|
|
177
180
|
this.log.debug(`Creating matter aggregator for ${plg}Matterbridge${db}`);
|
|
@@ -179,9 +182,7 @@ export class Matterbridge extends EventEmitter {
|
|
|
179
182
|
this.log.debug('Adding matterbridge aggregator to commissioning server');
|
|
180
183
|
this.commissioningServer.addDevice(this.matterAggregator);
|
|
181
184
|
this.log.debug('Adding matterbridge commissioning server to matter server');
|
|
182
|
-
await this.matterServer
|
|
183
|
-
this.log.debug(`Setting reachability to true for ${plg}Matterbridge${db}`);
|
|
184
|
-
this.commissioningServer.setReachability(true);
|
|
185
|
+
await this.matterServer.addCommissioningServer(this.commissioningServer, { uniqueStorageKey: 'Matterbridge' });
|
|
185
186
|
await this.startMatterServer();
|
|
186
187
|
this.log.info('Matter server started');
|
|
187
188
|
await this.showCommissioningQRCode(this.commissioningServer, this.matterbridgeContext, this.nodeContext, 'Matterbridge');
|
|
@@ -193,17 +194,26 @@ export class Matterbridge extends EventEmitter {
|
|
|
193
194
|
if (this.matterAggregator)
|
|
194
195
|
this.setAggregatorReachability(this.matterAggregator, true);
|
|
195
196
|
}, 60 * 1000);
|
|
197
|
+
return this.commissioningServer.isCommissioned();
|
|
196
198
|
}
|
|
197
199
|
/**
|
|
198
200
|
* Close the Matterbridge instance as extension for zigbee2mqtt.
|
|
199
201
|
*
|
|
200
202
|
* @returns A Promise that resolves when the initialization is complete.
|
|
201
203
|
*/
|
|
202
|
-
async
|
|
204
|
+
async stopExtension() {
|
|
203
205
|
// Closing matter
|
|
204
206
|
await this.stopMatter();
|
|
207
|
+
// Clearing the session manager
|
|
208
|
+
// this.matterbridgeContext?.createContext('SessionManager').clear();
|
|
205
209
|
// Closing storage
|
|
206
210
|
await this.stopStorage();
|
|
211
|
+
this.log.info('Matter server stopped');
|
|
212
|
+
}
|
|
213
|
+
isExtensionCommissioned() {
|
|
214
|
+
if (!this.commissioningServer)
|
|
215
|
+
return false;
|
|
216
|
+
return this.commissioningServer.isCommissioned();
|
|
207
217
|
}
|
|
208
218
|
/**
|
|
209
219
|
* Initializes the Matterbridge application.
|
|
@@ -243,6 +253,11 @@ export class Matterbridge extends EventEmitter {
|
|
|
243
253
|
}
|
|
244
254
|
// Set the first port to use
|
|
245
255
|
this.port = getIntParameter('port') ?? 5540;
|
|
256
|
+
// Set the restart mode
|
|
257
|
+
if (hasParameter('service'))
|
|
258
|
+
this.restartMode = 'service';
|
|
259
|
+
if (hasParameter('docker'))
|
|
260
|
+
this.restartMode = 'docker';
|
|
246
261
|
// Set Matterbridge logger
|
|
247
262
|
if (hasParameter('debug'))
|
|
248
263
|
this.debugEnabled = true;
|
|
@@ -277,7 +292,8 @@ export class Matterbridge extends EventEmitter {
|
|
|
277
292
|
await this.logNodeAndSystemInfo();
|
|
278
293
|
this.log.info(
|
|
279
294
|
// eslint-disable-next-line max-len
|
|
280
|
-
`Matterbridge version ${this.matterbridgeVersion} mode ${hasParameter('bridge') ? 'bridge' : ''}${hasParameter('childbridge') ? 'childbridge' : ''}${hasParameter('controller') ? 'controller' : ''}
|
|
295
|
+
`Matterbridge version ${this.matterbridgeVersion} mode ${hasParameter('bridge') ? 'bridge' : ''}${hasParameter('childbridge') ? 'childbridge' : ''}${hasParameter('controller') ? 'controller' : ''} ` +
|
|
296
|
+
`${this.restartMode !== '' ? 'restart mode ' + this.restartMode + ' ' : ''}running on ${this.systemInformation.osType} ${this.systemInformation.osRelease} ${this.systemInformation.osPlatform} ${this.systemInformation.osArch}`);
|
|
281
297
|
// Check node version and throw error
|
|
282
298
|
requireMinNodeVersion(18);
|
|
283
299
|
// Register SIGINT SIGTERM signal handlers
|
|
@@ -983,12 +999,7 @@ export class Matterbridge extends EventEmitter {
|
|
|
983
999
|
return;
|
|
984
1000
|
}
|
|
985
1001
|
this.log.debug('Starting matterbridge in mode', this.bridgeMode);
|
|
986
|
-
this.createMatterServer(this.storageManager);
|
|
987
|
-
if (!this.matterServer) {
|
|
988
|
-
this.log.error('No matter server initialized');
|
|
989
|
-
await this.cleanup('No matter server initialized');
|
|
990
|
-
return;
|
|
991
|
-
}
|
|
1002
|
+
this.matterServer = this.createMatterServer(this.storageManager);
|
|
992
1003
|
this.log.debug('***Starting startMatterbridge interval for Matterbridge');
|
|
993
1004
|
let failCount = 0;
|
|
994
1005
|
const startInterval = setInterval(async () => {
|
|
@@ -1164,7 +1175,7 @@ export class Matterbridge extends EventEmitter {
|
|
|
1164
1175
|
return Promise.reject(new Error(`Plugin ${plg}${plugin.name}${er} not loaded or no platform`));
|
|
1165
1176
|
}
|
|
1166
1177
|
if (plugin.started) {
|
|
1167
|
-
this.log.
|
|
1178
|
+
this.log.debug(`Plugin ${plg}${plugin.name}${db} already started`);
|
|
1168
1179
|
return Promise.resolve();
|
|
1169
1180
|
}
|
|
1170
1181
|
this.log.info(`Starting plugin ${plg}${plugin.name}${db} type ${typ}${plugin.type}${db}`);
|
|
@@ -1304,12 +1315,7 @@ export class Matterbridge extends EventEmitter {
|
|
|
1304
1315
|
return;
|
|
1305
1316
|
}
|
|
1306
1317
|
this.log.debug('Starting matterbridge in mode', this.bridgeMode);
|
|
1307
|
-
this.createMatterServer(this.storageManager);
|
|
1308
|
-
if (!this.matterServer) {
|
|
1309
|
-
this.log.error('No matter server initialized');
|
|
1310
|
-
await this.cleanup('No matter server initialized');
|
|
1311
|
-
return;
|
|
1312
|
-
}
|
|
1318
|
+
this.matterServer = this.createMatterServer(this.storageManager);
|
|
1313
1319
|
this.log.info('Creating matter commissioning controller');
|
|
1314
1320
|
this.commissioningController = new CommissioningController({
|
|
1315
1321
|
autoConnect: false,
|
|
@@ -1466,12 +1472,7 @@ export class Matterbridge extends EventEmitter {
|
|
|
1466
1472
|
return;
|
|
1467
1473
|
}
|
|
1468
1474
|
this.log.debug('Starting matterbridge in mode', this.bridgeMode);
|
|
1469
|
-
this.createMatterServer(this.storageManager);
|
|
1470
|
-
if (!this.matterServer) {
|
|
1471
|
-
this.log.error('No matter server initialized');
|
|
1472
|
-
await this.cleanup('No matter server initialized');
|
|
1473
|
-
return;
|
|
1474
|
-
}
|
|
1475
|
+
this.matterServer = this.createMatterServer(this.storageManager);
|
|
1475
1476
|
if (this.bridgeMode === 'bridge') {
|
|
1476
1477
|
// Plugins are loaded by loadPlugin on startup and plugin.loaded is set to true
|
|
1477
1478
|
// Plugins are started and configured by callback when Matterbridge is commissioned
|
|
@@ -1515,8 +1516,6 @@ export class Matterbridge extends EventEmitter {
|
|
|
1515
1516
|
this.commissioningServer.addDevice(this.matterAggregator);
|
|
1516
1517
|
this.log.debug('Adding matterbridge commissioning server to matter server');
|
|
1517
1518
|
await this.matterServer?.addCommissioningServer(this.commissioningServer, { uniqueStorageKey: 'Matterbridge' });
|
|
1518
|
-
this.log.debug(`Setting reachability to true for ${plg}Matterbridge${db}`);
|
|
1519
|
-
this.commissioningServer.setReachability(true);
|
|
1520
1519
|
await this.startMatterServer();
|
|
1521
1520
|
this.log.info('Matter server started');
|
|
1522
1521
|
await this.showCommissioningQRCode(this.commissioningServer, this.matterbridgeContext, this.nodeContext, 'Matterbridge');
|
|
@@ -1727,8 +1726,8 @@ export class Matterbridge extends EventEmitter {
|
|
|
1727
1726
|
if (!commissioningServer.isCommissioned()) {
|
|
1728
1727
|
this.log.info(`***The commissioning server on port ${commissioningServer.getPort()} for ${plg}${pluginName}${nf} is not commissioned. Pair it scanning the QR code ...`);
|
|
1729
1728
|
const { qrPairingCode, manualPairingCode } = commissioningServer.getPairingCode();
|
|
1730
|
-
storageContext.set('qrPairingCode', qrPairingCode);
|
|
1731
|
-
storageContext.set('manualPairingCode', manualPairingCode);
|
|
1729
|
+
await storageContext.set('qrPairingCode', qrPairingCode);
|
|
1730
|
+
await storageContext.set('manualPairingCode', manualPairingCode);
|
|
1732
1731
|
await nodeContext.set('qrPairingCode', qrPairingCode);
|
|
1733
1732
|
await nodeContext.set('manualPairingCode', manualPairingCode);
|
|
1734
1733
|
const QrCode = new QrCodeSchema();
|
|
@@ -1861,7 +1860,7 @@ export class Matterbridge extends EventEmitter {
|
|
|
1861
1860
|
const info = commissioningServer.getActiveSessionInformation(fabricIndex);
|
|
1862
1861
|
let connected = false;
|
|
1863
1862
|
info.forEach((session) => {
|
|
1864
|
-
this.log.
|
|
1863
|
+
this.log.info(`***Active session changed on fabric ${fabricIndex} ${session.fabric?.rootVendorId}/${session.fabric?.label} for ${plg}${pluginName}${nf}`, debugStringify(session));
|
|
1865
1864
|
if (session.isPeerActive === true && session.secure === true && session.numberOfActiveSubscriptions >= 1) {
|
|
1866
1865
|
let controllerName = '';
|
|
1867
1866
|
if (session.fabric?.rootVendorId === 4937)
|
|
@@ -1870,7 +1869,7 @@ export class Matterbridge extends EventEmitter {
|
|
|
1870
1869
|
controllerName = 'SmartThings';
|
|
1871
1870
|
if (session.fabric?.rootVendorId === 4939)
|
|
1872
1871
|
controllerName = 'HomeAssistant';
|
|
1873
|
-
this.log.info(`***Controller ${session.fabric?.rootVendorId}${controllerName !== '' ? '(' + controllerName + ')' : ''}/${session.fabric?.label} connected to ${plg}${pluginName}${nf}`);
|
|
1872
|
+
this.log.info(`***Controller ${session.fabric?.rootVendorId}${controllerName !== '' ? '(' + controllerName + ')' : ''}/${session.fabric?.label} connected to ${plg}${pluginName}${nf} on session ${session.name}`);
|
|
1874
1873
|
connected = true;
|
|
1875
1874
|
}
|
|
1876
1875
|
});
|
|
@@ -1928,7 +1927,7 @@ export class Matterbridge extends EventEmitter {
|
|
|
1928
1927
|
const info = commissioningServer.getCommissionedFabricInformation(fabricIndex);
|
|
1929
1928
|
this.log.debug(`***Commissioning changed on fabric ${fabricIndex} for ${plg}${pluginName}${nf}`, debugStringify(info));
|
|
1930
1929
|
if (info.length === 0) {
|
|
1931
|
-
this.log.warn(`***Commissioning removed from fabric ${fabricIndex} for ${plg}${pluginName}${
|
|
1930
|
+
this.log.warn(`***Commissioning removed from fabric ${fabricIndex} for ${plg}${pluginName}${wr}. Resetting the commissioning server ...`);
|
|
1932
1931
|
await commissioningServer.factoryReset();
|
|
1933
1932
|
if (pluginName === 'Matterbridge') {
|
|
1934
1933
|
await this.matterbridgeContext?.clearAll();
|
|
@@ -1943,6 +1942,7 @@ export class Matterbridge extends EventEmitter {
|
|
|
1943
1942
|
}
|
|
1944
1943
|
}
|
|
1945
1944
|
}
|
|
1945
|
+
this.log.warn(`***Restart to activate the pairing for ${plg}${pluginName}${wr}`);
|
|
1946
1946
|
}
|
|
1947
1947
|
},
|
|
1948
1948
|
});
|
|
@@ -1956,8 +1956,9 @@ export class Matterbridge extends EventEmitter {
|
|
|
1956
1956
|
*/
|
|
1957
1957
|
createMatterServer(storageManager) {
|
|
1958
1958
|
this.log.debug('Creating matter server');
|
|
1959
|
-
|
|
1959
|
+
const matterServer = new MatterServer(storageManager, { mdnsAnnounceInterface: undefined });
|
|
1960
1960
|
this.log.debug('Created matter server');
|
|
1961
|
+
return matterServer;
|
|
1961
1962
|
}
|
|
1962
1963
|
/**
|
|
1963
1964
|
* Creates a Matter Aggregator.
|
|
@@ -2495,7 +2496,7 @@ export class Matterbridge extends EventEmitter {
|
|
|
2495
2496
|
}
|
|
2496
2497
|
catch (error) {
|
|
2497
2498
|
attributeValue = 'Unavailable';
|
|
2498
|
-
this.log.debug(
|
|
2499
|
+
this.log.debug(`GetLocal value ${error} in clusterServer: ${clusterServer.name}(${clusterServer.id}) attribute: ${key}(${value.id})`);
|
|
2499
2500
|
//console.log(error);
|
|
2500
2501
|
}
|
|
2501
2502
|
data.push({
|
|
@@ -2765,6 +2766,8 @@ export class Matterbridge extends EventEmitter {
|
|
|
2765
2766
|
attributes += `Humidity: ${clusterServer.getMeasuredValueAttribute() / 100}% `;
|
|
2766
2767
|
if (clusterServer.name === 'PressureMeasurement')
|
|
2767
2768
|
attributes += `Pressure: ${clusterServer.getMeasuredValueAttribute()} `;
|
|
2769
|
+
if (clusterServer.name === 'FlowMeasurement')
|
|
2770
|
+
attributes += `Pressure: ${clusterServer.getMeasuredValueAttribute()} `;
|
|
2768
2771
|
});
|
|
2769
2772
|
return attributes;
|
|
2770
2773
|
}
|
|
@@ -2781,34 +2784,22 @@ function restartProcess() {
|
|
|
2781
2784
|
stdio: 'inherit',
|
|
2782
2785
|
});
|
|
2783
2786
|
|
|
2787
|
+
// Handle errors
|
|
2788
|
+
newProcess.on('error', (err) => {
|
|
2789
|
+
console.error('Failed to start new process:', err);
|
|
2790
|
+
});
|
|
2791
|
+
|
|
2784
2792
|
// Unreference the new process so that the current process can exit
|
|
2785
2793
|
newProcess.unref();
|
|
2786
2794
|
|
|
2787
2795
|
// Exit the current process
|
|
2796
|
+
cleanup();
|
|
2788
2797
|
process.exit();
|
|
2789
2798
|
}
|
|
2790
2799
|
|
|
2791
|
-
import * as WebSocket from 'ws';
|
|
2792
2800
|
|
|
2793
|
-
const wss = new WebSocket.Server({ port: 8080 });
|
|
2794
|
-
|
|
2795
|
-
wss.on('connection', ws => {
|
|
2796
|
-
ws.on('message', message => {
|
|
2797
|
-
console.log(`Received message => ${message}`)
|
|
2798
|
-
});
|
|
2799
|
-
|
|
2800
|
-
// Send a message to the frontend
|
|
2801
|
-
ws.send('Hello from backend!');
|
|
2802
|
-
});
|
|
2803
|
-
|
|
2804
|
-
const ws = new WebSocket('ws://localhost:8080');
|
|
2805
|
-
|
|
2806
|
-
ws.onmessage = (event) => {
|
|
2807
|
-
console.log(`Received message => ${event.data}`);
|
|
2808
|
-
};
|
|
2809
|
-
|
|
2810
|
-
*/
|
|
2811
2801
|
/*
|
|
2802
|
+
How frontend was created
|
|
2812
2803
|
npx create-react-app matterbridge-frontend
|
|
2813
2804
|
cd matterbridge-frontend
|
|
2814
2805
|
npm install react-router-dom
|