matterbridge 3.1.8-dev-20250727-b8987de → 3.1.8

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 (253) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/dist/cli.d.ts +26 -0
  3. package/dist/cli.d.ts.map +1 -0
  4. package/dist/cli.js +91 -2
  5. package/dist/cli.js.map +1 -0
  6. package/dist/cliEmitter.d.ts +34 -0
  7. package/dist/cliEmitter.d.ts.map +1 -0
  8. package/dist/cliEmitter.js +30 -0
  9. package/dist/cliEmitter.js.map +1 -0
  10. package/dist/clusters/export.d.ts +2 -0
  11. package/dist/clusters/export.d.ts.map +1 -0
  12. package/dist/clusters/export.js +2 -0
  13. package/dist/clusters/export.js.map +1 -0
  14. package/dist/defaultConfigSchema.d.ts +28 -0
  15. package/dist/defaultConfigSchema.d.ts.map +1 -0
  16. package/dist/defaultConfigSchema.js +24 -0
  17. package/dist/defaultConfigSchema.js.map +1 -0
  18. package/dist/deviceManager.d.ts +112 -0
  19. package/dist/deviceManager.d.ts.map +1 -0
  20. package/dist/deviceManager.js +94 -1
  21. package/dist/deviceManager.js.map +1 -0
  22. package/dist/devices/batteryStorage.d.ts +48 -0
  23. package/dist/devices/batteryStorage.d.ts.map +1 -0
  24. package/dist/devices/batteryStorage.js +48 -1
  25. package/dist/devices/batteryStorage.js.map +1 -0
  26. package/dist/devices/dishwasher.d.ts +91 -0
  27. package/dist/devices/dishwasher.d.ts.map +1 -0
  28. package/dist/devices/dishwasher.js +78 -3
  29. package/dist/devices/dishwasher.js.map +1 -0
  30. package/dist/devices/evse.d.ts +75 -0
  31. package/dist/devices/evse.d.ts.map +1 -0
  32. package/dist/devices/evse.js +74 -10
  33. package/dist/devices/evse.js.map +1 -0
  34. package/dist/devices/export.d.ts +11 -0
  35. package/dist/devices/export.d.ts.map +1 -0
  36. package/dist/devices/export.js +2 -0
  37. package/dist/devices/export.js.map +1 -0
  38. package/dist/devices/extractorHood.d.ts +46 -0
  39. package/dist/devices/extractorHood.d.ts.map +1 -0
  40. package/dist/devices/extractorHood.js +42 -0
  41. package/dist/devices/extractorHood.js.map +1 -0
  42. package/dist/devices/heatPump.d.ts +47 -0
  43. package/dist/devices/heatPump.d.ts.map +1 -0
  44. package/dist/devices/heatPump.js +50 -2
  45. package/dist/devices/heatPump.js.map +1 -0
  46. package/dist/devices/laundryDryer.d.ts +87 -0
  47. package/dist/devices/laundryDryer.d.ts.map +1 -0
  48. package/dist/devices/laundryDryer.js +83 -6
  49. package/dist/devices/laundryDryer.js.map +1 -0
  50. package/dist/devices/laundryWasher.d.ts +242 -0
  51. package/dist/devices/laundryWasher.d.ts.map +1 -0
  52. package/dist/devices/laundryWasher.js +91 -7
  53. package/dist/devices/laundryWasher.js.map +1 -0
  54. package/dist/devices/roboticVacuumCleaner.d.ts +112 -0
  55. package/dist/devices/roboticVacuumCleaner.d.ts.map +1 -0
  56. package/dist/devices/roboticVacuumCleaner.js +93 -7
  57. package/dist/devices/roboticVacuumCleaner.js.map +1 -0
  58. package/dist/devices/solarPower.d.ts +40 -0
  59. package/dist/devices/solarPower.d.ts.map +1 -0
  60. package/dist/devices/solarPower.js +38 -0
  61. package/dist/devices/solarPower.js.map +1 -0
  62. package/dist/devices/waterHeater.d.ts +111 -0
  63. package/dist/devices/waterHeater.d.ts.map +1 -0
  64. package/dist/devices/waterHeater.js +82 -2
  65. package/dist/devices/waterHeater.js.map +1 -0
  66. package/dist/dgram/coap.d.ts +205 -0
  67. package/dist/dgram/coap.d.ts.map +1 -0
  68. package/dist/dgram/coap.js +126 -13
  69. package/dist/dgram/coap.js.map +1 -0
  70. package/dist/dgram/dgram.d.ts +140 -0
  71. package/dist/dgram/dgram.d.ts.map +1 -0
  72. package/dist/dgram/dgram.js +113 -2
  73. package/dist/dgram/dgram.js.map +1 -0
  74. package/dist/dgram/mb_coap.d.ts +24 -0
  75. package/dist/dgram/mb_coap.d.ts.map +1 -0
  76. package/dist/dgram/mb_coap.js +41 -3
  77. package/dist/dgram/mb_coap.js.map +1 -0
  78. package/dist/dgram/mb_mdns.d.ts +24 -0
  79. package/dist/dgram/mb_mdns.d.ts.map +1 -0
  80. package/dist/dgram/mb_mdns.js +51 -13
  81. package/dist/dgram/mb_mdns.js.map +1 -0
  82. package/dist/dgram/mdns.d.ts +288 -0
  83. package/dist/dgram/mdns.d.ts.map +1 -0
  84. package/dist/dgram/mdns.js +298 -137
  85. package/dist/dgram/mdns.js.map +1 -0
  86. package/dist/dgram/multicast.d.ts +65 -0
  87. package/dist/dgram/multicast.d.ts.map +1 -0
  88. package/dist/dgram/multicast.js +60 -1
  89. package/dist/dgram/multicast.js.map +1 -0
  90. package/dist/dgram/unicast.d.ts +56 -0
  91. package/dist/dgram/unicast.d.ts.map +1 -0
  92. package/dist/dgram/unicast.js +54 -0
  93. package/dist/dgram/unicast.js.map +1 -0
  94. package/dist/frontend.d.ts +313 -0
  95. package/dist/frontend.d.ts.map +1 -0
  96. package/dist/frontend.js +449 -23
  97. package/dist/frontend.js.map +1 -0
  98. package/dist/globalMatterbridge.d.ts +59 -0
  99. package/dist/globalMatterbridge.d.ts.map +1 -0
  100. package/dist/globalMatterbridge.js +47 -0
  101. package/dist/globalMatterbridge.js.map +1 -0
  102. package/dist/helpers.d.ts +48 -0
  103. package/dist/helpers.d.ts.map +1 -0
  104. package/dist/helpers.js +53 -0
  105. package/dist/helpers.js.map +1 -0
  106. package/dist/index.d.ts +33 -0
  107. package/dist/index.d.ts.map +1 -0
  108. package/dist/index.js +30 -1
  109. package/dist/index.js.map +1 -0
  110. package/dist/logger/export.d.ts +2 -0
  111. package/dist/logger/export.d.ts.map +1 -0
  112. package/dist/logger/export.js +1 -0
  113. package/dist/logger/export.js.map +1 -0
  114. package/dist/matter/behaviors.d.ts +2 -0
  115. package/dist/matter/behaviors.d.ts.map +1 -0
  116. package/dist/matter/behaviors.js +2 -0
  117. package/dist/matter/behaviors.js.map +1 -0
  118. package/dist/matter/clusters.d.ts +2 -0
  119. package/dist/matter/clusters.d.ts.map +1 -0
  120. package/dist/matter/clusters.js +2 -0
  121. package/dist/matter/clusters.js.map +1 -0
  122. package/dist/matter/devices.d.ts +2 -0
  123. package/dist/matter/devices.d.ts.map +1 -0
  124. package/dist/matter/devices.js +2 -0
  125. package/dist/matter/devices.js.map +1 -0
  126. package/dist/matter/endpoints.d.ts +2 -0
  127. package/dist/matter/endpoints.d.ts.map +1 -0
  128. package/dist/matter/endpoints.js +2 -0
  129. package/dist/matter/endpoints.js.map +1 -0
  130. package/dist/matter/export.d.ts +5 -0
  131. package/dist/matter/export.d.ts.map +1 -0
  132. package/dist/matter/export.js +3 -0
  133. package/dist/matter/export.js.map +1 -0
  134. package/dist/matter/types.d.ts +3 -0
  135. package/dist/matter/types.d.ts.map +1 -0
  136. package/dist/matter/types.js +3 -0
  137. package/dist/matter/types.js.map +1 -0
  138. package/dist/matterbridge.d.ts +463 -0
  139. package/dist/matterbridge.d.ts.map +1 -0
  140. package/dist/matterbridge.js +803 -50
  141. package/dist/matterbridge.js.map +1 -0
  142. package/dist/matterbridgeAccessoryPlatform.d.ts +42 -0
  143. package/dist/matterbridgeAccessoryPlatform.d.ts.map +1 -0
  144. package/dist/matterbridgeAccessoryPlatform.js +36 -0
  145. package/dist/matterbridgeAccessoryPlatform.js.map +1 -0
  146. package/dist/matterbridgeBehaviors.d.ts +1351 -0
  147. package/dist/matterbridgeBehaviors.d.ts.map +1 -0
  148. package/dist/matterbridgeBehaviors.js +65 -5
  149. package/dist/matterbridgeBehaviors.js.map +1 -0
  150. package/dist/matterbridgeDeviceTypes.d.ts +709 -0
  151. package/dist/matterbridgeDeviceTypes.d.ts.map +1 -0
  152. package/dist/matterbridgeDeviceTypes.js +579 -15
  153. package/dist/matterbridgeDeviceTypes.js.map +1 -0
  154. package/dist/matterbridgeDynamicPlatform.d.ts +42 -0
  155. package/dist/matterbridgeDynamicPlatform.d.ts.map +1 -0
  156. package/dist/matterbridgeDynamicPlatform.js +36 -0
  157. package/dist/matterbridgeDynamicPlatform.js.map +1 -0
  158. package/dist/matterbridgeEndpoint.d.ts +1348 -0
  159. package/dist/matterbridgeEndpoint.d.ts.map +1 -0
  160. package/dist/matterbridgeEndpoint.js +1214 -54
  161. package/dist/matterbridgeEndpoint.js.map +1 -0
  162. package/dist/matterbridgeEndpointHelpers.d.ts +406 -0
  163. package/dist/matterbridgeEndpointHelpers.d.ts.map +1 -0
  164. package/dist/matterbridgeEndpointHelpers.js +344 -12
  165. package/dist/matterbridgeEndpointHelpers.js.map +1 -0
  166. package/dist/matterbridgePlatform.d.ts +310 -0
  167. package/dist/matterbridgePlatform.d.ts.map +1 -0
  168. package/dist/matterbridgePlatform.js +233 -0
  169. package/dist/matterbridgePlatform.js.map +1 -0
  170. package/dist/matterbridgeTypes.d.ts +197 -0
  171. package/dist/matterbridgeTypes.d.ts.map +1 -0
  172. package/dist/matterbridgeTypes.js +25 -0
  173. package/dist/matterbridgeTypes.js.map +1 -0
  174. package/dist/pluginManager.d.ts +270 -0
  175. package/dist/pluginManager.d.ts.map +1 -0
  176. package/dist/pluginManager.js +249 -3
  177. package/dist/pluginManager.js.map +1 -0
  178. package/dist/shelly.d.ts +174 -0
  179. package/dist/shelly.d.ts.map +1 -0
  180. package/dist/shelly.js +168 -7
  181. package/dist/shelly.js.map +1 -0
  182. package/dist/storage/export.d.ts +2 -0
  183. package/dist/storage/export.d.ts.map +1 -0
  184. package/dist/storage/export.js +1 -0
  185. package/dist/storage/export.js.map +1 -0
  186. package/dist/update.d.ts +68 -0
  187. package/dist/update.d.ts.map +1 -0
  188. package/dist/update.js +63 -0
  189. package/dist/update.js.map +1 -0
  190. package/dist/utils/colorUtils.d.ts +117 -0
  191. package/dist/utils/colorUtils.d.ts.map +1 -0
  192. package/dist/utils/colorUtils.js +263 -2
  193. package/dist/utils/colorUtils.js.map +1 -0
  194. package/dist/utils/commandLine.d.ts +59 -0
  195. package/dist/utils/commandLine.d.ts.map +1 -0
  196. package/dist/utils/commandLine.js +54 -0
  197. package/dist/utils/commandLine.js.map +1 -0
  198. package/dist/utils/copyDirectory.d.ts +33 -0
  199. package/dist/utils/copyDirectory.d.ts.map +1 -0
  200. package/dist/utils/copyDirectory.js +38 -1
  201. package/dist/utils/copyDirectory.js.map +1 -0
  202. package/dist/utils/createDirectory.d.ts +34 -0
  203. package/dist/utils/createDirectory.d.ts.map +1 -0
  204. package/dist/utils/createDirectory.js +33 -0
  205. package/dist/utils/createDirectory.js.map +1 -0
  206. package/dist/utils/createZip.d.ts +39 -0
  207. package/dist/utils/createZip.d.ts.map +1 -0
  208. package/dist/utils/createZip.js +47 -2
  209. package/dist/utils/createZip.js.map +1 -0
  210. package/dist/utils/deepCopy.d.ts +32 -0
  211. package/dist/utils/deepCopy.d.ts.map +1 -0
  212. package/dist/utils/deepCopy.js +39 -0
  213. package/dist/utils/deepCopy.js.map +1 -0
  214. package/dist/utils/deepEqual.d.ts +54 -0
  215. package/dist/utils/deepEqual.d.ts.map +1 -0
  216. package/dist/utils/deepEqual.js +72 -1
  217. package/dist/utils/deepEqual.js.map +1 -0
  218. package/dist/utils/error.d.ts +44 -0
  219. package/dist/utils/error.d.ts.map +1 -0
  220. package/dist/utils/error.js +41 -0
  221. package/dist/utils/error.js.map +1 -0
  222. package/dist/utils/export.d.ts +12 -0
  223. package/dist/utils/export.d.ts.map +1 -0
  224. package/dist/utils/export.js +1 -0
  225. package/dist/utils/export.js.map +1 -0
  226. package/dist/utils/hex.d.ts +89 -0
  227. package/dist/utils/hex.d.ts.map +1 -0
  228. package/dist/utils/hex.js +123 -0
  229. package/dist/utils/hex.js.map +1 -0
  230. package/dist/utils/isvalid.d.ts +103 -0
  231. package/dist/utils/isvalid.d.ts.map +1 -0
  232. package/dist/utils/isvalid.js +101 -0
  233. package/dist/utils/isvalid.js.map +1 -0
  234. package/dist/utils/network.d.ts +74 -0
  235. package/dist/utils/network.d.ts.map +1 -0
  236. package/dist/utils/network.js +81 -5
  237. package/dist/utils/network.js.map +1 -0
  238. package/dist/utils/spawn.d.ts +33 -0
  239. package/dist/utils/spawn.d.ts.map +1 -0
  240. package/dist/utils/spawn.js +40 -0
  241. package/dist/utils/spawn.js.map +1 -0
  242. package/dist/utils/wait.d.ts +56 -0
  243. package/dist/utils/wait.d.ts.map +1 -0
  244. package/dist/utils/wait.js +62 -9
  245. package/dist/utils/wait.js.map +1 -0
  246. package/frontend/build/asset-manifest.json +3 -3
  247. package/frontend/build/index.html +1 -1
  248. package/frontend/build/static/js/{main.dd4772c9.js → main.6ab99f2a.js} +3 -3
  249. package/frontend/build/static/js/{main.dd4772c9.js.map → main.6ab99f2a.js.map} +1 -1
  250. package/npm-shrinkwrap.json +2 -2
  251. package/package.json +2 -1
  252. package/vitest/matterbridge.test.ts +0 -218
  253. /package/frontend/build/static/js/{main.dd4772c9.js.LICENSE.txt → main.6ab99f2a.js.LICENSE.txt} +0 -0
