matterbridge 3.2.9 → 3.2.10-dev-20250928-30c21de

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 (287) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/cli.js +2 -91
  3. package/dist/cliEmitter.js +0 -30
  4. package/dist/clusters/export.js +0 -2
  5. package/dist/defaultConfigSchema.js +0 -24
  6. package/dist/deviceManager.js +1 -94
  7. package/dist/devices/airConditioner.js +0 -57
  8. package/dist/devices/batteryStorage.js +1 -48
  9. package/dist/devices/cooktop.js +0 -55
  10. package/dist/devices/dishwasher.js +0 -57
  11. package/dist/devices/evse.js +10 -74
  12. package/dist/devices/export.js +0 -5
  13. package/dist/devices/extractorHood.js +0 -42
  14. package/dist/devices/heatPump.js +2 -50
  15. package/dist/devices/laundryDryer.js +3 -62
  16. package/dist/devices/laundryWasher.js +4 -70
  17. package/dist/devices/microwaveOven.js +5 -88
  18. package/dist/devices/oven.js +0 -85
  19. package/dist/devices/refrigerator.js +0 -102
  20. package/dist/devices/roboticVacuumCleaner.js +9 -100
  21. package/dist/devices/solarPower.js +0 -38
  22. package/dist/devices/speaker.js +0 -84
  23. package/dist/devices/temperatureControl.js +3 -25
  24. package/dist/devices/waterHeater.js +2 -82
  25. package/dist/dgram/coap.js +13 -126
  26. package/dist/dgram/dgram.js +2 -114
  27. package/dist/dgram/mb_coap.js +3 -41
  28. package/dist/dgram/mb_mdns.js +15 -80
  29. package/dist/dgram/mdns.js +137 -299
  30. package/dist/dgram/multicast.js +1 -62
  31. package/dist/dgram/unicast.js +0 -54
  32. package/dist/frontend.js +27 -417
  33. package/dist/frontendTypes.js +0 -45
  34. package/dist/globalMatterbridge.js +0 -47
  35. package/dist/helpers.js +0 -53
  36. package/dist/index.js +1 -30
  37. package/dist/logger/export.js +0 -1
  38. package/dist/matter/behaviors.js +0 -2
  39. package/dist/matter/clusters.js +0 -2
  40. package/dist/matter/devices.js +0 -2
  41. package/dist/matter/endpoints.js +0 -2
  42. package/dist/matter/export.js +0 -3
  43. package/dist/matter/types.js +0 -3
  44. package/dist/matterbridge.js +52 -785
  45. package/dist/matterbridgeAccessoryPlatform.js +0 -36
  46. package/dist/matterbridgeBehaviors.js +5 -65
  47. package/dist/matterbridgeDeviceTypes.js +17 -630
  48. package/dist/matterbridgeDynamicPlatform.js +0 -36
  49. package/dist/matterbridgeEndpoint.js +58 -1398
  50. package/dist/matterbridgeEndpointHelpers.js +12 -345
  51. package/dist/matterbridgePlatform.js +0 -304
  52. package/dist/matterbridgeTypes.js +0 -25
  53. package/dist/pluginManager.js +3 -249
  54. package/dist/shelly.js +7 -168
  55. package/dist/storage/export.js +0 -1
  56. package/dist/update.js +0 -69
  57. package/dist/utils/colorUtils.js +2 -97
  58. package/dist/utils/commandLine.js +0 -54
  59. package/dist/utils/copyDirectory.js +1 -38
  60. package/dist/utils/createDirectory.js +0 -33
  61. package/dist/utils/createZip.js +2 -47
  62. package/dist/utils/deepCopy.js +0 -39
  63. package/dist/utils/deepEqual.js +1 -72
  64. package/dist/utils/error.js +0 -41
  65. package/dist/utils/export.js +0 -1
  66. package/dist/utils/hex.js +0 -124
  67. package/dist/utils/isvalid.js +0 -101
  68. package/dist/utils/jestHelpers.js +3 -153
  69. package/dist/utils/network.js +5 -91
  70. package/dist/utils/spawn.js +0 -69
  71. package/dist/utils/wait.js +8 -60
  72. package/frontend/build/assets/index.js +7 -7
  73. package/frontend/build/assets/vendor_node_modules.js +19 -19
  74. package/frontend/package-lock.json +115 -100
  75. package/frontend/package.json +9 -9
  76. package/npm-shrinkwrap.json +2 -2
  77. package/package.json +1 -2
  78. package/dist/cli.d.ts +0 -26
  79. package/dist/cli.d.ts.map +0 -1
  80. package/dist/cli.js.map +0 -1
  81. package/dist/cliEmitter.d.ts +0 -34
  82. package/dist/cliEmitter.d.ts.map +0 -1
  83. package/dist/cliEmitter.js.map +0 -1
  84. package/dist/clusters/export.d.ts +0 -2
  85. package/dist/clusters/export.d.ts.map +0 -1
  86. package/dist/clusters/export.js.map +0 -1
  87. package/dist/defaultConfigSchema.d.ts +0 -28
  88. package/dist/defaultConfigSchema.d.ts.map +0 -1
  89. package/dist/defaultConfigSchema.js.map +0 -1
  90. package/dist/deviceManager.d.ts +0 -112
  91. package/dist/deviceManager.d.ts.map +0 -1
  92. package/dist/deviceManager.js.map +0 -1
  93. package/dist/devices/airConditioner.d.ts +0 -98
  94. package/dist/devices/airConditioner.d.ts.map +0 -1
  95. package/dist/devices/airConditioner.js.map +0 -1
  96. package/dist/devices/batteryStorage.d.ts +0 -48
  97. package/dist/devices/batteryStorage.d.ts.map +0 -1
  98. package/dist/devices/batteryStorage.js.map +0 -1
  99. package/dist/devices/cooktop.d.ts +0 -60
  100. package/dist/devices/cooktop.d.ts.map +0 -1
  101. package/dist/devices/cooktop.js.map +0 -1
  102. package/dist/devices/dishwasher.d.ts +0 -71
  103. package/dist/devices/dishwasher.d.ts.map +0 -1
  104. package/dist/devices/dishwasher.js.map +0 -1
  105. package/dist/devices/evse.d.ts +0 -75
  106. package/dist/devices/evse.d.ts.map +0 -1
  107. package/dist/devices/evse.js.map +0 -1
  108. package/dist/devices/export.d.ts +0 -17
  109. package/dist/devices/export.d.ts.map +0 -1
  110. package/dist/devices/export.js.map +0 -1
  111. package/dist/devices/extractorHood.d.ts +0 -46
  112. package/dist/devices/extractorHood.d.ts.map +0 -1
  113. package/dist/devices/extractorHood.js.map +0 -1
  114. package/dist/devices/heatPump.d.ts +0 -47
  115. package/dist/devices/heatPump.d.ts.map +0 -1
  116. package/dist/devices/heatPump.js.map +0 -1
  117. package/dist/devices/laundryDryer.d.ts +0 -67
  118. package/dist/devices/laundryDryer.d.ts.map +0 -1
  119. package/dist/devices/laundryDryer.js.map +0 -1
  120. package/dist/devices/laundryWasher.d.ts +0 -81
  121. package/dist/devices/laundryWasher.d.ts.map +0 -1
  122. package/dist/devices/laundryWasher.js.map +0 -1
  123. package/dist/devices/microwaveOven.d.ts +0 -168
  124. package/dist/devices/microwaveOven.d.ts.map +0 -1
  125. package/dist/devices/microwaveOven.js.map +0 -1
  126. package/dist/devices/oven.d.ts +0 -105
  127. package/dist/devices/oven.d.ts.map +0 -1
  128. package/dist/devices/oven.js.map +0 -1
  129. package/dist/devices/refrigerator.d.ts +0 -118
  130. package/dist/devices/refrigerator.d.ts.map +0 -1
  131. package/dist/devices/refrigerator.js.map +0 -1
  132. package/dist/devices/roboticVacuumCleaner.d.ts +0 -112
  133. package/dist/devices/roboticVacuumCleaner.d.ts.map +0 -1
  134. package/dist/devices/roboticVacuumCleaner.js.map +0 -1
  135. package/dist/devices/solarPower.d.ts +0 -40
  136. package/dist/devices/solarPower.d.ts.map +0 -1
  137. package/dist/devices/solarPower.js.map +0 -1
  138. package/dist/devices/speaker.d.ts +0 -87
  139. package/dist/devices/speaker.d.ts.map +0 -1
  140. package/dist/devices/speaker.js.map +0 -1
  141. package/dist/devices/temperatureControl.d.ts +0 -166
  142. package/dist/devices/temperatureControl.d.ts.map +0 -1
  143. package/dist/devices/temperatureControl.js.map +0 -1
  144. package/dist/devices/waterHeater.d.ts +0 -111
  145. package/dist/devices/waterHeater.d.ts.map +0 -1
  146. package/dist/devices/waterHeater.js.map +0 -1
  147. package/dist/dgram/coap.d.ts +0 -205
  148. package/dist/dgram/coap.d.ts.map +0 -1
  149. package/dist/dgram/coap.js.map +0 -1
  150. package/dist/dgram/dgram.d.ts +0 -141
  151. package/dist/dgram/dgram.d.ts.map +0 -1
  152. package/dist/dgram/dgram.js.map +0 -1
  153. package/dist/dgram/mb_coap.d.ts +0 -24
  154. package/dist/dgram/mb_coap.d.ts.map +0 -1
  155. package/dist/dgram/mb_coap.js.map +0 -1
  156. package/dist/dgram/mb_mdns.d.ts +0 -24
  157. package/dist/dgram/mb_mdns.d.ts.map +0 -1
  158. package/dist/dgram/mb_mdns.js.map +0 -1
  159. package/dist/dgram/mdns.d.ts +0 -290
  160. package/dist/dgram/mdns.d.ts.map +0 -1
  161. package/dist/dgram/mdns.js.map +0 -1
  162. package/dist/dgram/multicast.d.ts +0 -67
  163. package/dist/dgram/multicast.d.ts.map +0 -1
  164. package/dist/dgram/multicast.js.map +0 -1
  165. package/dist/dgram/unicast.d.ts +0 -56
  166. package/dist/dgram/unicast.d.ts.map +0 -1
  167. package/dist/dgram/unicast.js.map +0 -1
  168. package/dist/frontend.d.ts +0 -232
  169. package/dist/frontend.d.ts.map +0 -1
  170. package/dist/frontend.js.map +0 -1
  171. package/dist/frontendTypes.d.ts +0 -514
  172. package/dist/frontendTypes.d.ts.map +0 -1
  173. package/dist/frontendTypes.js.map +0 -1
  174. package/dist/globalMatterbridge.d.ts +0 -59
  175. package/dist/globalMatterbridge.d.ts.map +0 -1
  176. package/dist/globalMatterbridge.js.map +0 -1
  177. package/dist/helpers.d.ts +0 -48
  178. package/dist/helpers.d.ts.map +0 -1
  179. package/dist/helpers.js.map +0 -1
  180. package/dist/index.d.ts +0 -33
  181. package/dist/index.d.ts.map +0 -1
  182. package/dist/index.js.map +0 -1
  183. package/dist/logger/export.d.ts +0 -2
  184. package/dist/logger/export.d.ts.map +0 -1
  185. package/dist/logger/export.js.map +0 -1
  186. package/dist/matter/behaviors.d.ts +0 -2
  187. package/dist/matter/behaviors.d.ts.map +0 -1
  188. package/dist/matter/behaviors.js.map +0 -1
  189. package/dist/matter/clusters.d.ts +0 -2
  190. package/dist/matter/clusters.d.ts.map +0 -1
  191. package/dist/matter/clusters.js.map +0 -1
  192. package/dist/matter/devices.d.ts +0 -2
  193. package/dist/matter/devices.d.ts.map +0 -1
  194. package/dist/matter/devices.js.map +0 -1
  195. package/dist/matter/endpoints.d.ts +0 -2
  196. package/dist/matter/endpoints.d.ts.map +0 -1
  197. package/dist/matter/endpoints.js.map +0 -1
  198. package/dist/matter/export.d.ts +0 -5
  199. package/dist/matter/export.d.ts.map +0 -1
  200. package/dist/matter/export.js.map +0 -1
  201. package/dist/matter/types.d.ts +0 -3
  202. package/dist/matter/types.d.ts.map +0 -1
  203. package/dist/matter/types.js.map +0 -1
  204. package/dist/matterbridge.d.ts +0 -444
  205. package/dist/matterbridge.d.ts.map +0 -1
  206. package/dist/matterbridge.js.map +0 -1
  207. package/dist/matterbridgeAccessoryPlatform.d.ts +0 -42
  208. package/dist/matterbridgeAccessoryPlatform.d.ts.map +0 -1
  209. package/dist/matterbridgeAccessoryPlatform.js.map +0 -1
  210. package/dist/matterbridgeBehaviors.d.ts +0 -1747
  211. package/dist/matterbridgeBehaviors.d.ts.map +0 -1
  212. package/dist/matterbridgeBehaviors.js.map +0 -1
  213. package/dist/matterbridgeDeviceTypes.d.ts +0 -761
  214. package/dist/matterbridgeDeviceTypes.d.ts.map +0 -1
  215. package/dist/matterbridgeDeviceTypes.js.map +0 -1
  216. package/dist/matterbridgeDynamicPlatform.d.ts +0 -42
  217. package/dist/matterbridgeDynamicPlatform.d.ts.map +0 -1
  218. package/dist/matterbridgeDynamicPlatform.js.map +0 -1
  219. package/dist/matterbridgeEndpoint.d.ts +0 -1534
  220. package/dist/matterbridgeEndpoint.d.ts.map +0 -1
  221. package/dist/matterbridgeEndpoint.js.map +0 -1
  222. package/dist/matterbridgeEndpointHelpers.d.ts +0 -407
  223. package/dist/matterbridgeEndpointHelpers.d.ts.map +0 -1
  224. package/dist/matterbridgeEndpointHelpers.js.map +0 -1
  225. package/dist/matterbridgePlatform.d.ts +0 -365
  226. package/dist/matterbridgePlatform.d.ts.map +0 -1
  227. package/dist/matterbridgePlatform.js.map +0 -1
  228. package/dist/matterbridgeTypes.d.ts +0 -197
  229. package/dist/matterbridgeTypes.d.ts.map +0 -1
  230. package/dist/matterbridgeTypes.js.map +0 -1
  231. package/dist/pluginManager.d.ts +0 -270
  232. package/dist/pluginManager.d.ts.map +0 -1
  233. package/dist/pluginManager.js.map +0 -1
  234. package/dist/shelly.d.ts +0 -174
  235. package/dist/shelly.d.ts.map +0 -1
  236. package/dist/shelly.js.map +0 -1
  237. package/dist/storage/export.d.ts +0 -2
  238. package/dist/storage/export.d.ts.map +0 -1
  239. package/dist/storage/export.js.map +0 -1
  240. package/dist/update.d.ts +0 -75
  241. package/dist/update.d.ts.map +0 -1
  242. package/dist/update.js.map +0 -1
  243. package/dist/utils/colorUtils.d.ts +0 -99
  244. package/dist/utils/colorUtils.d.ts.map +0 -1
  245. package/dist/utils/colorUtils.js.map +0 -1
  246. package/dist/utils/commandLine.d.ts +0 -59
  247. package/dist/utils/commandLine.d.ts.map +0 -1
  248. package/dist/utils/commandLine.js.map +0 -1
  249. package/dist/utils/copyDirectory.d.ts +0 -33
  250. package/dist/utils/copyDirectory.d.ts.map +0 -1
  251. package/dist/utils/copyDirectory.js.map +0 -1
  252. package/dist/utils/createDirectory.d.ts +0 -34
  253. package/dist/utils/createDirectory.d.ts.map +0 -1
  254. package/dist/utils/createDirectory.js.map +0 -1
  255. package/dist/utils/createZip.d.ts +0 -39
  256. package/dist/utils/createZip.d.ts.map +0 -1
  257. package/dist/utils/createZip.js.map +0 -1
  258. package/dist/utils/deepCopy.d.ts +0 -32
  259. package/dist/utils/deepCopy.d.ts.map +0 -1
  260. package/dist/utils/deepCopy.js.map +0 -1
  261. package/dist/utils/deepEqual.d.ts +0 -54
  262. package/dist/utils/deepEqual.d.ts.map +0 -1
  263. package/dist/utils/deepEqual.js.map +0 -1
  264. package/dist/utils/error.d.ts +0 -44
  265. package/dist/utils/error.d.ts.map +0 -1
  266. package/dist/utils/error.js.map +0 -1
  267. package/dist/utils/export.d.ts +0 -13
  268. package/dist/utils/export.d.ts.map +0 -1
  269. package/dist/utils/export.js.map +0 -1
  270. package/dist/utils/hex.d.ts +0 -89
  271. package/dist/utils/hex.d.ts.map +0 -1
  272. package/dist/utils/hex.js.map +0 -1
  273. package/dist/utils/isvalid.d.ts +0 -103
  274. package/dist/utils/isvalid.d.ts.map +0 -1
  275. package/dist/utils/isvalid.js.map +0 -1
  276. package/dist/utils/jestHelpers.d.ts +0 -137
  277. package/dist/utils/jestHelpers.d.ts.map +0 -1
  278. package/dist/utils/jestHelpers.js.map +0 -1
  279. package/dist/utils/network.d.ts +0 -84
  280. package/dist/utils/network.d.ts.map +0 -1
  281. package/dist/utils/network.js.map +0 -1
  282. package/dist/utils/spawn.d.ts +0 -34
  283. package/dist/utils/spawn.d.ts.map +0 -1
  284. package/dist/utils/spawn.js.map +0 -1
  285. package/dist/utils/wait.d.ts +0 -54
  286. package/dist/utils/wait.d.ts.map +0 -1
  287. package/dist/utils/wait.js.map +0 -1
