matterbridge 3.4.1-dev-20251130-422c2fc → 3.4.1-dev-20251130-cfb291e

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.
@@ -18,6 +18,7 @@ export class BroadcastServer extends EventEmitter {
18
18
  this.log = log;
19
19
  this.channel = channel;
20
20
  this.broadcastChannel = new BroadcastChannel(this.channel);
21
+ this.broadcastChannel.unref();
21
22
  this.broadcastChannel.onmessage = this.broadcastMessageHandler.bind(this);
22
23
  }
23
24
  close() {
@@ -290,9 +290,10 @@ export async function startMatterbridgeEnvironment(port = 5540) {
290
290
  return [server, aggregator];
291
291
  }
292
292
  export function addMatterbridgePlatform(platform, name) {
293
+ expect(platform).toBeDefined();
294
+ platform.setMatterNode?.(matterbridge.addBridgedEndpoint.bind(matterbridge), matterbridge.removeBridgedEndpoint.bind(matterbridge), matterbridge.removeAllBridgedEndpoints.bind(matterbridge), matterbridge.addVirtualEndpoint.bind(matterbridge));
293
295
  if (name)
294
296
  platform.config.name = name;
295
- expect(platform).toBeDefined();
296
297
  expect(platform.config.name).toBeDefined();
297
298
  expect(platform.config.type).toBeDefined();
298
299
  expect(platform.type).toBeDefined();
@@ -1700,6 +1700,7 @@ export class Matterbridge extends EventEmitter {
1700
1700
  await wait(2000);
1701
1701
  }
1702
1702
  async addVirtualEndpoint(pluginName, name, type, callback) {
1703
+ this.log.debug(`Adding virtual endpoint ${plg}${pluginName}${db}:${dev}${name}${db}...`);
1703
1704
  const plugin = this.plugins.get(pluginName);
1704
1705
  if (!plugin) {
1705
1706
  this.log.error(`Error adding virtual endpoint ${dev}${name}${er} for plugin ${plg}${pluginName}${er}: plugin not found`);
@@ -33,6 +33,17 @@ export class MatterbridgePlatform {
33
33
  #server;
34
34
  #debug = hasParameter('debug') || hasParameter('verbose');
35
35
  #verbose = hasParameter('verbose');
36
+ #addBridgedEndpoint;
37
+ #removeBridgedEndpoint;
38
+ #removeAllBridgedEndpoints;
39
+ #addVirtualEndpoint;
40
+ setMatterNode = (addBridgedEndpoint, removeBridgedEndpoint, removeAllBridgedEndpoints, addVirtualEndpoint) => {
41
+ this.#addBridgedEndpoint = addBridgedEndpoint;
42
+ this.#removeBridgedEndpoint = removeBridgedEndpoint;
43
+ this.#removeAllBridgedEndpoints = removeAllBridgedEndpoints;
44
+ this.#addVirtualEndpoint = addVirtualEndpoint;
45
+ this.setMatterNode = undefined;
46
+ };
36
47
  constructor(matterbridge, log, config) {
37
48
  this.matterbridge = matterbridge;
38
49
  this.log = log;
@@ -166,7 +177,7 @@ export class MatterbridgePlatform {
166
177
  return this.#registeredEndpoints.has(deviceUniqueId);
167
178
  }
168
179
  async registerVirtualDevice(name, type, callback) {
169
- return await this.matterbridge.addVirtualEndpoint(this.name, name, type, callback);
180
+ return (await this.#addVirtualEndpoint?.(this.name, name, type, callback)) ?? false;
170
181
  }
171
182
  async registerDevice(device) {
172
183
  device.plugin = this.name;
@@ -206,16 +217,16 @@ export class MatterbridgePlatform {
206
217
  device.createDefaultBridgedDeviceBasicInformationClusterServer(device.deviceName, device.serialNumber, device.vendorId, device.vendorName, device.productName, device.softwareVersion, device.softwareVersionString, device.hardwareVersion, device.hardwareVersionString);
207
218
  }
208
219
  }
209
- await this.matterbridge.addBridgedEndpoint(this.name, device);
220
+ await this.#addBridgedEndpoint?.(this.name, device);
210
221
  this.#registeredEndpoints.set(device.uniqueId, device);
211
222
  }
212
223
  async unregisterDevice(device) {
213
- await this.matterbridge.removeBridgedEndpoint(this.name, device);
224
+ await this.#removeBridgedEndpoint?.(this.name, device);
214
225
  if (device.uniqueId)
215
226
  this.#registeredEndpoints.delete(device.uniqueId);
216
227
  }
217
228
  async unregisterAllDevices(delay = 0) {
218
- await this.matterbridge.removeAllBridgedEndpoints(this.name, delay);
229
+ await this.#removeAllBridgedEndpoints?.(this.name, delay);
219
230
  this.#registeredEndpoints.clear();
220
231
  }
221
232
  async saveSelects() {
@@ -291,7 +302,7 @@ export class MatterbridgePlatform {
291
302
  }
292
303
  return selectEntities;
293
304
  }
294
- verifyMatterbridgeVersion(requiredVersion) {
305
+ verifyMatterbridgeVersion(requiredVersion, destroy = true) {
295
306
  const compareVersions = (matterbridgeVersion, requiredVersion) => {
296
307
  const stripTag = (v) => {
297
308
  const parts = v.split('-');
@@ -311,8 +322,11 @@ export class MatterbridgePlatform {
311
322
  }
312
323
  return true;
313
324
  };
314
- if (!compareVersions(this.matterbridge.matterbridgeVersion, requiredVersion))
325
+ if (!compareVersions(this.matterbridge.matterbridgeVersion, requiredVersion)) {
326
+ if (destroy)
327
+ this.destroy();
315
328
  return false;
329
+ }
316
330
  return true;
317
331
  }
318
332
  validateDevice(device, log = true) {
@@ -816,6 +816,7 @@ export class PluginManager extends EventEmitter {
816
816
  platform.config = config;
817
817
  platform.version = packageJson.version;
818
818
  platform.isLoaded = true;
819
+ platform.setMatterNode?.(this.matterbridge.addBridgedEndpoint.bind(this.matterbridge), this.matterbridge.removeBridgedEndpoint.bind(this.matterbridge), this.matterbridge.removeAllBridgedEndpoints.bind(this.matterbridge), this.matterbridge.addVirtualEndpoint.bind(this.matterbridge));
819
820
  plugin.name = packageJson.name;
820
821
  plugin.description = packageJson.description ?? 'No description';
821
822
  plugin.version = packageJson.version;
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "matterbridge",
3
- "version": "3.4.1-dev-20251130-422c2fc",
3
+ "version": "3.4.1-dev-20251130-cfb291e",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "matterbridge",
9
- "version": "3.4.1-dev-20251130-422c2fc",
9
+ "version": "3.4.1-dev-20251130-cfb291e",
10
10
  "license": "Apache-2.0",
11
11
  "dependencies": {
12
12
  "@matter/main": "0.15.6",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "matterbridge",
3
- "version": "3.4.1-dev-20251130-422c2fc",
3
+ "version": "3.4.1-dev-20251130-cfb291e",
4
4
  "description": "Matterbridge plugin manager for Matter",
5
5
  "author": "https://github.com/Luligu",
6
6
  "license": "Apache-2.0",