matterbridge 2.0.0 → 2.1.0-dev.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 (97) hide show
  1. package/CHANGELOG.md +22 -1
  2. package/README.md +1 -1
  3. package/dist/cli.js +0 -26
  4. package/dist/cluster/export.js +0 -2
  5. package/dist/defaultConfigSchema.js +0 -23
  6. package/dist/deviceManager.js +1 -26
  7. package/dist/frontend.js +57 -242
  8. package/dist/index.js +1 -30
  9. package/dist/logger/export.js +0 -1
  10. package/dist/matter/export.js +0 -7
  11. package/dist/matterbridge.js +77 -702
  12. package/dist/matterbridgeAccessoryPlatform.js +0 -33
  13. package/dist/matterbridgeBehaviors.js +33 -38
  14. package/dist/matterbridgeDeviceTypes.js +11 -112
  15. package/dist/matterbridgeDynamicPlatform.js +0 -33
  16. package/dist/matterbridgeEndpoint.js +970 -2524
  17. package/dist/matterbridgePlatform.js +3 -123
  18. package/dist/matterbridgeTypes.js +0 -28
  19. package/dist/pluginManager.js +3 -240
  20. package/dist/storage/export.js +0 -1
  21. package/dist/utils/colorUtils.js +2 -205
  22. package/dist/utils/export.js +0 -1
  23. package/dist/utils/utils.js +7 -251
  24. package/frontend/build/asset-manifest.json +3 -3
  25. package/frontend/build/index.html +1 -1
  26. package/frontend/build/static/js/{main.6df4ebe4.js → main.26dbf9b9.js} +3 -3
  27. package/frontend/build/static/js/{main.6df4ebe4.js.map → main.26dbf9b9.js.map} +1 -1
  28. package/npm-shrinkwrap.json +83 -68
  29. package/package.json +2 -4
  30. package/dist/cli.d.ts +0 -25
  31. package/dist/cli.d.ts.map +0 -1
  32. package/dist/cli.js.map +0 -1
  33. package/dist/cluster/export.d.ts +0 -2
  34. package/dist/cluster/export.d.ts.map +0 -1
  35. package/dist/cluster/export.js.map +0 -1
  36. package/dist/defaultConfigSchema.d.ts +0 -27
  37. package/dist/defaultConfigSchema.d.ts.map +0 -1
  38. package/dist/defaultConfigSchema.js.map +0 -1
  39. package/dist/deviceManager.d.ts +0 -46
  40. package/dist/deviceManager.d.ts.map +0 -1
  41. package/dist/deviceManager.js.map +0 -1
  42. package/dist/frontend.d.ts +0 -98
  43. package/dist/frontend.d.ts.map +0 -1
  44. package/dist/frontend.js.map +0 -1
  45. package/dist/index.d.ts +0 -34
  46. package/dist/index.d.ts.map +0 -1
  47. package/dist/index.js.map +0 -1
  48. package/dist/logger/export.d.ts +0 -2
  49. package/dist/logger/export.d.ts.map +0 -1
  50. package/dist/logger/export.js.map +0 -1
  51. package/dist/matter/export.d.ts +0 -10
  52. package/dist/matter/export.d.ts.map +0 -1
  53. package/dist/matter/export.js.map +0 -1
  54. package/dist/matterbridge.d.ts +0 -356
  55. package/dist/matterbridge.d.ts.map +0 -1
  56. package/dist/matterbridge.js.map +0 -1
  57. package/dist/matterbridgeAccessoryPlatform.d.ts +0 -39
  58. package/dist/matterbridgeAccessoryPlatform.d.ts.map +0 -1
  59. package/dist/matterbridgeAccessoryPlatform.js.map +0 -1
  60. package/dist/matterbridgeBehaviors.d.ts +0 -963
  61. package/dist/matterbridgeBehaviors.d.ts.map +0 -1
  62. package/dist/matterbridgeBehaviors.js.map +0 -1
  63. package/dist/matterbridgeDeviceTypes.d.ts +0 -177
  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/matterbridgeEndpoint.d.ts +0 -10254
  70. package/dist/matterbridgeEndpoint.d.ts.map +0 -1
  71. package/dist/matterbridgeEndpoint.js.map +0 -1
  72. package/dist/matterbridgeEndpointDefault.d.ts +0 -2
  73. package/dist/matterbridgeEndpointDefault.d.ts.map +0 -1
  74. package/dist/matterbridgeEndpointDefault.js +0 -159
  75. package/dist/matterbridgeEndpointDefault.js.map +0 -1
  76. package/dist/matterbridgePlatform.d.ts +0 -164
  77. package/dist/matterbridgePlatform.d.ts.map +0 -1
  78. package/dist/matterbridgePlatform.js.map +0 -1
  79. package/dist/matterbridgeTypes.d.ts +0 -167
  80. package/dist/matterbridgeTypes.d.ts.map +0 -1
  81. package/dist/matterbridgeTypes.js.map +0 -1
  82. package/dist/pluginManager.d.ts +0 -238
  83. package/dist/pluginManager.d.ts.map +0 -1
  84. package/dist/pluginManager.js.map +0 -1
  85. package/dist/storage/export.d.ts +0 -2
  86. package/dist/storage/export.d.ts.map +0 -1
  87. package/dist/storage/export.js.map +0 -1
  88. package/dist/utils/colorUtils.d.ts +0 -61
  89. package/dist/utils/colorUtils.d.ts.map +0 -1
  90. package/dist/utils/colorUtils.js.map +0 -1
  91. package/dist/utils/export.d.ts +0 -3
  92. package/dist/utils/export.d.ts.map +0 -1
  93. package/dist/utils/export.js.map +0 -1
  94. package/dist/utils/utils.d.ts +0 -221
  95. package/dist/utils/utils.d.ts.map +0 -1
  96. package/dist/utils/utils.js.map +0 -1
  97. /package/frontend/build/static/js/{main.6df4ebe4.js.LICENSE.txt → main.26dbf9b9.js.LICENSE.txt} +0 -0
