matterbridge 1.7.3 → 2.0.0-edge.2

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.
Files changed (102) hide show
  1. package/CHANGELOG.md +25 -1
  2. package/dist/cli.js +3 -39
  3. package/dist/cluster/export.js +0 -2
  4. package/dist/defaultConfigSchema.js +0 -23
  5. package/dist/deviceManager.js +1 -26
  6. package/dist/frontend.js +1203 -0
  7. package/dist/index.js +1 -36
  8. package/dist/logger/export.js +0 -1
  9. package/dist/matter/export.js +0 -5
  10. package/dist/matterbridge.js +516 -2678
  11. package/dist/matterbridgeAccessoryPlatform.js +0 -33
  12. package/dist/matterbridgeBehaviors.js +23 -31
  13. package/dist/matterbridgeDeviceTypes.js +11 -82
  14. package/dist/matterbridgeDynamicPlatform.js +0 -33
  15. package/dist/matterbridgeEndpoint.js +45 -1145
  16. package/dist/matterbridgePlatform.js +14 -145
  17. package/dist/matterbridgeTypes.js +3 -24
  18. package/dist/pluginManager.js +5 -246
  19. package/dist/storage/export.js +0 -1
  20. package/dist/utils/colorUtils.js +2 -205
  21. package/dist/utils/export.js +0 -1
  22. package/dist/utils/utils.js +7 -252
  23. package/frontend/build/asset-manifest.json +3 -3
  24. package/frontend/build/index.html +1 -1
  25. package/frontend/build/static/js/{main.6bbd1772.js → main.6204ae54.js} +3 -3
  26. package/frontend/build/static/js/main.6204ae54.js.map +1 -0
  27. package/npm-shrinkwrap.json +9 -9
  28. package/package.json +2 -3
  29. package/dist/cli.d.ts +0 -25
  30. package/dist/cli.d.ts.map +0 -1
  31. package/dist/cli.js.map +0 -1
  32. package/dist/cluster/export.d.ts +0 -2
  33. package/dist/cluster/export.d.ts.map +0 -1
  34. package/dist/cluster/export.js.map +0 -1
  35. package/dist/defaultConfigSchema.d.ts +0 -27
  36. package/dist/defaultConfigSchema.d.ts.map +0 -1
  37. package/dist/defaultConfigSchema.js.map +0 -1
  38. package/dist/deviceManager.d.ts +0 -46
  39. package/dist/deviceManager.d.ts.map +0 -1
  40. package/dist/deviceManager.js.map +0 -1
  41. package/dist/index.d.ts +0 -40
  42. package/dist/index.d.ts.map +0 -1
  43. package/dist/index.js.map +0 -1
  44. package/dist/logger/export.d.ts +0 -2
  45. package/dist/logger/export.d.ts.map +0 -1
  46. package/dist/logger/export.js.map +0 -1
  47. package/dist/matter/export.d.ts +0 -11
  48. package/dist/matter/export.d.ts.map +0 -1
  49. package/dist/matter/export.js.map +0 -1
  50. package/dist/matterbridge.d.ts +0 -483
  51. package/dist/matterbridge.d.ts.map +0 -1
  52. package/dist/matterbridge.js.map +0 -1
  53. package/dist/matterbridgeAccessoryPlatform.d.ts +0 -39
  54. package/dist/matterbridgeAccessoryPlatform.d.ts.map +0 -1
  55. package/dist/matterbridgeAccessoryPlatform.js.map +0 -1
  56. package/dist/matterbridgeBehaviors.d.ts +0 -942
  57. package/dist/matterbridgeBehaviors.d.ts.map +0 -1
  58. package/dist/matterbridgeBehaviors.js.map +0 -1
  59. package/dist/matterbridgeDevice.d.ts +0 -7077
  60. package/dist/matterbridgeDevice.d.ts.map +0 -1
  61. package/dist/matterbridgeDevice.js +0 -2736
  62. package/dist/matterbridgeDevice.js.map +0 -1
  63. package/dist/matterbridgeDeviceTypes.d.ts +0 -109
  64. package/dist/matterbridgeDeviceTypes.d.ts.map +0 -1
  65. package/dist/matterbridgeDeviceTypes.js.map +0 -1
  66. package/dist/matterbridgeDynamicPlatform.d.ts +0 -39
  67. package/dist/matterbridgeDynamicPlatform.d.ts.map +0 -1
  68. package/dist/matterbridgeDynamicPlatform.js.map +0 -1
  69. package/dist/matterbridgeEdge.d.ts +0 -91
  70. package/dist/matterbridgeEdge.d.ts.map +0 -1
  71. package/dist/matterbridgeEdge.js +0 -1077
  72. package/dist/matterbridgeEdge.js.map +0 -1
  73. package/dist/matterbridgeEndpoint.d.ts +0 -10156
  74. package/dist/matterbridgeEndpoint.d.ts.map +0 -1
  75. package/dist/matterbridgeEndpoint.js.map +0 -1
  76. package/dist/matterbridgePlatform.d.ts +0 -168
  77. package/dist/matterbridgePlatform.d.ts.map +0 -1
  78. package/dist/matterbridgePlatform.js.map +0 -1
  79. package/dist/matterbridgeTypes.d.ts +0 -172
  80. package/dist/matterbridgeTypes.d.ts.map +0 -1
  81. package/dist/matterbridgeTypes.js.map +0 -1
  82. package/dist/matterbridgeWebsocket.d.ts +0 -49
  83. package/dist/matterbridgeWebsocket.d.ts.map +0 -1
  84. package/dist/matterbridgeWebsocket.js +0 -325
  85. package/dist/matterbridgeWebsocket.js.map +0 -1
  86. package/dist/pluginManager.d.ts +0 -238
  87. package/dist/pluginManager.d.ts.map +0 -1
  88. package/dist/pluginManager.js.map +0 -1
  89. package/dist/storage/export.d.ts +0 -2
  90. package/dist/storage/export.d.ts.map +0 -1
  91. package/dist/storage/export.js.map +0 -1
  92. package/dist/utils/colorUtils.d.ts +0 -61
  93. package/dist/utils/colorUtils.d.ts.map +0 -1
  94. package/dist/utils/colorUtils.js.map +0 -1
  95. package/dist/utils/export.d.ts +0 -3
  96. package/dist/utils/export.d.ts.map +0 -1
  97. package/dist/utils/export.js.map +0 -1
  98. package/dist/utils/utils.d.ts +0 -221
  99. package/dist/utils/utils.d.ts.map +0 -1
  100. package/dist/utils/utils.js.map +0 -1
  101. package/frontend/build/static/js/main.6bbd1772.js.map +0 -1
  102. /package/frontend/build/static/js/{main.6bbd1772.js.LICENSE.txt → main.6204ae54.js.LICENSE.txt} +0 -0