@@ -1,54 +1,9 @@
1
- /**
2
- * This file contains the types for WebSocket messages.
3
- *
4
- * @file frontendTypes.ts
5
- * @author Luca Liguori
6
- * @created 2025-09-17
7
- * @version 1.0.0
8
- * @license Apache-2.0
9
- *
10
- * Copyright 2025, 2026, 2027 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
- /**
25
- * Type guard to check if a message is a WsMessageApiRequest.
26
- *
27
- * @param {WsMessage} msg - The message to check.
28
- *
29
- * @returns {msg is WsMessageApiRequest} True if the message is a WsMessageApiRequest, false otherwise.
30
- */
31
1
  export function isApiRequest(msg) {
32
2
  return msg.id !== 0 && msg.src === 'Frontend' && msg.dst === 'Matterbridge';
33
3
  }
34
- /**
35
- * Type guard to check if a message is a WsMessageApiResponse.
36
- *
37
- * @param {WsMessage} msg - The message to check.
38
- *
39
- * @returns {msg is WsMessageApiResponse} True if the message is a WsMessageApiResponse, false otherwise.
40
- */
41
4
  export function isApiResponse(msg) {
42
5
  return msg.id !== 0 && msg.src === 'Matterbridge' && msg.dst === 'Frontend';
43
6
  }
