matterbridge 1.2.22 → 1.3.1
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 +40 -0
- package/README.md +40 -8
- package/dist/cluster/AirQualityCluster.d.ts.map +1 -0
- package/dist/cluster/AirQualityCluster.js.map +1 -0
- package/dist/cluster/BooleanStateConfigurationCluster.d.ts +2200 -0
- package/dist/cluster/BooleanStateConfigurationCluster.d.ts.map +1 -0
- package/dist/cluster/BooleanStateConfigurationCluster.js +388 -0
- package/dist/cluster/BooleanStateConfigurationCluster.js.map +1 -0
- package/dist/cluster/BridgedDeviceBasicInformationCluster.d.ts.map +1 -0
- package/dist/cluster/BridgedDeviceBasicInformationCluster.js.map +1 -0
- package/dist/cluster/CarbonMonoxideConcentrationMeasurementCluster.d.ts +396 -0
- package/dist/cluster/CarbonMonoxideConcentrationMeasurementCluster.d.ts.map +1 -0
- package/dist/cluster/CarbonMonoxideConcentrationMeasurementCluster.js +30 -0
- package/dist/cluster/CarbonMonoxideConcentrationMeasurementCluster.js.map +1 -0
- package/dist/cluster/ConcentrationMeasurementCluster.d.ts +524 -0
- package/dist/cluster/ConcentrationMeasurementCluster.d.ts.map +1 -0
- package/dist/cluster/ConcentrationMeasurementCluster.js +282 -0
- package/dist/cluster/ConcentrationMeasurementCluster.js.map +1 -0
- package/dist/cluster/DeviceEnergyManagementCluster.d.ts +7851 -0
- package/dist/cluster/DeviceEnergyManagementCluster.d.ts.map +1 -0
- package/dist/cluster/DeviceEnergyManagementCluster.js +1634 -0
- package/dist/cluster/DeviceEnergyManagementCluster.js.map +1 -0
- package/dist/cluster/DeviceEnergyManagementModeCluster.d.ts +68 -0
- package/dist/cluster/DeviceEnergyManagementModeCluster.d.ts.map +1 -0
- package/dist/cluster/DeviceEnergyManagementModeCluster.js +49 -0
- package/dist/cluster/DeviceEnergyManagementModeCluster.js.map +1 -0
- package/dist/cluster/ElectricalEnergyMeasurementCluster.d.ts +4978 -0
- package/dist/cluster/ElectricalEnergyMeasurementCluster.d.ts.map +1 -0
- package/dist/cluster/ElectricalEnergyMeasurementCluster.js +510 -0
- package/dist/cluster/ElectricalEnergyMeasurementCluster.js.map +1 -0
- package/dist/cluster/ElectricalPowerMeasurementCluster.d.ts +3250 -0
- package/dist/cluster/ElectricalPowerMeasurementCluster.d.ts.map +1 -0
- package/dist/cluster/ElectricalPowerMeasurementCluster.js +675 -0
- package/dist/cluster/ElectricalPowerMeasurementCluster.js.map +1 -0
- package/dist/cluster/FanControlCluster.d.ts +1583 -0
- package/dist/cluster/FanControlCluster.d.ts.map +1 -0
- package/dist/cluster/FanControlCluster.js +492 -0
- package/dist/cluster/FanControlCluster.js.map +1 -0
- package/dist/cluster/MeasurementAccuracy.d.ts +63 -0
- package/dist/cluster/MeasurementAccuracy.d.ts.map +1 -0
- package/dist/cluster/MeasurementAccuracy.js +47 -0
- package/dist/cluster/MeasurementAccuracy.js.map +1 -0
- package/dist/cluster/MeasurementAccuracyRange.d.ts +134 -0
- package/dist/cluster/MeasurementAccuracyRange.d.ts.map +1 -0
- package/dist/cluster/MeasurementAccuracyRange.js +103 -0
- package/dist/cluster/MeasurementAccuracyRange.js.map +1 -0
- package/dist/cluster/MeasurementType.d.ts +68 -0
- package/dist/cluster/MeasurementType.d.ts.map +1 -0
- package/dist/cluster/MeasurementType.js +69 -0
- package/dist/cluster/MeasurementType.js.map +1 -0
- package/dist/cluster/PowerTopologyCluster.d.ts +355 -0
- package/dist/cluster/PowerTopologyCluster.d.ts.map +1 -0
- package/dist/cluster/PowerTopologyCluster.js +138 -0
- package/dist/cluster/PowerTopologyCluster.js.map +1 -0
- package/dist/cluster/SmokeCoAlarmCluster.d.ts +1599 -0
- package/dist/cluster/SmokeCoAlarmCluster.d.ts.map +1 -0
- package/dist/cluster/SmokeCoAlarmCluster.js +603 -0
- package/dist/cluster/SmokeCoAlarmCluster.js.map +1 -0
- package/dist/cluster/TvocCluster.d.ts.map +1 -0
- package/dist/cluster/TvocCluster.js.map +1 -0
- package/dist/defaultConfigSchema.d.ts.map +1 -1
- package/dist/defaultConfigSchema.js +9 -1
- package/dist/defaultConfigSchema.js.map +1 -1
- package/dist/index.d.ts +7 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -2
- package/dist/index.js.map +1 -1
- package/dist/matterbridge.d.ts +69 -6
- package/dist/matterbridge.d.ts.map +1 -1
- package/dist/matterbridge.js +131 -45
- package/dist/matterbridge.js.map +1 -1
- package/dist/matterbridgeDevice.d.ts +677 -34
- package/dist/matterbridgeDevice.d.ts.map +1 -1
- package/dist/matterbridgeDevice.js +442 -93
- package/dist/matterbridgeDevice.js.map +1 -1
- package/dist/matterbridgeDeviceV8.d.ts +3 -5
- package/dist/matterbridgeDeviceV8.d.ts.map +1 -1
- package/dist/matterbridgeDeviceV8.js +62 -14
- package/dist/matterbridgeDeviceV8.js.map +1 -1
- package/dist/matterbridgeV8.d.ts +69 -5
- package/dist/matterbridgeV8.d.ts.map +1 -1
- package/dist/matterbridgeV8.js +409 -139
- package/dist/matterbridgeV8.js.map +1 -1
- package/frontend/build/asset-manifest.json +3 -3
- package/frontend/build/index.html +1 -1
- package/frontend/build/static/js/{main.23829a0f.js → main.cbfc6c9b.js} +3 -3
- package/frontend/build/static/js/{main.23829a0f.js.map → main.cbfc6c9b.js.map} +1 -1
- package/package.json +6 -6
- package/dist/AirQualityCluster.d.ts.map +0 -1
- package/dist/AirQualityCluster.js.map +0 -1
- package/dist/BridgedDeviceBasicInformationCluster.d.ts.map +0 -1
- package/dist/BridgedDeviceBasicInformationCluster.js.map +0 -1
- package/dist/TvocCluster.d.ts.map +0 -1
- package/dist/TvocCluster.js.map +0 -1
- /package/dist/{AirQualityCluster.d.ts → cluster/AirQualityCluster.d.ts} +0 -0
- /package/dist/{AirQualityCluster.js → cluster/AirQualityCluster.js} +0 -0
- /package/dist/{BridgedDeviceBasicInformationCluster.d.ts → cluster/BridgedDeviceBasicInformationCluster.d.ts} +0 -0
- /package/dist/{BridgedDeviceBasicInformationCluster.js → cluster/BridgedDeviceBasicInformationCluster.js} +0 -0
- /package/dist/{TvocCluster.d.ts → cluster/TvocCluster.d.ts} +0 -0
- /package/dist/{TvocCluster.js → cluster/TvocCluster.js} +0 -0
- /package/frontend/build/static/js/{main.23829a0f.js.LICENSE.txt → main.cbfc6c9b.js.LICENSE.txt} +0 -0
package/dist/matterbridge.js
CHANGED
|
@@ -32,7 +32,7 @@ import express from 'express';
|
|
|
32
32
|
import os from 'os';
|
|
33
33
|
import path from 'path';
|
|
34
34
|
import WebSocket, { WebSocketServer } from 'ws';
|
|
35
|
-
import { BridgedDeviceBasicInformation, BridgedDeviceBasicInformationCluster } from './BridgedDeviceBasicInformationCluster.js';
|
|
35
|
+
import { BridgedDeviceBasicInformation, BridgedDeviceBasicInformationCluster } from './cluster/BridgedDeviceBasicInformationCluster.js';
|
|
36
36
|
import { CommissioningController, CommissioningServer, MatterServer } from '@project-chip/matter-node.js';
|
|
37
37
|
import { BasicInformationCluster, ClusterServer, FixedLabelCluster, GeneralCommissioning, PowerSourceCluster, ThreadNetworkDiagnosticsCluster, getClusterNameById } from '@project-chip/matter-node.js/cluster';
|
|
38
38
|
import { DeviceTypeId, VendorId } from '@project-chip/matter-node.js/datatype';
|
|
@@ -73,6 +73,9 @@ export class Matterbridge extends EventEmitter {
|
|
|
73
73
|
globalModulesDirectory: '',
|
|
74
74
|
matterbridgeVersion: '',
|
|
75
75
|
matterbridgeLatestVersion: '',
|
|
76
|
+
matterbridgeFabricInfo: [],
|
|
77
|
+
matterbridgePaired: false,
|
|
78
|
+
matterbridgeConnected: false,
|
|
76
79
|
bridgeMode: '',
|
|
77
80
|
restartMode: '',
|
|
78
81
|
debugEnabled: false,
|
|
@@ -133,6 +136,7 @@ export class Matterbridge extends EventEmitter {
|
|
|
133
136
|
}
|
|
134
137
|
/**
|
|
135
138
|
* Initializes the Matterbridge instance as extension for zigbee2mqtt.
|
|
139
|
+
* @deprecated This method is deprecated and will be removed in a future version.
|
|
136
140
|
*
|
|
137
141
|
* @returns A Promise that resolves when the initialization is complete.
|
|
138
142
|
*/
|
|
@@ -205,6 +209,7 @@ export class Matterbridge extends EventEmitter {
|
|
|
205
209
|
}
|
|
206
210
|
/**
|
|
207
211
|
* Close the Matterbridge instance as extension for zigbee2mqtt.
|
|
212
|
+
* @deprecated This method is deprecated and will be removed in a future version.
|
|
208
213
|
*
|
|
209
214
|
* @returns A Promise that resolves when the initialization is complete.
|
|
210
215
|
*/
|
|
@@ -217,6 +222,12 @@ export class Matterbridge extends EventEmitter {
|
|
|
217
222
|
await this.stopStorage();
|
|
218
223
|
this.log.info('Matter server stopped');
|
|
219
224
|
}
|
|
225
|
+
/**
|
|
226
|
+
* Checks if the extension is commissioned.
|
|
227
|
+
* @deprecated This method is deprecated and will be removed in a future version.
|
|
228
|
+
*
|
|
229
|
+
* @returns {boolean} Returns true if the extension is commissioned, false otherwise.
|
|
230
|
+
*/
|
|
220
231
|
isExtensionCommissioned() {
|
|
221
232
|
if (!this.commissioningServer)
|
|
222
233
|
return false;
|
|
@@ -277,7 +288,7 @@ export class Matterbridge extends EventEmitter {
|
|
|
277
288
|
this.nodeStorage = new NodeStorageManager({ dir: path.join(this.matterbridgeDirectory, 'storage'), logging: false });
|
|
278
289
|
this.log.debug('Creating node storage context for matterbridge');
|
|
279
290
|
this.nodeContext = await this.nodeStorage.createStorage('matterbridge');
|
|
280
|
-
// Get the plugins from node storage
|
|
291
|
+
// Get the plugins from node storage and create the plugin node storage contexts
|
|
281
292
|
this.registeredPlugins = await this.nodeContext.get('plugins', []);
|
|
282
293
|
for (const plugin of this.registeredPlugins) {
|
|
283
294
|
this.log.debug(`Creating node storage context for plugin ${plugin.name}`);
|
|
@@ -300,7 +311,34 @@ export class Matterbridge extends EventEmitter {
|
|
|
300
311
|
// Register SIGINT SIGTERM signal handlers
|
|
301
312
|
this.registerSignalHandlers();
|
|
302
313
|
// Set matter.js logger level and format
|
|
303
|
-
|
|
314
|
+
if (hasParameter('matterlogger')) {
|
|
315
|
+
const level = getParameter('matterlogger');
|
|
316
|
+
if (level === 'debug') {
|
|
317
|
+
Logger.defaultLogLevel = Level.DEBUG;
|
|
318
|
+
}
|
|
319
|
+
else if (level === 'info') {
|
|
320
|
+
Logger.defaultLogLevel = Level.INFO;
|
|
321
|
+
}
|
|
322
|
+
else if (level === 'notice') {
|
|
323
|
+
Logger.defaultLogLevel = Level.NOTICE;
|
|
324
|
+
}
|
|
325
|
+
else if (level === 'warn') {
|
|
326
|
+
Logger.defaultLogLevel = Level.WARN;
|
|
327
|
+
}
|
|
328
|
+
else if (level === 'error') {
|
|
329
|
+
Logger.defaultLogLevel = Level.ERROR;
|
|
330
|
+
}
|
|
331
|
+
else if (level === 'fatal') {
|
|
332
|
+
Logger.defaultLogLevel = Level.FATAL;
|
|
333
|
+
}
|
|
334
|
+
else {
|
|
335
|
+
this.log.warn(`Invalid matterlogger level: ${level}. Using default level ${this.debugEnabled ? 'debug' : 'info'}.`);
|
|
336
|
+
Logger.defaultLogLevel = this.debugEnabled ? Level.DEBUG : Level.INFO;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
else {
|
|
340
|
+
Logger.defaultLogLevel = this.debugEnabled ? Level.DEBUG : Level.INFO;
|
|
341
|
+
}
|
|
304
342
|
Logger.format = Format.ANSI;
|
|
305
343
|
// Parse command line
|
|
306
344
|
this.parseCommandLine();
|
|
@@ -458,6 +496,9 @@ export class Matterbridge extends EventEmitter {
|
|
|
458
496
|
this.log.debug('Adding matterbridge commissioning server to matter server');
|
|
459
497
|
await this.matterServer.addCommissioningServer(this.commissioningServer, { uniqueStorageKey: 'Matterbridge' });
|
|
460
498
|
for (const plugin of this.registeredPlugins) {
|
|
499
|
+
plugin.configJson = await this.loadPluginConfig(plugin);
|
|
500
|
+
plugin.schemaJson = await this.loadPluginSchema(plugin);
|
|
501
|
+
this.getPluginLatestVersion(plugin);
|
|
461
502
|
if (!plugin.enabled) {
|
|
462
503
|
this.log.info(`Plugin ${plg}${plugin.name}${nf} not enabled`);
|
|
463
504
|
continue;
|
|
@@ -485,6 +526,9 @@ export class Matterbridge extends EventEmitter {
|
|
|
485
526
|
this.log.debug('Starting matterbridge in mode', this.bridgeMode);
|
|
486
527
|
this.matterServer = this.createMatterServer(this.storageManager);
|
|
487
528
|
for (const plugin of this.registeredPlugins) {
|
|
529
|
+
plugin.configJson = await this.loadPluginConfig(plugin);
|
|
530
|
+
plugin.schemaJson = await this.loadPluginSchema(plugin);
|
|
531
|
+
this.getPluginLatestVersion(plugin);
|
|
488
532
|
if (!plugin.enabled) {
|
|
489
533
|
this.log.info(`Plugin ${plg}${plugin.name}${nf} not enabled`);
|
|
490
534
|
continue;
|
|
@@ -869,7 +913,7 @@ export class Matterbridge extends EventEmitter {
|
|
|
869
913
|
* Adds a bridged device to the Matterbridge.
|
|
870
914
|
* @param pluginName - The name of the plugin.
|
|
871
915
|
* @param device - The bridged device to add.
|
|
872
|
-
* @returns {Promise<void>} - A promise that resolves when the
|
|
916
|
+
* @returns {Promise<void>} - A promise that resolves when the device is added.
|
|
873
917
|
*/
|
|
874
918
|
async addBridgedDevice(pluginName, device) {
|
|
875
919
|
if (this.bridgeMode === 'bridge' && !this.matterAggregator) {
|
|
@@ -1094,15 +1138,38 @@ export class Matterbridge extends EventEmitter {
|
|
|
1094
1138
|
}
|
|
1095
1139
|
/**
|
|
1096
1140
|
* Loads the schema for a plugin.
|
|
1097
|
-
* If the schema file exists, it reads the file and returns the parsed JSON data.
|
|
1098
|
-
* If the schema file
|
|
1141
|
+
* If the schema file exists in the plugin directory, it reads the file and returns the parsed JSON data and delete the schema form .matterbridge.
|
|
1142
|
+
* If the schema file exists in matterbridgeDirectory, it reads the file and returns the parsed JSON data.
|
|
1143
|
+
* If the schema file does not exist, it creates a new schema with the default configuration and returns it.
|
|
1099
1144
|
* If any error occurs during file access or creation, it logs an error and return an empty schema.
|
|
1100
1145
|
*
|
|
1101
1146
|
* @param plugin - The plugin for which to load the schema.
|
|
1102
1147
|
* @returns A promise that resolves to the loaded or created schema.
|
|
1103
1148
|
*/
|
|
1104
1149
|
async loadPluginSchema(plugin) {
|
|
1105
|
-
|
|
1150
|
+
let schemaFile = plugin.path.replace('package.json', `${plugin.name}.schema.json`);
|
|
1151
|
+
try {
|
|
1152
|
+
await fs.access(schemaFile);
|
|
1153
|
+
const data = await fs.readFile(schemaFile, 'utf8');
|
|
1154
|
+
const schema = JSON.parse(data);
|
|
1155
|
+
schema.title = plugin.description;
|
|
1156
|
+
schema.description = plugin.name + ' v. ' + plugin.version + ' by ' + plugin.author;
|
|
1157
|
+
this.log.debug(`Schema file found: ${schemaFile}.`);
|
|
1158
|
+
// this.log.debug(`Schema file found: ${schemaFile}.\nSchema:${rs}\n`, schema);
|
|
1159
|
+
schemaFile = path.join(this.matterbridgeDirectory, `${plugin.name}.schema.json`);
|
|
1160
|
+
try {
|
|
1161
|
+
await fs.unlink(schemaFile);
|
|
1162
|
+
this.log.debug(`Schema file ${schemaFile} deleted.`);
|
|
1163
|
+
}
|
|
1164
|
+
catch (err) {
|
|
1165
|
+
this.log.debug(`Schema file ${schemaFile} to delete not found.`);
|
|
1166
|
+
}
|
|
1167
|
+
return schema;
|
|
1168
|
+
}
|
|
1169
|
+
catch (err) {
|
|
1170
|
+
this.log.debug(`Schema file ${schemaFile} not found.`);
|
|
1171
|
+
}
|
|
1172
|
+
schemaFile = path.join(this.matterbridgeDirectory, `${plugin.name}.schema.json`);
|
|
1106
1173
|
try {
|
|
1107
1174
|
await fs.access(schemaFile);
|
|
1108
1175
|
const data = await fs.readFile(schemaFile, 'utf8');
|
|
@@ -1140,22 +1207,28 @@ export class Matterbridge extends EventEmitter {
|
|
|
1140
1207
|
type: 'string',
|
|
1141
1208
|
readOnly: true,
|
|
1142
1209
|
},
|
|
1210
|
+
debug: {
|
|
1211
|
+
description: 'Enable the debug for the plugin (development only)',
|
|
1212
|
+
type: 'boolean',
|
|
1213
|
+
},
|
|
1143
1214
|
unregisterOnShutdown: {
|
|
1144
1215
|
description: 'Unregister all devices on shutdown (development only)',
|
|
1145
1216
|
type: 'boolean',
|
|
1146
1217
|
},
|
|
1147
1218
|
},
|
|
1148
1219
|
};
|
|
1220
|
+
return schema;
|
|
1221
|
+
/*
|
|
1149
1222
|
try {
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
}
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
return schema;
|
|
1223
|
+
await this.writeFile(schemaFile, JSON.stringify(schema, null, 2));
|
|
1224
|
+
this.log.debug(`Created schema file: ${schemaFile}.`);
|
|
1225
|
+
// this.log.debug(`Created schema file: ${schemaFile}.\nSchema:${rs}\n`, schema);
|
|
1226
|
+
return schema;
|
|
1227
|
+
} catch (err) {
|
|
1228
|
+
this.log.error(`Error creating schema file ${schemaFile}: ${err}`);
|
|
1229
|
+
return schema;
|
|
1158
1230
|
}
|
|
1231
|
+
*/
|
|
1159
1232
|
}
|
|
1160
1233
|
else {
|
|
1161
1234
|
this.log.error(`Error accessing schema file ${schemaFile}: ${err}`);
|
|
@@ -1170,17 +1243,18 @@ export class Matterbridge extends EventEmitter {
|
|
|
1170
1243
|
* Saves the plugin configuration to a JSON file.
|
|
1171
1244
|
* @param plugin - The registered plugin.
|
|
1172
1245
|
* @param config - The platform configuration.
|
|
1173
|
-
* @returns A promise that resolves when the configuration is saved successfully, or
|
|
1246
|
+
* @returns A promise that resolves when the configuration is saved successfully, or with an error logged.
|
|
1174
1247
|
*/
|
|
1175
1248
|
async savePluginConfigFromJson(plugin, config) {
|
|
1176
1249
|
if (!config.name || !config.type || config.name !== plugin.name) {
|
|
1177
|
-
this.log.error(`Error saving plugin ${plg}${plugin.name}${er} config
|
|
1250
|
+
this.log.error(`Error saving plugin ${plg}${plugin.name}${er} config. Wrong config data content.`);
|
|
1178
1251
|
return;
|
|
1179
1252
|
}
|
|
1180
1253
|
const configFile = path.join(this.matterbridgeDirectory, `${plugin.name}.config.json`);
|
|
1181
1254
|
try {
|
|
1182
1255
|
await this.writeFile(configFile, JSON.stringify(config, null, 2));
|
|
1183
|
-
|
|
1256
|
+
plugin.configJson = config;
|
|
1257
|
+
this.log.debug(`Saved config file ${configFile} for plugin ${plg}${plugin.name}${db}.\nConfig:${rs}\n`, config);
|
|
1184
1258
|
}
|
|
1185
1259
|
catch (err) {
|
|
1186
1260
|
this.log.error(`Error saving plugin ${plg}${plugin.name}${er} config: ${err}`);
|
|
@@ -1191,7 +1265,7 @@ export class Matterbridge extends EventEmitter {
|
|
|
1191
1265
|
* Loads the configuration for a plugin.
|
|
1192
1266
|
* If the configuration file exists, it reads the file and returns the parsed JSON data.
|
|
1193
1267
|
* If the configuration file does not exist, it creates a new file with default configuration and returns it.
|
|
1194
|
-
* If any error occurs during file access or creation, it logs an error and
|
|
1268
|
+
* If any error occurs during file access or creation, it logs an error and return un empty config.
|
|
1195
1269
|
*
|
|
1196
1270
|
* @param plugin - The plugin for which to load the configuration.
|
|
1197
1271
|
* @returns A promise that resolves to the loaded or created configuration.
|
|
@@ -1272,28 +1346,26 @@ export class Matterbridge extends EventEmitter {
|
|
|
1272
1346
|
* @returns {Promise<void>} - A promise that resolves when the data is successfully written to the file.
|
|
1273
1347
|
*/
|
|
1274
1348
|
async writeFile(filePath, data) {
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
.writeFile(`${filePath}`, data, 'utf8')
|
|
1278
|
-
.then(() => {
|
|
1349
|
+
try {
|
|
1350
|
+
await fs.writeFile(`${filePath}`, data, 'utf8');
|
|
1279
1351
|
this.log.debug(`Successfully wrote to ${filePath}`);
|
|
1280
|
-
}
|
|
1281
|
-
|
|
1352
|
+
}
|
|
1353
|
+
catch (error) {
|
|
1282
1354
|
this.log.error(`Error writing to ${filePath}:`, error);
|
|
1283
|
-
}
|
|
1355
|
+
}
|
|
1284
1356
|
}
|
|
1285
1357
|
/**
|
|
1286
1358
|
* Starts a plugin.
|
|
1287
1359
|
*
|
|
1288
1360
|
* @param {RegisteredPlugin} plugin - The plugin to start.
|
|
1289
1361
|
* @param {string} [message] - Optional message to pass to the plugin's onStart method.
|
|
1290
|
-
* @param {boolean} [configure
|
|
1362
|
+
* @param {boolean} [configure] - Indicates whether to configure the plugin after starting (default false).
|
|
1291
1363
|
* @returns {Promise<void>} A promise that resolves when the plugin is started successfully, or rejects with an error if starting the plugin fails.
|
|
1292
1364
|
*/
|
|
1293
1365
|
async startPlugin(plugin, message, configure = false) {
|
|
1294
1366
|
if (!plugin.loaded || !plugin.platform) {
|
|
1295
1367
|
this.log.error(`Plugin ${plg}${plugin.name}${er} not loaded or no platform`);
|
|
1296
|
-
return Promise.
|
|
1368
|
+
return Promise.resolve();
|
|
1297
1369
|
}
|
|
1298
1370
|
if (plugin.started) {
|
|
1299
1371
|
this.log.debug(`Plugin ${plg}${plugin.name}${db} already started`);
|
|
@@ -1313,13 +1385,13 @@ export class Matterbridge extends EventEmitter {
|
|
|
1313
1385
|
.catch((err) => {
|
|
1314
1386
|
plugin.error = true;
|
|
1315
1387
|
this.log.error(`Failed to start plugin ${plg}${plugin.name}${er}: ${err}`);
|
|
1316
|
-
|
|
1388
|
+
return Promise.resolve();
|
|
1317
1389
|
});
|
|
1318
1390
|
}
|
|
1319
1391
|
catch (err) {
|
|
1320
1392
|
plugin.error = true;
|
|
1321
1393
|
this.log.error(`Failed to start plugin ${plg}${plugin.name}${er}: ${err}`);
|
|
1322
|
-
|
|
1394
|
+
return Promise.resolve();
|
|
1323
1395
|
}
|
|
1324
1396
|
}
|
|
1325
1397
|
/**
|
|
@@ -1331,7 +1403,7 @@ export class Matterbridge extends EventEmitter {
|
|
|
1331
1403
|
async configurePlugin(plugin) {
|
|
1332
1404
|
if (!plugin.loaded || !plugin.started || !plugin.platform) {
|
|
1333
1405
|
this.log.error(`Plugin ${plg}${plugin.name}${er} not loaded (${plugin.loaded}) or not started (${plugin.started}) or not platform (${plugin.platform?.name})`);
|
|
1334
|
-
return Promise.
|
|
1406
|
+
return Promise.resolve();
|
|
1335
1407
|
}
|
|
1336
1408
|
if (plugin.configured) {
|
|
1337
1409
|
this.log.info(`Plugin ${plg}${plugin.name}${nf} already configured`);
|
|
@@ -1350,13 +1422,13 @@ export class Matterbridge extends EventEmitter {
|
|
|
1350
1422
|
.catch((err) => {
|
|
1351
1423
|
plugin.error = true;
|
|
1352
1424
|
this.log.error(`Failed to configure plugin ${plg}${plugin.name}${er}: ${err}`);
|
|
1353
|
-
|
|
1425
|
+
return Promise.resolve();
|
|
1354
1426
|
});
|
|
1355
1427
|
}
|
|
1356
1428
|
catch (err) {
|
|
1357
1429
|
plugin.error = true;
|
|
1358
1430
|
this.log.error(`Failed to configure plugin ${plg}${plugin.name}${er}: ${err}`);
|
|
1359
|
-
|
|
1431
|
+
return Promise.resolve();
|
|
1360
1432
|
}
|
|
1361
1433
|
}
|
|
1362
1434
|
/**
|
|
@@ -1370,7 +1442,7 @@ export class Matterbridge extends EventEmitter {
|
|
|
1370
1442
|
async loadPlugin(plugin, start = false, message = '') {
|
|
1371
1443
|
if (!plugin.enabled) {
|
|
1372
1444
|
this.log.error(`Plugin ${plg}${plugin.name}${er} not enabled`);
|
|
1373
|
-
return Promise.
|
|
1445
|
+
return Promise.resolve(undefined);
|
|
1374
1446
|
}
|
|
1375
1447
|
if (plugin.platform) {
|
|
1376
1448
|
this.log.error(`Plugin ${plg}${plugin.name}${er} already loaded`);
|
|
@@ -1387,11 +1459,10 @@ export class Matterbridge extends EventEmitter {
|
|
|
1387
1459
|
this.log.debug(`Importing plugin ${plg}${plugin.name}${db} from ${pluginUrl.href}`);
|
|
1388
1460
|
const pluginInstance = await import(pluginUrl.href);
|
|
1389
1461
|
this.log.debug(`Imported plugin ${plg}${plugin.name}${db} from ${pluginUrl.href}`);
|
|
1390
|
-
// Call the default export function of the plugin, passing this MatterBridge instance
|
|
1462
|
+
// Call the default export function of the plugin, passing this MatterBridge instance, the log and the config
|
|
1391
1463
|
if (pluginInstance.default) {
|
|
1392
1464
|
const config = await this.loadPluginConfig(plugin);
|
|
1393
1465
|
const log = new AnsiLogger({ logName: plugin.description, logTimestampFormat: 4 /* TimestampFormat.TIME_MILLIS */, logDebug: this.debugEnabled });
|
|
1394
|
-
// log.setCallback(this.wssSendMessage.bind(this));
|
|
1395
1466
|
const platform = pluginInstance.default(this, log, config);
|
|
1396
1467
|
platform.name = packageJson.name;
|
|
1397
1468
|
platform.config = config;
|
|
@@ -1405,8 +1476,11 @@ export class Matterbridge extends EventEmitter {
|
|
|
1405
1476
|
plugin.loaded = true;
|
|
1406
1477
|
plugin.registeredDevices = 0;
|
|
1407
1478
|
plugin.addedDevices = 0;
|
|
1479
|
+
plugin.configJson = config;
|
|
1480
|
+
plugin.schemaJson = await this.loadPluginSchema(plugin);
|
|
1481
|
+
// Save the updated plugin data in the node storage
|
|
1408
1482
|
await this.nodeContext?.set('plugins', await this.getBaseRegisteredPlugins());
|
|
1409
|
-
|
|
1483
|
+
// this.getPluginLatestVersion(plugin); moved to parseCommandLine
|
|
1410
1484
|
this.log.info(`Loaded plugin ${plg}${plugin.name}${nf} type ${typ}${platform.type} ${db}(entrypoint ${UNDERLINE}${pluginEntry}${UNDERLINEOFF})`);
|
|
1411
1485
|
if (start)
|
|
1412
1486
|
this.startPlugin(plugin, message); // No await do it asyncronously
|
|
@@ -1415,15 +1489,13 @@ export class Matterbridge extends EventEmitter {
|
|
|
1415
1489
|
else {
|
|
1416
1490
|
this.log.error(`Plugin ${plg}${plugin.name}${er} does not provide a default export`);
|
|
1417
1491
|
plugin.error = true;
|
|
1418
|
-
return;
|
|
1419
|
-
// return Promise.reject(new Error(`Plugin ${plg}${plugin.name}${er} does not provide a default export`));
|
|
1492
|
+
return Promise.resolve(undefined);
|
|
1420
1493
|
}
|
|
1421
1494
|
}
|
|
1422
1495
|
catch (err) {
|
|
1423
1496
|
this.log.error(`Failed to load plugin ${plg}${plugin.name}${er}: ${err}`);
|
|
1424
1497
|
plugin.error = true;
|
|
1425
|
-
return;
|
|
1426
|
-
// return Promise.reject(new Error(`Failed to load plugin ${plg}${plugin.name}${er}: ${err}`));
|
|
1498
|
+
return Promise.resolve(undefined);
|
|
1427
1499
|
}
|
|
1428
1500
|
}
|
|
1429
1501
|
/**
|
|
@@ -1970,7 +2042,6 @@ export class Matterbridge extends EventEmitter {
|
|
|
1970
2042
|
vendorName = '(AppleKeyChain)';
|
|
1971
2043
|
break;
|
|
1972
2044
|
case 4362:
|
|
1973
|
-
case 65521:
|
|
1974
2045
|
vendorName = '(SmartThings)';
|
|
1975
2046
|
break;
|
|
1976
2047
|
case 4939:
|
|
@@ -2496,8 +2567,10 @@ export class Matterbridge extends EventEmitter {
|
|
|
2496
2567
|
registeredDevices: plugin.registeredDevices,
|
|
2497
2568
|
qrPairingCode: plugin.qrPairingCode,
|
|
2498
2569
|
manualPairingCode: plugin.manualPairingCode,
|
|
2499
|
-
configJson: includeConfigSchema ? await this.loadPluginConfig(plugin) : {},
|
|
2500
|
-
schemaJson: includeConfigSchema ? await this.loadPluginSchema(plugin) : {},
|
|
2570
|
+
// configJson: includeConfigSchema ? await this.loadPluginConfig(plugin) : {},
|
|
2571
|
+
// schemaJson: includeConfigSchema ? await this.loadPluginSchema(plugin) : {},
|
|
2572
|
+
configJson: includeConfigSchema ? plugin.configJson : {},
|
|
2573
|
+
schemaJson: includeConfigSchema ? plugin.schemaJson : {},
|
|
2501
2574
|
});
|
|
2502
2575
|
}
|
|
2503
2576
|
return baseRegisteredPlugins;
|
|
@@ -2723,11 +2796,14 @@ export class Matterbridge extends EventEmitter {
|
|
|
2723
2796
|
}
|
|
2724
2797
|
catch (error) {
|
|
2725
2798
|
if (this.bridgeMode === 'bridge')
|
|
2726
|
-
this.log.
|
|
2799
|
+
this.log.warn('pairingCodes for /api/settings not found');
|
|
2727
2800
|
}
|
|
2728
2801
|
this.matterbridgeInformation.bridgeMode = this.bridgeMode;
|
|
2729
2802
|
this.matterbridgeInformation.restartMode = this.restartMode;
|
|
2730
2803
|
this.matterbridgeInformation.debugEnabled = this.debugEnabled;
|
|
2804
|
+
this.matterbridgeInformation.matterbridgePaired = this.matterbridgePaired;
|
|
2805
|
+
this.matterbridgeInformation.matterbridgeConnected = this.matterbridgeConnected;
|
|
2806
|
+
// this.matterbridgeInformation.matterbridgeFabricInfo = this.matterbridgeFabricInfo;
|
|
2731
2807
|
const response = { wssHost, qrPairingCode, manualPairingCode, systemInformation: this.systemInformation, matterbridgeInformation: this.matterbridgeInformation };
|
|
2732
2808
|
this.log.debug('Response:', debugStringify(response));
|
|
2733
2809
|
res.json(response);
|
|
@@ -2868,6 +2944,11 @@ export class Matterbridge extends EventEmitter {
|
|
|
2868
2944
|
this.debugEnabled = false;
|
|
2869
2945
|
Logger.defaultLogLevel = Level.INFO;
|
|
2870
2946
|
}
|
|
2947
|
+
else if (param === 'Notice') {
|
|
2948
|
+
this.log.setLogDebug(false);
|
|
2949
|
+
this.debugEnabled = false;
|
|
2950
|
+
Logger.defaultLogLevel = Level.NOTICE;
|
|
2951
|
+
}
|
|
2871
2952
|
else if (param === 'Warn') {
|
|
2872
2953
|
this.log.setLogDebug(false);
|
|
2873
2954
|
this.debugEnabled = false;
|
|
@@ -2878,6 +2959,11 @@ export class Matterbridge extends EventEmitter {
|
|
|
2878
2959
|
this.debugEnabled = false;
|
|
2879
2960
|
Logger.defaultLogLevel = Level.ERROR;
|
|
2880
2961
|
}
|
|
2962
|
+
else if (param === 'Fatal') {
|
|
2963
|
+
this.log.setLogDebug(false);
|
|
2964
|
+
this.debugEnabled = false;
|
|
2965
|
+
Logger.defaultLogLevel = Level.FATAL;
|
|
2966
|
+
}
|
|
2881
2967
|
this.registeredPlugins.forEach((plugin) => {
|
|
2882
2968
|
plugin.platform?.log.setLogDebug(this.debugEnabled);
|
|
2883
2969
|
});
|