matterbridge 3.5.0-dev-20260117-88ddbe4 → 3.5.0

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 (326) hide show
  1. package/CHANGELOG.md +130 -122
  2. package/README.md +14 -14
  3. package/dist/broadcastServer.d.ts +115 -0
  4. package/dist/broadcastServer.d.ts.map +1 -0
  5. package/dist/broadcastServer.js +117 -0
  6. package/dist/broadcastServer.js.map +1 -0
  7. package/dist/broadcastServerTypes.d.ts +43 -0
  8. package/dist/broadcastServerTypes.d.ts.map +1 -0
  9. package/dist/broadcastServerTypes.js +24 -0
  10. package/dist/broadcastServerTypes.js.map +1 -0
  11. package/dist/cli.d.ts +24 -0
  12. package/dist/cli.d.ts.map +1 -0
  13. package/dist/cli.js +98 -1
  14. package/dist/cli.js.map +1 -0
  15. package/dist/cliEmitter.d.ts +36 -0
  16. package/dist/cliEmitter.d.ts.map +1 -0
  17. package/dist/cliEmitter.js +37 -0
  18. package/dist/cliEmitter.js.map +1 -0
  19. package/dist/cliHistory.d.ts +42 -0
  20. package/dist/cliHistory.d.ts.map +1 -0
  21. package/dist/cliHistory.js +38 -0
  22. package/dist/cliHistory.js.map +1 -0
  23. package/dist/clusters/export.d.ts +1 -0
  24. package/dist/clusters/export.d.ts.map +1 -0
  25. package/dist/clusters/export.js +2 -0
  26. package/dist/clusters/export.js.map +1 -0
  27. package/dist/deviceManager.d.ts +108 -0
  28. package/dist/deviceManager.d.ts.map +1 -0
  29. package/dist/deviceManager.js +113 -1
  30. package/dist/deviceManager.js.map +1 -0
  31. package/dist/devices/airConditioner.d.ts +75 -0
  32. package/dist/devices/airConditioner.d.ts.map +1 -0
  33. package/dist/devices/airConditioner.js +57 -0
  34. package/dist/devices/airConditioner.js.map +1 -0
  35. package/dist/devices/batteryStorage.d.ts +43 -0
  36. package/dist/devices/batteryStorage.d.ts.map +1 -0
  37. package/dist/devices/batteryStorage.js +48 -1
  38. package/dist/devices/batteryStorage.js.map +1 -0
  39. package/dist/devices/cooktop.d.ts +55 -0
  40. package/dist/devices/cooktop.d.ts.map +1 -0
  41. package/dist/devices/cooktop.js +56 -0
  42. package/dist/devices/cooktop.js.map +1 -0
  43. package/dist/devices/dishwasher.d.ts +55 -0
  44. package/dist/devices/dishwasher.d.ts.map +1 -0
  45. package/dist/devices/dishwasher.js +57 -0
  46. package/dist/devices/dishwasher.js.map +1 -0
  47. package/dist/devices/evse.d.ts +57 -0
  48. package/dist/devices/evse.d.ts.map +1 -0
  49. package/dist/devices/evse.js +74 -10
  50. package/dist/devices/evse.js.map +1 -0
  51. package/dist/devices/export.d.ts +1 -0
  52. package/dist/devices/export.d.ts.map +1 -0
  53. package/dist/devices/export.js +5 -0
  54. package/dist/devices/export.js.map +1 -0
  55. package/dist/devices/extractorHood.d.ts +41 -0
  56. package/dist/devices/extractorHood.d.ts.map +1 -0
  57. package/dist/devices/extractorHood.js +43 -0
  58. package/dist/devices/extractorHood.js.map +1 -0
  59. package/dist/devices/heatPump.d.ts +43 -0
  60. package/dist/devices/heatPump.d.ts.map +1 -0
  61. package/dist/devices/heatPump.js +50 -2
  62. package/dist/devices/heatPump.js.map +1 -0
  63. package/dist/devices/laundryDryer.d.ts +58 -0
  64. package/dist/devices/laundryDryer.d.ts.map +1 -0
  65. package/dist/devices/laundryDryer.js +62 -3
  66. package/dist/devices/laundryDryer.js.map +1 -0
  67. package/dist/devices/laundryWasher.d.ts +64 -0
  68. package/dist/devices/laundryWasher.d.ts.map +1 -0
  69. package/dist/devices/laundryWasher.js +70 -4
  70. package/dist/devices/laundryWasher.js.map +1 -0
  71. package/dist/devices/microwaveOven.d.ts +77 -1
  72. package/dist/devices/microwaveOven.d.ts.map +1 -0
  73. package/dist/devices/microwaveOven.js +88 -5
  74. package/dist/devices/microwaveOven.js.map +1 -0
  75. package/dist/devices/oven.d.ts +82 -0
  76. package/dist/devices/oven.d.ts.map +1 -0
  77. package/dist/devices/oven.js +85 -0
  78. package/dist/devices/oven.js.map +1 -0
  79. package/dist/devices/refrigerator.d.ts +100 -0
  80. package/dist/devices/refrigerator.d.ts.map +1 -0
  81. package/dist/devices/refrigerator.js +102 -0
  82. package/dist/devices/refrigerator.js.map +1 -0
  83. package/dist/devices/roboticVacuumCleaner.d.ts +83 -0
  84. package/dist/devices/roboticVacuumCleaner.d.ts.map +1 -0
  85. package/dist/devices/roboticVacuumCleaner.js +100 -9
  86. package/dist/devices/roboticVacuumCleaner.js.map +1 -0
  87. package/dist/devices/solarPower.d.ts +36 -0
  88. package/dist/devices/solarPower.d.ts.map +1 -0
  89. package/dist/devices/solarPower.js +38 -0
  90. package/dist/devices/solarPower.js.map +1 -0
  91. package/dist/devices/speaker.d.ts +79 -0
  92. package/dist/devices/speaker.d.ts.map +1 -0
  93. package/dist/devices/speaker.js +84 -0
  94. package/dist/devices/speaker.js.map +1 -0
  95. package/dist/devices/temperatureControl.d.ts +21 -0
  96. package/dist/devices/temperatureControl.d.ts.map +1 -0
  97. package/dist/devices/temperatureControl.js +24 -3
  98. package/dist/devices/temperatureControl.js.map +1 -0
  99. package/dist/devices/waterHeater.d.ts +74 -0
  100. package/dist/devices/waterHeater.d.ts.map +1 -0
  101. package/dist/devices/waterHeater.js +82 -2
  102. package/dist/devices/waterHeater.js.map +1 -0
  103. package/dist/dgram/coap.d.ts +171 -0
  104. package/dist/dgram/coap.d.ts.map +1 -0
  105. package/dist/dgram/coap.js +126 -13
  106. package/dist/dgram/coap.js.map +1 -0
  107. package/dist/dgram/dgram.d.ts +99 -0
  108. package/dist/dgram/dgram.d.ts.map +1 -0
  109. package/dist/dgram/dgram.js +114 -2
  110. package/dist/dgram/dgram.js.map +1 -0
  111. package/dist/dgram/mb_coap.d.ts +23 -0
  112. package/dist/dgram/mb_coap.d.ts.map +1 -0
  113. package/dist/dgram/mb_coap.js +41 -3
  114. package/dist/dgram/mb_coap.js.map +1 -0
  115. package/dist/dgram/mb_mdns.d.ts +23 -0
  116. package/dist/dgram/mb_mdns.d.ts.map +1 -0
  117. package/dist/dgram/mb_mdns.js +80 -24
  118. package/dist/dgram/mb_mdns.js.map +1 -0
  119. package/dist/dgram/mdns.d.ts +187 -4
  120. package/dist/dgram/mdns.d.ts.map +1 -0
  121. package/dist/dgram/mdns.js +371 -139
  122. package/dist/dgram/mdns.js.map +1 -0
  123. package/dist/dgram/multicast.d.ts +49 -0
  124. package/dist/dgram/multicast.d.ts.map +1 -0
  125. package/dist/dgram/multicast.js +62 -1
  126. package/dist/dgram/multicast.js.map +1 -0
  127. package/dist/dgram/unicast.d.ts +53 -0
  128. package/dist/dgram/unicast.d.ts.map +1 -0
  129. package/dist/dgram/unicast.js +60 -0
  130. package/dist/dgram/unicast.js.map +1 -0
  131. package/dist/frontend.d.ts +187 -0
  132. package/dist/frontend.d.ts.map +1 -0
  133. package/dist/frontend.js +543 -73
  134. package/dist/frontend.js.map +1 -0
  135. package/dist/frontendTypes.d.ts +57 -0
  136. package/dist/frontendTypes.d.ts.map +1 -0
  137. package/dist/frontendTypes.js +45 -0
  138. package/dist/frontendTypes.js.map +1 -0
  139. package/dist/helpers.d.ts +43 -0
  140. package/dist/helpers.d.ts.map +1 -0
  141. package/dist/helpers.js +53 -0
  142. package/dist/helpers.js.map +1 -0
  143. package/dist/index.d.ts +23 -0
  144. package/dist/index.d.ts.map +1 -0
  145. package/dist/index.js +25 -0
  146. package/dist/index.js.map +1 -0
  147. package/dist/jestutils/export.d.ts +1 -0
  148. package/dist/jestutils/export.d.ts.map +1 -0
  149. package/dist/jestutils/export.js +1 -0
  150. package/dist/jestutils/export.js.map +1 -0
  151. package/dist/jestutils/jestHelpers.d.ts +255 -0
  152. package/dist/jestutils/jestHelpers.d.ts.map +1 -0
  153. package/dist/jestutils/jestHelpers.js +372 -14
  154. package/dist/jestutils/jestHelpers.js.map +1 -0
  155. package/dist/logger/export.d.ts +1 -0
  156. package/dist/logger/export.d.ts.map +1 -0
  157. package/dist/logger/export.js +1 -0
  158. package/dist/logger/export.js.map +1 -0
  159. package/dist/matter/behaviors.d.ts +1 -0
  160. package/dist/matter/behaviors.d.ts.map +1 -0
  161. package/dist/matter/behaviors.js +2 -0
  162. package/dist/matter/behaviors.js.map +1 -0
  163. package/dist/matter/clusters.d.ts +1 -0
  164. package/dist/matter/clusters.d.ts.map +1 -0
  165. package/dist/matter/clusters.js +2 -0
  166. package/dist/matter/clusters.js.map +1 -0
  167. package/dist/matter/devices.d.ts +1 -0
  168. package/dist/matter/devices.d.ts.map +1 -0
  169. package/dist/matter/devices.js +2 -0
  170. package/dist/matter/devices.js.map +1 -0
  171. package/dist/matter/endpoints.d.ts +1 -0
  172. package/dist/matter/endpoints.d.ts.map +1 -0
  173. package/dist/matter/endpoints.js +2 -0
  174. package/dist/matter/endpoints.js.map +1 -0
  175. package/dist/matter/export.d.ts +1 -0
  176. package/dist/matter/export.d.ts.map +1 -0
  177. package/dist/matter/export.js +2 -0
  178. package/dist/matter/export.js.map +1 -0
  179. package/dist/matter/types.d.ts +1 -0
  180. package/dist/matter/types.d.ts.map +1 -0
  181. package/dist/matter/types.js +2 -0
  182. package/dist/matter/types.js.map +1 -0
  183. package/dist/matterNode.d.ts +258 -0
  184. package/dist/matterNode.d.ts.map +1 -0
  185. package/dist/matterNode.js +362 -9
  186. package/dist/matterNode.js.map +1 -0
  187. package/dist/matterbridge.d.ts +362 -0
  188. package/dist/matterbridge.d.ts.map +1 -0
  189. package/dist/matterbridge.js +879 -56
  190. package/dist/matterbridge.js.map +1 -0
  191. package/dist/matterbridgeAccessoryPlatform.d.ts +36 -0
  192. package/dist/matterbridgeAccessoryPlatform.d.ts.map +1 -0
  193. package/dist/matterbridgeAccessoryPlatform.js +38 -0
  194. package/dist/matterbridgeAccessoryPlatform.js.map +1 -0
  195. package/dist/matterbridgeBehaviors.d.ts +24 -0
  196. package/dist/matterbridgeBehaviors.d.ts.map +1 -0
  197. package/dist/matterbridgeBehaviors.js +68 -5
  198. package/dist/matterbridgeBehaviors.js.map +1 -0
  199. package/dist/matterbridgeDeviceTypes.d.ts +649 -0
  200. package/dist/matterbridgeDeviceTypes.d.ts.map +1 -0
  201. package/dist/matterbridgeDeviceTypes.js +673 -6
  202. package/dist/matterbridgeDeviceTypes.js.map +1 -0
  203. package/dist/matterbridgeDynamicPlatform.d.ts +36 -0
  204. package/dist/matterbridgeDynamicPlatform.d.ts.map +1 -0
  205. package/dist/matterbridgeDynamicPlatform.js +38 -0
  206. package/dist/matterbridgeDynamicPlatform.js.map +1 -0
  207. package/dist/matterbridgeEndpoint.d.ts +1332 -0
  208. package/dist/matterbridgeEndpoint.d.ts.map +1 -0
  209. package/dist/matterbridgeEndpoint.js +1457 -53
  210. package/dist/matterbridgeEndpoint.js.map +1 -0
  211. package/dist/matterbridgeEndpointHelpers.d.ts +425 -0
  212. package/dist/matterbridgeEndpointHelpers.d.ts.map +1 -0
  213. package/dist/matterbridgeEndpointHelpers.js +483 -20
  214. package/dist/matterbridgeEndpointHelpers.js.map +1 -0
  215. package/dist/matterbridgeEndpointTypes.d.ts +70 -0
  216. package/dist/matterbridgeEndpointTypes.d.ts.map +1 -0
  217. package/dist/matterbridgeEndpointTypes.js +25 -0
  218. package/dist/matterbridgeEndpointTypes.js.map +1 -0
  219. package/dist/matterbridgePlatform.d.ts +425 -0
  220. package/dist/matterbridgePlatform.d.ts.map +1 -0
  221. package/dist/matterbridgePlatform.js +451 -1
  222. package/dist/matterbridgePlatform.js.map +1 -0
  223. package/dist/matterbridgeTypes.d.ts +46 -0
  224. package/dist/matterbridgeTypes.d.ts.map +1 -0
  225. package/dist/matterbridgeTypes.js +26 -0
  226. package/dist/matterbridgeTypes.js.map +1 -0
  227. package/dist/pluginManager.d.ts +305 -0
  228. package/dist/pluginManager.d.ts.map +1 -0
  229. package/dist/pluginManager.js +341 -5
  230. package/dist/pluginManager.js.map +1 -0
  231. package/dist/shelly.d.ts +157 -0
  232. package/dist/shelly.d.ts.map +1 -0
  233. package/dist/shelly.js +178 -7
  234. package/dist/shelly.js.map +1 -0
  235. package/dist/storage/export.d.ts +1 -0
  236. package/dist/storage/export.d.ts.map +1 -0
  237. package/dist/storage/export.js +1 -0
  238. package/dist/storage/export.js.map +1 -0
  239. package/dist/update.d.ts +75 -0
  240. package/dist/update.d.ts.map +1 -0
  241. package/dist/update.js +93 -1
  242. package/dist/update.js.map +1 -0
  243. package/dist/utils/colorUtils.d.ts +77 -0
  244. package/dist/utils/colorUtils.d.ts.map +1 -0
  245. package/dist/utils/colorUtils.js +97 -2
  246. package/dist/utils/colorUtils.js.map +1 -0
  247. package/dist/utils/commandLine.d.ts +60 -0
  248. package/dist/utils/commandLine.d.ts.map +1 -0
  249. package/dist/utils/commandLine.js +60 -0
  250. package/dist/utils/commandLine.js.map +1 -0
  251. package/dist/utils/copyDirectory.d.ts +33 -0
  252. package/dist/utils/copyDirectory.d.ts.map +1 -0
  253. package/dist/utils/copyDirectory.js +37 -0
  254. package/dist/utils/copyDirectory.js.map +1 -0
  255. package/dist/utils/createDirectory.d.ts +32 -0
  256. package/dist/utils/createDirectory.d.ts.map +1 -0
  257. package/dist/utils/createDirectory.js +33 -0
  258. package/dist/utils/createDirectory.js.map +1 -0
  259. package/dist/utils/createZip.d.ts +38 -0
  260. package/dist/utils/createZip.d.ts.map +1 -0
  261. package/dist/utils/createZip.js +47 -2
  262. package/dist/utils/createZip.js.map +1 -0
  263. package/dist/utils/deepCopy.d.ts +31 -0
  264. package/dist/utils/deepCopy.d.ts.map +1 -0
  265. package/dist/utils/deepCopy.js +39 -0
  266. package/dist/utils/deepCopy.js.map +1 -0
  267. package/dist/utils/deepEqual.d.ts +53 -0
  268. package/dist/utils/deepEqual.d.ts.map +1 -0
  269. package/dist/utils/deepEqual.js +72 -1
  270. package/dist/utils/deepEqual.js.map +1 -0
  271. package/dist/utils/error.d.ts +42 -0
  272. package/dist/utils/error.d.ts.map +1 -0
  273. package/dist/utils/error.js +42 -0
  274. package/dist/utils/error.js.map +1 -0
  275. package/dist/utils/export.d.ts +1 -0
  276. package/dist/utils/export.d.ts.map +1 -0
  277. package/dist/utils/export.js +1 -0
  278. package/dist/utils/export.js.map +1 -0
  279. package/dist/utils/format.d.ts +49 -0
  280. package/dist/utils/format.d.ts.map +1 -0
  281. package/dist/utils/format.js +49 -0
  282. package/dist/utils/format.js.map +1 -0
  283. package/dist/utils/hex.d.ts +85 -0
  284. package/dist/utils/hex.d.ts.map +1 -0
  285. package/dist/utils/hex.js +124 -0
  286. package/dist/utils/hex.js.map +1 -0
  287. package/dist/utils/inspector.d.ts +63 -0
  288. package/dist/utils/inspector.d.ts.map +1 -0
  289. package/dist/utils/inspector.js +69 -1
  290. package/dist/utils/inspector.js.map +1 -0
  291. package/dist/utils/isValid.d.ts +93 -0
  292. package/dist/utils/isValid.d.ts.map +1 -0
  293. package/dist/utils/isValid.js +93 -0
  294. package/dist/utils/isValid.js.map +1 -0
  295. package/dist/utils/network.d.ts +116 -0
  296. package/dist/utils/network.d.ts.map +1 -0
  297. package/dist/utils/network.js +126 -5
  298. package/dist/utils/network.js.map +1 -0
  299. package/dist/utils/spawn.d.ts +32 -0
  300. package/dist/utils/spawn.d.ts.map +1 -0
  301. package/dist/utils/spawn.js +71 -1
  302. package/dist/utils/spawn.js.map +1 -0
  303. package/dist/utils/tracker.d.ts +56 -0
  304. package/dist/utils/tracker.d.ts.map +1 -0
  305. package/dist/utils/tracker.js +64 -1
  306. package/dist/utils/tracker.js.map +1 -0
  307. package/dist/utils/wait.d.ts +51 -0
  308. package/dist/utils/wait.d.ts.map +1 -0
  309. package/dist/utils/wait.js +60 -8
  310. package/dist/utils/wait.js.map +1 -0
  311. package/dist/workerGlobalPrefix.d.ts +24 -0
  312. package/dist/workerGlobalPrefix.d.ts.map +1 -0
  313. package/dist/workerGlobalPrefix.js +37 -5
  314. package/dist/workerGlobalPrefix.js.map +1 -0
  315. package/dist/workerTypes.d.ts +25 -0
  316. package/dist/workerTypes.d.ts.map +1 -0
  317. package/dist/workerTypes.js +24 -0
  318. package/dist/workerTypes.js.map +1 -0
  319. package/dist/workers.d.ts +61 -0
  320. package/dist/workers.d.ts.map +1 -0
  321. package/dist/workers.js +68 -4
  322. package/dist/workers.js.map +1 -0
  323. package/frontend/build/assets/index.js +4 -4
  324. package/frontend/package.json +1 -1
  325. package/npm-shrinkwrap.json +5 -35
  326. package/package.json +7 -7