@@ -1,60 +1,24 @@
1
- /**
2
- * This file contains the class MatterbridgeAccessoryPlatform.
3
- *
4
- * @file matterbridgePlatform.ts
5
- * @author Luca Liguori
6
- * @date 2024-03-21
7
- * @version 1.1.0
8
- *
9
- * Copyright 2024, 2025, 2026 Luca Liguori.
10
- *
11
- * Licensed under the Apache License, Version 2.0 (the "License");
12
- * you may not use this file except in compliance with the License.
13
- * You may obtain a copy of the License at
14
- *
15
- * http://www.apache.org/licenses/LICENSE-2.0
16
- *
17
- * Unless required by applicable law or agreed to in writing, software
18
- * distributed under the License is distributed on an "AS IS" BASIS,
19
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
- * See the License for the specific language governing permissions and
21
- * limitations under the License. *
22
- */
23
- import { MatterbridgeDevice } from './matterbridgeDevice.js';
24
1
  import { MatterbridgeEndpoint } from './matterbridgeEndpoint.js';
25
2
  import { isValidArray, isValidObject, isValidString } from './utils/utils.js';
26
- // AnsiLogger module
27
3
  import { CYAN, db, nf, wr } from 'node-ansi-logger';
28
- // Storage module
29
4
  import { NodeStorageManager } from 'node-persist-manager';