@@ -1,59 +1,23 @@
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
1
  import { isValidArray, isValidObject, isValidString } from './utils/utils.js';
24
- // AnsiLogger module
25
2
  import { CYAN, db, nf, wr } from './logger/export.js';
26
- // Storage module
27
3
  import { NodeStorageManager } from './storage/export.js';
28
- // Node.js module
29
4
  import path from 'path';
30
- /**
31
- * Represents the base Matterbridge platform.
32
- *
33
- */
34
5
  export class MatterbridgePlatform {
35
6
  matterbridge;
36
7
  log;
37
8
  config = {};
38
- name = ''; // Will be set by the loadPlugin() method using the package.json value.
39
- type = ''; // Will be set by the extending classes.
40
- version = ''; // Will be set by the loadPlugin() method using the package.json value.
9
+ name = '';
10
+ type = '';
11
+ version = '1.0.0';
41
12
  storage;
42
13
  context;
43
14
  selectDevice = new Map();
44
15
  selectEntity = new Map();
45
16
  registeredEndpoints = new Map();
46
- /**
47
- * Creates an instance of the base MatterbridgePlatform.
48
- * @param {Matterbridge} matterbridge - The Matterbridge instance.
49
- * @param {AnsiLogger} log - The logger instance.
50
- * @param {PlatformConfig} config - The platform configuration.
51
- */
52
17
  constructor(matterbridge, log, config) {
53
18
  this.matterbridge = matterbridge;
54
19
  this.log = log;
55
20
  this.config = config;
56
- // create the NodeStorageManager for the plugin platform
57
21
  if (!isValidString(this.config.name))
58
22
  return;
59
23
  this.log.debug(`Creating storage for plugin ${this.config.name} in ${path.join(this.matterbridge.matterbridgeDirectory, this.config.name)}`);
@@ -65,74 +29,36 @@ export class MatterbridgePlatform {
65
29
  forgiveParseErrors: true,
66
30
  });
67
31
  }