44
- /**
45
- * Type guard to check if a message is a WsMessageBroadcast.
46
- *
47
- * @param {WsMessage} msg - The message to check.
48
- *
49
- * @returns {msg is WsMessageBroadcast} True if the message is a WsMessageBroadcast, false otherwise.
50
- */
51
7
  export function isBroadcast(msg) {
52
8
  return msg.id === 0 && msg.src === 'Matterbridge' && msg.dst === 'Frontend';
53
9
  }
54
- //# sourceMappingURL=frontendTypes.js.map
@@ -1,70 +1,23 @@
1
- /**
2
- * This file contains functions to set and get global instances of Matterbridge, Frontend, and Logger.
3
- *
4
- * @file globalMatterbridge.ts
5
- * @author Luca Liguori
6
- * @created 2025-06-01
7
- * @version 1.0.0
8
- * @license Apache-2.0
9
- *
10
- * Copyright 2025, 2026, 2027 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
- /**
25
- * Store the Matterbridge instance globally for later retrieval.
26
- *
27
- * @param {Matterbridge} matterbridge An initialized Matterbridge instance
28
- */
29
1
  export function setGlobalMatterbridge(matterbridge) {
30
2
  globalThis.__matterbridge__ = matterbridge;
31
3
  globalThis.__frontend__ = matterbridge.frontend;
32
4
  globalThis.__log__ = matterbridge.log;
33
5
  }
