matterbridge 3.1.7-dev-20250723-8e073ce → 3.1.7

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 (248) hide show
  1. package/CHANGELOG.md +8 -17
  2. package/README-SERVICE.md +1 -0
  3. package/dist/cli.d.ts +26 -0
  4. package/dist/cli.d.ts.map +1 -0
  5. package/dist/cli.js +91 -2
  6. package/dist/cli.js.map +1 -0
  7. package/dist/cliEmitter.d.ts +34 -0
  8. package/dist/cliEmitter.d.ts.map +1 -0
  9. package/dist/cliEmitter.js +30 -0
  10. package/dist/cliEmitter.js.map +1 -0
  11. package/dist/clusters/export.d.ts +2 -0
  12. package/dist/clusters/export.d.ts.map +1 -0
  13. package/dist/clusters/export.js +2 -0
  14. package/dist/clusters/export.js.map +1 -0
  15. package/dist/defaultConfigSchema.d.ts +28 -0
  16. package/dist/defaultConfigSchema.d.ts.map +1 -0
  17. package/dist/defaultConfigSchema.js +24 -0
  18. package/dist/defaultConfigSchema.js.map +1 -0
  19. package/dist/deviceManager.d.ts +112 -0
  20. package/dist/deviceManager.d.ts.map +1 -0
  21. package/dist/deviceManager.js +94 -1
  22. package/dist/deviceManager.js.map +1 -0
  23. package/dist/devices/batteryStorage.d.ts +48 -0
  24. package/dist/devices/batteryStorage.d.ts.map +1 -0
  25. package/dist/devices/batteryStorage.js +48 -1
  26. package/dist/devices/batteryStorage.js.map +1 -0
  27. package/dist/devices/dishwasher.d.ts +91 -0
  28. package/dist/devices/dishwasher.d.ts.map +1 -0
  29. package/dist/devices/dishwasher.js +78 -3
  30. package/dist/devices/dishwasher.js.map +1 -0
  31. package/dist/devices/evse.d.ts +75 -0
  32. package/dist/devices/evse.d.ts.map +1 -0
  33. package/dist/devices/evse.js +74 -10
  34. package/dist/devices/evse.js.map +1 -0
  35. package/dist/devices/export.d.ts +11 -0
  36. package/dist/devices/export.d.ts.map +1 -0
  37. package/dist/devices/export.js +2 -0
  38. package/dist/devices/export.js.map +1 -0
  39. package/dist/devices/extractorHood.d.ts +46 -0
  40. package/dist/devices/extractorHood.d.ts.map +1 -0
  41. package/dist/devices/extractorHood.js +42 -0
  42. package/dist/devices/extractorHood.js.map +1 -0
  43. package/dist/devices/heatPump.d.ts +47 -0
  44. package/dist/devices/heatPump.d.ts.map +1 -0
  45. package/dist/devices/heatPump.js +50 -2
  46. package/dist/devices/heatPump.js.map +1 -0
  47. package/dist/devices/laundryDryer.d.ts +87 -0
  48. package/dist/devices/laundryDryer.d.ts.map +1 -0
  49. package/dist/devices/laundryDryer.js +83 -6
  50. package/dist/devices/laundryDryer.js.map +1 -0
  51. package/dist/devices/laundryWasher.d.ts +242 -0
  52. package/dist/devices/laundryWasher.d.ts.map +1 -0
  53. package/dist/devices/laundryWasher.js +91 -7
  54. package/dist/devices/laundryWasher.js.map +1 -0
  55. package/dist/devices/roboticVacuumCleaner.d.ts +112 -0
  56. package/dist/devices/roboticVacuumCleaner.d.ts.map +1 -0
  57. package/dist/devices/roboticVacuumCleaner.js +93 -7
  58. package/dist/devices/roboticVacuumCleaner.js.map +1 -0
  59. package/dist/devices/solarPower.d.ts +40 -0
  60. package/dist/devices/solarPower.d.ts.map +1 -0
  61. package/dist/devices/solarPower.js +38 -0
  62. package/dist/devices/solarPower.js.map +1 -0
  63. package/dist/devices/waterHeater.d.ts +111 -0
  64. package/dist/devices/waterHeater.d.ts.map +1 -0
  65. package/dist/devices/waterHeater.js +82 -2
  66. package/dist/devices/waterHeater.js.map +1 -0
  67. package/dist/dgram/coap.d.ts +205 -0
  68. package/dist/dgram/coap.d.ts.map +1 -0
  69. package/dist/dgram/coap.js +126 -13
  70. package/dist/dgram/coap.js.map +1 -0
  71. package/dist/dgram/dgram.d.ts +140 -0
  72. package/dist/dgram/dgram.d.ts.map +1 -0
  73. package/dist/dgram/dgram.js +113 -2
  74. package/dist/dgram/dgram.js.map +1 -0
  75. package/dist/dgram/mb_coap.d.ts +24 -0
  76. package/dist/dgram/mb_coap.d.ts.map +1 -0
  77. package/dist/dgram/mb_coap.js +41 -3
  78. package/dist/dgram/mb_coap.js.map +1 -0
  79. package/dist/dgram/mb_mdns.d.ts +24 -0
  80. package/dist/dgram/mb_mdns.d.ts.map +1 -0
  81. package/dist/dgram/mb_mdns.js +51 -13
  82. package/dist/dgram/mb_mdns.js.map +1 -0
  83. package/dist/dgram/mdns.d.ts +288 -0
  84. package/dist/dgram/mdns.d.ts.map +1 -0
  85. package/dist/dgram/mdns.js +300 -135
  86. package/dist/dgram/mdns.js.map +1 -0
  87. package/dist/dgram/multicast.d.ts +65 -0
  88. package/dist/dgram/multicast.d.ts.map +1 -0
  89. package/dist/dgram/multicast.js +60 -1
  90. package/dist/dgram/multicast.js.map +1 -0
  91. package/dist/dgram/unicast.d.ts +56 -0
  92. package/dist/dgram/unicast.d.ts.map +1 -0
  93. package/dist/dgram/unicast.js +54 -0
  94. package/dist/dgram/unicast.js.map +1 -0
  95. package/dist/frontend.d.ts +304 -0
  96. package/dist/frontend.d.ts.map +1 -0
  97. package/dist/frontend.js +435 -21
  98. package/dist/frontend.js.map +1 -0
  99. package/dist/globalMatterbridge.d.ts +59 -0
  100. package/dist/globalMatterbridge.d.ts.map +1 -0
  101. package/dist/globalMatterbridge.js +47 -0
  102. package/dist/globalMatterbridge.js.map +1 -0
  103. package/dist/helpers.d.ts +48 -0
  104. package/dist/helpers.d.ts.map +1 -0
  105. package/dist/helpers.js +53 -0
  106. package/dist/helpers.js.map +1 -0
  107. package/dist/index.d.ts +33 -0
  108. package/dist/index.d.ts.map +1 -0
  109. package/dist/index.js +30 -1
  110. package/dist/index.js.map +1 -0
  111. package/dist/logger/export.d.ts +2 -0
  112. package/dist/logger/export.d.ts.map +1 -0
  113. package/dist/logger/export.js +1 -0
  114. package/dist/logger/export.js.map +1 -0
  115. package/dist/matter/behaviors.d.ts +2 -0
  116. package/dist/matter/behaviors.d.ts.map +1 -0
  117. package/dist/matter/behaviors.js +2 -0
  118. package/dist/matter/behaviors.js.map +1 -0
  119. package/dist/matter/clusters.d.ts +2 -0
  120. package/dist/matter/clusters.d.ts.map +1 -0
  121. package/dist/matter/clusters.js +2 -0
  122. package/dist/matter/clusters.js.map +1 -0
  123. package/dist/matter/devices.d.ts +2 -0
  124. package/dist/matter/devices.d.ts.map +1 -0
  125. package/dist/matter/devices.js +2 -0
  126. package/dist/matter/devices.js.map +1 -0
  127. package/dist/matter/endpoints.d.ts +2 -0
  128. package/dist/matter/endpoints.d.ts.map +1 -0
  129. package/dist/matter/endpoints.js +2 -0
  130. package/dist/matter/endpoints.js.map +1 -0
  131. package/dist/matter/export.d.ts +5 -0
  132. package/dist/matter/export.d.ts.map +1 -0
  133. package/dist/matter/export.js +3 -0
  134. package/dist/matter/export.js.map +1 -0
  135. package/dist/matter/types.d.ts +3 -0
  136. package/dist/matter/types.d.ts.map +1 -0
  137. package/dist/matter/types.js +3 -0
  138. package/dist/matter/types.js.map +1 -0
  139. package/dist/matterbridge.d.ts +463 -0
  140. package/dist/matterbridge.d.ts.map +1 -0
  141. package/dist/matterbridge.js +843 -58
  142. package/dist/matterbridge.js.map +1 -0
  143. package/dist/matterbridgeAccessoryPlatform.d.ts +42 -0
  144. package/dist/matterbridgeAccessoryPlatform.d.ts.map +1 -0
  145. package/dist/matterbridgeAccessoryPlatform.js +36 -0
  146. package/dist/matterbridgeAccessoryPlatform.js.map +1 -0
  147. package/dist/matterbridgeBehaviors.d.ts +1351 -0
  148. package/dist/matterbridgeBehaviors.d.ts.map +1 -0
  149. package/dist/matterbridgeBehaviors.js +65 -5
  150. package/dist/matterbridgeBehaviors.js.map +1 -0
  151. package/dist/matterbridgeDeviceTypes.d.ts +709 -0
  152. package/dist/matterbridgeDeviceTypes.d.ts.map +1 -0
  153. package/dist/matterbridgeDeviceTypes.js +579 -15
  154. package/dist/matterbridgeDeviceTypes.js.map +1 -0
  155. package/dist/matterbridgeDynamicPlatform.d.ts +42 -0
  156. package/dist/matterbridgeDynamicPlatform.d.ts.map +1 -0
  157. package/dist/matterbridgeDynamicPlatform.js +36 -0
  158. package/dist/matterbridgeDynamicPlatform.js.map +1 -0
  159. package/dist/matterbridgeEndpoint.d.ts +1348 -0
  160. package/dist/matterbridgeEndpoint.d.ts.map +1 -0
  161. package/dist/matterbridgeEndpoint.js +1220 -51
  162. package/dist/matterbridgeEndpoint.js.map +1 -0
  163. package/dist/matterbridgeEndpointHelpers.d.ts +406 -0
  164. package/dist/matterbridgeEndpointHelpers.d.ts.map +1 -0
  165. package/dist/matterbridgeEndpointHelpers.js +353 -18
  166. package/dist/matterbridgeEndpointHelpers.js.map +1 -0
  167. package/dist/matterbridgePlatform.d.ts +310 -0
  168. package/dist/matterbridgePlatform.d.ts.map +1 -0
  169. package/dist/matterbridgePlatform.js +233 -0
  170. package/dist/matterbridgePlatform.js.map +1 -0
  171. package/dist/matterbridgeTypes.d.ts +195 -0
  172. package/dist/matterbridgeTypes.d.ts.map +1 -0
  173. package/dist/matterbridgeTypes.js +25 -0
  174. package/dist/matterbridgeTypes.js.map +1 -0
  175. package/dist/pluginManager.d.ts +270 -0
  176. package/dist/pluginManager.d.ts.map +1 -0
  177. package/dist/pluginManager.js +249 -3
  178. package/dist/pluginManager.js.map +1 -0
  179. package/dist/shelly.d.ts +174 -0
  180. package/dist/shelly.d.ts.map +1 -0
  181. package/dist/shelly.js +168 -7
  182. package/dist/shelly.js.map +1 -0
  183. package/dist/storage/export.d.ts +2 -0
  184. package/dist/storage/export.d.ts.map +1 -0
  185. package/dist/storage/export.js +1 -0
  186. package/dist/storage/export.js.map +1 -0
  187. package/dist/update.d.ts +59 -0
  188. package/dist/update.d.ts.map +1 -0
  189. package/dist/update.js +54 -0
  190. package/dist/update.js.map +1 -0
  191. package/dist/utils/colorUtils.d.ts +117 -0
  192. package/dist/utils/colorUtils.d.ts.map +1 -0
  193. package/dist/utils/colorUtils.js +263 -2
  194. package/dist/utils/colorUtils.js.map +1 -0
  195. package/dist/utils/commandLine.d.ts +59 -0
  196. package/dist/utils/commandLine.d.ts.map +1 -0
  197. package/dist/utils/commandLine.js +54 -0
  198. package/dist/utils/commandLine.js.map +1 -0
  199. package/dist/utils/copyDirectory.d.ts +33 -0
  200. package/dist/utils/copyDirectory.d.ts.map +1 -0
  201. package/dist/utils/copyDirectory.js +38 -1
  202. package/dist/utils/copyDirectory.js.map +1 -0
  203. package/dist/utils/createDirectory.d.ts +34 -0
  204. package/dist/utils/createDirectory.d.ts.map +1 -0
  205. package/dist/utils/createDirectory.js +33 -0
  206. package/dist/utils/createDirectory.js.map +1 -0
  207. package/dist/utils/createZip.d.ts +39 -0
  208. package/dist/utils/createZip.d.ts.map +1 -0
  209. package/dist/utils/createZip.js +47 -2
  210. package/dist/utils/createZip.js.map +1 -0
  211. package/dist/utils/deepCopy.d.ts +32 -0
  212. package/dist/utils/deepCopy.d.ts.map +1 -0
  213. package/dist/utils/deepCopy.js +39 -0
  214. package/dist/utils/deepCopy.js.map +1 -0
  215. package/dist/utils/deepEqual.d.ts +54 -0
  216. package/dist/utils/deepEqual.d.ts.map +1 -0
  217. package/dist/utils/deepEqual.js +72 -1
  218. package/dist/utils/deepEqual.js.map +1 -0
  219. package/dist/utils/error.d.ts +44 -0
  220. package/dist/utils/error.d.ts.map +1 -0
  221. package/dist/utils/error.js +41 -0
  222. package/dist/utils/error.js.map +1 -0
  223. package/dist/utils/export.d.ts +12 -0
  224. package/dist/utils/export.d.ts.map +1 -0
  225. package/dist/utils/export.js +1 -0
  226. package/dist/utils/export.js.map +1 -0
  227. package/dist/utils/hex.d.ts +49 -0
  228. package/dist/utils/hex.d.ts.map +1 -0
  229. package/dist/utils/hex.js +58 -0
  230. package/dist/utils/hex.js.map +1 -0
  231. package/dist/utils/isvalid.d.ts +103 -0
  232. package/dist/utils/isvalid.d.ts.map +1 -0
  233. package/dist/utils/isvalid.js +101 -0
  234. package/dist/utils/isvalid.js.map +1 -0
  235. package/dist/utils/network.d.ts +74 -0
  236. package/dist/utils/network.d.ts.map +1 -0
  237. package/dist/utils/network.js +81 -5
  238. package/dist/utils/network.js.map +1 -0
  239. package/dist/utils/spawn.d.ts +33 -0
  240. package/dist/utils/spawn.d.ts.map +1 -0
  241. package/dist/utils/spawn.js +40 -0
  242. package/dist/utils/spawn.js.map +1 -0
  243. package/dist/utils/wait.d.ts +56 -0
  244. package/dist/utils/wait.d.ts.map +1 -0
  245. package/dist/utils/wait.js +62 -9
  246. package/dist/utils/wait.js.map +1 -0
  247. package/npm-shrinkwrap.json +2 -2
  248. package/package.json +2 -1
