@matterbridge/core 3.5.3 → 3.5.4-edge-20260211-1ea4e31

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 (294) hide show
  1. package/README.md +1 -1
  2. package/dist/cli.d.ts +0 -24
  3. package/dist/cli.js +1 -97
  4. package/dist/cliEmitter.d.ts +0 -36
  5. package/dist/cliEmitter.js +0 -37
  6. package/dist/cliHistory.d.ts +0 -42
  7. package/dist/cliHistory.js +0 -38
  8. package/dist/clusters/export.d.ts +0 -1
  9. package/dist/clusters/export.js +0 -2
  10. package/dist/deviceManager.d.ts +0 -108
  11. package/dist/deviceManager.js +1 -114
  12. package/dist/devices/airConditioner.d.ts +0 -75
  13. package/dist/devices/airConditioner.js +0 -57
  14. package/dist/devices/basicVideoPlayer.d.ts +0 -58
  15. package/dist/devices/basicVideoPlayer.js +1 -56
  16. package/dist/devices/batteryStorage.d.ts +0 -43
  17. package/dist/devices/batteryStorage.js +1 -48
  18. package/dist/devices/castingVideoPlayer.d.ts +0 -63
  19. package/dist/devices/castingVideoPlayer.js +2 -65
  20. package/dist/devices/cooktop.d.ts +0 -55
  21. package/dist/devices/cooktop.js +0 -56
  22. package/dist/devices/dishwasher.d.ts +0 -55
  23. package/dist/devices/dishwasher.js +0 -57
  24. package/dist/devices/evse.d.ts +0 -57
  25. package/dist/devices/evse.js +10 -74
  26. package/dist/devices/export.d.ts +0 -1
  27. package/dist/devices/export.js +0 -5
  28. package/dist/devices/extractorHood.d.ts +0 -41
  29. package/dist/devices/extractorHood.js +0 -43
  30. package/dist/devices/heatPump.d.ts +0 -43
  31. package/dist/devices/heatPump.js +2 -50
  32. package/dist/devices/laundryDryer.d.ts +0 -58
  33. package/dist/devices/laundryDryer.js +3 -62
  34. package/dist/devices/laundryWasher.d.ts +0 -64
  35. package/dist/devices/laundryWasher.js +4 -70
  36. package/dist/devices/microwaveOven.d.ts +1 -77
  37. package/dist/devices/microwaveOven.js +5 -88
  38. package/dist/devices/oven.d.ts +0 -82
  39. package/dist/devices/oven.js +0 -85
  40. package/dist/devices/refrigerator.d.ts +0 -100
  41. package/dist/devices/refrigerator.js +0 -102
  42. package/dist/devices/roboticVacuumCleaner.d.ts +0 -83
  43. package/dist/devices/roboticVacuumCleaner.js +9 -100
  44. package/dist/devices/solarPower.d.ts +0 -36
  45. package/dist/devices/solarPower.js +0 -38
  46. package/dist/devices/speaker.d.ts +0 -79
  47. package/dist/devices/speaker.js +0 -84
  48. package/dist/devices/temperatureControl.d.ts +0 -21
  49. package/dist/devices/temperatureControl.js +3 -24
  50. package/dist/devices/waterHeater.d.ts +0 -74
  51. package/dist/devices/waterHeater.js +2 -82
  52. package/dist/dgram/export.d.ts +0 -1
  53. package/dist/dgram/export.js +0 -1
  54. package/dist/export.d.ts +0 -23
  55. package/dist/export.js +0 -28
  56. package/dist/frontend.d.ts +0 -187
  57. package/dist/frontend.js +38 -539
  58. package/dist/helpers.d.ts +0 -43
  59. package/dist/helpers.js +0 -86
  60. package/dist/jestutils/export.d.ts +0 -1
  61. package/dist/jestutils/export.js +0 -1
  62. package/dist/jestutils/jestHelpers.d.ts +0 -259
  63. package/dist/jestutils/jestHelpers.js +14 -395
  64. package/dist/matter/behaviors.d.ts +0 -1
  65. package/dist/matter/behaviors.js +0 -2
  66. package/dist/matter/clusters.d.ts +0 -1
  67. package/dist/matter/clusters.js +0 -2
  68. package/dist/matter/devices.d.ts +0 -1
  69. package/dist/matter/devices.js +0 -2
  70. package/dist/matter/endpoints.d.ts +0 -1
  71. package/dist/matter/endpoints.js +0 -2
  72. package/dist/matter/export.d.ts +0 -1
  73. package/dist/matter/export.js +0 -2
  74. package/dist/matter/types.d.ts +0 -1
  75. package/dist/matter/types.js +0 -2
  76. package/dist/matterNode.d.ts +0 -258
  77. package/dist/matterNode.js +8 -356
  78. package/dist/matterbridge.d.ts +0 -389
  79. package/dist/matterbridge.js +48 -878
  80. package/dist/matterbridgeAccessoryPlatform.d.ts +0 -42
  81. package/dist/matterbridgeAccessoryPlatform.js +0 -50
  82. package/dist/matterbridgeBehaviors.d.ts +0 -24
  83. package/dist/matterbridgeBehaviors.js +5 -65
  84. package/dist/matterbridgeDeviceTypes.d.ts +0 -649
  85. package/dist/matterbridgeDeviceTypes.js +6 -673
  86. package/dist/matterbridgeDynamicPlatform.d.ts +0 -42
  87. package/dist/matterbridgeDynamicPlatform.js +0 -50
  88. package/dist/matterbridgeEndpoint.d.ts +0 -1369
  89. package/dist/matterbridgeEndpoint.js +56 -1514
  90. package/dist/matterbridgeEndpointHelpers.d.ts +0 -425
  91. package/dist/matterbridgeEndpointHelpers.js +20 -483
  92. package/dist/matterbridgeEndpointTypes.d.ts +0 -70
  93. package/dist/matterbridgeEndpointTypes.js +0 -25
  94. package/dist/matterbridgePlatform.d.ts +0 -434
  95. package/dist/matterbridgePlatform.js +1 -473
  96. package/dist/mb_coap.d.ts +0 -23
  97. package/dist/mb_coap.js +3 -41
  98. package/dist/mb_health.d.ts +0 -67
  99. package/dist/mb_health.js +0 -70
  100. package/dist/mb_mdns.d.ts +0 -23
  101. package/dist/mb_mdns.js +36 -94
  102. package/dist/pluginManager.d.ts +0 -307
  103. package/dist/pluginManager.js +6 -346
  104. package/dist/spawn.d.ts +0 -32
  105. package/dist/spawn.js +1 -71
  106. package/dist/utils/export.d.ts +0 -1
  107. package/dist/utils/export.js +0 -1
  108. package/package.json +27 -6
  109. package/dist/cli.d.ts.map +0 -1
  110. package/dist/cli.js.map +0 -1
  111. package/dist/cliEmitter.d.ts.map +0 -1
  112. package/dist/cliEmitter.js.map +0 -1
  113. package/dist/cliHistory.d.ts.map +0 -1
  114. package/dist/cliHistory.js.map +0 -1
  115. package/dist/clusters/export.d.ts.map +0 -1
  116. package/dist/clusters/export.js.map +0 -1
  117. package/dist/crypto/attestationDecoder.d.ts +0 -180
  118. package/dist/crypto/attestationDecoder.d.ts.map +0 -1
  119. package/dist/crypto/attestationDecoder.js +0 -176
  120. package/dist/crypto/attestationDecoder.js.map +0 -1
  121. package/dist/crypto/declarationDecoder.d.ts +0 -72
  122. package/dist/crypto/declarationDecoder.d.ts.map +0 -1
  123. package/dist/crypto/declarationDecoder.js +0 -241
  124. package/dist/crypto/declarationDecoder.js.map +0 -1
  125. package/dist/crypto/extract/342/200/220cert/342/200/220extensions.d.ts +0 -9
  126. package/dist/crypto/extract/342/200/220cert/342/200/220extensions.d.ts.map +0 -1
  127. package/dist/crypto/extract/342/200/220cert/342/200/220extensions.js +0 -120
  128. package/dist/crypto/extract/342/200/220cert/342/200/220extensions.js.map +0 -1
  129. package/dist/crypto/read-extensions.d.ts +0 -2
  130. package/dist/crypto/read-extensions.d.ts.map +0 -1
  131. package/dist/crypto/read-extensions.js +0 -81
  132. package/dist/crypto/read-extensions.js.map +0 -1
  133. package/dist/crypto/testData.d.ts +0 -31
  134. package/dist/crypto/testData.d.ts.map +0 -1
  135. package/dist/crypto/testData.js +0 -131
  136. package/dist/crypto/testData.js.map +0 -1
  137. package/dist/crypto/walk-der.d.ts +0 -2
  138. package/dist/crypto/walk-der.d.ts.map +0 -1
  139. package/dist/crypto/walk-der.js +0 -165
  140. package/dist/crypto/walk-der.js.map +0 -1
  141. package/dist/deviceManager.d.ts.map +0 -1
  142. package/dist/deviceManager.js.map +0 -1
  143. package/dist/devices/airConditioner.d.ts.map +0 -1
  144. package/dist/devices/airConditioner.js.map +0 -1
  145. package/dist/devices/basicVideoPlayer.d.ts.map +0 -1
  146. package/dist/devices/basicVideoPlayer.js.map +0 -1
  147. package/dist/devices/batteryStorage.d.ts.map +0 -1
  148. package/dist/devices/batteryStorage.js.map +0 -1
  149. package/dist/devices/castingVideoPlayer.d.ts.map +0 -1
  150. package/dist/devices/castingVideoPlayer.js.map +0 -1
  151. package/dist/devices/cooktop.d.ts.map +0 -1
  152. package/dist/devices/cooktop.js.map +0 -1
  153. package/dist/devices/dishwasher.d.ts.map +0 -1
  154. package/dist/devices/dishwasher.js.map +0 -1
  155. package/dist/devices/evse.d.ts.map +0 -1
  156. package/dist/devices/evse.js.map +0 -1
  157. package/dist/devices/export.d.ts.map +0 -1
  158. package/dist/devices/export.js.map +0 -1
  159. package/dist/devices/extractorHood.d.ts.map +0 -1
  160. package/dist/devices/extractorHood.js.map +0 -1
  161. package/dist/devices/heatPump.d.ts.map +0 -1
  162. package/dist/devices/heatPump.js.map +0 -1
  163. package/dist/devices/laundryDryer.d.ts.map +0 -1
  164. package/dist/devices/laundryDryer.js.map +0 -1
  165. package/dist/devices/laundryWasher.d.ts.map +0 -1
  166. package/dist/devices/laundryWasher.js.map +0 -1
  167. package/dist/devices/microwaveOven.d.ts.map +0 -1
  168. package/dist/devices/microwaveOven.js.map +0 -1
  169. package/dist/devices/oven.d.ts.map +0 -1
  170. package/dist/devices/oven.js.map +0 -1
  171. package/dist/devices/refrigerator.d.ts.map +0 -1
  172. package/dist/devices/refrigerator.js.map +0 -1
  173. package/dist/devices/roboticVacuumCleaner.d.ts.map +0 -1
  174. package/dist/devices/roboticVacuumCleaner.js.map +0 -1
  175. package/dist/devices/solarPower.d.ts.map +0 -1
  176. package/dist/devices/solarPower.js.map +0 -1
  177. package/dist/devices/speaker.d.ts.map +0 -1
  178. package/dist/devices/speaker.js.map +0 -1
  179. package/dist/devices/temperatureControl.d.ts.map +0 -1
  180. package/dist/devices/temperatureControl.js.map +0 -1
  181. package/dist/devices/waterHeater.d.ts.map +0 -1
  182. package/dist/devices/waterHeater.js.map +0 -1
  183. package/dist/dgram/export.d.ts.map +0 -1
  184. package/dist/dgram/export.js.map +0 -1
  185. package/dist/export.d.ts.map +0 -1
  186. package/dist/export.js.map +0 -1
  187. package/dist/frontend.d.ts.map +0 -1
  188. package/dist/frontend.js.map +0 -1
  189. package/dist/helpers.d.ts.map +0 -1
  190. package/dist/helpers.js.map +0 -1
  191. package/dist/jestutils/export.d.ts.map +0 -1
  192. package/dist/jestutils/export.js.map +0 -1
  193. package/dist/jestutils/jestHelpers.d.ts.map +0 -1
  194. package/dist/jestutils/jestHelpers.js.map +0 -1
  195. package/dist/matter/behaviors.d.ts.map +0 -1
  196. package/dist/matter/behaviors.js.map +0 -1
  197. package/dist/matter/clusters.d.ts.map +0 -1
  198. package/dist/matter/clusters.js.map +0 -1
  199. package/dist/matter/devices.d.ts.map +0 -1
  200. package/dist/matter/devices.js.map +0 -1
  201. package/dist/matter/endpoints.d.ts.map +0 -1
  202. package/dist/matter/endpoints.js.map +0 -1
  203. package/dist/matter/export.d.ts.map +0 -1
  204. package/dist/matter/export.js.map +0 -1
  205. package/dist/matter/types.d.ts.map +0 -1
  206. package/dist/matter/types.js.map +0 -1
  207. package/dist/matterNode.d.ts.map +0 -1
  208. package/dist/matterNode.js.map +0 -1
  209. package/dist/matterbridge.d.ts.map +0 -1
  210. package/dist/matterbridge.js.map +0 -1
  211. package/dist/matterbridgeAccessoryPlatform.d.ts.map +0 -1
  212. package/dist/matterbridgeAccessoryPlatform.js.map +0 -1
  213. package/dist/matterbridgeBehaviors.d.ts.map +0 -1
  214. package/dist/matterbridgeBehaviors.js.map +0 -1
  215. package/dist/matterbridgeDeviceTypes.d.ts.map +0 -1
  216. package/dist/matterbridgeDeviceTypes.js.map +0 -1
  217. package/dist/matterbridgeDynamicPlatform.d.ts.map +0 -1
  218. package/dist/matterbridgeDynamicPlatform.js.map +0 -1
  219. package/dist/matterbridgeEndpoint.d.ts.map +0 -1
  220. package/dist/matterbridgeEndpoint.js.map +0 -1
  221. package/dist/matterbridgeEndpointHelpers.d.ts.map +0 -1
  222. package/dist/matterbridgeEndpointHelpers.js.map +0 -1
  223. package/dist/matterbridgeEndpointTypes.d.ts.map +0 -1
  224. package/dist/matterbridgeEndpointTypes.js.map +0 -1
  225. package/dist/matterbridgePlatform.d.ts.map +0 -1
  226. package/dist/matterbridgePlatform.js.map +0 -1
  227. package/dist/mb_coap.d.ts.map +0 -1
  228. package/dist/mb_coap.js.map +0 -1
  229. package/dist/mb_health.d.ts.map +0 -1
  230. package/dist/mb_health.js.map +0 -1
  231. package/dist/mb_mdns.d.ts.map +0 -1
  232. package/dist/mb_mdns.js.map +0 -1
  233. package/dist/pluginManager.d.ts.map +0 -1
  234. package/dist/pluginManager.js.map +0 -1
  235. package/dist/spawn.d.ts.map +0 -1
  236. package/dist/spawn.js.map +0 -1
  237. package/dist/utils/export.d.ts.map +0 -1
  238. package/dist/utils/export.js.map +0 -1
  239. package/dist/workers/brand.d.ts +0 -25
  240. package/dist/workers/brand.d.ts.map +0 -1
  241. package/dist/workers/brand.extend.d.ts +0 -10
  242. package/dist/workers/brand.extend.d.ts.map +0 -1
  243. package/dist/workers/brand.extend.js +0 -15
  244. package/dist/workers/brand.extend.js.map +0 -1
  245. package/dist/workers/brand.invalid.d.ts +0 -9
  246. package/dist/workers/brand.invalid.d.ts.map +0 -1
  247. package/dist/workers/brand.invalid.js +0 -19
  248. package/dist/workers/brand.invalid.js.map +0 -1
  249. package/dist/workers/brand.js +0 -67
  250. package/dist/workers/brand.js.map +0 -1
  251. package/dist/workers/clusterTypes.d.ts +0 -47
  252. package/dist/workers/clusterTypes.d.ts.map +0 -1
  253. package/dist/workers/clusterTypes.js +0 -57
  254. package/dist/workers/clusterTypes.js.map +0 -1
  255. package/dist/workers/frontendWorker.d.ts +0 -2
  256. package/dist/workers/frontendWorker.d.ts.map +0 -1
  257. package/dist/workers/frontendWorker.js +0 -90
  258. package/dist/workers/frontendWorker.js.map +0 -1
  259. package/dist/workers/helloWorld.d.ts +0 -2
  260. package/dist/workers/helloWorld.d.ts.map +0 -1
  261. package/dist/workers/helloWorld.js +0 -135
  262. package/dist/workers/helloWorld.js.map +0 -1
  263. package/dist/workers/matterWorker.d.ts +0 -2
  264. package/dist/workers/matterWorker.d.ts.map +0 -1
  265. package/dist/workers/matterWorker.js +0 -104
  266. package/dist/workers/matterWorker.js.map +0 -1
  267. package/dist/workers/matterbridgeWorker.d.ts +0 -2
  268. package/dist/workers/matterbridgeWorker.d.ts.map +0 -1
  269. package/dist/workers/matterbridgeWorker.js +0 -75
  270. package/dist/workers/matterbridgeWorker.js.map +0 -1
  271. package/dist/workers/messageLab.d.ts +0 -134
  272. package/dist/workers/messageLab.d.ts.map +0 -1
  273. package/dist/workers/messageLab.js +0 -129
  274. package/dist/workers/messageLab.js.map +0 -1
  275. package/dist/workers/testWorker.d.ts +0 -2
  276. package/dist/workers/testWorker.d.ts.map +0 -1
  277. package/dist/workers/testWorker.js +0 -45
  278. package/dist/workers/testWorker.js.map +0 -1
  279. package/dist/workers/usage.d.ts +0 -19
  280. package/dist/workers/usage.d.ts.map +0 -1
  281. package/dist/workers/usage.js +0 -140
  282. package/dist/workers/usage.js.map +0 -1
  283. package/dist/workers/workerManager.d.ts +0 -115
  284. package/dist/workers/workerManager.d.ts.map +0 -1
  285. package/dist/workers/workerManager.js +0 -464
  286. package/dist/workers/workerManager.js.map +0 -1
  287. package/dist/workers/workerServer.d.ts +0 -126
  288. package/dist/workers/workerServer.d.ts.map +0 -1
  289. package/dist/workers/workerServer.js +0 -340
  290. package/dist/workers/workerServer.js.map +0 -1
  291. package/dist/workers/workerTypes.d.ts +0 -23
  292. package/dist/workers/workerTypes.d.ts.map +0 -1
  293. package/dist/workers/workerTypes.js +0 -3
  294. package/dist/workers/workerTypes.js.map +0 -1
