matterbridge 3.4.0 → 3.4.1-dev-20251126-9e86094

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 (322) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/broadcastServer.js +1 -93
  3. package/dist/broadcastServerTypes.js +0 -24
  4. package/dist/cli.js +1 -97
  5. package/dist/cliEmitter.js +0 -37
  6. package/dist/cliHistory.js +0 -38
  7. package/dist/clusters/export.js +0 -2
  8. package/dist/defaultConfigSchema.js +0 -24
  9. package/dist/deviceManager.js +1 -113
  10. package/dist/devices/airConditioner.js +0 -57
  11. package/dist/devices/batteryStorage.js +1 -48
  12. package/dist/devices/cooktop.js +0 -56
  13. package/dist/devices/dishwasher.js +0 -57
  14. package/dist/devices/evse.js +10 -74
  15. package/dist/devices/export.js +0 -5
  16. package/dist/devices/extractorHood.js +0 -43
  17. package/dist/devices/heatPump.js +2 -50
  18. package/dist/devices/laundryDryer.js +3 -62
  19. package/dist/devices/laundryWasher.js +4 -70
  20. package/dist/devices/microwaveOven.js +5 -88
  21. package/dist/devices/oven.js +0 -85
  22. package/dist/devices/refrigerator.js +0 -102
  23. package/dist/devices/roboticVacuumCleaner.js +9 -100
  24. package/dist/devices/solarPower.js +0 -38
  25. package/dist/devices/speaker.js +0 -84
  26. package/dist/devices/temperatureControl.js +3 -24
  27. package/dist/devices/waterHeater.js +2 -82
  28. package/dist/dgram/coap.js +13 -126
  29. package/dist/dgram/dgram.js +2 -114
  30. package/dist/dgram/mb_coap.js +3 -41
  31. package/dist/dgram/mb_mdns.js +15 -80
  32. package/dist/dgram/mdns.js +137 -299
  33. package/dist/dgram/multicast.js +1 -62
  34. package/dist/dgram/unicast.js +0 -54
  35. package/dist/frontend.js +35 -455
  36. package/dist/frontendTypes.js +0 -45
  37. package/dist/helpers.js +0 -53
  38. package/dist/index.js +0 -25
  39. package/dist/jestutils/export.js +0 -1
  40. package/dist/jestutils/jestHelpers.js +13 -352
  41. package/dist/logger/export.js +0 -1
  42. package/dist/matter/behaviors.js +0 -2
  43. package/dist/matter/clusters.js +0 -2
  44. package/dist/matter/devices.js +0 -2
  45. package/dist/matter/endpoints.js +0 -2
  46. package/dist/matter/export.js +0 -3
  47. package/dist/matter/types.js +0 -3
  48. package/dist/matterNode.js +8 -369
  49. package/dist/matterbridge.js +46 -787
  50. package/dist/matterbridgeAccessoryPlatform.js +0 -38
  51. package/dist/matterbridgeBehaviors.js +5 -68
  52. package/dist/matterbridgeDeviceTypes.js +14 -635
  53. package/dist/matterbridgeDynamicPlatform.js +0 -38
  54. package/dist/matterbridgeEndpoint.js +53 -1444
  55. package/dist/matterbridgeEndpointHelpers.js +20 -483
  56. package/dist/matterbridgeEndpointTypes.js +0 -25
  57. package/dist/matterbridgePlatform.js +1 -439
  58. package/dist/matterbridgeTypes.js +0 -26
  59. package/dist/pluginManager.js +5 -340
  60. package/dist/shelly.js +7 -168
  61. package/dist/storage/export.js +0 -1
  62. package/dist/update.js +0 -69
  63. package/dist/utils/colorUtils.js +2 -97
  64. package/dist/utils/commandLine.js +0 -60
  65. package/dist/utils/copyDirectory.js +0 -37
  66. package/dist/utils/createDirectory.js +0 -33
  67. package/dist/utils/createZip.js +2 -47
  68. package/dist/utils/deepCopy.js +0 -39
  69. package/dist/utils/deepEqual.js +1 -72
  70. package/dist/utils/error.js +0 -41
  71. package/dist/utils/export.js +0 -1
  72. package/dist/utils/format.js +0 -49
  73. package/dist/utils/hex.js +0 -124
  74. package/dist/utils/inspector.js +1 -69
  75. package/dist/utils/isvalid.js +0 -101
  76. package/dist/utils/network.js +5 -96
  77. package/dist/utils/spawn.js +1 -71
  78. package/dist/utils/tracker.js +1 -64
  79. package/dist/utils/wait.js +8 -60
  80. package/frontend/build/assets/index.js +4 -4
  81. package/frontend/build/assets/vendor_mui.js +1 -1
  82. package/frontend/build/assets/vendor_node_modules.js +19 -83
  83. package/frontend/build/assets/vendor_qrcode.js +1 -9
  84. package/frontend/build/assets/vendor_rjsf.js +1 -9
  85. package/frontend/package-lock.json +229 -439
  86. package/frontend/package.json +15 -15
  87. package/npm-shrinkwrap.json +165 -231
  88. package/package.json +2 -3
  89. package/dist/broadcastServer.d.ts +0 -115
  90. package/dist/broadcastServer.d.ts.map +0 -1
  91. package/dist/broadcastServer.js.map +0 -1
  92. package/dist/broadcastServerTypes.d.ts +0 -838
  93. package/dist/broadcastServerTypes.d.ts.map +0 -1
  94. package/dist/broadcastServerTypes.js.map +0 -1
  95. package/dist/cli.d.ts +0 -30
  96. package/dist/cli.d.ts.map +0 -1
  97. package/dist/cli.js.map +0 -1
  98. package/dist/cliEmitter.d.ts +0 -50
  99. package/dist/cliEmitter.d.ts.map +0 -1
  100. package/dist/cliEmitter.js.map +0 -1
  101. package/dist/cliHistory.d.ts +0 -48
  102. package/dist/cliHistory.d.ts.map +0 -1
  103. package/dist/cliHistory.js.map +0 -1
  104. package/dist/clusters/export.d.ts +0 -2
  105. package/dist/clusters/export.d.ts.map +0 -1
  106. package/dist/clusters/export.js.map +0 -1
  107. package/dist/defaultConfigSchema.d.ts +0 -28
  108. package/dist/defaultConfigSchema.d.ts.map +0 -1
  109. package/dist/defaultConfigSchema.js.map +0 -1
  110. package/dist/deviceManager.d.ts +0 -135
  111. package/dist/deviceManager.d.ts.map +0 -1
  112. package/dist/deviceManager.js.map +0 -1
  113. package/dist/devices/airConditioner.d.ts +0 -98
  114. package/dist/devices/airConditioner.d.ts.map +0 -1
  115. package/dist/devices/airConditioner.js.map +0 -1
  116. package/dist/devices/batteryStorage.d.ts +0 -48
  117. package/dist/devices/batteryStorage.d.ts.map +0 -1
  118. package/dist/devices/batteryStorage.js.map +0 -1
  119. package/dist/devices/cooktop.d.ts +0 -61
  120. package/dist/devices/cooktop.d.ts.map +0 -1
  121. package/dist/devices/cooktop.js.map +0 -1
  122. package/dist/devices/dishwasher.d.ts +0 -71
  123. package/dist/devices/dishwasher.d.ts.map +0 -1
  124. package/dist/devices/dishwasher.js.map +0 -1
  125. package/dist/devices/evse.d.ts +0 -76
  126. package/dist/devices/evse.d.ts.map +0 -1
  127. package/dist/devices/evse.js.map +0 -1
  128. package/dist/devices/export.d.ts +0 -17
  129. package/dist/devices/export.d.ts.map +0 -1
  130. package/dist/devices/export.js.map +0 -1
  131. package/dist/devices/extractorHood.d.ts +0 -46
  132. package/dist/devices/extractorHood.d.ts.map +0 -1
  133. package/dist/devices/extractorHood.js.map +0 -1
  134. package/dist/devices/heatPump.d.ts +0 -47
  135. package/dist/devices/heatPump.d.ts.map +0 -1
  136. package/dist/devices/heatPump.js.map +0 -1
  137. package/dist/devices/laundryDryer.d.ts +0 -67
  138. package/dist/devices/laundryDryer.d.ts.map +0 -1
  139. package/dist/devices/laundryDryer.js.map +0 -1
  140. package/dist/devices/laundryWasher.d.ts +0 -81
  141. package/dist/devices/laundryWasher.d.ts.map +0 -1
  142. package/dist/devices/laundryWasher.js.map +0 -1
  143. package/dist/devices/microwaveOven.d.ts +0 -168
  144. package/dist/devices/microwaveOven.d.ts.map +0 -1
  145. package/dist/devices/microwaveOven.js.map +0 -1
  146. package/dist/devices/oven.d.ts +0 -105
  147. package/dist/devices/oven.d.ts.map +0 -1
  148. package/dist/devices/oven.js.map +0 -1
  149. package/dist/devices/refrigerator.d.ts +0 -118
  150. package/dist/devices/refrigerator.d.ts.map +0 -1
  151. package/dist/devices/refrigerator.js.map +0 -1
  152. package/dist/devices/roboticVacuumCleaner.d.ts +0 -112
  153. package/dist/devices/roboticVacuumCleaner.d.ts.map +0 -1
  154. package/dist/devices/roboticVacuumCleaner.js.map +0 -1
  155. package/dist/devices/solarPower.d.ts +0 -40
  156. package/dist/devices/solarPower.d.ts.map +0 -1
  157. package/dist/devices/solarPower.js.map +0 -1
  158. package/dist/devices/speaker.d.ts +0 -87
  159. package/dist/devices/speaker.d.ts.map +0 -1
  160. package/dist/devices/speaker.js.map +0 -1
  161. package/dist/devices/temperatureControl.d.ts +0 -166
  162. package/dist/devices/temperatureControl.d.ts.map +0 -1
  163. package/dist/devices/temperatureControl.js.map +0 -1
  164. package/dist/devices/waterHeater.d.ts +0 -111
  165. package/dist/devices/waterHeater.d.ts.map +0 -1
  166. package/dist/devices/waterHeater.js.map +0 -1
  167. package/dist/dgram/coap.d.ts +0 -205
  168. package/dist/dgram/coap.d.ts.map +0 -1
  169. package/dist/dgram/coap.js.map +0 -1
  170. package/dist/dgram/dgram.d.ts +0 -141
  171. package/dist/dgram/dgram.d.ts.map +0 -1
  172. package/dist/dgram/dgram.js.map +0 -1
  173. package/dist/dgram/mb_coap.d.ts +0 -24
  174. package/dist/dgram/mb_coap.d.ts.map +0 -1
  175. package/dist/dgram/mb_coap.js.map +0 -1
  176. package/dist/dgram/mb_mdns.d.ts +0 -24
  177. package/dist/dgram/mb_mdns.d.ts.map +0 -1
  178. package/dist/dgram/mb_mdns.js.map +0 -1
  179. package/dist/dgram/mdns.d.ts +0 -290
  180. package/dist/dgram/mdns.d.ts.map +0 -1
  181. package/dist/dgram/mdns.js.map +0 -1
  182. package/dist/dgram/multicast.d.ts +0 -67
  183. package/dist/dgram/multicast.d.ts.map +0 -1
  184. package/dist/dgram/multicast.js.map +0 -1
  185. package/dist/dgram/unicast.d.ts +0 -56
  186. package/dist/dgram/unicast.d.ts.map +0 -1
  187. package/dist/dgram/unicast.js.map +0 -1
  188. package/dist/frontend.d.ts +0 -238
  189. package/dist/frontend.d.ts.map +0 -1
  190. package/dist/frontend.js.map +0 -1
  191. package/dist/frontendTypes.d.ts +0 -529
  192. package/dist/frontendTypes.d.ts.map +0 -1
  193. package/dist/frontendTypes.js.map +0 -1
  194. package/dist/helpers.d.ts +0 -48
  195. package/dist/helpers.d.ts.map +0 -1
  196. package/dist/helpers.js.map +0 -1
  197. package/dist/index.d.ts +0 -34
  198. package/dist/index.d.ts.map +0 -1
  199. package/dist/index.js.map +0 -1
  200. package/dist/jestutils/export.d.ts +0 -2
  201. package/dist/jestutils/export.d.ts.map +0 -1
  202. package/dist/jestutils/export.js.map +0 -1
  203. package/dist/jestutils/jestHelpers.d.ts +0 -303
  204. package/dist/jestutils/jestHelpers.d.ts.map +0 -1
  205. package/dist/jestutils/jestHelpers.js.map +0 -1
  206. package/dist/logger/export.d.ts +0 -2
  207. package/dist/logger/export.d.ts.map +0 -1
  208. package/dist/logger/export.js.map +0 -1
  209. package/dist/matter/behaviors.d.ts +0 -2
  210. package/dist/matter/behaviors.d.ts.map +0 -1
  211. package/dist/matter/behaviors.js.map +0 -1
  212. package/dist/matter/clusters.d.ts +0 -2
  213. package/dist/matter/clusters.d.ts.map +0 -1
  214. package/dist/matter/clusters.js.map +0 -1
  215. package/dist/matter/devices.d.ts +0 -2
  216. package/dist/matter/devices.d.ts.map +0 -1
  217. package/dist/matter/devices.js.map +0 -1
  218. package/dist/matter/endpoints.d.ts +0 -2
  219. package/dist/matter/endpoints.d.ts.map +0 -1
  220. package/dist/matter/endpoints.js.map +0 -1
  221. package/dist/matter/export.d.ts +0 -5
  222. package/dist/matter/export.d.ts.map +0 -1
  223. package/dist/matter/export.js.map +0 -1
  224. package/dist/matter/types.d.ts +0 -3
  225. package/dist/matter/types.d.ts.map +0 -1
  226. package/dist/matter/types.js.map +0 -1
  227. package/dist/matterNode.d.ts +0 -342
  228. package/dist/matterNode.d.ts.map +0 -1
  229. package/dist/matterNode.js.map +0 -1
  230. package/dist/matterbridge.d.ts +0 -473
  231. package/dist/matterbridge.d.ts.map +0 -1
  232. package/dist/matterbridge.js.map +0 -1
  233. package/dist/matterbridgeAccessoryPlatform.d.ts +0 -41
  234. package/dist/matterbridgeAccessoryPlatform.d.ts.map +0 -1
  235. package/dist/matterbridgeAccessoryPlatform.js.map +0 -1
  236. package/dist/matterbridgeBehaviors.d.ts +0 -2404
  237. package/dist/matterbridgeBehaviors.d.ts.map +0 -1
  238. package/dist/matterbridgeBehaviors.js.map +0 -1
  239. package/dist/matterbridgeDeviceTypes.d.ts +0 -698
  240. package/dist/matterbridgeDeviceTypes.d.ts.map +0 -1
  241. package/dist/matterbridgeDeviceTypes.js.map +0 -1
  242. package/dist/matterbridgeDynamicPlatform.d.ts +0 -41
  243. package/dist/matterbridgeDynamicPlatform.d.ts.map +0 -1
  244. package/dist/matterbridgeDynamicPlatform.js.map +0 -1
  245. package/dist/matterbridgeEndpoint.d.ts +0 -1507
  246. package/dist/matterbridgeEndpoint.d.ts.map +0 -1
  247. package/dist/matterbridgeEndpoint.js.map +0 -1
  248. package/dist/matterbridgeEndpointHelpers.d.ts +0 -787
  249. package/dist/matterbridgeEndpointHelpers.d.ts.map +0 -1
  250. package/dist/matterbridgeEndpointHelpers.js.map +0 -1
  251. package/dist/matterbridgeEndpointTypes.d.ts +0 -166
  252. package/dist/matterbridgeEndpointTypes.d.ts.map +0 -1
  253. package/dist/matterbridgeEndpointTypes.js.map +0 -1
  254. package/dist/matterbridgePlatform.d.ts +0 -524
  255. package/dist/matterbridgePlatform.d.ts.map +0 -1
  256. package/dist/matterbridgePlatform.js.map +0 -1
  257. package/dist/matterbridgeTypes.d.ts +0 -251
  258. package/dist/matterbridgeTypes.d.ts.map +0 -1
  259. package/dist/matterbridgeTypes.js.map +0 -1
  260. package/dist/pluginManager.d.ts +0 -371
  261. package/dist/pluginManager.d.ts.map +0 -1
  262. package/dist/pluginManager.js.map +0 -1
  263. package/dist/shelly.d.ts +0 -174
  264. package/dist/shelly.d.ts.map +0 -1
  265. package/dist/shelly.js.map +0 -1
  266. package/dist/storage/export.d.ts +0 -2
  267. package/dist/storage/export.d.ts.map +0 -1
  268. package/dist/storage/export.js.map +0 -1
  269. package/dist/update.d.ts +0 -75
  270. package/dist/update.d.ts.map +0 -1
  271. package/dist/update.js.map +0 -1
  272. package/dist/utils/colorUtils.d.ts +0 -101
  273. package/dist/utils/colorUtils.d.ts.map +0 -1
  274. package/dist/utils/colorUtils.js.map +0 -1
  275. package/dist/utils/commandLine.d.ts +0 -66
  276. package/dist/utils/commandLine.d.ts.map +0 -1
  277. package/dist/utils/commandLine.js.map +0 -1
  278. package/dist/utils/copyDirectory.d.ts +0 -35
  279. package/dist/utils/copyDirectory.d.ts.map +0 -1
  280. package/dist/utils/copyDirectory.js.map +0 -1
  281. package/dist/utils/createDirectory.d.ts +0 -34
  282. package/dist/utils/createDirectory.d.ts.map +0 -1
  283. package/dist/utils/createDirectory.js.map +0 -1
  284. package/dist/utils/createZip.d.ts +0 -39
  285. package/dist/utils/createZip.d.ts.map +0 -1
  286. package/dist/utils/createZip.js.map +0 -1
  287. package/dist/utils/deepCopy.d.ts +0 -32
  288. package/dist/utils/deepCopy.d.ts.map +0 -1
  289. package/dist/utils/deepCopy.js.map +0 -1
  290. package/dist/utils/deepEqual.d.ts +0 -54
  291. package/dist/utils/deepEqual.d.ts.map +0 -1
  292. package/dist/utils/deepEqual.js.map +0 -1
  293. package/dist/utils/error.d.ts +0 -44
  294. package/dist/utils/error.d.ts.map +0 -1
  295. package/dist/utils/error.js.map +0 -1
  296. package/dist/utils/export.d.ts +0 -13
  297. package/dist/utils/export.d.ts.map +0 -1
  298. package/dist/utils/export.js.map +0 -1
  299. package/dist/utils/format.d.ts +0 -53
  300. package/dist/utils/format.d.ts.map +0 -1
  301. package/dist/utils/format.js.map +0 -1
  302. package/dist/utils/hex.d.ts +0 -89
  303. package/dist/utils/hex.d.ts.map +0 -1
  304. package/dist/utils/hex.js.map +0 -1
  305. package/dist/utils/inspector.d.ts +0 -87
  306. package/dist/utils/inspector.d.ts.map +0 -1
  307. package/dist/utils/inspector.js.map +0 -1
  308. package/dist/utils/isvalid.d.ts +0 -103
  309. package/dist/utils/isvalid.d.ts.map +0 -1
  310. package/dist/utils/isvalid.js.map +0 -1
  311. package/dist/utils/network.d.ts +0 -111
  312. package/dist/utils/network.d.ts.map +0 -1
  313. package/dist/utils/network.js.map +0 -1
  314. package/dist/utils/spawn.d.ts +0 -33
  315. package/dist/utils/spawn.d.ts.map +0 -1
  316. package/dist/utils/spawn.js.map +0 -1
  317. package/dist/utils/tracker.d.ts +0 -108
  318. package/dist/utils/tracker.d.ts.map +0 -1
  319. package/dist/utils/tracker.js.map +0 -1
  320. package/dist/utils/wait.d.ts +0 -54
  321. package/dist/utils/wait.d.ts.map +0 -1
  322. package/dist/utils/wait.js.map +0 -1