68
- /**
69
- * This method must be overridden in the extended class.
70
- * It is called when the platform is started.
71
- * Use this method to create the MatterbridgeDevice and call this.registerDevice().
72
- * @param {string} [reason] - The reason for starting.
73
- * @throws {Error} - Throws an error if the method is not overridden.
74
- */
75
32
  async onStart(reason) {
76
33
  this.log.error('Plugins must override onStart.', reason);
77
34
  throw new Error('Plugins must override onStart.');
78
35
  }
79
- /**
80
- * This method can be overridden in the extended class.
81
- * It is called after the platform has been commissioned.
82
- * Use this method to perform any configuration of your devices.
83
- */
84
36
  async onConfigure() {
85
37
  this.log.debug(`Configuring platform ${this.name}`);
86
38
  await this.checkEndpointNumbers();
87
39
  }
88
- /**
89
- * This method can be overridden in the extended class.
90
- * It is called when the platform is shutting down.
91
- * Use this method to clean up any resources.
92
- * @param {string} [reason] - The reason for shutting down.
93
- */
94
40
  async onShutdown(reason) {
95
41
  this.log.debug(`Shutting down platform ${this.name}`, reason);
96
42
  await this.checkEndpointNumbers();
97
43
  }
98
- /**
99
- * Sets the logger level and logs a debug message indicating that the plugin doesn't override this method.
100
- * @param {LogLevel} logLevel The new logger level.
101
- */
102
44
  async onChangeLoggerLevel(logLevel) {
103
45
  this.log.debug(`The plugin doesn't override onChangeLoggerLevel. Logger level set to: ${logLevel}`);
104
46
  }
105
- /**
106
- * Registers a device with the Matterbridge platform.
107
- * @param {MatterbridgeEndpoint} device - The device to register.
108
- */
109
47
  async registerDevice(device) {
110
48
  device.plugin = this.name;
111
49
  await this.matterbridge.addBridgedEndpoint(this.name, device);
112
50
  if (device.uniqueId)
113
51
  this.registeredEndpoints.set(device.uniqueId, device);
114
52
  }
115
- /**
116
- * Unregisters a device registered with the Matterbridge platform.
117
- * @param {MatterbridgeEndpoint} device - The device to unregister.
118
- */
119
53
  async unregisterDevice(device) {
120
54
  await this.matterbridge.removeBridgedEndpoint(this.name, device);
121
55
  if (device.uniqueId)
122
56
  this.registeredEndpoints.delete(device.uniqueId);
123
57
  }
124
- /**
125
- * Unregisters all devices registered with the Matterbridge platform.
126
- */
127
58
  async unregisterAllDevices() {
128
59
  await this.matterbridge.removeAllBridgedEndpoints(this.name);
129
60
  this.registeredEndpoints.clear();
130
61
  }