34
- /**
35
- * Retrieve the globally stored Matterbridge instance.
36
- *
37
- * @returns {Matterbridge} The Matterbridge instance.
38
- * @throws {Error} If the Matterbridge instance is not set.
39
- */
40
6
  export function getGlobalMatterbridge() {
41
7
  if (!globalThis.__matterbridge__) {
42
8
  throw new Error('Global Matterbridge instance is not set.');
43
9
  }
44
10
  return globalThis.__matterbridge__;
45
11
  }
46
- /**
47
- * Retrieve the globally stored Frontend instance.
48
- *
49
- * @returns {Frontend} The Frontend instance.
50
- * @throws {Error} If the Frontend instance is not set.
51
- */
52
12
  export function getGlobalFrontend() {
53
13
  if (!globalThis.__frontend__) {
54
14
  throw new Error('Global Frontend instance is not set.');
55
15
  }
56
16
  return globalThis.__frontend__;
57
17
  }
58
- /**
59
- * Retrieve the globally stored Logger instance.
60
- *
61
- * @returns {AnsiLogger} The AnsiLogger instance.
62
- * @throws {Error} If the Logger instance is not set.
63
- */
64
18
  export function getGlobalLog() {
65
19
  if (!globalThis.__log__) {
66
20
  throw new Error('Global Logger instance is not set.');
67
21
  }
68
22
  return globalThis.__log__;
69
23
  }