@@ -1,37 +1,9 @@
1
- /**
2
- * This file contains the Plugins class.
3
- *
4
- * @file plugins.ts
5
- * @author Luca Liguori
6
- * @created 2024-07-14
7
- * @version 1.3.1
8
- * @license Apache-2.0
9
- *
10
- * Copyright 2024, 2025, 2026 Luca Liguori.
11
- *
12
- * Licensed under the Apache License, Version 2.0 (the "License");
13
- * you may not use this file except in compliance with the License.
14
- * You may obtain a copy of the License at
15
- *
16
- * http://www.apache.org/licenses/LICENSE-2.0
17
- *
18
- * Unless required by applicable law or agreed to in writing, software
19
- * distributed under the License is distributed on an "AS IS" BASIS,
20
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
- * See the License for the specific language governing permissions and
22
- * limitations under the License.
23
- */
24
- // Node.js import
25
1
  import EventEmitter from 'node:events';
26
- // AnsiLogger module
27
2
  import { AnsiLogger, UNDERLINE, UNDERLINEOFF, BLUE, db, er, nf, nt, rs, wr, debugStringify, CYAN } from 'node-ansi-logger';
28
3
  import { plg, typ } from './matterbridgeTypes.js';
29
4
  import { inspectError, logError } from './utils/error.js';
