matterbridge 3.4.3-dev-20251209-e6cb85f → 3.4.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 (324) hide show
  1. package/README.md +2 -3
  2. package/dist/broadcastServer.d.ts +144 -0
  3. package/dist/broadcastServer.d.ts.map +1 -0
  4. package/dist/broadcastServer.js +119 -0
  5. package/dist/broadcastServer.js.map +1 -0
  6. package/dist/broadcastServerTypes.d.ts +841 -0
  7. package/dist/broadcastServerTypes.d.ts.map +1 -0
  8. package/dist/broadcastServerTypes.js +24 -0
  9. package/dist/broadcastServerTypes.js.map +1 -0
  10. package/dist/cli.d.ts +30 -0
  11. package/dist/cli.d.ts.map +1 -0
  12. package/dist/cli.js +97 -1
  13. package/dist/cli.js.map +1 -0
  14. package/dist/cliEmitter.d.ts +50 -0
  15. package/dist/cliEmitter.d.ts.map +1 -0
  16. package/dist/cliEmitter.js +37 -0
  17. package/dist/cliEmitter.js.map +1 -0
  18. package/dist/cliHistory.d.ts +48 -0
  19. package/dist/cliHistory.d.ts.map +1 -0
  20. package/dist/cliHistory.js +38 -0
  21. package/dist/cliHistory.js.map +1 -0
  22. package/dist/clusters/export.d.ts +2 -0
  23. package/dist/clusters/export.d.ts.map +1 -0
  24. package/dist/clusters/export.js +2 -0
  25. package/dist/clusters/export.js.map +1 -0
  26. package/dist/deviceManager.d.ts +135 -0
  27. package/dist/deviceManager.d.ts.map +1 -0
  28. package/dist/deviceManager.js +113 -1
  29. package/dist/deviceManager.js.map +1 -0
  30. package/dist/devices/airConditioner.d.ts +98 -0
  31. package/dist/devices/airConditioner.d.ts.map +1 -0
  32. package/dist/devices/airConditioner.js +57 -0
  33. package/dist/devices/airConditioner.js.map +1 -0
  34. package/dist/devices/batteryStorage.d.ts +48 -0
  35. package/dist/devices/batteryStorage.d.ts.map +1 -0
  36. package/dist/devices/batteryStorage.js +48 -1
  37. package/dist/devices/batteryStorage.js.map +1 -0
  38. package/dist/devices/cooktop.d.ts +61 -0
  39. package/dist/devices/cooktop.d.ts.map +1 -0
  40. package/dist/devices/cooktop.js +56 -0
  41. package/dist/devices/cooktop.js.map +1 -0
  42. package/dist/devices/dishwasher.d.ts +71 -0
  43. package/dist/devices/dishwasher.d.ts.map +1 -0
  44. package/dist/devices/dishwasher.js +57 -0
  45. package/dist/devices/dishwasher.js.map +1 -0
  46. package/dist/devices/evse.d.ts +76 -0
  47. package/dist/devices/evse.d.ts.map +1 -0
  48. package/dist/devices/evse.js +74 -10
  49. package/dist/devices/evse.js.map +1 -0
  50. package/dist/devices/export.d.ts +17 -0
  51. package/dist/devices/export.d.ts.map +1 -0
  52. package/dist/devices/export.js +5 -0
  53. package/dist/devices/export.js.map +1 -0
  54. package/dist/devices/extractorHood.d.ts +46 -0
  55. package/dist/devices/extractorHood.d.ts.map +1 -0
  56. package/dist/devices/extractorHood.js +43 -0
  57. package/dist/devices/extractorHood.js.map +1 -0
  58. package/dist/devices/heatPump.d.ts +47 -0
  59. package/dist/devices/heatPump.d.ts.map +1 -0
  60. package/dist/devices/heatPump.js +50 -2
  61. package/dist/devices/heatPump.js.map +1 -0
  62. package/dist/devices/laundryDryer.d.ts +67 -0
  63. package/dist/devices/laundryDryer.d.ts.map +1 -0
  64. package/dist/devices/laundryDryer.js +62 -3
  65. package/dist/devices/laundryDryer.js.map +1 -0
  66. package/dist/devices/laundryWasher.d.ts +81 -0
  67. package/dist/devices/laundryWasher.d.ts.map +1 -0
  68. package/dist/devices/laundryWasher.js +70 -4
  69. package/dist/devices/laundryWasher.js.map +1 -0
  70. package/dist/devices/microwaveOven.d.ts +168 -0
  71. package/dist/devices/microwaveOven.d.ts.map +1 -0
  72. package/dist/devices/microwaveOven.js +88 -5
  73. package/dist/devices/microwaveOven.js.map +1 -0
  74. package/dist/devices/oven.d.ts +105 -0
  75. package/dist/devices/oven.d.ts.map +1 -0
  76. package/dist/devices/oven.js +85 -0
  77. package/dist/devices/oven.js.map +1 -0
  78. package/dist/devices/refrigerator.d.ts +118 -0
  79. package/dist/devices/refrigerator.d.ts.map +1 -0
  80. package/dist/devices/refrigerator.js +102 -0
  81. package/dist/devices/refrigerator.js.map +1 -0
  82. package/dist/devices/roboticVacuumCleaner.d.ts +112 -0
  83. package/dist/devices/roboticVacuumCleaner.d.ts.map +1 -0
  84. package/dist/devices/roboticVacuumCleaner.js +100 -9
  85. package/dist/devices/roboticVacuumCleaner.js.map +1 -0
  86. package/dist/devices/solarPower.d.ts +40 -0
  87. package/dist/devices/solarPower.d.ts.map +1 -0
  88. package/dist/devices/solarPower.js +38 -0
  89. package/dist/devices/solarPower.js.map +1 -0
  90. package/dist/devices/speaker.d.ts +87 -0
  91. package/dist/devices/speaker.d.ts.map +1 -0
  92. package/dist/devices/speaker.js +84 -0
  93. package/dist/devices/speaker.js.map +1 -0
  94. package/dist/devices/temperatureControl.d.ts +166 -0
  95. package/dist/devices/temperatureControl.d.ts.map +1 -0
  96. package/dist/devices/temperatureControl.js +24 -3
  97. package/dist/devices/temperatureControl.js.map +1 -0
  98. package/dist/devices/waterHeater.d.ts +111 -0
  99. package/dist/devices/waterHeater.d.ts.map +1 -0
  100. package/dist/devices/waterHeater.js +82 -2
  101. package/dist/devices/waterHeater.js.map +1 -0
  102. package/dist/dgram/coap.d.ts +205 -0
  103. package/dist/dgram/coap.d.ts.map +1 -0
  104. package/dist/dgram/coap.js +126 -13
  105. package/dist/dgram/coap.js.map +1 -0
  106. package/dist/dgram/dgram.d.ts +141 -0
  107. package/dist/dgram/dgram.d.ts.map +1 -0
  108. package/dist/dgram/dgram.js +114 -2
  109. package/dist/dgram/dgram.js.map +1 -0
  110. package/dist/dgram/mb_coap.d.ts +24 -0
  111. package/dist/dgram/mb_coap.d.ts.map +1 -0
  112. package/dist/dgram/mb_coap.js +41 -3
  113. package/dist/dgram/mb_coap.js.map +1 -0
  114. package/dist/dgram/mb_mdns.d.ts +24 -0
  115. package/dist/dgram/mb_mdns.d.ts.map +1 -0
  116. package/dist/dgram/mb_mdns.js +80 -15
  117. package/dist/dgram/mb_mdns.js.map +1 -0
  118. package/dist/dgram/mdns.d.ts +290 -0
  119. package/dist/dgram/mdns.d.ts.map +1 -0
  120. package/dist/dgram/mdns.js +299 -137
  121. package/dist/dgram/mdns.js.map +1 -0
  122. package/dist/dgram/multicast.d.ts +67 -0
  123. package/dist/dgram/multicast.d.ts.map +1 -0
  124. package/dist/dgram/multicast.js +62 -1
  125. package/dist/dgram/multicast.js.map +1 -0
  126. package/dist/dgram/unicast.d.ts +56 -0
  127. package/dist/dgram/unicast.d.ts.map +1 -0
  128. package/dist/dgram/unicast.js +54 -0
  129. package/dist/dgram/unicast.js.map +1 -0
  130. package/dist/frontend.d.ts +238 -0
  131. package/dist/frontend.d.ts.map +1 -0
  132. package/dist/frontend.js +455 -35
  133. package/dist/frontend.js.map +1 -0
  134. package/dist/frontendTypes.d.ts +529 -0
  135. package/dist/frontendTypes.d.ts.map +1 -0
  136. package/dist/frontendTypes.js +45 -0
  137. package/dist/frontendTypes.js.map +1 -0
  138. package/dist/helpers.d.ts +48 -0
  139. package/dist/helpers.d.ts.map +1 -0
  140. package/dist/helpers.js +53 -0
  141. package/dist/helpers.js.map +1 -0
  142. package/dist/index.d.ts +34 -0
  143. package/dist/index.d.ts.map +1 -0
  144. package/dist/index.js +25 -0
  145. package/dist/index.js.map +1 -0
  146. package/dist/jestutils/export.d.ts +2 -0
  147. package/dist/jestutils/export.d.ts.map +1 -0
  148. package/dist/jestutils/export.js +1 -0
  149. package/dist/jestutils/export.js.map +1 -0
  150. package/dist/jestutils/jestHelpers.d.ts +345 -0
  151. package/dist/jestutils/jestHelpers.d.ts.map +1 -0
  152. package/dist/jestutils/jestHelpers.js +371 -14
  153. package/dist/jestutils/jestHelpers.js.map +1 -0
  154. package/dist/logger/export.d.ts +2 -0
  155. package/dist/logger/export.d.ts.map +1 -0
  156. package/dist/logger/export.js +1 -0
  157. package/dist/logger/export.js.map +1 -0
  158. package/dist/matter/behaviors.d.ts +2 -0
  159. package/dist/matter/behaviors.d.ts.map +1 -0
  160. package/dist/matter/behaviors.js +2 -0
  161. package/dist/matter/behaviors.js.map +1 -0
  162. package/dist/matter/clusters.d.ts +2 -0
  163. package/dist/matter/clusters.d.ts.map +1 -0
  164. package/dist/matter/clusters.js +2 -0
  165. package/dist/matter/clusters.js.map +1 -0
  166. package/dist/matter/devices.d.ts +2 -0
  167. package/dist/matter/devices.d.ts.map +1 -0
  168. package/dist/matter/devices.js +2 -0
  169. package/dist/matter/devices.js.map +1 -0
  170. package/dist/matter/endpoints.d.ts +2 -0
  171. package/dist/matter/endpoints.d.ts.map +1 -0
  172. package/dist/matter/endpoints.js +2 -0
  173. package/dist/matter/endpoints.js.map +1 -0
  174. package/dist/matter/export.d.ts +5 -0
  175. package/dist/matter/export.d.ts.map +1 -0
  176. package/dist/matter/export.js +3 -0
  177. package/dist/matter/export.js.map +1 -0
  178. package/dist/matter/types.d.ts +3 -0
  179. package/dist/matter/types.d.ts.map +1 -0
  180. package/dist/matter/types.js +3 -0
  181. package/dist/matter/types.js.map +1 -0
  182. package/dist/matterNode.d.ts +342 -0
  183. package/dist/matterNode.d.ts.map +1 -0
  184. package/dist/matterNode.js +369 -8
  185. package/dist/matterNode.js.map +1 -0
  186. package/dist/matterbridge.d.ts +492 -0
  187. package/dist/matterbridge.d.ts.map +1 -0
  188. package/dist/matterbridge.js +811 -46
  189. package/dist/matterbridge.js.map +1 -0
  190. package/dist/matterbridgeAccessoryPlatform.d.ts +41 -0
  191. package/dist/matterbridgeAccessoryPlatform.d.ts.map +1 -0
  192. package/dist/matterbridgeAccessoryPlatform.js +38 -0
  193. package/dist/matterbridgeAccessoryPlatform.js.map +1 -0
  194. package/dist/matterbridgeBehaviors.d.ts +2404 -0
  195. package/dist/matterbridgeBehaviors.d.ts.map +1 -0
  196. package/dist/matterbridgeBehaviors.js +68 -5
  197. package/dist/matterbridgeBehaviors.js.map +1 -0
  198. package/dist/matterbridgeDeviceTypes.d.ts +698 -0
  199. package/dist/matterbridgeDeviceTypes.d.ts.map +1 -0
  200. package/dist/matterbridgeDeviceTypes.js +635 -14
  201. package/dist/matterbridgeDeviceTypes.js.map +1 -0
  202. package/dist/matterbridgeDynamicPlatform.d.ts +41 -0
  203. package/dist/matterbridgeDynamicPlatform.d.ts.map +1 -0
  204. package/dist/matterbridgeDynamicPlatform.js +38 -0
  205. package/dist/matterbridgeDynamicPlatform.js.map +1 -0
  206. package/dist/matterbridgeEndpoint.d.ts +1507 -0
  207. package/dist/matterbridgeEndpoint.d.ts.map +1 -0
  208. package/dist/matterbridgeEndpoint.js +1444 -53
  209. package/dist/matterbridgeEndpoint.js.map +1 -0
  210. package/dist/matterbridgeEndpointHelpers.d.ts +787 -0
  211. package/dist/matterbridgeEndpointHelpers.d.ts.map +1 -0
  212. package/dist/matterbridgeEndpointHelpers.js +483 -20
  213. package/dist/matterbridgeEndpointHelpers.js.map +1 -0
  214. package/dist/matterbridgeEndpointTypes.d.ts +166 -0
  215. package/dist/matterbridgeEndpointTypes.d.ts.map +1 -0
  216. package/dist/matterbridgeEndpointTypes.js +25 -0
  217. package/dist/matterbridgeEndpointTypes.js.map +1 -0
  218. package/dist/matterbridgePlatform.d.ts +539 -0
  219. package/dist/matterbridgePlatform.d.ts.map +1 -0
  220. package/dist/matterbridgePlatform.js +451 -1
  221. package/dist/matterbridgePlatform.js.map +1 -0
  222. package/dist/matterbridgeTypes.d.ts +251 -0
  223. package/dist/matterbridgeTypes.d.ts.map +1 -0
  224. package/dist/matterbridgeTypes.js +26 -0
  225. package/dist/matterbridgeTypes.js.map +1 -0
  226. package/dist/pluginManager.d.ts +372 -0
  227. package/dist/pluginManager.d.ts.map +1 -0
  228. package/dist/pluginManager.js +341 -5
  229. package/dist/pluginManager.js.map +1 -0
  230. package/dist/shelly.d.ts +181 -0
  231. package/dist/shelly.d.ts.map +1 -0
  232. package/dist/shelly.js +178 -7
  233. package/dist/shelly.js.map +1 -0
  234. package/dist/storage/export.d.ts +2 -0
  235. package/dist/storage/export.d.ts.map +1 -0
  236. package/dist/storage/export.js +1 -0
  237. package/dist/storage/export.js.map +1 -0
  238. package/dist/update.d.ts +84 -0
  239. package/dist/update.d.ts.map +1 -0
  240. package/dist/update.js +93 -1
  241. package/dist/update.js.map +1 -0
  242. package/dist/utils/colorUtils.d.ts +101 -0
  243. package/dist/utils/colorUtils.d.ts.map +1 -0
  244. package/dist/utils/colorUtils.js +97 -2
  245. package/dist/utils/colorUtils.js.map +1 -0
  246. package/dist/utils/commandLine.d.ts +66 -0
  247. package/dist/utils/commandLine.d.ts.map +1 -0
  248. package/dist/utils/commandLine.js +60 -0
  249. package/dist/utils/commandLine.js.map +1 -0
  250. package/dist/utils/copyDirectory.d.ts +35 -0
  251. package/dist/utils/copyDirectory.d.ts.map +1 -0
  252. package/dist/utils/copyDirectory.js +37 -0
  253. package/dist/utils/copyDirectory.js.map +1 -0
  254. package/dist/utils/createDirectory.d.ts +34 -0
  255. package/dist/utils/createDirectory.d.ts.map +1 -0
  256. package/dist/utils/createDirectory.js +33 -0
  257. package/dist/utils/createDirectory.js.map +1 -0
  258. package/dist/utils/createZip.d.ts +39 -0
  259. package/dist/utils/createZip.d.ts.map +1 -0
  260. package/dist/utils/createZip.js +47 -2
  261. package/dist/utils/createZip.js.map +1 -0
  262. package/dist/utils/deepCopy.d.ts +32 -0
  263. package/dist/utils/deepCopy.d.ts.map +1 -0
  264. package/dist/utils/deepCopy.js +39 -0
  265. package/dist/utils/deepCopy.js.map +1 -0
  266. package/dist/utils/deepEqual.d.ts +54 -0
  267. package/dist/utils/deepEqual.d.ts.map +1 -0
  268. package/dist/utils/deepEqual.js +72 -1
  269. package/dist/utils/deepEqual.js.map +1 -0
  270. package/dist/utils/error.d.ts +45 -0
  271. package/dist/utils/error.d.ts.map +1 -0
  272. package/dist/utils/error.js +42 -0
  273. package/dist/utils/error.js.map +1 -0
  274. package/dist/utils/export.d.ts +13 -0
  275. package/dist/utils/export.d.ts.map +1 -0
  276. package/dist/utils/export.js +1 -0
  277. package/dist/utils/export.js.map +1 -0
  278. package/dist/utils/format.d.ts +53 -0
  279. package/dist/utils/format.d.ts.map +1 -0
  280. package/dist/utils/format.js +49 -0
  281. package/dist/utils/format.js.map +1 -0
  282. package/dist/utils/hex.d.ts +89 -0
  283. package/dist/utils/hex.d.ts.map +1 -0
  284. package/dist/utils/hex.js +124 -0
  285. package/dist/utils/hex.js.map +1 -0
  286. package/dist/utils/inspector.d.ts +87 -0
  287. package/dist/utils/inspector.d.ts.map +1 -0
  288. package/dist/utils/inspector.js +69 -1
  289. package/dist/utils/inspector.js.map +1 -0
  290. package/dist/utils/isvalid.d.ts +103 -0
  291. package/dist/utils/isvalid.d.ts.map +1 -0
  292. package/dist/utils/isvalid.js +101 -0
  293. package/dist/utils/isvalid.js.map +1 -0
  294. package/dist/utils/network.d.ts +111 -0
  295. package/dist/utils/network.d.ts.map +1 -0
  296. package/dist/utils/network.js +96 -5
  297. package/dist/utils/network.js.map +1 -0
  298. package/dist/utils/spawn.d.ts +33 -0
  299. package/dist/utils/spawn.d.ts.map +1 -0
  300. package/dist/utils/spawn.js +71 -1
  301. package/dist/utils/spawn.js.map +1 -0
  302. package/dist/utils/tracker.d.ts +108 -0
  303. package/dist/utils/tracker.d.ts.map +1 -0
  304. package/dist/utils/tracker.js +64 -1
  305. package/dist/utils/tracker.js.map +1 -0
  306. package/dist/utils/wait.d.ts +54 -0
  307. package/dist/utils/wait.d.ts.map +1 -0
  308. package/dist/utils/wait.js +60 -8
  309. package/dist/utils/wait.js.map +1 -0
  310. package/dist/workerGlobalPrefix.d.ts +25 -0
  311. package/dist/workerGlobalPrefix.d.ts.map +1 -0
  312. package/dist/workerGlobalPrefix.js +37 -5
  313. package/dist/workerGlobalPrefix.js.map +1 -0
  314. package/dist/workerTypes.d.ts +52 -0
  315. package/dist/workerTypes.d.ts.map +1 -0
  316. package/dist/workerTypes.js +24 -0
  317. package/dist/workerTypes.js.map +1 -0
  318. package/dist/workers.d.ts +69 -0
  319. package/dist/workers.d.ts.map +1 -0
  320. package/dist/workers.js +68 -4
  321. package/dist/workers.js.map +1 -0
  322. package/npm-shrinkwrap.json +2 -2
  323. package/package.json +2 -1
  324. package/scripts/data_model.mjs +2058 -0