30
- // Node.js module
31
5
  import path from 'path';
32
- /**
33
- * Represents the base Matterbridge platform.
34
- *
35
- */
36
6
  export class MatterbridgePlatform {
37
7
  matterbridge;
38
8
  log;
39
9
  config = {};
40
- name = ''; // Will be set by the loadPlugin() method using the package.json value.
41
- type = ''; // Will be set by the extending classes.
42
- version = ''; // Will be set by the loadPlugin() method using the package.json value.
10
+ name = '';
11
+ type = '';
12
+ version = '';
43
13
  storage;
44
14
  context;
45
15
  selectDevice = new Map();
46
16
  selectEntity = new Map();
47
- /**
48
- * Creates an instance of the base MatterbridgePlatform.
49
- * @param {Matterbridge} matterbridge - The Matterbridge instance.
50
- * @param {AnsiLogger} log - The logger instance.
51
- * @param {PlatformConfig} config - The platform configuration.
52
- */
17
+ registeredEndpoints = new Map();
53
18
  constructor(matterbridge, log, config) {
54
19
  this.matterbridge = matterbridge;
55
20
  this.log = log;
56
21
  this.config = config;
57
- // create the NodeStorageManager for the plugin platform
58
22
  if (!isValidString(this.config.name))
59
23
  return;
60
24
  this.log.debug(`Creating storage for plugin ${this.config.name} in ${path.join(this.matterbridge.matterbridgeDirectory, this.config.name)}`);
@@ -66,78 +30,36 @@ export class MatterbridgePlatform {
66
30
  forgiveParseErrors: true,
67
31
  });
68
32
  }
69
- /**
70
- * This method must be overridden in the extended class.
71
- * It is called when the platform is started.
72
- * Use this method to create the MatterbridgeDevice and call this.registerDevice().
73
- * @param {string} [reason] - The reason for starting.
74
- * @throws {Error} - Throws an error if the method is not overridden.
75
- */
76
33
  async onStart(reason) {
77
34
  this.log.error('Plugins must override onStart.', reason);
78
35
  throw new Error('Plugins must override onStart.');
79
36
  }
80
- /**
81
- * This method can be overridden in the extended class.
82
- * It is called after the platform has been commissioned.
83
- * Use this method to perform any configuration of your devices.
84
- */
85
37
  async onConfigure() {
86
38
  this.log.debug(`Configuring platform ${this.name}`);
87
39
  await this.checkEndpointNumbers();
88
40
  }
89
- /**
90
- * This method can be overridden in the extended class.
91
- * It is called when the platform is shutting down.
92
- * Use this method to clean up any resources.
93
- * @param {string} [reason] - The reason for shutting down.
94
- */
95
41
  async onShutdown(reason) {
96
42
  this.log.debug(`Shutting down platform ${this.name}`, reason);
97
43
  await this.checkEndpointNumbers();
98
44
  }
99
- /**
100
- * Sets the logger level and logs a debug message indicating that the plugin doesn't override this method.
101
- * @param {LogLevel} logLevel The new logger level.
102
- */
103
45
  async onChangeLoggerLevel(logLevel) {
104
46
  this.log.debug(`The plugin doesn't override onChangeLoggerLevel. Logger level set to: ${logLevel}`);
105
47
  }
106
- /**
107
- * Registers a device with the Matterbridge platform.
108
- * @param {MatterbridgeDevice} device - The device to register.
109
- */
110
48
  async registerDevice(device) {
111
49
  device.plugin = this.name;
112
- if (device instanceof MatterbridgeDevice)
113
- await this.matterbridge.addBridgedDevice(this.name, device);
114
- if (device instanceof MatterbridgeEndpoint)
115
- await this.matterbridge.addBridgedEndpoint(this.name, device);
50
+ await this.matterbridge.addBridgedEndpoint(this.name, device);
51
+ if (device.uniqueId)
52
+ this.registeredEndpoints.set(device.uniqueId, device);
116
53
  }