30
5
  import { hasParameter } from './utils/commandLine.js';
31
6
  import { BroadcastServer } from './broadcastServer.js';
32
- /**
33
- * Manages Matterbridge plugins.
34
- */
35
7
  export class PluginManager extends EventEmitter {
36
8
  matterbridge;
37
9
  _plugins = new Map();
@@ -39,15 +11,10 @@ export class PluginManager extends EventEmitter {
39
11
  server;
40
12
  debug = hasParameter('debug') || hasParameter('verbose');
41
13
  verbose = hasParameter('verbose');
42
- /**
43
- * Creates an instance of PluginManager.
44
- *
45
- * @param {Matterbridge} matterbridge - The Matterbridge instance.
46
- */
47
14
  constructor(matterbridge) {
48
15
  super();
49
16
  this.matterbridge = matterbridge;
50
- this.log = new AnsiLogger({ logName: 'PluginManager', logTimestampFormat: 4 /* TimestampFormat.TIME_MILLIS */, logLevel: hasParameter('debug') ? "debug" /* LogLevel.DEBUG */ : "info" /* LogLevel.INFO */ });
17
+ this.log = new AnsiLogger({ logName: 'PluginManager', logTimestampFormat: 4, logLevel: hasParameter('debug') ? "debug" : "info" });
51
18
  this.log.debug('Matterbridge plugin manager starting...');
52
19
  this.server = new BroadcastServer('plugins', this.log);
53
20
  this.server.on('broadcast_message', this.msgHandler.bind(this));
@@ -219,7 +186,7 @@ export class PluginManager extends EventEmitter {
219
186
  {
220
187
  const plugin = this.get(msg.params.name);
221
188
  if (plugin) {
222
- this.saveConfigFromJson(plugin, msg.params.config, msg.params.restartRequired); // No await as it's not necessary to wait
189
+ this.saveConfigFromJson(plugin, msg.params.config, msg.params.restartRequired);
223
190
  this.server.respond({ ...msg, response: { success: true } });
224
191
  }
225
192
  else {
@@ -233,62 +200,25 @@ export class PluginManager extends EventEmitter {
233
200
  }
234
201
  }
235
202
  }
236
- /**
237
- * Gets the number of plugins.
238
- *
239
- * @returns {number} The number of plugins.
240
- */
241
203
  get length() {
242
204
  return this._plugins.size;
243
205
  }
244
- /**
245
- * Gets the number of plugins.
246
- *
247
- * @returns {number} The number of plugins.
248
- */
249
206
  get size() {
250
207
  return this._plugins.size;
251
208
  }
252
- /**
253
- * Checks if a plugin with the specified name exists.
254
- *
255
- * @param {string} name - The name of the plugin.
256
- * @returns {boolean} True if the plugin exists, false otherwise.
257
- */
258
209
  has(name) {
259
210
  return this._plugins.has(name);
260
211
  }
261
- /**
262
- * Gets a plugin by its name.
263
- *
264
- * @param {string} name - The name of the plugin.
265
- * @returns {Plugin | undefined} The plugin, or undefined if not found.
266
- */
267
212
  get(name) {
268
213
  return this._plugins.get(name);
269
214
  }
270
- /**
271
- * Adds a plugin to the manager.
272
- *
273
- * @param {Plugin} plugin - The plugin to add.
274
- * @returns {Plugin} The added plugin.
275
- */
276
215
  set(plugin) {
277
216
  this._plugins.set(plugin.name, plugin);
278
217
  return plugin;
279
218
  }
280
- /**
281
- * Clears all plugins from the manager.
282
- */
283
219
  clear() {
284
220
  this._plugins.clear();
285
221
  }
286
- /**
287
- * Converts a plugin or API plugin to a storage plugin.
288
- *
289
- * @param {Plugin | ApiPlugin} plugin - The plugin or API plugin to convert.
290
- * @returns {StoragePlugin} The converted storage plugin.
291
- */
292
222
  toStoragePlugin(plugin) {
293
223
  return {
294
224
  name: plugin.name,
@@ -300,12 +230,6 @@ export class PluginManager extends EventEmitter {
300
230
  enabled: plugin.enabled,
301
231
  };
302
232
  }
303
- /**
304
- * Converts a plugin to an API plugin.
305
- *
306
- * @param {Plugin} plugin - The plugin to convert.
307
- * @returns {ApiPlugin} The converted API plugin.
308
- */
309
233
  toApiPlugin(plugin) {
310
234
  return {
311
235
  name: plugin.name,
@@ -335,19 +259,9 @@ export class PluginManager extends EventEmitter {
335
259
  matter: plugin.serverNode ? this.matterbridge.getServerNodeData(plugin.serverNode) : undefined,
336
260
  };
337
261
  }
338
- /**
339
- * Gets an array of all plugins.
340
- *
341
- * @returns {Plugin[]} An array of all plugins.
342
- */
343
262
  array() {
344
263
  return Array.from(this._plugins.values());
345
264
  }
346
- /**
347
- * Gets a StoragePlugin array of all plugins suitable for serialization.
348
- *
349
- * @returns {StoragePlugin[]} An array of all plugins.
350
- */
351
265
  storagePluginArray() {
352
266
  const storagePlugins = [];
353
267
  for (const plugin of this._plugins.values()) {
@@ -355,11 +269,6 @@ export class PluginManager extends EventEmitter {
355
269
  }
356
270
  return storagePlugins;
357
271
  }
358
- /**
359
- * Gets an ApiPlugin array of all plugins suitable for serialization.
360
- *
361
- * @returns {ApiPlugin[]} An array of all plugins.
362
- */
363
272
  apiPluginArray() {
364
273
  const apiPlugins = [];
365
274
  for (const plugin of this._plugins.values()) {
@@ -367,20 +276,9 @@ export class PluginManager extends EventEmitter {
367
276
  }
368
277
  return apiPlugins;
369
278
  }
370
- /**
371
- * Gets an iterator for the plugins.
372
- *
373
- * @returns {IterableIterator<Plugin>} An iterator for the plugins.
374
- */
375
279
  [Symbol.iterator]() {
376
280
  return this._plugins.values();
377
281
  }
378
- /**
379
- * Executes a provided function once for each plugin.
380
- *
381
- * @param {Function} callback - The function to execute for each plugin.
382
- * @returns {Promise<void>}
383
- */
384
282
  async forEach(callback) {
385
283
  if (this.size === 0)
386
284
  return;
@@ -394,40 +292,23 @@ export class PluginManager extends EventEmitter {
394
292
  });
395
293
  await Promise.all(tasks);
396
294
  }
397
- /**
398
- * Sets the log level for the plugin manager.
399
- *
400
- * @param {LogLevel} logLevel - The log level to set.
401
- */
402
295
  set logLevel(logLevel) {
403
296
  this.log.logLevel = logLevel;
404
297
  }
405
- /**
406
- * Loads registered plugins from storage.
407
- *
408
- * @returns {Promise<StoragePlugin[]>} A promise that resolves to an array of registered plugins.
409
- */
410
298
  async loadFromStorage() {
411
299
  if (!this.matterbridge.nodeContext) {
412
300
  throw new Error('loadFromStorage: node context is not available.');
413
301
  }
414
- // Load the array from storage and convert it to a map
415
302
  const pluginsArray = await this.matterbridge.nodeContext.get('plugins', []);
416
303
  for (const plugin of pluginsArray)
417
304
  this._plugins.set(plugin.name, plugin);
418
305
  this.log.debug(`Loaded ${BLUE}${pluginsArray.length}${db} plugins from storage`);
419
306
  return pluginsArray;
420
307
  }
421
- /**
422
- * Saves registered plugins to storage.
423
- *
424
- * @returns {Promise<number>} A promise that resolves to the number of registered plugins.
425
- */
426
308
  async saveToStorage() {
427
309
  if (!this.matterbridge.nodeContext) {
428
310
  throw new Error('loadFromStorage: node context is not available.');
429
311
  }
430
- // Convert the map to an array
431
312
  const plugins = [];
432
313
  for (const plugin of this.array()) {
433
314
  plugins.push({
@@ -444,21 +325,13 @@ export class PluginManager extends EventEmitter {
444
325
  this.log.debug(`Saved ${BLUE}${plugins.length}${db} plugins to storage`);
445
326
  return plugins.length;
446
327
  }
447
- /**
448
- * Resolves the name of a plugin by loading and parsing its package.json file.
449
- *
450
- * @param {string} nameOrPath - The name of the plugin or the path to the plugin's package.json file.
451
- * @returns {Promise<string | null>} A promise that resolves to the path of the plugin's package.json file or null if it could not be resolved.
452
- */
453
328
  async resolve(nameOrPath) {
454
329
  const { default: path } = await import('node:path');
455
330
  const { promises } = await import('node:fs');
456
331
  if (!nameOrPath.endsWith('package.json'))
457
332
  nameOrPath = path.join(nameOrPath, 'package.json');
458
- // Resolve the package.json of the plugin
459
333
  let packageJsonPath = path.resolve(nameOrPath);
460
334
  this.log.debug(`Resolving plugin path ${plg}${packageJsonPath}${db}`);
461
- // Check if the package.json file exists
462
335
  try {
463
336
  await promises.access(packageJsonPath);
464
337
  }
@@ -468,9 +341,7 @@ export class PluginManager extends EventEmitter {
468
341
  this.log.debug(`Trying at ${plg}${packageJsonPath}${db}`);
469
342
  }
470
343
  try {
471
- // Load the package.json of the plugin
472
344
  const packageJson = JSON.parse(await promises.readFile(packageJsonPath, 'utf8'));
473
- // Check for main issues
474
345
  if (!packageJson.name) {
475
346
  this.log.error(`Package.json name not found at ${packageJsonPath}`);
476
347
  return null;
@@ -483,7 +354,6 @@ export class PluginManager extends EventEmitter {
483
354
  this.log.error(`Plugin at ${packageJsonPath} has no main entrypoint in package.json`);
484
355
  return null;
485
356
  }
486
- // Check for @project-chip and @matter packages in dependencies and devDependencies
487
357
  const checkForProjectChipPackages = (dependencies) => {
488
358
  return Object.keys(dependencies).filter((pkg) => pkg.startsWith('@project-chip') || pkg.startsWith('@matter'));
489
359
  };
@@ -505,7 +375,6 @@ export class PluginManager extends EventEmitter {
505
375
  this.log.error(`Please open an issue on the plugin repository to remove them.`);
506
376
  return null;
507
377
  }
508
- // Check for matterbridge package in dependencies and devDependencies
509
378
  const checkForMatterbridgePackage = (dependencies) => {
510
379
  return Object.keys(dependencies).filter((pkg) => pkg === 'matterbridge');
511
380
  };
@@ -535,19 +404,13 @@ export class PluginManager extends EventEmitter {
535
404
  return null;
536
405
  }
537
406
  }
538
- /**
539
- * Installs a package globally using npm.
540
- *
541
- * @param {string} packageName - The name of the package to install.
542
- * @returns {Promise<boolean>} A promise that resolves to true if the installation was successful, false otherwise.
543
- */
544
407
  async install(packageName) {
545
408
  this.log.debug(`Installing plugin ${plg}${packageName}${db}...`);
546
409
  const { spawnCommand } = await import('./utils/spawn.js');
547
410
  if (await spawnCommand('npm', ['install', '-g', packageName, '--omit=dev', '--verbose'], 'install', packageName)) {
548
411
  this.matterbridge.restartRequired = true;
549
412
  this.matterbridge.fixedRestartRequired = true;
550
- packageName = packageName.replace(/@.*$/, ''); // Remove @version if present
413
+ packageName = packageName.replace(/@.*$/, '');
551
414
  if (packageName !== 'matterbridge') {
552
415
  if (!this.has(packageName))
553
416
  await this.add(packageName);
@@ -568,12 +431,6 @@ export class PluginManager extends EventEmitter {
568
431
  return false;
569
432
  }
570
433
  }
571
- /**
572
- * Uninstalls a package globally using npm.
573
- *
574
- * @param {string} packageName - The name of the package to uninstall.
575
- * @returns {Promise<boolean>} A promise that resolves to true if the uninstallation was successful, false otherwise.
576
- */
577
434
  async uninstall(packageName) {
578
435
  this.log.debug(`Uninstalling plugin ${plg}${packageName}${db}...`);
579
436
  const { spawnCommand } = await import('./utils/spawn.js');
@@ -595,12 +452,6 @@ export class PluginManager extends EventEmitter {
595
452
  return false;
596
453
  }
597
454
  }
598
- /**
599
- * Get the author of a plugin from its package.json.
600
- *
601
- * @param {Record<string, string | number | Record<string, string | number | object>>} packageJson - The package.json object of the plugin.
602
- * @returns {string} The author of the plugin, or 'Unknown author' if not found.
603
- */
604
455
  getAuthor(packageJson) {
605
456
  if (packageJson.author && typeof packageJson.author === 'string')
606
457
  return packageJson.author;
@@ -608,12 +459,6 @@ export class PluginManager extends EventEmitter {
608
459
  return packageJson.author.name;
609
460
  return 'Unknown author';
610
461
  }
611
- /**
612
- * Get the homepage of a plugin from its package.json.
613
- *
614
- * @param {Record<string, string | number | Record<string, string | number | object>>} packageJson - The package.json object of the plugin.
615
- * @returns {string | undefined} The homepage of the plugin, or undefined if not found.
616
- */
617
462
  getHomepage(packageJson) {
618
463
  if (packageJson.homepage && typeof packageJson.homepage === 'string' && packageJson.homepage.includes('http')) {
619
464
  return packageJson.homepage.replace('git+', '').replace('.git', '');
@@ -622,14 +467,7 @@ export class PluginManager extends EventEmitter {
622
467
  return packageJson.repository.url.replace('git+', '').replace('.git', '');
623
468
  }
624
469
  }
625
- /**
626
- * Get the help URL of a plugin from its package.json.
627
- *
628
- * @param {Record<string, string | number | Record<string, string | number | object>>} packageJson - The package.json object of the plugin.
629
- * @returns {string | undefined} The URL to the help page or to the README file, or undefined if not found.
630
- */
631
470
  getHelp(packageJson) {
632
- // If there's a help field that looks like a URL, return it.
633
471
  if (packageJson.help && typeof packageJson.help === 'string' && packageJson.help.startsWith('http')) {
634
472
  return packageJson.help;
635
473
  }
@@ -640,14 +478,7 @@ export class PluginManager extends EventEmitter {
640
478
  return packageJson.homepage.replace('git+', '').replace('.git', '');
641
479
  }
642
480
  }
643
- /**
644
- * Get the changelog URL of a plugin from its package.json.
645
- *
646
- * @param {Record<string, string | number | Record<string, string | number | object>>} packageJson - The package.json object of the plugin.
647
- * @returns {string | undefined} The URL to the CHANGELOG file, or undefined if not found.
648
- */
649
481
  getChangelog(packageJson) {
650
- // If there's a changelog field that looks like a URL, return it.
651
482
  if (packageJson.changelog && typeof packageJson.changelog === 'string' && packageJson.changelog.startsWith('http')) {
652
483
  return packageJson.changelog;
653
484
  }
@@ -658,13 +489,6 @@ export class PluginManager extends EventEmitter {
658
489
  return packageJson.homepage.replace('git+', '').replace('.git', '');
659
490
  }
660
491
  }
661
- /**
662
- * Get the first funding URL(s) of a plugin from its package.json.
663
- *
664
- * @param {Record<string, any>} packageJson - The package.json object of the plugin.
665
- * @returns {string | undefined} The first funding URLs, or undefined if not found.
666
- */
667
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
668
492
  getFunding(packageJson) {
669
493
  const funding = packageJson.funding;
670
494
  if (!funding)
@@ -673,27 +497,16 @@ export class PluginManager extends EventEmitter {
673
497
  return;
674
498
  if (typeof funding === 'string' && funding.startsWith('http'))
675
499
  return funding;
676
- // Normalize funding into an array.
677
500
  const fundingEntries = Array.isArray(funding) ? funding : [funding];
678
501
  for (const entry of fundingEntries) {
679
502
  if (entry && typeof entry === 'string' && entry.startsWith('http')) {
680
- // If the funding entry is a string, assume it is a URL.
681
503
  return entry;
682
504
  }
683
505
  else if (entry && typeof entry === 'object' && typeof entry.url === 'string' && entry.url.startsWith('http')) {
684
- // If it's an object with a 'url' property, use that.
685
506
  return entry.url;
686
507
  }
687
508
  }
688
509
  }
689
- /**
690
- * Parses the plugin package.json and returns it.
691
- * It will also log warnings and errors for missing or invalid fields.
692
- * It will return null if critical errors are found.
693
- *
694
- * @param {Plugin | PluginName} plugin - The plugin to load the package from.
695
- * @returns {Promise<Record<string, string | number | object> | null>} A promise that resolves to the parsed package.json object or null if it could not be parsed.
696
- */
697
510
  async parse(plugin) {
698
511
  const { promises } = await import('node:fs');
699
512
  if (typeof plugin === 'string') {
@@ -731,7 +544,6 @@ export class PluginManager extends EventEmitter {
731
544
  plugin.funding = this.getFunding(packageJson);
732
545
  if (!plugin.type)
733
546
  this.log.warn(`Plugin ${plg}${plugin.name}${wr} has no type`);
734
- // Check for @project-chip and @matter packages in dependencies and devDependencies
735
547
  const checkForProjectChipPackages = (dependencies) => {
736
548
  return Object.keys(dependencies).filter((pkg) => pkg.startsWith('@project-chip') || pkg.startsWith('@matter'));
737
549
  };
@@ -753,7 +565,6 @@ export class PluginManager extends EventEmitter {
753
565
  this.log.error(`Please open an issue on the plugin repository to remove them.`);
754
566
  return null;
755
567
  }
756
- // Check for matterbridge package in dependencies and devDependencies
757
568
  const checkForMatterbridgePackage = (dependencies) => {
758
569
  return Object.keys(dependencies).filter((pkg) => pkg === 'matterbridge');
759
570
  };
@@ -783,16 +594,6 @@ export class PluginManager extends EventEmitter {
783
594
  return null;
784
595
  }
785
596
  }
786
- /**
787
- * Enables a plugin by its name or path.
788
- *
789
- * This method enables a plugin by setting its `enabled` property to `true` and saving the updated
790
- * plugin information to storage. It first checks if the plugin is already registered in the `_plugins` map.
791
- * If not, it attempts to resolve the plugin's `package.json` file to retrieve its name and enable it.
792
- *
793
- * @param {string} nameOrPath - The name or path of the plugin to enable.
794
- * @returns {Promise<Plugin | null>} A promise that resolves to the enabled plugin object, or null if the plugin could not be enabled.
795
- */
796
597
  async enable(nameOrPath) {
797
598
  const { promises } = await import('node:fs');
798
599
  if (!nameOrPath)
@@ -828,16 +629,6 @@ export class PluginManager extends EventEmitter {
828
629
  return null;
829
630
  }
830
631
  }
831
- /**
832
- * Disables a plugin by its name or path.
833
- *
834
- * This method disables a plugin by setting its `enabled` property to `false` and saving the updated
835
- * plugin information to storage. It first checks if the plugin is already registered in the `_plugins` map.
836
- * If not, it attempts to resolve the plugin's `package.json` file to retrieve its name and disable it.
837
- *
838
- * @param {string} nameOrPath - The name or path of the plugin to enable.
839
- * @returns {Promise<Plugin | null>} A promise that resolves to the disabled plugin object, or null if the plugin could not be disabled.
840
- */
841
632
  async disable(nameOrPath) {
842
633
  const { promises } = await import('node:fs');
843
634
  if (!nameOrPath)
@@ -873,16 +664,6 @@ export class PluginManager extends EventEmitter {
873
664
  return null;
874
665
  }
875
666
  }
876
- /**
877
- * Removes a plugin by its name or path.
878
- *
879
- * This method removes a plugin from the `_plugins` map and saves the updated plugin information to storage.
880
- * It first checks if the plugin is already registered in the `_plugins` map. If not, it attempts to resolve
881
- * the plugin's `package.json` file to retrieve its name and remove it.
882
- *
883
- * @param {string} nameOrPath - The name or path of the plugin to remove.
884
- * @returns {Promise<Plugin | null>} A promise that resolves to the removed plugin object, or null if the plugin could not be removed.
885
- */
886
667
  async remove(nameOrPath) {
887
668
  const { promises } = await import('node:fs');
888
669
  if (!nameOrPath)
@@ -918,17 +699,6 @@ export class PluginManager extends EventEmitter {
918
699
  return null;
919
700
  }
920
701
  }
921
- /**
922
- * Adds a plugin by its name or path.
923
- *
924
- * This method adds a plugin to the plugins map and saves the updated plugin information to storage.
925
- * It first resolves the plugin's `package.json` file to retrieve its details. If the plugin is already
926
- * registered, it logs an info message and returns null. Otherwise, it registers the plugin, enables it,
927
- * and saves the updated plugin information to storage.
928
- *
929
- * @param {string} nameOrPath - The name or path of the plugin to add.
930
- * @returns {Promise<Plugin | null>} A promise that resolves to the added plugin object, or null if the plugin could not be added.
931
- */
932
702
  async add(nameOrPath) {
933
703
  const { promises } = await import('node:fs');
934
704
  if (!nameOrPath)
@@ -968,15 +738,6 @@ export class PluginManager extends EventEmitter {
968
738
  return null;
969
739
  }
970
740
  }
971
- /**
972
- * Loads a plugin and returns the corresponding MatterbridgePlatform instance.
973
- *
974
- * @param {Plugin | PluginName} plugin - The plugin to load.
975
- * @param {boolean} start - Optional flag indicating whether to start the plugin after loading. Default is false.
976
- * @param {string} message - Optional message to pass to the plugin when starting.
977
- * @param {boolean} configure - Optional flag indicating whether to configure the plugin after loading. Default is false.
978
- * @returns {Promise<MatterbridgePlatform | undefined>} A Promise that resolves to the loaded MatterbridgePlatform instance or undefined.
979
- */
980
741
  async load(plugin, start = false, message = '', configure = false) {
981
742
  const { promises } = await import('node:fs');
982
743
  const { default: path } = await import('node:path');
@@ -998,20 +759,15 @@ export class PluginManager extends EventEmitter {
998
759
  }
999
760
  this.log.info(`Loading plugin ${plg}${plugin.name}${nf} type ${typ}${plugin.type}${nf}`);
1000
761
  try {
1001
- // Load the package.json of the plugin
1002
762
  const packageJson = JSON.parse(await promises.readFile(plugin.path, 'utf8'));
1003
- // Resolve the main module path relative to package.json
1004
763
  const pluginEntry = path.resolve(path.dirname(plugin.path), packageJson.main);
1005
- // Dynamically import the plugin
1006
764
  const { pathToFileURL } = await import('node:url');
1007
765
  const pluginUrl = pathToFileURL(pluginEntry);
1008
766
  this.log.debug(`Importing plugin ${plg}${plugin.name}${db} from ${pluginUrl.href}`);
1009
767
  const pluginInstance = (await import(pluginUrl.href));
1010
768
  this.log.debug(`Imported plugin ${plg}${plugin.name}${db} from ${pluginUrl.href}`);
1011
- // Call the default export function of the plugin, passing this MatterBridge instance, the log and the config
1012
769
  if (pluginInstance.default) {
1013
770
  const config = await this.loadConfig(plugin);
1014
- // Preset the plugin properties here in case the plugin throws an error during loading. In this case the user can change the config and restart the plugin.
1015
771
  plugin.name = packageJson.name;
1016
772
  plugin.description = packageJson.description ?? 'No description';
1017
773
  plugin.version = packageJson.version;
@@ -1020,7 +776,7 @@ export class PluginManager extends EventEmitter {
1020
776
  plugin.schemaJson = await this.loadSchema(plugin);
1021
777
  config.name = packageJson.name;
1022
778
  config.version = packageJson.version;
1023
- const log = new AnsiLogger({ logName: plugin.description, logTimestampFormat: 4 /* TimestampFormat.TIME_MILLIS */, logLevel: config.debug ? "debug" /* LogLevel.DEBUG */ : this.matterbridge.logLevel });
779
+ const log = new AnsiLogger({ logName: plugin.description, logTimestampFormat: 4, logLevel: config.debug ? "debug" : this.matterbridge.logLevel });
1024
780
  const platform = pluginInstance.default(this.matterbridge, log, config);
1025
781
  config.type = platform.type;
1026
782
  platform.name = packageJson.name;
@@ -1039,7 +795,7 @@ export class PluginManager extends EventEmitter {
1039
795
  plugin.platform = platform;
1040
796
  plugin.loaded = true;
1041
797
  plugin.registeredDevices = 0;
1042
- await this.saveToStorage(); // Save the plugin to storage
798
+ await this.saveToStorage();
1043
799
  this.log.notice(`Loaded plugin ${plg}${plugin.name}${nt} type ${typ}${platform.type}${nt} (entrypoint ${UNDERLINE}${pluginEntry}${UNDERLINEOFF})`);
1044
800
  this.emit('loaded', plugin.name);
1045
801
  if (start)
@@ -1059,14 +815,6 @@ export class PluginManager extends EventEmitter {
1059
815
  }
1060
816
  return undefined;
1061
817
  }
1062
- /**
1063
- * Starts a plugin.
1064
- *
1065
- * @param {Plugin | PluginName} plugin - The plugin to start.
1066
- * @param {string} [message] - Optional message to pass to the plugin's onStart method.
1067
- * @param {boolean} [configure] - Indicates whether to configure the plugin after starting (default false).
1068
- * @returns {Promise<Plugin | undefined>} A promise that resolves when the plugin is started successfully, or rejects with an error if starting the plugin fails.
1069
- */
1070
818
  async start(plugin, message, configure = false) {
1071
819
  if (typeof plugin === 'string') {
1072
820
  const p = this._plugins.get(plugin);
@@ -1106,12 +854,6 @@ export class PluginManager extends EventEmitter {
1106
854
  }
1107
855
  return undefined;
1108
856
  }
1109
- /**
1110
- * Configures a plugin.
1111
- *
1112
- * @param {Plugin | PluginName} plugin - The plugin to configure.
1113
- * @returns {Promise<Plugin | undefined>} A promise that resolves when the plugin is configured successfully, or rejects with an error if configuration fails.
1114
- */
1115
857
  async configure(plugin) {
1116
858
  if (typeof plugin === 'string') {
1117
859
  const p = this._plugins.get(plugin);
@@ -1152,18 +894,6 @@ export class PluginManager extends EventEmitter {
1152
894
  }
1153
895
  return undefined;
1154
896
  }
1155
- /**
1156
- * Shuts down a plugin.
1157
- *
1158
- * This method shuts down a plugin by calling its `onShutdown` method and resetting its state.
1159
- * It logs the shutdown process and optionally removes all devices associated with the plugin.
1160
- *
1161
- * @param {Plugin | PluginName} plugin - The plugin to shut down.
1162
- * @param {string} [reason] - The reason for shutting down the plugin.
1163
- * @param {boolean} [removeAllDevices] - Whether to remove all devices associated with the plugin.
1164
- * @param {boolean} [force] - Whether to force the shutdown even if the plugin is not loaded or started.
1165
- * @returns {Promise<Plugin | undefined>} A promise that resolves to the shut down plugin object, or undefined if the shutdown failed.
1166
- */
1167
897
  async shutdown(plugin, reason, removeAllDevices = false, force = false) {
1168
898
  if (typeof plugin === 'string') {
1169
899
  const p = this._plugins.get(plugin);
@@ -1218,15 +948,6 @@ export class PluginManager extends EventEmitter {
1218
948
  }
1219
949
  return undefined;
1220
950
  }
1221
- /**
1222
- * Loads the configuration for a plugin.
1223
- * If the configuration file exists, it reads the file and returns the parsed JSON data.
1224
- * If the configuration file does not exist, it creates a new file with default configuration and returns it.
1225
- * If any error occurs during file access or creation, it logs an error and return un empty config.
1226
- *
1227
- * @param {Plugin} plugin - The plugin for which to load the configuration.
1228
- * @returns {Promise<PlatformConfig>} A promise that resolves to the loaded or created configuration.
1229
- */
1230
951
  async loadConfig(plugin) {
1231
952
  const { default: path } = await import('node:path');
1232
953
  const { promises } = await import('node:fs');
@@ -1238,8 +959,6 @@ export class PluginManager extends EventEmitter {
1238
959
  const data = await promises.readFile(configFile, 'utf8');
1239
960
  const config = JSON.parse(data);
1240
961
  this.log.debug(`Loaded config file ${configFile} for plugin ${plg}${plugin.name}${db}.`);
1241
- // this.log.debug(`Loaded config file ${configFile} for plugin ${plg}${plugin.name}${db}.\nConfig:${rs}\n`, config);
1242
- // The first time a plugin is added to the system, the config file is created with the plugin name and type "AnyPlatform".
1243
962
  config.name = plugin.name;
1244
963
  config.type = plugin.type;
1245
964
  if (config.debug === undefined)
@@ -1261,8 +980,6 @@ export class PluginManager extends EventEmitter {
1261
980
  }
1262
981
  catch (_err) {
1263
982
  this.log.debug(`Default config file ${defaultConfigFile} for plugin ${plg}${plugin.name}${db} does not exist, creating new config file...`);
1264
- // TODO: Remove this when all these plugins have their own default config file
1265
- // istanbul ignore next if
1266
983
  if (plugin.name === 'matterbridge-zigbee2mqtt')
1267
984
  config = zigbee2mqtt_config;
1268
985
  else if (plugin.name === 'matterbridge-somfy-tahoma')
@@ -1275,7 +992,6 @@ export class PluginManager extends EventEmitter {
1275
992
  try {
1276
993
  await promises.writeFile(configFile, JSON.stringify(config, null, 2), 'utf8');
1277
994
  this.log.debug(`Created config file ${configFile} for plugin ${plg}${plugin.name}${db}.`);
1278
- // this.log.debug(`Created config file ${configFile} for plugin ${plg}${plugin.name}${db}.\nConfig:${rs}\n`, config);
1279
995
  return config;
1280
996
  }
1281
997
  catch (err) {
@@ -1289,19 +1005,6 @@ export class PluginManager extends EventEmitter {
1289
1005
  }
1290
1006
  }
1291
1007
  }
1292
- /**
1293
- * Saves the configuration of a plugin to a file.
1294
- *
1295
- * This method saves the configuration of the specified plugin to a JSON file in the matterbridge directory.
1296
- * If the plugin's configuration is not found, it logs an error and rejects the promise. If the configuration
1297
- * is successfully saved, it logs a debug message. If an error occurs during the file write operation, it logs
1298
- * the error and rejects the promise.
1299
- *
1300
- * @param {Plugin} plugin - The plugin whose configuration is to be saved.
1301
- * @param {boolean} [restartRequired] - Indicates whether a restart is required after saving the configuration.
1302
- * @returns {Promise<void>} A promise that resolves when the configuration is successfully saved, or rejects if an error occurs.
1303
- * @throws {Error} If the plugin's configuration is not found.
1304
- */
1305
1008
  async saveConfigFromPlugin(plugin, restartRequired = false) {
1306
1009
  const { default: path } = await import('node:path');
1307
1010
  const { promises } = await import('node:fs');
@@ -1316,7 +1019,6 @@ export class PluginManager extends EventEmitter {
1316
1019
  if (restartRequired)
1317
1020
  plugin.restartRequired = true;
1318
1021
  this.log.debug(`Saved config file ${configFile} for plugin ${plg}${plugin.name}${db}`);
1319
- // this.log.debug(`Saved config file ${configFile} for plugin ${plg}${plugin.name}${db}.\nConfig:${rs}\n`, plugin.platform.config);
1320
1022
  return Promise.resolve();
1321
1023
  }
1322
1024
  catch (err) {
@@ -1324,20 +1026,6 @@ export class PluginManager extends EventEmitter {
1324
1026
  return Promise.reject(err);
1325
1027
  }
1326
1028
  }
1327
- /**
1328
- * Saves the configuration of a plugin from a JSON object to a file.
1329
- *
1330
- * This method saves the provided configuration of the specified plugin to a JSON file in the matterbridge directory.
1331
- * It first checks if the configuration data is valid by ensuring it contains the correct name and type, and matches
1332
- * the plugin's name. If the configuration data is invalid, it logs an error and returns. If the configuration is
1333
- * successfully saved, it updates the plugin's `configJson` property and logs a debug message. If an error occurs
1334
- * during the file write operation, it logs the error and returns.
1335
- *
1336
- * @param {Plugin} plugin - The plugin whose configuration is to be saved.
1337
- * @param {PlatformConfig} config - The configuration data to be saved.
1338
- * @param {boolean} [restartRequired] - Indicates whether a restart is required after saving the configuration.
1339
- * @returns {Promise<void>} A promise that resolves when the configuration is successfully saved, or returns if an error occurs.
1340
- */
1341
1029
  async saveConfigFromJson(plugin, config, restartRequired = false) {
1342
1030
  const { default: path } = await import('node:path');
1343
1031
  const { promises } = await import('node:fs');
@@ -1356,23 +1044,12 @@ export class PluginManager extends EventEmitter {
1356
1044
  plugin.platform.onConfigChanged(config).catch((err) => this.log.error(`Error calling onConfigChanged for plugin ${plg}${plugin.name}${er}: ${err}`));
1357
1045
  }
1358
1046
  this.log.debug(`Saved config file ${configFile} for plugin ${plg}${plugin.name}${db}`);
1359
- // this.log.debug(`Saved config file ${configFile} for plugin ${plg}${plugin.name}${db}.\nConfig:${rs}\n`, config);
1360
1047
  }
1361
1048
  catch (err) {
1362
1049
  logError(this.log, `Error saving config file ${configFile} for plugin ${plg}${plugin.name}${er}`, err);
1363
1050
  return;
1364
1051
  }
1365
1052
  }
1366
- /**
1367
- * Loads the schema for a plugin.
1368
- *
1369
- * This method attempts to load the schema file for the specified plugin. If the schema file is found,
1370
- * it reads and parses the file, updates the schema's title and description, and logs the process.
1371
- * If the schema file is not found, it logs the event and loads a default schema for the plugin.
1372
- *
1373
- * @param {Plugin} plugin - The plugin whose schema is to be loaded.
1374
- * @returns {Promise<PlatformSchema>} A promise that resolves to the loaded schema object, or the default schema if the schema file is not found.
1375
- */
1376
1053
  async loadSchema(plugin) {
1377
1054
  const { promises } = await import('node:fs');
1378
1055
  const schemaFile = plugin.path.replace('package.json', `${plugin.name}.schema.json`);
@@ -1383,7 +1060,6 @@ export class PluginManager extends EventEmitter {
1383
1060
  schema.title = plugin.description;
1384
1061
  schema.description = plugin.name + ' v. ' + plugin.version + ' by ' + plugin.author;
1385
1062
  this.log.debug(`Loaded schema file ${schemaFile} for plugin ${plg}${plugin.name}${db}.`);
1386
- // this.log.debug(`Loaded schema file ${schemaFile} for plugin ${plg}${plugin.name}${db}.\nSchema:${rs}\n`, schema);
1387
1063
  return schema;
1388
1064
  }
1389
1065
  catch (_err) {
@@ -1391,16 +1067,6 @@ export class PluginManager extends EventEmitter {
1391
1067
  return this.getDefaultSchema(plugin);
1392
1068
  }
1393
1069
  }
1394
- /**
1395
- * Returns the default schema for a plugin.
1396
- *
1397
- * This method generates a default schema object for the specified plugin. The schema includes
1398
- * metadata such as the plugin's title, description, version, and author. It also defines the
1399
- * properties of the schema, including the plugin's name, type, debug flag, and unregisterOnShutdown flag.
1400
- *
1401
- * @param {Plugin} plugin - The plugin for which the default schema is to be generated.
1402
- * @returns {PlatformSchema} The default schema object for the plugin.
1403
- */
1404
1070
  getDefaultSchema(plugin) {
1405
1071
  return {
1406
1072
  title: plugin.description,
@@ -1431,4 +1097,3 @@ export class PluginManager extends EventEmitter {
1431
1097
  };
1432
1098
  }
1433
1099
  }
1434
- //# sourceMappingURL=pluginManager.js.map