@@ -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 mandatory since Matter 1.4.2.
1094
+ */
524
1095
  createDefaultScenesManagementClusterServer() {
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,11 +1613,32 @@ 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
1640
  externalMeasuredIndoorTemperature: localTemperature * 100,
800
- ...(outdoorTemperature !== undefined ? { outdoorTemperature: outdoorTemperature !== null ? outdoorTemperature * 100 : outdoorTemperature } : {}),
1641
+ ...(outdoorTemperature !== undefined ? { outdoorTemperature: outdoorTemperature !== null ? outdoorTemperature * 100 : outdoorTemperature } : {}), // Optional nullable attribute
801
1642
  controlSequenceOfOperation: Thermostat.ControlSequenceOfOperation.CoolingAndHeating,
802
1643
  systemMode: Thermostat.SystemMode.Auto,
803
1644
  thermostatRunningState: {
@@ -809,18 +1650,22 @@ export class MatterbridgeEndpoint extends Endpoint {
809
1650
  fanStage2: false,
810
1651
  fanStage3: false,
811
1652
  },
1653
+ // Thermostat.Feature.Heating
812
1654
  occupiedHeatingSetpoint: occupiedHeatingSetpoint * 100,
813
1655
  minHeatSetpointLimit: minHeatSetpointLimit * 100,
814
1656
  maxHeatSetpointLimit: maxHeatSetpointLimit * 100,
815
1657
  absMinHeatSetpointLimit: minHeatSetpointLimit * 100,
816
1658
  absMaxHeatSetpointLimit: maxHeatSetpointLimit * 100,
1659
+ // Thermostat.Feature.Cooling
817
1660
  occupiedCoolingSetpoint: occupiedCoolingSetpoint * 100,
818
1661
  minCoolSetpointLimit: minCoolSetpointLimit * 100,
819
1662
  maxCoolSetpointLimit: maxCoolSetpointLimit * 100,
820
1663
  absMinCoolSetpointLimit: minCoolSetpointLimit * 100,
821
1664
  absMaxCoolSetpointLimit: maxCoolSetpointLimit * 100,
1665
+ // Thermostat.Feature.AutoMode
822
1666
  minSetpointDeadBand: minSetpointDeadBand * 10,
823
1667
  thermostatRunningMode: Thermostat.ThermostatRunningMode.Off,
1668
+ // Thermostat.Feature.Occupancy
824
1669
  ...(occupied !== undefined ? { unoccupiedHeatingSetpoint: unoccupiedHeatingSetpoint !== undefined ? unoccupiedHeatingSetpoint * 100 : 1900 } : {}),
825
1670
  ...(occupied !== undefined ? { unoccupiedCoolingSetpoint: unoccupiedCoolingSetpoint !== undefined ? unoccupiedCoolingSetpoint * 100 : 2700 } : {}),
826
1671
  ...(occupied !== undefined ? { occupancy: { occupied } } : {}),
@@ -828,11 +1673,27 @@ export class MatterbridgeEndpoint extends Endpoint {
828
1673
  });
829
1674
  return this;
830
1675
  }