70
- //# sourceMappingURL=globalMatterbridge.js.map
package/dist/helpers.js CHANGED
@@ -1,27 +1,3 @@
1
- /**
2
- * This file contains the helpers functions of Matterbridge.
3
- *
4
- * @file helpers.ts
5
- * @author Luca Liguori
6
- * @created 2025-05-12
7
- * @version 1.0.0
8
- * @license Apache-2.0
9
- *
10
- * Copyright 2025, 2026, 2027 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
- // @matter module
25
1
  import { OnOff } from '@matter/main/clusters/on-off';
26
2
  import { Endpoint } from '@matter/node';
27
3
  import { BridgedDeviceBasicInformationServer } from '@matter/node/behaviors/bridged-device-basic-information';
@@ -30,24 +6,8 @@ import { OnOffPlugInUnitDevice } from '@matter/node/devices/on-off-plug-in-unit'
30
6
  import { MountedOnOffControlDevice } from '@matter/node/devices/mounted-on-off-control';
31
7
  import { OnOffLightDevice } from '@matter/node/devices/on-off-light';
32
8
  import { OnOffLightSwitchDevice } from '@matter/node/devices/on-off-light-switch';
33
- // Matterbridge
34
9
  import { hasParameter } from './utils/commandLine.js';
35
- /**
36
- * Adds a virtual device to the provided endpoint, sets up an event listener for device state changes,
37
- * and ensures the device is initialized in the off state.
38
- *
39
- * @param {Endpoint<AggregatorEndpoint>} aggregatorEndpoint - The aggragator endpoint to which the virtual device will be added.
40
- * @param {string} name - The name of the virtual device. Spaces in the name are removed to form the device ID.
41
- * @param {'light' | 'outlet' | 'switch' | 'mounted_switch'} type - The type of the virtual device. Can be 'light', 'outlet', 'switch', or 'mounted_switch'.
42
- * @param {() => Promise<void>} callback - A callback function that gets executed when the device's on/off state changes to true.
43
- * @returns {Promise<Endpoint>} A promise that resolves with the created virtual device.
44
- * @remarks The virtual device is created as an instance of `Endpoint` with the `OnOffPlugInUnitDevice` device type.
45
- * The onOff state always reverts to false when the device is turned on.
46
- */
47
10
  export async function addVirtualDevice(aggregatorEndpoint, name, type, callback) {
48
- // Create a new virtual device by instantiating `Endpoint` with device information.
49
- // The device ID is created by replacing all spaces in the name with an empty string.
50
- // The node label of the bridged device basic information is set to the given name.
51
11
  let deviceType;
52
12
  switch (type) {
53
13
  case 'light':
@@ -68,9 +28,7 @@ export async function addVirtualDevice(aggregatorEndpoint, name, type, callback)
68
28
  bridgedDeviceBasicInformation: { nodeLabel: name.slice(0, 32) },
69
29
  onOff: { onOff: false, startUpOnOff: OnOff.StartUpOnOff.Off },
70
30
  });