@@ -1,7 +1,34 @@
1
+ /**
2
+ * This file contains the helpers for the class MatterbridgeEndpoint.
3
+ *
4
+ * @file matterbridgeEndpointHelpers.ts
5
+ * @author Luca Liguori
6
+ * @created 2024-10-01
7
+ * @version 2.1.0
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
+ // Other modules
1
25
  import { createHash } from 'node:crypto';
26
+ // AnsiLogger module
2
27
  import { BLUE, CYAN, db, debugStringify, er, hk, or, YELLOW, zb } from 'node-ansi-logger';
28
+ // @matter
3
29
  import { Lifecycle } from '@matter/main';
4
30
  import { getClusterNameById } from '@matter/main/types';
31
+ // @matter clusters
5
32
  import { PowerSource } from '@matter/main/clusters/power-source';
6
33
  import { UserLabel } from '@matter/main/clusters/user-label';
7
34
  import { FixedLabel } from '@matter/main/clusters/fixed-label';
@@ -46,6 +73,7 @@ import { TotalVolatileOrganicCompoundsConcentrationMeasurement } from '@matter/m
46
73
  import { OperationalState } from '@matter/main/clusters/operational-state';
47
74
  import { DeviceEnergyManagement } from '@matter/main/clusters/device-energy-management';
48
75
  import { DeviceEnergyManagementMode } from '@matter/main/clusters/device-energy-management-mode';
76
+ // @matter behaviors
49
77
  import { PowerSourceServer } from '@matter/main/behaviors/power-source';
50
78
  import { UserLabelServer } from '@matter/main/behaviors/user-label';
51
79
  import { FixedLabelServer } from '@matter/main/behaviors/fixed-label';
@@ -76,56 +104,126 @@ import { Pm10ConcentrationMeasurementServer } from '@matter/main/behaviors/pm10-
76
104
  import { RadonConcentrationMeasurementServer } from '@matter/main/behaviors/radon-concentration-measurement';
77
105
  import { TotalVolatileOrganicCompoundsConcentrationMeasurementServer } from '@matter/main/behaviors/total-volatile-organic-compounds-concentration-measurement';
78
106
  import { DeviceEnergyManagementServer } from '@matter/node/behaviors/device-energy-management';
107
+ // Matterbridge
79
108
  import { deepCopy, deepEqual, isValidArray } from './utils/export.js';
80
109
  import { MatterbridgeIdentifyServer, MatterbridgeOnOffServer, MatterbridgeLevelControlServer, MatterbridgeColorControlServer, MatterbridgeLiftWindowCoveringServer, MatterbridgeThermostatServer, MatterbridgeFanControlServer, MatterbridgeDoorLockServer, MatterbridgeModeSelectServer, MatterbridgeValveConfigurationAndControlServer, MatterbridgeSmokeCoAlarmServer, MatterbridgeBooleanStateConfigurationServer, MatterbridgeOperationalStateServer, MatterbridgeDeviceEnergyManagementModeServer, } from './matterbridgeBehaviors.js';
110
+ /**
111
+ * Capitalizes the first letter of a string.
112
+ *
113
+ * @param {string} name - The string to capitalize.
114
+ * @returns {string} The string with the first letter capitalized.
115
+ */
81
116
  export function capitalizeFirstLetter(name) {
82
117
  if (!name)
83
118
  return name;
84
119
  return name.charAt(0).toUpperCase() + name.slice(1);
85
120
  }
