@matterbridge/core 3.5.3

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 (295) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +22 -0
  3. package/dist/cli.d.ts +29 -0
  4. package/dist/cli.d.ts.map +1 -0
  5. package/dist/cli.js +268 -0
  6. package/dist/cli.js.map +1 -0
  7. package/dist/cliEmitter.d.ts +50 -0
  8. package/dist/cliEmitter.d.ts.map +1 -0
  9. package/dist/cliEmitter.js +49 -0
  10. package/dist/cliEmitter.js.map +1 -0
  11. package/dist/cliHistory.d.ts +48 -0
  12. package/dist/cliHistory.d.ts.map +1 -0
  13. package/dist/cliHistory.js +826 -0
  14. package/dist/cliHistory.js.map +1 -0
  15. package/dist/clusters/export.d.ts +2 -0
  16. package/dist/clusters/export.d.ts.map +1 -0
  17. package/dist/clusters/export.js +3 -0
  18. package/dist/clusters/export.js.map +1 -0
  19. package/dist/crypto/attestationDecoder.d.ts +180 -0
  20. package/dist/crypto/attestationDecoder.d.ts.map +1 -0
  21. package/dist/crypto/attestationDecoder.js +176 -0
  22. package/dist/crypto/attestationDecoder.js.map +1 -0
  23. package/dist/crypto/declarationDecoder.d.ts +72 -0
  24. package/dist/crypto/declarationDecoder.d.ts.map +1 -0
  25. package/dist/crypto/declarationDecoder.js +241 -0
  26. package/dist/crypto/declarationDecoder.js.map +1 -0
  27. package/dist/crypto/extract/342/200/220cert/342/200/220extensions.d.ts +9 -0
  28. package/dist/crypto/extract/342/200/220cert/342/200/220extensions.d.ts.map +1 -0
  29. package/dist/crypto/extract/342/200/220cert/342/200/220extensions.js +120 -0
  30. package/dist/crypto/extract/342/200/220cert/342/200/220extensions.js.map +1 -0
  31. package/dist/crypto/read-extensions.d.ts +2 -0
  32. package/dist/crypto/read-extensions.d.ts.map +1 -0
  33. package/dist/crypto/read-extensions.js +81 -0
  34. package/dist/crypto/read-extensions.js.map +1 -0
  35. package/dist/crypto/testData.d.ts +31 -0
  36. package/dist/crypto/testData.d.ts.map +1 -0
  37. package/dist/crypto/testData.js +131 -0
  38. package/dist/crypto/testData.js.map +1 -0
  39. package/dist/crypto/walk-der.d.ts +2 -0
  40. package/dist/crypto/walk-der.d.ts.map +1 -0
  41. package/dist/crypto/walk-der.js +165 -0
  42. package/dist/crypto/walk-der.js.map +1 -0
  43. package/dist/deviceManager.d.ts +135 -0
  44. package/dist/deviceManager.d.ts.map +1 -0
  45. package/dist/deviceManager.js +270 -0
  46. package/dist/deviceManager.js.map +1 -0
  47. package/dist/devices/airConditioner.d.ts +98 -0
  48. package/dist/devices/airConditioner.d.ts.map +1 -0
  49. package/dist/devices/airConditioner.js +74 -0
  50. package/dist/devices/airConditioner.js.map +1 -0
  51. package/dist/devices/basicVideoPlayer.d.ts +88 -0
  52. package/dist/devices/basicVideoPlayer.d.ts.map +1 -0
  53. package/dist/devices/basicVideoPlayer.js +155 -0
  54. package/dist/devices/basicVideoPlayer.js.map +1 -0
  55. package/dist/devices/batteryStorage.d.ts +48 -0
  56. package/dist/devices/batteryStorage.d.ts.map +1 -0
  57. package/dist/devices/batteryStorage.js +75 -0
  58. package/dist/devices/batteryStorage.js.map +1 -0
  59. package/dist/devices/castingVideoPlayer.d.ts +79 -0
  60. package/dist/devices/castingVideoPlayer.d.ts.map +1 -0
  61. package/dist/devices/castingVideoPlayer.js +101 -0
  62. package/dist/devices/castingVideoPlayer.js.map +1 -0
  63. package/dist/devices/cooktop.d.ts +61 -0
  64. package/dist/devices/cooktop.d.ts.map +1 -0
  65. package/dist/devices/cooktop.js +77 -0
  66. package/dist/devices/cooktop.js.map +1 -0
  67. package/dist/devices/dishwasher.d.ts +71 -0
  68. package/dist/devices/dishwasher.d.ts.map +1 -0
  69. package/dist/devices/dishwasher.js +130 -0
  70. package/dist/devices/dishwasher.js.map +1 -0
  71. package/dist/devices/evse.d.ts +76 -0
  72. package/dist/devices/evse.d.ts.map +1 -0
  73. package/dist/devices/evse.js +156 -0
  74. package/dist/devices/evse.js.map +1 -0
  75. package/dist/devices/export.d.ts +19 -0
  76. package/dist/devices/export.d.ts.map +1 -0
  77. package/dist/devices/export.js +23 -0
  78. package/dist/devices/export.js.map +1 -0
  79. package/dist/devices/extractorHood.d.ts +46 -0
  80. package/dist/devices/extractorHood.d.ts.map +1 -0
  81. package/dist/devices/extractorHood.js +78 -0
  82. package/dist/devices/extractorHood.js.map +1 -0
  83. package/dist/devices/heatPump.d.ts +47 -0
  84. package/dist/devices/heatPump.d.ts.map +1 -0
  85. package/dist/devices/heatPump.js +84 -0
  86. package/dist/devices/heatPump.js.map +1 -0
  87. package/dist/devices/laundryDryer.d.ts +67 -0
  88. package/dist/devices/laundryDryer.d.ts.map +1 -0
  89. package/dist/devices/laundryDryer.js +106 -0
  90. package/dist/devices/laundryDryer.js.map +1 -0
  91. package/dist/devices/laundryWasher.d.ts +81 -0
  92. package/dist/devices/laundryWasher.d.ts.map +1 -0
  93. package/dist/devices/laundryWasher.js +147 -0
  94. package/dist/devices/laundryWasher.js.map +1 -0
  95. package/dist/devices/microwaveOven.d.ts +168 -0
  96. package/dist/devices/microwaveOven.d.ts.map +1 -0
  97. package/dist/devices/microwaveOven.js +179 -0
  98. package/dist/devices/microwaveOven.js.map +1 -0
  99. package/dist/devices/oven.d.ts +105 -0
  100. package/dist/devices/oven.d.ts.map +1 -0
  101. package/dist/devices/oven.js +190 -0
  102. package/dist/devices/oven.js.map +1 -0
  103. package/dist/devices/refrigerator.d.ts +118 -0
  104. package/dist/devices/refrigerator.d.ts.map +1 -0
  105. package/dist/devices/refrigerator.js +186 -0
  106. package/dist/devices/refrigerator.js.map +1 -0
  107. package/dist/devices/roboticVacuumCleaner.d.ts +112 -0
  108. package/dist/devices/roboticVacuumCleaner.d.ts.map +1 -0
  109. package/dist/devices/roboticVacuumCleaner.js +268 -0
  110. package/dist/devices/roboticVacuumCleaner.js.map +1 -0
  111. package/dist/devices/solarPower.d.ts +40 -0
  112. package/dist/devices/solarPower.d.ts.map +1 -0
  113. package/dist/devices/solarPower.js +59 -0
  114. package/dist/devices/solarPower.js.map +1 -0
  115. package/dist/devices/speaker.d.ts +87 -0
  116. package/dist/devices/speaker.d.ts.map +1 -0
  117. package/dist/devices/speaker.js +120 -0
  118. package/dist/devices/speaker.js.map +1 -0
  119. package/dist/devices/temperatureControl.d.ts +166 -0
  120. package/dist/devices/temperatureControl.d.ts.map +1 -0
  121. package/dist/devices/temperatureControl.js +78 -0
  122. package/dist/devices/temperatureControl.js.map +1 -0
  123. package/dist/devices/waterHeater.d.ts +111 -0
  124. package/dist/devices/waterHeater.d.ts.map +1 -0
  125. package/dist/devices/waterHeater.js +166 -0
  126. package/dist/devices/waterHeater.js.map +1 -0
  127. package/dist/dgram/export.d.ts +2 -0
  128. package/dist/dgram/export.d.ts.map +1 -0
  129. package/dist/dgram/export.js +2 -0
  130. package/dist/dgram/export.js.map +1 -0
  131. package/dist/export.d.ts +32 -0
  132. package/dist/export.d.ts.map +1 -0
  133. package/dist/export.js +39 -0
  134. package/dist/export.js.map +1 -0
  135. package/dist/frontend.d.ts +248 -0
  136. package/dist/frontend.d.ts.map +1 -0
  137. package/dist/frontend.js +2605 -0
  138. package/dist/frontend.js.map +1 -0
  139. package/dist/helpers.d.ts +48 -0
  140. package/dist/helpers.d.ts.map +1 -0
  141. package/dist/helpers.js +161 -0
  142. package/dist/helpers.js.map +1 -0
  143. package/dist/jestutils/export.d.ts +2 -0
  144. package/dist/jestutils/export.d.ts.map +1 -0
  145. package/dist/jestutils/export.js +2 -0
  146. package/dist/jestutils/export.js.map +1 -0
  147. package/dist/jestutils/jestHelpers.d.ts +349 -0
  148. package/dist/jestutils/jestHelpers.d.ts.map +1 -0
  149. package/dist/jestutils/jestHelpers.js +980 -0
  150. package/dist/jestutils/jestHelpers.js.map +1 -0
  151. package/dist/matter/behaviors.d.ts +2 -0
  152. package/dist/matter/behaviors.d.ts.map +1 -0
  153. package/dist/matter/behaviors.js +3 -0
  154. package/dist/matter/behaviors.js.map +1 -0
  155. package/dist/matter/clusters.d.ts +2 -0
  156. package/dist/matter/clusters.d.ts.map +1 -0
  157. package/dist/matter/clusters.js +3 -0
  158. package/dist/matter/clusters.js.map +1 -0
  159. package/dist/matter/devices.d.ts +2 -0
  160. package/dist/matter/devices.d.ts.map +1 -0
  161. package/dist/matter/devices.js +3 -0
  162. package/dist/matter/devices.js.map +1 -0
  163. package/dist/matter/endpoints.d.ts +2 -0
  164. package/dist/matter/endpoints.d.ts.map +1 -0
  165. package/dist/matter/endpoints.js +3 -0
  166. package/dist/matter/endpoints.js.map +1 -0
  167. package/dist/matter/export.d.ts +4 -0
  168. package/dist/matter/export.d.ts.map +1 -0
  169. package/dist/matter/export.js +5 -0
  170. package/dist/matter/export.js.map +1 -0
  171. package/dist/matter/types.d.ts +2 -0
  172. package/dist/matter/types.d.ts.map +1 -0
  173. package/dist/matter/types.js +3 -0
  174. package/dist/matter/types.js.map +1 -0
  175. package/dist/matterNode.d.ts +341 -0
  176. package/dist/matterNode.d.ts.map +1 -0
  177. package/dist/matterNode.js +1329 -0
  178. package/dist/matterNode.js.map +1 -0
  179. package/dist/matterbridge.d.ts +544 -0
  180. package/dist/matterbridge.d.ts.map +1 -0
  181. package/dist/matterbridge.js +2880 -0
  182. package/dist/matterbridge.js.map +1 -0
  183. package/dist/matterbridgeAccessoryPlatform.d.ts +49 -0
  184. package/dist/matterbridgeAccessoryPlatform.d.ts.map +1 -0
  185. package/dist/matterbridgeAccessoryPlatform.js +80 -0
  186. package/dist/matterbridgeAccessoryPlatform.js.map +1 -0
  187. package/dist/matterbridgeBehaviors.d.ts +2428 -0
  188. package/dist/matterbridgeBehaviors.d.ts.map +1 -0
  189. package/dist/matterbridgeBehaviors.js +620 -0
  190. package/dist/matterbridgeBehaviors.js.map +1 -0
  191. package/dist/matterbridgeDeviceTypes.d.ts +744 -0
  192. package/dist/matterbridgeDeviceTypes.d.ts.map +1 -0
  193. package/dist/matterbridgeDeviceTypes.js +1312 -0
  194. package/dist/matterbridgeDeviceTypes.js.map +1 -0
  195. package/dist/matterbridgeDynamicPlatform.d.ts +49 -0
  196. package/dist/matterbridgeDynamicPlatform.d.ts.map +1 -0
  197. package/dist/matterbridgeDynamicPlatform.js +80 -0
  198. package/dist/matterbridgeDynamicPlatform.js.map +1 -0
  199. package/dist/matterbridgeEndpoint.d.ts +1548 -0
  200. package/dist/matterbridgeEndpoint.d.ts.map +1 -0
  201. package/dist/matterbridgeEndpoint.js +2883 -0
  202. package/dist/matterbridgeEndpoint.js.map +1 -0
  203. package/dist/matterbridgeEndpointHelpers.d.ts +1855 -0
  204. package/dist/matterbridgeEndpointHelpers.d.ts.map +1 -0
  205. package/dist/matterbridgeEndpointHelpers.js +1270 -0
  206. package/dist/matterbridgeEndpointHelpers.js.map +1 -0
  207. package/dist/matterbridgeEndpointTypes.d.ts +172 -0
  208. package/dist/matterbridgeEndpointTypes.d.ts.map +1 -0
  209. package/dist/matterbridgeEndpointTypes.js +28 -0
  210. package/dist/matterbridgeEndpointTypes.js.map +1 -0
  211. package/dist/matterbridgePlatform.d.ts +520 -0
  212. package/dist/matterbridgePlatform.d.ts.map +1 -0
  213. package/dist/matterbridgePlatform.js +921 -0
  214. package/dist/matterbridgePlatform.js.map +1 -0
  215. package/dist/mb_coap.d.ts +24 -0
  216. package/dist/mb_coap.d.ts.map +1 -0
  217. package/dist/mb_coap.js +89 -0
  218. package/dist/mb_coap.js.map +1 -0
  219. package/dist/mb_health.d.ts +77 -0
  220. package/dist/mb_health.d.ts.map +1 -0
  221. package/dist/mb_health.js +147 -0
  222. package/dist/mb_health.js.map +1 -0
  223. package/dist/mb_mdns.d.ts +24 -0
  224. package/dist/mb_mdns.d.ts.map +1 -0
  225. package/dist/mb_mdns.js +285 -0
  226. package/dist/mb_mdns.js.map +1 -0
  227. package/dist/pluginManager.d.ts +388 -0
  228. package/dist/pluginManager.d.ts.map +1 -0
  229. package/dist/pluginManager.js +1574 -0
  230. package/dist/pluginManager.js.map +1 -0
  231. package/dist/spawn.d.ts +33 -0
  232. package/dist/spawn.d.ts.map +1 -0
  233. package/dist/spawn.js +165 -0
  234. package/dist/spawn.js.map +1 -0
  235. package/dist/utils/export.d.ts +2 -0
  236. package/dist/utils/export.d.ts.map +1 -0
  237. package/dist/utils/export.js +2 -0
  238. package/dist/utils/export.js.map +1 -0
  239. package/dist/workers/brand.d.ts +25 -0
  240. package/dist/workers/brand.d.ts.map +1 -0
  241. package/dist/workers/brand.extend.d.ts +10 -0
  242. package/dist/workers/brand.extend.d.ts.map +1 -0
  243. package/dist/workers/brand.extend.js +15 -0
  244. package/dist/workers/brand.extend.js.map +1 -0
  245. package/dist/workers/brand.invalid.d.ts +9 -0
  246. package/dist/workers/brand.invalid.d.ts.map +1 -0
  247. package/dist/workers/brand.invalid.js +19 -0
  248. package/dist/workers/brand.invalid.js.map +1 -0
  249. package/dist/workers/brand.js +67 -0
  250. package/dist/workers/brand.js.map +1 -0
  251. package/dist/workers/clusterTypes.d.ts +47 -0
  252. package/dist/workers/clusterTypes.d.ts.map +1 -0
  253. package/dist/workers/clusterTypes.js +57 -0
  254. package/dist/workers/clusterTypes.js.map +1 -0
  255. package/dist/workers/frontendWorker.d.ts +2 -0
  256. package/dist/workers/frontendWorker.d.ts.map +1 -0
  257. package/dist/workers/frontendWorker.js +90 -0
  258. package/dist/workers/frontendWorker.js.map +1 -0
  259. package/dist/workers/helloWorld.d.ts +2 -0
  260. package/dist/workers/helloWorld.d.ts.map +1 -0
  261. package/dist/workers/helloWorld.js +135 -0
  262. package/dist/workers/helloWorld.js.map +1 -0
  263. package/dist/workers/matterWorker.d.ts +2 -0
  264. package/dist/workers/matterWorker.d.ts.map +1 -0
  265. package/dist/workers/matterWorker.js +104 -0
  266. package/dist/workers/matterWorker.js.map +1 -0
  267. package/dist/workers/matterbridgeWorker.d.ts +2 -0
  268. package/dist/workers/matterbridgeWorker.d.ts.map +1 -0
  269. package/dist/workers/matterbridgeWorker.js +75 -0
  270. package/dist/workers/matterbridgeWorker.js.map +1 -0
  271. package/dist/workers/messageLab.d.ts +134 -0
  272. package/dist/workers/messageLab.d.ts.map +1 -0
  273. package/dist/workers/messageLab.js +129 -0
  274. package/dist/workers/messageLab.js.map +1 -0
  275. package/dist/workers/testWorker.d.ts +2 -0
  276. package/dist/workers/testWorker.d.ts.map +1 -0
  277. package/dist/workers/testWorker.js +45 -0
  278. package/dist/workers/testWorker.js.map +1 -0
  279. package/dist/workers/usage.d.ts +19 -0
  280. package/dist/workers/usage.d.ts.map +1 -0
  281. package/dist/workers/usage.js +140 -0
  282. package/dist/workers/usage.js.map +1 -0
  283. package/dist/workers/workerManager.d.ts +115 -0
  284. package/dist/workers/workerManager.d.ts.map +1 -0
  285. package/dist/workers/workerManager.js +464 -0
  286. package/dist/workers/workerManager.js.map +1 -0
  287. package/dist/workers/workerServer.d.ts +126 -0
  288. package/dist/workers/workerServer.d.ts.map +1 -0
  289. package/dist/workers/workerServer.js +340 -0
  290. package/dist/workers/workerServer.js.map +1 -0
  291. package/dist/workers/workerTypes.d.ts +23 -0
  292. package/dist/workers/workerTypes.d.ts.map +1 -0
  293. package/dist/workers/workerTypes.js +3 -0
  294. package/dist/workers/workerTypes.js.map +1 -0
  295. package/package.json +120 -0