71
- // Set up an event listener for when the `onOff` state changes.
72
31
  device.events.onOff.onOff$Changed.on((value) => {
73
- // If the `onOff` state becomes true, turn off the virtual device and execute the callback.
74
32
  if (value) {
75
33
  callback();
76
34
  process.nextTick(async () => {
@@ -78,24 +36,14 @@ export async function addVirtualDevice(aggregatorEndpoint, name, type, callback)
78
36
  await device.setStateOf(OnOffBaseServer, { onOff: false });
79
37
  }
80
38
  catch (_error) {
81
- // Not necessary to handle the error
82
39
  }
83
40
  });
84
41
  }
85
42
  });
86
- // Add the created device to the given endpoint.
87
43
  await aggregatorEndpoint.add(device);
88
- // Initially set the state of the virtual device's `OnOffBaseServer` to false (off).
89
44
  await device.setStateOf(OnOffBaseServer, { onOff: false });
90
45
  return device;
91
46
  }
92
- /**
93
- * Creates and add the virtual devices to the aggregator.
94
- *
95
- * @param {Matterbridge} matterbridge - The Matterbridge instance.
96
- * @param {Endpoint<AggregatorEndpoint>} aggregatorEndpoint - The aggregator node to add the virtual devices to.
97
- * @returns {Promise<void>} A promise that resolves when the virtual devices are added.
98
- */
99
47
  export async function addVirtualDevices(matterbridge, aggregatorEndpoint) {
100
48
  if (matterbridge.matterbridgeInformation.virtualMode !== 'disabled' && matterbridge.bridgeMode === 'bridge' && aggregatorEndpoint) {
101
49
  matterbridge.log.notice(`Creating virtual devices for Matterbridge server node...`);
@@ -144,4 +92,3 @@ export async function addVirtualDevices(matterbridge, aggregatorEndpoint) {
144
92
  }
145
93
  }
146
94
  }