121
+ /**
122
+ * Lowercases the first letter of a string.
123
+ *
124
+ * @param {string} name - The string to lowercase the first letter of.
125
+ * @returns {string} The string with the first letter lowercased.
126
+ */
86
127
  export function lowercaseFirstLetter(name) {
87
128
  if (!name)
88
129
  return name;
89
130
  return name.charAt(0).toLowerCase() + name.slice(1);
90
131
  }
132
+ /**
133
+ * Checks if the device name contains non-Latin characters.
134
+ *
135
+ * @param {string} deviceName - The name of the device to check.
136
+ * @returns {boolean} Returns true if the device name contains non-Latin characters, false otherwise.
137
+ */
91
138
  export function checkNotLatinCharacters(deviceName) {
92
139
  const nonLatinRegexList = [
93
- /[\u0400-\u04FF\u0500-\u052F]/,
94
- /[\u2E80-\u9FFF]/,
95
- /[\uAC00-\uD7AF]/,
96
- /[\u0600-\u06FF\u0750-\u077F]/,
97
- /[\u0590-\u05FF]/,
98
- /[\u0900-\u097F]/,
99
- /[\u0E00-\u0E7F]/,
100
- /[\u1200-\u137F]/,
140
+ /[\u0400-\u04FF\u0500-\u052F]/, // Cyrillic
141
+ /[\u2E80-\u9FFF]/, // CJK (Chinese, Japanese, Korean)
142
+ /[\uAC00-\uD7AF]/, // Korean Hangul
143
+ /[\u0600-\u06FF\u0750-\u077F]/, // Arabic, Persian
144
+ /[\u0590-\u05FF]/, // Hebrew
145
+ /[\u0900-\u097F]/, // Devanagari (Hindi, Sanskrit)
146
+ /[\u0E00-\u0E7F]/, // Thai
147
+ /[\u1200-\u137F]/, // Ethiopic (Amharic, Tigrinya)
101
148
  ];
102
149
  return nonLatinRegexList.some((regex) => regex.test(deviceName));
103
150
  }
