matterbridge 1.2.9 → 1.2.11

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.
@@ -55,6 +55,7 @@ export class Matterbridge extends EventEmitter {
55
55
  ipv6Address: '',
56
56
  nodeVersion: '',
57
57
  hostname: '',
58
+ user: '',
58
59
  osType: '',
59
60
  osRelease: '',
60
61
  osPlatform: '',
@@ -72,6 +73,7 @@ export class Matterbridge extends EventEmitter {
72
73
  matterbridgeVersion: '',
73
74
  matterbridgeLatestVersion: '',
74
75
  bridgeMode: '',
76
+ restartMode: '',
75
77
  debugEnabled: false,
76
78
  };
77
79
  homeDirectory = '';
@@ -82,6 +84,7 @@ export class Matterbridge extends EventEmitter {
82
84
  matterbridgeVersion = '';
83
85
  matterbridgeLatestVersion = '';
84
86
  bridgeMode = '';
87
+ restartMode = '';
85
88
  debugEnabled = false;
86
89
  port = 5540;
87
90
  log;
@@ -128,11 +131,11 @@ export class Matterbridge extends EventEmitter {
128
131
  *
129
132
  * @returns A Promise that resolves when the initialization is complete.
130
133
  */
131
- async initializeAsExtension(dataPath, debugEnabled) {
134
+ async startExtension(dataPath, debugEnabled, extensionVersion, port = 5560) {
132
135
  // Set the bridge mode
133
136
  this.bridgeMode = 'bridge';
134
137
  // Set the first port to use
135
- this.port = 5560;
138
+ this.port = port;
136
139
  // Set Matterbridge logger
137
140
  this.debugEnabled = debugEnabled;
138
141
  this.log = new AnsiLogger({ logName: 'Matterbridge', logTimestampFormat: 4 /* TimestampFormat.TIME_MILLIS */, logDebug: this.debugEnabled });
@@ -164,14 +167,16 @@ export class Matterbridge extends EventEmitter {
164
167
  Logger.format = Format.ANSI;
165
168
  // Start the storage and create matterbridgeContext
166
169
  await this.startStorage('json', path.join(this.matterbridgeDirectory, 'matterbridge.json'));
167
- this.matterbridgeContext = await this.createCommissioningServerContext('Matterbridge', 'Matterbridge', DeviceTypes.AGGREGATOR.code, 0xfff1, 'Matterbridge', 0x8000, 'Matterbridge aggregator');
168
- if (!this.storageManager || !this.matterbridgeContext)
169
- return;
170
+ if (!this.storageManager)
171
+ return false;
172
+ this.matterbridgeContext = await this.createCommissioningServerContext('Matterbridge', 'Matterbridge zigbee2MQTT', DeviceTypes.AGGREGATOR.code, 0xfff1, 'Matterbridge', 0x8000, 'zigbee2MQTT Matter extension');
173
+ if (!this.matterbridgeContext)
174
+ return false;
170
175
  await this.matterbridgeContext.set('softwareVersion', 1);
171
176
  await this.matterbridgeContext.set('softwareVersionString', this.matterbridgeVersion);
172
- await this.matterbridgeContext.set('hardwareVersion', 0);
173
- await this.matterbridgeContext.set('hardwareVersionString', '1.0.0'); // Update with the extension version
174
- this.createMatterServer(this.storageManager);
177
+ await this.matterbridgeContext.set('hardwareVersion', 1);
178
+ await this.matterbridgeContext.set('hardwareVersionString', extensionVersion); // Update with the extension version
179
+ this.matterServer = this.createMatterServer(this.storageManager);
175
180
  this.log.debug(`Creating commissioning server for ${plg}Matterbridge${db}`);
176
181
  this.commissioningServer = await this.createCommisioningServer(this.matterbridgeContext, 'Matterbridge');
177
182
  this.log.debug(`Creating matter aggregator for ${plg}Matterbridge${db}`);
@@ -179,9 +184,7 @@ export class Matterbridge extends EventEmitter {
179
184
  this.log.debug('Adding matterbridge aggregator to commissioning server');
180
185
  this.commissioningServer.addDevice(this.matterAggregator);
181
186
  this.log.debug('Adding matterbridge commissioning server to matter server');
182
- await this.matterServer?.addCommissioningServer(this.commissioningServer, { uniqueStorageKey: 'Matterbridge' });
183
- this.log.debug(`Setting reachability to true for ${plg}Matterbridge${db}`);
184
- this.commissioningServer.setReachability(true);
187
+ await this.matterServer.addCommissioningServer(this.commissioningServer, { uniqueStorageKey: 'Matterbridge' });
185
188
  await this.startMatterServer();
186
189
  this.log.info('Matter server started');
187
190
  await this.showCommissioningQRCode(this.commissioningServer, this.matterbridgeContext, this.nodeContext, 'Matterbridge');
@@ -193,17 +196,26 @@ export class Matterbridge extends EventEmitter {
193
196
  if (this.matterAggregator)
194
197
  this.setAggregatorReachability(this.matterAggregator, true);
195
198
  }, 60 * 1000);
199
+ return this.commissioningServer.isCommissioned();
196
200
  }
197
201
  /**
198
202
  * Close the Matterbridge instance as extension for zigbee2mqtt.
199
203
  *
200
204
  * @returns A Promise that resolves when the initialization is complete.
201
205
  */
202
- async closeAsExtension() {
206
+ async stopExtension() {
203
207
  // Closing matter
204
208
  await this.stopMatter();
209
+ // Clearing the session manager
210
+ // this.matterbridgeContext?.createContext('SessionManager').clear();
205
211
  // Closing storage
206
212
  await this.stopStorage();
213
+ this.log.info('Matter server stopped');
214
+ }
215
+ isExtensionCommissioned() {
216
+ if (!this.commissioningServer)
217
+ return false;
218
+ return this.commissioningServer.isCommissioned();
207
219
  }
208
220
  /**
209
221
  * Initializes the Matterbridge application.
@@ -243,6 +255,11 @@ export class Matterbridge extends EventEmitter {
243
255
  }
244
256
  // Set the first port to use
245
257
  this.port = getIntParameter('port') ?? 5540;
258
+ // Set the restart mode
259
+ if (hasParameter('service'))
260
+ this.restartMode = 'service';
261
+ if (hasParameter('docker'))
262
+ this.restartMode = 'docker';
246
263
  // Set Matterbridge logger
247
264
  if (hasParameter('debug'))
248
265
  this.debugEnabled = true;
@@ -277,7 +294,8 @@ export class Matterbridge extends EventEmitter {
277
294
  await this.logNodeAndSystemInfo();
278
295
  this.log.info(
279
296
  // eslint-disable-next-line max-len
280
- `Matterbridge version ${this.matterbridgeVersion} mode ${hasParameter('bridge') ? 'bridge' : ''}${hasParameter('childbridge') ? 'childbridge' : ''}${hasParameter('controller') ? 'controller' : ''} running on ${this.systemInformation.osType} ${this.systemInformation.osRelease} ${this.systemInformation.osPlatform} ${this.systemInformation.osArch}`);
297
+ `Matterbridge version ${this.matterbridgeVersion} mode ${hasParameter('bridge') ? 'bridge' : ''}${hasParameter('childbridge') ? 'childbridge' : ''}${hasParameter('controller') ? 'controller' : ''} ` +
298
+ `${this.restartMode !== '' ? 'restart mode ' + this.restartMode + ' ' : ''}running on ${this.systemInformation.osType} ${this.systemInformation.osRelease} ${this.systemInformation.osPlatform} ${this.systemInformation.osArch}`);
281
299
  // Check node version and throw error
282
300
  requireMinNodeVersion(18);
283
301
  // Register SIGINT SIGTERM signal handlers
@@ -608,12 +626,17 @@ export class Matterbridge extends EventEmitter {
608
626
  this.log.debug('All listeners removed');
609
627
  // Calling the shutdown functions with a reason
610
628
  for (const plugin of this.registeredPlugins) {
611
- if (!plugin.enabled)
629
+ if (!plugin.enabled || plugin.error)
612
630
  continue;
613
631
  this.log.info(`*Shutting down plugin ${plg}${plugin.name}${nf}`);
614
632
  if (plugin.platform) {
615
- await plugin.platform.onShutdown('Matterbridge is closing: ' + message);
616
- await this.savePluginConfig(plugin);
633
+ try {
634
+ await plugin.platform.onShutdown('Matterbridge is closing: ' + message);
635
+ await this.savePluginConfig(plugin);
636
+ }
637
+ catch (error) {
638
+ this.log.error(`Plugin ${plg}${plugin.name}${er} shutting down error: ${error}`);
639
+ }
617
640
  }
618
641
  else {
619
642
  this.log.warn(`Plugin ${plg}${plugin.name}${wr} platform not found`);
@@ -983,12 +1006,7 @@ export class Matterbridge extends EventEmitter {
983
1006
  return;
984
1007
  }
985
1008
  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
- }
1009
+ this.matterServer = this.createMatterServer(this.storageManager);
992
1010
  this.log.debug('***Starting startMatterbridge interval for Matterbridge');
993
1011
  let failCount = 0;
994
1012
  const startInterval = setInterval(async () => {
@@ -1164,7 +1182,7 @@ export class Matterbridge extends EventEmitter {
1164
1182
  return Promise.reject(new Error(`Plugin ${plg}${plugin.name}${er} not loaded or no platform`));
1165
1183
  }
1166
1184
  if (plugin.started) {
1167
- this.log.warn(`Plugin ${plg}${plugin.name}${wr} already started`);
1185
+ this.log.debug(`Plugin ${plg}${plugin.name}${db} already started`);
1168
1186
  return Promise.resolve();
1169
1187
  }
1170
1188
  this.log.info(`Starting plugin ${plg}${plugin.name}${db} type ${typ}${plugin.type}${db}`);
@@ -1179,13 +1197,15 @@ export class Matterbridge extends EventEmitter {
1179
1197
  return Promise.resolve();
1180
1198
  })
1181
1199
  .catch((err) => {
1200
+ plugin.error = true;
1182
1201
  this.log.error(`Failed to start plugin ${plg}${plugin.name}${er}: ${err}`);
1183
- return Promise.reject(new Error(`Failed to start plugin ${plg}${plugin.name}${er}: ${err}`));
1202
+ // return Promise.reject(new Error(`Failed to start plugin ${plg}${plugin.name}${er}: ${err}`));
1184
1203
  });
1185
1204
  }
1186
1205
  catch (err) {
1206
+ plugin.error = true;
1187
1207
  this.log.error(`Failed to start plugin ${plg}${plugin.name}${er}: ${err}`);
1188
- return Promise.reject(new Error(`Failed to start plugin ${plg}${plugin.name}${er}: ${err}`));
1208
+ // return Promise.reject(new Error(`Failed to start plugin ${plg}${plugin.name}${er}: ${err}`));
1189
1209
  }
1190
1210
  }
1191
1211
  /**
@@ -1213,13 +1233,15 @@ export class Matterbridge extends EventEmitter {
1213
1233
  return Promise.resolve();
1214
1234
  })
1215
1235
  .catch((err) => {
1236
+ plugin.error = true;
1216
1237
  this.log.error(`Failed to configure plugin ${plg}${plugin.name}${er}: ${err}`);
1217
- return Promise.reject(new Error(`Failed to configure plugin ${plg}${plugin.name}${er}: ${err}`));
1238
+ // return Promise.reject(new Error(`Failed to configure plugin ${plg}${plugin.name}${er}: ${err}`));
1218
1239
  });
1219
1240
  }
1220
1241
  catch (err) {
1242
+ plugin.error = true;
1221
1243
  this.log.error(`Failed to configure plugin ${plg}${plugin.name}${er}: ${err}`);
1222
- return Promise.reject(new Error(`Failed to configure plugin ${plg}${plugin.name}${er}: ${err}`));
1244
+ // return Promise.reject(new Error(`Failed to configure plugin ${plg}${plugin.name}${er}: ${err}`));
1223
1245
  }
1224
1246
  }
1225
1247
  /**
@@ -1275,12 +1297,14 @@ export class Matterbridge extends EventEmitter {
1275
1297
  }
1276
1298
  else {
1277
1299
  this.log.error(`Plugin ${plg}${plugin.name}${er} does not provide a default export`);
1300
+ plugin.error = true;
1278
1301
  return;
1279
1302
  //return Promise.reject(new Error(`Plugin ${plg}${plugin.name}${er} does not provide a default export`));
1280
1303
  }
1281
1304
  }
1282
1305
  catch (err) {
1283
1306
  this.log.error(`Failed to load plugin ${plg}${plugin.name}${er}: ${err}`);
1307
+ plugin.error = true;
1284
1308
  return;
1285
1309
  //return Promise.reject(new Error(`Failed to load plugin ${plg}${plugin.name}${er}: ${err}`));
1286
1310
  }
@@ -1304,12 +1328,7 @@ export class Matterbridge extends EventEmitter {
1304
1328
  return;
1305
1329
  }
1306
1330
  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
- }
1331
+ this.matterServer = this.createMatterServer(this.storageManager);
1313
1332
  this.log.info('Creating matter commissioning controller');
1314
1333
  this.commissioningController = new CommissioningController({
1315
1334
  autoConnect: false,
@@ -1466,12 +1485,7 @@ export class Matterbridge extends EventEmitter {
1466
1485
  return;
1467
1486
  }
1468
1487
  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
- }
1488
+ this.matterServer = this.createMatterServer(this.storageManager);
1475
1489
  if (this.bridgeMode === 'bridge') {
1476
1490
  // Plugins are loaded by loadPlugin on startup and plugin.loaded is set to true
1477
1491
  // Plugins are started and configured by callback when Matterbridge is commissioned
@@ -1479,10 +1493,10 @@ export class Matterbridge extends EventEmitter {
1479
1493
  let failCount = 0;
1480
1494
  const startInterval = setInterval(async () => {
1481
1495
  for (const plugin of this.registeredPlugins) {
1482
- if (!plugin.enabled)
1496
+ if (!plugin.enabled || plugin.error)
1483
1497
  continue;
1484
1498
  if (!plugin.loaded) {
1485
- this.log.info(`***Waiting (failSafeCount=${failCount}/30) in startMatterbridge interval for plugin ${plg}${plugin.name}${db} loaded: ${plugin.loaded}...`);
1499
+ this.log.debug(`***Waiting (failSafeCount=${failCount}/30) in startMatterbridge interval for plugin ${plg}${plugin.name}${db} loaded: ${plugin.loaded}...`);
1486
1500
  failCount++;
1487
1501
  if (failCount > 30) {
1488
1502
  this.log.error(`***Failed to load plugin ${plg}${plugin.name}${er}`);
@@ -1515,8 +1529,6 @@ export class Matterbridge extends EventEmitter {
1515
1529
  this.commissioningServer.addDevice(this.matterAggregator);
1516
1530
  this.log.debug('Adding matterbridge commissioning server to matter server');
1517
1531
  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
1532
  await this.startMatterServer();
1521
1533
  this.log.info('Matter server started');
1522
1534
  await this.showCommissioningQRCode(this.commissioningServer, this.matterbridgeContext, this.nodeContext, 'Matterbridge');
@@ -1543,7 +1555,7 @@ export class Matterbridge extends EventEmitter {
1543
1555
  let failCount = 0;
1544
1556
  const startInterval = setInterval(async () => {
1545
1557
  if (!plugin.loaded || !plugin.started /* || !plugin.configured*/) {
1546
- this.log.info(`***Waiting (failSafeCount=${failCount}/30) in startMatterbridge interval for plugin ${plg}${plugin.name}${db} loaded: ${plugin.loaded} started: ${plugin.started}...`);
1558
+ this.log.debug(`***Waiting (failSafeCount=${failCount}/30) in startMatterbridge interval for plugin ${plg}${plugin.name}${db} loaded: ${plugin.loaded} started: ${plugin.started}...`);
1547
1559
  failCount++;
1548
1560
  if (failCount > 30) {
1549
1561
  this.log.error(`***Failed to load plugin ${plg}${plugin.name}${er}`);
@@ -1727,8 +1739,8 @@ export class Matterbridge extends EventEmitter {
1727
1739
  if (!commissioningServer.isCommissioned()) {
1728
1740
  this.log.info(`***The commissioning server on port ${commissioningServer.getPort()} for ${plg}${pluginName}${nf} is not commissioned. Pair it scanning the QR code ...`);
1729
1741
  const { qrPairingCode, manualPairingCode } = commissioningServer.getPairingCode();
1730
- storageContext.set('qrPairingCode', qrPairingCode);
1731
- storageContext.set('manualPairingCode', manualPairingCode);
1742
+ await storageContext.set('qrPairingCode', qrPairingCode);
1743
+ await storageContext.set('manualPairingCode', manualPairingCode);
1732
1744
  await nodeContext.set('qrPairingCode', qrPairingCode);
1733
1745
  await nodeContext.set('manualPairingCode', manualPairingCode);
1734
1746
  const QrCode = new QrCodeSchema();
@@ -1861,7 +1873,7 @@ export class Matterbridge extends EventEmitter {
1861
1873
  const info = commissioningServer.getActiveSessionInformation(fabricIndex);
1862
1874
  let connected = false;
1863
1875
  info.forEach((session) => {
1864
- this.log.debug(`***Active session changed on fabric ${fabricIndex} ${session.fabric?.rootVendorId}/${session.fabric?.label} for ${plg}${pluginName}${nf}`, debugStringify(session));
1876
+ this.log.info(`***Active session changed on fabric ${fabricIndex} ${session.fabric?.rootVendorId}/${session.fabric?.label} for ${plg}${pluginName}${nf}`, debugStringify(session));
1865
1877
  if (session.isPeerActive === true && session.secure === true && session.numberOfActiveSubscriptions >= 1) {
1866
1878
  let controllerName = '';
1867
1879
  if (session.fabric?.rootVendorId === 4937)
@@ -1870,7 +1882,7 @@ export class Matterbridge extends EventEmitter {
1870
1882
  controllerName = 'SmartThings';
1871
1883
  if (session.fabric?.rootVendorId === 4939)
1872
1884
  controllerName = 'HomeAssistant';
1873
- this.log.info(`***Controller ${session.fabric?.rootVendorId}${controllerName !== '' ? '(' + controllerName + ')' : ''}/${session.fabric?.label} connected to ${plg}${pluginName}${nf}`);
1885
+ this.log.info(`***Controller ${session.fabric?.rootVendorId}${controllerName !== '' ? '(' + controllerName + ')' : ''}/${session.fabric?.label} connected to ${plg}${pluginName}${nf} on session ${session.name}`);
1874
1886
  connected = true;
1875
1887
  }
1876
1888
  });
@@ -1886,9 +1898,15 @@ export class Matterbridge extends EventEmitter {
1886
1898
  if (this.bridgeMode === 'bridge') {
1887
1899
  //Logger.defaultLogLevel = Level.INFO;
1888
1900
  for (const plugin of this.registeredPlugins) {
1889
- if (!plugin.enabled)
1901
+ if (!plugin.enabled || !plugin.loaded || plugin.error)
1890
1902
  continue;
1891
- this.startPlugin(plugin, 'Matterbridge is commissioned and controllers are connected', true); // No await do it asyncronously with also configurePlugin
1903
+ try {
1904
+ this.startPlugin(plugin, 'Matterbridge is commissioned and controllers are connected', true); // No await do it asyncronously with also configurePlugin
1905
+ }
1906
+ catch (error) {
1907
+ plugin.error = true;
1908
+ this.log.error(`Error starting plugin ${plg}${plugin.name}${er}`, error);
1909
+ }
1892
1910
  }
1893
1911
  Logger.defaultLogLevel = this.debugEnabled ? Level.DEBUG : Level.INFO;
1894
1912
  }
@@ -1928,7 +1946,7 @@ export class Matterbridge extends EventEmitter {
1928
1946
  const info = commissioningServer.getCommissionedFabricInformation(fabricIndex);
1929
1947
  this.log.debug(`***Commissioning changed on fabric ${fabricIndex} for ${plg}${pluginName}${nf}`, debugStringify(info));
1930
1948
  if (info.length === 0) {
1931
- this.log.warn(`***Commissioning removed from fabric ${fabricIndex} for ${plg}${pluginName}${nf}. Resetting the commissioning server ...`);
1949
+ this.log.warn(`***Commissioning removed from fabric ${fabricIndex} for ${plg}${pluginName}${wr}. Resetting the commissioning server ...`);
1932
1950
  await commissioningServer.factoryReset();
1933
1951
  if (pluginName === 'Matterbridge') {
1934
1952
  await this.matterbridgeContext?.clearAll();
@@ -1943,6 +1961,7 @@ export class Matterbridge extends EventEmitter {
1943
1961
  }
1944
1962
  }
1945
1963
  }
1964
+ this.log.warn(`***Restart to activate the pairing for ${plg}${pluginName}${wr}`);
1946
1965
  }
1947
1966
  },
1948
1967
  });
@@ -1956,8 +1975,9 @@ export class Matterbridge extends EventEmitter {
1956
1975
  */
1957
1976
  createMatterServer(storageManager) {
1958
1977
  this.log.debug('Creating matter server');
1959
- this.matterServer = new MatterServer(storageManager, { mdnsAnnounceInterface: undefined });
1978
+ const matterServer = new MatterServer(storageManager, { mdnsAnnounceInterface: undefined });
1960
1979
  this.log.debug('Created matter server');
1980
+ return matterServer;
1961
1981
  }
1962
1982
  /**
1963
1983
  * Creates a Matter Aggregator.
@@ -2075,6 +2095,7 @@ export class Matterbridge extends EventEmitter {
2075
2095
  const versionPatch = parseInt(this.systemInformation.nodeVersion.split('.')[2]);
2076
2096
  // Host system information
2077
2097
  this.systemInformation.hostname = os.hostname();
2098
+ this.systemInformation.user = os.userInfo().username;
2078
2099
  this.systemInformation.osType = os.type(); // "Windows_NT", "Darwin", etc.
2079
2100
  this.systemInformation.osRelease = os.release(); // Kernel version
2080
2101
  this.systemInformation.osPlatform = os.platform(); // "win32", "linux", "darwin", etc.
@@ -2085,6 +2106,7 @@ export class Matterbridge extends EventEmitter {
2085
2106
  // Log the system information
2086
2107
  this.log.debug('Host System Information:');
2087
2108
  this.log.debug(`- Hostname: ${this.systemInformation.hostname}`);
2109
+ this.log.debug(`- User: ${this.systemInformation.user}`);
2088
2110
  this.log.debug(`- IPv4 Address: ${this.systemInformation.ipv4Address}`);
2089
2111
  this.log.debug(`- IPv6 Address: ${this.systemInformation.ipv6Address}`);
2090
2112
  this.log.debug(`- Node.js: ${versionMajor}.${versionMinor}.${versionPatch}`);
@@ -2266,7 +2288,7 @@ export class Matterbridge extends EventEmitter {
2266
2288
  args.unshift(command);
2267
2289
  command = 'sudo';
2268
2290
  }
2269
- this.log.debug(`Spawning command ${command} with ${debugStringify(args)}`);
2291
+ this.log.debug(`Spawn command ${command} with ${debugStringify(args)}`);
2270
2292
  return new Promise((resolve, reject) => {
2271
2293
  const childProcess = spawn(command, args, {
2272
2294
  stdio: ['inherit', 'pipe', 'pipe'],
@@ -2430,6 +2452,7 @@ export class Matterbridge extends EventEmitter {
2430
2452
  res.json({});
2431
2453
  }
2432
2454
  this.matterbridgeInformation.bridgeMode = this.bridgeMode;
2455
+ this.matterbridgeInformation.restartMode = this.restartMode;
2433
2456
  this.matterbridgeInformation.debugEnabled = this.debugEnabled;
2434
2457
  const response = { wssHost, qrPairingCode, manualPairingCode, systemInformation: this.systemInformation, matterbridgeInformation: this.matterbridgeInformation };
2435
2458
  this.log.debug('The frontend sent /api/settings');
@@ -2495,7 +2518,7 @@ export class Matterbridge extends EventEmitter {
2495
2518
  }
2496
2519
  catch (error) {
2497
2520
  attributeValue = 'Unavailable';
2498
- this.log.debug(`****${error} in clusterServer: ${clusterServer.name}(${clusterServer.id}) attribute: ${key}(${value.id})`);
2521
+ this.log.debug(`GetLocal value ${error} in clusterServer: ${clusterServer.name}(${clusterServer.id}) attribute: ${key}(${value.id})`);
2499
2522
  //console.log(error);
2500
2523
  }
2501
2524
  data.push({
@@ -2765,6 +2788,8 @@ export class Matterbridge extends EventEmitter {
2765
2788
  attributes += `Humidity: ${clusterServer.getMeasuredValueAttribute() / 100}% `;
2766
2789
  if (clusterServer.name === 'PressureMeasurement')
2767
2790
  attributes += `Pressure: ${clusterServer.getMeasuredValueAttribute()} `;
2791
+ if (clusterServer.name === 'FlowMeasurement')
2792
+ attributes += `Pressure: ${clusterServer.getMeasuredValueAttribute()} `;
2768
2793
  });
2769
2794
  return attributes;
2770
2795
  }
@@ -2781,34 +2806,22 @@ function restartProcess() {
2781
2806
  stdio: 'inherit',
2782
2807
  });
2783
2808
 
2809
+ // Handle errors
2810
+ newProcess.on('error', (err) => {
2811
+ console.error('Failed to start new process:', err);
2812
+ });
2813
+
2784
2814
  // Unreference the new process so that the current process can exit
2785
2815
  newProcess.unref();
2786
2816
 
2787
2817
  // Exit the current process
2818
+ cleanup();
2788
2819
  process.exit();
2789
2820
  }
2790
2821
 
2791
- import * as WebSocket from 'ws';
2792
-
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
2822
 
2806
- ws.onmessage = (event) => {
2807
- console.log(`Received message => ${event.data}`);
2808
- };
2809
-
2810
- */
2811
2823
  /*
2824
+ How frontend was created
2812
2825
  npx create-react-app matterbridge-frontend
2813
2826
  cd matterbridge-frontend
2814
2827
  npm install react-router-dom