@@ -1,10 +1,39 @@
1
+ /**
2
+ * This file contains the class MatterbridgeEndpoint that extends the Endpoint class from the Matter.js library.
3
+ *
4
+ * @file matterbridgeEndpoint.ts
5
+ * @author Luca Liguori
6
+ * @created 2024-10-01
7
+ * @version 2.1.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
1
25
  if (process.argv.includes('--loader') || process.argv.includes('-loader'))
2
26
  console.log('\u001B[32mMatterbridgeEndpoint loaded.\u001B[40;0m');
27
+ // AnsiLogger module
3
28
  import { AnsiLogger, CYAN, YELLOW, db, debugStringify, hk, or, zb } from 'node-ansi-logger';
29
+ // @matter/general
4
30
  import { Lifecycle, NamedHandler, UINT16_MAX, UINT32_MAX } from '@matter/general';
31
+ // @matter/node
5
32
  import { Endpoint, MutableEndpoint, SupportedBehaviors } from '@matter/node';
33
+ // @matter/types
6
34
  import { getClusterNameById } from '@matter/types/cluster';
7
35
  import { VendorId } from '@matter/types/datatype';
36
+ // @matter clusters
8
37
  import { Descriptor } from '@matter/types/clusters/descriptor';
9
38
  import { PowerSource } from '@matter/types/clusters/power-source';
10
39
  import { BridgedDeviceBasicInformation } from '@matter/types/clusters/bridged-device-basic-information';
@@ -31,6 +60,7 @@ import { ThermostatUserInterfaceConfiguration } from '@matter/types/clusters/the
31
60
  import { OperationalState } from '@matter/types/clusters/operational-state';
32
61
  import { DeviceEnergyManagement } from '@matter/types/clusters/device-energy-management';
33
62
  import { ResourceMonitoring } from '@matter/types/clusters/resource-monitoring';
63
+ // @matter behaviors
34
64
  import { DescriptorServer } from '@matter/node/behaviors/descriptor';
35
65
  import { BridgedDeviceBasicInformationServer } from '@matter/node/behaviors/bridged-device-basic-information';
36
66
  import { GroupsServer } from '@matter/node/behaviors/groups';
@@ -65,11 +95,29 @@ import { MatterbridgeServer, MatterbridgeIdentifyServer, MatterbridgeOnOffServer
65
95
  import { addClusterServers, addFixedLabel, addOptionalClusterServers, addRequiredClusterServers, addUserLabel, createUniqueId, getBehavior, getBehaviourTypesFromClusterClientIds, getBehaviourTypesFromClusterServerIds, getDefaultOperationalStateClusterServer, getDefaultFlowMeasurementClusterServer, getDefaultIlluminanceMeasurementClusterServer, getDefaultPressureMeasurementClusterServer, getDefaultRelativeHumidityMeasurementClusterServer, getDefaultTemperatureMeasurementClusterServer, getDefaultOccupancySensingClusterServer, getDefaultElectricalEnergyMeasurementClusterServer, getDefaultElectricalPowerMeasurementClusterServer, getApparentElectricalPowerMeasurementClusterServer, lowercaseFirstLetter, updateAttribute, getClusterId, getAttributeId, setAttribute, getAttribute, checkNotLatinCharacters, generateUniqueId, subscribeAttribute, invokeBehaviorCommand, triggerEvent, featuresFor, getDefaultPowerSourceWiredClusterServer, getDefaultPowerSourceReplaceableBatteryClusterServer, getDefaultPowerSourceRechargeableBatteryClusterServer, getDefaultDeviceEnergyManagementClusterServer, getDefaultDeviceEnergyManagementModeClusterServer, getDefaultPowerSourceBatteryClusterServer, } from './matterbridgeEndpointHelpers.js';
66
96
  import { inspectError } from './utils/error.js';
67
97
  export class MatterbridgeEndpoint extends Endpoint {
68
- static logLevel = "info";
98
+ /** The default log level of the new MatterbridgeEndpoints */
99
+ static logLevel = "info" /* LogLevel.INFO */;
100
+ /**
101
+ * Activates a special mode for this endpoint.
102
+ * - 'server': it creates the device server node and add the device as Matter device that needs to be paired individually.
103
+ * In this case the bridge mode is not relevant. The device is autonomous. The main use case is a workaround for the Apple Home rvc issue.
104
+ *
105
+ * - 'matter': it adds the device directly to the bridge server node as Matter device. In this case the implementation must respect
106
+ * the 9.2.3. Disambiguation rule (i.e. use taglist if needed cause the device doesn't have nodeLabel).
107
+ * Furthermore the device will be a part of the bridge (i.e. will have the same name and will be in the same room).
108
+ * See 9.12.2.2. Native Matter functionality in Bridge.
109
+ *
110
+ * @remarks
111
+ * Always use createDefaultBasicInformationClusterServer() to create the BasicInformation cluster server.
112
+ */
69
113
  mode = undefined;
114
+ /** The server node of the endpoint, if it is a single not bridged endpoint */
70
115
  serverNode;
116
+ /** The logger instance for the MatterbridgeEndpoint */
71
117
  log;
118
+ /** The plugin name this MatterbridgeEndpoint belongs to */
72
119
  plugin = undefined;
120
+ /** The configuration URL of the device, if available */
73
121
  configUrl = undefined;
74
122
  deviceName = undefined;
75
123
  serialNumber = undefined;