151
+ /**
152
+ * Generates a unique ID based on the device name.
153
+ *
154
+ * @param {string} deviceName - The name of the device to generate a unique ID for.
155
+ * @returns {string} A unique ID generated from the device name using MD5 hashing.
156
+ */
104
157
  export function generateUniqueId(deviceName) {
105
- return createHash('md5').update(deviceName).digest('hex');
106
- }
158
+ return createHash('md5').update(deviceName).digest('hex'); // MD5 hash of the device name
159
+ }
160
+ /**
161
+ * Generates a unique ID based on four parameters.
162
+ *
163
+ * @param {string} param1 - The first parameter.
164
+ * @param {string} param2 - The second parameter.
165
+ * @param {string} param3 - The third parameter.
166
+ * @param {string} param4 - The fourth parameter.
167
+ * @returns {string} A unique ID generated from the concatenation of the parameters using MD5 hashing.
168
+ */
107
169
  export function createUniqueId(param1, param2, param3, param4) {
108
170
  const hash = createHash('md5');
109
171
  hash.update(param1 + param2 + param3 + param4);
110
172
  return hash.digest('hex');
111
173
  }
174
+ /**
175
+ * Retrieves the features for a specific behavior.
176
+ *
177
+ * @param {Endpoint} endpoint - The endpoint to retrieve the features from.
178
+ * @param {string} behavior - The behavior to retrieve the features for.
179
+ *
180
+ * @returns {Record<string, boolean | undefined>} The features for the specified behavior.
181
+ *
182
+ * @remarks Use with:
183
+ * ```typescript
184
+ * expect(featuresFor(device, 'powerSource').wired).toBe(true);
185
+ * ```
186
+ */
112
187
  export function featuresFor(endpoint, behavior) {
188
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
113
189
  return endpoint.behaviors.supported[lowercaseFirstLetter(behavior)]['cluster']['supportedFeatures'];
114
190
  }
191
+ /**
192
+ * Maps a list of ClusterId to Behavior.Type for server clusters.
193
+ *
194
+ * @param {ClusterId[]} clusterServerList - The list of ClusterId to map.
195
+ * @returns {Behavior.Type[]} An array of Behavior.Type corresponding to the ClusterId in the server list.
196
+ */
115
197
  export function getBehaviourTypesFromClusterServerIds(clusterServerList) {
198
+ // Map Server ClusterId to Behavior.Type
116
199
  const behaviorTypes = [];
117
200
  clusterServerList.forEach((clusterId) => {
118
201
  behaviorTypes.push(getBehaviourTypeFromClusterServerId(clusterId));
119
202
  });
120
203
  return behaviorTypes;
121
204
  }
205
+ /**
206
+ * Maps a list of ClusterId to Behavior.Type for client clusters.
207
+ *
208
+ * @param {ClusterId[]} clusterClientList - The list of ClusterId to map.
209
+ * @returns {Behavior.Type[]} An array of Behavior.Type corresponding to the ClusterId in the client list.
210
+ */
122
211
  export function getBehaviourTypesFromClusterClientIds(clusterClientList) {
212
+ // Map Client ClusterId to Behavior.Type
123
213
  const behaviorTypes = [];
124
214
  clusterClientList.forEach((_clusterId) => {
215
+ // behaviorTypes.push(getBehaviourTypeFromClusterClientId(clusterId));
125
216
  });
126
217
  return behaviorTypes;
127
218
  }