@@ -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,53 +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
+ */
187
+ export function featuresFor(endpoint, behavior) {
188
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
189
+ return endpoint.behaviors.supported[lowercaseFirstLetter(behavior)]['cluster']['supportedFeatures'];
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
+ */
112
197
  export function getBehaviourTypesFromClusterServerIds(clusterServerList) {
198
+ // Map Server ClusterId to Behavior.Type
113
199
  const behaviorTypes = [];
114
200
  clusterServerList.forEach((clusterId) => {
115
201
  behaviorTypes.push(getBehaviourTypeFromClusterServerId(clusterId));
116
202
  });
117
203
  return behaviorTypes;
118
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
+ */
119
211
  export function getBehaviourTypesFromClusterClientIds(clusterClientList) {
212
+ // Map Client ClusterId to Behavior.Type
120
213
  const behaviorTypes = [];
121
214
  clusterClientList.forEach((_clusterId) => {
215
+ // behaviorTypes.push(getBehaviourTypeFromClusterClientId(clusterId));
122
216
  });
123
217
  return behaviorTypes;
124
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
+ */
125
225
  export function getBehaviourTypeFromClusterServerId(clusterId) {
226
+ // Map ClusterId to Server Behavior.Type
126
227
  if (clusterId === PowerSource.Cluster.id)
127
228
  return PowerSourceServer.with(PowerSource.Feature.Wired);
128
229
  if (clusterId === UserLabel.Cluster.id)
@@ -213,8 +314,22 @@ export function getBehaviourTypeFromClusterServerId(clusterId) {
213
314
  return MatterbridgeDeviceEnergyManagementModeServer;
214
315
  return MatterbridgeIdentifyServer;
215
316
  }
317
+ /**
318
+ * Maps a ClusterId to a Behavior.Type for client clusters.
319
+ *
320
+ * @param {ClusterId} _clusterId - The ClusterId to map.
321
+ */
216
322
  export function getBehaviourTypeFromClusterClientId(_clusterId) {
217
- }
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
+ */
218
333
  export function getBehavior(endpoint, cluster) {
219
334
  let behavior;
220
335
  if (typeof cluster === 'string') {
@@ -231,6 +346,18 @@ export function getBehavior(endpoint, cluster) {
231
346
  }
232
347
  return behavior;
233
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
+ */
234
361
  export async function invokeBehaviorCommand(endpoint, cluster, command, params) {
235
362
  const behaviorId = getBehavior(endpoint, cluster)?.id;
236
363
  if (!behaviorId) {
@@ -238,6 +365,7 @@ export async function invokeBehaviorCommand(endpoint, cluster, command, params)
238
365
  return false;
239
366
  }
240
367
  await endpoint.act((agent) => {
368
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
241
369
  const behavior = agent[behaviorId];
242
370
  if (!(command in behavior) || typeof behavior[command] !== 'function') {
243
371
  endpoint.log?.error(`invokeBehaviorCommand error: command ${hk}${command}${er} not found on agent for endpoint ${or}${endpoint.maybeId}${er}:${or}${endpoint.maybeNumber}${er}`);
@@ -247,6 +375,18 @@ export async function invokeBehaviorCommand(endpoint, cluster, command, params)
247
375
  });
248
376
  return true;
249
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
+ */
250
390
  export async function invokeSubscribeHandler(endpoint, cluster, attribute, newValue, oldValue) {
251
391
  const event = attribute + '$Changed';
252
392
  const clusterName = getBehavior(endpoint, cluster)?.id;
@@ -263,9 +403,17 @@ export async function invokeSubscribeHandler(endpoint, cluster, attribute, newVa
263
403
  endpoint.log.error(`invokeSubscribeHandler ${hk}${event}${er} error: cluster ${clusterName} not found on endpoint ${or}${endpoint.id}${er}:${or}${endpoint.number}${er}`);
264
404
  return false;
265
405
  }
406
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
407
+ // @ts-ignore
266
408
  await endpoint.act((agent) => agent[clusterName].events[event].emit(newValue, oldValue, { ...agent.context, offline: false }));
267
409
  return true;
268
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
+ */
269
417
  export function addRequiredClusterServers(endpoint) {
270
418
  const requiredServerList = [];
271
419
  endpoint.log.debug(`addRequiredClusterServers for ${CYAN}${endpoint.maybeId}${db}`);
@@ -280,6 +428,12 @@ export function addRequiredClusterServers(endpoint) {
280
428
  });
281
429
  addClusterServers(endpoint, requiredServerList);
282
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
+ */
283
437
  export function addOptionalClusterServers(endpoint) {
284
438
  const optionalServerList = [];
285
439
  endpoint.log.debug(`addOptionalClusterServers for ${CYAN}${endpoint.maybeId}${db}`);
@@ -294,6 +448,12 @@ export function addOptionalClusterServers(endpoint) {
294
448
  });
295
449
  addClusterServers(endpoint, optionalServerList);
296
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
+ */
297
457
  export function addClusterServers(endpoint, serverList) {
298
458
  if (serverList.includes(PowerSource.Cluster.id))
299
459
  endpoint.createDefaultPowerSourceWiredClusterServer();
@@ -374,48 +534,94 @@ export function addClusterServers(endpoint, serverList) {
374
534
  if (serverList.includes(DeviceEnergyManagementMode.Cluster.id))
375
535
  endpoint.createDefaultDeviceEnergyManagementModeClusterServer();
376
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
+ */
377
544
  export async function addFixedLabel(endpoint, label, value) {
378
545
  if (!endpoint.hasClusterServer(FixedLabel.Cluster.id)) {
379
546
  endpoint.log.debug(`addFixedLabel: add cluster ${hk}FixedLabel${db}:${hk}fixedLabel${db} with label ${CYAN}${label}${db} value ${CYAN}${value}${db}`);
380
547
  endpoint.behaviors.require(FixedLabelServer, {
381
- labelList: [{ label, value }],
548
+ labelList: [{ label: label.substring(0, 16), value: value.substring(0, 16) }],
382
549
  });
383
550
  return;
384
551
  }
385
552
  endpoint.log.debug(`addFixedLabel: add label ${CYAN}${label}${db} value ${CYAN}${value}${db}`);
386
553
  let labelList = endpoint.getAttribute(FixedLabel.Cluster.id, 'labelList', endpoint.log);
387
554
  if (isValidArray(labelList)) {
388
- labelList = labelList.filter((entry) => entry.label !== label);
389
- labelList.push({ label, value });
555
+ labelList = labelList.filter((entry) => entry.label !== label.substring(0, 16));
556
+ labelList.push({ label: label.substring(0, 16), value: value.substring(0, 16) });
390
557
  await endpoint.setAttribute(FixedLabel.Cluster.id, 'labelList', labelList, endpoint.log);
391
558
  }
392
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
+ */
393
567
  export async function addUserLabel(endpoint, label, value) {
394
568
  if (!endpoint.hasClusterServer(UserLabel.Cluster.id)) {
395
569
  endpoint.log.debug(`addUserLabel: add cluster ${hk}UserLabel${db}:${hk}userLabel${db} with label ${CYAN}${label}${db} value ${CYAN}${value}${db}`);
396
570
  endpoint.behaviors.require(UserLabelServer, {
397
- labelList: [{ label, value }],
571
+ labelList: [{ label: label.substring(0, 16), value: value.substring(0, 16) }],
398
572
  });
399
573
  return;
400
574
  }
401
575
  endpoint.log.debug(`addUserLabel: add label ${CYAN}${label}${db} value ${CYAN}${value}${db}`);
402
576
  let labelList = endpoint.getAttribute(UserLabel.Cluster.id, 'labelList', endpoint.log);
403
577
  if (isValidArray(labelList)) {
404
- labelList = labelList.filter((entry) => entry.label !== label);
405
- labelList.push({ label, value });
578
+ labelList = labelList.filter((entry) => entry.label !== label.substring(0, 16));
579
+ labelList.push({ label: label.substring(0, 16), value: value.substring(0, 16) });
406
580
  await endpoint.setAttribute(UserLabel.Cluster.id, 'labelList', labelList, endpoint.log);
407
581
  }
408
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
+ */
409
590
  export function optionsFor(type, options) {
410
591
  return options;
411
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
+ */
412
600
  export function getClusterId(endpoint, cluster) {
413
601
  return endpoint.behaviors.supported[lowercaseFirstLetter(cluster)]?.schema?.id;
414
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
+ */
415
611
  export function getAttributeId(endpoint, cluster, attribute) {
416
612
  const clusterBehavior = endpoint.behaviors.supported[lowercaseFirstLetter(cluster)];
417
613
  return clusterBehavior?.cluster?.attributes[lowercaseFirstLetter(attribute)]?.id;
418
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
419
625
  export function getAttribute(endpoint, cluster, attribute, log) {
420
626
  const clusterName = getBehavior(endpoint, cluster)?.id;
421
627
  if (!clusterName) {
@@ -438,6 +644,16 @@ export function getAttribute(endpoint, cluster, attribute, log) {
438
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}`);
439
645
  return value;
440
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
+ */
441
657
  export async function setAttribute(endpoint, cluster, attribute, value, log) {
442
658
  const clusterName = getBehavior(endpoint, cluster)?.id;
443
659
  if (!clusterName) {
@@ -463,6 +679,16 @@ export async function setAttribute(endpoint, cluster, attribute, value, log) {
463
679
  `to ${YELLOW}${value !== null && typeof value === 'object' ? debugStringify(value) : value}${db}`);
464
680
  return true;
465
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
+ */
466
692
  export async function updateAttribute(endpoint, cluster, attribute, value, log) {
467
693
  const clusterName = getBehavior(endpoint, cluster)?.id;
468
694
  if (!clusterName) {
@@ -493,7 +719,24 @@ export async function updateAttribute(endpoint, cluster, attribute, value, log)
493
719
  `to ${YELLOW}${value !== null && typeof value === 'object' ? debugStringify(value) : value}${db}`);
494
720
  return true;
495
721
  }
496
- 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) {
497
740
  const clusterName = getBehavior(endpoint, cluster)?.id;
498
741
  if (!clusterName) {
499
742
  endpoint.log.error(`subscribeAttribute ${hk}${attribute}${er} error: cluster not found on endpoint ${or}${endpoint.maybeId}${er}:${or}${endpoint.maybeNumber}${er}`);
@@ -503,6 +746,7 @@ export async function subscribeAttribute(endpoint, cluster, attribute, listener,
503
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`);
504
747
  await endpoint.construction.ready;
505
748
  }
749
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
506
750
  const events = endpoint.events;
507
751
  attribute = lowercaseFirstLetter(attribute) + '$Changed';
508
752
  if (!(clusterName in events) || !(attribute in events[clusterName])) {
@@ -513,6 +757,17 @@ export async function subscribeAttribute(endpoint, cluster, attribute, listener,
513
757
  log?.info(`${db}Subscribed endpoint ${or}${endpoint.id}${db}:${or}${endpoint.number}${db} attribute ${hk}${capitalizeFirstLetter(clusterName)}${db}.${hk}${attribute}${db}`);
514
758
  return true;
515
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
+ */
516
771
  export async function triggerEvent(endpoint, cluster, event, payload, log) {
517
772
  const clusterName = getBehavior(endpoint, cluster)?.id;
518
773
  if (!clusterName) {
@@ -523,15 +778,32 @@ export async function triggerEvent(endpoint, cluster, event, payload, log) {
523
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`);
524
779
  return false;
525
780
  }
781
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
526
782
  const events = endpoint.events;
527
783
  if (!(clusterName in events) || !(event in events[clusterName])) {
528
784
  endpoint.log.error(`triggerEvent ${hk}${event}${er} error: cluster ${clusterName} not found on endpoint ${or}${endpoint.id}${er}:${or}${endpoint.number}${er}`);
529
785
  return false;
530
786
  }
787
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
788
+ // @ts-ignore
531
789
  await endpoint.act((agent) => agent[clusterName].events[event].emit(payload, agent.context));
532
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} `);
533
791
  return true;
534
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
+ */
535
807
  export function getDefaultOperationalStateClusterServer(operationalState = OperationalState.OperationalStateEnum.Stopped) {
536
808
  return optionsFor(MatterbridgeOperationalStateServer, {
537
809
  phaseList: [],
@@ -547,6 +819,14 @@ export function getDefaultOperationalStateClusterServer(operationalState = Opera
547
819
  operationalError: { errorStateId: OperationalState.ErrorState.NoError, errorStateLabel: 'No error', errorStateDetails: 'Fully operational' },
548
820
  });
549
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
+ */
550
830
  export function getDefaultTemperatureMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
551
831
  return optionsFor(TemperatureMeasurementServer, {
552
832
  measuredValue,
@@ -555,6 +835,14 @@ export function getDefaultTemperatureMeasurementClusterServer(measuredValue = nu
555
835
  tolerance: 0,
556
836
  });
557
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
+ */
558
846
  export function getDefaultRelativeHumidityMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
559
847
  return optionsFor(RelativeHumidityMeasurementServer, {
560
848
  measuredValue,
@@ -563,6 +851,14 @@ export function getDefaultRelativeHumidityMeasurementClusterServer(measuredValue
563
851
  tolerance: 0,
564
852
  });
565
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
+ */
566
862
  export function getDefaultPressureMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
567
863
  return optionsFor(PressureMeasurementServer, {
568
864
  measuredValue,
@@ -571,6 +867,22 @@ export function getDefaultPressureMeasurementClusterServer(measuredValue = null,
571
867
  tolerance: 0,
572
868
  });
573
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
+ */
574
886
  export function getDefaultIlluminanceMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
575
887
  return optionsFor(IlluminanceMeasurementServer, {
576
888
  measuredValue,
@@ -579,6 +891,14 @@ export function getDefaultIlluminanceMeasurementClusterServer(measuredValue = nu
579
891
  tolerance: 0,
580
892
  });
581
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
+ */
582
902
  export function getDefaultFlowMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
583
903
  return optionsFor(FlowMeasurementServer, {
584
904
  measuredValue,
@@ -587,6 +907,20 @@ export function getDefaultFlowMeasurementClusterServer(measuredValue = null, min
587
907
  tolerance: 0,
588
908
  });
589
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
+ */
590
924
  export function getDefaultOccupancySensingClusterServer(occupied = false, holdTime = 30, holdTimeMin = 1, holdTimeMax = 300) {
591
925
  return optionsFor(OccupancySensingServer.with(OccupancySensing.Feature.PassiveInfrared), {
592
926
  occupancy: { occupied },
@@ -598,3 +932,4 @@ export function getDefaultOccupancySensingClusterServer(occupied = false, holdTi
598
932
  holdTimeLimits: { holdTimeMin, holdTimeMax, holdTimeDefault: holdTime },
599
933
  });
600
934
  }
935
+ //# sourceMappingURL=matterbridgeEndpointHelpers.js.map