117
- /**
118
- * Unregisters a device registered with the Matterbridge platform.
119
- * @param {MatterbridgeDevice} device - The device to unregister.
120
- */
121
54
  async unregisterDevice(device) {
122
- if (device instanceof MatterbridgeDevice)
123
- await this.matterbridge.removeBridgedDevice(this.name, device);
124
- if (device instanceof MatterbridgeEndpoint)
125
- await this.matterbridge.removeBridgedEndpoint(this.name, device);
55
+ await this.matterbridge.removeBridgedEndpoint(this.name, device);
56
+ if (device.uniqueId)
57
+ this.registeredEndpoints.delete(device.uniqueId);
126
58
  }
127
- /**
128
- * Unregisters all devices registered with the Matterbridge platform.
129
- */
130
59
  async unregisterAllDevices() {
131
- if (this.matterbridge.edge)
132
- await this.matterbridge.removeAllBridgedEndpoints(this.name);
133
- else
134
- await this.matterbridge.removeAllBridgedDevices(this.name);
60
+ await this.matterbridge.removeAllBridgedEndpoints(this.name);
61
+ this.registeredEndpoints.clear();
135
62
  }
136
- /**
137
- * Verifies if the Matterbridge version meets the required version.
138
- * @param {string} requiredVersion - The required version to compare against.
139
- * @returns {boolean} True if the Matterbridge version meets or exceeds the required version, false otherwise.
140
- */
141
63
  verifyMatterbridgeVersion(requiredVersion) {
142
64
  const compareVersions = (matterbridgeVersion, requiredVersion) => {
143
65
  const stripTag = (v) => {
@@ -162,27 +84,9 @@ export class MatterbridgePlatform {
162
84
  return false;
163
85
  return true;
164
86
  }
165
- /**
166
- * Validates if a device is allowed based on the whitelist and blacklist configurations.
167
- * The blacklist has priority over the whitelist.
168
- *
169
- * @param {string | string[]} device - The device name(s) to validate.
170
- * @param {boolean} [log=true] - Whether to log the validation result.
171
- * @returns {boolean} - Returns true if the device is allowed, false otherwise.
172
- */
173
87
  validateDevice(device, log = true) {
174
88
  return this.validateDeviceWhiteBlackList(device, log);
175
89
  }
176
- /**
177
- * Validates if a device is allowed based on the whitelist and blacklist configurations.
178
- * The blacklist has priority over the whitelist.
179
- *
180
- * @param {string | string[]} device - The device name(s) to validate.
181
- * @param {boolean} [log=true] - Whether to log the validation result.
182
- * @returns {boolean} - Returns true if the device is allowed, false otherwise.
183
- *
184
- * @deprecated This method is deprecated and will be removed in future versions. Use validateDevice instead.
185
- */
186
90
  validateDeviceWhiteBlackList(device, log = true) {
187
91
  if (!Array.isArray(device))
188
92
  device = [device];
@@ -212,27 +116,9 @@ export class MatterbridgePlatform {
212
116
  this.log.info(`Skipping device ${CYAN}${device.join(', ')}${nf} because not in whitelist`);
213
117
  return false;
214
118
  }
215
- /**
216
- * Validates if an entity is allowed based on the entity whitelist and blacklist and the device-entity blacklist configurations.
217
- *
218
- * @param {string} device - The device to which the entity belongs.
219
- * @param {string} entity - The entity to validate.
220
- * @param {boolean} [log=true] - Whether to log the validation result.
221
- * @returns {boolean} - Returns true if the entity is allowed, false otherwise.
222
- */
223
119
  validateEntity(device, entity, log = true) {
224
120
  return this.validateEntityBlackList(device, entity, log);
225
121
  }
226
- /**
227
- * Validates if an entity is allowed based on the entity blacklist and device-entity blacklist configurations.
228
- *
229
- * @param {string} device - The device to which the entity belongs.
230
- * @param {string} entity - The entity to validate.
231
- * @param {boolean} [log=true] - Whether to log the validation result.
232
- * @returns {boolean} - Returns true if the entity is allowed, false otherwise.
233
- *
234
- * @deprecated This method is deprecated and will be removed in future versions. Use validateEntity instead.
235
- */
236
122
  validateEntityBlackList(device, entity, log = true) {
237
123
  if (isValidArray(this.config.entityBlackList, 1) && this.config.entityBlackList.find((e) => e === entity)) {
238
124
  if (log)
@@ -251,15 +137,6 @@ export class MatterbridgePlatform {
251
137
  }
252
138
  return true;
253
139
  }
254
- /**
255
- * Checks and updates the endpoint numbers for Matterbridge devices.
256
- *
257
- * This method retrieves the list of Matterbridge devices and their child endpoints,
258
- * compares their current endpoint numbers with the stored ones, and updates the storage
259
- * if there are any changes. It logs the changes and updates the endpoint numbers accordingly.
260
- *
261
- * @returns {Promise<number>} The size of the updated endpoint map, or -1 if storage is not available.
262
- */
263
140
  async checkEndpointNumbers() {
264
141
  if (!this.storage)
265
142
  return -1;
@@ -281,7 +158,7 @@ export class MatterbridgePlatform {
281
158
  endpointMap.set(device.uniqueId, device.maybeNumber);
282
159
  }
283
160
  for (const child of device.getChildEndpoints()) {
284
- const childId = child instanceof MatterbridgeEndpoint ? child.id : child.uniqueStorageKey;
161
+ const childId = child.id;
285
162
  if (!childId || !child.maybeNumber)
286
163
  continue;
287
164
  if (endpointMap.has(device.uniqueId + separator + childId) && endpointMap.get(device.uniqueId + separator + childId) !== child.maybeNumber) {
@@ -298,15 +175,7 @@ export class MatterbridgePlatform {
298
175
  this.log.debug('Endpoint numbers check completed.');
299
176
  return endpointMap.size;
300
177
  }
301
- // Temporary method to create a MatterbridgeDevice before switching to the edge
302
178
  async _createMutableDevice(definition, options = {}, debug = false) {
303
- let device;
304
- if (this.matterbridge.edge === true) {
305
- device = new MatterbridgeEndpoint(definition, options, debug);
306
- }
307
- else
308
- device = new MatterbridgeDevice(definition, undefined, debug);
309
- return device;
179
+ return new MatterbridgeEndpoint(definition, options, debug);
310
180
  }
311
181
  }
312
- //# sourceMappingURL=matterbridgePlatform.js.map
@@ -1,27 +1,6 @@
1
- /**
2
- * This file contains the types for Matterbridge.
3
- *
4
- * @file matterbridgeTypes.ts
5
- * @author Luca Liguori
6
- * @date 2024-07-12
7
- * @version 1.0.2
8
- *
9
- * Copyright 2023, 2024, 2025 Luca Liguori.
10
- *
11
- * Licensed under the Apache License, Version 2.0 (the "License");
12
- * you may not use this file except in compliance with the License.
13
- * You may obtain a copy of the License at
14
- *
15
- * http://www.apache.org/licenses/LICENSE-2.0
16
- *
17
- * Unless required by applicable law or agreed to in writing, software
18
- * distributed under the License is distributed on an "AS IS" BASIS,
19
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
- * See the License for the specific language governing permissions and
21
- * limitations under the License. *
22
- */
23
- // Default colors
1
+ import { MatterbridgeEndpoint } from './matterbridgeEndpoint.js';
24
2
  export const plg = '\u001B[38;5;33m';
25
3
  export const dev = '\u001B[38;5;79m';
26
4
  export const typ = '\u001B[38;5;207m';
27
- //# sourceMappingURL=matterbridgeTypes.js.map
5
+ export class MatterbridgeDevice extends MatterbridgeEndpoint {
6
+ }