219
+ /**
220
+ * Maps a ClusterId to a Behavior.Type for server clusters.
221
+ *
222
+ * @param {ClusterId} clusterId - The ClusterId to map.
223
+ * @returns {Behavior.Type} The corresponding Behavior.Type for the given ClusterId.
224
+ */
128
225
  export function getBehaviourTypeFromClusterServerId(clusterId) {
226
+ // Map ClusterId to Server Behavior.Type
129
227
  if (clusterId === PowerSource.Cluster.id)
130
228
  return PowerSourceServer.with(PowerSource.Feature.Wired);
131
229
  if (clusterId === UserLabel.Cluster.id)
@@ -216,8 +314,22 @@ export function getBehaviourTypeFromClusterServerId(clusterId) {
216
314
  return MatterbridgeDeviceEnergyManagementModeServer;
217
315
  return MatterbridgeIdentifyServer;
218
316
  }
317
+ /**
318
+ * Maps a ClusterId to a Behavior.Type for client clusters.
319
+ *
320
+ * @param {ClusterId} _clusterId - The ClusterId to map.
321
+ */
219
322
  export function getBehaviourTypeFromClusterClientId(_clusterId) {
220
- }
323
+ // Map ClusterId to Client Behavior.Type
324
+ // return IdentifyClient;
325
+ }
326
+ /**
327
+ * Retrieves the Behavior.Type for a given cluster from the endpoint's supported behaviors.
328
+ *
329
+ * @param {MatterbridgeEndpoint} endpoint - The endpoint to retrieve the behavior from.
330
+ * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to retrieve the behavior for.
331
+ * @returns {Behavior.Type | undefined} The Behavior.Type for the given cluster, or undefined if not found.
332
+ */
221
333
  export function getBehavior(endpoint, cluster) {
222
334
  let behavior;
223
335
  if (typeof cluster === 'string') {
@@ -234,6 +346,18 @@ export function getBehavior(endpoint, cluster) {
234
346
  }
235
347
  return behavior;
236
348
  }
349
+ /**
350
+ * Invokes a command on the specified behavior of the endpoint. Used ONLY in Jest tests.
351
+ *
352
+ * @param {MatterbridgeEndpoint} endpoint - The endpoint to invoke the command on.
353
+ * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to invoke the command on.
354
+ * @param {keyof MatterbridgeEndpointCommands} command - The command to invoke.
355
+ * @param {Record<string, boolean | number | bigint | string | object | null>} [params] - The parameters to pass to the command.
356
+ *
357
+ * @returns {Promise<boolean>} A promise that resolves to true if the command was invoked successfully, false otherwise.
358
+ *
359
+ * @deprecated Used ONLY in Jest tests.
360
+ */
237
361
  export async function invokeBehaviorCommand(endpoint, cluster, command, params) {
238
362
  const behaviorId = getBehavior(endpoint, cluster)?.id;
239
363
  if (!behaviorId) {
@@ -241,6 +365,7 @@ export async function invokeBehaviorCommand(endpoint, cluster, command, params)
241
365
  return false;
242
366
  }
243
367
  await endpoint.act((agent) => {
368
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
244
369
  const behavior = agent[behaviorId];
245
370
  if (!(command in behavior) || typeof behavior[command] !== 'function') {
246
371
  endpoint.log?.error(`invokeBehaviorCommand error: command ${hk}${command}${er} not found on agent for endpoint ${or}${endpoint.maybeId}${er}:${or}${endpoint.maybeNumber}${er}`);
@@ -250,6 +375,18 @@ export async function invokeBehaviorCommand(endpoint, cluster, command, params)
250
375
  });
251
376
  return true;
252
377
  }
378
+ /**
379
+ * Invokes the subscription handler on the specified cluster and attribute of the endpoint. Used ONLY in Jest tests.
380
+ *
381
+ * @param {MatterbridgeEndpoint} endpoint - The endpoint to invoke the subscription handler on.
382
+ * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to invoke the subscription handler on.
383
+ * @param {string} attribute - The attribute to invoke the subscription handler on.
384
+ * @param {unknown} newValue - The new value of the attribute.
385
+ * @param {unknown} oldValue - The old value of the attribute.
386
+ *
387
+ * @returns {Promise<boolean>} A promise that resolves to true if the subscription handler was invoked successfully, false otherwise.
388
+ * @deprecated Used ONLY in Jest tests.
389
+ */
253
390
  export async function invokeSubscribeHandler(endpoint, cluster, attribute, newValue, oldValue) {
254
391
  const event = attribute + '$Changed';
255
392
  const clusterName = getBehavior(endpoint, cluster)?.id;
@@ -266,9 +403,17 @@ export async function invokeSubscribeHandler(endpoint, cluster, attribute, newVa
266
403
  endpoint.log.error(`invokeSubscribeHandler ${hk}${event}${er} error: cluster ${clusterName} not found on endpoint ${or}${endpoint.id}${er}:${or}${endpoint.number}${er}`);
267
404
  return false;
268
405
  }
406
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
407
+ // @ts-ignore
269
408
  await endpoint.act((agent) => agent[clusterName].events[event].emit(newValue, oldValue, { ...agent.context, offline: false }));
270
409
  return true;
271
410
  }
411
+ /**
412
+ * Adds required cluster servers to the specified endpoint based on the device types.
413
+ *
414
+ * @param {MatterbridgeEndpoint} endpoint - The endpoint to add the required cluster servers to.
415
+ * @returns {void}
416
+ */
272
417
  export function addRequiredClusterServers(endpoint) {
273
418
  const requiredServerList = [];
274
419
  endpoint.log.debug(`addRequiredClusterServers for ${CYAN}${endpoint.maybeId}${db}`);
@@ -283,6 +428,12 @@ export function addRequiredClusterServers(endpoint) {
283
428
  });
284
429
  addClusterServers(endpoint, requiredServerList);
285
430
  }
431
+ /**
432
+ * Adds optional cluster servers to the specified endpoint based on the device types.
433
+ *
434
+ * @param {MatterbridgeEndpoint} endpoint - The endpoint to add the optional cluster servers to.
435
+ * @returns {void}
436
+ */
286
437
  export function addOptionalClusterServers(endpoint) {
287
438
  const optionalServerList = [];
288
439
  endpoint.log.debug(`addOptionalClusterServers for ${CYAN}${endpoint.maybeId}${db}`);
@@ -297,6 +448,12 @@ export function addOptionalClusterServers(endpoint) {
297
448
  });
298
449
  addClusterServers(endpoint, optionalServerList);
299
450
  }