1676
+ /**
1677
+ * Creates a default heating thermostat cluster server with feature **Heating**.
1678
+ *
1679
+ * - When the occupied parameter is provided (either false or true), the **Occupancy** feature is also added (defaults to undefined).
1680
+ * - When the outdoorTemperature parameter is provided (either null or a number), the outdoorTemperature attribute is also added (defaults to undefined).
1681
+ *
1682
+ * @param {number} [localTemperature] - The local temperature value in degrees Celsius. Defaults to 23°.
1683
+ * @param {number} [occupiedHeatingSetpoint] - The occupied heating setpoint value in degrees Celsius. Defaults to 21°.
1684
+ * @param {number} [minHeatSetpointLimit] - The minimum heat setpoint limit value. Defaults to 0°.
1685
+ * @param {number} [maxHeatSetpointLimit] - The maximum heat setpoint limit value. Defaults to 50°.
1686
+ * @param {number | undefined} [unoccupiedHeatingSetpoint] - The unoccupied heating setpoint value in degrees Celsius. Defaults to 19° (it will be ignored if occupied is not provided).
1687
+ * @param {boolean | undefined} [occupied] - The occupancy status. Defaults to undefined (it will be ignored).
1688
+ * @param {number | null | undefined} [outdoorTemperature] - The outdoor temperature value in degrees Celsius. Defaults to undefined (it will be ignored).
1689
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1690
+ */
831
1691
  createDefaultHeatingThermostatClusterServer(localTemperature = 23, occupiedHeatingSetpoint = 21, minHeatSetpointLimit = 0, maxHeatSetpointLimit = 50, unoccupiedHeatingSetpoint = undefined, occupied = undefined, outdoorTemperature = undefined) {
832
1692
  this.behaviors.require(MatterbridgeThermostatServer.with(Thermostat.Feature.Heating, ...(occupied !== undefined ? [Thermostat.Feature.Occupancy] : [])), {
1693
+ // Common attributes
833
1694
  localTemperature: localTemperature * 100,
834
1695
  externalMeasuredIndoorTemperature: localTemperature * 100,
835
- ...(outdoorTemperature !== undefined ? { outdoorTemperature: outdoorTemperature !== null ? outdoorTemperature * 100 : outdoorTemperature } : {}),
1696
+ ...(outdoorTemperature !== undefined ? { outdoorTemperature: outdoorTemperature !== null ? outdoorTemperature * 100 : outdoorTemperature } : {}), // Optional nullable attribute
836
1697
  controlSequenceOfOperation: Thermostat.ControlSequenceOfOperation.HeatingOnly,
837
1698
  systemMode: Thermostat.SystemMode.Heat,
838
1699
  thermostatRunningState: {
@@ -844,22 +1705,40 @@ export class MatterbridgeEndpoint extends Endpoint {
844
1705
  fanStage2: false,
845
1706
  fanStage3: false,
846
1707
  },
1708
+ // Thermostat.Feature.Heating
847
1709
  occupiedHeatingSetpoint: occupiedHeatingSetpoint * 100,
848
1710
  minHeatSetpointLimit: minHeatSetpointLimit * 100,
849
1711
  maxHeatSetpointLimit: maxHeatSetpointLimit * 100,
850
1712
  absMinHeatSetpointLimit: minHeatSetpointLimit * 100,
851
1713
  absMaxHeatSetpointLimit: maxHeatSetpointLimit * 100,
1714
+ // Thermostat.Feature.Occupancy
852
1715
  ...(occupied !== undefined ? { unoccupiedHeatingSetpoint: unoccupiedHeatingSetpoint !== undefined ? unoccupiedHeatingSetpoint * 100 : 1900 } : {}),
853
1716
  ...(occupied !== undefined ? { occupancy: { occupied } } : {}),
854
1717
  ...(occupied !== undefined ? { externallyMeasuredOccupancy: true } : {}),
855
1718
  });
856
1719
  return this;
857
1720
  }
1721
+ /**
1722
+ * Creates a default cooling thermostat cluster server with feature **Cooling**.
1723
+ *
1724
+ * - When the occupied parameter is provided (either false or true), the **Occupancy** feature is also added (defaults to undefined).
1725
+ * - When the outdoorTemperature parameter is provided (either null or a number), the outdoorTemperature attribute is also added (defaults to undefined).
1726
+ *
1727
+ * @param {number} [localTemperature] - The local temperature value in degrees Celsius. Defaults to 23°.
1728
+ * @param {number} [occupiedCoolingSetpoint] - The occupied cooling setpoint value in degrees Celsius. Defaults to 25°.
1729
+ * @param {number} [minCoolSetpointLimit] - The minimum cool setpoint limit value. Defaults to 0°.
1730
+ * @param {number} [maxCoolSetpointLimit] - The maximum cool setpoint limit value. Defaults to 50°.
1731
+ * @param {number | undefined} [unoccupiedCoolingSetpoint] - The unoccupied cooling setpoint value in degrees Celsius. Defaults to 27° (it will be ignored if occupied is not provided).
1732
+ * @param {boolean | undefined} [occupied] - The occupancy status. Defaults to undefined (it will be ignored).
1733
+ * @param {number | null | undefined} [outdoorTemperature] - The outdoor temperature value in degrees Celsius. Defaults to undefined (it will be ignored).
1734
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1735
+ */
858
1736
  createDefaultCoolingThermostatClusterServer(localTemperature = 23, occupiedCoolingSetpoint = 25, minCoolSetpointLimit = 0, maxCoolSetpointLimit = 50, unoccupiedCoolingSetpoint = undefined, occupied = undefined, outdoorTemperature = undefined) {
859
1737
  this.behaviors.require(MatterbridgeThermostatServer.with(Thermostat.Feature.Cooling, ...(occupied !== undefined ? [Thermostat.Feature.Occupancy] : [])), {
1738
+ // Common attributes
860
1739
  localTemperature: localTemperature * 100,
861
1740
  externalMeasuredIndoorTemperature: localTemperature * 100,
862
- ...(outdoorTemperature !== undefined ? { outdoorTemperature: outdoorTemperature !== null ? outdoorTemperature * 100 : outdoorTemperature } : {}),
1741
+ ...(outdoorTemperature !== undefined ? { outdoorTemperature: outdoorTemperature !== null ? outdoorTemperature * 100 : outdoorTemperature } : {}), // Optional nullable attribute
863
1742
  controlSequenceOfOperation: Thermostat.ControlSequenceOfOperation.CoolingOnly,
864
1743
  systemMode: Thermostat.SystemMode.Cool,
865
1744
  thermostatRunningState: {
@@ -871,17 +1750,33 @@ export class MatterbridgeEndpoint extends Endpoint {
871
1750
  fanStage2: false,
872
1751
  fanStage3: false,
873
1752
  },
1753
+ // Thermostat.Feature.Cooling
874
1754
  occupiedCoolingSetpoint: occupiedCoolingSetpoint * 100,
875
1755
  minCoolSetpointLimit: minCoolSetpointLimit * 100,
876
1756
  maxCoolSetpointLimit: maxCoolSetpointLimit * 100,
877
1757
  absMinCoolSetpointLimit: minCoolSetpointLimit * 100,
878
1758
  absMaxCoolSetpointLimit: maxCoolSetpointLimit * 100,
1759
+ // Thermostat.Feature.Occupancy
879
1760
  ...(occupied !== undefined ? { unoccupiedCoolingSetpoint: unoccupiedCoolingSetpoint !== undefined ? unoccupiedCoolingSetpoint * 100 : 2700 } : {}),
880
1761
  ...(occupied !== undefined ? { occupancy: { occupied } } : {}),
881
1762
  ...(occupied !== undefined ? { externallyMeasuredOccupancy: true } : {}),
882
1763
  });
883
1764
  return this;
884
1765
  }
1766
+ /**
1767
+ * Creates a default thermostat user interface configuration cluster server.
1768
+ *
1769
+ * @param {ThermostatUserInterfaceConfiguration.TemperatureDisplayMode} [temperatureDisplayMode] - The temperature display mode to set. Defaults to `ThermostatUserInterfaceConfiguration.TemperatureDisplayMode.Celsius`.
1770
+ * @param {ThermostatUserInterfaceConfiguration.KeypadLockout} [keypadLockout] - The keypad lockout mode. Defaults to `ThermostatUserInterfaceConfiguration.KeypadLockout.NoLockout`.
1771
+ * @param {ThermostatUserInterfaceConfiguration.ScheduleProgrammingVisibility} [scheduleProgrammingVisibility] - The schedule programming visibility. Defaults to `ThermostatUserInterfaceConfiguration.ScheduleProgrammingVisibility.ScheduleProgrammingPermitted`.
1772
+ *
1773
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1774
+ * @remarks
1775
+ * The default values are:
1776
+ * - temperatureDisplayMode: ThermostatUserInterfaceConfiguration.TemperatureDisplayMode.Celsius (writable).
1777
+ * - keypadLockout: ThermostatUserInterfaceConfiguration.KeypadLockout.NoLockout (writable).
1778
+ * - scheduleProgrammingVisibility: ThermostatUserInterfaceConfiguration.ScheduleProgrammingVisibility.ScheduleProgrammingPermitted (writable).
1779
+ */
885
1780
  createDefaultThermostatUserInterfaceConfigurationClusterServer(temperatureDisplayMode = ThermostatUserInterfaceConfiguration.TemperatureDisplayMode.Celsius, keypadLockout = ThermostatUserInterfaceConfiguration.KeypadLockout.NoLockout, scheduleProgrammingVisibility = ThermostatUserInterfaceConfiguration.ScheduleProgrammingVisibility.ScheduleProgrammingPermitted) {
886
1781
  this.behaviors.require(ThermostatUserInterfaceConfigurationServer, {
887
1782
  temperatureDisplayMode,
@@ -890,95 +1785,286 @@ export class MatterbridgeEndpoint extends Endpoint {
890
1785
  });
891
1786
  return this;
892
1787
  }
1788
+ /**
1789
+ * Creates a default fan control cluster server with features Auto, and Step and mode Off Low Med High Auto.
1790
+ *
1791
+ * @param {FanControl.FanMode} [fanMode] - The fan mode to set. Defaults to `FanControl.FanMode.Off`.
1792
+ * @param {FanControl.FanModeSequence} [fanModeSequence] - The fan mode sequence to set. Defaults to `FanControl.FanModeSequence.OffLowMedHighAuto`.
1793
+ * @param {number} [percentSetting] - The initial percent setting. Defaults to 0.
1794
+ * @param {number} [percentCurrent] - The initial percent current. Defaults to 0.
1795
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1796
+ *
1797
+ * @remarks
1798
+ * - fanmode is writable and persists across reboots.
1799
+ * - fanModeSequence is fixed.
1800
+ * - percentSetting is writable.
1801
+ */
893
1802
  createDefaultFanControlClusterServer(fanMode = FanControl.FanMode.Off, fanModeSequence = FanControl.FanModeSequence.OffLowMedHighAuto, percentSetting = 0, percentCurrent = 0) {
894
1803
  this.behaviors.require(MatterbridgeFanControlServer.with(FanControl.Feature.Auto, FanControl.Feature.Step), {
895
- fanMode,
896
- fanModeSequence,
897
- percentSetting,
1804
+ // Base fan control attributes
1805
+ fanMode, // Writable and persistent attribute
1806
+ fanModeSequence, // Fixed attribute
1807
+ percentSetting, // Writable attribute
898
1808
  percentCurrent,
899
1809
  });
900
1810
  return this;
901
1811
  }
1812
+ /**
1813
+ * Creates an On Off fan control cluster server without features and mode Off High.
1814
+ *
1815
+ * @param {FanControl.FanMode} [fanMode] - The fan mode to set. Defaults to `FanControl.FanMode.Off`.
1816
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1817
+ *
1818
+ * @remarks
1819
+ * fanmode is writable and persists across reboots.
1820
+ * fanModeSequence is fixed.
1821
+ * percentSetting is writable.
1822
+ */
902
1823
  createOnOffFanControlClusterServer(fanMode = FanControl.FanMode.Off) {
903
1824
  this.behaviors.require(FanControlServer, {
904
- fanMode,
905
- fanModeSequence: FanControl.FanModeSequence.OffHigh,
906
- percentSetting: 0,
1825
+ // Base fan control attributes
1826
+ fanMode, // Writable and persistent attribute
1827
+ fanModeSequence: FanControl.FanModeSequence.OffHigh, // Fixed attribute
1828
+ percentSetting: 0, // Writable attribute
907
1829
  percentCurrent: 0,
908
1830
  });
909
1831
  return this;
910
1832
  }
1833
+ /**
1834
+ * Creates a base fan control cluster server without features and mode Off Low Med High.
1835
+ *
1836
+ * @param {FanControl.FanMode} [fanMode] - The fan mode to set. Defaults to `FanControl.FanMode.Off`.
1837
+ * @param {FanControl.FanModeSequence} [fanModeSequence] - The fan mode sequence to set. Defaults to `FanControl.FanModeSequence.OffLowMedHigh`.
1838
+ * @param {number} [percentSetting] - The initial percent setting. Defaults to 0.
1839
+ * @param {number} [percentCurrent] - The initial percent current. Defaults to 0.
1840
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1841
+ *
1842
+ * @remarks
1843
+ * fanmode is writable and persists across reboots.
1844
+ * fanModeSequence is fixed.
1845
+ * percentSetting is writable.
1846
+ */
911
1847
  createBaseFanControlClusterServer(fanMode = FanControl.FanMode.Off, fanModeSequence = FanControl.FanModeSequence.OffLowMedHigh, percentSetting = 0, percentCurrent = 0) {
912
1848
  this.behaviors.require(FanControlServer, {
913
- fanMode,
914
- fanModeSequence,
915
- percentSetting,
1849
+ // Base fan control attributes
1850
+ fanMode, // Writable and persistent attribute
1851
+ fanModeSequence, // Fixed attribute
1852
+ percentSetting, // Writable attribute
916
1853
  percentCurrent,
917
1854
  });
918
1855
  return this;
919
1856
  }
1857
+ /**
1858
+ * Creates a fan control cluster server with features MultiSpeed, Auto, and Step and mode Off Low Med High Auto.
1859
+ *
1860
+ * @param {FanControl.FanMode} [fanMode] - The fan mode to set. Defaults to `FanControl.FanMode.Off`.
1861
+ * @param {FanControl.FanModeSequence} [fanModeSequence] - The fan mode sequence to set. Defaults to `FanControl.FanModeSequence.OffLowMedHighAuto`.
1862
+ * @param {number} [percentSetting] - The initial percent setting. Defaults to 0.
1863
+ * @param {number} [percentCurrent] - The initial percent current. Defaults to 0.
1864
+ * @param {number} [speedMax] - The maximum speed setting. Defaults to 10.
1865
+ * @param {number} [speedSetting] - The initial speed setting. Defaults to 0.
1866
+ * @param {number} [speedCurrent] - The initial speed current. Defaults to 0.
1867
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1868
+ *
1869
+ * @remarks
1870
+ * - fanmode is writable and persists across reboots.
1871
+ * - fanModeSequence is fixed.
1872
+ * - percentSetting is writable.
1873
+ * - speedMax is fixed.
1874
+ * - speedSetting is writable.
1875
+ */
920
1876
  createMultiSpeedFanControlClusterServer(fanMode = FanControl.FanMode.Off, fanModeSequence = FanControl.FanModeSequence.OffLowMedHighAuto, percentSetting = 0, percentCurrent = 0, speedMax = 10, speedSetting = 0, speedCurrent = 0) {
921
1877
  this.behaviors.require(MatterbridgeFanControlServer.with(FanControl.Feature.MultiSpeed, FanControl.Feature.Auto, FanControl.Feature.Step), {
922
- fanMode,
923
- fanModeSequence,
924
- percentSetting,
1878
+ // Base fan control attributes
1879
+ fanMode, // Writable and persistent attribute
1880
+ fanModeSequence, // Fixed attribute
1881
+ percentSetting, // Writable attribute
925
1882
  percentCurrent,
926
- speedMax,
927
- speedSetting,
1883
+ // MultiSpeed feature
1884
+ speedMax, // Fixed attribute
1885
+ speedSetting, // Writable attribute
928
1886
  speedCurrent,
929
1887
  });
930
1888
  return this;
931
1889
  }
1890
+ /**
1891
+ * Creates a fan control cluster server with features MultiSpeed, Auto, Step, Rock, Wind and AirflowDirection and mode Off Low Med High Auto.
1892
+ *
1893
+ * @param {FanControl.FanMode} [fanMode] - The fan mode to set. Defaults to `FanControl.FanMode.Off`.
1894
+ * @param {FanControl.FanModeSequence} [fanModeSequence] - The fan mode sequence to set. Defaults to `FanControl.FanModeSequence.OffLowMedHighAuto`.
1895
+ * @param {number} [percentSetting] - The initial percent setting. Defaults to 0.
1896
+ * @param {number} [percentCurrent] - The initial percent current. Defaults to 0.
1897
+ * @param {number} [speedMax] - The maximum speed setting. Defaults to 10.
1898
+ * @param {number} [speedSetting] - The initial speed setting. Defaults to 0.
1899
+ * @param {number} [speedCurrent] - The initial speed current. Defaults to 0.
1900
+ * @param {object} [rockSupport] - The rock support configuration.
1901
+ * @param {boolean} rockSupport.rockLeftRight - Indicates support for rocking left to right. Defaults to true.
1902
+ * @param {boolean} rockSupport.rockUpDown - Indicates support for rocking up and down. Defaults to true.
1903
+ * @param {boolean} rockSupport.rockRound - Indicates support for round rocking. Defaults to true.
1904
+ * @param {object} [rockSetting] - The rock setting configuration.
1905
+ * @param {boolean} rockSetting.rockLeftRight - Indicates the current setting for rocking left to right. Defaults to true.
1906
+ * @param {boolean} rockSetting.rockUpDown - Indicates the current setting for rocking up and down. Defaults to true.
1907
+ * @param {boolean} rockSetting.rockRound - Indicates the current setting for round rocking. Defaults to true.
1908
+ * @param {object} [windSupport] - The wind support configuration.
1909
+ * @param {boolean} windSupport.sleepWind - Indicates support for sleep wind. Defaults to true.
1910
+ * @param {boolean} windSupport.naturalWind - Indicates support for natural wind. Defaults to true.
1911
+ * @param {object} [windSetting] - The wind setting configuration.
1912
+ * @param {boolean} windSetting.sleepWind - Indicates the current setting for sleep wind. Defaults to false.
1913
+ * @param {boolean} windSetting.naturalWind - Indicates the current setting for natural wind. Defaults to true.
1914
+ * @param {FanControl.AirflowDirection} [airflowDirection] - The airflow direction. Defaults to `FanControl.AirflowDirection.Forward`.
1915
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1916
+ *
1917
+ * @remarks
1918
+ * - fanmode is writable and persists across reboots.
1919
+ * - fanModeSequence is fixed.
1920
+ * - percentSetting is writable.
1921
+ * - speedMax is fixed.
1922
+ * - speedSetting is writable.
1923
+ * - rockSupport is fixed.
1924
+ * - rockSetting is writable.
1925
+ * - windSupport is fixed.
1926
+ * - windSetting is writable.
1927
+ * - airflowDirection is writable.
1928
+ */
932
1929
  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) {
933
1930
  this.behaviors.require(MatterbridgeFanControlServer.with(FanControl.Feature.MultiSpeed, FanControl.Feature.Auto, FanControl.Feature.Step, FanControl.Feature.Rocking, FanControl.Feature.Wind, FanControl.Feature.AirflowDirection), {
934
- fanMode,
935
- fanModeSequence,
936
- percentSetting,
1931
+ // Base fan control attributes
1932
+ fanMode, // Writable and persistent attribute
1933
+ fanModeSequence, // Fixed attribute
1934
+ percentSetting, // Writable attribute
937
1935
  percentCurrent,
938
- speedMax,
939
- speedSetting,
1936
+ // MultiSpeed feature
1937
+ speedMax, // Fixed attribute
1938
+ speedSetting, // Writable attribute
940
1939
  speedCurrent,
941
- rockSupport,
942
- rockSetting,
943
- windSupport,
944
- windSetting,
945
- airflowDirection,
1940
+ // Rocking feature
1941
+ rockSupport, // Fixed attribute
1942
+ rockSetting, // Writable attribute
1943
+ // Wind feature
1944
+ windSupport, // Fixed attribute
1945
+ windSetting, // Writable attribute
1946
+ // AirflowDirection feature
1947
+ airflowDirection, // Writable attribute
946
1948
  });
947
1949
  return this;
948
1950
  }
1951
+ /**
1952
+ * Creates a default HEPA Filter Monitoring Cluster Server with features Condition and ReplacementProductList.
1953
+ * It supports ResourceMonitoring.Feature.Condition, ResourceMonitoring.Feature.Warning, and ResourceMonitoring.Feature.ReplacementProductList.
1954
+ *
1955
+ * @param {number} condition - The initial condition value (range 0-100). Default is 100.
1956
+ * @param {ResourceMonitoring.ChangeIndication} changeIndication - The initial change indication. Default is ResourceMonitoring.ChangeIndication.Ok.
1957
+ * @param {boolean | undefined} inPlaceIndicator - The in-place indicator. Default is true.
1958
+ * @param {number | undefined} lastChangedTime - The last changed time (EpochS). Default is null.
1959
+ * @param {ResourceMonitoring.ReplacementProduct[]} replacementProductList - The list of replacement products. Default is an empty array. It is a fixed attribute.
1960
+ *
1961
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1962
+ *
1963
+ * @remarks
1964
+ * The HEPA Filter Monitoring Cluster Server is used to monitor the status of HEPA filters.
1965
+ * It provides information about the condition of the filter, whether it is in place, and the last time it was changed.
1966
+ * The change indication can be used to indicate if the filter needs to be replaced or serviced.
1967
+ * The replacement product list can be used to provide a list of replacement products for the filter.
1968
+ * The condition attribute is fixed at 100, indicating a healthy filter.
1969
+ * The degradation direction is fixed at ResourceMonitoring.DegradationDirection.Down, indicating that a lower value indicates a worse condition.
1970
+ * The replacement product list is initialized as an empty array.
1971
+ */
949
1972
  createDefaultHepaFilterMonitoringClusterServer(condition = 100, changeIndication = ResourceMonitoring.ChangeIndication.Ok, inPlaceIndicator = true, lastChangedTime = null, replacementProductList = []) {
950
1973
  this.behaviors.require(MatterbridgeHepaFilterMonitoringServer.with(ResourceMonitoring.Feature.Condition, ResourceMonitoring.Feature.Warning, ResourceMonitoring.Feature.ReplacementProductList), {
1974
+ // Feature.Condition
951
1975
  condition,
952
- degradationDirection: ResourceMonitoring.DegradationDirection.Down,
953
- replacementProductList,
1976
+ degradationDirection: ResourceMonitoring.DegradationDirection.Down, // Fixed attribute
1977
+ // Feature.ReplacementProductList
1978
+ replacementProductList, // Fixed attribute
1979
+ // Base attributes
954
1980
  changeIndication,
955
1981
  inPlaceIndicator,
956
- lastChangedTime,
1982
+ lastChangedTime, // Writable and persistent across restarts
957
1983
  });
958
1984
  return this;
959
1985
  }
1986
+ /**
1987
+ * Creates a default Activated Carbon Filter Monitoring Cluster Server with features Condition and ReplacementProductList.
1988
+ * It supports ResourceMonitoring.Feature.Condition, ResourceMonitoring.Feature.Warning, and ResourceMonitoring.Feature.ReplacementProductList.
1989
+ *
1990
+ * @param {number} condition - The initial condition value (range 0-100). Default is 100.
1991
+ * @param {ResourceMonitoring.ChangeIndication} changeIndication - The initial change indication. Default is ResourceMonitoring.ChangeIndication.Ok.
1992
+ * @param {boolean | undefined} inPlaceIndicator - The in-place indicator. Default is undefined.
1993
+ * @param {number | undefined} lastChangedTime - The last changed time (EpochS). Default is undefined.
1994
+ * @param {ResourceMonitoring.ReplacementProduct[]} replacementProductList - The list of replacement products. Default is an empty array. It is a fixed attribute.
1995
+ *
1996
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1997
+ *
1998
+ * @remarks
1999
+ * The Activated Carbon Filter Monitoring Cluster Server is used to monitor the status of activated carbon filters.
2000
+ * It provides information about the condition of the filter, whether it is in place, and the last time it was changed.
2001
+ * The change indication can be used to indicate if the filter needs to be replaced or serviced.
2002
+ * The replacement product list can be used to provide a list of replacement products for the filter.
2003
+ * The condition attribute is fixed at 100, indicating a healthy filter.
2004
+ * The degradation direction is fixed at ResourceMonitoring.DegradationDirection.Down, indicating that a lower value indicates a worse condition.
2005
+ * The replacement product list is initialized as an empty array.
2006
+ */
960
2007
  createDefaultActivatedCarbonFilterMonitoringClusterServer(condition = 100, changeIndication = ResourceMonitoring.ChangeIndication.Ok, inPlaceIndicator = true, lastChangedTime = null, replacementProductList = []) {
961
2008
  this.behaviors.require(MatterbridgeActivatedCarbonFilterMonitoringServer.with(ResourceMonitoring.Feature.Condition, ResourceMonitoring.Feature.Warning, ResourceMonitoring.Feature.ReplacementProductList), {
2009
+ // Feature.Condition
962
2010
  condition,
963
2011
  degradationDirection: ResourceMonitoring.DegradationDirection.Down,
964
- replacementProductList,
2012
+ // Feature.ReplacementProductList
2013
+ replacementProductList, // Fixed attribute
2014
+ // Base attributes
965
2015
  changeIndication,
966
2016
  inPlaceIndicator,
967
- lastChangedTime,
2017
+ lastChangedTime, // Writable and persistent across restarts
968
2018
  });
969
2019
  return this;
970
2020
  }
2021
+ /**
2022
+ * Creates a default door lock cluster server.
2023
+ *
2024
+ * @param {DoorLock.LockState} [lockState] - The initial state of the lock (default: Locked).
2025
+ * @param {DoorLock.LockType} [lockType] - The type of the lock (default: DeadBolt).
2026
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2027
+ *
2028
+ * @remarks
2029
+ * 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.
2030
+ */
971
2031
  createDefaultDoorLockClusterServer(lockState = DoorLock.LockState.Locked, lockType = DoorLock.LockType.DeadBolt) {
972
2032
  this.behaviors.require(MatterbridgeDoorLockServer.enable({ events: { doorLockAlarm: true, lockOperation: true, lockOperationError: true } }), {
973
2033
  lockState,
974
2034
  lockType,
975
2035
  actuatorEnabled: false,
2036
+ /** This attribute SHALL indicate the current operating mode of the lock as defined in OperatingModeEnum */
976
2037
  operatingMode: DoorLock.OperatingMode.Normal,
2038
+ /**
2039
+ * This attribute SHALL contain a bitmap with all operating bits of the OperatingMode attribute supported
2040
+ * by the lock. All operating modes NOT supported by a lock SHALL be set to one. The value of
2041
+ * the OperatingMode enumeration defines the related bit to be set.
2042
+ * OperatingModesBitmap.Normal and OperatingModesBitmap.noRemoteLockUnlock are mandatory and SHALL always be supported.
2043
+ * Default value 0xFFF6 (1111 1111 1111 0110) means:
2044
+ * - normal: false (bit 0)
2045
+ * - vacation: true (bit 1)
2046
+ * - privacy: true (bit 2)
2047
+ * - noRemoteLockUnlock: false (bit 3)
2048
+ * - passage: true (bit 4)
2049
+ * Special case of inverted bitmap: add also alwaysSet = 2047 (0000 0111 1111 1111) to have all bits set except the unsupported ones.
2050
+ */
977
2051
  supportedOperatingModes: { normal: false, vacation: true, privacy: true, noRemoteLockUnlock: false, passage: true, alwaysSet: 2047 },
978
- autoRelockTime: 0,
2052
+ autoRelockTime: 0, // 0=disabled
979
2053
  });
980
2054
  return this;
981
2055
  }
2056
+ /**
2057
+ * Creates a default Mode Select cluster server.
2058
+ *
2059
+ * @param {string} description - The description of the mode select cluster.
2060
+ * @param {ModeSelect.ModeOption[]} supportedModes - The list of supported modes.
2061
+ * @param {number} [currentMode] - The current mode (default: 0).
2062
+ * @param {number} [startUpMode] - The startup mode (default: 0).
2063
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2064
+ *
2065
+ * @remarks
2066
+ * endpoint.createDefaultModeSelectClusterServer('Night mode', [{ label: 'Led ON', mode: 0, semanticTags: [] }, { label: 'Led OFF', mode: 1, semanticTags: [] }], 0, 0);
2067
+ */
982
2068
  createDefaultModeSelectClusterServer(description, supportedModes, currentMode = 0, startUpMode = 0) {
983
2069
  this.behaviors.require(MatterbridgeModeSelectServer, {
984
2070
  description: description,
@@ -989,21 +2075,35 @@ export class MatterbridgeEndpoint extends Endpoint {
989
2075
  });
990
2076
  return this;
991
2077
  }
2078
+ /**
2079
+ * Creates the default Valve Configuration And Control cluster server with features Level.
2080
+ *
2081
+ * @param {ValveConfigurationAndControl.ValveState} [valveState] - The valve state to set. Defaults to `ValveConfigurationAndControl.ValveState.Closed`.
2082
+ * @param {number} [valveLevel] - The valve level to set. Defaults to 0.
2083
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2084
+ */
992
2085
  createDefaultValveConfigurationAndControlClusterServer(valveState = ValveConfigurationAndControl.ValveState.Closed, valveLevel = 0) {
993
2086
  this.behaviors.require(MatterbridgeValveConfigurationAndControlServer.with(ValveConfigurationAndControl.Feature.Level), {
994
2087
  currentState: valveState,
995
2088
  targetState: valveState,
996
2089
  openDuration: null,
997
- defaultOpenDuration: null,
2090
+ defaultOpenDuration: null, // Writable and persistent across restarts
998
2091
  remainingDuration: null,
999
2092
  valveFault: { generalFault: false, blocked: false, leaking: false, notConnected: false, shortCircuit: false, currentExceeded: false },
2093
+ // Feature.Level
1000
2094
  currentLevel: valveLevel,
1001
2095
  targetLevel: valveLevel,
1002
- defaultOpenLevel: 100,
1003
- levelStep: 1,
2096
+ defaultOpenLevel: 100, // Writable and persistent across restarts
2097
+ levelStep: 1, // Fixed
1004
2098
  });
1005
2099
  return this;
1006
2100
  }
2101
+ /**
2102
+ * Creates the default PumpConfigurationAndControl cluster server with features ConstantSpeed.
2103
+ *
2104
+ * @param {PumpConfigurationAndControl.OperationMode} [pumpMode] - The pump mode to set. Defaults to `PumpConfigurationAndControl.OperationMode.Normal`.
2105
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2106
+ */
1007
2107
  createDefaultPumpConfigurationAndControlClusterServer(pumpMode = PumpConfigurationAndControl.OperationMode.Normal) {
1008
2108
  this.behaviors.require(PumpConfigurationAndControlServer.with(PumpConfigurationAndControl.Feature.ConstantSpeed), {
1009
2109
  minConstSpeed: null,
@@ -1018,6 +2118,13 @@ export class MatterbridgeEndpoint extends Endpoint {
1018
2118
  });
1019
2119
  return this;
1020
2120
  }
2121
+ /**
2122
+ * Creates the default SmokeCOAlarm Cluster Server with features SmokeAlarm and CoAlarm.
2123
+ *
2124
+ * @param {SmokeCoAlarm.AlarmState} smokeState - The state of the smoke alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
2125
+ * @param {SmokeCoAlarm.AlarmState} coState - The state of the CO alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
2126
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2127
+ */
1021
2128
  createDefaultSmokeCOAlarmClusterServer(smokeState = SmokeCoAlarm.AlarmState.Normal, coState = SmokeCoAlarm.AlarmState.Normal) {
1022
2129
  this.behaviors.require(MatterbridgeSmokeCoAlarmServer.with(SmokeCoAlarm.Feature.SmokeAlarm, SmokeCoAlarm.Feature.CoAlarm).enable({
1023
2130
  events: { smokeAlarm: true, interconnectSmokeAlarm: false, coAlarm: true, interconnectCoAlarm: false, lowBattery: true, hardwareFault: true, endOfService: true, selfTestComplete: true, alarmMuted: true, muteEnded: true, allClear: true },
@@ -1033,6 +2140,12 @@ export class MatterbridgeEndpoint extends Endpoint {
1033
2140
  });
1034
2141
  return this;
1035
2142
  }
2143
+ /**
2144
+ * Creates a smoke only SmokeCOAlarm Cluster Server with features SmokeAlarm.
2145
+ *
2146
+ * @param {SmokeCoAlarm.AlarmState} smokeState - The state of the smoke alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
2147
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2148
+ */
1036
2149
  createSmokeOnlySmokeCOAlarmClusterServer(smokeState = SmokeCoAlarm.AlarmState.Normal) {
1037
2150
  this.behaviors.require(MatterbridgeSmokeCoAlarmServer.with(SmokeCoAlarm.Feature.SmokeAlarm).enable({
1038
2151
  events: { smokeAlarm: true, interconnectSmokeAlarm: false, lowBattery: true, hardwareFault: true, endOfService: true, selfTestComplete: true, alarmMuted: true, muteEnded: true, allClear: true },
@@ -1047,6 +2160,12 @@ export class MatterbridgeEndpoint extends Endpoint {
1047
2160
  });
1048
2161
  return this;
1049
2162
  }
2163
+ /**
2164
+ * Creates a co only SmokeCOAlarm Cluster Server with features CoAlarm.
2165
+ *
2166
+ * @param {SmokeCoAlarm.AlarmState} coState - The state of the CO alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
2167
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2168
+ */
1050
2169
  createCoOnlySmokeCOAlarmClusterServer(coState = SmokeCoAlarm.AlarmState.Normal) {
1051
2170
  this.behaviors.require(MatterbridgeSmokeCoAlarmServer.with(SmokeCoAlarm.Feature.CoAlarm).enable({
1052
2171
  events: { coAlarm: true, interconnectCoAlarm: false, lowBattery: true, hardwareFault: true, endOfService: true, selfTestComplete: true, alarmMuted: true, muteEnded: true, allClear: true },
@@ -1061,6 +2180,15 @@ export class MatterbridgeEndpoint extends Endpoint {
1061
2180
  });
1062
2181
  return this;
1063
2182
  }
2183
+ /**
2184
+ * Creates a default momentary switch cluster server with features MomentarySwitch, MomentarySwitchRelease, MomentarySwitchLongPress and MomentarySwitchMultiPress
2185
+ * and events initialPress, longPress, shortRelease, longRelease, multiPressOngoing, multiPressComplete.
2186
+ *
2187
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2188
+ *
2189
+ * @remarks
2190
+ * This method adds a cluster server with default momentary switch features and configuration suitable for (AppleHome) Single Double Long automations.
2191
+ */
1064
2192
  createDefaultSwitchClusterServer() {
1065
2193
  this.behaviors.require(MatterbridgeSwitchServer.with(Switch.Feature.MomentarySwitch, Switch.Feature.MomentarySwitchRelease, Switch.Feature.MomentarySwitchLongPress, Switch.Feature.MomentarySwitchMultiPress).enable({
1066
2194
  events: { initialPress: true, longPress: true, shortRelease: true, longRelease: true, multiPressOngoing: true, multiPressComplete: true },
@@ -1071,6 +2199,15 @@ export class MatterbridgeEndpoint extends Endpoint {
1071
2199
  });
1072
2200
  return this;
1073
2201
  }
2202
+ /**
2203
+ * Creates a default momentary switch cluster server with feature MomentarySwitch and event initialPress.
2204
+ *
2205
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2206
+ *
2207
+ * @remarks
2208
+ * This method adds a cluster server with default momentary switch features and configuration suitable for a Single press automations.
2209
+ * It is supported by the Home app.
2210
+ */
1074
2211
  createDefaultMomentarySwitchClusterServer() {
1075
2212
  this.behaviors.require(MatterbridgeSwitchServer.with(Switch.Feature.MomentarySwitch).enable({
1076
2213
  events: { initialPress: true },
@@ -1080,6 +2217,14 @@ export class MatterbridgeEndpoint extends Endpoint {
1080
2217
  });
1081
2218
  return this;
1082
2219
  }
2220
+ /**
2221
+ * Creates a default latching switch cluster server with features LatchingSwitch.
2222
+ *
2223
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2224
+ *
2225
+ * @remarks
2226
+ * This method adds a cluster server with default latching switch features and configuration suitable for a latching switch with 2 positions.
2227
+ */
1083
2228
  createDefaultLatchingSwitchClusterServer() {
1084
2229
  this.behaviors.require(SwitchServer.with(Switch.Feature.LatchingSwitch).enable({
1085
2230
  events: { switchLatched: true },
@@ -1089,6 +2234,15 @@ export class MatterbridgeEndpoint extends Endpoint {
1089
2234
  });
1090
2235
  return this;
1091
2236
  }
2237
+ /**
2238
+ * Triggers a switch event on the specified endpoint.
2239
+ * We usually use get from real devices something like 'single', 'double', 'long'.
2240
+ * Here we convert it to the Matter sequence of events (taken from Matter specs).
2241
+ *
2242
+ * @param {string} event - The type of event to trigger. Possible values are 'Single', 'Double', 'Long' for momentarySwitch and 'Press', 'Release' for latchingSwitch.
2243
+ * @param {AnsiLogger} log - Optional logger to log the event.
2244
+ * @returns {boolean} - A boolean indicating whether the event was successfully triggered.
2245
+ */
1092
2246
  async triggerSwitchEvent(event, log) {
1093
2247
  if (this.maybeNumber === undefined) {
1094
2248
  this.log.error(`triggerSwitchEvent ${event} error: Endpoint number not assigned on endpoint ${this.maybeId}:${this.maybeNumber}`);
@@ -1150,10 +2304,37 @@ export class MatterbridgeEndpoint extends Endpoint {
1150
2304
  }
1151
2305
  return true;
1152
2306
  }
2307
+ /**
2308
+ * Creates a default OperationalState Cluster Server.
2309
+ *
2310
+ * @param {OperationalState.OperationalStateEnum} operationalState - The initial operational state id.
2311
+ *
2312
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2313
+ *
2314
+ * @remarks
2315
+ * This method adds a cluster server with a default operational state configuration:
2316
+ * - { operationalStateId: OperationalState.OperationalStateEnum.Stopped, operationalStateLabel: 'Stopped' },
2317
+ * - { operationalStateId: OperationalState.OperationalStateEnum.Running, operationalStateLabel: 'Running' },
2318
+ * - { operationalStateId: OperationalState.OperationalStateEnum.Paused, operationalStateLabel: 'Paused' },
2319
+ * - { operationalStateId: OperationalState.OperationalStateEnum.Error, operationalStateLabel: 'Error' },
2320
+ */
1153
2321
  createDefaultOperationalStateClusterServer(operationalState = OperationalState.OperationalStateEnum.Stopped) {
1154
2322
  this.behaviors.require(MatterbridgeOperationalStateServer, getDefaultOperationalStateClusterServer(operationalState));
1155
2323
  return this;
1156
2324
  }
2325
+ /**
2326
+ * Creates a default boolean state cluster server.
2327
+ * The stateChange event is enabled.
2328
+ *
2329
+ * @param {boolean} contact - The state of the cluster. Defaults to true (true = contact).
2330
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2331
+ *
2332
+ * @remarks
2333
+ * Water Leak Detector: true = leak, false = no leak
2334
+ * Water Freeze Detector: true = freeze, false = no freeze
2335
+ * Rain Sensor: true = rain, false = no rain
2336
+ * Contact Sensor: true = closed or contact, false = open or no contact
2337
+ */
1157
2338
  createDefaultBooleanStateClusterServer(contact) {
1158
2339
  this.behaviors.require(BooleanStateServer.enable({
1159
2340
  events: { stateChange: true },
@@ -1162,6 +2343,22 @@ export class MatterbridgeEndpoint extends Endpoint {
1162
2343
  });
1163
2344
  return this;
1164
2345
  }
2346
+ /**
2347
+ * Creates a default boolean state configuration cluster server to be used with the waterFreezeDetector, waterLeakDetector, and rainSensor device types.
2348
+ *
2349
+ * Features:
2350
+ * - Visual
2351
+ * - Audible
2352
+ * - SensitivityLevel
2353
+ *
2354
+ * @remarks Supports the enableDisableAlarm command.
2355
+ *
2356
+ * @param {boolean} [sensorFault] - Optional boolean value indicating the sensor fault state. Defaults to `false` if not provided.
2357
+ * @param {number} [currentSensitivityLevel] - The current sensitivity level. Defaults to `0` if not provided.
2358
+ * @param {number} [supportedSensitivityLevels] - The number of supported sensitivity levels. Defaults to `2` if not provided (min 2, max 10).
2359
+ * @param {number} [defaultSensitivityLevel] - The default sensitivity level. Defaults to `0` if not provided.
2360
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2361
+ */
1165
2362
  createDefaultBooleanStateConfigurationClusterServer(sensorFault = false, currentSensitivityLevel = 0, supportedSensitivityLevels = 2, defaultSensitivityLevel = 0) {
1166
2363
  this.behaviors.require(MatterbridgeBooleanStateConfigurationServer.with(BooleanStateConfiguration.Feature.Visual, BooleanStateConfiguration.Feature.Audible, BooleanStateConfiguration.Feature.SensitivityLevel).enable({
1167
2364
  events: { alarmsStateChanged: true, sensorFault: true },
@@ -1176,36 +2373,128 @@ export class MatterbridgeEndpoint extends Endpoint {
1176
2373
  });
1177
2374
  return this;
1178
2375
  }
2376
+ /**
2377
+ * Creates a default TemperatureMeasurement cluster server.
2378
+ *
2379
+ * @param {number | null} measuredValue - The measured value of the temperature x 100.
2380
+ * @param {number | null} minMeasuredValue - The minimum measured value of the temperature x 100.
2381
+ * @param {number | null} maxMeasuredValue - The maximum measured value of the temperature x 100.
2382
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2383
+ */
1179
2384
  createDefaultTemperatureMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
1180
2385
  this.behaviors.require(TemperatureMeasurementServer, getDefaultTemperatureMeasurementClusterServer(measuredValue, minMeasuredValue, maxMeasuredValue));
1181
2386
  return this;
1182
2387
  }
2388
+ /**
2389
+ * Creates a default RelativeHumidityMeasurement cluster server.
2390
+ *
2391
+ * @param {number | null} measuredValue - The measured value of the relative humidity x 100.
2392
+ * @param {number | null} minMeasuredValue - The minimum measured value of the relative humidity x 100.
2393
+ * @param {number | null} maxMeasuredValue - The maximum measured value of the relative humidity x 100.
2394
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2395
+ */
1183
2396
  createDefaultRelativeHumidityMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
1184
2397
  this.behaviors.require(RelativeHumidityMeasurementServer, getDefaultRelativeHumidityMeasurementClusterServer(measuredValue, minMeasuredValue, maxMeasuredValue));
1185
2398
  return this;
1186
2399
  }
2400
+ /**
2401
+ * Creates a default PressureMeasurement cluster server.
2402
+ *
2403
+ * @param {number | null} measuredValue - The measured value for the pressure in kPa x 10.
2404
+ * @param {number | null} minMeasuredValue - The minimum measured value for the pressure in kPa x 10.
2405
+ * @param {number | null} maxMeasuredValue - The maximum measured value for the pressure in kPa x 10.
2406
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2407
+ *
2408
+ * @remarks
2409
+ * - MeasuredValue = 10 x Pressure in kPa
2410
+ * - MeasuredValue = 1 x Pressure in hPa
2411
+ * - MeasuredValue = 33.8639 x Pressure in inHg
2412
+ *
2413
+ * Conversion:
2414
+ * - 1 kPa = 10 hPa
2415
+ * - 1 inHg = 33.8639 hPa
2416
+ */
1187
2417
  createDefaultPressureMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
1188
2418
  this.behaviors.require(PressureMeasurementServer, getDefaultPressureMeasurementClusterServer(measuredValue, minMeasuredValue, maxMeasuredValue));
1189
2419
  return this;
1190
2420
  }
2421
+ /**
2422
+ * Creates a default IlluminanceMeasurement cluster server.
2423
+ *
2424
+ * @param {number | null} measuredValue - The measured value of illuminance.
2425
+ * @param {number | null} minMeasuredValue - The minimum measured value of illuminance.
2426
+ * @param {number | null} maxMeasuredValue - The maximum measured value of illuminance.
2427
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2428
+ *
2429
+ * @remarks
2430
+ *
2431
+ * The default value for the illuminance measurement is null.
2432
+ *
2433
+ * This attribute SHALL indicate the illuminance in Lux (symbol lx) as follows:
2434
+ * • MeasuredValue = 10,000 x log10(illuminance) + 1,
2435
+ * where 1 lx <= illuminance <= 3.576 Mlx, corresponding to a MeasuredValue in the range 1 to 0xFFFE.
2436
+ * • 0 indicates a value of illuminance that is too low to be measured
2437
+ * • null indicates that the illuminance measurement is invalid.
2438
+ *
2439
+ * - Lux to matter = Math.round(Math.max(Math.min(10000 * Math.log10(lux), 0xfffe), 0))
2440
+ * - Matter to Lux = Math.round(Math.max(Math.pow(10, value / 10000), 0))
2441
+ */
1191
2442
  createDefaultIlluminanceMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
1192
2443
  this.behaviors.require(IlluminanceMeasurementServer, getDefaultIlluminanceMeasurementClusterServer(measuredValue, minMeasuredValue, maxMeasuredValue));
1193
2444
  return this;
1194
2445
  }
2446
+ /**
2447
+ * Creates a default FlowMeasurement cluster server.
2448
+ *
2449
+ * @param {number | null} measuredValue - The measured value of the flow in 10 x m3/h.
2450
+ * @param {number | null} minMeasuredValue - The minimum measured value of the flow in 10 x m3/h.
2451
+ * @param {number | null} maxMeasuredValue - The maximum measured value of the flow in 10 x m3/h.
2452
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2453
+ */
1195
2454
  createDefaultFlowMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
1196
2455
  this.behaviors.require(FlowMeasurementServer, getDefaultFlowMeasurementClusterServer(measuredValue, minMeasuredValue, maxMeasuredValue));
1197
2456
  return this;
1198
2457
  }
2458
+ /**
2459
+ * Creates a default OccupancySensing cluster server with feature PassiveInfrared.
2460
+ *
2461
+ * @param {boolean} occupied - A boolean indicating whether the occupancy is occupied or not. Default is false.
2462
+ * @param {number} holdTime - The hold time in seconds. Default is 30.
2463
+ * @param {number} holdTimeMin - The minimum hold time in seconds. Default is 1.
2464
+ * @param {number} holdTimeMax - The maximum hold time in seconds. Default is 300.
2465
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2466
+ *
2467
+ * @remarks The default value for the occupancy sensor type is PIR.
2468
+ */
1199
2469
  createDefaultOccupancySensingClusterServer(occupied = false, holdTime = 30, holdTimeMin = 1, holdTimeMax = 300) {
1200
2470
  this.behaviors.require(OccupancySensingServer.with(OccupancySensing.Feature.PassiveInfrared), getDefaultOccupancySensingClusterServer(occupied, holdTime, holdTimeMin, holdTimeMax));
1201
2471
  return this;
1202
2472
  }
2473
+ /**
2474
+ * Creates a default AirQuality cluster server.
2475
+ *
2476
+ * @param {AirQuality.AirQualityEnum} airQuality The air quality level. Defaults to `AirQuality.AirQualityType.Unknown`.
2477
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2478
+ */
1203
2479
  createDefaultAirQualityClusterServer(airQuality = AirQuality.AirQualityEnum.Unknown) {
1204
2480
  this.behaviors.require(AirQualityServer.with(AirQuality.Feature.Fair, AirQuality.Feature.Moderate, AirQuality.Feature.VeryPoor, AirQuality.Feature.ExtremelyPoor), {
1205
2481
  airQuality,
1206
2482
  });
1207
2483
  return this;
1208
2484
  }
2485
+ /**
2486
+ * Creates a default TotalVolatileOrganicCompoundsConcentrationMeasurement cluster server with feature NumericMeasurement.
2487
+ *
2488
+ * @param {number | null} measuredValue - The measured value of the concentration.
2489
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ugm3).
2490
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2491
+ * @param {number} [uncertainty] - The uncertainty value (optional).
2492
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2493
+ *
2494
+ * @remarks
2495
+ * The measurementUnit and the measurementMedium attributes are fixed and cannot be changed after creation.
2496
+ * Apple Home requires Ugm3 for TotalVolatileOrganicCompoundsConcentrationMeasurement cluster.
2497
+ */
1209
2498
  createDefaultTvocMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ugm3, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air, uncertainty) {
1210
2499
  this.behaviors.require(TotalVolatileOrganicCompoundsConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1211
2500
  measuredValue,
@@ -1217,6 +2506,16 @@ export class MatterbridgeEndpoint extends Endpoint {
1217
2506
  });
1218
2507
  return this;
1219
2508
  }
2509
+ /**
2510
+ * Creates a default TotalVolatileOrganicCompoundsConcentrationMeasurement cluster server with feature LevelIndication, MediumLevel and CriticalLevel.
2511
+ *
2512
+ * @param {ConcentrationMeasurement.LevelValue} levelValue - The level value of the measurement (default to ConcentrationMeasurement.LevelValue.Unknown).
2513
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The measurement medium (default to ConcentrationMeasurement.MeasurementMedium.Air).
2514
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2515
+ *
2516
+ * @remarks
2517
+ * The measurementMedium attribute is fixed and cannot be changed after creation.
2518
+ */
1220
2519
  createLevelTvocMeasurementClusterServer(levelValue = ConcentrationMeasurement.LevelValue.Unknown, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1221
2520
  this.behaviors.require(TotalVolatileOrganicCompoundsConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.LevelIndication, ConcentrationMeasurement.Feature.MediumLevel, ConcentrationMeasurement.Feature.CriticalLevel), {
1222
2521
  levelValue,
@@ -1224,6 +2523,17 @@ export class MatterbridgeEndpoint extends Endpoint {
1224
2523
  });
1225
2524
  return this;
1226
2525
  }
2526
+ /**
2527
+ * Create a default CarbonMonoxideConcentrationMeasurement cluster server with feature NumericMeasurement.
2528
+ *
2529
+ * @param {number | null} measuredValue - The measured value of the concentration.
2530
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
2531
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2532
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2533
+ *
2534
+ * @remarks
2535
+ * The measurementUnit and the measurementMedium attributes are fixed and cannot be changed after creation.
2536
+ */
1227
2537
  createDefaultCarbonMonoxideConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1228
2538
  this.behaviors.require(CarbonMonoxideConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1229
2539
  measuredValue,
@@ -1235,6 +2545,17 @@ export class MatterbridgeEndpoint extends Endpoint {
1235
2545
  });
1236
2546
  return this;
1237
2547
  }
2548
+ /**
2549
+ * Create a default CarbonDioxideConcentrationMeasurement cluster server with feature NumericMeasurement.
2550
+ *
2551
+ * @param {number | null} measuredValue - The measured value of the concentration.
2552
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
2553
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2554
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2555
+ *
2556
+ * @remarks
2557
+ * The measurementUnit and the measurementMedium attributes are fixed and cannot be changed after creation.
2558
+ */
1238
2559
  createDefaultCarbonDioxideConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1239
2560
  this.behaviors.require(CarbonDioxideConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1240
2561
  measuredValue,
@@ -1246,6 +2567,18 @@ export class MatterbridgeEndpoint extends Endpoint {
1246
2567
  });
1247
2568
  return this;
1248
2569
  }
2570
+ /**
2571
+ * Create a default FormaldehydeConcentrationMeasurement cluster server with feature NumericMeasurement.
2572
+ *
2573
+ * @param {number | null} measuredValue - The measured value of the concentration.
2574
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Mgm3).
2575
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2576
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2577
+ *
2578
+ * @remarks
2579
+ * The measurementUnit and the measurementMedium attributes are fixed and cannot be changed after creation.
2580
+ * Apple Home doesn't support FormaldehydeConcentrationMeasurement cluster.
2581
+ */
1249
2582
  createDefaultFormaldehydeConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Mgm3, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1250
2583
  this.behaviors.require(FormaldehydeConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1251
2584
  measuredValue,
@@ -1257,6 +2590,18 @@ export class MatterbridgeEndpoint extends Endpoint {
1257
2590
  });
1258
2591
  return this;
1259
2592
  }
2593
+ /**
2594
+ * Create a default Pm1ConcentrationMeasurement cluster server with feature NumericMeasurement.
2595
+ *
2596
+ * @param {number | null} measuredValue - The measured value of the concentration.
2597
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ugm3).
2598
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2599
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2600
+ *
2601
+ * @remarks
2602
+ * The measurementUnit and the measurementMedium attributes are fixed and cannot be changed after creation.
2603
+ * Apple Home doesn't support Pm1ConcentrationMeasurement cluster.
2604
+ */
1260
2605
  createDefaultPm1ConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ugm3, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1261
2606
  this.behaviors.require(Pm1ConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1262
2607
  measuredValue,
@@ -1268,6 +2613,18 @@ export class MatterbridgeEndpoint extends Endpoint {
1268
2613
  });
1269
2614
  return this;
1270
2615
  }
2616
+ /**
2617
+ * Create a default Pm25ConcentrationMeasurement cluster server with feature NumericMeasurement.
2618
+ *
2619
+ * @param {number | null} measuredValue - The measured value of the concentration.
2620
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ugm3).
2621
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2622
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2623
+ *
2624
+ * @remarks
2625
+ * The measurementUnit and the measurementMedium attributes are fixed and cannot be changed after creation.
2626
+ * Apple Home requires Ugm3 for Pm25ConcentrationMeasurement cluster.
2627
+ */
1271
2628
  createDefaultPm25ConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ugm3, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1272
2629
  this.behaviors.require(Pm25ConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1273
2630
  measuredValue,
@@ -1279,6 +2636,18 @@ export class MatterbridgeEndpoint extends Endpoint {
1279
2636
  });
1280
2637
  return this;
1281
2638
  }
2639
+ /**
2640
+ * Create a default Pm10ConcentrationMeasurement cluster server with feature NumericMeasurement.
2641
+ *
2642
+ * @param {number | null} measuredValue - The measured value of the concentration.
2643
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ugm3).
2644
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2645
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2646
+ *
2647
+ * @remarks
2648
+ * The measurementUnit and the measurementMedium attributes are fixed and cannot be changed after creation.
2649
+ * Apple Home requires Ugm3 for Pm10ConcentrationMeasurement cluster.
2650
+ */
1282
2651
  createDefaultPm10ConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ugm3, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1283
2652
  this.behaviors.require(Pm10ConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1284
2653
  measuredValue,
@@ -1290,6 +2659,17 @@ export class MatterbridgeEndpoint extends Endpoint {
1290
2659
  });
1291
2660
  return this;
1292
2661
  }
2662
+ /**
2663
+ * Create a default OzoneConcentrationMeasurement cluster server with feature NumericMeasurement.
2664
+ *
2665
+ * @param {number | null} measuredValue - The measured value of the concentration.
2666
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ugm3).
2667
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2668
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2669
+ *
2670
+ * @remarks
2671
+ * The measurementUnit and the measurementMedium attributes are fixed and cannot be changed after creation.
2672
+ */
1293
2673
  createDefaultOzoneConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ugm3, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1294
2674
  this.behaviors.require(OzoneConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1295
2675
  measuredValue,
@@ -1301,6 +2681,18 @@ export class MatterbridgeEndpoint extends Endpoint {
1301
2681
  });
1302
2682
  return this;
1303
2683
  }
2684
+ /**
2685
+ * Create a default RadonConcentrationMeasurement cluster server with feature NumericMeasurement.
2686
+ *
2687
+ * @param {number | null} measuredValue - The measured value of the concentration.
2688
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Bqm3).
2689
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2690
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2691
+ *
2692
+ * @remarks
2693
+ * The measurementUnit and the measurementMedium attributes are fixed and cannot be changed after creation.
2694
+ * Apple Home doesn't support RadonConcentrationMeasurement cluster.
2695
+ */
1304
2696
  createDefaultRadonConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Bqm3, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1305
2697
  this.behaviors.require(RadonConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1306
2698
  measuredValue,
@@ -1312,6 +2704,17 @@ export class MatterbridgeEndpoint extends Endpoint {
1312
2704
  });
1313
2705
  return this;
1314
2706
  }
2707
+ /**
2708
+ * Create a default NitrogenDioxideConcentrationMeasurement cluster server with feature NumericMeasurement.
2709
+ *
2710
+ * @param {number | null} measuredValue - The measured value of the concentration.
2711
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ugm3).
2712
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2713
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2714
+ *
2715
+ * @remarks
2716
+ * The measurementUnit and the measurementMedium attributes are fixed and cannot be changed after creation.
2717
+ */
1315
2718
  createDefaultNitrogenDioxideConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ugm3, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1316
2719
  this.behaviors.require(NitrogenDioxideConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1317
2720
  measuredValue,
@@ -1324,3 +2727,4 @@ export class MatterbridgeEndpoint extends Endpoint {
1324
2727
  return this;
1325
2728
  }
1326
2729
  }
2730
+ //# sourceMappingURL=matterbridgeEndpoint.js.map