147
- //# sourceMappingURL=helpers.js.map
package/dist/index.js CHANGED
@@ -1,31 +1,6 @@
1
- /**
2
- * @description This file contains the entry point of Matterbridge.
3
- * @file index.ts
4
- * @author Luca Liguori
5
- * @created 2023-12-29
6
- * @version 1.0.7
7
- * @license Apache-2.0
8
- *
9
- * Copyright 2023, 2024, 2025 Luca Liguori.
10
- *
11
- * Licensed under the Apache License, Version 2.0 (the "License");
12
- * you may not use this file except in compliance with the License.
13
- * You may obtain a copy of the License at
14
- *
15
- * http://www.apache.org/licenses/LICENSE-2.0
16
- *
17
- * Unless required by applicable law or agreed to in writing, software
18
- * distributed under the License is distributed on an "AS IS" BASIS,
19
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
- * See the License for the specific language governing permissions and
21
- * limitations under the License.
22
- */
23
- // AnsiLogger module
24
1
  import { AnsiLogger } from 'node-ansi-logger';
25
- // Matterbridge
26
2
  import { Matterbridge } from './matterbridge.js';
27
3
  import { hasParameter } from './utils/export.js';
28
- // Matterbridge
29
4
  export * from './matterbridge.js';
30
5
  export * from './matterbridgeTypes.js';