451
+ /**
452
+ * Adds cluster servers to the specified endpoint based on the provided server list.
453
+ *
454
+ * @param {MatterbridgeEndpoint} endpoint - The endpoint to add the cluster servers to.
455
+ * @param {ClusterId[]} serverList - The list of cluster IDs to add.
456
+ */
300
457
  export function addClusterServers(endpoint, serverList) {
301
458
  if (serverList.includes(PowerSource.Cluster.id))
302
459
  endpoint.createDefaultPowerSourceWiredClusterServer();
@@ -377,6 +534,13 @@ export function addClusterServers(endpoint, serverList) {
377
534
  if (serverList.includes(DeviceEnergyManagementMode.Cluster.id))
378
535
  endpoint.createDefaultDeviceEnergyManagementModeClusterServer();
379
536
  }
537
+ /**
538
+ * Adds a fixed label to the FixedLabel cluster. The FixedLabel cluster is created if it does not exist.
539
+ *
540
+ * @param {MatterbridgeEndpoint} endpoint - The endpoint to add the cluster servers to.
541
+ * @param {string} label - The label to add. Max 16 characters.
542
+ * @param {string} value - The value of the label. Max 16 characters.
543
+ */
380
544
  export async function addFixedLabel(endpoint, label, value) {
381
545
  if (!endpoint.hasClusterServer(FixedLabel.Cluster.id)) {
382
546
  endpoint.log.debug(`addFixedLabel: add cluster ${hk}FixedLabel${db}:${hk}fixedLabel${db} with label ${CYAN}${label}${db} value ${CYAN}${value}${db}`);
@@ -393,6 +557,13 @@ export async function addFixedLabel(endpoint, label, value) {
393
557
  await endpoint.setAttribute(FixedLabel.Cluster.id, 'labelList', labelList, endpoint.log);
394
558
  }
395
559
  }
560
+ /**
561
+ * Adds a user label to the UserLabel cluster. The UserLabel cluster is created if it does not exist.
562
+ *
563
+ * @param {MatterbridgeEndpoint} endpoint - The endpoint to add the cluster servers to.
564
+ * @param {string} label - The label to add. Max 16 characters.
565
+ * @param {string} value - The value of the label. Max 16 characters.
566
+ */
396
567
  export async function addUserLabel(endpoint, label, value) {
397
568
  if (!endpoint.hasClusterServer(UserLabel.Cluster.id)) {
398
569
  endpoint.log.debug(`addUserLabel: add cluster ${hk}UserLabel${db}:${hk}userLabel${db} with label ${CYAN}${label}${db} value ${CYAN}${value}${db}`);
@@ -409,16 +580,48 @@ export async function addUserLabel(endpoint, label, value) {
409
580
  await endpoint.setAttribute(UserLabel.Cluster.id, 'labelList', labelList, endpoint.log);
410
581
  }
411
582
  }
583
+ /**
584
+ * Returns the options for a given behavior type.
585
+ *
586
+ * @param {T} type - The behavior type.
587
+ * @param {Behavior.Options<T>} options - The options for the behavior type.
588
+ * @returns {Behavior.Options<T>} The options for the behavior type.
589
+ */
412
590
  export function optionsFor(type, options) {
413
591
  return options;
414
592
  }
593
+ /**
594
+ * Retrieves the cluster name by its ID.
595
+ *
596
+ * @param {Endpoint} endpoint - The endpoint to retrieve the cluster name from.
597
+ * @param {ClusterId} cluster - The ID of the cluster.
598
+ * @returns {string} The name of the cluster.
599
+ */
415
600
  export function getClusterId(endpoint, cluster) {
416
601
  return endpoint.behaviors.supported[lowercaseFirstLetter(cluster)]?.schema?.id;
417
602
  }
603
+ /**
604
+ * Retrieves the ID of an attribute from a cluster behavior.
605
+ *
606
+ * @param {Endpoint} endpoint - The endpoint to retrieve the attribute ID from.
607
+ * @param {string} cluster - The name of the cluster.
608
+ * @param {string} attribute - The name of the attribute.
609
+ * @returns {number | undefined} The ID of the attribute, or undefined if not found.
610
+ */
418
611
  export function getAttributeId(endpoint, cluster, attribute) {
419
612
  const clusterBehavior = endpoint.behaviors.supported[lowercaseFirstLetter(cluster)];
420
613
  return clusterBehavior?.cluster?.attributes[lowercaseFirstLetter(attribute)]?.id;
421
614
  }
615
+ /**
616
+ * Retrieves the value of the provided attribute from the given cluster.
617
+ *
618
+ * @param {MatterbridgeEndpoint} endpoint - The endpoint to retrieve the attribute from.
619
+ * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to retrieve the attribute from.
620
+ * @param {string} attribute - The name of the attribute to retrieve.
621
+ * @param {AnsiLogger} [log] - (Optional) The logger to use for logging the retrieve. Errors are logged to the endpoint logger.
622
+ * @returns {any} The value of the attribute, or undefined if the attribute is not found.
623
+ */
624
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
422
625
  export function getAttribute(endpoint, cluster, attribute, log) {
423
626
  const clusterName = getBehavior(endpoint, cluster)?.id;
424
627
  if (!clusterName) {
@@ -441,6 +644,16 @@ export function getAttribute(endpoint, cluster, attribute, log) {
441
644
  log?.info(`${db}Get endpoint ${or}${endpoint.id}${db}:${or}${endpoint.number}${db} attribute ${hk}${capitalizeFirstLetter(clusterName)}${db}.${hk}${attribute}${db} value ${YELLOW}${value !== null && typeof value === 'object' ? debugStringify(value) : value}${db}`);
442
645
  return value;
443
646
  }
647
+ /**
648
+ * Sets the value of an attribute on a cluster server.
649
+ *
650
+ * @param {MatterbridgeEndpoint} endpoint - The endpoint to set the attribute on.
651
+ * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to set the attribute on.
652
+ * @param {string} attribute - The name of the attribute.
653
+ * @param {boolean | number | bigint | string | object | null} value - The value to set for the attribute.
654
+ * @param {AnsiLogger} [log] - (Optional) The logger to use for logging the set. Errors are logged to the endpoint logger.
655
+ * @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the attribute was successfully set.
656
+ */
444
657
  export async function setAttribute(endpoint, cluster, attribute, value, log) {
445
658
  const clusterName = getBehavior(endpoint, cluster)?.id;
446
659
  if (!clusterName) {
@@ -466,6 +679,16 @@ export async function setAttribute(endpoint, cluster, attribute, value, log) {
466
679
  `to ${YELLOW}${value !== null && typeof value === 'object' ? debugStringify(value) : value}${db}`);
467
680
  return true;
468
681
  }
682
+ /**
683
+ * Sets the value of an attribute on a cluster server.
684
+ *
685
+ * @param {MatterbridgeEndpoint} endpoint - The endpoint to update the attribute on.
686
+ * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to update the attribute on.
687
+ * @param {string} attribute - The name of the attribute.
688
+ * @param {boolean | number | bigint | string | object | null} value - The value to set for the attribute.
689
+ * @param {AnsiLogger} [log] - (Optional) The logger to use for logging the update. Errors are logged to the endpoint logger.
690
+ * @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the attribute was successfully set.
691
+ */
469
692
  export async function updateAttribute(endpoint, cluster, attribute, value, log) {
470
693
  const clusterName = getBehavior(endpoint, cluster)?.id;
471
694
  if (!clusterName) {
@@ -496,7 +719,24 @@ export async function updateAttribute(endpoint, cluster, attribute, value, log)
496
719
  `to ${YELLOW}${value !== null && typeof value === 'object' ? debugStringify(value) : value}${db}`);
497
720
  return true;
498
721
  }
499
- export async function subscribeAttribute(endpoint, cluster, attribute, listener, log) {
722
+ /**
723
+ * Subscribes to the provided attribute on a cluster.
724
+ *
725
+ * @param {MatterbridgeEndpoint} endpoint - The endpoint to subscribe the attribute to.
726
+ * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to subscribe the attribute to.
727
+ * @param {string} attribute - The name of the attribute to subscribe to.
728
+ * @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.
729
+ * @param {AnsiLogger} [log] - Optional logger for logging errors and information.
730
+ * @returns {boolean} - A boolean indicating whether the subscription was successful.
731
+ *
732
+ * @remarks The listener function (cannot be async) will receive three parameters:
733
+ * - `newValue`: The new value of the attribute.
734
+ * - `oldValue`: The old value of the attribute.
735
+ * - `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.
736
+ */
737
+ export async function subscribeAttribute(endpoint, cluster, attribute,
738
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
739
+ listener, log) {
500
740
  const clusterName = getBehavior(endpoint, cluster)?.id;
501
741
  if (!clusterName) {
502
742
  endpoint.log.error(`subscribeAttribute ${hk}${attribute}${er} error: cluster not found on endpoint ${or}${endpoint.maybeId}${er}:${or}${endpoint.maybeNumber}${er}`);
@@ -506,6 +746,7 @@ export async function subscribeAttribute(endpoint, cluster, attribute, listener,
506
746
  endpoint.log.debug(`subscribeAttribute ${hk}${clusterName}.${attribute}${db}: Endpoint ${or}${endpoint.maybeId}${db}:${or}${endpoint.maybeNumber}${db} is in the ${BLUE}${endpoint.construction.status}${db} state`);
507
747
  await endpoint.construction.ready;
508
748
  }
749
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
509
750
  const events = endpoint.events;
510
751
  attribute = lowercaseFirstLetter(attribute) + '$Changed';
511
752
  if (!(clusterName in events) || !(attribute in events[clusterName])) {
@@ -516,6 +757,17 @@ export async function subscribeAttribute(endpoint, cluster, attribute, listener,
516
757
  log?.info(`${db}Subscribed endpoint ${or}${endpoint.id}${db}:${or}${endpoint.number}${db} attribute ${hk}${capitalizeFirstLetter(clusterName)}${db}.${hk}${attribute}${db}`);
517
758
  return true;
518
759
  }
760
+ /**
761
+ * Triggers an event on the specified cluster.
762
+ *
763
+ * @param {MatterbridgeEndpoint} endpoint - The endpoint to trigger the event on.
764
+ * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The ID of the cluster.
765
+ * @param {string} event - The name of the event to trigger.
766
+ * @param {Record<string, boolean | number | bigint | string | object | undefined | null>} payload - The payload to pass to the event.
767
+ * @param {AnsiLogger} [log] - Optional logger for logging information.
768
+ *
769
+ * @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the event was successfully triggered.
770
+ */
519
771
  export async function triggerEvent(endpoint, cluster, event, payload, log) {
520
772
  const clusterName = getBehavior(endpoint, cluster)?.id;
521
773
  if (!clusterName) {
@@ -526,15 +778,32 @@ export async function triggerEvent(endpoint, cluster, event, payload, log) {
526
778
  endpoint.log.error(`triggerEvent ${hk}${clusterName}.${event}${er} error: Endpoint ${or}${endpoint.maybeId}${er}:${or}${endpoint.maybeNumber}${er} is in the ${BLUE}${endpoint.construction.status}${er} state`);
527
779
  return false;
528
780
  }
781
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
529
782
  const events = endpoint.events;
530
783
  if (!(clusterName in events) || !(event in events[clusterName])) {
531
784
  endpoint.log.error(`triggerEvent ${hk}${event}${er} error: cluster ${clusterName} not found on endpoint ${or}${endpoint.id}${er}:${or}${endpoint.number}${er}`);
532
785
  return false;
533
786
  }
787
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
788
+ // @ts-ignore
534
789
  await endpoint.act((agent) => agent[clusterName].events[event].emit(payload, agent.context));
535
790
  log?.info(`${db}Trigger event ${hk}${capitalizeFirstLetter(clusterName)}${db}.${hk}${event}${db} with ${debugStringify(payload)}${db} on endpoint ${or}${endpoint.id}${db}:${or}${endpoint.number}${db} `);
536
791
  return true;
537
792
  }
793
+ /**
794
+ * Get the default OperationalState Cluster Server.
795
+ *
796
+ * @param {OperationalState.OperationalStateEnum} operationalState - The initial operational state id.
797
+ *
798
+ * @returns {Behavior.Options<MatterbridgeOperationalStateServer>} - The default options for the OperationalState cluster server.
799
+ *
800
+ * @remarks
801
+ * This method adds a cluster server with a default operational state configuration:
802
+ * - { operationalStateId: OperationalState.OperationalStateEnum.Stopped, operationalStateLabel: 'Stopped' },
803
+ * - { operationalStateId: OperationalState.OperationalStateEnum.Running, operationalStateLabel: 'Running' },
804
+ * - { operationalStateId: OperationalState.OperationalStateEnum.Paused, operationalStateLabel: 'Paused' },
805
+ * - { operationalStateId: OperationalState.OperationalStateEnum.Error, operationalStateLabel: 'Error' },
806
+ */
538
807
  export function getDefaultOperationalStateClusterServer(operationalState = OperationalState.OperationalStateEnum.Stopped) {
539
808
  return optionsFor(MatterbridgeOperationalStateServer, {
540
809
  phaseList: [],
@@ -550,6 +819,14 @@ export function getDefaultOperationalStateClusterServer(operationalState = Opera
550
819
  operationalError: { errorStateId: OperationalState.ErrorState.NoError, errorStateLabel: 'No error', errorStateDetails: 'Fully operational' },
551
820
  });
552
821
  }
822
+ /**
823
+ * Get the default TemperatureMeasurement cluster server options.
824
+ *
825
+ * @param {number | null} measuredValue - The measured value of the temperature x 100.
826
+ * @param {number | null} minMeasuredValue - The minimum measured value of the temperature x 100.
827
+ * @param {number | null} maxMeasuredValue - The maximum measured value of the temperature x 100.
828
+ * @returns {Behavior.Options<MatterbridgeTemperatureMeasurementServer>} - The default options for the TemperatureMeasurement cluster server.
829
+ */
553
830
  export function getDefaultTemperatureMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
554
831
  return optionsFor(TemperatureMeasurementServer, {
555
832
  measuredValue,
@@ -558,6 +835,14 @@ export function getDefaultTemperatureMeasurementClusterServer(measuredValue = nu
558
835
  tolerance: 0,
559
836
  });
560
837
  }
838
+ /**
839
+ * Get the default RelativeHumidityMeasurement cluster server options.
840
+ *
841
+ * @param {number | null} measuredValue - The measured value of the relative humidity x 100.
842
+ * @param {number | null} minMeasuredValue - The minimum measured value of the relative humidity x 100.
843
+ * @param {number | null} maxMeasuredValue - The maximum measured value of the relative humidity x 100.
844
+ * @returns {Behavior.Options<MatterbridgeRelativeHumidityMeasurementServer>} - The default options for the RelativeHumidityMeasurement cluster server.
845
+ */
561
846
  export function getDefaultRelativeHumidityMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
562
847
  return optionsFor(RelativeHumidityMeasurementServer, {
563
848
  measuredValue,
@@ -566,6 +851,14 @@ export function getDefaultRelativeHumidityMeasurementClusterServer(measuredValue
566
851
  tolerance: 0,
567
852
  });
568
853
  }
854
+ /**
855
+ * Get the default PressureMeasurement cluster server options.
856
+ *
857
+ * @param {number | null} measuredValue - The measured value for the pressure in kPa x 10.
858
+ * @param {number | null} minMeasuredValue - The minimum measured value for the pressure in kPa x 10.
859
+ * @param {number | null} maxMeasuredValue - The maximum measured value for the pressure in kPa x 10.
860
+ * @returns {Behavior.Options<MatterbridgePressureMeasurementServer>} - The default options for the PressureMeasurement cluster server.
861
+ */
569
862
  export function getDefaultPressureMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
570
863
  return optionsFor(PressureMeasurementServer, {
571
864
  measuredValue,
@@ -574,6 +867,22 @@ export function getDefaultPressureMeasurementClusterServer(measuredValue = null,
574
867
  tolerance: 0,
575
868
  });
576
869
  }
870
+ /**
871
+ * Get the default IlluminanceMeasurement cluster server options.
872
+ *
873
+ * @param {number | null} measuredValue - The measured value of illuminance.
874
+ * @param {number | null} minMeasuredValue - The minimum measured value of illuminance.
875
+ * @param {number | null} maxMeasuredValue - The maximum measured value of illuminance.
876
+ *
877
+ * @returns {Behavior.Options<MatterbridgeIlluminanceMeasurementServer>} - The default options for the IlluminanceMeasurement cluster server.
878
+ *
879
+ * @remarks The default value for the illuminance measurement is null.
880
+ * This attribute SHALL indicate the illuminance in Lux (symbol lx) as follows:
881
+ * • MeasuredValue = 10,000 x log10(illuminance) + 1,
882
+ * where 1 lx <= illuminance <= 3.576 Mlx, corresponding to a MeasuredValue in the range 1 to 0xFFFE.
883
+ * • 0 indicates a value of illuminance that is too low to be measured
884
+ * • null indicates that the illuminance measurement is invalid.
885
+ */
577
886
  export function getDefaultIlluminanceMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
578
887
  return optionsFor(IlluminanceMeasurementServer, {
579
888
  measuredValue,
@@ -582,6 +891,14 @@ export function getDefaultIlluminanceMeasurementClusterServer(measuredValue = nu
582
891
  tolerance: 0,
583
892
  });
584
893
  }
894
+ /**
895
+ * Get the default FlowMeasurement cluster server options.
896
+ *
897
+ * @param {number | null} measuredValue - The measured value of the flow in 10 x m3/h.
898
+ * @param {number | null} minMeasuredValue - The minimum measured value of the flow in 10 x m3/h.
899
+ * @param {number | null} maxMeasuredValue - The maximum measured value of the flow in 10 x m3/h.
900
+ * @returns {Behavior.Options<MatterbridgeFlowMeasurementServer>} - The default options for the FlowMeasurement cluster server.
901
+ */
585
902
  export function getDefaultFlowMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
586
903
  return optionsFor(FlowMeasurementServer, {
587
904
  measuredValue,
@@ -590,6 +907,20 @@ export function getDefaultFlowMeasurementClusterServer(measuredValue = null, min
590
907
  tolerance: 0,
591
908
  });
592
909
  }
910
+ /**
911
+ * Get the default OccupancySensing cluster server options.
912
+ *
913
+ * @param {boolean} occupied - A boolean indicating whether the occupancy is occupied or not. Default is false.
914
+ * @param {number} holdTime - The hold time in seconds. Default is 30.
915
+ * @param {number} holdTimeMin - The minimum hold time in seconds. Default is 1.
916
+ * @param {number} holdTimeMax - The maximum hold time in seconds. Default is 300.
917
+ * @returns {Behavior.Options<MatterbridgeOccupancySensingServer>} - The default options for the OccupancySensing cluster server.
918
+ *
919
+ * @remarks The default value for the occupancy sensor type is PIR.
920
+ * Servers SHALL set these attributes for backward compatibility with clients implementing a cluster revision <= 4 as
921
+ * described in OccupancySensorType and OccupancySensorTypeBitmap Attributes.
922
+ * This replaces the 9 legacy attributes PIROccupiedToUnoccupiedDelay through PhysicalContactUnoccupiedToOccupiedThreshold.
923
+ */
593
924
  export function getDefaultOccupancySensingClusterServer(occupied = false, holdTime = 30, holdTimeMin = 1, holdTimeMax = 300) {
594
925
  return optionsFor(OccupancySensingServer.with(OccupancySensing.Feature.PassiveInfrared), {
595
926
  occupancy: { occupied },
@@ -601,3 +932,4 @@ export function getDefaultOccupancySensingClusterServer(occupied = false, holdTi
601
932
  holdTimeLimits: { holdTimeMin, holdTimeMax, holdTimeDefault: holdTime },
602
933
  });
603
934
  }
935
+ //# sourceMappingURL=matterbridgeEndpointHelpers.js.map