131
- /**
132
- * Verifies if the Matterbridge version meets the required version.
133
- * @param {string} requiredVersion - The required version to compare against.
134
- * @returns {boolean} True if the Matterbridge version meets or exceeds the required version, false otherwise.
135
- */
136
62
  verifyMatterbridgeVersion(requiredVersion) {
137
63
  const compareVersions = (matterbridgeVersion, requiredVersion) => {
138
64
  const stripTag = (v) => {
@@ -157,27 +83,9 @@ export class MatterbridgePlatform {
157
83
  return false;
158
84
  return true;
159
85
  }
160
- /**
161
- * Validates if a device is allowed based on the whitelist and blacklist configurations.
162
- * The blacklist has priority over the whitelist.
163
- *
164
- * @param {string | string[]} device - The device name(s) to validate.
165
- * @param {boolean} [log=true] - Whether to log the validation result.
166
- * @returns {boolean} - Returns true if the device is allowed, false otherwise.
167
- */
168
86
  validateDevice(device, log = true) {
169
87
  return this.validateDeviceWhiteBlackList(device, log);
170
88
  }
171
- /**
172
- * Validates if a device is allowed based on the whitelist and blacklist configurations.
173
- * The blacklist has priority over the whitelist.
174
- *
175
- * @param {string | string[]} device - The device name(s) to validate.
176
- * @param {boolean} [log=true] - Whether to log the validation result.
177
- * @returns {boolean} - Returns true if the device is allowed, false otherwise.
178
- *
179
- * @deprecated This method is deprecated and will be removed in future versions. Use validateDevice instead.
180
- */
181
89
  validateDeviceWhiteBlackList(device, log = true) {
182
90
  if (!Array.isArray(device))
183
91
  device = [device];
@@ -207,27 +115,9 @@ export class MatterbridgePlatform {
207
115
  this.log.info(`Skipping device ${CYAN}${device.join(', ')}${nf} because not in whitelist`);
208
116
  return false;
209
117
  }
210
- /**
211
- * Validates if an entity is allowed based on the entity whitelist and blacklist and the device-entity blacklist configurations.
212
- *
213
- * @param {string} device - The device to which the entity belongs.
214
- * @param {string} entity - The entity to validate.
215
- * @param {boolean} [log=true] - Whether to log the validation result.
216
- * @returns {boolean} - Returns true if the entity is allowed, false otherwise.
217
- */
218
118
  validateEntity(device, entity, log = true) {
219
119
  return this.validateEntityBlackList(device, entity, log);
220
120
  }
221
- /**
222
- * Validates if an entity is allowed based on the entity blacklist and device-entity blacklist configurations.
223
- *
224
- * @param {string} device - The device to which the entity belongs.
225
- * @param {string} entity - The entity to validate.
226
- * @param {boolean} [log=true] - Whether to log the validation result.
227
- * @returns {boolean} - Returns true if the entity is allowed, false otherwise.
228
- *
229
- * @deprecated This method is deprecated and will be removed in future versions. Use validateEntity instead.
230
- */
231
121
  validateEntityBlackList(device, entity, log = true) {
232
122
  if (isValidArray(this.config.entityBlackList, 1) && this.config.entityBlackList.find((e) => e === entity)) {
233
123
  if (log)
@@ -246,15 +136,6 @@ export class MatterbridgePlatform {
246
136
  }
247
137
  return true;
248
138
  }
249
- /**
250
- * Checks and updates the endpoint numbers for Matterbridge devices.
251
- *
252
- * This method retrieves the list of Matterbridge devices and their child endpoints,
253
- * compares their current endpoint numbers with the stored ones, and updates the storage
254
- * if there are any changes. It logs the changes and updates the endpoint numbers accordingly.
255
- *
256
- * @returns {Promise<number>} The size of the updated endpoint map, or -1 if storage is not available.
257
- */
258
139
  async checkEndpointNumbers() {
259
140
  if (!this.storage)
260
141
  return -1;
@@ -294,4 +175,3 @@ export class MatterbridgePlatform {
294
175
  return endpointMap.size;
295
176
  }
296
177
  }
297
- //# sourceMappingURL=matterbridgePlatform.js.map
@@ -1,31 +1,3 @@
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
- import { MatterbridgeEndpoint } from './matterbridgeEndpoint.js';
24
- // Default colors
25
1
  export const plg = '\u001B[38;5;33m';
26
2
  export const dev = '\u001B[38;5;79m';
27
3
  export const typ = '\u001B[38;5;207m';
28
- // Define an alias for MatterbridgeEndpoint by extending it
29
- export class MatterbridgeDevice extends MatterbridgeEndpoint {
30
- }
31
- //# sourceMappingURL=matterbridgeTypes.js.map