@@ -83,15 +131,30 @@ export class MatterbridgeEndpoint extends Endpoint {
83
131
  hardwareVersion = undefined;
84
132
  hardwareVersionString = undefined;
85
133
  productUrl = 'https://www.npmjs.com/package/matterbridge';
134
+ /** The tagList of the descriptor cluster of the MatterbridgeEndpoint */
86
135
  tagList = undefined;
136
+ /** The original id (with spaces and .) of the MatterbridgeEndpoint constructor options */
87
137
  originalId = undefined;
138
+ /** The name of the first device type of the MatterbridgeEndpoint */
88
139
  name = undefined;
140
+ /** The code of the first device type of the MatterbridgeEndpoint */
89
141
  deviceType = undefined;
142
+ /** Maps the DeviceTypeDefinitions of the MatterbridgeEndpoint keyed by their code */
90
143
  deviceTypes = new Map();
144
+ /** Command handler for the MatterbridgeEndpoint commands */
91
145
  commandHandler = new NamedHandler();
146
+ /**
147
+ * Represents a MatterbridgeEndpoint.
148
+ *
149
+ * @class MatterbridgeEndpoint
150
+ * @param {DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>} definition - The DeviceTypeDefinition(s) of the endpoint.
151
+ * @param {MatterbridgeEndpointOptions} [options] - The options for the device.
152
+ * @param {boolean} [debug] - Debug flag.
153
+ */
92
154
  constructor(definition, options = {}, debug = false) {
93
155
  let deviceTypeList = [];
94
156
  const originalId = options.id;
157
+ // Get the first DeviceTypeDefinition
95
158
  let firstDefinition;
96
159
  if (Array.isArray(definition)) {
97
160
  firstDefinition = definition[0];
@@ -104,10 +167,12 @@ export class MatterbridgeEndpoint extends Endpoint {
104
167
  firstDefinition = definition;
105
168
  deviceTypeList = [{ deviceType: firstDefinition.code, revision: firstDefinition.revision }];
106
169
  }
170
+ // Convert the first DeviceTypeDefinition to an EndpointType.Options
107
171
  const deviceTypeDefinitionV8 = {
108
172
  name: firstDefinition.name.replace('-', '_'),
109
173
  deviceType: firstDefinition.code,
110
174
  deviceRevision: firstDefinition.revision,
175
+ // @ts-expect-error we don't import an entire module for DeviceClassification
111
176
  deviceClass: firstDefinition.deviceClass.toLowerCase(),
112
177
  requirements: {
113
178
  server: {
@@ -122,9 +187,11 @@ export class MatterbridgeEndpoint extends Endpoint {
122
187
  behaviors: options.tagList ? SupportedBehaviors(DescriptorServer.with(Descriptor.Feature.TagList)) : SupportedBehaviors(DescriptorServer),
123
188
  };
124
189
  const endpointV8 = MutableEndpoint(deviceTypeDefinitionV8);
190
+ // Check if the options.id is valid
125
191
  if (options.id && checkNotLatinCharacters(options.id)) {
126
192
  options.id = generateUniqueId(options.id);
127
193
  }
194
+ // Convert the options to an Endpoint.Options
128
195
  const optionsV8 = {
129
196
  id: options.id?.replace(/[ .]/g, ''),
130
197
  number: options.number,
@@ -143,16 +210,53 @@ export class MatterbridgeEndpoint extends Endpoint {
143
210
  }
144
211
  else
145
212
  this.deviceTypes.set(firstDefinition.code, firstDefinition);
146
- this.log = new AnsiLogger({ logName: this.originalId ?? 'MatterbridgeEndpoint', logTimestampFormat: 4, logLevel: debug === true ? "debug" : MatterbridgeEndpoint.logLevel });
213
+ // console.log('MatterbridgeEndpoint.option', options);
214
+ // console.log('MatterbridgeEndpoint.endpointV8', endpointV8);
215
+ // console.log('MatterbridgeEndpoint.optionsV8', optionsV8);
216
+ // Create the logger. Temporarly uses the originalId if available or 'MatterbridgeEndpoint' as fallback. The logName will be set by createDefaultBasicInformationClusterServer() and createDefaultBridgedDeviceBasicInformationClusterServer() with deviceName.
217
+ this.log = new AnsiLogger({ logName: this.originalId ?? 'MatterbridgeEndpoint', logTimestampFormat: 4 /* TimestampFormat.TIME_MILLIS */, logLevel: debug === true ? "debug" /* LogLevel.DEBUG */ : MatterbridgeEndpoint.logLevel });
147
218
  this.log.debug(`${YELLOW}new${db} MatterbridgeEndpoint: ${zb}${'0x' + firstDefinition.code.toString(16).padStart(4, '0')}${db}-${zb}${firstDefinition.name}${db} mode: ${CYAN}${this.mode}${db} id: ${CYAN}${optionsV8.id}${db} number: ${CYAN}${optionsV8.number}${db} taglist: ${CYAN}${options.tagList ? debugStringify(options.tagList) : 'undefined'}${db}`);
219
+ // Add MatterbridgeServer
148
220
  this.behaviors.require(MatterbridgeServer, { log: this.log, commandHandler: this.commandHandler });
149
221
  }
222
+ /**
223
+ * Loads an instance of the MatterbridgeEndpoint class.
224
+ *
225
+ * @param {DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>} definition - The DeviceTypeDefinition(s) of the device.
226
+ * @param {MatterbridgeEndpointOptions} [options] - The options for the device.
227
+ * @param {boolean} [debug] - Debug flag.
228
+ * @returns {Promise<MatterbridgeEndpoint>} MatterbridgeEndpoint instance.
229
+ */
150
230
  static async loadInstance(definition, options = {}, debug = false) {
151
231
  return new MatterbridgeEndpoint(definition, options, debug);
152
232
  }
233
+ /**
234
+ * Get all the device types of this endpoint.
235
+ *
236
+ * @returns {DeviceTypeDefinition[]} The device types of this endpoint.
237
+ */
153
238
  getDeviceTypes() {
154
239
  return Array.from(this.deviceTypes.values());
155
240
  }
241
+ /**
242
+ * Checks if the provided cluster server is supported by this endpoint.
243
+ *
244
+ * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to check.
245
+ * @returns {boolean} True if the cluster server is supported, false otherwise.
246
+ *
247
+ * @example
248
+ *
249
+ * The following examples are all valid ways to check if the 'OnOff' cluster server is supported by the endpoint:
250
+ * ```typescript
251
+ * if(device.hasClusterServer(OnOffBehavior)) ...
252
+ * if(device.hasClusterServer(OnOffServer)) ...
253
+ * if(device.hasClusterServer(OnOffCluster)) ...
254
+ * if(device.hasClusterServer(OnOff.Cluster)) ...
255
+ * if(device.hasClusterServer(OnOff.Cluster.id)) ...
256
+ * if(device.hasClusterServer('OnOff')) ...
257
+ * ```
258
+ * The last has the advantage of being able to check for clusters without imports. Just use the name found in the Matter specs.
259
+ */
156
260
  hasClusterServer(cluster) {
157
261
  const behavior = getBehavior(this, cluster);
158
262
  if (behavior)
@@ -160,6 +264,26 @@ export class MatterbridgeEndpoint extends Endpoint {
160
264
  else
161
265
  return false;
162
266
  }
267
+ /**
268
+ * Checks if the provided attribute server is supported for a given cluster of this endpoint.
269
+ *
270
+ * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to check.
271
+ * @param {string} attribute - The attribute name to check.
272
+ * @returns {boolean} True if the attribute server is supported, false otherwise.
273
+ *
274
+ * @example
275
+ *
276
+ * The following examples are all valid ways to check if the 'onOff' attribute of the 'OnOff' cluster server is supported by the endpoint:
277
+ * ```typescript
278
+ * if(device.hasAttributeServer(OnOffBehavior, 'onOff')) ...
279
+ * if(device.hasAttributeServer(OnOffServer, 'onOff')) ...
280
+ * if(device.hasAttributeServer(OnOffCluster, 'onOff')) ...
281
+ * if(device.hasAttributeServer(OnOff.Cluster, 'onOff')) ...
282
+ * if(device.hasAttributeServer(OnOff.Cluster.id, 'onOff')) ...
283
+ * if(device.hasAttributeServer('OnOff', 'onOff')) ...
284
+ * ```
285
+ * The last has the advantage of being able to check for clusters attributes without imports. Just use the names found in the Matter specs.
286
+ */
163
287
  hasAttributeServer(cluster, attribute) {
164
288
  const behavior = getBehavior(this, cluster);
165
289
  if (!behavior || !this.behaviors.supported[behavior.id])
@@ -168,82 +292,279 @@ export class MatterbridgeEndpoint extends Endpoint {
168
292
  const defaults = this.behaviors.defaultsFor(behavior);
169
293
  return lowercaseFirstLetter(attribute) in options || lowercaseFirstLetter(attribute) in defaults;
170
294
  }
295
+ /**
296
+ * Retrieves the initial options for the provided cluster server.
297
+ *
298
+ * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to get options for.
299
+ * @returns {Record<string, boolean | number | bigint | string | object | null> | undefined} The options for the provided cluster server, or undefined if the cluster is not supported.
300
+ */
171
301
  getClusterServerOptions(cluster) {
172
302
  const behavior = getBehavior(this, cluster);
173
303
  if (!behavior)
174
304
  return undefined;
175
305
  return this.behaviors.optionsFor(behavior);
176
306
  }
307
+ /**
308
+ * Retrieves the value of the provided attribute from the given cluster.
309
+ *
310
+ * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to retrieve the attribute from.
311
+ * @param {string} attribute - The name of the attribute to retrieve.
312
+ * @param {AnsiLogger} [log] - Optional logger for error and info messages.
313
+ * @returns {any} The value of the attribute, or undefined if the attribute is not found.
314
+ *
315
+ * @example
316
+ *
317
+ * The following examples are all valid ways to retrieve the 'onOff' attribute of the 'OnOff' cluster server:
318
+ * ```typescript
319
+ * device.getAttribute(OnOffBehavior, 'onOff')
320
+ * device.getAttribute(OnOffServer, 'onOff')
321
+ * device.getAttribute(OnOffCluster, 'onOff')
322
+ * device.getAttribute(OnOff.Cluster, 'onOff')
323
+ * device.getAttribute(OnOff.Cluster.id, 'onOff')
324
+ * device.getAttribute('OnOff', 'onOff')
325
+ * ```
326
+ * The last has the advantage of being able to retrieve cluster attributes without imports. Just use the names found in the Matter specs.
327
+ */
328
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
177
329
  getAttribute(cluster, attribute, log) {
178
330
  return getAttribute(this, cluster, attribute, log);
179
331
  }
332
+ /**
333
+ * Sets the value of an attribute on a cluster server.
334
+ *
335
+ * @param {Behavior.Type | ClusterType | ClusterId | string} clusterId - The ID of the cluster.
336
+ * @param {string} attribute - The name of the attribute.
337
+ * @param {boolean | number | bigint | string | object | null} value - The value to set for the attribute.
338
+ * @param {AnsiLogger} [log] - (Optional) The logger to use for logging errors and information.
339
+ * @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the attribute was successfully set.
340
+ *
341
+ * @example
342
+ *
343
+ * The following examples are all valid ways to set the 'onOff' attribute of the 'OnOff' cluster server:
344
+ * ```typescript
345
+ * await device.setAttribute(OnOffBehavior, 'onOff', true)
346
+ * await device.setAttribute(OnOffServer, 'onOff', true)
347
+ * await device.setAttribute(OnOffCluster, 'onOff', true)
348
+ * await device.setAttribute(OnOff.Cluster, 'onOff', true)
349
+ * await device.setAttribute(OnOff.Cluster.id, 'onOff', true)
350
+ * await device.setAttribute('OnOff', 'onOff', true)
351
+ * ```
352
+ * The last has the advantage of being able to set cluster attributes without imports. Just use the names found in the Matter specs.
353
+ */
180
354
  async setAttribute(clusterId, attribute, value, log) {
181
355
  return await setAttribute(this, clusterId, attribute, value, log);
182
356
  }
357
+ /**
358
+ * Update the value of an attribute on a cluster server only if the value is different.
359
+ *
360
+ * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to set the attribute on.
361
+ * @param {string} attribute - The name of the attribute.
362
+ * @param {boolean | number | bigint | string | object | null} value - The value to set for the attribute.
363
+ * @param {AnsiLogger} [log] - (Optional) The logger to use for logging the update. Errors are logged to the endpoint logger.
364
+ * @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the attribute was successfully set.
365
+ *
366
+ * @example
367
+ *
368
+ * The following examples are all valid ways to update the 'onOff' attribute of the 'OnOff' cluster server:
369
+ * ```typescript
370
+ * await device.updateAttribute(OnOffBehavior, 'onOff', true)
371
+ * await device.updateAttribute(OnOffServer, 'onOff', true)
372
+ * await device.updateAttribute(OnOffCluster, 'onOff', true)
373
+ * await device.updateAttribute(OnOff.Cluster, 'onOff', true)
374
+ * await device.updateAttribute(OnOff.Cluster.id, 'onOff', true)
375
+ * await device.updateAttribute('OnOff', 'onOff', true)
376
+ * ```
377
+ * The last has the advantage of being able to update cluster attributes without imports. Just use the names found in the Matter specs.
378
+ */
183
379
  async updateAttribute(cluster, attribute, value, log) {
184
380
  return await updateAttribute(this, cluster, attribute, value, log);
185
381
  }
382
+ /**
383
+ * Subscribes to the provided attribute on a cluster.
384
+ *
385
+ * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to subscribe the attribute to.
386
+ * @param {string} attribute - The name of the attribute to subscribe to.
387
+ * @param {(newValue: any, oldValue: any, context: ActionContext) => void} listener - A callback function that will be called when the attribute value changes. When context.offline === true then the change is locally generated and not from the controller.
388
+ * @param {AnsiLogger} [log] - Optional logger for logging errors and information.
389
+ * @returns {Promise<boolean>} - A boolean indicating whether the subscription was successful.
390
+ *
391
+ * @remarks
392
+ * The listener function (cannot be async!) will receive three parameters:
393
+ * - `newValue`: The new value of the attribute.
394
+ * - `oldValue`: The old value of the attribute.
395
+ * - `context`: The action context, which includes information about the action that triggered the change. When context.offline === true then the change is locally generated and not from the controller.
396
+ */
397
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
186
398
  async subscribeAttribute(cluster, attribute, listener, log) {
187
399
  return await subscribeAttribute(this, cluster, attribute, listener, log);
188
400
  }
401
+ /**
402
+ * Triggers an event on the specified cluster.
403
+ *
404
+ * @param {ClusterId} cluster - The ID of the cluster.
405
+ * @param {string} event - The name of the event to trigger.
406
+ * @param {Record<string, boolean | number | bigint | string | object | undefined | null>} payload - The payload to pass to the event.
407
+ * @param {AnsiLogger} [log] - Optional logger for logging information.
408
+ * @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the event was successfully triggered.
409
+ */
189
410
  async triggerEvent(cluster, event, payload, log) {
190
411
  return await triggerEvent(this, cluster, event, payload, log);
191
412
  }
413
+ /**
414
+ * Adds cluster servers from the provided server list.
415
+ *
416
+ * @param {ClusterId[]} serverList - The list of cluster IDs to add.
417
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
418
+ */
192
419
  addClusterServers(serverList) {
193
420
  addClusterServers(this, serverList);
194
421
  return this;
195
422
  }
423
+ /**
424
+ * Adds a fixed label to the FixedLabel cluster. If the cluster server is not present, it will be added.
425
+ *
426
+ * @param {string} label - The label to add.
427
+ * @param {string} value - The value of the label.
428
+ * @returns {Promise<this>} The current MatterbridgeEndpoint instance for chaining.
429
+ */
196
430
  async addFixedLabel(label, value) {
197
431
  await addFixedLabel(this, label, value);
198
432
  return this;
199
433
  }
434
+ /**
435
+ * Adds a user label to the UserLabel cluster. If the cluster server is not present, it will be added.
436
+ *
437
+ * @param {string} label - The label to add.
438
+ * @param {string} value - The value of the label.
439
+ * @returns {Promise<this>} The current MatterbridgeEndpoint instance for chaining.
440
+ */
200
441
  async addUserLabel(label, value) {
201
442
  await addUserLabel(this, label, value);
202
443
  return this;
203
444
  }
445
+ /**
446
+ * Adds a command handler for the specified command.
447
+ *
448
+ * @param {keyof MatterbridgeEndpointCommands} command - The command to add the handler for.
449
+ * @param {CommandHandlerFunction} handler - The handler function to execute when the command is received.
450
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
451
+ *
452
+ * @remarks
453
+ * The handler function will receive an object with the following properties:
454
+ * - `request`: The request object sent with the command.
455
+ * - `cluster`: The id of the cluster that received the command (i.e. "onOff").
456
+ * - `attributes`: The current attributes of the cluster that received the command (i.e. { onOff: true}).
457
+ * - `endpoint`: The MatterbridgeEndpoint instance that received the command.
458
+ */
204
459
  addCommandHandler(command, handler) {
205
460
  this.commandHandler.addHandler(command, handler);
206
461
  return this;
207
462
  }
463
+ /**
464
+ * Execute the command handler for the specified command. Used ONLY in Jest tests.
465
+ *
466
+ * @param {keyof MatterbridgeEndpointCommands} command - The command to execute.
467
+ * @param {Record<string, boolean | number | bigint | string | object | null>} [request] - The optional request to pass to the handler function.
468
+ * @param {string} [cluster] - The optional cluster to pass to the handler function.
469
+ * @param {Record<string, boolean | number | bigint | string | object | null>} [attributes] - The optional attributes to pass to the handler function.
470
+ * @param {MatterbridgeEndpoint} [endpoint] - The optional MatterbridgeEndpoint instance to pass to the handler function
471
+ *
472
+ * @deprecated Used ONLY in Jest tests.
473
+ */
208
474
  async executeCommandHandler(command, request, cluster, attributes, endpoint) {
209
475
  await this.commandHandler.executeHandler(command, { request, cluster, attributes, endpoint });
210
476
  }
477
+ /**
478
+ * Invokes a behavior command on the specified cluster. Used ONLY in Jest tests.
479
+ *
480
+ * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to invoke the command on.
481
+ * @param {string} command - The command to invoke.
482
+ * @param {Record<string, boolean | number | bigint | string | object | null>} [params] - The optional parameters to pass to the command.
483
+ *
484
+ * @deprecated Used ONLY in Jest tests.
485
+ */
211
486
  async invokeBehaviorCommand(cluster, command, params) {
212
487
  await invokeBehaviorCommand(this, cluster, command, params);
213
488
  }
489
+ /**
490
+ * Adds the required cluster servers (only if they are not present) for the device types of the specified endpoint.
491
+ *
492
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
493
+ */
214
494
  addRequiredClusterServers() {
215
495
  addRequiredClusterServers(this);
216
496
  return this;
217
497
  }
498
+ /**
499
+ * Adds the optional cluster servers (only if they are not present) for the device types of the specified endpoint.
500
+ *
501
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
502
+ */
218
503
  addOptionalClusterServers() {
219
504
  addOptionalClusterServers(this);
220
505
  return this;
221
506
  }
507
+ /**
508
+ * Retrieves all cluster servers.
509
+ *
510
+ * @returns {Behavior.Type[]} An array of all cluster servers.
511
+ */
222
512
  getAllClusterServers() {
223
513
  return Object.values(this.behaviors.supported);
224
514
  }
515
+ /**
516
+ * Retrieves the names of all cluster servers.
517
+ *
518
+ * @returns {string[]} An array of all cluster server names.
519
+ */
225
520
  getAllClusterServerNames() {
226
521
  return Object.keys(this.behaviors.supported);
227
522
  }
523
+ /**
524
+ * Iterates over each attribute of each cluster server of the device state and calls the provided callback function.
525
+ *
526
+ * @param {Function} callback - The callback function to call with the cluster name, cluster id, attribute name, attribute id and attribute value.
527
+ */
228
528
  forEachAttribute(callback) {
229
529
  if (!this.lifecycle.isReady || this.construction.status !== Lifecycle.Status.Active)
230
530
  return;
231
531
  for (const [clusterName, clusterAttributes] of Object.entries(this.state)) {
532
+ // Skip if the key / cluster name is a number, cause they are double indexed.
232
533
  if (!isNaN(Number(clusterName)))
233
534
  continue;
234
535
  for (const [attributeName, attributeValue] of Object.entries(clusterAttributes)) {
536
+ // Skip if the behavior has no associated cluster (i.e. matterbridge server)
235
537
  const clusterId = getClusterId(this, clusterName);
236
538
  if (clusterId === undefined) {
539
+ // this.log.debug(`***forEachAttribute: cluster ${clusterName} not found`);
237
540
  continue;
238
541
  }
542
+ // Skip if the attribute is not present in the ClusterBehavior.Type. Also skip if the attribute it is an internal state.
239
543
  const attributeId = getAttributeId(this, clusterName, attributeName);
240
544
  if (attributeId === undefined) {
545
+ // this.log.debug(`***forEachAttribute: attribute ${clusterName}.${attributeName} not found`);
241
546
  continue;
242
547
  }
243
548
  callback(clusterName, clusterId, attributeName, attributeId, attributeValue);
244
549
  }
245
550
  }
246
551
  }
552
+ /**
553
+ * Adds a child endpoint with the specified device types and options.
554
+ * If the child endpoint is not already present, it will be created and added.
555
+ * If the child endpoint is already present, the existing child endpoint will be returned.
556
+ *
557
+ * @param {string} endpointName - The name of the new endpoint to add.
558
+ * @param {DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>} definition - The device types to add.
559
+ * @param {MatterbridgeEndpointOptions} [options] - The options for the endpoint.
560
+ * @param {boolean} [debug] - Whether to enable debug logging.
561
+ * @returns {MatterbridgeEndpoint} - The child endpoint that was found or added.
562
+ *
563
+ * @example
564
+ * ```typescript
565
+ * const endpoint = device.addChildDeviceType('Temperature', [temperatureSensor], { tagList: [{ mfgCode: null, namespaceId: LocationTag.Indoor.namespaceId, tag: LocationTag.Indoor.tag, label: null }] }, true);
566
+ * ```
567
+ */
247
568
  addChildDeviceType(endpointName, definition, options = {}, debug = false) {
248
569
  this.log.debug(`addChildDeviceType: ${CYAN}${endpointName}${db}`);
249
570
  let alreadyAdded = false;
@@ -279,6 +600,7 @@ export class MatterbridgeEndpoint extends Endpoint {
279
600
  this.add(child);
280
601
  }
281
602
  catch (error) {
603
+ // istanbul ignore next cause is only a safety check
282
604
  inspectError(this.log, `addChildDeviceType: error adding (with lifecycle installed) child endpoint ${CYAN}${endpointName}${db}`, error);
283
605
  }
284
606
  }
@@ -288,11 +610,29 @@ export class MatterbridgeEndpoint extends Endpoint {
288
610
  this.parts.add(child);
289
611
  }
290
612
  catch (error) {
613
+ // istanbul ignore next cause is only a safety check
291
614
  inspectError(this.log, `addChildDeviceType: error adding (with lifecycle NOT installed) child endpoint ${CYAN}${endpointName}${db}`, error);
292
615
  }
293
616
  }
294
617
  return child;
295
618
  }
619
+ /**
620
+ * Adds a child endpoint with one or more device types with the required cluster servers and the specified cluster servers.
621
+ * If the child endpoint is not already present in the childEndpoints, it will be added.
622
+ * If the child endpoint is already present in the childEndpoints, the device types and cluster servers will be added to the existing child endpoint.
623
+ *
624
+ * @param {string} endpointName - The name of the new enpoint to add.
625
+ * @param {DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>} definition - The device types to add.
626
+ * @param {ClusterId[]} [serverList] - The list of cluster IDs to include.
627
+ * @param {MatterbridgeEndpointOptions} [options] - The options for the device.
628
+ * @param {boolean} [debug] - Whether to enable debug logging.
629
+ * @returns {MatterbridgeEndpoint} - The child endpoint that was found or added.
630
+ *
631
+ * @example
632
+ * ```typescript
633
+ * const endpoint = device.addChildDeviceTypeWithClusterServer('Temperature', [temperatureSensor], [], { tagList: [{ mfgCode: null, namespaceId: LocationTag.Indoor.namespaceId, tag: LocationTag.Indoor.tag, label: null }] }, true);
634
+ * ```
635
+ */
296
636
  addChildDeviceTypeWithClusterServer(endpointName, definition, serverList = [], options = {}, debug = false) {
297
637
  this.log.debug(`addChildDeviceTypeWithClusterServer: ${CYAN}${endpointName}${db}`);
298
638
  let alreadyAdded = false;
@@ -351,6 +691,7 @@ export class MatterbridgeEndpoint extends Endpoint {
351
691
  this.add(child);
352
692
  }
353
693
  catch (error) {
694
+ // istanbul ignore next cause is only a safety check
354
695
  inspectError(this.log, `addChildDeviceType: error adding (with lifecycle installed) child endpoint ${CYAN}${endpointName}${db}`, error);
355
696
  }
356
697
  }
@@ -360,26 +701,68 @@ export class MatterbridgeEndpoint extends Endpoint {
360
701
  this.parts.add(child);
361
702
  }
362
703
  catch (error) {
704
+ // istanbul ignore next cause is only a safety check
363
705
  inspectError(this.log, `addChildDeviceType: error adding (with lifecycle NOT installed) child endpoint ${CYAN}${endpointName}${db}`, error);
364
706
  }
365
707
  }
366
708
  return child;
367
709
  }
710
+ /**
711
+ * Retrieves a child endpoint by its name (id).
712
+ * Since the name is stored like id, the endpointName should be without spaces and dots.
713
+ * If case of not latin characters, the endpointName should be the generated unique id.
714
+ *
715
+ * @param {string} endpointName - The name of the endpoint to retrieve.
716
+ * @returns {Endpoint | undefined} The child endpoint with the specified name, or undefined if not found.
717
+ * @deprecated Use getChildEndpointById() or getChildEndpointByOriginalId() instead.
718
+ */
368
719
  getChildEndpointByName(endpointName) {
369
720
  return this.parts.find((part) => part.id === endpointName);
370
721
  }
722
+ /**
723
+ * Retrieves a child endpoint by its id.
724
+ * Since the id of a child endpoint is the endpointName passed in the constructor, the id to retrieve it should be without spaces and dots.
725
+ * If case of not latin characters, the id is a generated unique id.
726
+ *
727
+ * @param {string} id - The id of the endpoint to retrieve.
728
+ * @returns {Endpoint | undefined} The child endpoint with the specified id, or undefined if not found.
729
+ */
371
730
  getChildEndpointById(id) {
372
731
  return this.parts.find((part) => part.id === id);
373
732
  }
733
+ /**
734
+ * Retrieves a child endpoint by its original id (the id of MatterbridgeEndpointOptions).
735
+ *
736
+ * @param {string} originalId - The original id of the endpoint to retrieve.
737
+ * @returns {Endpoint | undefined} The child endpoint with the specified originalId, or undefined if not found.
738
+ */
374
739
  getChildEndpointByOriginalId(originalId) {
375
740
  return this.parts.find((part) => part.originalId === originalId);
376
741
  }
742
+ /**
743
+ * Retrieves a child endpoint by its EndpointNumber.
744
+ *
745
+ * @param {EndpointNumber} endpointNumber - The EndpointNumber of the endpoint to retrieve.
746
+ * @returns {MatterbridgeEndpoint | undefined} The child endpoint with the specified EndpointNumber, or undefined if not found.
747
+ */
377
748
  getChildEndpoint(endpointNumber) {
378
749
  return this.parts.find((part) => part.number === endpointNumber);
379
750
  }
751
+ /**
752
+ * Get all the child endpoints of this endpoint.
753
+ *
754
+ * @returns {MatterbridgeEndpoint[]} The child endpoints.
755
+ */
380
756
  getChildEndpoints() {
381
757
  return Array.from(this.parts);
382
758
  }
759
+ /**
760
+ * Serializes the Matterbridge device into a serialized object.
761
+ *
762
+ * @param {MatterbridgeEndpoint} device - The Matterbridge device to serialize.
763
+ *
764
+ * @returns {SerializedMatterbridgeEndpoint | undefined} The serialized Matterbridge device object.
765
+ */
383
766
  static serialize(device) {
384
767
  if (!device.serialNumber || !device.deviceName || !device.uniqueId || !device.maybeId || !device.maybeNumber)
385
768
  return;
@@ -402,9 +785,16 @@ export class MatterbridgeEndpoint extends Endpoint {
402
785
  serialized.clusterServersId.push(BridgedDeviceBasicInformation.Cluster.id);
403
786
  if (behaviorName === 'powerSource')
404
787
  serialized.clusterServersId.push(PowerSource.Cluster.id);
788
+ // serialized.clusterServersId.push(this.behaviors.supported[behaviorName]cluster.id);
405
789
  });
406
790
  return serialized;
407
791
  }
792
+ /**
793
+ * Deserializes the device into a serialized object.
794
+ *
795
+ * @param {SerializedMatterbridgeEndpoint} serializedDevice - The serialized Matterbridge device object.
796
+ * @returns {MatterbridgeEndpoint | undefined} The deserialized Matterbridge device.
797
+ */
408
798
  static deserialize(serializedDevice) {
409
799
  const device = new MatterbridgeEndpoint(serializedDevice.deviceTypes, { id: serializedDevice.id, number: serializedDevice.number }, false);
410
800
  device.plugin = serializedDevice.pluginName;
@@ -420,25 +810,103 @@ export class MatterbridgeEndpoint extends Endpoint {
420
810
  device.createDefaultBridgedDeviceBasicInformationClusterServer(serializedDevice.deviceName, serializedDevice.serialNumber, serializedDevice.vendorId ?? 0xfff1, serializedDevice.vendorName ?? 'Matterbridge', serializedDevice.productName ?? 'Matterbridge device');
421
811
  else if (clusterId === PowerSource.Cluster.id)
422
812
  device.createDefaultPowerSourceWiredClusterServer();
813
+ // else addClusterServerFromList(device, [clusterId]);
423
814
  }
424
815
  return device;
425
816
  }
817
+ /** Utility Cluster Helpers */
818
+ /**
819
+ * Creates a default power source wired cluster server.
820
+ *
821
+ * @param {PowerSource.WiredCurrentType} wiredCurrentType - The type of wired current (default: PowerSource.WiredCurrentType.Ac)
822
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
823
+ *
824
+ * @remarks
825
+ * - order: The order of the power source is a persisted attribute that indicates the order in which the power sources are used.
826
+ * - description: The description of the power source is a fixed attribute that describes the power source type.
827
+ * - wiredCurrentType: The type of wired current is a fixed attribute that indicates the type of wired current used by the power source (AC or DC).
828
+ */
426
829
  createDefaultPowerSourceWiredClusterServer(wiredCurrentType = PowerSource.WiredCurrentType.Ac) {
427
830
  this.behaviors.require(MatterbridgePowerSourceServer.with(PowerSource.Feature.Wired), getDefaultPowerSourceWiredClusterServer(wiredCurrentType));
428
831
  return this;
429
832
  }
833
+ /**
834
+ * Creates a default power source battery cluster server.
835
+ *
836
+ * @param {null | number} batPercentRemaining - The remaining battery percentage (default: null). The attribute is in the range 0-200.
837
+ * @param {PowerSource.BatChargeLevel} batChargeLevel - The battery charge level (default: PowerSource.BatChargeLevel.Ok).
838
+ * @param {null | number} batVoltage - The battery voltage (default: null).
839
+ * @param {PowerSource.BatReplaceability} batReplaceability - The replaceability of the battery (default: PowerSource.BatReplaceability.Unspecified).
840
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
841
+ *
842
+ * @remarks
843
+ * - order: The order of the power source is a persisted attribute that indicates the order in which the power sources are used.
844
+ * - description: The description of the power source is a fixed attribute that describes the power source type.
845
+ * - batReplaceability: The replaceability of the battery is a fixed attribute that indicates whether the battery is user-replaceable or not.
846
+ */
430
847
  createDefaultPowerSourceBatteryClusterServer(batPercentRemaining = null, batChargeLevel = PowerSource.BatChargeLevel.Ok, batVoltage = null, batReplaceability = PowerSource.BatReplaceability.Unspecified) {
431
848
  this.behaviors.require(MatterbridgePowerSourceServer.with(PowerSource.Feature.Battery), getDefaultPowerSourceBatteryClusterServer(batPercentRemaining, batChargeLevel, batVoltage, batReplaceability));
432
849
  return this;
433
850
  }
851
+ /**
852
+ * Creates a default power source replaceable battery cluster server.
853
+ *
854
+ * @param {number} batPercentRemaining - The remaining battery percentage (default: 100). The attribute is in the range 0-200.
855
+ * @param {PowerSource.BatChargeLevel} batChargeLevel - The battery charge level (default: PowerSource.BatChargeLevel.Ok).
856
+ * @param {number} batVoltage - The battery voltage (default: 1500).
857
+ * @param {string} batReplacementDescription - The description of the battery replacement (default: 'Battery type').
858
+ * @param {number} batQuantity - The quantity of the battery (default: 1).
859
+ * @param {PowerSource.BatReplaceability} batReplaceability - The replaceability of the battery (default: PowerSource.BatReplaceability.UserReplaceable).
860
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
861
+ *
862
+ * @remarks
863
+ * - order: The order of the power source is a persisted attribute that indicates the order in which the power sources are used.
864
+ * - description: The description of the power source is a fixed attribute that describes the power source type.
865
+ * - batReplaceability: The replaceability of the battery is a fixed attribute that indicates whether the battery is user-replaceable or not.
866
+ * - batReplacementDescription: The description of the battery replacement is a fixed attribute that describes the battery type.
867
+ * - batQuantity: The quantity of the battery is a fixed attribute that indicates how many batteries are present in the device.
868
+ */
434
869
  createDefaultPowerSourceReplaceableBatteryClusterServer(batPercentRemaining = 100, batChargeLevel = PowerSource.BatChargeLevel.Ok, batVoltage = 1500, batReplacementDescription = 'Battery type', batQuantity = 1, batReplaceability = PowerSource.BatReplaceability.UserReplaceable) {
435
870
  this.behaviors.require(MatterbridgePowerSourceServer.with(PowerSource.Feature.Battery, PowerSource.Feature.Replaceable), getDefaultPowerSourceReplaceableBatteryClusterServer(batPercentRemaining, batChargeLevel, batVoltage, batReplacementDescription, batQuantity, batReplaceability));
436
871
  return this;
437
872
  }
873
+ /**
874
+ * Creates a default power source rechargeable battery cluster server.
875
+ *
876
+ * @param {number} [batPercentRemaining] - The remaining battery percentage (default: 100). The attribute is in the range 0-200.
877
+ * @param {PowerSource.BatChargeLevel} [batChargeLevel] - The battery charge level (default: PowerSource.BatChargeLevel.Ok).
878
+ * @param {number} [batVoltage] - The battery voltage in mV (default: 1500).
879
+ * @param {PowerSource.BatReplaceability} [batReplaceability] - The replaceability of the battery (default: PowerSource.BatReplaceability.Unspecified).
880
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
881
+ *
882
+ * @remarks
883
+ * - order: The order of the power source is a persisted attribute that indicates the order in which the power sources are used.
884
+ * - description: The description of the power source is a fixed attribute that describes the power source type.
885
+ * - batReplaceability: The replaceability of the battery is a fixed attribute that indicates whether the battery is user-replaceable or not.
886
+ */
438
887
  createDefaultPowerSourceRechargeableBatteryClusterServer(batPercentRemaining = 100, batChargeLevel = PowerSource.BatChargeLevel.Ok, batVoltage = 1500, batReplaceability = PowerSource.BatReplaceability.Unspecified) {
439
888
  this.behaviors.require(MatterbridgePowerSourceServer.with(PowerSource.Feature.Battery, PowerSource.Feature.Rechargeable), getDefaultPowerSourceRechargeableBatteryClusterServer(batPercentRemaining, batChargeLevel, batVoltage, batReplaceability));
440
889
  return this;
441
890
  }
891
+ /**
892
+ * Setup the default Basic Information Cluster Server attributes for the server node.
893
+ *
894
+ * This method sets the device name, serial number, unique ID, vendor ID, vendor name, product ID, product name, software version, software version string, hardware version and hardware version string.
895
+ *
896
+ * The actual BasicInformationClusterServer is created by the Matterbridge class for device.mode = 'server' and for the device of an AccessoryPlatform.
897
+ *
898
+ * @param {string} deviceName - The name of the device.
899
+ * @param {string} serialNumber - The serial number of the device.
900
+ * @param {number} [vendorId] - The vendor ID of the device. Default is 0xfff1 (Matter Test VendorId).
901
+ * @param {string} [vendorName] - The name of the vendor. Default is 'Matterbridge'.
902
+ * @param {number} [productId] - The product ID of the device. Default is 0x8000 (Matter Test ProductId).
903
+ * @param {string} [productName] - The name of the product. Default is 'Matterbridge device'.
904
+ * @param {number} [softwareVersion] - The software version of the device. Default is 1.
905
+ * @param {string} [softwareVersionString] - The software version string of the device. Default is '1.0.0'.
906
+ * @param {number} [hardwareVersion] - The hardware version of the device. Default is 1.
907
+ * @param {string} [hardwareVersionString] - The hardware version string of the device. Default is '1.0.0'.
908
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
909
+ */
442
910
  createDefaultBasicInformationClusterServer(deviceName, serialNumber, vendorId = 0xfff1, vendorName = 'Matterbridge', productId = 0x8000, productName = 'Matterbridge device', softwareVersion = 1, softwareVersionString = '1.0.0', hardwareVersion = 1, hardwareVersionString = '1.0.0') {
443
911
  this.log.logName = deviceName;
444
912
  this.deviceName = deviceName;
@@ -454,6 +922,26 @@ export class MatterbridgeEndpoint extends Endpoint {
454
922
  this.hardwareVersionString = hardwareVersionString;
455
923
  return this;
456
924
  }
925
+ /**
926
+ * Creates a default BridgedDeviceBasicInformationClusterServer for the aggregator endpoints.
927
+ *
928
+ * This method sets the device name, serial number, unique ID, vendor ID, vendor name, product name, software version, software version string, hardware version and hardware version string.
929
+ *
930
+ * @param {string} deviceName - The name of the device.
931
+ * @param {string} serialNumber - The serial number of the device.
932
+ * @param {number} [vendorId] - The vendor ID of the device. Default is 0xfff1 (Matter Test VendorId).
933
+ * @param {string} [vendorName] - The name of the vendor. Default is 'Matterbridge'.
934
+ * @param {string} [productName] - The name of the product. Default is 'Matterbridge device'.
935
+ * @param {number} [softwareVersion] - The software version of the device. Default is 1.
936
+ * @param {string} [softwareVersionString] - The software version string of the device. Default is '1.0.0'.
937
+ * @param {number} [hardwareVersion] - The hardware version of the device. Default is 1.
938
+ * @param {string} [hardwareVersionString] - The hardware version string of the device. Default is '1.0.0'.
939
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
940
+ *
941
+ * @remarks
942
+ * - The productId doesn't exist on the BridgedDeviceBasicInformation cluster.
943
+ * - The bridgedNode device type must be added to the deviceTypeList of the Descriptor cluster.
944
+ */
457
945
  createDefaultBridgedDeviceBasicInformationClusterServer(deviceName, serialNumber, vendorId = 0xfff1, vendorName = 'Matterbridge', productName = 'Matterbridge device', softwareVersion = 1, softwareVersionString = '1.0.0', hardwareVersion = 1, hardwareVersionString = '1.0.0') {
458
946
  this.log.logName = deviceName;
459
947
  this.deviceName = deviceName;
@@ -486,30 +974,101 @@ export class MatterbridgeEndpoint extends Endpoint {
486
974
  });
487
975
  return this;
488
976
  }
977
+ /**
978
+ * Creates a default Power Topology Cluster Server with feature TreeTopology (the endpoint provides or consumes power to/from itself and its child endpoints). Only needed for an electricalSensor device type.
979
+ *
980
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
981
+ */
489
982
  createDefaultPowerTopologyClusterServer() {
490
983
  this.behaviors.require(PowerTopologyServer.with(PowerTopology.Feature.TreeTopology));
491
984
  return this;
492
985
  }
986
+ /**
987
+ * Creates a default Electrical Energy Measurement Cluster Server with features ImportedEnergy, ExportedEnergy, and CumulativeEnergy.
988
+ *
989
+ * @param {number} energyImported - The total consumption value in mW/h.
990
+ * @param {number} energyExported - The total production value in mW/h.
991
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
992
+ */
493
993
  createDefaultElectricalEnergyMeasurementClusterServer(energyImported = null, energyExported = null) {
494
994
  this.behaviors.require(ElectricalEnergyMeasurementServer.with(ElectricalEnergyMeasurement.Feature.ImportedEnergy, ElectricalEnergyMeasurement.Feature.ExportedEnergy, ElectricalEnergyMeasurement.Feature.CumulativeEnergy), getDefaultElectricalEnergyMeasurementClusterServer(energyImported, energyExported));
495
995
  return this;
496
996
  }
997
+ /**
998
+ * Creates a default Electrical Power Measurement Cluster Server with features AlternatingCurrent.
999
+ *
1000
+ * @param {number} voltage - The voltage value in millivolts.
1001
+ * @param {number} current - The current value in milliamperes.
1002
+ * @param {number} power - The power value in milliwatts.
1003
+ * @param {number} frequency - The frequency value in millihertz.
1004
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1005
+ */
497
1006
  createDefaultElectricalPowerMeasurementClusterServer(voltage = null, current = null, power = null, frequency = null) {
498
1007
  this.behaviors.require(ElectricalPowerMeasurementServer.with(ElectricalPowerMeasurement.Feature.AlternatingCurrent), getDefaultElectricalPowerMeasurementClusterServer(voltage, current, power, frequency));
499
1008
  return this;
500
1009
  }
1010
+ /**
1011
+ * Creates a default Electrical Apparent Power Measurement Cluster Server with features AlternatingCurrent.
1012
+ *
1013
+ * @param {number} voltage - The voltage value in millivolts.
1014
+ * @param {number} apparentCurrent - The current value in milliamperes.
1015
+ * @param {number} apparentPower - The apparent power value in millivoltamperes.
1016
+ * @param {number} frequency - The frequency value in millihertz.
1017
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1018
+ */
501
1019
  createApparentElectricalPowerMeasurementClusterServer(voltage = null, apparentCurrent = null, apparentPower = null, frequency = null) {
502
1020
  this.behaviors.require(ElectricalPowerMeasurementServer.with(ElectricalPowerMeasurement.Feature.AlternatingCurrent), getApparentElectricalPowerMeasurementClusterServer(voltage, apparentCurrent, apparentPower, frequency));
503
1021
  return this;
504
1022
  }
1023
+ /**
1024
+ * Creates a default Device Energy Management Cluster Server with feature PowerForecastReporting and with the specified ESA type, ESA canGenerate, ESA state, and power limits.
1025
+ *
1026
+ * @param {DeviceEnergyManagement.EsaType} [esaType] - The ESA type. Defaults to `DeviceEnergyManagement.EsaType.Other`.
1027
+ * @param {boolean} [esaCanGenerate] - Indicates if the ESA can generate energy. Defaults to `false`.
1028
+ * @param {DeviceEnergyManagement.EsaState} [esaState] - The ESA state. Defaults to `DeviceEnergyManagement.EsaState.Online`.
1029
+ * @param {number} [absMinPower] - Indicate the minimum electrical power in mw that the ESA can consume when switched on. Defaults to `0` if not provided.
1030
+ * @param {number} [absMaxPower] - Indicate the maximum electrical power in mw that the ESA can consume when switched on. Defaults to `0` if not provided.
1031
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1032
+ *
1033
+ * @remarks
1034
+ * - The forecast attribute is set to null, indicating that there is no forecast currently available.
1035
+ * - The ESA type and canGenerate attributes are fixed and cannot be changed after creation.
1036
+ * - The ESA state is set to Online by default.
1037
+ * - The absolute minimum and maximum power attributes are set to 0 by default.
1038
+ * - For example, a battery storage inverter that can charge its battery at a maximum power of 2000W and can
1039
+ * discharge the battery at a maximum power of 3000W, would have a absMinPower: -3000W, absMaxPower: 2000W.
1040
+ */
505
1041
  createDefaultDeviceEnergyManagementClusterServer(esaType = DeviceEnergyManagement.EsaType.Other, esaCanGenerate = false, esaState = DeviceEnergyManagement.EsaState.Online, absMinPower = 0, absMaxPower = 0) {
506
1042
  this.behaviors.require(MatterbridgeDeviceEnergyManagementServer.with(DeviceEnergyManagement.Feature.PowerForecastReporting, DeviceEnergyManagement.Feature.PowerAdjustment), getDefaultDeviceEnergyManagementClusterServer(esaType, esaCanGenerate, esaState, absMinPower, absMaxPower));
507
1043
  return this;
508
1044
  }
1045
+ /**
1046
+ * Creates a default EnergyManagementMode Cluster Server.
1047
+ *
1048
+ * @param {number} [currentMode] - The current mode of the EnergyManagementMode cluster. Defaults to mode 1 (DeviceEnergyManagementMode.ModeTag.NoOptimization).
1049
+ * @param {EnergyManagementMode.ModeOption[]} [supportedModes] - The supported modes for the DeviceEnergyManagementMode cluster. The attribute is fixed and defaults to a predefined set of cluster modes.
1050
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1051
+ *
1052
+ * @remarks
1053
+ * A few examples of Device Energy Management modes and their mode tags are provided below.
1054
+ * - For the "No Energy Management (Forecast reporting only)" mode, tags: 0x4000 (NoOptimization).
1055
+ * - For the "Device Energy Management" mode, tags: 0x4001 (DeviceOptimization).
1056
+ * - For the "Home Energy Management" mode, tags: 0x4001 (DeviceOptimization), 0x4002 (LocalOptimization).
1057
+ * - For the "Grid Energy Management" mode, tags: 0x4003 (GridOptimization).
1058
+ * - For the "Full Energy Management" mode, tags: 0x4001 (DeviceOptimization), 0x4002 (LocalOptimization), 0x4003 (GridOptimization).
1059
+ */
509
1060
  createDefaultDeviceEnergyManagementModeClusterServer(currentMode, supportedModes) {
510
1061
  this.behaviors.require(MatterbridgeDeviceEnergyManagementModeServer, getDefaultDeviceEnergyManagementModeClusterServer(currentMode, supportedModes));
511
1062
  return this;
512
1063
  }
1064
+ /** Application Cluster Helpers */
1065
+ /**
1066
+ * Creates a default identify cluster server with the specified identify time and type.
1067
+ *
1068
+ * @param {number} [identifyTime] - The time to identify the server. Defaults to 0.
1069
+ * @param {Identify.IdentifyType} [identifyType] - The type of identification. Defaults to Identify.IdentifyType.None.
1070
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1071
+ */
513
1072
  createDefaultIdentifyClusterServer(identifyTime = 0, identifyType = Identify.IdentifyType.None) {
514
1073
  this.behaviors.require(MatterbridgeIdentifyServer, {
515
1074
  identifyTime,
@@ -517,14 +1076,36 @@ export class MatterbridgeEndpoint extends Endpoint {
517
1076
  });
518
1077
  return this;
519
1078
  }
1079
+ /**
1080
+ * Creates a default groups cluster server.
1081
+ *
1082
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1083
+ */
520
1084
  createDefaultGroupsClusterServer() {
521
1085
  this.behaviors.require(GroupsServer);
522
1086
  return this;
523
1087
  }
1088
+ /**
1089
+ * Creates a default scenes management cluster server.
1090
+ *
1091
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1092
+ *
1093
+ * @remarks The scenes management cluster server is still provisional and so not yet implemented.
1094
+ */
524
1095
  createDefaultScenesClusterServer() {
525
1096
  this.behaviors.require(ScenesManagementServer);
526
1097
  return this;
527
1098
  }
1099
+ /**
1100
+ * Creates a default OnOff cluster server for light devices with feature Lighting.
1101
+ *
1102
+ * @param {boolean} [onOff] - The initial state of the OnOff cluster.
1103
+ * @param {boolean} [globalSceneControl] - The global scene control state.
1104
+ * @param {number} [onTime] - The on time value.
1105
+ * @param {number} [offWaitTime] - The off wait time value.
1106
+ * @param {OnOff.StartUpOnOff | null} [startUpOnOff] - The start-up OnOff state. Null means previous state.
1107
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1108
+ */
528
1109
  createDefaultOnOffClusterServer(onOff = false, globalSceneControl = false, onTime = 0, offWaitTime = 0, startUpOnOff = null) {
529
1110
  this.behaviors.require(MatterbridgeOnOffServer.with(OnOff.Feature.Lighting), {
530
1111
  onOff,
@@ -535,24 +1116,73 @@ export class MatterbridgeEndpoint extends Endpoint {
535
1116
  });
536
1117
  return this;
537
1118
  }
1119
+ /**
1120
+ * Creates an OnOff cluster server without features.
1121
+ *
1122
+ * @param {boolean} [onOff] - The initial state of the OnOff cluster.
1123
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1124
+ */
538
1125
  createOnOffClusterServer(onOff = false) {
539
1126
  this.behaviors.require(MatterbridgeOnOffServer, {
540
1127
  onOff,
541
1128
  });
542
1129
  return this;
543
1130
  }
1131
+ /**
1132
+ * Creates a DeadFront OnOff cluster server with feature DeadFrontBehavior.
1133
+ *
1134
+ * The "dead front" state is linked to the OnOff attribute
1135
+ * in the On/Off cluster having the value False. Thus, the Off command of the On/Off cluster SHALL
1136
+ * move the device into the "dead front" state, the On command of the On/Off cluster SHALL bring the
1137
+ * device out of the "dead front" state, and the device SHALL adhere with the associated requirements
1138
+ * on subscription handling and event reporting.
1139
+ *
1140
+ * @param {boolean} [onOff] - The initial state of the OnOff cluster.
1141
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1142
+ */
544
1143
  createDeadFrontOnOffClusterServer(onOff = false) {
545
1144
  this.behaviors.require(MatterbridgeOnOffServer.with(OnOff.Feature.DeadFrontBehavior), {
546
1145
  onOff,
547
1146
  });
548
1147
  return this;
549
1148
  }
1149
+ /**
1150
+ * Creates an OffOnly OnOff cluster server with feature OffOnly.
1151
+ *
1152
+ * @param {boolean} [onOff] - The initial state of the OnOff cluster.
1153
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1154
+ */
550
1155
  createOffOnlyOnOffClusterServer(onOff = false) {
551
1156
  this.behaviors.require(MatterbridgeOnOffServer.with(OnOff.Feature.OffOnly), {
552
1157
  onOff,
553
1158
  });
554
1159
  return this;
555
1160
  }
1161
+ /**
1162
+ * Creates a default level control cluster server for light devices with feature OnOff and Lighting.
1163
+ *
1164
+ * @param {number} [currentLevel] - The current level (default: 254).
1165
+ * @param {number} [minLevel] - The minimum level (default: 1).
1166
+ * @param {number} [maxLevel] - The maximum level (default: 254).
1167
+ * @param {number | null} [onLevel] - The on level (default: null).
1168
+ * @param {number | null} [startUpCurrentLevel] - The startUp on level (default: null).
1169
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1170
+ *
1171
+ * @remarks OptionMasks and OptionOverride fields of moveToLevel and moveToLevelWithOnOff commands requests
1172
+ *
1173
+ * Each bit in the Options attribute SHALL determine the corresponding bit in the temporary Options
1174
+ * bitmap, unless the OptionsMask field is present and has the corresponding bit set to 1, in which
1175
+ * case the corresponding bit in the OptionsOverride field SHALL determine the corresponding bit in
1176
+ * the temporary Options bitmap.
1177
+ *
1178
+ * @remarks 'With On/Off' Commands
1179
+ *
1180
+ * Before commencing any command that has the effect of setting the CurrentLevel attribute above
1181
+ * the minimum level allowed by the device, the OnOff attribute of the On/Off cluster on the same endpoint, if implemented, SHALL be set to TRUE (‘On’).
1182
+ *
1183
+ * If any command that has the effect of setting the CurrentLevel attribute to the minimum level
1184
+ * allowed by the device, the OnOff attribute of the On/Off cluster on the same endpoint, if implemented, SHALL be set to FALSE (‘Off’).
1185
+ */
556
1186
  createDefaultLevelControlClusterServer(currentLevel = 254, minLevel = 1, maxLevel = 254, onLevel = null, startUpCurrentLevel = null) {
557
1187
  this.behaviors.require(MatterbridgeLevelControlServer.with(LevelControl.Feature.OnOff, LevelControl.Feature.Lighting), {
558
1188
  currentLevel,
@@ -568,6 +1198,13 @@ export class MatterbridgeEndpoint extends Endpoint {
568
1198
  });
569
1199
  return this;
570
1200
  }
1201
+ /**
1202
+ * Creates a level control cluster server without features.
1203
+ *
1204
+ * @param {number} [currentLevel] - The current level (default: 254).
1205
+ * @param {number | null} [onLevel] - The on level (default: null).
1206
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1207
+ */
571
1208
  createLevelControlClusterServer(currentLevel = 254, onLevel = null) {
572
1209
  this.behaviors.require(MatterbridgeLevelControlServer, {
573
1210
  currentLevel,
@@ -579,6 +1216,40 @@ export class MatterbridgeEndpoint extends Endpoint {
579
1216
  });
580
1217
  return this;
581
1218
  }
1219
+ /**
1220
+ * Creates a default color control cluster server with features Xy, HueSaturation and ColorTemperature.
1221
+ *
1222
+ * @param {number} currentX - The current X value (range 0-65279).
1223
+ * @param {number} currentY - The current Y value (range 0-65279).
1224
+ * @param {number} currentHue - The current hue value (range: 0-254).
1225
+ * @param {number} currentSaturation - The current saturation value (range: 0-254).
1226
+ * @param {number} colorTemperatureMireds - The color temperature in mireds (range colorTempPhysicalMinMireds-colorTempPhysicalMaxMireds).
1227
+ * @param {number} colorTempPhysicalMinMireds - The physical minimum color temperature in mireds (default 147).
1228
+ * @param {number} colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds (default 500).
1229
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1230
+ *
1231
+ * @remarks colorMode and enhancedColorMode persist across restarts.
1232
+ * @remarks currentHue and currentSaturation persist across restarts.
1233
+ * @remarks currentX and currentY persist across restarts.
1234
+ * @remarks colorTemperatureMireds persists across restarts.
1235
+ * @remarks startUpColorTemperatureMireds persists across restarts.
1236
+ * @remarks coupleColorTempToLevelMinMireds persists across restarts.
1237
+ *
1238
+ * @remarks OptionMasks and OptionOverride fields of color control commands requests
1239
+ *
1240
+ * Each bit in the Options attribute SHALL determine the corresponding bit in the temporary Options
1241
+ * bitmap, unless the OptionsMask field is present and has the corresponding bit set to 1, in which
1242
+ * case the corresponding bit in the OptionsOverride field SHALL determine the corresponding bit in
1243
+ * the temporary Options bitmap.
1244
+ *
1245
+ * @remarks CoupleColorTempToLevel
1246
+ *
1247
+ * If the CoupleColorTempToLevel bit of the Options attribute of the Level Control cluster is equal to 1
1248
+ * and the ColorMode or EnhancedColorMode attribute is set to 2 (ColorTemperatureMireds) then a
1249
+ * change in the CurrentLevel attribute SHALL affect the ColorTemperatureMireds attribute.
1250
+ * This relationship is manufacturer specific, with the qualification that the maximum value of the CurrentLevel attribute
1251
+ * SHALL correspond to a ColorTemperatureMired attribute value equal to the CoupleColorTempToLevelMinMireds attribute.
1252
+ */
582
1253
  createDefaultColorControlClusterServer(currentX = 0, currentY = 0, currentHue = 0, currentSaturation = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
583
1254
  this.behaviors.require(MatterbridgeColorControlServer.with(ColorControl.Feature.Xy, ColorControl.Feature.HueSaturation, ColorControl.Feature.ColorTemperature), {
584
1255
  colorMode: ColorControl.ColorMode.CurrentHueAndCurrentSaturation,
@@ -601,6 +1272,40 @@ export class MatterbridgeEndpoint extends Endpoint {
601
1272
  });
602
1273
  return this;
603
1274
  }
1275
+ /**
1276
+ * Creates a default color control cluster server with features Xy, HueSaturation, EnhancedHueSaturation and ColorTemperature.
1277
+ *
1278
+ * @param {number} currentX - The current X value (range 0-65279).
1279
+ * @param {number} currentY - The current Y value (range 0-65279).
1280
+ * @param {number} enhancedCurrentHue - The enhanced current hue value (range: 0-65535).
1281
+ * @param {number} currentSaturation - The current saturation value (range: 0-254).
1282
+ * @param {number} colorTemperatureMireds - The color temperature in mireds (range colorTempPhysicalMinMireds-colorTempPhysicalMaxMireds).
1283
+ * @param {number} colorTempPhysicalMinMireds - The physical minimum color temperature in mireds (default 147).
1284
+ * @param {number} colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds (default 500).
1285
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1286
+ *
1287
+ * @remarks colorMode and enhancedColorMode persist across restarts.
1288
+ * @remarks currentHue and currentSaturation persist across restarts.
1289
+ * @remarks currentX and currentY persist across restarts.
1290
+ * @remarks colorTemperatureMireds persists across restarts.
1291
+ * @remarks startUpColorTemperatureMireds persists across restarts.
1292
+ * @remarks coupleColorTempToLevelMinMireds persists across restarts.
1293
+ *
1294
+ * @remarks OptionMasks and OptionOverride field
1295
+ *
1296
+ * Each bit in the Options attribute SHALL determine the corresponding bit in the temporary Options
1297
+ * bitmap, unless the OptionsMask field is present and has the corresponding bit set to 1, in which
1298
+ * case the corresponding bit in the OptionsOverride field SHALL determine the corresponding bit in
1299
+ * the temporary Options bitmap.
1300
+ *
1301
+ * @remarks CoupleColorTempToLevel
1302
+ *
1303
+ * If the CoupleColorTempToLevel bit of the Options attribute of the Level Control cluster is equal to 1
1304
+ * and the ColorMode or EnhancedColorMode attribute is set to 2 (ColorTemperatureMireds) then a
1305
+ * change in the CurrentLevel attribute SHALL affect the ColorTemperatureMireds attribute.
1306
+ * This relationship is manufacturer specific, with the qualification that the maximum value of the CurrentLevel attribute
1307
+ * SHALL correspond to a ColorTemperatureMired attribute value equal to the CoupleColorTempToLevelMinMireds attribute.
1308
+ */
604
1309
  createEnhancedColorControlClusterServer(currentX = 0, currentY = 0, enhancedCurrentHue = 0, currentSaturation = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
605
1310
  this.behaviors.require(MatterbridgeEnhancedColorControlServer.with(ColorControl.Feature.Xy, ColorControl.Feature.HueSaturation, ColorControl.Feature.EnhancedHue, ColorControl.Feature.ColorTemperature), {
606
1311
  colorMode: ColorControl.ColorMode.CurrentHueAndCurrentSaturation,
@@ -612,7 +1317,7 @@ export class MatterbridgeEndpoint extends Endpoint {
612
1317
  numberOfPrimaries: null,
613
1318
  currentX,
614
1319
  currentY,
615
- currentHue: Math.round((enhancedCurrentHue / 65535) * 254),
1320
+ currentHue: Math.round((enhancedCurrentHue / 65535) * 254), // currentHue range is 0-254 and enhancedCurrentHue range is 0-65535
616
1321
  enhancedCurrentHue,
617
1322
  currentSaturation,
618
1323
  colorTemperatureMireds,
@@ -624,6 +1329,25 @@ export class MatterbridgeEndpoint extends Endpoint {
624
1329
  });
625
1330
  return this;
626
1331
  }
1332
+ /**
1333
+ * Creates a Xy color control cluster server with feature Xy and ColorTemperature.
1334
+ *
1335
+ * @param {number} currentX - The current X value (range 0-65279).
1336
+ * @param {number} currentY - The current Y value (range 0-65279).
1337
+ * @param {number} colorTemperatureMireds - The color temperature in mireds (range colorTempPhysicalMinMireds-colorTempPhysicalMaxMireds).
1338
+ * @param {number} colorTempPhysicalMinMireds - The physical minimum color temperature in mireds (default 147).
1339
+ * @param {number} colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds (default 500).
1340
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1341
+ *
1342
+ * @remarks
1343
+ * From zigbee to matter = Math.max(Math.min(Math.round(x * 65536), 65279), 0)
1344
+ *
1345
+ * @remarks colorMode and enhancedColorMode persist across restarts.
1346
+ * @remarks currentX and currentY persist across restarts.
1347
+ * @remarks colorTemperatureMireds persists across restarts.
1348
+ * @remarks startUpColorTemperatureMireds persists across restarts.
1349
+ * @remarks coupleColorTempToLevelMinMireds persists across restarts.
1350
+ */
627
1351
  createXyColorControlClusterServer(currentX = 0, currentY = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
628
1352
  this.behaviors.require(MatterbridgeColorControlServer.with(ColorControl.Feature.Xy, ColorControl.Feature.ColorTemperature), {
629
1353
  colorMode: ColorControl.ColorMode.CurrentXAndCurrentY,
@@ -644,6 +1368,22 @@ export class MatterbridgeEndpoint extends Endpoint {
644
1368
  });
645
1369
  return this;
646
1370
  }
1371
+ /**
1372
+ * Creates a default hue and saturation control cluster server with feature HueSaturation and ColorTemperature.
1373
+ *
1374
+ * @param {number} currentHue - The current hue value (range: 0-254).
1375
+ * @param {number} currentSaturation - The current saturation value (range: 0-254).
1376
+ * @param {number} colorTemperatureMireds - The color temperature in mireds (range colorTempPhysicalMinMireds-colorTempPhysicalMaxMireds).
1377
+ * @param {number} colorTempPhysicalMinMireds - The physical minimum color temperature in mireds (default 147).
1378
+ * @param {number} colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds (default 500).
1379
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1380
+ *
1381
+ * @remarks colorMode and enhancedColorMode persist across restarts.
1382
+ * @remarks currentHue and currentSaturation persist across restarts.
1383
+ * @remarks colorTemperatureMireds persists across restarts.
1384
+ * @remarks startUpColorTemperatureMireds persists across restarts.
1385
+ * @remarks coupleColorTempToLevelMinMireds persists across restarts.
1386
+ */
647
1387
  createHsColorControlClusterServer(currentHue = 0, currentSaturation = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
648
1388
  this.behaviors.require(MatterbridgeColorControlServer.with(ColorControl.Feature.HueSaturation, ColorControl.Feature.ColorTemperature), {
649
1389
  colorMode: ColorControl.ColorMode.CurrentHueAndCurrentSaturation,
@@ -664,6 +1404,20 @@ export class MatterbridgeEndpoint extends Endpoint {
664
1404
  });
665
1405
  return this;
666
1406
  }
1407
+ /**
1408
+ * Creates a color temperature color control cluster server with feature ColorTemperature.
1409
+ * This cluster server is used for devices that only support color temperature control.
1410
+ *
1411
+ * @param {number} colorTemperatureMireds - The color temperature in mireds (range colorTempPhysicalMinMireds-colorTempPhysicalMaxMireds).
1412
+ * @param {number} colorTempPhysicalMinMireds - The physical minimum color temperature in mireds (default 147).
1413
+ * @param {number} colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds (default 500).
1414
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1415
+ *
1416
+ * @remarks colorMode and enhancedColorMode persist across restarts.
1417
+ * @remarks colorTemperatureMireds persists across restarts.
1418
+ * @remarks startUpColorTemperatureMireds persists across restarts.
1419
+ * @remarks coupleColorTempToLevelMinMireds persists across restarts.
1420
+ */
667
1421
  createCtColorControlClusterServer(colorTemperatureMireds = 250, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
668
1422
  this.behaviors.require(MatterbridgeColorControlServer.with(ColorControl.Feature.ColorTemperature), {
669
1423
  colorMode: ColorControl.ColorMode.ColorTemperatureMireds,
@@ -682,21 +1436,47 @@ export class MatterbridgeEndpoint extends Endpoint {
682
1436
  });
683
1437
  return this;
684
1438
  }
1439
+ /**
1440
+ * Configures the color control mode for the device.
1441
+ *
1442
+ * @param {ColorControl.ColorMode} colorMode - The color mode to set.
1443
+ *
1444
+ * @remarks colorMode and enhancedColorMode persist across restarts.
1445
+ */
685
1446
  async configureColorControlMode(colorMode) {
686
1447
  if (isValidNumber(colorMode, ColorControl.ColorMode.CurrentHueAndCurrentSaturation, ColorControl.ColorMode.ColorTemperatureMireds)) {
687
1448
  await this.setAttribute(ColorControl.Cluster.id, 'colorMode', colorMode, this.log);
688
1449
  await this.setAttribute(ColorControl.Cluster.id, 'enhancedColorMode', colorMode, this.log);
689
1450
  }
690
1451
  }
1452
+ /**
1453
+ * Configures the enhanced color control mode for the device.
1454
+ *
1455
+ * @param {ColorControl.EnhancedColorMode} colorMode - The enhanced color mode to set.
1456
+ *
1457
+ * @remarks colorMode and enhancedColorMode persist across restarts.
1458
+ */
691
1459
  async configureEnhancedColorControlMode(colorMode) {
692
1460
  if (isValidNumber(colorMode, ColorControl.EnhancedColorMode.CurrentHueAndCurrentSaturation, ColorControl.EnhancedColorMode.EnhancedCurrentHueAndCurrentSaturation)) {
693
1461
  await this.setAttribute(ColorControl.Cluster.id, 'colorMode', colorMode === ColorControl.EnhancedColorMode.EnhancedCurrentHueAndCurrentSaturation ? ColorControl.ColorMode.CurrentHueAndCurrentSaturation : colorMode, this.log);
694
1462
  await this.setAttribute(ColorControl.Cluster.id, 'enhancedColorMode', colorMode, this.log);
695
1463
  }
696
1464
  }
1465
+ /**
1466
+ * Creates a default window covering cluster server with feature Lift and PositionAwareLift.
1467
+ *
1468
+ * @param {number} positionPercent100ths - The position percentage in 100ths (0-10000). Defaults to 0. Matter uses 10000 = fully closed 0 = fully opened.
1469
+ * @param {WindowCovering.WindowCoveringType} type - The type of window covering (default: WindowCovering.WindowCoveringType.Rollershade). Must support feature Lift.
1470
+ * @param {WindowCovering.EndProductType} endProductType - The end product type (default: WindowCovering.EndProductType.RollerShade). Must support feature Lift.
1471
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1472
+ *
1473
+ * @remarks mode attributes is writable and persists across restarts.
1474
+ * currentPositionLiftPercent100ths persists across restarts.
1475
+ * configStatus attributes persists across restarts.
1476
+ */
697
1477
  createDefaultWindowCoveringClusterServer(positionPercent100ths, type = WindowCovering.WindowCoveringType.Rollershade, endProductType = WindowCovering.EndProductType.RollerShade) {
698
1478
  this.behaviors.require(MatterbridgeLiftWindowCoveringServer.with(WindowCovering.Feature.Lift, WindowCovering.Feature.PositionAwareLift), {
699
- type,
1479
+ type, // Must support feature Lift
700
1480
  numberOfActuationsLift: 0,
701
1481
  configStatus: {
702
1482
  operational: true,
@@ -704,20 +1484,33 @@ export class MatterbridgeEndpoint extends Endpoint {
704
1484
  liftMovementReversed: false,
705
1485
  liftPositionAware: true,
706
1486
  tiltPositionAware: false,
707
- liftEncoderControlled: false,
708
- tiltEncoderControlled: false,
1487
+ liftEncoderControlled: false, // 0 = Timer Controlled 1 = Encoder Controlled
1488
+ tiltEncoderControlled: false, // 0 = Timer Controlled 1 = Encoder Controlled
709
1489
  },
710
1490
  operationalStatus: { global: WindowCovering.MovementStatus.Stopped, lift: WindowCovering.MovementStatus.Stopped, tilt: WindowCovering.MovementStatus.Stopped },
711
- endProductType,
1491
+ endProductType, // Must support feature Lift
712
1492
  mode: { motorDirectionReversed: false, calibrationMode: false, maintenanceMode: false, ledFeedback: false },
713
- targetPositionLiftPercent100ths: positionPercent100ths ?? 0,
714
- currentPositionLiftPercent100ths: positionPercent100ths ?? 0,
1493
+ targetPositionLiftPercent100ths: positionPercent100ths ?? 0, // 0 Fully open 10000 fully closed
1494
+ currentPositionLiftPercent100ths: positionPercent100ths ?? 0, // 0 Fully open 10000 fully closed
715
1495
  });
716
1496
  return this;
717
1497
  }
1498
+ /**
1499
+ * Creates a default window covering cluster server with features Lift, PositionAwareLift, Tilt, PositionAwareTilt.
1500
+ *
1501
+ * @param {number} positionLiftPercent100ths - The lift position percentage in 100ths (0-10000). Defaults to 0. Matter uses 10000 = fully closed 0 = fully opened.
1502
+ * @param {number} positionTiltPercent100ths - The tilt position percentage in 100ths (0-10000). Defaults to 0. Matter uses 10000 = fully closed 0 = fully opened.
1503
+ * @param {WindowCovering.WindowCoveringType} type - The type of window covering (default: WindowCovering.WindowCoveringType.TiltBlindLift). Must support features Lift and Tilt.
1504
+ * @param {WindowCovering.EndProductType} endProductType - The end product type (default: WindowCovering.EndProductType.InteriorBlind). Must support features Lift and Tilt.
1505
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1506
+ *
1507
+ * @remarks mode attributes is writable and persists across restarts.
1508
+ * currentPositionTiltPercent100ths persists across restarts.
1509
+ * configStatus attributes persists across restarts.
1510
+ */
718
1511
  createDefaultLiftTiltWindowCoveringClusterServer(positionLiftPercent100ths, positionTiltPercent100ths, type = WindowCovering.WindowCoveringType.TiltBlindLift, endProductType = WindowCovering.EndProductType.InteriorBlind) {
719
1512
  this.behaviors.require(MatterbridgeLiftTiltWindowCoveringServer.with(WindowCovering.Feature.Lift, WindowCovering.Feature.PositionAwareLift, WindowCovering.Feature.Tilt, WindowCovering.Feature.PositionAwareTilt), {
720
- type,
1513
+ type, // Must support features Lift and Tilt
721
1514
  numberOfActuationsLift: 0,
722
1515
  numberOfActuationsTilt: 0,
723
1516
  configStatus: {
@@ -726,19 +1519,23 @@ export class MatterbridgeEndpoint extends Endpoint {
726
1519
  liftMovementReversed: false,
727
1520
  liftPositionAware: true,
728
1521
  tiltPositionAware: true,
729
- liftEncoderControlled: false,
730
- tiltEncoderControlled: false,
1522
+ liftEncoderControlled: false, // 0 = Timer Controlled 1 = Encoder Controlled
1523
+ tiltEncoderControlled: false, // 0 = Timer Controlled 1 = Encoder Controlled
731
1524
  },
732
1525
  operationalStatus: { global: WindowCovering.MovementStatus.Stopped, lift: WindowCovering.MovementStatus.Stopped, tilt: WindowCovering.MovementStatus.Stopped },
733
- endProductType,
1526
+ endProductType, // Must support features Lift and Tilt
734
1527
  mode: { motorDirectionReversed: false, calibrationMode: false, maintenanceMode: false, ledFeedback: false },
735
- targetPositionLiftPercent100ths: positionLiftPercent100ths ?? 0,
736
- currentPositionLiftPercent100ths: positionLiftPercent100ths ?? 0,
737
- targetPositionTiltPercent100ths: positionTiltPercent100ths ?? 0,
738
- currentPositionTiltPercent100ths: positionTiltPercent100ths ?? 0,
1528
+ targetPositionLiftPercent100ths: positionLiftPercent100ths ?? 0, // 0 Fully open 10000 fully closed
1529
+ currentPositionLiftPercent100ths: positionLiftPercent100ths ?? 0, // 0 Fully open 10000 fully closed
1530
+ targetPositionTiltPercent100ths: positionTiltPercent100ths ?? 0, // 0 Fully open 10000 fully closed
1531
+ currentPositionTiltPercent100ths: positionTiltPercent100ths ?? 0, // 0 Fully open 10000 fully closed
739
1532
  });
740
1533
  return this;
741
1534
  }
1535
+ /**
1536
+ * Sets the window covering lift target position as the current position and stops the movement.
1537
+ *
1538
+ */
742
1539
  async setWindowCoveringTargetAsCurrentAndStopped() {
743
1540
  const position = this.getAttribute(WindowCovering.Cluster.id, 'currentPositionLiftPercent100ths', this.log);
744
1541
  if (isValidNumber(position, 0, 10000)) {
@@ -758,6 +1555,13 @@ export class MatterbridgeEndpoint extends Endpoint {
758
1555
  this.log.debug(`Set WindowCovering currentPositionTiltPercent100ths and targetPositionTiltPercent100ths to ${position} and operationalStatus to Stopped.`);
759
1556
  }
760
1557
  }
1558
+ /**
1559
+ * Sets the lift current and target position and the status of a window covering.
1560
+ *
1561
+ * @param {number} current - The current position of the window covering.
1562
+ * @param {number} target - The target position of the window covering.
1563
+ * @param {WindowCovering.MovementStatus} status - The movement status of the window covering.
1564
+ */
761
1565
  async setWindowCoveringCurrentTargetStatus(current, target, status) {
762
1566
  await this.setAttribute(WindowCovering.Cluster.id, 'currentPositionLiftPercent100ths', current, this.log);
763
1567
  await this.setAttribute(WindowCovering.Cluster.id, 'targetPositionLiftPercent100ths', target, this.log);
@@ -768,6 +1572,11 @@ export class MatterbridgeEndpoint extends Endpoint {
768
1572
  }, this.log);
769
1573
  this.log.debug(`Set WindowCovering currentPositionLiftPercent100ths: ${current}, targetPositionLiftPercent100ths: ${target} and operationalStatus: ${status}.`);
770
1574
  }
1575
+ /**
1576
+ * Sets the status of the window covering.
1577
+ *
1578
+ * @param {WindowCovering.MovementStatus} status - The movement status to set.
1579
+ */
771
1580
  async setWindowCoveringStatus(status) {
772
1581
  await this.setAttribute(WindowCovering.Cluster.id, 'operationalStatus', {
773
1582
  global: status,
@@ -776,6 +1585,11 @@ export class MatterbridgeEndpoint extends Endpoint {
776
1585
  }, this.log);
777
1586
  this.log.debug(`Set WindowCovering operationalStatus: ${status}`);
778
1587
  }
1588
+ /**
1589
+ * Retrieves the status of the window covering.
1590
+ *
1591
+ * @returns {WindowCovering.MovementStatus | undefined} The movement status of the window covering, or undefined if not available.
1592
+ */
779
1593
  getWindowCoveringStatus() {
780
1594
  const status = this.getAttribute(WindowCovering.Cluster.id, 'operationalStatus', this.log);
781
1595
  if (isValidObject(status, 3) && 'global' in status && typeof status.global === 'number') {
@@ -783,6 +1597,12 @@ export class MatterbridgeEndpoint extends Endpoint {
783
1597
  return status.global;
784
1598
  }
785
1599
  }
1600
+ /**
1601
+ * Sets the lift target and current position of the window covering.
1602
+ *
1603
+ * @param {number} liftPosition - The position to set, specified as a number.
1604
+ * @param {number} [tiltPosition] - The tilt position to set, specified as a number.
1605
+ */
786
1606
  async setWindowCoveringTargetAndCurrentPosition(liftPosition, tiltPosition) {
787
1607
  await this.setAttribute(WindowCovering.Cluster.id, 'currentPositionLiftPercent100ths', liftPosition, this.log);
788
1608
  await this.setAttribute(WindowCovering.Cluster.id, 'targetPositionLiftPercent100ths', liftPosition, this.log);
@@ -793,10 +1613,31 @@ export class MatterbridgeEndpoint extends Endpoint {
793
1613
  this.log.debug(`Set WindowCovering currentPositionTiltPercent100ths: ${tiltPosition} and targetPositionTiltPercent100ths: ${tiltPosition}.`);
794
1614
  }
795
1615
  }
1616
+ /**
1617
+ * Creates a default thermostat cluster server with features **Heating**, **Cooling** and **AutoMode**.
1618
+ *
1619
+ * - When the occupied parameter is provided (either false or true), the **Occupancy** feature is also added (defaults to undefined).
1620
+ * - When the outdoorTemperature parameter is provided (either null or a number), the outdoorTemperature attribute is also added (defaults to undefined).
1621
+ *
1622
+ * @param {number} [localTemperature] - The local temperature value in degrees Celsius. Defaults to 23°.
1623
+ * @param {number} [occupiedHeatingSetpoint] - The occupied heating setpoint value in degrees Celsius. Defaults to 21°.
1624
+ * @param {number} [occupiedCoolingSetpoint] - The occupied cooling setpoint value in degrees Celsius. Defaults to 25°.
1625
+ * @param {number} [minSetpointDeadBand] - The minimum setpoint dead band value. Defaults to 1°.
1626
+ * @param {number} [minHeatSetpointLimit] - The minimum heat setpoint limit value. Defaults to 0°.
1627
+ * @param {number} [maxHeatSetpointLimit] - The maximum heat setpoint limit value. Defaults to 50°.
1628
+ * @param {number} [minCoolSetpointLimit] - The minimum cool setpoint limit value. Defaults to 0°.
1629
+ * @param {number} [maxCoolSetpointLimit] - The maximum cool setpoint limit value. Defaults to 50°.
1630
+ * @param {number | undefined} [unoccupiedHeatingSetpoint] - The unoccupied heating setpoint value in degrees Celsius. Defaults to 19° (it will be ignored if occupied is not provided).
1631
+ * @param {number | undefined} [unoccupiedCoolingSetpoint] - The unoccupied cooling setpoint value in degrees Celsius. Defaults to 27° (it will be ignored if occupied is not provided).
1632
+ * @param {boolean | undefined} [occupied] - The occupancy status. Defaults to undefined (it will be ignored).
1633
+ * @param {number | null | undefined} [outdoorTemperature] - The outdoor temperature value in degrees Celsius. Defaults to undefined (it will be ignored).
1634
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1635
+ */
796
1636
  createDefaultThermostatClusterServer(localTemperature = 23, occupiedHeatingSetpoint = 21, occupiedCoolingSetpoint = 25, minSetpointDeadBand = 1, minHeatSetpointLimit = 0, maxHeatSetpointLimit = 50, minCoolSetpointLimit = 0, maxCoolSetpointLimit = 50, unoccupiedHeatingSetpoint = undefined, unoccupiedCoolingSetpoint = undefined, occupied = undefined, outdoorTemperature = undefined) {
797
1637
  this.behaviors.require(MatterbridgeThermostatServer.with(Thermostat.Feature.Heating, Thermostat.Feature.Cooling, Thermostat.Feature.AutoMode, ...(occupied !== undefined ? [Thermostat.Feature.Occupancy] : [])), {
1638
+ // Common attributes
798
1639
  localTemperature: localTemperature * 100,
799
- ...(outdoorTemperature !== undefined ? { outdoorTemperature: outdoorTemperature !== null ? outdoorTemperature * 100 : outdoorTemperature } : {}),
1640
+ ...(outdoorTemperature !== undefined ? { outdoorTemperature: outdoorTemperature !== null ? outdoorTemperature * 100 : outdoorTemperature } : {}), // Optional nullable attribute
800
1641
  controlSequenceOfOperation: Thermostat.ControlSequenceOfOperation.CoolingAndHeating,
801
1642
  systemMode: Thermostat.SystemMode.Auto,
802
1643
  thermostatRunningState: {
@@ -808,28 +1649,48 @@ export class MatterbridgeEndpoint extends Endpoint {
808
1649
  fanStage2: false,
809
1650
  fanStage3: false,
810
1651
  },
1652
+ // Thermostat.Feature.Heating
811
1653
  occupiedHeatingSetpoint: occupiedHeatingSetpoint * 100,
812
1654
  minHeatSetpointLimit: minHeatSetpointLimit * 100,
813
1655
  maxHeatSetpointLimit: maxHeatSetpointLimit * 100,
814
1656
  absMinHeatSetpointLimit: minHeatSetpointLimit * 100,
815
1657
  absMaxHeatSetpointLimit: maxHeatSetpointLimit * 100,
1658
+ // Thermostat.Feature.Cooling
816
1659
  occupiedCoolingSetpoint: occupiedCoolingSetpoint * 100,
817
1660
  minCoolSetpointLimit: minCoolSetpointLimit * 100,
818
1661
  maxCoolSetpointLimit: maxCoolSetpointLimit * 100,
819
1662
  absMinCoolSetpointLimit: minCoolSetpointLimit * 100,
820
1663
  absMaxCoolSetpointLimit: maxCoolSetpointLimit * 100,
1664
+ // Thermostat.Feature.AutoMode
821
1665
  minSetpointDeadBand: minSetpointDeadBand * 10,
822
1666
  thermostatRunningMode: Thermostat.ThermostatRunningMode.Off,
1667
+ // Thermostat.Feature.Occupancy
823
1668
  ...(occupied !== undefined ? { unoccupiedHeatingSetpoint: unoccupiedHeatingSetpoint !== undefined ? unoccupiedHeatingSetpoint * 100 : 1900 } : {}),
824
1669
  ...(occupied !== undefined ? { unoccupiedCoolingSetpoint: unoccupiedCoolingSetpoint !== undefined ? unoccupiedCoolingSetpoint * 100 : 2700 } : {}),
825
1670
  ...(occupied !== undefined ? { occupancy: { occupied } } : {}),
826
1671
  });
827
1672
  return this;
828
1673
  }
1674
+ /**
1675
+ * Creates a default heating thermostat cluster server with feature **Heating**.
1676
+ *
1677
+ * - When the occupied parameter is provided (either false or true), the **Occupancy** feature is also added (defaults to undefined).
1678
+ * - When the outdoorTemperature parameter is provided (either null or a number), the outdoorTemperature attribute is also added (defaults to undefined).
1679
+ *
1680
+ * @param {number} [localTemperature] - The local temperature value in degrees Celsius. Defaults to 23°.
1681
+ * @param {number} [occupiedHeatingSetpoint] - The occupied heating setpoint value in degrees Celsius. Defaults to 21°.
1682
+ * @param {number} [minHeatSetpointLimit] - The minimum heat setpoint limit value. Defaults to 0°.
1683
+ * @param {number} [maxHeatSetpointLimit] - The maximum heat setpoint limit value. Defaults to 50°.
1684
+ * @param {number | undefined} [unoccupiedHeatingSetpoint] - The unoccupied heating setpoint value in degrees Celsius. Defaults to 19° (it will be ignored if occupied is not provided).
1685
+ * @param {boolean | undefined} [occupied] - The occupancy status. Defaults to undefined (it will be ignored).
1686
+ * @param {number | null | undefined} [outdoorTemperature] - The outdoor temperature value in degrees Celsius. Defaults to undefined (it will be ignored).
1687
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1688
+ */
829
1689
  createDefaultHeatingThermostatClusterServer(localTemperature = 23, occupiedHeatingSetpoint = 21, minHeatSetpointLimit = 0, maxHeatSetpointLimit = 50, unoccupiedHeatingSetpoint = undefined, occupied = undefined, outdoorTemperature = undefined) {
830
1690
  this.behaviors.require(MatterbridgeThermostatServer.with(Thermostat.Feature.Heating, ...(occupied !== undefined ? [Thermostat.Feature.Occupancy] : [])), {
1691
+ // Common attributes
831
1692
  localTemperature: localTemperature * 100,
832
- ...(outdoorTemperature !== undefined ? { outdoorTemperature: outdoorTemperature !== null ? outdoorTemperature * 100 : outdoorTemperature } : {}),
1693
+ ...(outdoorTemperature !== undefined ? { outdoorTemperature: outdoorTemperature !== null ? outdoorTemperature * 100 : outdoorTemperature } : {}), // Optional nullable attribute
833
1694
  controlSequenceOfOperation: Thermostat.ControlSequenceOfOperation.HeatingOnly,
834
1695
  systemMode: Thermostat.SystemMode.Heat,
835
1696
  thermostatRunningState: {
@@ -841,20 +1702,38 @@ export class MatterbridgeEndpoint extends Endpoint {
841
1702
  fanStage2: false,
842
1703
  fanStage3: false,
843
1704
  },
1705
+ // Thermostat.Feature.Heating
844
1706
  occupiedHeatingSetpoint: occupiedHeatingSetpoint * 100,
845
1707
  minHeatSetpointLimit: minHeatSetpointLimit * 100,
846
1708
  maxHeatSetpointLimit: maxHeatSetpointLimit * 100,
847
1709
  absMinHeatSetpointLimit: minHeatSetpointLimit * 100,
848
1710
  absMaxHeatSetpointLimit: maxHeatSetpointLimit * 100,
1711
+ // Thermostat.Feature.Occupancy
849
1712
  ...(occupied !== undefined ? { unoccupiedHeatingSetpoint: unoccupiedHeatingSetpoint !== undefined ? unoccupiedHeatingSetpoint * 100 : 1900 } : {}),
850
1713
  ...(occupied !== undefined ? { occupancy: { occupied } } : {}),
851
1714
  });
852
1715
  return this;
853
1716
  }
1717
+ /**
1718
+ * Creates a default cooling thermostat cluster server with feature **Cooling**.
1719
+ *
1720
+ * - When the occupied parameter is provided (either false or true), the **Occupancy** feature is also added (defaults to undefined).
1721
+ * - When the outdoorTemperature parameter is provided (either null or a number), the outdoorTemperature attribute is also added (defaults to undefined).
1722
+ *
1723
+ * @param {number} [localTemperature] - The local temperature value in degrees Celsius. Defaults to 23°.
1724
+ * @param {number} [occupiedCoolingSetpoint] - The occupied cooling setpoint value in degrees Celsius. Defaults to 25°.
1725
+ * @param {number} [minCoolSetpointLimit] - The minimum cool setpoint limit value. Defaults to 0°.
1726
+ * @param {number} [maxCoolSetpointLimit] - The maximum cool setpoint limit value. Defaults to 50°.
1727
+ * @param {number | undefined} [unoccupiedCoolingSetpoint] - The unoccupied cooling setpoint value in degrees Celsius. Defaults to 27° (it will be ignored if occupied is not provided).
1728
+ * @param {boolean | undefined} [occupied] - The occupancy status. Defaults to undefined (it will be ignored).
1729
+ * @param {number | null | undefined} [outdoorTemperature] - The outdoor temperature value in degrees Celsius. Defaults to undefined (it will be ignored).
1730
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1731
+ */
854
1732
  createDefaultCoolingThermostatClusterServer(localTemperature = 23, occupiedCoolingSetpoint = 25, minCoolSetpointLimit = 0, maxCoolSetpointLimit = 50, unoccupiedCoolingSetpoint = undefined, occupied = undefined, outdoorTemperature = undefined) {
855
1733
  this.behaviors.require(MatterbridgeThermostatServer.with(Thermostat.Feature.Cooling, ...(occupied !== undefined ? [Thermostat.Feature.Occupancy] : [])), {
1734
+ // Common attributes
856
1735
  localTemperature: localTemperature * 100,
857
- ...(outdoorTemperature !== undefined ? { outdoorTemperature: outdoorTemperature !== null ? outdoorTemperature * 100 : outdoorTemperature } : {}),
1736
+ ...(outdoorTemperature !== undefined ? { outdoorTemperature: outdoorTemperature !== null ? outdoorTemperature * 100 : outdoorTemperature } : {}), // Optional nullable attribute
858
1737
  controlSequenceOfOperation: Thermostat.ControlSequenceOfOperation.CoolingOnly,
859
1738
  systemMode: Thermostat.SystemMode.Cool,
860
1739
  thermostatRunningState: {
@@ -866,16 +1745,32 @@ export class MatterbridgeEndpoint extends Endpoint {
866
1745
  fanStage2: false,
867
1746
  fanStage3: false,
868
1747
  },
1748
+ // Thermostat.Feature.Cooling
869
1749
  occupiedCoolingSetpoint: occupiedCoolingSetpoint * 100,
870
1750
  minCoolSetpointLimit: minCoolSetpointLimit * 100,
871
1751
  maxCoolSetpointLimit: maxCoolSetpointLimit * 100,
872
1752
  absMinCoolSetpointLimit: minCoolSetpointLimit * 100,
873
1753
  absMaxCoolSetpointLimit: maxCoolSetpointLimit * 100,
1754
+ // Thermostat.Feature.Occupancy
874
1755
  ...(occupied !== undefined ? { unoccupiedCoolingSetpoint: unoccupiedCoolingSetpoint !== undefined ? unoccupiedCoolingSetpoint * 100 : 2700 } : {}),
875
1756
  ...(occupied !== undefined ? { occupancy: { occupied } } : {}),
876
1757
  });
877
1758
  return this;
878
1759
  }
1760
+ /**
1761
+ * Creates a default thermostat user interface configuration cluster server.
1762
+ *
1763
+ * @param {ThermostatUserInterfaceConfiguration.TemperatureDisplayMode} [temperatureDisplayMode] - The temperature display mode to set. Defaults to `ThermostatUserInterfaceConfiguration.TemperatureDisplayMode.Celsius`.
1764
+ * @param {ThermostatUserInterfaceConfiguration.KeypadLockout} [keypadLockout] - The keypad lockout mode. Defaults to `ThermostatUserInterfaceConfiguration.KeypadLockout.NoLockout`.
1765
+ * @param {ThermostatUserInterfaceConfiguration.ScheduleProgrammingVisibility} [scheduleProgrammingVisibility] - The schedule programming visibility. Defaults to `ThermostatUserInterfaceConfiguration.ScheduleProgrammingVisibility.ScheduleProgrammingPermitted`.
1766
+ *
1767
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1768
+ * @remarks
1769
+ * The default values are:
1770
+ * - temperatureDisplayMode: ThermostatUserInterfaceConfiguration.TemperatureDisplayMode.Celsius (writable).
1771
+ * - keypadLockout: ThermostatUserInterfaceConfiguration.KeypadLockout.NoLockout (writable).
1772
+ * - scheduleProgrammingVisibility: ThermostatUserInterfaceConfiguration.ScheduleProgrammingVisibility.ScheduleProgrammingPermitted (writable).
1773
+ */
879
1774
  createDefaultThermostatUserInterfaceConfigurationClusterServer(temperatureDisplayMode = ThermostatUserInterfaceConfiguration.TemperatureDisplayMode.Celsius, keypadLockout = ThermostatUserInterfaceConfiguration.KeypadLockout.NoLockout, scheduleProgrammingVisibility = ThermostatUserInterfaceConfiguration.ScheduleProgrammingVisibility.ScheduleProgrammingPermitted) {
880
1775
  this.behaviors.require(ThermostatUserInterfaceConfigurationServer, {
881
1776
  temperatureDisplayMode,
@@ -884,95 +1779,273 @@ export class MatterbridgeEndpoint extends Endpoint {
884
1779
  });
885
1780
  return this;
886
1781
  }
1782
+ /**
1783
+ * Creates a default fan control cluster server with features Auto, and Step and mode Off Low Med High Auto.
1784
+ *
1785
+ * @param {FanControl.FanMode} [fanMode] - The fan mode to set. Defaults to `FanControl.FanMode.Off`.
1786
+ * @param {FanControl.FanModeSequence} [fanModeSequence] - The fan mode sequence to set. Defaults to `FanControl.FanModeSequence.OffLowMedHighAuto`.
1787
+ * @param {number} [percentSetting] - The initial percent setting. Defaults to 0.
1788
+ * @param {number} [percentCurrent] - The initial percent current. Defaults to 0.
1789
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1790
+ *
1791
+ * @remarks
1792
+ * - fanmode is writable and persists across reboots.
1793
+ * - fanModeSequence is fixed.
1794
+ * - percentSetting is writable.
1795
+ */
887
1796
  createDefaultFanControlClusterServer(fanMode = FanControl.FanMode.Off, fanModeSequence = FanControl.FanModeSequence.OffLowMedHighAuto, percentSetting = 0, percentCurrent = 0) {
888
1797
  this.behaviors.require(MatterbridgeFanControlServer.with(FanControl.Feature.Auto, FanControl.Feature.Step), {
889
- fanMode,
890
- fanModeSequence,
891
- percentSetting,
1798
+ // Base fan control attributes
1799
+ fanMode, // Writable and persistent attribute
1800
+ fanModeSequence, // Fixed attribute
1801
+ percentSetting, // Writable attribute
892
1802
  percentCurrent,
893
1803
  });
894
1804
  return this;
895
1805
  }
1806
+ /**
1807
+ * Creates an On Off fan control cluster server without features and mode Off High.
1808
+ *
1809
+ * @param {FanControl.FanMode} [fanMode] - The fan mode to set. Defaults to `FanControl.FanMode.Off`.
1810
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1811
+ *
1812
+ * @remarks
1813
+ * fanmode is writable and persists across reboots.
1814
+ * fanModeSequence is fixed.
1815
+ * percentSetting is writable.
1816
+ */
896
1817
  createOnOffFanControlClusterServer(fanMode = FanControl.FanMode.Off) {
897
1818
  this.behaviors.require(FanControlServer, {
898
- fanMode,
899
- fanModeSequence: FanControl.FanModeSequence.OffHigh,
900
- percentSetting: 0,
1819
+ // Base fan control attributes
1820
+ fanMode, // Writable and persistent attribute
1821
+ fanModeSequence: FanControl.FanModeSequence.OffHigh, // Fixed attribute
1822
+ percentSetting: 0, // Writable attribute
901
1823
  percentCurrent: 0,
902
1824
  });
903
1825
  return this;
904
1826
  }
1827
+ /**
1828
+ * Creates a base fan control cluster server without features and mode Off Low Med High.
1829
+ *
1830
+ * @param {FanControl.FanMode} [fanMode] - The fan mode to set. Defaults to `FanControl.FanMode.Off`.
1831
+ * @param {FanControl.FanModeSequence} [fanModeSequence] - The fan mode sequence to set. Defaults to `FanControl.FanModeSequence.OffLowMedHigh`.
1832
+ * @param {number} [percentSetting] - The initial percent setting. Defaults to 0.
1833
+ * @param {number} [percentCurrent] - The initial percent current. Defaults to 0.
1834
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1835
+ *
1836
+ * @remarks
1837
+ * fanmode is writable and persists across reboots.
1838
+ * fanModeSequence is fixed.
1839
+ * percentSetting is writable.
1840
+ */
905
1841
  createBaseFanControlClusterServer(fanMode = FanControl.FanMode.Off, fanModeSequence = FanControl.FanModeSequence.OffLowMedHigh, percentSetting = 0, percentCurrent = 0) {
906
1842
  this.behaviors.require(FanControlServer, {
907
- fanMode,
908
- fanModeSequence,
909
- percentSetting,
1843
+ // Base fan control attributes
1844
+ fanMode, // Writable and persistent attribute
1845
+ fanModeSequence, // Fixed attribute
1846
+ percentSetting, // Writable attribute
910
1847
  percentCurrent,
911
1848
  });
912
1849
  return this;
913
1850
  }
1851
+ /**
1852
+ * Creates a fan control cluster server with features MultiSpeed, Auto, and Step and mode Off Low Med High Auto.
1853
+ *
1854
+ * @param {FanControl.FanMode} [fanMode] - The fan mode to set. Defaults to `FanControl.FanMode.Off`.
1855
+ * @param {FanControl.FanModeSequence} [fanModeSequence] - The fan mode sequence to set. Defaults to `FanControl.FanModeSequence.OffLowMedHighAuto`.
1856
+ * @param {number} [percentSetting] - The initial percent setting. Defaults to 0.
1857
+ * @param {number} [percentCurrent] - The initial percent current. Defaults to 0.
1858
+ * @param {number} [speedMax] - The maximum speed setting. Defaults to 10.
1859
+ * @param {number} [speedSetting] - The initial speed setting. Defaults to 0.
1860
+ * @param {number} [speedCurrent] - The initial speed current. Defaults to 0.
1861
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1862
+ *
1863
+ * @remarks
1864
+ * - fanmode is writable and persists across reboots.
1865
+ * - fanModeSequence is fixed.
1866
+ * - percentSetting is writable.
1867
+ * - speedMax is fixed.
1868
+ * - speedSetting is writable.
1869
+ */
914
1870
  createMultiSpeedFanControlClusterServer(fanMode = FanControl.FanMode.Off, fanModeSequence = FanControl.FanModeSequence.OffLowMedHighAuto, percentSetting = 0, percentCurrent = 0, speedMax = 10, speedSetting = 0, speedCurrent = 0) {
915
1871
  this.behaviors.require(MatterbridgeFanControlServer.with(FanControl.Feature.MultiSpeed, FanControl.Feature.Auto, FanControl.Feature.Step), {
916
- fanMode,
917
- fanModeSequence,
918
- percentSetting,
1872
+ // Base fan control attributes
1873
+ fanMode, // Writable and persistent attribute
1874
+ fanModeSequence, // Fixed attribute
1875
+ percentSetting, // Writable attribute
919
1876
  percentCurrent,
920
- speedMax,
921
- speedSetting,
1877
+ // MultiSpeed feature
1878
+ speedMax, // Fixed attribute
1879
+ speedSetting, // Writable attribute
922
1880
  speedCurrent,
923
1881
  });
924
1882
  return this;
925
1883
  }
1884
+ /**
1885
+ * Creates a fan control cluster server with features MultiSpeed, Auto, Step, Rock, Wind and AirflowDirection and mode Off Low Med High Auto.
1886
+ *
1887
+ * @param {FanControl.FanMode} [fanMode] - The fan mode to set. Defaults to `FanControl.FanMode.Off`.
1888
+ * @param {FanControl.FanModeSequence} [fanModeSequence] - The fan mode sequence to set. Defaults to `FanControl.FanModeSequence.OffLowMedHighAuto`.
1889
+ * @param {number} [percentSetting] - The initial percent setting. Defaults to 0.
1890
+ * @param {number} [percentCurrent] - The initial percent current. Defaults to 0.
1891
+ * @param {number} [speedMax] - The maximum speed setting. Defaults to 10.
1892
+ * @param {number} [speedSetting] - The initial speed setting. Defaults to 0.
1893
+ * @param {number} [speedCurrent] - The initial speed current. Defaults to 0.
1894
+ * @param {object} [rockSupport] - The rock support configuration.
1895
+ * @param {boolean} rockSupport.rockLeftRight - Indicates support for rocking left to right. Defaults to true.
1896
+ * @param {boolean} rockSupport.rockUpDown - Indicates support for rocking up and down. Defaults to true.
1897
+ * @param {boolean} rockSupport.rockRound - Indicates support for round rocking. Defaults to true.
1898
+ * @param {object} [rockSetting] - The rock setting configuration.
1899
+ * @param {boolean} rockSetting.rockLeftRight - Indicates the current setting for rocking left to right. Defaults to true.
1900
+ * @param {boolean} rockSetting.rockUpDown - Indicates the current setting for rocking up and down. Defaults to true.
1901
+ * @param {boolean} rockSetting.rockRound - Indicates the current setting for round rocking. Defaults to true.
1902
+ * @param {object} [windSupport] - The wind support configuration.
1903
+ * @param {boolean} windSupport.sleepWind - Indicates support for sleep wind. Defaults to true.
1904
+ * @param {boolean} windSupport.naturalWind - Indicates support for natural wind. Defaults to true.
1905
+ * @param {object} [windSetting] - The wind setting configuration.
1906
+ * @param {boolean} windSetting.sleepWind - Indicates the current setting for sleep wind. Defaults to false.
1907
+ * @param {boolean} windSetting.naturalWind - Indicates the current setting for natural wind. Defaults to true.
1908
+ * @param {FanControl.AirflowDirection} [airflowDirection] - The airflow direction. Defaults to `FanControl.AirflowDirection.Forward`.
1909
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1910
+ *
1911
+ * @remarks
1912
+ * - fanmode is writable and persists across reboots.
1913
+ * - fanModeSequence is fixed.
1914
+ * - percentSetting is writable.
1915
+ * - speedMax is fixed.
1916
+ * - speedSetting is writable.
1917
+ * - rockSupport is fixed.
1918
+ * - rockSetting is writable.
1919
+ * - windSupport is fixed.
1920
+ * - windSetting is writable.
1921
+ * - airflowDirection is writable.
1922
+ */
926
1923
  createCompleteFanControlClusterServer(fanMode = FanControl.FanMode.Off, fanModeSequence = FanControl.FanModeSequence.OffLowMedHighAuto, percentSetting = 0, percentCurrent = 0, speedMax = 10, speedSetting = 0, speedCurrent = 0, rockSupport = { rockLeftRight: true, rockUpDown: true, rockRound: true }, rockSetting = { rockLeftRight: true, rockUpDown: false, rockRound: false }, windSupport = { sleepWind: true, naturalWind: true }, windSetting = { sleepWind: false, naturalWind: true }, airflowDirection = FanControl.AirflowDirection.Forward) {
927
1924
  this.behaviors.require(MatterbridgeFanControlServer.with(FanControl.Feature.MultiSpeed, FanControl.Feature.Auto, FanControl.Feature.Step, FanControl.Feature.Rocking, FanControl.Feature.Wind, FanControl.Feature.AirflowDirection), {
928
- fanMode,
929
- fanModeSequence,
930
- percentSetting,
1925
+ // Base fan control attributes
1926
+ fanMode, // Writable and persistent attribute
1927
+ fanModeSequence, // Fixed attribute
1928
+ percentSetting, // Writable attribute
931
1929
  percentCurrent,
932
- speedMax,
933
- speedSetting,
1930
+ // MultiSpeed feature
1931
+ speedMax, // Fixed attribute
1932
+ speedSetting, // Writable attribute
934
1933
  speedCurrent,
935
- rockSupport,
936
- rockSetting,
937
- windSupport,
938
- windSetting,
939
- airflowDirection,
1934
+ // Rocking feature
1935
+ rockSupport, // Fixed attribute
1936
+ rockSetting, // Writable attribute
1937
+ // Wind feature
1938
+ windSupport, // Fixed attribute
1939
+ windSetting, // Writable attribute
1940
+ // AirflowDirection feature
1941
+ airflowDirection, // Writable attribute
940
1942
  });
941
1943
  return this;
942
1944
  }
1945
+ /**
1946
+ * Creates a default HEPA Filter Monitoring Cluster Server with features Condition and ReplacementProductList.
1947
+ * It supports ResourceMonitoring.Feature.Condition, ResourceMonitoring.Feature.Warning, and ResourceMonitoring.Feature.ReplacementProductList.
1948
+ *
1949
+ * @param {number} condition - The initial condition value (range 0-100). Default is 100.
1950
+ * @param {ResourceMonitoring.ChangeIndication} changeIndication - The initial change indication. Default is ResourceMonitoring.ChangeIndication.Ok.
1951
+ * @param {boolean | undefined} inPlaceIndicator - The in-place indicator. Default is true.
1952
+ * @param {number | undefined} lastChangedTime - The last changed time (EpochS). Default is null.
1953
+ * @param {ResourceMonitoring.ReplacementProduct[]} replacementProductList - The list of replacement products. Default is an empty array. It is a fixed attribute.
1954
+ *
1955
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1956
+ *
1957
+ * @remarks
1958
+ * The HEPA Filter Monitoring Cluster Server is used to monitor the status of HEPA filters.
1959
+ * It provides information about the condition of the filter, whether it is in place, and the last time it was changed.
1960
+ * The change indication can be used to indicate if the filter needs to be replaced or serviced.
1961
+ * The replacement product list can be used to provide a list of replacement products for the filter.
1962
+ * The condition attribute is fixed at 100, indicating a healthy filter.
1963
+ * The degradation direction is fixed at ResourceMonitoring.DegradationDirection.Down, indicating that a lower value indicates a worse condition.
1964
+ * The replacement product list is initialized as an empty array.
1965
+ */
943
1966
  createDefaultHepaFilterMonitoringClusterServer(condition = 100, changeIndication = ResourceMonitoring.ChangeIndication.Ok, inPlaceIndicator = true, lastChangedTime = null, replacementProductList = []) {
944
1967
  this.behaviors.require(MatterbridgeHepaFilterMonitoringServer.with(ResourceMonitoring.Feature.Condition, ResourceMonitoring.Feature.Warning, ResourceMonitoring.Feature.ReplacementProductList), {
1968
+ // Feature.Condition
945
1969
  condition,
946
- degradationDirection: ResourceMonitoring.DegradationDirection.Down,
947
- replacementProductList,
1970
+ degradationDirection: ResourceMonitoring.DegradationDirection.Down, // Fixed attribute
1971
+ // Feature.ReplacementProductList
1972
+ replacementProductList, // Fixed attribute
1973
+ // Base attributes
948
1974
  changeIndication,
949
1975
  inPlaceIndicator,
950
- lastChangedTime,
1976
+ lastChangedTime, // Writable and persistent across restarts
951
1977
  });
952
1978
  return this;
953
1979
  }
1980
+ /**
1981
+ * Creates a default Activated Carbon Filter Monitoring Cluster Server with features Condition and ReplacementProductList.
1982
+ * It supports ResourceMonitoring.Feature.Condition, ResourceMonitoring.Feature.Warning, and ResourceMonitoring.Feature.ReplacementProductList.
1983
+ *
1984
+ * @param {number} condition - The initial condition value (range 0-100). Default is 100.
1985
+ * @param {ResourceMonitoring.ChangeIndication} changeIndication - The initial change indication. Default is ResourceMonitoring.ChangeIndication.Ok.
1986
+ * @param {boolean | undefined} inPlaceIndicator - The in-place indicator. Default is undefined.
1987
+ * @param {number | undefined} lastChangedTime - The last changed time (EpochS). Default is undefined.
1988
+ * @param {ResourceMonitoring.ReplacementProduct[]} replacementProductList - The list of replacement products. Default is an empty array. It is a fixed attribute.
1989
+ *
1990
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1991
+ *
1992
+ * @remarks
1993
+ * The Activated Carbon Filter Monitoring Cluster Server is used to monitor the status of activated carbon filters.
1994
+ * It provides information about the condition of the filter, whether it is in place, and the last time it was changed.
1995
+ * The change indication can be used to indicate if the filter needs to be replaced or serviced.
1996
+ * The replacement product list can be used to provide a list of replacement products for the filter.
1997
+ * The condition attribute is fixed at 100, indicating a healthy filter.
1998
+ * The degradation direction is fixed at ResourceMonitoring.DegradationDirection.Down, indicating that a lower value indicates a worse condition.
1999
+ * The replacement product list is initialized as an empty array.
2000
+ */
954
2001
  createDefaultActivatedCarbonFilterMonitoringClusterServer(condition = 100, changeIndication = ResourceMonitoring.ChangeIndication.Ok, inPlaceIndicator = true, lastChangedTime = null, replacementProductList = []) {
955
2002
  this.behaviors.require(MatterbridgeActivatedCarbonFilterMonitoringServer.with(ResourceMonitoring.Feature.Condition, ResourceMonitoring.Feature.Warning, ResourceMonitoring.Feature.ReplacementProductList), {
2003
+ // Feature.Condition
956
2004
  condition,
957
2005
  degradationDirection: ResourceMonitoring.DegradationDirection.Down,
958
- replacementProductList,
2006
+ // Feature.ReplacementProductList
2007
+ replacementProductList, // Fixed attribute
2008
+ // Base attributes
959
2009
  changeIndication,
960
2010
  inPlaceIndicator,
961
- lastChangedTime,
2011
+ lastChangedTime, // Writable and persistent across restarts
962
2012
  });
963
2013
  return this;
964
2014
  }
2015
+ /**
2016
+ * Creates a default door lock cluster server.
2017
+ *
2018
+ * @param {DoorLock.LockState} [lockState] - The initial state of the lock (default: Locked).
2019
+ * @param {DoorLock.LockType} [lockType] - The type of the lock (default: DeadBolt).
2020
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2021
+ *
2022
+ * @remarks
2023
+ * All operating modes NOT supported by a lock SHALL be set to one. The value of the OperatingMode enumeration defines the related bit to be set.
2024
+ */
965
2025
  createDefaultDoorLockClusterServer(lockState = DoorLock.LockState.Locked, lockType = DoorLock.LockType.DeadBolt) {
966
2026
  this.behaviors.require(MatterbridgeDoorLockServer.enable({ events: { doorLockAlarm: true, lockOperation: true, lockOperationError: true } }), {
967
2027
  lockState,
968
2028
  lockType,
969
2029
  actuatorEnabled: false,
970
2030
  operatingMode: DoorLock.OperatingMode.Normal,
2031
+ // Special case of inverted bitmap: add also alwaysSet = 2047
971
2032
  supportedOperatingModes: { normal: false, vacation: true, privacy: true, noRemoteLockUnlock: true, passage: true, alwaysSet: 2047 },
972
- autoRelockTime: 0,
2033
+ autoRelockTime: 0, // 0=disabled
973
2034
  });
974
2035
  return this;
975
2036
  }
2037
+ /**
2038
+ * Creates a default Mode Select cluster server.
2039
+ *
2040
+ * @param {string} description - The description of the mode select cluster.
2041
+ * @param {ModeSelect.ModeOption[]} supportedModes - The list of supported modes.
2042
+ * @param {number} [currentMode] - The current mode (default: 0).
2043
+ * @param {number} [startUpMode] - The startup mode (default: 0).
2044
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2045
+ *
2046
+ * @remarks
2047
+ * endpoint.createDefaultModeSelectClusterServer('Night mode', [{ label: 'Led ON', mode: 0, semanticTags: [] }, { label: 'Led OFF', mode: 1, semanticTags: [] }], 0, 0);
2048
+ */
976
2049
  createDefaultModeSelectClusterServer(description, supportedModes, currentMode = 0, startUpMode = 0) {
977
2050
  this.behaviors.require(MatterbridgeModeSelectServer, {
978
2051
  description: description,
@@ -983,21 +2056,35 @@ export class MatterbridgeEndpoint extends Endpoint {
983
2056
  });
984
2057
  return this;
985
2058
  }
2059
+ /**
2060
+ * Creates the default Valve Configuration And Control cluster server with features Level.
2061
+ *
2062
+ * @param {ValveConfigurationAndControl.ValveState} [valveState] - The valve state to set. Defaults to `ValveConfigurationAndControl.ValveState.Closed`.
2063
+ * @param {number} [valveLevel] - The valve level to set. Defaults to 0.
2064
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2065
+ */
986
2066
  createDefaultValveConfigurationAndControlClusterServer(valveState = ValveConfigurationAndControl.ValveState.Closed, valveLevel = 0) {
987
2067
  this.behaviors.require(MatterbridgeValveConfigurationAndControlServer.with(ValveConfigurationAndControl.Feature.Level), {
988
2068
  currentState: valveState,
989
2069
  targetState: valveState,
990
2070
  openDuration: null,
991
- defaultOpenDuration: null,
2071
+ defaultOpenDuration: null, // Writable and persistent across restarts
992
2072
  remainingDuration: null,
993
2073
  valveFault: { generalFault: false, blocked: false, leaking: false, notConnected: false, shortCircuit: false, currentExceeded: false },
2074
+ // Feature.Level
994
2075
  currentLevel: valveLevel,
995
2076
  targetLevel: valveLevel,
996
- defaultOpenLevel: 100,
997
- levelStep: 1,
2077
+ defaultOpenLevel: 100, // Writable and persistent across restarts
2078
+ levelStep: 1, // Fixed
998
2079
  });
999
2080
  return this;
1000
2081
  }
2082
+ /**
2083
+ * Creates the default PumpConfigurationAndControl cluster server with features ConstantSpeed.
2084
+ *
2085
+ * @param {PumpConfigurationAndControl.OperationMode} [pumpMode] - The pump mode to set. Defaults to `PumpConfigurationAndControl.OperationMode.Normal`.
2086
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2087
+ */
1001
2088
  createDefaultPumpConfigurationAndControlClusterServer(pumpMode = PumpConfigurationAndControl.OperationMode.Normal) {
1002
2089
  this.behaviors.require(PumpConfigurationAndControlServer.with(PumpConfigurationAndControl.Feature.ConstantSpeed), {
1003
2090
  minConstSpeed: null,
@@ -1012,6 +2099,13 @@ export class MatterbridgeEndpoint extends Endpoint {
1012
2099
  });
1013
2100
  return this;
1014
2101
  }
2102
+ /**
2103
+ * Creates the default SmokeCOAlarm Cluster Server with features SmokeAlarm and CoAlarm.
2104
+ *
2105
+ * @param {SmokeCoAlarm.AlarmState} smokeState - The state of the smoke alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
2106
+ * @param {SmokeCoAlarm.AlarmState} coState - The state of the CO alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
2107
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2108
+ */
1015
2109
  createDefaultSmokeCOAlarmClusterServer(smokeState = SmokeCoAlarm.AlarmState.Normal, coState = SmokeCoAlarm.AlarmState.Normal) {
1016
2110
  this.behaviors.require(MatterbridgeSmokeCoAlarmServer.with(SmokeCoAlarm.Feature.SmokeAlarm, SmokeCoAlarm.Feature.CoAlarm).enable({
1017
2111
  events: { smokeAlarm: true, interconnectSmokeAlarm: false, coAlarm: true, interconnectCoAlarm: false, lowBattery: true, hardwareFault: true, endOfService: true, selfTestComplete: true, alarmMuted: true, muteEnded: true, allClear: true },
@@ -1027,6 +2121,12 @@ export class MatterbridgeEndpoint extends Endpoint {
1027
2121
  });
1028
2122
  return this;
1029
2123
  }
2124
+ /**
2125
+ * Creates a smoke only SmokeCOAlarm Cluster Server with features SmokeAlarm.
2126
+ *
2127
+ * @param {SmokeCoAlarm.AlarmState} smokeState - The state of the smoke alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
2128
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2129
+ */
1030
2130
  createSmokeOnlySmokeCOAlarmClusterServer(smokeState = SmokeCoAlarm.AlarmState.Normal) {
1031
2131
  this.behaviors.require(MatterbridgeSmokeCoAlarmServer.with(SmokeCoAlarm.Feature.SmokeAlarm).enable({
1032
2132
  events: { smokeAlarm: true, interconnectSmokeAlarm: false, lowBattery: true, hardwareFault: true, endOfService: true, selfTestComplete: true, alarmMuted: true, muteEnded: true, allClear: true },
@@ -1041,6 +2141,12 @@ export class MatterbridgeEndpoint extends Endpoint {
1041
2141
  });
1042
2142
  return this;
1043
2143
  }
2144
+ /**
2145
+ * Creates a co only SmokeCOAlarm Cluster Server with features CoAlarm.
2146
+ *
2147
+ * @param {SmokeCoAlarm.AlarmState} coState - The state of the CO alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
2148
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2149
+ */
1044
2150
  createCoOnlySmokeCOAlarmClusterServer(coState = SmokeCoAlarm.AlarmState.Normal) {
1045
2151
  this.behaviors.require(MatterbridgeSmokeCoAlarmServer.with(SmokeCoAlarm.Feature.CoAlarm).enable({
1046
2152
  events: { coAlarm: true, interconnectCoAlarm: false, lowBattery: true, hardwareFault: true, endOfService: true, selfTestComplete: true, alarmMuted: true, muteEnded: true, allClear: true },
@@ -1055,6 +2161,15 @@ export class MatterbridgeEndpoint extends Endpoint {
1055
2161
  });
1056
2162
  return this;
1057
2163
  }
2164
+ /**
2165
+ * Creates a default momentary switch cluster server with features MomentarySwitch, MomentarySwitchRelease, MomentarySwitchLongPress and MomentarySwitchMultiPress
2166
+ * and events initialPress, longPress, shortRelease, longRelease, multiPressOngoing, multiPressComplete.
2167
+ *
2168
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2169
+ *
2170
+ * @remarks
2171
+ * This method adds a cluster server with default momentary switch features and configuration suitable for (AppleHome) Single Double Long automations.
2172
+ */
1058
2173
  createDefaultSwitchClusterServer() {
1059
2174
  this.behaviors.require(MatterbridgeSwitchServer.with(Switch.Feature.MomentarySwitch, Switch.Feature.MomentarySwitchRelease, Switch.Feature.MomentarySwitchLongPress, Switch.Feature.MomentarySwitchMultiPress).enable({
1060
2175
  events: { initialPress: true, longPress: true, shortRelease: true, longRelease: true, multiPressOngoing: true, multiPressComplete: true },
@@ -1065,6 +2180,15 @@ export class MatterbridgeEndpoint extends Endpoint {
1065
2180
  });
1066
2181
  return this;
1067
2182
  }
2183
+ /**
2184
+ * Creates a default momentary switch cluster server with feature MomentarySwitch and event initialPress.
2185
+ *
2186
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2187
+ *
2188
+ * @remarks
2189
+ * This method adds a cluster server with default momentary switch features and configuration suitable for a Single press automations.
2190
+ * It is supported by the Home app.
2191
+ */
1068
2192
  createDefaultMomentarySwitchClusterServer() {
1069
2193
  this.behaviors.require(MatterbridgeSwitchServer.with(Switch.Feature.MomentarySwitch).enable({
1070
2194
  events: { initialPress: true },
@@ -1074,6 +2198,14 @@ export class MatterbridgeEndpoint extends Endpoint {
1074
2198
  });
1075
2199
  return this;
1076
2200
  }
2201
+ /**
2202
+ * Creates a default latching switch cluster server with features LatchingSwitch.
2203
+ *
2204
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2205
+ *
2206
+ * @remarks
2207
+ * This method adds a cluster server with default latching switch features and configuration suitable for a latching switch with 2 positions.
2208
+ */
1077
2209
  createDefaultLatchingSwitchClusterServer() {
1078
2210
  this.behaviors.require(SwitchServer.with(Switch.Feature.LatchingSwitch).enable({
1079
2211
  events: { switchLatched: true },
@@ -1083,6 +2215,15 @@ export class MatterbridgeEndpoint extends Endpoint {
1083
2215
  });
1084
2216
  return this;
1085
2217
  }
2218
+ /**
2219
+ * Triggers a switch event on the specified endpoint.
2220
+ * We usually use get from real devices something like 'single', 'double', 'long'.
2221
+ * Here we convert it to the Matter sequence of events (taken from Matter specs).
2222
+ *
2223
+ * @param {string} event - The type of event to trigger. Possible values are 'Single', 'Double', 'Long' for momentarySwitch and 'Press', 'Release' for latchingSwitch.
2224
+ * @param {AnsiLogger} log - Optional logger to log the event.
2225
+ * @returns {boolean} - A boolean indicating whether the event was successfully triggered.
2226
+ */
1086
2227
  async triggerSwitchEvent(event, log) {
1087
2228
  if (this.maybeNumber === undefined) {
1088
2229
  this.log.error(`triggerSwitchEvent ${event} error: Endpoint number not assigned on endpoint ${this.maybeId}:${this.maybeNumber}`);
@@ -1144,10 +2285,37 @@ export class MatterbridgeEndpoint extends Endpoint {
1144
2285
  }
1145
2286
  return true;
1146
2287
  }
2288
+ /**
2289
+ * Creates a default OperationalState Cluster Server.
2290
+ *
2291
+ * @param {OperationalState.OperationalStateEnum} operationalState - The initial operational state id.
2292
+ *
2293
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2294
+ *
2295
+ * @remarks
2296
+ * This method adds a cluster server with a default operational state configuration:
2297
+ * - { operationalStateId: OperationalState.OperationalStateEnum.Stopped, operationalStateLabel: 'Stopped' },
2298
+ * - { operationalStateId: OperationalState.OperationalStateEnum.Running, operationalStateLabel: 'Running' },
2299
+ * - { operationalStateId: OperationalState.OperationalStateEnum.Paused, operationalStateLabel: 'Paused' },
2300
+ * - { operationalStateId: OperationalState.OperationalStateEnum.Error, operationalStateLabel: 'Error' },
2301
+ */
1147
2302
  createDefaultOperationalStateClusterServer(operationalState = OperationalState.OperationalStateEnum.Stopped) {
1148
2303
  this.behaviors.require(MatterbridgeOperationalStateServer, getDefaultOperationalStateClusterServer(operationalState));
1149
2304
  return this;
1150
2305
  }
2306
+ /**
2307
+ * Creates a default boolean state cluster server.
2308
+ * The stateChange event is enabled.
2309
+ *
2310
+ * @param {boolean} contact - The state of the cluster. Defaults to true (true = contact).
2311
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2312
+ *
2313
+ * @remarks
2314
+ * Water Leak Detector: true = leak, false = no leak
2315
+ * Water Freeze Detector: true = freeze, false = no freeze
2316
+ * Rain Sensor: true = rain, false = no rain
2317
+ * Contact Sensor: true = closed or contact, false = open or no contact
2318
+ */
1151
2319
  createDefaultBooleanStateClusterServer(contact) {
1152
2320
  this.behaviors.require(BooleanStateServer.enable({
1153
2321
  events: { stateChange: true },
@@ -1156,6 +2324,22 @@ export class MatterbridgeEndpoint extends Endpoint {
1156
2324
  });
1157
2325
  return this;
1158
2326
  }
2327
+ /**
2328
+ * Creates a default boolean state configuration cluster server to be used with the waterFreezeDetector, waterLeakDetector, and rainSensor device types.
2329
+ *
2330
+ * Features:
2331
+ * - Visual
2332
+ * - Audible
2333
+ * - SensitivityLevel
2334
+ *
2335
+ * @remarks Supports the enableDisableAlarm command.
2336
+ *
2337
+ * @param {boolean} [sensorFault] - Optional boolean value indicating the sensor fault state. Defaults to `false` if not provided.
2338
+ * @param {number} [currentSensitivityLevel] - The current sensitivity level. Defaults to `0` if not provided.
2339
+ * @param {number} [supportedSensitivityLevels] - The number of supported sensitivity levels. Defaults to `2` if not provided (min 2, max 10).
2340
+ * @param {number} [defaultSensitivityLevel] - The default sensitivity level. Defaults to `0` if not provided.
2341
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2342
+ */
1159
2343
  createDefaultBooleanStateConfigurationClusterServer(sensorFault = false, currentSensitivityLevel = 0, supportedSensitivityLevels = 2, defaultSensitivityLevel = 0) {
1160
2344
  this.behaviors.require(MatterbridgeBooleanStateConfigurationServer.with(BooleanStateConfiguration.Feature.Visual, BooleanStateConfiguration.Feature.Audible, BooleanStateConfiguration.Feature.SensitivityLevel).enable({
1161
2345
  events: { alarmsStateChanged: true, sensorFault: true },
@@ -1170,36 +2354,128 @@ export class MatterbridgeEndpoint extends Endpoint {
1170
2354
  });
1171
2355
  return this;
1172
2356
  }
2357
+ /**
2358
+ * Creates a default TemperatureMeasurement cluster server.
2359
+ *
2360
+ * @param {number | null} measuredValue - The measured value of the temperature x 100.
2361
+ * @param {number | null} minMeasuredValue - The minimum measured value of the temperature x 100.
2362
+ * @param {number | null} maxMeasuredValue - The maximum measured value of the temperature x 100.
2363
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2364
+ */
1173
2365
  createDefaultTemperatureMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
1174
2366
  this.behaviors.require(TemperatureMeasurementServer, getDefaultTemperatureMeasurementClusterServer(measuredValue, minMeasuredValue, maxMeasuredValue));
1175
2367
  return this;
1176
2368
  }
2369
+ /**
2370
+ * Creates a default RelativeHumidityMeasurement cluster server.
2371
+ *
2372
+ * @param {number | null} measuredValue - The measured value of the relative humidity x 100.
2373
+ * @param {number | null} minMeasuredValue - The minimum measured value of the relative humidity x 100.
2374
+ * @param {number | null} maxMeasuredValue - The maximum measured value of the relative humidity x 100.
2375
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2376
+ */
1177
2377
  createDefaultRelativeHumidityMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
1178
2378
  this.behaviors.require(RelativeHumidityMeasurementServer, getDefaultRelativeHumidityMeasurementClusterServer(measuredValue, minMeasuredValue, maxMeasuredValue));
1179
2379
  return this;
1180
2380
  }
2381
+ /**
2382
+ * Creates a default PressureMeasurement cluster server.
2383
+ *
2384
+ * @param {number | null} measuredValue - The measured value for the pressure in kPa x 10.
2385
+ * @param {number | null} minMeasuredValue - The minimum measured value for the pressure in kPa x 10.
2386
+ * @param {number | null} maxMeasuredValue - The maximum measured value for the pressure in kPa x 10.
2387
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2388
+ *
2389
+ * @remarks
2390
+ * - MeasuredValue = 10 x Pressure in kPa
2391
+ * - MeasuredValue = 1 x Pressure in hPa
2392
+ * - MeasuredValue = 33.8639 x Pressure in inHg
2393
+ *
2394
+ * Conversion:
2395
+ * - 1 kPa = 10 hPa
2396
+ * - 1 inHg = 33.8639 hPa
2397
+ */
1181
2398
  createDefaultPressureMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
1182
2399
  this.behaviors.require(PressureMeasurementServer, getDefaultPressureMeasurementClusterServer(measuredValue, minMeasuredValue, maxMeasuredValue));
1183
2400
  return this;
1184
2401
  }
2402
+ /**
2403
+ * Creates a default IlluminanceMeasurement cluster server.
2404
+ *
2405
+ * @param {number | null} measuredValue - The measured value of illuminance.
2406
+ * @param {number | null} minMeasuredValue - The minimum measured value of illuminance.
2407
+ * @param {number | null} maxMeasuredValue - The maximum measured value of illuminance.
2408
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2409
+ *
2410
+ * @remarks
2411
+ *
2412
+ * The default value for the illuminance measurement is null.
2413
+ *
2414
+ * This attribute SHALL indicate the illuminance in Lux (symbol lx) as follows:
2415
+ * • MeasuredValue = 10,000 x log10(illuminance) + 1,
2416
+ * where 1 lx <= illuminance <= 3.576 Mlx, corresponding to a MeasuredValue in the range 1 to 0xFFFE.
2417
+ * • 0 indicates a value of illuminance that is too low to be measured
2418
+ * • null indicates that the illuminance measurement is invalid.
2419
+ *
2420
+ * - Lux to matter = Math.round(Math.max(Math.min(10000 * Math.log10(lux), 0xfffe), 0))
2421
+ * - Matter to Lux = Math.round(Math.max(Math.pow(10, value / 10000), 0))
2422
+ */
1185
2423
  createDefaultIlluminanceMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
1186
2424
  this.behaviors.require(IlluminanceMeasurementServer, getDefaultIlluminanceMeasurementClusterServer(measuredValue, minMeasuredValue, maxMeasuredValue));
1187
2425
  return this;
1188
2426
  }
2427
+ /**
2428
+ * Creates a default FlowMeasurement cluster server.
2429
+ *
2430
+ * @param {number | null} measuredValue - The measured value of the flow in 10 x m3/h.
2431
+ * @param {number | null} minMeasuredValue - The minimum measured value of the flow in 10 x m3/h.
2432
+ * @param {number | null} maxMeasuredValue - The maximum measured value of the flow in 10 x m3/h.
2433
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2434
+ */
1189
2435
  createDefaultFlowMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
1190
2436
  this.behaviors.require(FlowMeasurementServer, getDefaultFlowMeasurementClusterServer(measuredValue, minMeasuredValue, maxMeasuredValue));
1191
2437
  return this;
1192
2438
  }
2439
+ /**
2440
+ * Creates a default OccupancySensing cluster server with feature PassiveInfrared.
2441
+ *
2442
+ * @param {boolean} occupied - A boolean indicating whether the occupancy is occupied or not. Default is false.
2443
+ * @param {number} holdTime - The hold time in seconds. Default is 30.
2444
+ * @param {number} holdTimeMin - The minimum hold time in seconds. Default is 1.
2445
+ * @param {number} holdTimeMax - The maximum hold time in seconds. Default is 300.
2446
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2447
+ *
2448
+ * @remarks The default value for the occupancy sensor type is PIR.
2449
+ */
1193
2450
  createDefaultOccupancySensingClusterServer(occupied = false, holdTime = 30, holdTimeMin = 1, holdTimeMax = 300) {
1194
2451
  this.behaviors.require(OccupancySensingServer.with(OccupancySensing.Feature.PassiveInfrared), getDefaultOccupancySensingClusterServer(occupied, holdTime, holdTimeMin, holdTimeMax));
1195
2452
  return this;
1196
2453
  }
2454
+ /**
2455
+ * Creates a default AirQuality cluster server.
2456
+ *
2457
+ * @param {AirQuality.AirQualityEnum} airQuality The air quality level. Defaults to `AirQuality.AirQualityType.Unknown`.
2458
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2459
+ */
1197
2460
  createDefaultAirQualityClusterServer(airQuality = AirQuality.AirQualityEnum.Unknown) {
1198
2461
  this.behaviors.require(AirQualityServer.with(AirQuality.Feature.Fair, AirQuality.Feature.Moderate, AirQuality.Feature.VeryPoor, AirQuality.Feature.ExtremelyPoor), {
1199
2462
  airQuality,
1200
2463
  });
1201
2464
  return this;
1202
2465
  }
2466
+ /**
2467
+ * Creates a default TotalVolatileOrganicCompoundsConcentrationMeasurement cluster server with feature NumericMeasurement.
2468
+ *
2469
+ * @param {number | null} measuredValue - The measured value of the concentration.
2470
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ugm3).
2471
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2472
+ * @param {number} [uncertainty] - The uncertainty value (optional).
2473
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2474
+ *
2475
+ * @remarks
2476
+ * The measurementUnit and the measurementMedium attributes are fixed and cannot be changed after creation.
2477
+ * Apple Home requires Ugm3 for TotalVolatileOrganicCompoundsConcentrationMeasurement cluster.
2478
+ */
1203
2479
  createDefaultTvocMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ugm3, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air, uncertainty) {
1204
2480
  this.behaviors.require(TotalVolatileOrganicCompoundsConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1205
2481
  measuredValue,
@@ -1211,6 +2487,16 @@ export class MatterbridgeEndpoint extends Endpoint {
1211
2487
  });
1212
2488
  return this;
1213
2489
  }
2490
+ /**
2491
+ * Creates a default TotalVolatileOrganicCompoundsConcentrationMeasurement cluster server with feature LevelIndication, MediumLevel and CriticalLevel.
2492
+ *
2493
+ * @param {ConcentrationMeasurement.LevelValue} levelValue - The level value of the measurement (default to ConcentrationMeasurement.LevelValue.Unknown).
2494
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The measurement medium (default to ConcentrationMeasurement.MeasurementMedium.Air).
2495
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2496
+ *
2497
+ * @remarks
2498
+ * The measurementMedium attribute is fixed and cannot be changed after creation.
2499
+ */
1214
2500
  createLevelTvocMeasurementClusterServer(levelValue = ConcentrationMeasurement.LevelValue.Unknown, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1215
2501
  this.behaviors.require(TotalVolatileOrganicCompoundsConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.LevelIndication, ConcentrationMeasurement.Feature.MediumLevel, ConcentrationMeasurement.Feature.CriticalLevel), {
1216
2502
  levelValue,
@@ -1218,6 +2504,17 @@ export class MatterbridgeEndpoint extends Endpoint {
1218
2504
  });
1219
2505
  return this;
1220
2506
  }
2507
+ /**
2508
+ * Create a default CarbonMonoxideConcentrationMeasurement cluster server with feature NumericMeasurement.
2509
+ *
2510
+ * @param {number | null} measuredValue - The measured value of the concentration.
2511
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
2512
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2513
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2514
+ *
2515
+ * @remarks
2516
+ * The measurementUnit and the measurementMedium attributes are fixed and cannot be changed after creation.
2517
+ */
1221
2518
  createDefaultCarbonMonoxideConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1222
2519
  this.behaviors.require(CarbonMonoxideConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1223
2520
  measuredValue,
@@ -1229,6 +2526,17 @@ export class MatterbridgeEndpoint extends Endpoint {
1229
2526
  });
1230
2527
  return this;
1231
2528
  }
2529
+ /**
2530
+ * Create a default CarbonDioxideConcentrationMeasurement cluster server with feature NumericMeasurement.
2531
+ *
2532
+ * @param {number | null} measuredValue - The measured value of the concentration.
2533
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
2534
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2535
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2536
+ *
2537
+ * @remarks
2538
+ * The measurementUnit and the measurementMedium attributes are fixed and cannot be changed after creation.
2539
+ */
1232
2540
  createDefaultCarbonDioxideConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1233
2541
  this.behaviors.require(CarbonDioxideConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1234
2542
  measuredValue,
@@ -1240,6 +2548,18 @@ export class MatterbridgeEndpoint extends Endpoint {
1240
2548
  });
1241
2549
  return this;
1242
2550
  }
2551
+ /**
2552
+ * Create a default FormaldehydeConcentrationMeasurement cluster server with feature NumericMeasurement.
2553
+ *
2554
+ * @param {number | null} measuredValue - The measured value of the concentration.
2555
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Mgm3).
2556
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2557
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2558
+ *
2559
+ * @remarks
2560
+ * The measurementUnit and the measurementMedium attributes are fixed and cannot be changed after creation.
2561
+ * Apple Home doesn't support FormaldehydeConcentrationMeasurement cluster.
2562
+ */
1243
2563
  createDefaultFormaldehydeConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Mgm3, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1244
2564
  this.behaviors.require(FormaldehydeConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1245
2565
  measuredValue,
@@ -1251,6 +2571,18 @@ export class MatterbridgeEndpoint extends Endpoint {
1251
2571
  });
1252
2572
  return this;
1253
2573
  }
2574
+ /**
2575
+ * Create a default Pm1ConcentrationMeasurement cluster server with feature NumericMeasurement.
2576
+ *
2577
+ * @param {number | null} measuredValue - The measured value of the concentration.
2578
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ugm3).
2579
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2580
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2581
+ *
2582
+ * @remarks
2583
+ * The measurementUnit and the measurementMedium attributes are fixed and cannot be changed after creation.
2584
+ * Apple Home doesn't support Pm1ConcentrationMeasurement cluster.
2585
+ */
1254
2586
  createDefaultPm1ConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ugm3, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1255
2587
  this.behaviors.require(Pm1ConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1256
2588
  measuredValue,
@@ -1262,6 +2594,18 @@ export class MatterbridgeEndpoint extends Endpoint {
1262
2594
  });
1263
2595
  return this;
1264
2596
  }
2597
+ /**
2598
+ * Create a default Pm25ConcentrationMeasurement cluster server with feature NumericMeasurement.
2599
+ *
2600
+ * @param {number | null} measuredValue - The measured value of the concentration.
2601
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ugm3).
2602
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2603
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2604
+ *
2605
+ * @remarks
2606
+ * The measurementUnit and the measurementMedium attributes are fixed and cannot be changed after creation.
2607
+ * Apple Home requires Ugm3 for Pm25ConcentrationMeasurement cluster.
2608
+ */
1265
2609
  createDefaultPm25ConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ugm3, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1266
2610
  this.behaviors.require(Pm25ConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1267
2611
  measuredValue,
@@ -1273,6 +2617,18 @@ export class MatterbridgeEndpoint extends Endpoint {
1273
2617
  });
1274
2618
  return this;
1275
2619
  }
2620
+ /**
2621
+ * Create a default Pm10ConcentrationMeasurement cluster server with feature NumericMeasurement.
2622
+ *
2623
+ * @param {number | null} measuredValue - The measured value of the concentration.
2624
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ugm3).
2625
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2626
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2627
+ *
2628
+ * @remarks
2629
+ * The measurementUnit and the measurementMedium attributes are fixed and cannot be changed after creation.
2630
+ * Apple Home requires Ugm3 for Pm10ConcentrationMeasurement cluster.
2631
+ */
1276
2632
  createDefaultPm10ConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ugm3, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1277
2633
  this.behaviors.require(Pm10ConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1278
2634
  measuredValue,
@@ -1284,6 +2640,17 @@ export class MatterbridgeEndpoint extends Endpoint {
1284
2640
  });
1285
2641
  return this;
1286
2642
  }
2643
+ /**
2644
+ * Create a default OzoneConcentrationMeasurement cluster server with feature NumericMeasurement.
2645
+ *
2646
+ * @param {number | null} measuredValue - The measured value of the concentration.
2647
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ugm3).
2648
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2649
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2650
+ *
2651
+ * @remarks
2652
+ * The measurementUnit and the measurementMedium attributes are fixed and cannot be changed after creation.
2653
+ */
1287
2654
  createDefaultOzoneConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ugm3, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1288
2655
  this.behaviors.require(OzoneConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1289
2656
  measuredValue,
@@ -1295,6 +2662,18 @@ export class MatterbridgeEndpoint extends Endpoint {
1295
2662
  });
1296
2663
  return this;
1297
2664
  }
2665
+ /**
2666
+ * Create a default RadonConcentrationMeasurement cluster server with feature NumericMeasurement.
2667
+ *
2668
+ * @param {number | null} measuredValue - The measured value of the concentration.
2669
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Bqm3).
2670
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2671
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2672
+ *
2673
+ * @remarks
2674
+ * The measurementUnit and the measurementMedium attributes are fixed and cannot be changed after creation.
2675
+ * Apple Home doesn't support RadonConcentrationMeasurement cluster.
2676
+ */
1298
2677
  createDefaultRadonConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Bqm3, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1299
2678
  this.behaviors.require(RadonConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1300
2679
  measuredValue,
@@ -1306,6 +2685,17 @@ export class MatterbridgeEndpoint extends Endpoint {
1306
2685
  });
1307
2686
  return this;
1308
2687
  }
2688
+ /**
2689
+ * Create a default NitrogenDioxideConcentrationMeasurement cluster server with feature NumericMeasurement.
2690
+ *
2691
+ * @param {number | null} measuredValue - The measured value of the concentration.
2692
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ugm3).
2693
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2694
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2695
+ *
2696
+ * @remarks
2697
+ * The measurementUnit and the measurementMedium attributes are fixed and cannot be changed after creation.
2698
+ */
1309
2699
  createDefaultNitrogenDioxideConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ugm3, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1310
2700
  this.behaviors.require(NitrogenDioxideConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1311
2701
  measuredValue,
@@ -1318,3 +2708,4 @@ export class MatterbridgeEndpoint extends Endpoint {
1318
2708
  return this;
1319
2709
  }
1320
2710
  }
2711
+ //# sourceMappingURL=matterbridgeEndpoint.js.map