@@ -1,143 +1,61 @@
1
- /**
2
- * This file contains the class MatterbridgePlatform.
3
- *
4
- * @file matterbridgePlatform.ts
5
- * @author Luca Liguori
6
- * @created 2024-03-21
7
- * @version 1.6.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
- // eslint-disable-next-line no-console
25
1
  if (process.argv.includes('--loader') || process.argv.includes('-loader'))
26
2
  console.log('\u001B[32mMatterbridgePlatform loaded.\u001B[40;0m');
27
- // Node.js modules
28
3
  import path from 'node:path';
29
- // Node AnsiLogger module
30
4
  import { CYAN, db, er, nf, wr } from 'node-ansi-logger';
31
- // Node Storage module
32
5
  import { NodeStorageManager } from 'node-persist-manager';
33
6
  import { Descriptor } from '@matter/types/clusters/descriptor';
34
7
  import { BridgedDeviceBasicInformation } from '@matter/types/clusters/bridged-device-basic-information';
35
- // @matterbridge
36
8
  import { hasParameter, isValidArray, isValidObject, isValidString } from '@matterbridge/utils';
37
9
  import { BroadcastServer } from '@matterbridge/thread';
38
- // Matterbridge
39
10
  import { assertMatterbridgeEndpoint } from './matterbridgeEndpoint.js';
40
11
  import { checkNotLatinCharacters } from './matterbridgeEndpointHelpers.js';
41
12
  import { bridgedNode } from './matterbridgeDeviceTypes.js';
42
- // Module-private brand
43
13
  const MATTERBRIDGE_PLATFORM_BRAND = Symbol('MatterbridgePlatform.brand');
44
- /**
45
- * Type guard to check whether a value is a MatterbridgePlatform instance.
46
- *
47
- * @param {unknown} value - the value to check
48
- * @returns { value is MatterbridgePlatform } - true if the value is a MatterbridgePlatform instance
49
- */
50
14
  export function isMatterbridgePlatform(value) {
51
15
  if (!value || typeof value !== 'object')
52
16
  return false;
53
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
54
17
  const v = value;
55
- // 1. Brand: must be branded by *this* module instance.
56
18
  if (v[MATTERBRIDGE_PLATFORM_BRAND] !== true)
57
19
  return false;
58
- // 2. instanceof: strengthen guarantee when there aren't multiple copies of the package.
59
20
  if (!(v instanceof MatterbridgePlatform))
60
21
  return false;
61
- // 3. Shape checks: basic sanity for API surface.
62
22
  if (typeof v.name !== 'string' || typeof v.type !== 'string' || typeof v.version !== 'string' || typeof v.config !== 'object')
63
23
  return false;
64
24
  return true;
65
25
  }