@@ -0,0 +1,270 @@
1
+ /**
2
+ * This file contains the DeviceManager class.
3
+ *
4
+ * @file devices.ts
5
+ * @author Luca Liguori
6
+ * @created 2024-07-26
7
+ * @version 1.1.2
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
+ // AnsiLogger module
25
+ import { AnsiLogger, BLUE, CYAN, db, debugStringify, er } from 'node-ansi-logger';
26
+ // @matterbridge
27
+ import { hasParameter } from '@matterbridge/utils';
28
+ import { dev } from '@matterbridge/types';
29
+ import { BroadcastServer } from '@matterbridge/thread';
30
+ /**
31
+ * Converts a MatterbridgeEndpoint to a BaseDevice.
32
+ *
33
+ * @param {MatterbridgeEndpoint} device The MatterbridgeEndpoint to convert.
34
+ * @returns {BaseDevice} The converted BaseDevice.
35
+ */
36
+ export function toBaseDevice(device) {
37
+ return {
38
+ // MatterbridgeEndpoint properties
39
+ mode: device.mode,
40
+ plugin: device.plugin,
41
+ configUrl: device.configUrl,
42
+ deviceName: device.deviceName,
43
+ serialNumber: device.serialNumber,
44
+ uniqueId: device.uniqueId,
45
+ vendorId: device.vendorId,
46
+ vendorName: device.vendorName,
47
+ productId: device.productId,
48
+ productName: device.productName,
49
+ softwareVersion: device.softwareVersion,
50
+ softwareVersionString: device.softwareVersionString,
51
+ hardwareVersion: device.hardwareVersion,
52
+ hardwareVersionString: device.hardwareVersionString,
53
+ productUrl: device.productUrl,
54
+ tagList: device.tagList,
55
+ originalId: device.originalId,
56
+ name: device.name,
57
+ deviceType: device.deviceType,
58
+ // Endpoint properties
59
+ number: device.number,
60
+ id: device.id,
61
+ };
62
+ }
63
+ /**
64
+ * Manages Matterbridge devices.
65
+ */
66
+ export class DeviceManager {
67
+ _devices = new Map();
68
+ log;
69
+ server;
70
+ debug = hasParameter('debug') || hasParameter('verbose');
71
+ verbose = hasParameter('verbose');
72
+ /**
73
+ * Creates an instance of DeviceManager.
74
+ */
75
+ constructor() {
76
+ this.log = new AnsiLogger({ logName: 'DeviceManager', logTimestampFormat: 4 /* TimestampFormat.TIME_MILLIS */, logLevel: hasParameter('debug') ? "debug" /* LogLevel.DEBUG */ : "info" /* LogLevel.INFO */ });
77
+ this.log.debug('Matterbridge device manager starting...');
78
+ this.server = new BroadcastServer('devices', this.log);
79
+ this.server.on('broadcast_message', this.msgHandler.bind(this));
80
+ this.log.debug('Matterbridge device manager started');
81
+ }
82
+ destroy() {
83
+ this.server.off('broadcast_message', this.msgHandler.bind(this));
84
+ this.server.close();
85
+ }
86
+ async msgHandler(msg) {
87
+ if (this.server.isWorkerRequest(msg)) {
88
+ if (this.verbose)
89
+ this.log.debug(`Received request message ${CYAN}${msg.type}${db} from ${CYAN}${msg.src}${db}: ${debugStringify(msg)}${db}`);
90
+ switch (msg.type) {
91
+ case 'get_log_level':
92
+ this.server.respond({ ...msg, result: { logLevel: this.log.logLevel } });
93
+ break;
94
+ case 'set_log_level':
95
+ this.log.logLevel = msg.params.logLevel;
96
+ this.server.respond({ ...msg, result: { logLevel: this.log.logLevel } });
97
+ break;
98
+ case 'devices_length':
99
+ this.server.respond({ ...msg, result: { length: this.length } });
100
+ break;
101
+ case 'devices_size':
102
+ this.server.respond({ ...msg, result: { size: this.size } });
103
+ break;
104
+ case 'devices_has':
105
+ this.server.respond({ ...msg, result: { has: this.has(msg.params.uniqueId) } });
106
+ break;
107
+ case 'devices_get':
108
+ {
109
+ const endpoint = this.get(msg.params.uniqueId);
110
+ this.server.respond({ ...msg, result: { device: endpoint ? toBaseDevice(endpoint) : undefined } });
111
+ }
112
+ break;
113
+ case 'devices_set':
114
+ this.server.respond({ ...msg, result: { device: this.set(toBaseDevice(msg.params.device)) } });
115
+ break;
116
+ case 'devices_remove':
117
+ this.server.respond({ ...msg, result: { success: this.remove(toBaseDevice(msg.params.device)) } });
118
+ break;
119
+ case 'devices_clear':
120
+ this.clear();
121
+ this.server.respond({ ...msg, result: { success: true } });
122
+ break;
123
+ case 'devices_basearray':
124
+ this.server.respond({ ...msg, result: { devices: this.baseArray(msg.params.pluginName) } });
125
+ break;
126
+ default:
127
+ if (this.verbose)
128
+ this.log.debug(`Unknown broadcast message ${CYAN}${msg.type}${db} from ${CYAN}${msg.src}${db}`);
129
+ }
130
+ }
131
+ }
132
+ /**
133
+ * Gets the number of devices.
134
+ *
135
+ * @returns {number} The number of devices.
136
+ */
137
+ get length() {
138
+ return this._devices.size;
139
+ }
140
+ /**
141
+ * Gets the number of devices.
142
+ *
143
+ * @returns {number} The number of devices.
144
+ */
145
+ get size() {
146
+ return this._devices.size;
147
+ }
148
+ /**
149
+ * Checks if a device with the specified unique ID exists.
150
+ *
151
+ * @param {string} uniqueId - The unique ID of the device.
152
+ * @returns {boolean} True if the device exists, false otherwise.
153
+ */
154
+ has(uniqueId) {
155
+ return this._devices.has(uniqueId);
156
+ }
157
+ /**
158
+ * Gets a device by its unique ID.
159
+ *
160
+ * @param {string} uniqueId - The unique ID of the device.
161
+ * @returns {MatterbridgeEndpoint | undefined} The device, or undefined if not found.
162
+ */
163
+ get(uniqueId) {
164
+ return this._devices.get(uniqueId);
165
+ }
166
+ /**
167
+ * Adds a device to the manager.
168
+ *
169
+ * @param {MatterbridgeEndpoint} device - The device to add.
170
+ * @returns {MatterbridgeEndpoint} The added device.
171
+ * @throws {Error} If the device does not have a unique ID.
172
+ */
173
+ set(device) {
174
+ if (!device.uniqueId)
175
+ throw new Error(`The device ${dev}${device.deviceName}${er} has not been initialized: uniqueId is required`);
176
+ if (this._devices.has(device.uniqueId))
177
+ this.log.error(`The device ${dev}${device.deviceName}${er} with uniqueId ${BLUE}${device.uniqueId}${er} serialNumber ${BLUE}${device.serialNumber}${er} is already in the device manager`);
178
+ this._devices.set(device.uniqueId, device);
179
+ return device;
180
+ }
181
+ /**
182
+ * Removes a device from the manager.
183
+ *
184
+ * @param {MatterbridgeEndpoint} device - The device to remove.
185
+ * @returns {boolean} True if the device was removed, false otherwise.
186
+ * @throws {Error} If the device does not have a unique ID.
187
+ */
188
+ remove(device) {
189
+ if (!device.uniqueId)
190
+ throw new Error(`The device ${dev}${device.deviceName}${er} has not been initialized: uniqueId is required`);
191
+ if (!this._devices.has(device.uniqueId))
192
+ this.log.error(`The device ${dev}${device.deviceName}${er} with uniqueId ${BLUE}${device.uniqueId}${er} serialNumber ${BLUE}${device.serialNumber}${er} is not registered in the device manager`);
193
+ return this._devices.delete(device.uniqueId);
194
+ }
195
+ /**
196
+ * Clears all devices from the manager.
197
+ */
198
+ clear() {
199
+ this._devices.clear();
200
+ }
201
+ /**
202
+ * Converts a MatterbridgeEndpoint to a BaseDevice.
203
+ *
204
+ * @param {MatterbridgeEndpoint} device The MatterbridgeEndpoint to convert.
205
+ * @returns {BaseDevice} The converted BaseDevice.
206
+ */
207
+ toBaseDevice(device) {
208
+ return toBaseDevice(device);
209
+ }
210
+ /**
211
+ * Gets an array of all devices.
212
+ *
213
+ * @returns {MatterbridgeEndpoint[]} An array of all devices.
214
+ */
215
+ array() {
216
+ return Array.from(this._devices.values());
217
+ }
218
+ /**
219
+ * Gets a base array of all devices suitable for serialization.
220
+ *
221
+ * @param {string} [pluginName] - Optional plugin name to filter devices.
222
+ * @returns {ApiDevices[]} A base array of all devices.
223
+ */
224
+ baseArray(pluginName) {
225
+ const devices = [];
226
+ for (const device of Array.from(this._devices.values())) {
227
+ // Filter by pluginName if provided
228
+ if (pluginName && pluginName !== device.plugin)
229
+ continue;
230
+ devices.push(this.toBaseDevice(device));
231
+ }
232
+ return devices;
233
+ }
234
+ /**
235
+ * Iterates over all devices.
236
+ *
237
+ * @returns {IterableIterator<MatterbridgeEndpoint>} An iterator for the devices.
238
+ */
239
+ [Symbol.iterator]() {
240
+ return this._devices.values();
241
+ }
242
+ /**
243
+ * Asynchronously iterates over each device and calls the provided callback function.
244
+ *
245
+ * @param {(device: MatterbridgeEndpoint) => Promise<void>} callback - The callback function to call with each device.
246
+ * @returns {Promise<void>} A promise that resolves when all callbacks have been called.
247
+ */
248
+ async forEach(callback) {
249
+ if (this.size === 0)
250
+ return;
251
+ const tasks = Array.from(this._devices.values()).map(async (device) => {
252
+ try {
253
+ await callback(device);
254
+ }
255
+ catch (error) {
256
+ this.log.error(`Error processing forEach device ${dev}${device.deviceName}${er} serialNumber ${BLUE}${device.serialNumber}${er} uniqueId: ${BLUE}${device.uniqueId}${er}:`, error);
257
+ }
258
+ });
259
+ await Promise.all(tasks);
260
+ }
261
+ /**
262
+ * Sets the log level.
263
+ *
264
+ * @param {LogLevel} logLevel - The log level to set.
265
+ */
266
+ set logLevel(logLevel) {
267
+ this.log.logLevel = logLevel;
268
+ }
269
+ }
270
+ //# sourceMappingURL=deviceManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deviceManager.js","sourceRoot":"","sources":["../src/deviceManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,oBAAoB;AACpB,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,cAAc,EAAE,EAAE,EAA6B,MAAM,kBAAkB,CAAC;AAC7G,gBAAgB;AAChB,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAE1C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAKvD;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,MAAyC;IACpE,OAAO;QACL,kCAAkC;QAClC,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,YAAY,EAAE,MAAM,CAAC,YAAY;QACjC,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,eAAe,EAAE,MAAM,CAAC,eAAe;QACvC,qBAAqB,EAAE,MAAM,CAAC,qBAAqB;QACnD,eAAe,EAAE,MAAM,CAAC,eAAe;QACvC,qBAAqB,EAAE,MAAM,CAA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
+ * @file src/devices/airConditioner.ts
4
+ * @author Luca Liguori
5
+ * @created 2025-09-04
6
+ * @version 1.0.0
7
+ * @license Apache-2.0
8
+ *
9
+ * Copyright 2025, 2026, 2027 Luca Liguori.
10
+ *
11
+ * Licensed under the Apache License, Version 2.0 (the "License");
12
+ * you may not use this file except in compliance with the License.
13
+ * You may obtain a copy of the License at
14
+ *
15
+ * http://www.apache.org/licenses/LICENSE-2.0
16
+ *
17
+ * Unless required by applicable law or agreed to in writing, software
18
+ * distributed under the License is distributed on an "AS IS" BASIS,
19
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
+ * See the License for the specific language governing permissions and
21
+ * limitations under the License.
22
+ */
23
+ import { ThermostatUserInterfaceConfiguration } from '@matter/types/clusters/thermostat-user-interface-configuration';
24
+ import { FanControl } from '@matter/types/clusters/fan-control';
25
+ import { MatterbridgeEndpoint } from '../matterbridgeEndpoint.js';
26
+ /**
27
+ * Options for configuring an {@link AirConditioner} instance.
28
+ *
29
+ * All temperatures in °C. Typical valid range 0–50 unless otherwise noted.
30
+ */
31
+ export interface AirConditionerOptions {
32
+ /** Local ambient temperature (°C). Default 23. */
33
+ localTemperature?: number;
34
+ /** Occupied heating setpoint (°C). Default 21. */
35
+ occupiedHeatingSetpoint?: number;
36
+ /** Occupied cooling setpoint (°C). Default 25. */
37
+ occupiedCoolingSetpoint?: number;
38
+ /** Minimum setpoint dead band (°C). Default 1. */
39
+ minSetpointDeadBand?: number;
40
+ /** Minimum heat setpoint limit (°C). Default 0. */
41
+ minHeatSetpointLimit?: number;
42
+ /** Maximum heat setpoint limit (°C). Default 50. */
43
+ maxHeatSetpointLimit?: number;
44
+ /** Minimum cool setpoint limit (°C). Default 0. */
45
+ minCoolSetpointLimit?: number;
46
+ /** Maximum cool setpoint limit (°C). Default 50. */
47
+ maxCoolSetpointLimit?: number;
48
+ /** Temperature display mode. Default Celsius. */
49
+ temperatureDisplayMode?: ThermostatUserInterfaceConfiguration.TemperatureDisplayMode;
50
+ /** Keypad lockout mode. Default NoLockout. */
51
+ keypadLockout?: ThermostatUserInterfaceConfiguration.KeypadLockout;
52
+ /** Schedule programming visibility. Default ScheduleProgrammingPermitted. */
53
+ scheduleProgrammingVisibility?: ThermostatUserInterfaceConfiguration.ScheduleProgrammingVisibility;
54
+ /** Fan mode. Default Off. */
55
+ fanMode?: FanControl.FanMode;
56
+ /** Fan mode sequence. Default OffLowMedHighAuto. */
57
+ fanModeSequence?: FanControl.FanModeSequence;
58
+ /** Target fan percent setting (0–100). Default 0. */
59
+ percentSetting?: number;
60
+ /** Current fan percent (0–100). Default 0. */
61
+ percentCurrent?: number;
62
+ }
63
+ export declare class AirConditioner extends MatterbridgeEndpoint {
64
+ /**
65
+ * Creates an instance of the AirConditioner class.
66
+ *
67
+ * A Room Air Conditioner is a device which at a minimum is capable of being turned on and off and of controlling the temperature in the living space.
68
+ * A Room Air Conditioner MAY also support additional capabilities via endpoint composition.
69
+ * The DF (Dead Front) feature is required for the On/Off cluster in this device type.
70
+ *
71
+ * @param {string} name - The name of the air conditioner.
72
+ * @param {string} serial - The serial number of the air conditioner.
73
+ * @param {AirConditionerOptions} [options] - Optional configuration values. Missing fields use defaults.
74
+ *
75
+ * Options defaults:
76
+ * - localTemperature: 23
77
+ * - occupiedHeatingSetpoint: 21
78
+ * - occupiedCoolingSetpoint: 25
79
+ * - minSetpointDeadBand: 1
80
+ * - minHeatSetpointLimit: 0
81
+ * - maxHeatSetpointLimit: 50
82
+ * - minCoolSetpointLimit: 0
83
+ * - maxCoolSetpointLimit: 50
84
+ * - temperatureDisplayMode: Celsius
85
+ * - keypadLockout: NoLockout
86
+ * - scheduleProgrammingVisibility: ScheduleProgrammingPermitted
87
+ * - fanMode: Off
88
+ * - fanModeSequence: OffLowMedHighAuto
89
+ * - percentSetting: 0
90
+ * - percentCurrent: 0
91
+ *
92
+ * @returns {AirConditioner} The AirConditioner instance.
93
+ *
94
+ * @remarks Not supported by Google Home.
95
+ */
96
+ constructor(name: string, serial: string, options?: AirConditionerOptions);
97
+ }
98
+ //# sourceMappingURL=airConditioner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"airConditioner.d.ts","sourceRoot":"","sources":["../../src/devices/airConditioner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,EAAE,oCAAoC,EAAE,MAAM,gEAAgE,CAAC;AACtH,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAIhE,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAElE;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACpC,kDAAkD;IAClD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,kDAAkD;IAClD,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,kDAAkD;IAClD,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,kDAAkD;IAClD,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,mDAAmD;IACnD,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,oDAAoD;IACpD,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,mDAAmD;IACnD,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,oDAAoD;IACpD,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,iDAAiD;IACjD,sBAAsB,CAAC,EAAE,oCAAoC,CAAC,sBAAsB,CAAC;IACrF,8CAA8C;IAC9C,aAAa,CAAC,EAAE,oCAAoC,CAAC,aAAa,CAAC;IACnE,6EAA6E;IAC7E,6BAA6B,CAAC,EAAE,oCAAoC,CAAC,6BAA6B,CAAC;IACnG,6BAA6B;IAC7B,OAAO,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC;IAC7B,oDAAoD;IACpD,eAAe,CAAC,EAAE,UAAU,CAAC,eAAe,CAAC;IAC7C,qDAAqD;IACrD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,8CAA8C;IAC9C,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,qBAAa,cAAe,SAAQ,oBAAoB;IACtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;gBACS,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,qBAA0B;CAoC9E"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * @description This file contains the AirConditioner class.
3
+ * @file src/devices/airConditioner.ts
4
+ * @author Luca Liguori
5
+ * @created 2025-09-04
6
+ * @version 1.0.0
7
+ * @license Apache-2.0
8
+ *
9
+ * Copyright 2025, 2026, 2027 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
+ // Imports from @matter
24
+ import { ThermostatUserInterfaceConfiguration } from '@matter/types/clusters/thermostat-user-interface-configuration';
25
+ import { FanControl } from '@matter/types/clusters/fan-control';
26
+ // Matterbridge
27
+ import { airConditioner, powerSource } from '../matterbridgeDeviceTypes.js';
28
+ import { MatterbridgeEndpoint } from '../matterbridgeEndpoint.js';
29
+ export class AirConditioner extends MatterbridgeEndpoint {
30
+ /**
31
+ * Creates an instance of the AirConditioner class.
32
+ *
33
+ * A Room Air Conditioner is a device which at a minimum is capable of being turned on and off and of controlling the temperature in the living space.
34
+ * A Room Air Conditioner MAY also support additional capabilities via endpoint composition.
35
+ * The DF (Dead Front) feature is required for the On/Off cluster in this device type.
36
+ *
37
+ * @param {string} name - The name of the air conditioner.
38
+ * @param {string} serial - The serial number of the air conditioner.
39
+ * @param {AirConditionerOptions} [options] - Optional configuration values. Missing fields use defaults.
40
+ *
41
+ * Options defaults:
42
+ * - localTemperature: 23
43
+ * - occupiedHeatingSetpoint: 21
44
+ * - occupiedCoolingSetpoint: 25
45
+ * - minSetpointDeadBand: 1
46
+ * - minHeatSetpointLimit: 0
47
+ * - maxHeatSetpointLimit: 50
48
+ * - minCoolSetpointLimit: 0
49
+ * - maxCoolSetpointLimit: 50
50
+ * - temperatureDisplayMode: Celsius
51
+ * - keypadLockout: NoLockout
52
+ * - scheduleProgrammingVisibility: ScheduleProgrammingPermitted
53
+ * - fanMode: Off
54
+ * - fanModeSequence: OffLowMedHighAuto
55
+ * - percentSetting: 0
56
+ * - percentCurrent: 0
57
+ *
58
+ * @returns {AirConditioner} The AirConditioner instance.
59
+ *
60
+ * @remarks Not supported by Google Home.
61
+ */
62
+ constructor(name, serial, options = {}) {
63
+ const { localTemperature = 23, occupiedHeatingSetpoint = 21, occupiedCoolingSetpoint = 25, minSetpointDeadBand = 1, minHeatSetpointLimit = 0, maxHeatSetpointLimit = 50, minCoolSetpointLimit = 0, maxCoolSetpointLimit = 50, temperatureDisplayMode = ThermostatUserInterfaceConfiguration.TemperatureDisplayMode.Celsius, keypadLockout = ThermostatUserInterfaceConfiguration.KeypadLockout.NoLockout, scheduleProgrammingVisibility = ThermostatUserInterfaceConfiguration.ScheduleProgrammingVisibility.ScheduleProgrammingPermitted, fanMode = FanControl.FanMode.Off, fanModeSequence = FanControl.FanModeSequence.OffLowMedHighAuto, percentSetting = 0, percentCurrent = 0, } = options;
64
+ super([airConditioner, powerSource], { id: `${name.replaceAll(' ', '')}-${serial.replaceAll(' ', '')}` });
65
+ this.createDefaultIdentifyClusterServer();
66
+ this.createDefaultBasicInformationClusterServer(name, serial, 0xfff1, 'Matterbridge', 0x8000, 'Matterbridge Air Conditioner');
67
+ this.createDefaultPowerSourceWiredClusterServer();
68
+ this.createDeadFrontOnOffClusterServer(true);
69
+ this.createDefaultThermostatClusterServer(localTemperature, occupiedHeatingSetpoint, occupiedCoolingSetpoint, minSetpointDeadBand, minHeatSetpointLimit, maxHeatSetpointLimit, minCoolSetpointLimit, maxCoolSetpointLimit);
70
+ this.createDefaultThermostatUserInterfaceConfigurationClusterServer(temperatureDisplayMode, keypadLockout, scheduleProgrammingVisibility);
71
+ this.createDefaultFanControlClusterServer(fanMode, fanModeSequence, percentSetting, percentCurrent);
72
+ }
73
+ }
74
+ //# sourceMappingURL=airConditioner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"airConditioner.js","sourceRoot":"","sources":["../../src/devices/airConditioner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,uBAAuB;AACvB,OAAO,EAAE,oCAAoC,EAAE,MAAM,gEAAgE,CAAC;AACtH,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAEhE,eAAe;AACf,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAwClE,MAAM,OAAO,cAAe,SAAQ,oBAAoB;IACtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;IACH,YAAY,IAAY,EAAE,MAAc,EAAE,UAAiC,EAAE;QAC3E,MAAM,EACJ,gBAAgB,GAAG,EAAE,EACrB,uBAAuB,GAAG,EAAE,EAC5B,uBAAuB,GAAG,EAAE,EAC5B,mBAAmB,GAAG,CAAC,EACvB,oBAAoB,GAAG,CAAC,EACxB,oBAAoB,GAAG,EAAE,EACzB,oBAAoB,GAAG,CAAC,EACxB,oBAAoB,GAAG,EAAE,EACzB,sBAAsB,GAAG,oCAAoC,CAAC,sBAAsB,CAAC,OAAO,EAC5F,aAAa,GAAG,oCAAoC,CAAC,aAAa,CAAC,SAAS,EAC5E,6BAA6B,GAAG,oCAAoC,CAAC,6BAA6B,CAAC,4BAA4B,EAC/H,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,GAAG,EAChC,eAAe,GAAG,UAAU,CAAC,eAAe,CAAC,iBAAiB,EAC9D,cAAc,GAAG,CAAC,EAClB,cAAc,GAAG,CAAC,GACnB,GAAG,OAAO,CAAC;QACZ,KAAK,CAAC,CAAC,cAAc,EAAE,WAAW,CAAC,EAAE,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QAC1G,IAAI,CAAC,kCAAkC,EAAE,CAAC;QAC1C,IAAI,CAAC,0CAA0C,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,8BAA8B,CAAC,CAAC;QAC9H,IAAI,CAAC,0CAA0C,EAAE,CAAC;QAClD,IAAI,CAAC,iCAAiC,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,oCAAoC,CACvC,gBAAgB,EAChB,uBAAuB,EACvB,uBAAuB,EACvB,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,CACrB,CAAC;QACF,IAAI,CAAC,8DAA8D,CAAC,sBAAsB,EAAE,aAAa,EAAE,6BAA6B,CAAC,CAAC;QAC1I,IAAI,CAAC,oCAAoC,CAAC,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,CAAC,CAAC;IACtG,CAAC;CACF"}
@@ -0,0 +1,88 @@
1
+ /**
2
+ * @description This file contains the BasicVideoPlayer class.
3
+ * @file src/devices/basicVideoPlayer.ts
4
+ * @author Luca Liguori
5
+ * @created 2026-01-25
6
+ * @version 1.0.0
7
+ * @license Apache-2.0
8
+ *
9
+ * Copyright 2025, 2026, 2027 Luca Liguori.
10
+ *
11
+ * Licensed under the Apache License, Version 2.0 (the "License");
12
+ * you may not use this file except in compliance with the License.
13
+ * You may obtain a copy of the License at
14
+ *
15
+ * http://www.apache.org/licenses/LICENSE-2.0
16
+ *
17
+ * Unless required by applicable law or agreed to in writing, software
18
+ * distributed under the License is distributed on an "AS IS" BASIS,
19
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
+ * See the License for the specific language governing permissions and
21
+ * limitations under the License.
22
+ */
23
+ import { MaybePromise } from '@matter/general';
24
+ import { MediaPlayback } from '@matter/types/clusters/media-playback';
25
+ import { KeypadInput } from '@matter/types/clusters/keypad-input';
26
+ import { MediaPlaybackServer } from '@matter/node/behaviors/media-playback';
27
+ import { KeypadInputServer } from '@matter/node/behaviors/keypad-input';
28
+ import { MatterbridgeEndpoint } from '../matterbridgeEndpoint.js';
29
+ /**
30
+ * Options for configuring an {@link AirConditioner} instance.
31
+ *
32
+ * All temperatures in °C. Typical valid range 0–50 unless otherwise noted.
33
+ */
34
+ export interface BasicVideoPlayerOptions {
35
+ /** Device state */
36
+ onOff?: boolean;
37
+ playbackState?: MediaPlayback.PlaybackState;
38
+ }
39
+ export declare class BasicVideoPlayer extends MatterbridgeEndpoint {
40
+ /**
41
+ * Creates an instance of the BasicVideoPlayer class.
42
+ *
43
+ * A Video Player (either Basic or Casting) represents a device that is able to play media to a physical
44
+ * output or to a display screen which is part of the device.
45
+ *
46
+ * @param {string} name - The name of the video player.
47
+ * @param {string} serial - The serial number of the video player.
48
+ * @param {BasicVideoPlayerOptions} [options] - Optional configuration values. Missing fields use defaults.
49
+ *
50
+ * Options defaults:
51
+ * - onOff: false
52
+ * - playbackState: NotPlaying
53
+ *
54
+ * @returns {BasicVideoPlayer} The BasicVideoPlayer instance.
55
+ *
56
+ * @remarks Not supported by Google Home.
57
+ */
58
+ constructor(name: string, serial: string, options?: BasicVideoPlayerOptions);
59
+ /**
60
+ * Creates a default Media Playback Cluster Server.
61
+ *
62
+ * @param {MediaPlayback.PlaybackState} currentState - The current state of the video player.
63
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
64
+ */
65
+ createDefaultMediaPlaybackClusterServer(currentState: MediaPlayback.PlaybackState): this;
66
+ /**
67
+ * Creates a default Keypad Input Cluster Server.
68
+ *
69
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
70
+ */
71
+ createDefaultKeypadInputClusterServer(): this;
72
+ }
73
+ export declare class MatterbridgeMediaPlaybackServer extends MediaPlaybackServer {
74
+ initialize(): void;
75
+ protected handleOnOffChange(_onOff: boolean): void;
76
+ play(): MaybePromise<MediaPlayback.PlaybackResponse>;
77
+ pause(): MaybePromise<MediaPlayback.PlaybackResponse>;
78
+ stop(): MaybePromise<MediaPlayback.PlaybackResponse>;
79
+ previous(): MaybePromise<MediaPlayback.PlaybackResponse>;
80
+ next(): MaybePromise<MediaPlayback.PlaybackResponse>;
81
+ skipForward(): MaybePromise<MediaPlayback.PlaybackResponse>;
82
+ skipBackward(): MaybePromise<MediaPlayback.PlaybackResponse>;
83
+ }
84
+ export declare class MatterbridgeKeypadInputServer extends KeypadInputServer {
85
+ initialize(): void;
86
+ sendKey(request: KeypadInput.SendKeyRequest): MaybePromise<KeypadInput.SendKeyResponse>;
87
+ }
88
+ //# sourceMappingURL=basicVideoPlayer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"basicVideoPlayer.d.ts","sourceRoot":"","sources":["../../src/devices/basicVideoPlayer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAIxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAGlE;;;;GAIG;AACH,MAAM,WAAW,uBAAuB;IACtC,mBAAmB;IACnB,KAAK,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