31
6
  export * from './matterbridgeEndpoint.js';
@@ -36,10 +11,7 @@ export * from './matterbridgePlatform.js';
36
11
  export * from './matterbridgeAccessoryPlatform.js';
37
12
  export * from './matterbridgeDynamicPlatform.js';
38
13
  export { addVirtualDevice } from './helpers.js';
39
- const log = new AnsiLogger({ logName: 'Main', logTimestampFormat: 4 /* TimestampFormat.TIME_MILLIS */, logLevel: hasParameter('debug') ? "debug" /* LogLevel.DEBUG */ : "info" /* LogLevel.INFO */ });
40
- /**
41
- * Main function to load the Matterbridge instance.
42
- */
14
+ const log = new AnsiLogger({ logName: 'Main', logTimestampFormat: 4, logLevel: hasParameter('debug') ? "debug" : "info" });
43
15
  async function main() {
44
16
  log.debug('***Matterbridge.loadInstance() called');
45
17
  await Matterbridge.loadInstance();
@@ -48,4 +20,3 @@ async function main() {
48
20
  main().catch((error) => {
49
21
  log.error(`Matterbridge.loadInstance() failed with error: ${error instanceof Error ? error.message : error}`);
50
22
  });
51
- //# sourceMappingURL=index.js.map
@@ -1,2 +1 @@
1
1
  export * from 'node-ansi-logger';
2
- //# sourceMappingURL=export.js.map
@@ -1,3 +1 @@
1
- // @matter
2
1
  export * from '@matter/node/behaviors';
3
- //# sourceMappingURL=behaviors.js.map
@@ -1,3 +1 @@
1
- // @matter
2
1
  export * from '@matter/types/clusters';
3
- //# sourceMappingURL=clusters.js.map
@@ -1,3 +1 @@
1
- // @matter
2
1
  export * from '@matter/node/devices';
3
- //# sourceMappingURL=devices.js.map
@@ -1,3 +1 @@
1
- // @matter
2
1
  export { AggregatorEndpoint, ElectricalSensorEndpoint, PowerSourceEndpoint, BridgedNodeEndpoint, RootEndpoint, DeviceEnergyManagementEndpoint, OtaProviderEndpoint, OtaRequestorEndpoint } from '@matter/node/endpoints';
3
- //# sourceMappingURL=endpoints.js.map
@@ -1,7 +1,4 @@
1
- /* eslint-disable import/export */
2
- // @matter
3
1
  export * from '@matter/main';
4
2
  export { SemanticNamespace, ClosureTag, CompassDirectionTag, CompassLocationTag, DirectionTag, ElectricalMeasurementTag, LaundryTag, LevelTag, LocationTag, NumberTag, PositionTag, PowerSourceTag, RefrigeratorTag, RoomAirConditionerTag, SwitchesTag, } from '@matter/main';
5
3
  export { AttributeElement, ClusterElement, ClusterModel, CommandElement, EventElement, FieldElement } from '@matter/main/model';
6
4
  export { MdnsService, Val } from '@matter/main/protocol';
7
- //# sourceMappingURL=export.js.map
@@ -1,5 +1,2 @@
1
- /* eslint-disable import/export */
2
- // @matter
3
1
  export * from '@matter/types';
4
2
  export { ClusterRegistry } from '@matter/types';
5
- //# sourceMappingURL=types.js.map