66
- /**
67
- * Assert that a value is a MatterbridgePlatform instance.
68
- *
69
- * @param {unknown} value - the value to check
70
- * @param {string} [context] - optional context for error message
71
- * @returns {asserts value is MatterbridgePlatform} - asserts that the value is a MatterbridgePlatform instance
72
- * @throws {TypeError} - if the value is not a MatterbridgePlatform instance
73
- */
74
26
  export function assertMatterbridgePlatform(value, context) {
75
27
  if (isMatterbridgePlatform(value))
76
28
  return;
77
29
  throw new TypeError(`Invalid MatterbridgePlatform received${context ? ` in ${context}` : ''}`);
78
30
  }
79
- /**
80
- * Represents the base Matterbridge platform. It is extended by the MatterbridgeAccessoryPlatform and MatterbridgeServicePlatform classes.
81
- *
82
- */
83
31
  export class MatterbridgePlatform {
84
- /** The PlatformMatterbridge instance of this Platform. */
85
32
  matterbridge;
86
- /** The logger instance for this platform. Created by the PluginManager.load() method. */
87
33
  log;
88
- /** The configuration for this platform. Set by the PluginManager.load() method using the stored config file. */
89
34
  config;
90
- /** The name of the platform. Set by the PluginManager.load() method using the package.json name value. */
91
35
  name = '';
92
- /** The type of the platform. Set by the extending classes: MatterbridgeDynamicPlatform and MatterbridgeAccessoryPlatform */
93
36
  type = 'AnyPlatform';
94
- /** The version of the platform. Set by the PluginManager.load() method using the package.json version value. */
95
37
  version = '1.0.0';
96
- /** Platform node storage manager created in the matterbridgeDirectory with the plugin name. */
97
38
  #storage;
98
- /** Platform context in the storage of matterbridgeDirectory. Use await platform.ready to access it early. */
99
39
  context;
100
- /** Indicates whether the platform is is fully initialized (including context and selects). */
101
40
  isReady = false;
102
- /** Indicates whether the platform has been loaded. */
103
41
  isLoaded = false;
104
- /** Indicates whether the platform has been started. */
105
42
  isStarted = false;
106
- /** Indicates whether the platform has been configured. */
107
43
  isConfigured = false;
108
- /** Indicates whether the platform is shutting down. */
109
44
  isShuttingDown = false;
110
- // Device and entity select in the plugin config UI
111
45
  #selectDevices = new Map();
112
46
  #selectEntities = new Map();
113
- // Promises for platform initialization. They are grouped in MatterbridgePlatform.ready with Promise.all.
114
47
  #contextReady;
115
48
  #selectDeviceContextReady;
116
49
  #selectEntityContextReady;
117
- /** The ready promise for the platform, which resolves when the platform is fully initialized (including context and selects). Await platform.ready if you access the platform context or select early. */
118
50
  ready;
119
- /** Registered MatterbridgeEndpoint map keyed by uniqueId */
120
51
  #registeredEndpoints = new Map();
121
- /** Broadcast server */
122
52
  #server;
123
53
  #debug = hasParameter('debug') || hasParameter('verbose');
124
54
  #verbose = hasParameter('verbose');
125
- /** MatterNode helper injected by the PluginManager.load() method */
126
55
  #addBridgedEndpoint;
127
- /** MatterNode helper injected by the PluginManager.load() method */
128
56
  #removeBridgedEndpoint;
129
- /** MatterNode helper injected by the PluginManager.load() method */
130
57
  #removeAllBridgedEndpoints;
131
- /** MatterNode helper injected by the PluginManager.load() method */
132
58
  #addVirtualEndpoint;
133
- /**
134
- * MatterNode helpers injected by the PluginManager.load() method
135
- *
136
- * @param {(pluginName: string, device: MatterbridgeEndpoint) => Promise<void>} addBridgedEndpoint - Function to add a bridged endpoint.
137
- * @param {(pluginName: string, device: MatterbridgeEndpoint) => Promise<void>} removeBridgedEndpoint - Function to remove a bridged endpoint.
138
- * @param {(pluginName: string, delay?: number) => Promise<void>} removeAllBridgedEndpoints - Function to remove all bridged endpoints.
139
- * @param {(pluginName: string, name: string, type: 'light' | 'outlet' | 'switch' | 'mounted_switch', callback: () => Promise<void>) => Promise<boolean>} addVirtualEndpoint - Function to add a virtual endpoint.
140
- */
141
59
  setMatterNode = (addBridgedEndpoint, removeBridgedEndpoint, removeAllBridgedEndpoints, addVirtualEndpoint) => {
142
60
  this.#addBridgedEndpoint = addBridgedEndpoint;
143
61
  this.#removeBridgedEndpoint = removeBridgedEndpoint;
@@ -145,21 +63,11 @@ export class MatterbridgePlatform {
145
63
  this.#addVirtualEndpoint = addVirtualEndpoint;
146
64
  this.setMatterNode = undefined;
147
65
  };
148
- /**
149
- * Creates an instance of the base MatterbridgePlatform.
150
- * Each plugin must extend the MatterbridgeDynamicPlatform or MatterbridgeAccessoryPlatform class.
151
- * MatterbridgePlatform cannot be instantiated directly, it can only be extended by the MatterbridgeDynamicPlatform or MatterbridgeAccessoryPlatform class.
152
- *
153
- * @param {PlatformMatterbridge} matterbridge - The PlatformMatterbridge instance.
154
- * @param {AnsiLogger} log - The logger instance.
155
- * @param {PlatformConfig} config - The platform configuration.
156
- */
157
66
  constructor(matterbridge, log, config) {
158
67
  this.matterbridge = matterbridge;
159
68
  this.log = log;
160
69
  this.config = config;
161
70
  this.#server = new BroadcastServer('platform', this.log);
162
- // Set the brand
163
71
  Object.defineProperty(this, MATTERBRIDGE_PLATFORM_BRAND, {
164
72
  value: true,
165
73
  writable: false,
@@ -170,7 +78,6 @@ export class MatterbridgePlatform {
170
78
  this.log.debug(`Creating MatterbridgePlatform for plugin ${this.config.name}`);
171
79
  if (this.#verbose)
172
80
  this.log.debug(`Creating MatterbridgePlatform for plugin ${this.config.name} with config:\n${JSON.stringify(this.config, null, 2)}\n`);
173
- // create the NodeStorageManager for the plugin platform
174
81
  if (!isValidString(this.config.name, 1)) {
175
82
  this.#server.close();
176
83
  throw new Error('Platform: the plugin name is missing or invalid.');
@@ -183,14 +90,12 @@ export class MatterbridgePlatform {
183
90
  logging: false,
184
91
  forgiveParseErrors: true,
185
92
  });
186
- // create the context storage for the plugin platform
187
93
  this.log.debug(`Creating context for plugin ${this.config.name}`);
188
94
  this.#contextReady = this.#storage.createStorage('context').then((context) => {
189
95
  this.context = context;
190
96
  this.log.debug(`Created context for plugin ${this.config.name}`);
191
97
  return;
192
98
  });
193
- // create the selectDevice storage for the plugin platform
194
99
  this.log.debug(`Loading selectDevice for plugin ${this.config.name}`);
195
100
  this.#selectDeviceContextReady = this.#storage.createStorage('selectDevice').then(async (context) => {
196
101
  const selectDevice = await context.get('selectDevice', []);
@@ -199,7 +104,6 @@ export class MatterbridgePlatform {
199
104
  this.log.debug(`Loaded ${this.#selectDevices.size} selectDevice for plugin ${this.config.name}`);
200
105
  return;
201
106
  });
202
- // create the selectEntity storage for the plugin platform
203
107
  this.log.debug(`Loading selectEntity for plugin ${this.config.name}`);
204
108
  this.#selectEntityContextReady = this.#storage.createStorage('selectEntity').then(async (context) => {
205
109
  const selectEntity = await context.get('selectEntity', []);
@@ -208,300 +112,98 @@ export class MatterbridgePlatform {
208
112
  this.log.debug(`Loaded ${this.#selectEntities.size} selectEntity for plugin ${this.config.name}`);
209
113
  return;
210
114
  });
211
- // Create the `ready` promise for the platform
212
115
  this.ready = Promise.all([this.#contextReady, this.#selectDeviceContextReady, this.#selectEntityContextReady]).then(() => {
213
116
  this.log.debug(`MatterbridgePlatform for plugin ${this.config.name} is fully initialized`);
214
117
  this.isReady = true;
215
118
  return;
216
119
  });
217
120
  }
218
- /**
219
- * Destroys the platform, cleaning up memory, closing storage and broadcast server.
220
- */
221
121
  async destroy() {
222
122
  if (this.#verbose)
223
123
  this.log.debug(`Destroying MatterbridgePlatform for plugin ${this.config.name}`);
224
- // Cleanup memory
225
124
  this.#selectDevices.clear();
226
125
  this.#selectEntities.clear();
227
126
  this.#registeredEndpoints.clear();
228
- // Close the storage
229
127
  await this.context?.close();
230
128
  this.context = undefined;
231
129
  await this.#storage?.close();
232
- // Close the broadcast server
233
130
  this.#server.close();
234
131
  if (this.#verbose)
235
132
  this.log.debug(`Destroyed MatterbridgePlatform for plugin ${this.config.name}`);
236
133
  this.isReady = false;
237
134
  }
238
- /**
239
- * This method shall be overridden in the extended class.
240
- * It is called when the platform is started.
241
- * Use this method to create the MatterbridgeEndpoints and call this.registerDevice().
242
- *
243
- * @param {string} [reason] - The reason for starting.
244
- * @throws {Error} - Throws an error if the method is not overridden.
245
- */
246
135
  async onStart(reason) {
247
136
  this.log.error('Plugins must override onStart.', reason);
248
137
  throw new Error('Plugins must override onStart.');
249
138
  }
250
- /**
251
- * This method can be overridden in the extended class. In this case always call super.onConfigure() to save the select and run checkEndpointNumbers().
252
- * It is called after the platform has started.
253
- * Use this method to perform any configuration of your devices and to override the value of the attributes that are persistent and stored in the
254
- * matter storage (i.e. the onOff attribute of the OnOff cluster).
255
- */
256
139
  async onConfigure() {
257
140
  this.log.debug(`Configuring platform ${this.name}`);
258
- // Save the selectDevice and selectEntity
259
141
  await this.saveSelects();
260
- // Check and update the endpoint numbers
261
142
  await this.checkEndpointNumbers();
262
143
  }
263
- /**
264
- * This method can be overridden in the extended class. In this case always call super.onShutdown() to save the selects, run checkEndpointNumbers() and cleanup memory.
265
- * It is called when the platform is shutting down.
266
- * Use this method to clean up any resources you used in the constructor or onStart.
267
- *
268
- * @param {string} [reason] - The reason for shutting down.
269
- */
270
144
  async onShutdown(reason) {
271
145
  this.log.debug(`Shutting down platform ${this.name}`, reason);
272
- // Save the selectDevice and selectEntity
273
146
  await this.saveSelects();
274
- // Check and update the endpoint numbers
275
147
  await this.checkEndpointNumbers();
276
- // Cleanup memory and close storage and broadcast server
277
148
  await this.destroy();
278
149
  }
279
- /**
280
- * Called when the logger level is changed.
281
- *
282
- * @param {LogLevel} logLevel The new logger level.
283
- */
284
150
  async onChangeLoggerLevel(logLevel) {
285
151
  this.log.debug(`The plugin doesn't override onChangeLoggerLevel. Logger level set to: ${logLevel}`);
286
152
  }
287
- /**
288
- * Called when a plugin config includes an action button or an action button with text field.
289
- *
290
- * @param {string} action The action triggered by the button in plugin config.
291
- * @param {string} value The value of the field of the action button.
292
- * @param {string} id The id of the schema associated with the action.
293
- * @param {PlatformConfig} formData The changed form data of the plugin.
294
- *
295
- * @remarks
296
- * This method can be overridden in the extended class.
297
- *
298
- * @example
299
- * Use this method to handle the action defined in the plugin schema:
300
- * ```json
301
- * "addDevice": {
302
- * "description": "Manually add a device that has not been discovered with mdns:",
303
- * "type": "boolean",
304
- * "buttonText": "ADD", // The text on the button. This is used when the action doesn't include a text field.
305
- * "buttonField": "ADD", // The text on the button. This is used when the action includes a text field.
306
- * "buttonClose": false, // optional, default is false. When true, the dialog will close after the action is sent.
307
- * "buttonSave": false, // optional, default is false. When true, the dialog will close and trigger the restart required after the action is sent.
308
- * "textPlaceholder": "Enter the device IP address", // optional: the placeholder text for the text field.
309
- * "default": false
310
- * },
311
- * ```
312
- */
313
153
  async onAction(action, value, id, formData) {
314
154
  this.log.debug(`The plugin ${CYAN}${this.name}${db} doesn't override onAction. Received action ${CYAN}${action}${db}${value ? ' with ' + CYAN + value + db : ''} ${id ? ' for schema ' + CYAN + id + db : ''}`, formData);
315
155
  }
316
- /**
317
- * Called when the plugin config has been updated.
318
- *
319
- * @param {PlatformConfig} config The new plugin config.
320
- */
321
156
  async onConfigChanged(config) {
322
157
  this.log.debug(`The plugin ${CYAN}${config.name}${db} doesn't override onConfigChanged. Received new config.`);
323
158
  }
324
- /**
325
- * Save the platform configuration to the platform config JSON.
326
- *
327
- * @param {PlatformConfig} [config] - The platform configuration to save.
328
- * @returns {void}
329
- */
330
159
  saveConfig(config) {
331
160
  this.#server.request({ type: 'plugins_saveconfigfromjson', src: 'platform', dst: 'plugins', params: { name: this.name, config } });
332
161
  }
333
- /**
334
- * Get the platform schema for the config editor. This will retrieve the schema from the Matterbridge plugin manager.
335
- *
336
- * @returns {Promise<PlatformSchema | undefined>} The platform schema.
337
- */
338
162
  async getSchema() {
339
163
  return (await this.#server.fetch({ type: 'plugins_getschema', src: 'platform', dst: 'plugins', params: { name: this.name } })).result.schema;
340
164
  }
341
- /**
342
- * Set the platform schema for the config editor. This will update the schema in the Matterbridge plugin manager but will not change the schema file.
343
- * It must be called from onStart() to update the schema in the plugin.
344
- * Calling this method from the platform constructor will have no effect.
345
- *
346
- * @param {PlatformSchema} [schema] - The platform schema to set.
347
- * @returns {void}
348
- */
349
165
  setSchema(schema) {
350
166
  this.#server.request({ type: 'plugins_setschema', src: 'platform', dst: 'plugins', params: { name: this.name, schema } });
351
167
  }
352
- /**
353
- * Sends a restart required message to the frontend.
354
- *
355
- * @param {boolean} [snackbar] - If true, shows a snackbar notification. Default is true.
356
- * @param {boolean} [fixed] - If true, shows a fixed notification. Default is false.
357
- * @returns {void}
358
- */
359
168
  wssSendRestartRequired(snackbar = true, fixed = false) {
360
169
  this.#server.request({ type: 'frontend_restartrequired', src: 'platform', dst: 'frontend', params: { snackbar, fixed } });
361
170
  }
362
- /**
363
- * Sends an open snackbar message to all connected clients.
364
- *
365
- * @param {string} message - The message to send.
366
- * @param {number} timeout - The timeout in seconds for the snackbar message. Default is 5 seconds.
367
- * @param {'info' | 'warning' | 'error' | 'success'} severity - The severity of the message.
368
- * possible values are: 'info', 'warning', 'error', 'success'. Default is 'info'.
369
- *
370
- * @remarks
371
- * If timeout is 0, the snackbar message will be displayed until closed by the user.
372
- */
373
171
  wssSendSnackbarMessage(message, timeout, severity) {
374
172
  this.#server.request({ type: 'frontend_snackbarmessage', src: 'platform', dst: 'frontend', params: { message, timeout, severity } });
375
173
  }
376
- /**
377
- * Retrieves the number of devices registered with the platform.
378
- *
379
- * @returns {number} The number of registered devices.
380
- */
381
174
  size() {
382
175
  return this.#registeredEndpoints.size;
383
176
  }
384
- /**
385
- * Retrieves the devices registered with the platform.
386
- *
387
- * @returns {MatterbridgeEndpoint[]} The registered devices.
388
- */
389
177
  getDevices() {
390
178
  return Array.from(this.#registeredEndpoints.values());
391
179
  }
392
- /**
393
- * Retrieves a registered device by its name.
394
- *
395
- * @param {string} deviceName - The device name to search for.
396
- * @returns {MatterbridgeEndpoint | undefined} The registered device or undefined if not found.
397
- */
398
180
  getDeviceByName(deviceName) {
399
181
  return Array.from(this.#registeredEndpoints.values()).find((device) => device.deviceName === deviceName);
400
182
  }
401
- /**
402
- * Retrieves a registered device by its uniqueId.
403
- *
404
- * @param {string} uniqueId - The device unique ID to search for.
405
- * @returns {MatterbridgeEndpoint | undefined} The registered device or undefined if not found.
406
- */
407
183
  getDeviceByUniqueId(uniqueId) {
408
184
  return Array.from(this.#registeredEndpoints.values()).find((device) => device.uniqueId === uniqueId);
409
185
  }
410
- /**
411
- * Retrieves a registered device by its serialNumber.
412
- *
413
- * @param {string} serialNumber - The device serial number to search for.
414
- * @returns {MatterbridgeEndpoint | undefined} The registered device or undefined if not found.
415
- */
416
186
  getDeviceBySerialNumber(serialNumber) {
417
187
  return Array.from(this.#registeredEndpoints.values()).find((device) => device.serialNumber === serialNumber);
418
188
  }
419
- /**
420
- * Retrieves a registered device by its id.
421
- *
422
- * @param {string} id - The device id to search for.
423
- * @returns {MatterbridgeEndpoint | undefined} The registered device or undefined if not found.
424
- */
425
189
  getDeviceById(id) {
426
190
  return Array.from(this.#registeredEndpoints.values()).find((device) => device.maybeId === id);
427
191
  }
428
- /**
429
- * Retrieves a registered device by its originalId.
430
- *
431
- * @param {string} originalId - The device originalId to search for.
432
- * @returns {MatterbridgeEndpoint | undefined} The registered device or undefined if not found.
433
- */
434
192
  getDeviceByOriginalId(originalId) {
435
193
  return Array.from(this.#registeredEndpoints.values()).find((device) => device.originalId === originalId);
436
194
  }
437
- /**
438
- * Retrieves a registered device by its number.
439
- *
440
- * @param {EndpointNumber | number} number - The device number to search for.
441
- * @returns {MatterbridgeEndpoint | undefined} The registered device or undefined if not found.
442
- */
443
195
  getDeviceByNumber(number) {
444
196
  return Array.from(this.#registeredEndpoints.values()).find((device) => device.maybeNumber === number);
445
197
  }
446
- /**
447
- * Checks if a device with this name is already registered in the platform.
448
- *
449
- * @param {string} deviceName - The device name to check.
450
- * @returns {boolean} True if the device is already registered, false otherwise.
451
- */
452
198
  hasDeviceName(deviceName) {
453
199
  return Array.from(this.#registeredEndpoints.values()).find((device) => device.deviceName === deviceName) !== undefined;
454
- // return this.registeredEndpointsByName.has(deviceName);
455
- }
456
- /**
457
- * Checks if a device with this uniqueId is already registered in the platform.
458
- *
459
- * @param {string} deviceUniqueId - The device unique ID to check.
460
- * @returns {boolean} True if the device is already registered, false otherwise.
461
- */
200
+ }
462
201
  hasDeviceUniqueId(deviceUniqueId) {
463
202
  return this.#registeredEndpoints.has(deviceUniqueId);
464
203
  }
465
- /**
466
- * Registers a virtual device with the Matterbridge platform.
467
- * Virtual devices are only supported in bridge mode and childbridge mode with a DynamicPlatform.
468
- *
469
- * The virtual device is created as an instance of `Endpoint` with the provided device type.
470
- * When the virtual device is turned on, the provided callback function is executed.
471
- * The onOff state of the virtual device always reverts to false when the device is turned on.
472
- *
473
- * @param { string } name - The name of the virtual device.
474
- * @param { 'light' | 'outlet' | 'switch' | 'mounted_switch' } type - The type of the virtual device.
475
- * @param { () => Promise<void> } callback - The callback to call when the virtual device is turned on.
476
- *
477
- * @returns {Promise<boolean>} A promise that resolves to true if the virtual device was successfully registered, false otherwise.
478
- *
479
- * @remarks
480
- * The virtual devices don't show up in the device list of the frontend.
481
- * Type 'switch' is not supported by Alexa and 'mounted_switch' is not supported by Apple Home.
482
- */
483
204
  async registerVirtualDevice(name, type, callback) {
484
205
  return (await this.#addVirtualEndpoint?.(this.name, name, type, callback)) ?? false;
485
206
  }
486
- /**
487
- * Registers a device with the Matterbridge platform and performs validation checks.
488
- *
489
- * This method also checks if the implementation called createDefaultBasicInformationClusterServer() instead of createDefaultBridgedDeviceBasicInformationClusterServer().
490
- *
491
- * This is correct with Accessory platforms so we check if we are running in bridge mode and add the bridgedNode and the BridgedDeviceBasicInformation cluster.
492
- *
493
- * If we are in bridge mode, we add the bridgedNode device type and the BridgedDeviceBasicInformation cluster.
494
- *
495
- * If we are in childbridge mode and the plugin is a 'DynamicPlatform', we add the bridgedNode device type and the BridgedDeviceBasicInformation cluster.
496
- *
497
- * if we are in childbridge mode and the plugin is a 'AccessoryPlatform', the device is not bridged so no action is taken.
498
- *
499
- * If the device.mode = 'server', the device is not bridged so no action is taken.
500
- *
501
- * If the device.mode = 'matter', the device is not bridged so no action is taken.
502
- *
503
- * @param {MatterbridgeEndpoint} device - The device to register.
504
- */
505
207
  async registerDevice(device) {
506
208
  assertMatterbridgeEndpoint(device, `MatterbridgePlatform.registerDevice for plugin ${this.name}`);
507
209
  device.plugin = this.name;
@@ -524,9 +226,7 @@ export class MatterbridgePlatform {
524
226
  if (checkNotLatinCharacters(device.deviceName)) {
525
227
  this.log.debug(`Device with name ${CYAN}${device.deviceName}${db} has non latin characters.`);
526
228
  }
527
- // Validate bridgedNode and BridgedDeviceBasicInformation cluster
528
229
  if (device.mode === undefined && (this.matterbridge.bridgeMode === 'bridge' || (this.matterbridge.bridgeMode === 'childbridge' && this.type === 'DynamicPlatform'))) {
529
- // If the device is a bridged device, we add the bridgedNode to the deviceTypes map and to the Descriptor Cluster options
530
230
  if (!device.deviceTypes.has(bridgedNode.code)) {
531
231
  this.log.debug(`Device with name ${CYAN}${device.deviceName}${db} has no bridgedNode device type. Adding it...`);
532
232
  device.deviceTypes.set(bridgedNode.code, bridgedNode);
@@ -538,7 +238,6 @@ export class MatterbridgePlatform {
538
238
  }
539
239
  }
540
240
  }
541
- // If the device is a bridged device, we add the BridgedDeviceBasicInformation cluster
542
241
  if (!device.hasClusterServer(BridgedDeviceBasicInformation.Cluster.id)) {
543
242
  this.log.debug(`Device with name ${CYAN}${device.deviceName}${db} has no BridgedDeviceBasicInformation cluster. Adding it...`);
544
243
  device.createDefaultBridgedDeviceBasicInformationClusterServer(device.deviceName, device.serialNumber, device.vendorId, device.vendorName, device.productName, device.softwareVersion, device.softwareVersionString, device.hardwareVersion, device.hardwareVersionString);
@@ -547,34 +246,16 @@ export class MatterbridgePlatform {
547
246
  await this.#addBridgedEndpoint?.(this.name, device);
548
247
  this.#registeredEndpoints.set(device.uniqueId, device);
549
248
  }
550
- /**
551
- * Unregisters a device registered with the Matterbridge platform.
552
- *
553
- * @param {MatterbridgeEndpoint} device - The device to unregister.
554
- */
555
249
  async unregisterDevice(device) {
556
250
  assertMatterbridgeEndpoint(device, `MatterbridgePlatform.unregisterDevice for plugin ${this.name}`);
557
251
  await this.#removeBridgedEndpoint?.(this.name, device);
558
252
  if (device.uniqueId)
559
253
  this.#registeredEndpoints.delete(device.uniqueId);
560
254
  }
561
- /**
562
- * Unregisters all devices registered with the Matterbridge platform.
563
- *
564
- * @param {number} [delay] - The delay in milliseconds between removing each bridged endpoint (default: 0).
565
- */
566
255
  async unregisterAllDevices(delay = 0) {
567
256
  await this.#removeAllBridgedEndpoints?.(this.name, delay);
568
257
  this.#registeredEndpoints.clear();
569
258
  }
570
- /**
571
- * Saves the select devices and entities to storage.
572
- *
573
- * This method saves the current state of `selectDevice` and `selectEntity` maps to their respective storage.
574
- * It logs the number of items being saved and ensures that the storage is properly closed after saving.
575
- *
576
- * @returns {Promise<void>} A promise that resolves when the save operation is complete.
577
- */
578
259
  async saveSelects() {
579
260
  if (this.#storage) {
580
261
  this.log.debug(`Saving ${this.#selectDevices.size} selectDevice...`);
@@ -587,60 +268,19 @@ export class MatterbridgePlatform {
587
268
  await selectEntity.close();
588
269
  }
589
270
  }
590
- /**
591
- * Clears all the select device and entity maps and saves the changes to the storage.
592
- *
593
- * @returns {void}
594
- */
595
271
  async clearSelect() {
596
272
  this.#selectDevices.clear();
597
273
  this.#selectEntities.clear();
598
274
  await this.saveSelects();
599
275
  }
600
- /**
601
- * Clears the select for a single device and saves the changes to the storage.
602
- *
603
- * @param {string} serial - The serial of the device to clear.
604
- * @returns {void}
605
- */
606
276
  async clearDeviceSelect(serial) {
607
277
  this.#selectDevices.delete(serial);
608
278
  await this.saveSelects();
609
279
  }
610
- /**
611
- * Clears the select for a single entity and saves the changes to the storage.
612
- *
613
- * @param {string} name - The name of the entity to clear.
614
- * @returns {void}
615
- */
616
280
  async clearEntitySelect(name) {
617
281
  this.#selectEntities.delete(name);
618
282
  await this.saveSelects();
619
283
  }
620
- /**
621
- * Set the select device in the platform map.
622
- *
623
- * @param {string} serial - The serial number of the device.
624
- * @param {string} name - The name of the device.
625
- * @param {string} [configUrl] - The configuration URL of the device.
626
- * @param {string} [icon] - The icon of the device: 'wifi', 'ble', 'hub'
627
- * @param {Array<{ name: string; description: string; icon?: string }>} [entities] - The entities associated with the device.
628
- * @returns {void}
629
- *
630
- * @remarks
631
- * In the schema use selectFrom: 'serial' or 'name'
632
- * ```json
633
- * "whiteList": {
634
- * "description": "Only the devices in the list will be exposed.",
635
- * "type": "array",
636
- * "items": {
637
- * "type": "string"
638
- * },
639
- * "uniqueItems": true,
640
- * "selectFrom": "name"
641
- * },
642
- * ```
643
- */
644
284
  setSelectDevice(serial, name, configUrl, icon, entities) {
645
285
  const device = this.#selectDevices.get(serial);
646
286
  if (device) {
@@ -657,44 +297,9 @@ export class MatterbridgePlatform {
657
297
  this.#selectDevices.set(serial, { serial, name, configUrl, icon, entities });
658
298
  }
659
299
  }
660
- /**
661
- * Retrieve a select device by serial.
662
- *
663
- * @param {string} serial - The serial number of the device.
664
- * @returns {{ serial: string; name: string; configUrl?: string; icon?: string; entities?: { name: string; description: string; icon?: string }[] } | undefined} The select device or undefined if not found.
665
- */
666
300
  getSelectDevice(serial) {
667
301
  return this.#selectDevices.get(serial);
668
302
  }
669
- /**
670
- * Set the select device entity in the platform map.
671
- *
672
- * @param {string} serial - The serial number of the device.
673
- * @param {string} entityName - The name of the entity.
674
- * @param {string} entityDescription - The description of the entity.
675
- * @param {string} [entityIcon] - The icon of the entity: 'wifi', 'ble', 'hub', 'component', 'matter'
676
- * @returns {void}
677
- *
678
- * @remarks
679
- * In the schema use selectDeviceEntityFrom: 'name' or 'description'
680
- * ```json
681
- * "deviceEntityBlackList": {
682
- * "description": "List of entities not to be exposed for a single device.",
683
- * "type": "object",
684
- * "uniqueItems": true,
685
- * "selectFrom": "name",
686
- * "additionalProperties": {
687
- * "description": "List of entities not to be exposed for this device.",
688
- * "type": "array",
689
- * "items": {
690
- * "type": "string"
691
- * },
692
- * "uniqueItems": true,
693
- * "selectDeviceEntityFrom": "name"
694
- * }
695
- * },
696
- * ```
697
- */
698
303
  setSelectDeviceEntity(serial, entityName, entityDescription, entityIcon) {
699
304
  const device = this.#selectDevices.get(serial);
700
305
  if (device) {
@@ -704,11 +309,6 @@ export class MatterbridgePlatform {
704
309
  device.entities.push({ name: entityName, description: entityDescription, icon: entityIcon });
705
310
  }
706
311
  }
707
- /**
708
- * Retrieves the select devices from the platform map.
709
- *
710
- * @returns {ApiSelectDevice[]} The selected devices array.
711
- */
712
312
  getSelectDevices() {
713
313
  const selectDevices = [];
714
314
  for (const device of this.#selectDevices.values()) {
@@ -716,45 +316,12 @@ export class MatterbridgePlatform {
716
316
  }
717
317
  return selectDevices;
718
318
  }
719
- /**
720
- * Set the select entity in the platform map.
721
- *
722
- * @param {string} name - The entity name.
723
- * @param {string} description - The entity description.
724
- * @param {string} [icon] - The entity icon: 'wifi', 'ble', 'hub', 'component', 'matter'
725
- * @returns {void}
726
- *
727
- * @remarks
728
- * In the schema use selectEntityFrom: 'name' or 'description'
729
- * ```json
730
- * "entityBlackList": {
731
- * "description": "The entities in the list will not be exposed.",
732
- * "type": "array",
733
- * "items": {
734
- * "type": "string"
735
- * },
736
- * "uniqueItems": true,
737
- * "selectEntityFrom": "name"
738
- * },
739
- * ```
740
- */
741
319
  setSelectEntity(name, description, icon) {
742
320
  this.#selectEntities.set(name, { name, description, icon });
743
321
  }
744
- /**
745
- * Retrieve a select entity by name.
746
- *
747
- * @param {string} name - The name of the entity.
748
- * @returns {{ name: string; description: string; icon?: string } | undefined} The select entity or undefined if not found.
749
- */
750
322
  getSelectEntity(name) {
751
323
  return this.#selectEntities.get(name);
752
324
  }
753
- /**
754
- * Retrieve the select entities.
755
- *
756
- * @returns {ApiSelectEntity[]} The select entities array.
757
- */
758
325
  getSelectEntities() {
759
326
  const selectEntities = [];
760
327
  for (const entity of this.#selectEntities.values()) {
@@ -762,14 +329,6 @@ export class MatterbridgePlatform {
762
329
  }
763
330
  return selectEntities;
764
331
  }
765
- /**
766
- * Verifies if the Matterbridge version meets the required version.
767
- * If not, it destroys the platform cause the implementation may not call destroy().
768
- *
769
- * @param {string} requiredVersion - The required version to compare against.
770
- * @param {boolean} [destroy] - Whether to destroy the platform if the version check fails. Default is true.
771
- * @returns {boolean} True if the Matterbridge version meets or exceeds the required version, false otherwise.
772
- */
773
332
  verifyMatterbridgeVersion(requiredVersion, destroy = true) {
774
333
  const compareVersions = (matterbridgeVersion, requiredVersion) => {
775
334
  const stripTag = (v) => {
@@ -797,14 +356,6 @@ export class MatterbridgePlatform {
797
356
  }
798
357
  return true;
799
358
  }
800
- /**
801
- * Validates if a device is allowed based on the whitelist and blacklist configurations.
802
- * The blacklist has priority over the whitelist.
803
- *
804
- * @param {string | string[]} device - The device name(s) to validate.
805
- * @param {boolean} [log] - Whether to log the validation result.
806
- * @returns {boolean} - Returns true if the device is allowed, false otherwise.
807
- */
808
359
  validateDevice(device, log = true) {
809
360
  if (!Array.isArray(device))
810
361
  device = [device];
@@ -834,14 +385,6 @@ export class MatterbridgePlatform {
834
385
  this.log.info(`Skipping device ${CYAN}${device.join(', ')}${nf} because not in whitelist`);
835
386
  return false;
836
387
  }
837
- /**
838
- * Validates if an entity is allowed based on the entity blacklist and device-entity blacklist configurations.
839
- *
840
- * @param {string} device - The device to which the entity belongs.
841
- * @param {string} entity - The entity to validate.
842
- * @param {boolean} [log] - Whether to log the validation result.
843
- * @returns {boolean} - Returns true if the entity is allowed, false otherwise.
844
- */
845
388
  validateEntity(device, entity, log = true) {
846
389
  if (isValidArray(this.config.entityBlackList, 1) && this.config.entityBlackList.find((e) => e === entity)) {
847
390
  if (log)
@@ -862,24 +405,10 @@ export class MatterbridgePlatform {
862
405
  }
863
406
  return true;
864
407
  }
865
- /**
866
- * Clears all stored endpoint numbers for checkEndpointNumbers().
867
- *
868
- * @returns {Promise<void>} A promise that resolves when the endpoint numbers have been cleared.
869
- */
870
408
  async clearEndpointNumbers() {
871
409
  const context = await this.#storage.createStorage('endpointNumbers');
872
410
  await context.set('endpointMap', []);
873
411
  }
874
- /**
875
- * Checks and updates the endpoint numbers for Matterbridge devices.
876
- *
877
- * This method retrieves the list of Matterbridge devices and their child endpoints,
878
- * compares their current endpoint numbers with the stored ones, and updates the storage
879
- * if there are any changes. It logs the changes and updates the endpoint numbers accordingly.
880
- *
881
- * @returns {Promise<number>} The size of the updated endpoint map, or -1 if storage is not available.
882
- */
883
412
  async checkEndpointNumbers() {
884
413
  this.log.debug('Checking endpoint numbers...');
885
414
  const context = await this.#storage.createStorage('endpointNumbers');
@@ -918,4 +447,3 @@ export class MatterbridgePlatform {
918
447
  return endpointMap.size;
919
448
  }
920
449
  }
921
- //# sourceMappingURL=matterbridgePlatform.js.map