@matterbridge/core 3.5.3 → 3.5.4-dev-20260211-c4f9359

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 (294) hide show
  1. package/README.md +1 -1
  2. package/dist/cli.d.ts +0 -24
  3. package/dist/cli.js +1 -97
  4. package/dist/cliEmitter.d.ts +0 -36
  5. package/dist/cliEmitter.js +0 -37
  6. package/dist/cliHistory.d.ts +0 -42
  7. package/dist/cliHistory.js +0 -38
  8. package/dist/clusters/export.d.ts +0 -1
  9. package/dist/clusters/export.js +0 -2
  10. package/dist/deviceManager.d.ts +0 -108
  11. package/dist/deviceManager.js +1 -114
  12. package/dist/devices/airConditioner.d.ts +0 -75
  13. package/dist/devices/airConditioner.js +0 -57
  14. package/dist/devices/basicVideoPlayer.d.ts +0 -58
  15. package/dist/devices/basicVideoPlayer.js +1 -56
  16. package/dist/devices/batteryStorage.d.ts +0 -43
  17. package/dist/devices/batteryStorage.js +1 -48
  18. package/dist/devices/castingVideoPlayer.d.ts +0 -63
  19. package/dist/devices/castingVideoPlayer.js +2 -65
  20. package/dist/devices/cooktop.d.ts +0 -55
  21. package/dist/devices/cooktop.js +0 -56
  22. package/dist/devices/dishwasher.d.ts +0 -55
  23. package/dist/devices/dishwasher.js +0 -57
  24. package/dist/devices/evse.d.ts +0 -57
  25. package/dist/devices/evse.js +10 -74
  26. package/dist/devices/export.d.ts +0 -1
  27. package/dist/devices/export.js +0 -5
  28. package/dist/devices/extractorHood.d.ts +0 -41
  29. package/dist/devices/extractorHood.js +0 -43
  30. package/dist/devices/heatPump.d.ts +0 -43
  31. package/dist/devices/heatPump.js +2 -50
  32. package/dist/devices/laundryDryer.d.ts +0 -58
  33. package/dist/devices/laundryDryer.js +3 -62
  34. package/dist/devices/laundryWasher.d.ts +0 -64
  35. package/dist/devices/laundryWasher.js +4 -70
  36. package/dist/devices/microwaveOven.d.ts +1 -77
  37. package/dist/devices/microwaveOven.js +5 -88
  38. package/dist/devices/oven.d.ts +0 -82
  39. package/dist/devices/oven.js +0 -85
  40. package/dist/devices/refrigerator.d.ts +0 -100
  41. package/dist/devices/refrigerator.js +0 -102
  42. package/dist/devices/roboticVacuumCleaner.d.ts +0 -83
  43. package/dist/devices/roboticVacuumCleaner.js +9 -100
  44. package/dist/devices/solarPower.d.ts +0 -36
  45. package/dist/devices/solarPower.js +0 -38
  46. package/dist/devices/speaker.d.ts +0 -79
  47. package/dist/devices/speaker.js +0 -84
  48. package/dist/devices/temperatureControl.d.ts +0 -21
  49. package/dist/devices/temperatureControl.js +3 -24
  50. package/dist/devices/waterHeater.d.ts +0 -74
  51. package/dist/devices/waterHeater.js +2 -82
  52. package/dist/dgram/export.d.ts +0 -1
  53. package/dist/dgram/export.js +0 -1
  54. package/dist/export.d.ts +0 -23
  55. package/dist/export.js +0 -28
  56. package/dist/frontend.d.ts +0 -187
  57. package/dist/frontend.js +38 -539
  58. package/dist/helpers.d.ts +0 -43
  59. package/dist/helpers.js +0 -86
  60. package/dist/jestutils/export.d.ts +0 -1
  61. package/dist/jestutils/export.js +0 -1
  62. package/dist/jestutils/jestHelpers.d.ts +0 -259
  63. package/dist/jestutils/jestHelpers.js +14 -395
  64. package/dist/matter/behaviors.d.ts +0 -1
  65. package/dist/matter/behaviors.js +0 -2
  66. package/dist/matter/clusters.d.ts +0 -1
  67. package/dist/matter/clusters.js +0 -2
  68. package/dist/matter/devices.d.ts +0 -1
  69. package/dist/matter/devices.js +0 -2
  70. package/dist/matter/endpoints.d.ts +0 -1
  71. package/dist/matter/endpoints.js +0 -2
  72. package/dist/matter/export.d.ts +0 -1
  73. package/dist/matter/export.js +0 -2
  74. package/dist/matter/types.d.ts +0 -1
  75. package/dist/matter/types.js +0 -2
  76. package/dist/matterNode.d.ts +0 -258
  77. package/dist/matterNode.js +8 -356
  78. package/dist/matterbridge.d.ts +0 -389
  79. package/dist/matterbridge.js +48 -878
  80. package/dist/matterbridgeAccessoryPlatform.d.ts +0 -42
  81. package/dist/matterbridgeAccessoryPlatform.js +0 -50
  82. package/dist/matterbridgeBehaviors.d.ts +0 -24
  83. package/dist/matterbridgeBehaviors.js +5 -65
  84. package/dist/matterbridgeDeviceTypes.d.ts +0 -649
  85. package/dist/matterbridgeDeviceTypes.js +6 -673
  86. package/dist/matterbridgeDynamicPlatform.d.ts +0 -42
  87. package/dist/matterbridgeDynamicPlatform.js +0 -50
  88. package/dist/matterbridgeEndpoint.d.ts +0 -1369
  89. package/dist/matterbridgeEndpoint.js +56 -1514
  90. package/dist/matterbridgeEndpointHelpers.d.ts +0 -425
  91. package/dist/matterbridgeEndpointHelpers.js +20 -483
  92. package/dist/matterbridgeEndpointTypes.d.ts +0 -70
  93. package/dist/matterbridgeEndpointTypes.js +0 -25
  94. package/dist/matterbridgePlatform.d.ts +0 -434
  95. package/dist/matterbridgePlatform.js +1 -473
  96. package/dist/mb_coap.d.ts +0 -23
  97. package/dist/mb_coap.js +3 -41
  98. package/dist/mb_health.d.ts +0 -67
  99. package/dist/mb_health.js +0 -70
  100. package/dist/mb_mdns.d.ts +0 -23
  101. package/dist/mb_mdns.js +36 -94
  102. package/dist/pluginManager.d.ts +0 -307
  103. package/dist/pluginManager.js +6 -346
  104. package/dist/spawn.d.ts +0 -32
  105. package/dist/spawn.js +1 -71
  106. package/dist/utils/export.d.ts +0 -1
  107. package/dist/utils/export.js +0 -1
  108. package/package.json +27 -6
  109. package/dist/cli.d.ts.map +0 -1
  110. package/dist/cli.js.map +0 -1
  111. package/dist/cliEmitter.d.ts.map +0 -1
  112. package/dist/cliEmitter.js.map +0 -1
  113. package/dist/cliHistory.d.ts.map +0 -1
  114. package/dist/cliHistory.js.map +0 -1
  115. package/dist/clusters/export.d.ts.map +0 -1
  116. package/dist/clusters/export.js.map +0 -1
  117. package/dist/crypto/attestationDecoder.d.ts +0 -180
  118. package/dist/crypto/attestationDecoder.d.ts.map +0 -1
  119. package/dist/crypto/attestationDecoder.js +0 -176
  120. package/dist/crypto/attestationDecoder.js.map +0 -1
  121. package/dist/crypto/declarationDecoder.d.ts +0 -72
  122. package/dist/crypto/declarationDecoder.d.ts.map +0 -1
  123. package/dist/crypto/declarationDecoder.js +0 -241
  124. package/dist/crypto/declarationDecoder.js.map +0 -1
  125. package/dist/crypto/extract/342/200/220cert/342/200/220extensions.d.ts +0 -9
  126. package/dist/crypto/extract/342/200/220cert/342/200/220extensions.d.ts.map +0 -1
  127. package/dist/crypto/extract/342/200/220cert/342/200/220extensions.js +0 -120
  128. package/dist/crypto/extract/342/200/220cert/342/200/220extensions.js.map +0 -1
  129. package/dist/crypto/read-extensions.d.ts +0 -2
  130. package/dist/crypto/read-extensions.d.ts.map +0 -1
  131. package/dist/crypto/read-extensions.js +0 -81
  132. package/dist/crypto/read-extensions.js.map +0 -1
  133. package/dist/crypto/testData.d.ts +0 -31
  134. package/dist/crypto/testData.d.ts.map +0 -1
  135. package/dist/crypto/testData.js +0 -131
  136. package/dist/crypto/testData.js.map +0 -1
  137. package/dist/crypto/walk-der.d.ts +0 -2
  138. package/dist/crypto/walk-der.d.ts.map +0 -1
  139. package/dist/crypto/walk-der.js +0 -165
  140. package/dist/crypto/walk-der.js.map +0 -1
  141. package/dist/deviceManager.d.ts.map +0 -1
  142. package/dist/deviceManager.js.map +0 -1
  143. package/dist/devices/airConditioner.d.ts.map +0 -1
  144. package/dist/devices/airConditioner.js.map +0 -1
  145. package/dist/devices/basicVideoPlayer.d.ts.map +0 -1
  146. package/dist/devices/basicVideoPlayer.js.map +0 -1
  147. package/dist/devices/batteryStorage.d.ts.map +0 -1
  148. package/dist/devices/batteryStorage.js.map +0 -1
  149. package/dist/devices/castingVideoPlayer.d.ts.map +0 -1
  150. package/dist/devices/castingVideoPlayer.js.map +0 -1
  151. package/dist/devices/cooktop.d.ts.map +0 -1
  152. package/dist/devices/cooktop.js.map +0 -1
  153. package/dist/devices/dishwasher.d.ts.map +0 -1
  154. package/dist/devices/dishwasher.js.map +0 -1
  155. package/dist/devices/evse.d.ts.map +0 -1
  156. package/dist/devices/evse.js.map +0 -1
  157. package/dist/devices/export.d.ts.map +0 -1
  158. package/dist/devices/export.js.map +0 -1
  159. package/dist/devices/extractorHood.d.ts.map +0 -1
  160. package/dist/devices/extractorHood.js.map +0 -1
  161. package/dist/devices/heatPump.d.ts.map +0 -1
  162. package/dist/devices/heatPump.js.map +0 -1
  163. package/dist/devices/laundryDryer.d.ts.map +0 -1
  164. package/dist/devices/laundryDryer.js.map +0 -1
  165. package/dist/devices/laundryWasher.d.ts.map +0 -1
  166. package/dist/devices/laundryWasher.js.map +0 -1
  167. package/dist/devices/microwaveOven.d.ts.map +0 -1
  168. package/dist/devices/microwaveOven.js.map +0 -1
  169. package/dist/devices/oven.d.ts.map +0 -1
  170. package/dist/devices/oven.js.map +0 -1
  171. package/dist/devices/refrigerator.d.ts.map +0 -1
  172. package/dist/devices/refrigerator.js.map +0 -1
  173. package/dist/devices/roboticVacuumCleaner.d.ts.map +0 -1
  174. package/dist/devices/roboticVacuumCleaner.js.map +0 -1
  175. package/dist/devices/solarPower.d.ts.map +0 -1
  176. package/dist/devices/solarPower.js.map +0 -1
  177. package/dist/devices/speaker.d.ts.map +0 -1
  178. package/dist/devices/speaker.js.map +0 -1
  179. package/dist/devices/temperatureControl.d.ts.map +0 -1
  180. package/dist/devices/temperatureControl.js.map +0 -1
  181. package/dist/devices/waterHeater.d.ts.map +0 -1
  182. package/dist/devices/waterHeater.js.map +0 -1
  183. package/dist/dgram/export.d.ts.map +0 -1
  184. package/dist/dgram/export.js.map +0 -1
  185. package/dist/export.d.ts.map +0 -1
  186. package/dist/export.js.map +0 -1
  187. package/dist/frontend.d.ts.map +0 -1
  188. package/dist/frontend.js.map +0 -1
  189. package/dist/helpers.d.ts.map +0 -1
  190. package/dist/helpers.js.map +0 -1
  191. package/dist/jestutils/export.d.ts.map +0 -1
  192. package/dist/jestutils/export.js.map +0 -1
  193. package/dist/jestutils/jestHelpers.d.ts.map +0 -1
  194. package/dist/jestutils/jestHelpers.js.map +0 -1
  195. package/dist/matter/behaviors.d.ts.map +0 -1
  196. package/dist/matter/behaviors.js.map +0 -1
  197. package/dist/matter/clusters.d.ts.map +0 -1
  198. package/dist/matter/clusters.js.map +0 -1
  199. package/dist/matter/devices.d.ts.map +0 -1
  200. package/dist/matter/devices.js.map +0 -1
  201. package/dist/matter/endpoints.d.ts.map +0 -1
  202. package/dist/matter/endpoints.js.map +0 -1
  203. package/dist/matter/export.d.ts.map +0 -1
  204. package/dist/matter/export.js.map +0 -1
  205. package/dist/matter/types.d.ts.map +0 -1
  206. package/dist/matter/types.js.map +0 -1
  207. package/dist/matterNode.d.ts.map +0 -1
  208. package/dist/matterNode.js.map +0 -1
  209. package/dist/matterbridge.d.ts.map +0 -1
  210. package/dist/matterbridge.js.map +0 -1
  211. package/dist/matterbridgeAccessoryPlatform.d.ts.map +0 -1
  212. package/dist/matterbridgeAccessoryPlatform.js.map +0 -1
  213. package/dist/matterbridgeBehaviors.d.ts.map +0 -1
  214. package/dist/matterbridgeBehaviors.js.map +0 -1
  215. package/dist/matterbridgeDeviceTypes.d.ts.map +0 -1
  216. package/dist/matterbridgeDeviceTypes.js.map +0 -1
  217. package/dist/matterbridgeDynamicPlatform.d.ts.map +0 -1
  218. package/dist/matterbridgeDynamicPlatform.js.map +0 -1
  219. package/dist/matterbridgeEndpoint.d.ts.map +0 -1
  220. package/dist/matterbridgeEndpoint.js.map +0 -1
  221. package/dist/matterbridgeEndpointHelpers.d.ts.map +0 -1
  222. package/dist/matterbridgeEndpointHelpers.js.map +0 -1
  223. package/dist/matterbridgeEndpointTypes.d.ts.map +0 -1
  224. package/dist/matterbridgeEndpointTypes.js.map +0 -1
  225. package/dist/matterbridgePlatform.d.ts.map +0 -1
  226. package/dist/matterbridgePlatform.js.map +0 -1
  227. package/dist/mb_coap.d.ts.map +0 -1
  228. package/dist/mb_coap.js.map +0 -1
  229. package/dist/mb_health.d.ts.map +0 -1
  230. package/dist/mb_health.js.map +0 -1
  231. package/dist/mb_mdns.d.ts.map +0 -1
  232. package/dist/mb_mdns.js.map +0 -1
  233. package/dist/pluginManager.d.ts.map +0 -1
  234. package/dist/pluginManager.js.map +0 -1
  235. package/dist/spawn.d.ts.map +0 -1
  236. package/dist/spawn.js.map +0 -1
  237. package/dist/utils/export.d.ts.map +0 -1
  238. package/dist/utils/export.js.map +0 -1
  239. package/dist/workers/brand.d.ts +0 -25
  240. package/dist/workers/brand.d.ts.map +0 -1
  241. package/dist/workers/brand.extend.d.ts +0 -10
  242. package/dist/workers/brand.extend.d.ts.map +0 -1
  243. package/dist/workers/brand.extend.js +0 -15
  244. package/dist/workers/brand.extend.js.map +0 -1
  245. package/dist/workers/brand.invalid.d.ts +0 -9
  246. package/dist/workers/brand.invalid.d.ts.map +0 -1
  247. package/dist/workers/brand.invalid.js +0 -19
  248. package/dist/workers/brand.invalid.js.map +0 -1
  249. package/dist/workers/brand.js +0 -67
  250. package/dist/workers/brand.js.map +0 -1
  251. package/dist/workers/clusterTypes.d.ts +0 -47
  252. package/dist/workers/clusterTypes.d.ts.map +0 -1
  253. package/dist/workers/clusterTypes.js +0 -57
  254. package/dist/workers/clusterTypes.js.map +0 -1
  255. package/dist/workers/frontendWorker.d.ts +0 -2
  256. package/dist/workers/frontendWorker.d.ts.map +0 -1
  257. package/dist/workers/frontendWorker.js +0 -90
  258. package/dist/workers/frontendWorker.js.map +0 -1
  259. package/dist/workers/helloWorld.d.ts +0 -2
  260. package/dist/workers/helloWorld.d.ts.map +0 -1
  261. package/dist/workers/helloWorld.js +0 -135
  262. package/dist/workers/helloWorld.js.map +0 -1
  263. package/dist/workers/matterWorker.d.ts +0 -2
  264. package/dist/workers/matterWorker.d.ts.map +0 -1
  265. package/dist/workers/matterWorker.js +0 -104
  266. package/dist/workers/matterWorker.js.map +0 -1
  267. package/dist/workers/matterbridgeWorker.d.ts +0 -2
  268. package/dist/workers/matterbridgeWorker.d.ts.map +0 -1
  269. package/dist/workers/matterbridgeWorker.js +0 -75
  270. package/dist/workers/matterbridgeWorker.js.map +0 -1
  271. package/dist/workers/messageLab.d.ts +0 -134
  272. package/dist/workers/messageLab.d.ts.map +0 -1
  273. package/dist/workers/messageLab.js +0 -129
  274. package/dist/workers/messageLab.js.map +0 -1
  275. package/dist/workers/testWorker.d.ts +0 -2
  276. package/dist/workers/testWorker.d.ts.map +0 -1
  277. package/dist/workers/testWorker.js +0 -45
  278. package/dist/workers/testWorker.js.map +0 -1
  279. package/dist/workers/usage.d.ts +0 -19
  280. package/dist/workers/usage.d.ts.map +0 -1
  281. package/dist/workers/usage.js +0 -140
  282. package/dist/workers/usage.js.map +0 -1
  283. package/dist/workers/workerManager.d.ts +0 -115
  284. package/dist/workers/workerManager.d.ts.map +0 -1
  285. package/dist/workers/workerManager.js +0 -464
  286. package/dist/workers/workerManager.js.map +0 -1
  287. package/dist/workers/workerServer.d.ts +0 -126
  288. package/dist/workers/workerServer.d.ts.map +0 -1
  289. package/dist/workers/workerServer.js +0 -340
  290. package/dist/workers/workerServer.js.map +0 -1
  291. package/dist/workers/workerTypes.d.ts +0 -23
  292. package/dist/workers/workerTypes.d.ts.map +0 -1
  293. package/dist/workers/workerTypes.js +0 -3
  294. package/dist/workers/workerTypes.js.map +0 -1
@@ -1,39 +1,10 @@
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
- /* eslint-disable jsdoc/reject-any-type */
25
- // eslint-disable-next-line no-console
26
1
  if (process.argv.includes('--loader') || process.argv.includes('-loader'))
27
2
  console.log('\u001B[32mMatterbridgeEndpointHelpers loaded.\u001B[40;0m');
28
- // Other modules
29
3
  import { createHash } from 'node:crypto';
30
- // AnsiLogger module
31
4
  import { BLUE, CYAN, db, debugStringify, er, hk, or, YELLOW, zb } from 'node-ansi-logger';
32
- // @matter
33
5
  import { Lifecycle } from '@matter/general';
34
6
  import { MeasurementType } from '@matter/types/globals';
35
7
  import { getClusterNameById } from '@matter/types/cluster';
36
- // @matter clusters
37
8
  import { PowerSource } from '@matter/types/clusters/power-source';
38
9
  import { UserLabel } from '@matter/types/clusters/user-label';
39
10
  import { FixedLabel } from '@matter/types/clusters/fixed-label';
@@ -79,7 +50,6 @@ import { TotalVolatileOrganicCompoundsConcentrationMeasurement } from '@matter/t
79
50
  import { OperationalState } from '@matter/types/clusters/operational-state';
80
51
  import { DeviceEnergyManagement } from '@matter/types/clusters/device-energy-management';
81
52
  import { DeviceEnergyManagementMode } from '@matter/types/clusters/device-energy-management-mode';
82
- // @matter behaviors
83
53
  import { PowerSourceServer } from '@matter/node/behaviors/power-source';
84
54
  import { UserLabelServer } from '@matter/node/behaviors/user-label';
85
55
  import { FixedLabelServer } from '@matter/node/behaviors/fixed-label';
@@ -112,128 +82,59 @@ import { RadonConcentrationMeasurementServer } from '@matter/node/behaviors/rado
112
82
  import { TotalVolatileOrganicCompoundsConcentrationMeasurementServer } from '@matter/node/behaviors/total-volatile-organic-compounds-concentration-measurement';
113
83
  import { deepCopy, deepEqual, isValidArray } from '@matterbridge/utils';
114
84
  import { MatterbridgeIdentifyServer, MatterbridgeOnOffServer, MatterbridgeLevelControlServer, MatterbridgeColorControlServer, MatterbridgeLiftWindowCoveringServer, MatterbridgeThermostatServer, MatterbridgeFanControlServer, MatterbridgeDoorLockServer, MatterbridgeModeSelectServer, MatterbridgeValveConfigurationAndControlServer, MatterbridgeSmokeCoAlarmServer, MatterbridgeBooleanStateConfigurationServer, MatterbridgeOperationalStateServer, MatterbridgePowerSourceServer, MatterbridgeDeviceEnergyManagementServer, MatterbridgeDeviceEnergyManagementModeServer, } from './matterbridgeBehaviors.js';
115
- /**
116
- * Capitalizes the first letter of a string.
117
- *
118
- * @param {string} name - The string to capitalize.
119
- * @returns {string} The string with the first letter capitalized.
120
- */
121
85
  export function capitalizeFirstLetter(name) {
122
86
  if (!name)
123
87
  return name;
124
88
  return name.charAt(0).toUpperCase() + name.slice(1);
125
89
  }
126
- /**
127
- * Lowercases the first letter of a string.
128
- *
129
- * @param {string} name - The string to lowercase the first letter of.
130
- * @returns {string} The string with the first letter lowercased.
131
- */
132
90
  export function lowercaseFirstLetter(name) {
133
91
  if (!name)
134
92
  return name;
135
93
  return name.charAt(0).toLowerCase() + name.slice(1);
136
94
  }
137
- /**
138
- * Checks if the device name contains non-Latin characters.
139
- *
140
- * @param {string} deviceName - The name of the device to check.
141
- * @returns {boolean} Returns true if the device name contains non-Latin characters, false otherwise.
142
- */
143
95
  export function checkNotLatinCharacters(deviceName) {
144
96
  const nonLatinRegexList = [
145
- /[\u0400-\u04FF\u0500-\u052F]/, // Cyrillic
146
- /[\u2E80-\u9FFF]/, // CJK (Chinese, Japanese, Korean)
147
- /[\uAC00-\uD7AF]/, // Korean Hangul
148
- /[\u0600-\u06FF\u0750-\u077F]/, // Arabic, Persian
149
- /[\u0590-\u05FF]/, // Hebrew
150
- /[\u0900-\u097F]/, // Devanagari (Hindi, Sanskrit)
151
- /[\u0E00-\u0E7F]/, // Thai
152
- /[\u1200-\u137F]/, // Ethiopic (Amharic, Tigrinya)
97
+ /[\u0400-\u04FF\u0500-\u052F]/,
98
+ /[\u2E80-\u9FFF]/,
99
+ /[\uAC00-\uD7AF]/,
100
+ /[\u0600-\u06FF\u0750-\u077F]/,
101
+ /[\u0590-\u05FF]/,
102
+ /[\u0900-\u097F]/,
103
+ /[\u0E00-\u0E7F]/,
104
+ /[\u1200-\u137F]/,
153
105
  ];
154
106
  return nonLatinRegexList.some((regex) => regex.test(deviceName));
155
107
  }
156
- /**
157
- * Generates a unique ID based on the device name.
158
- *
159
- * @param {string} deviceName - The name of the device to generate a unique ID for.
160
- * @returns {string} A unique ID generated from the device name using MD5 hashing.
161
- */
162
108
  export function generateUniqueId(deviceName) {
163
- return createHash('md5').update(deviceName).digest('hex'); // MD5 hash of the device name
109
+ return createHash('md5').update(deviceName).digest('hex');
164
110
  }
165
- /**
166
- * Generates a unique ID based on four parameters.
167
- *
168
- * @param {string} param1 - The first parameter.
169
- * @param {string} param2 - The second parameter.
170
- * @param {string} param3 - The third parameter.
171
- * @param {string} param4 - The fourth parameter.
172
- * @returns {string} A unique ID generated from the concatenation of the parameters using MD5 hashing.
173
- */
174
111
  export function createUniqueId(param1, param2, param3, param4) {
175
112
  const hash = createHash('md5');
176
113
  hash.update(param1 + param2 + param3 + param4);
177
114
  return hash.digest('hex');
178
115
  }
179
- /**
180
- * Retrieves the features for a specific behavior.
181
- *
182
- * @param {Endpoint} endpoint - The endpoint to retrieve the features from.
183
- * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to retrieve the features for.
184
- *
185
- * @returns {Record<string, boolean | undefined>} The features for the specified behavior.
186
- *
187
- * @remarks Use with:
188
- * ```typescript
189
- * expect(featuresFor(device, 'powerSource').wired).toBe(true);
190
- * ```
191
- */
192
116
  export function featuresFor(endpoint, cluster) {
193
117
  const behaviorId = getBehavior(endpoint, cluster)?.id;
194
118
  if (!behaviorId) {
195
119
  endpoint.log?.error(`featuresFor error: cluster not found on endpoint ${or}${endpoint.maybeId}${er}:${or}${endpoint.maybeNumber}${er}`);
196
120
  return {};
197
121
  }
198
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
199
122
  return endpoint.behaviors.supported[lowercaseFirstLetter(behaviorId)]['cluster']['supportedFeatures'];
200
123
  }
201
- /**
202
- * Maps a list of ClusterId to Behavior.Type for server clusters.
203
- *
204
- * @param {ClusterId[]} clusterServerList - The list of ClusterId to map.
205
- * @returns {Behavior.Type[]} An array of Behavior.Type corresponding to the ClusterId in the server list.
206
- */
207
124
  export function getBehaviourTypesFromClusterServerIds(clusterServerList) {
208
- // Map Server ClusterId to Behavior.Type
209
125
  const behaviorTypes = [];
210
126
  clusterServerList.forEach((clusterId) => {
211
127
  behaviorTypes.push(getBehaviourTypeFromClusterServerId(clusterId));
212
128
  });
213
129
  return behaviorTypes;
214
130
  }
215
- /**
216
- * Maps a list of ClusterId to Behavior.Type for client clusters.
217
- *
218
- * @param {ClusterId[]} clusterClientList - The list of ClusterId to map.
219
- * @returns {Behavior.Type[]} An array of Behavior.Type corresponding to the ClusterId in the client list.
220
- */
221
131
  export function getBehaviourTypesFromClusterClientIds(clusterClientList) {
222
- // Map Client ClusterId to Behavior.Type
223
132
  const behaviorTypes = [];
224
133
  clusterClientList.forEach((_clusterId) => {
225
- // behaviorTypes.push(getBehaviourTypeFromClusterClientId(clusterId));
226
134
  });
227
135
  return behaviorTypes;
228
136
  }
229
- /**
230
- * Maps a ClusterId to a Behavior.Type for server clusters.
231
- *
232
- * @param {ClusterId} clusterId - The ClusterId to map.
233
- * @returns {Behavior.Type} The corresponding Behavior.Type for the given ClusterId.
234
- */
235
137
  export function getBehaviourTypeFromClusterServerId(clusterId) {
236
- // Map ClusterId to Server Behavior.Type
237
138
  if (clusterId === PowerSource.Cluster.id)
238
139
  return PowerSourceServer.with(PowerSource.Feature.Wired);
239
140
  if (clusterId === UserLabel.Cluster.id)
@@ -326,22 +227,8 @@ export function getBehaviourTypeFromClusterServerId(clusterId) {
326
227
  return MatterbridgeDeviceEnergyManagementModeServer;
327
228
  return MatterbridgeIdentifyServer;
328
229
  }
329
- /**
330
- * Maps a ClusterId to a Behavior.Type for client clusters.
331
- *
332
- * @param {ClusterId} _clusterId - The ClusterId to map.
333
- */
334
230
  export function getBehaviourTypeFromClusterClientId(_clusterId) {
335
- // Map ClusterId to Client Behavior.Type
336
- // return IdentifyClient;
337
231
  }
338
- /**
339
- * Retrieves the Behavior.Type for a given cluster from the endpoint's supported behaviors.
340
- *
341
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to retrieve the behavior from.
342
- * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to retrieve the behavior for.
343
- * @returns {Behavior.Type | undefined} The Behavior.Type for the given cluster, or undefined if not found.
344
- */
345
232
  export function getBehavior(endpoint, cluster) {
346
233
  let behavior;
347
234
  if (typeof cluster === 'string') {
@@ -358,18 +245,6 @@ export function getBehavior(endpoint, cluster) {
358
245
  }
359
246
  return behavior;
360
247
  }
361
- /**
362
- * Invokes a command on the specified behavior of the endpoint. Used ONLY in Jest tests.
363
- *
364
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to invoke the command on.
365
- * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to invoke the command on.
366
- * @param {keyof MatterbridgeEndpointCommands} command - The command to invoke.
367
- * @param {Record<string, boolean | number | bigint | string | object | null>} [params] - The parameters to pass to the command.
368
- *
369
- * @returns {Promise<boolean>} A promise that resolves to true if the command was invoked successfully, false otherwise.
370
- *
371
- * @deprecated Used ONLY in Jest tests.
372
- */
373
248
  export async function invokeBehaviorCommand(endpoint, cluster, command, params) {
374
249
  const behaviorId = getBehavior(endpoint, cluster)?.id;
375
250
  if (!behaviorId) {
@@ -377,7 +252,6 @@ export async function invokeBehaviorCommand(endpoint, cluster, command, params)
377
252
  return false;
378
253
  }
379
254
  await endpoint.act((agent) => {
380
- // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
381
255
  const behavior = agent[behaviorId];
382
256
  if (!(command in behavior) || typeof behavior[command] !== 'function') {
383
257
  endpoint.log?.error(`invokeBehaviorCommand error: command ${hk}${command}${er} not found on agent for endpoint ${or}${endpoint.maybeId}${er}:${or}${endpoint.maybeNumber}${er}`);
@@ -387,19 +261,6 @@ export async function invokeBehaviorCommand(endpoint, cluster, command, params)
387
261
  });
388
262
  return true;
389
263
  }
390
- /**
391
- * Invokes the subscription handler on the specified cluster and attribute of the endpoint. Used ONLY in Jest tests.
392
- *
393
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to invoke the subscription handler on.
394
- * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to invoke the subscription handler on.
395
- * @param {string} attribute - The attribute to invoke the subscription handler on.
396
- * @param {unknown} newValue - The new value of the attribute.
397
- * @param {unknown} oldValue - The old value of the attribute.
398
- *
399
- * @returns {Promise<boolean>} A promise that resolves to true if the subscription handler was invoked successfully, false otherwise.
400
- *
401
- * @deprecated Used ONLY in Jest tests.
402
- */
403
264
  export async function invokeSubscribeHandler(endpoint, cluster, attribute, newValue, oldValue) {
404
265
  const event = attribute + '$Changed';
405
266
  const behaviorId = getBehavior(endpoint, cluster)?.id;
@@ -416,17 +277,9 @@ export async function invokeSubscribeHandler(endpoint, cluster, attribute, newVa
416
277
  endpoint.log.error(`invokeSubscribeHandler ${hk}${event}${er} error: cluster ${behaviorId} not found on endpoint ${or}${endpoint.id}${er}:${or}${endpoint.number}${er}`);
417
278
  return false;
418
279
  }
419
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
420
- // @ts-ignore
421
280
  await endpoint.act((agent) => agent[behaviorId].events[event].emit(newValue, oldValue, { ...agent.context, offline: false, fabric: 1 }));
422
281
  return true;
423
282
  }
424
- /**
425
- * Adds required cluster servers to the specified endpoint based on the device types.
426
- *
427
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to add the required cluster servers to.
428
- * @returns {void}
429
- */
430
283
  export function addRequiredClusterServers(endpoint) {
431
284
  const requiredServerList = [];
432
285
  endpoint.log.debug(`addRequiredClusterServers for ${CYAN}${endpoint.maybeId}${db}`);
@@ -441,12 +294,6 @@ export function addRequiredClusterServers(endpoint) {
441
294
  });
442
295
  addClusterServers(endpoint, requiredServerList);
443
296
  }
444
- /**
445
- * Adds optional cluster servers to the specified endpoint based on the device types.
446
- *
447
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to add the optional cluster servers to.
448
- * @returns {void}
449
- */
450
297
  export function addOptionalClusterServers(endpoint) {
451
298
  const optionalServerList = [];
452
299
  endpoint.log.debug(`addOptionalClusterServers for ${CYAN}${endpoint.maybeId}${db}`);
@@ -461,12 +308,6 @@ export function addOptionalClusterServers(endpoint) {
461
308
  });
462
309
  addClusterServers(endpoint, optionalServerList);
463
310
  }
464
- /**
465
- * Adds cluster servers to the specified endpoint based on the provided server list.
466
- *
467
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to add the cluster servers to.
468
- * @param {ClusterId[]} serverList - The list of cluster IDs to add.
469
- */
470
311
  export function addClusterServers(endpoint, serverList) {
471
312
  if (serverList.includes(PowerSource.Cluster.id))
472
313
  endpoint.createDefaultPowerSourceWiredClusterServer();
@@ -549,13 +390,6 @@ export function addClusterServers(endpoint, serverList) {
549
390
  if (serverList.includes(DeviceEnergyManagementMode.Cluster.id))
550
391
  endpoint.createDefaultDeviceEnergyManagementModeClusterServer();
551
392
  }
552
- /**
553
- * Adds a fixed label to the FixedLabel cluster. The FixedLabel cluster is created if it does not exist.
554
- *
555
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to add the cluster servers to.
556
- * @param {string} label - The label to add. Max 16 characters.
557
- * @param {string} value - The value of the label. Max 16 characters.
558
- */
559
393
  export async function addFixedLabel(endpoint, label, value) {
560
394
  if (!endpoint.hasClusterServer(FixedLabel.Cluster.id)) {
561
395
  endpoint.log.debug(`addFixedLabel: add cluster ${hk}FixedLabel${db}:${hk}fixedLabel${db} with label ${CYAN}${label}${db} value ${CYAN}${value}${db}`);
@@ -572,13 +406,6 @@ export async function addFixedLabel(endpoint, label, value) {
572
406
  await endpoint.setAttribute(FixedLabel.Cluster.id, 'labelList', labelList, endpoint.log);
573
407
  }
574
408
  }
575
- /**
576
- * Adds a user label to the UserLabel cluster. The UserLabel cluster is created if it does not exist.
577
- *
578
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to add the cluster servers to.
579
- * @param {string} label - The label to add. Max 16 characters.
580
- * @param {string} value - The value of the label. Max 16 characters.
581
- */
582
409
  export async function addUserLabel(endpoint, label, value) {
583
410
  if (!endpoint.hasClusterServer(UserLabel.Cluster.id)) {
584
411
  endpoint.log.debug(`addUserLabel: add cluster ${hk}UserLabel${db}:${hk}userLabel${db} with label ${CYAN}${label}${db} value ${CYAN}${value}${db}`);
@@ -595,48 +422,16 @@ export async function addUserLabel(endpoint, label, value) {
595
422
  await endpoint.setAttribute(UserLabel.Cluster.id, 'labelList', labelList, endpoint.log);
596
423
  }
597
424
  }
598
- /**
599
- * Returns the options for a given behavior type.
600
- *
601
- * @param {T} type - The behavior type.
602
- * @param {Behavior.Options<T>} options - The options for the behavior type.
603
- * @returns {Behavior.Options<T>} The options for the behavior type.
604
- */
605
425
  export function optionsFor(type, options) {
606
426
  return options;
607
427
  }
608
- /**
609
- * Retrieves the cluster ID.
610
- *
611
- * @param {Endpoint} endpoint - The endpoint to retrieve the cluster ID from.
612
- * @param {ClusterId} cluster - The ID of the cluster.
613
- * @returns {number | undefined} The ID of the cluster.
614
- */
615
428
  export function getClusterId(endpoint, cluster) {
616
429
  return endpoint.behaviors.supported[lowercaseFirstLetter(cluster)]?.schema?.id;
617
430
  }
618
- /**
619
- * Retrieves the ID of an attribute from a cluster behavior.
620
- *
621
- * @param {Endpoint} endpoint - The endpoint to retrieve the attribute ID from.
622
- * @param {string} cluster - The name of the cluster.
623
- * @param {string} attribute - The name of the attribute.
624
- * @returns {number | undefined} The ID of the attribute, or undefined if not found.
625
- */
626
431
  export function getAttributeId(endpoint, cluster, attribute) {
627
432
  const clusterBehavior = endpoint.behaviors.supported[lowercaseFirstLetter(cluster)];
628
433
  return clusterBehavior?.cluster?.attributes[lowercaseFirstLetter(attribute)]?.id;
629
434
  }
630
- /**
631
- * Retrieves the value of the provided attribute from the given cluster.
632
- *
633
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to retrieve the attribute from.
634
- * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to retrieve the attribute from.
635
- * @param {string} attribute - The name of the attribute to retrieve.
636
- * @param {AnsiLogger} [log] - (Optional) The logger to use for logging the retrieve. Errors are logged to the endpoint logger.
637
- * @returns {any} The value of the attribute, or undefined if the attribute is not found.
638
- */
639
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
640
435
  export function getAttribute(endpoint, cluster, attribute, log) {
641
436
  const clusterName = getBehavior(endpoint, cluster)?.id;
642
437
  if (!clusterName) {
@@ -659,16 +454,6 @@ export function getAttribute(endpoint, cluster, attribute, log) {
659
454
  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}`);
660
455
  return value;
661
456
  }
662
- /**
663
- * Sets the value of an attribute on a cluster server.
664
- *
665
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to set the attribute on.
666
- * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to set the attribute on.
667
- * @param {string} attribute - The name of the attribute.
668
- * @param {boolean | number | bigint | string | object | null} value - The value to set for the attribute.
669
- * @param {AnsiLogger} [log] - (Optional) The logger to use for logging the set. Errors are logged to the endpoint logger.
670
- * @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the attribute was successfully set.
671
- */
672
457
  export async function setAttribute(endpoint, cluster, attribute, value, log) {
673
458
  const clusterName = getBehavior(endpoint, cluster)?.id;
674
459
  if (!clusterName) {
@@ -694,16 +479,6 @@ export async function setAttribute(endpoint, cluster, attribute, value, log) {
694
479
  `to ${YELLOW}${value !== null && typeof value === 'object' ? debugStringify(value) : value}${db}`);
695
480
  return true;
696
481
  }
697
- /**
698
- * Sets the value of an attribute on a cluster server.
699
- *
700
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to update the attribute on.
701
- * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to update the attribute on.
702
- * @param {string} attribute - The name of the attribute.
703
- * @param {boolean | number | bigint | string | object | null} value - The value to set for the attribute.
704
- * @param {AnsiLogger} [log] - (Optional) The logger to use for logging the update. Errors are logged to the endpoint logger.
705
- * @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the attribute was successfully set.
706
- */
707
482
  export async function updateAttribute(endpoint, cluster, attribute, value, log) {
708
483
  const clusterName = getBehavior(endpoint, cluster)?.id;
709
484
  if (!clusterName) {
@@ -734,24 +509,7 @@ export async function updateAttribute(endpoint, cluster, attribute, value, log)
734
509
  `to ${YELLOW}${value !== null && typeof value === 'object' ? debugStringify(value) : value}${db}`);
735
510
  return true;
736
511
  }
737
- /**
738
- * Subscribes to the provided attribute on a cluster.
739
- *
740
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to subscribe the attribute to.
741
- * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to subscribe the attribute to.
742
- * @param {string} attribute - The name of the attribute to subscribe to.
743
- * @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.
744
- * @param {AnsiLogger} [log] - Optional logger for logging errors and information.
745
- * @returns {boolean} - A boolean indicating whether the subscription was successful.
746
- *
747
- * @remarks The listener function (cannot be async) will receive three parameters:
748
- * - `newValue`: The new value of the attribute.
749
- * - `oldValue`: The old value of the attribute.
750
- * - `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.
751
- */
752
- export async function subscribeAttribute(endpoint, cluster, attribute,
753
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
754
- listener, log) {
512
+ export async function subscribeAttribute(endpoint, cluster, attribute, listener, log) {
755
513
  const clusterName = getBehavior(endpoint, cluster)?.id;
756
514
  if (!clusterName) {
757
515
  endpoint.log.error(`subscribeAttribute ${hk}${attribute}${er} error: cluster not found on endpoint ${or}${endpoint.maybeId}${er}:${or}${endpoint.maybeNumber}${er}`);
@@ -761,7 +519,6 @@ listener, log) {
761
519
  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`);
762
520
  await endpoint.construction.ready;
763
521
  }
764
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
765
522
  const events = endpoint.events;
766
523
  attribute = lowercaseFirstLetter(attribute) + '$Changed';
767
524
  if (!(clusterName in events) || !(attribute in events[clusterName])) {
@@ -772,17 +529,6 @@ listener, log) {
772
529
  log?.info(`${db}Subscribed endpoint ${or}${endpoint.id}${db}:${or}${endpoint.number}${db} attribute ${hk}${capitalizeFirstLetter(clusterName)}${db}.${hk}${attribute}${db}`);
773
530
  return true;
774
531
  }
775
- /**
776
- * Triggers an event on the specified cluster.
777
- *
778
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to trigger the event on.
779
- * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The ID of the cluster.
780
- * @param {string} event - The name of the event to trigger.
781
- * @param {Record<string, boolean | number | bigint | string | object | undefined | null>} payload - The payload to pass to the event.
782
- * @param {AnsiLogger} [log] - Optional logger for logging information.
783
- *
784
- * @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the event was successfully triggered.
785
- */
786
532
  export async function triggerEvent(endpoint, cluster, event, payload, log) {
787
533
  const clusterName = getBehavior(endpoint, cluster)?.id;
788
534
  if (!clusterName) {
@@ -793,63 +539,30 @@ export async function triggerEvent(endpoint, cluster, event, payload, log) {
793
539
  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`);
794
540
  return false;
795
541
  }
796
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
797
542
  const events = endpoint.events;
798
543
  if (!(clusterName in events) || !(event in events[clusterName])) {
799
544
  endpoint.log.error(`triggerEvent ${hk}${event}${er} error: cluster ${clusterName} not found on endpoint ${or}${endpoint.id}${er}:${or}${endpoint.number}${er}`);
800
545
  return false;
801
546
  }
802
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
803
- // @ts-ignore
804
547
  await endpoint.act((agent) => agent[clusterName].events[event].emit(payload, agent.context));
805
548
  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} `);
806
549
  return true;
807
550
  }
808
- /** Utility Cluster Helpers */
809
- /**
810
- * Get the default power source wired cluster server options.
811
- *
812
- * @param {PowerSource.WiredCurrentType} wiredCurrentType - The type of wired current (default: PowerSource.WiredCurrentType.Ac)
813
- * @returns {Behavior.Options<PowerSourceClusterServer>} The options for the power source wired cluster server.
814
- *
815
- * @remarks
816
- * - order: The order of the power source is a persisted attribute that indicates the order in which the power sources are used.
817
- * - description: The description of the power source is a fixed attribute that describes the power source type.
818
- * - wiredCurrentType: The type of wired current is a fixed attribute that indicates the type of wired current used by the power source (AC or DC).
819
- */
820
551
  export function getDefaultPowerSourceWiredClusterServer(wiredCurrentType = PowerSource.WiredCurrentType.Ac) {
821
552
  return optionsFor(MatterbridgePowerSourceServer.with(PowerSource.Feature.Wired), {
822
- // Base attributes
823
553
  status: PowerSource.PowerSourceStatus.Active,
824
554
  order: 0,
825
555
  description: wiredCurrentType === PowerSource.WiredCurrentType.Ac ? 'AC Power' : 'DC Power',
826
- endpointList: [], // Will be filled by the MatterbridgePowerSourceServer
827
- // Wired feature attributes
556
+ endpointList: [],
828
557
  wiredCurrentType,
829
558
  });
830
559
  }
831
- /**
832
- * Get the default power source battery cluster server options.
833
- *
834
- * @param {null | number} batPercentRemaining - The remaining battery percentage (default: null). The attribute is in the range 0-200.
835
- * @param {PowerSource.BatChargeLevel} batChargeLevel - The battery charge level (default: PowerSource.BatChargeLevel.Ok).
836
- * @param {null | number} batVoltage - The battery voltage (default: null).
837
- * @param {PowerSource.BatReplaceability} batReplaceability - The replaceability of the battery (default: PowerSource.BatReplaceability.Unspecified).
838
- * @returns {Behavior.Options<PowerSourceClusterServer>} The options for the power source replaceable battery cluster server.
839
- *
840
- * @remarks
841
- * - order: The order of the power source is a persisted attribute that indicates the order in which the power sources are used.
842
- * - description: The description of the power source is a fixed attribute that describes the power source type.
843
- * - batReplaceability: The replaceability of the battery is a fixed attribute that indicates whether the battery is user-replaceable or not.
844
- */
845
560
  export function getDefaultPowerSourceBatteryClusterServer(batPercentRemaining = null, batChargeLevel = PowerSource.BatChargeLevel.Ok, batVoltage = null, batReplaceability = PowerSource.BatReplaceability.Unspecified) {
846
561
  return optionsFor(MatterbridgePowerSourceServer.with(PowerSource.Feature.Battery), {
847
- // Base attributes
848
562
  status: PowerSource.PowerSourceStatus.Active,
849
563
  order: 0,
850
564
  description: 'Primary battery',
851
- endpointList: [], // Will be filled by the MatterbridgePowerSourceServer
852
- // Battery feature attributes
565
+ endpointList: [],
853
566
  batVoltage,
854
567
  batPercentRemaining: batPercentRemaining !== null ? Math.min(Math.max(batPercentRemaining * 2, 0), 200) : null,
855
568
  batChargeLevel,
@@ -857,85 +570,40 @@ export function getDefaultPowerSourceBatteryClusterServer(batPercentRemaining =
857
570
  batReplaceability,
858
571
  });
859
572
  }
860
- /**
861
- * Get the default power source replaceable battery cluster server options.
862
- *
863
- * @param {number} batPercentRemaining - The remaining battery percentage (default: 100). The attribute is in the range 0-200.
864
- * @param {PowerSource.BatChargeLevel} batChargeLevel - The battery charge level (default: PowerSource.BatChargeLevel.Ok).
865
- * @param {number} batVoltage - The battery voltage (default: 1500).
866
- * @param {string} batReplacementDescription - The description of the battery replacement (default: 'Battery type').
867
- * @param {number} batQuantity - The quantity of the battery (default: 1).
868
- * @param {PowerSource.BatReplaceability} batReplaceability - The replaceability of the battery (default: PowerSource.BatReplaceability.UserReplaceable).
869
- * @returns {Behavior.Options<PowerSourceClusterServer>} The options for the power source replaceable battery cluster server.
870
- *
871
- * @remarks
872
- * - order: The order of the power source is a persisted attribute that indicates the order in which the power sources are used.
873
- * - description: The description of the power source is a fixed attribute that describes the power source type.
874
- * - batReplaceability: The replaceability of the battery is a fixed attribute that indicates whether the battery is user-replaceable or not.
875
- * - batReplacementDescription: The description of the battery replacement is a fixed attribute that describes the battery type.
876
- * - batQuantity: The quantity of the battery is a fixed attribute that indicates how many batteries are present in the device.
877
- */
878
573
  export function getDefaultPowerSourceReplaceableBatteryClusterServer(batPercentRemaining = 100, batChargeLevel = PowerSource.BatChargeLevel.Ok, batVoltage = 1500, batReplacementDescription = 'Battery type', batQuantity = 1, batReplaceability = PowerSource.BatReplaceability.UserReplaceable) {
879
574
  return optionsFor(MatterbridgePowerSourceServer.with(PowerSource.Feature.Battery, PowerSource.Feature.Replaceable), {
880
- // Base attributes
881
575
  status: PowerSource.PowerSourceStatus.Active,
882
576
  order: 0,
883
577
  description: 'Primary battery',
884
- endpointList: [], // Will be filled by the MatterbridgePowerSourceServer
885
- // Battery feature attributes
578
+ endpointList: [],
886
579
  batVoltage,
887
580
  batPercentRemaining: Math.min(Math.max(batPercentRemaining * 2, 0), 200),
888
581
  batChargeLevel,
889
582
  batReplacementNeeded: false,
890
583
  batReplaceability,
891
584
  activeBatFaults: undefined,
892
- // Replaceable feature attributes
893
585
  batReplacementDescription,
894
586
  batQuantity,
895
587
  });
896
588
  }
897
- /**
898
- * Creates a default power source rechargeable battery cluster server.
899
- *
900
- * @param {number} [batPercentRemaining] - The remaining battery percentage (default: 100). The attribute is in the range 0-200.
901
- * @param {PowerSource.BatChargeLevel} [batChargeLevel] - The battery charge level (default: PowerSource.BatChargeLevel.Ok).
902
- * @param {number} [batVoltage] - The battery voltage in mV (default: 1500).
903
- * @param {PowerSource.BatReplaceability} [batReplaceability] - The replaceability of the battery (default: PowerSource.BatReplaceability.Unspecified).
904
- * @returns {Behavior.Options<PowerSourceClusterServer>} The options for the power source rechargeable battery cluster server.
905
- *
906
- * @remarks
907
- * - order: The order of the power source is a persisted attribute that indicates the order in which the power sources are used.
908
- * - description: The description of the power source is a fixed attribute that describes the power source type.
909
- * - batReplaceability: The replaceability of the battery is a fixed attribute that indicates whether the battery is user-replaceable or not.
910
- */
911
589
  export function getDefaultPowerSourceRechargeableBatteryClusterServer(batPercentRemaining = 100, batChargeLevel = PowerSource.BatChargeLevel.Ok, batVoltage = 1500, batReplaceability = PowerSource.BatReplaceability.Unspecified) {
912
590
  return optionsFor(MatterbridgePowerSourceServer.with(PowerSource.Feature.Battery, PowerSource.Feature.Rechargeable), {
913
- // Base attributes
914
591
  status: PowerSource.PowerSourceStatus.Active,
915
592
  order: 0,
916
593
  description: 'Primary battery',
917
- endpointList: [], // Will be filled by the MatterbridgePowerSourceServer
918
- // Battery feature attributes
594
+ endpointList: [],
919
595
  batVoltage,
920
596
  batPercentRemaining: Math.min(Math.max(batPercentRemaining * 2, 0), 200),
921
- batTimeRemaining: null, // Indicates the estimated time in seconds before the battery will no longer be able to provide power to the Node
597
+ batTimeRemaining: null,
922
598
  batChargeLevel,
923
599
  batReplacementNeeded: false,
924
600
  batReplaceability,
925
601
  batPresent: true,
926
602
  activeBatFaults: [],
927
- // Rechargeable feature attributes
928
603
  batChargeState: PowerSource.BatChargeState.IsNotCharging,
929
604
  batFunctionalWhileCharging: true,
930
605
  });
931
606
  }
932
- /**
933
- * Get the default Electrical Energy Measurement Cluster Server options with features ImportedEnergy, ExportedEnergy, and CumulativeEnergy.
934
- *
935
- * @param {number} energyImported - The total consumption value in mW/h.
936
- * @param {number} energyExported - The total production value in mW/h.
937
- * @returns {Behavior.Options<ElectricalEnergyMeasurementServer>} - The default options for the Electrical Energy Measurement Cluster Server.
938
- */
939
607
  export function getDefaultElectricalEnergyMeasurementClusterServer(energyImported = null, energyExported = null) {
940
608
  return optionsFor(ElectricalEnergyMeasurementServer.with(ElectricalEnergyMeasurement.Feature.ImportedEnergy, ElectricalEnergyMeasurement.Feature.ExportedEnergy, ElectricalEnergyMeasurement.Feature.CumulativeEnergy), {
941
609
  accuracy: {
@@ -950,15 +618,6 @@ export function getDefaultElectricalEnergyMeasurementClusterServer(energyImporte
950
618
  cumulativeEnergyExported: energyExported !== null && energyExported >= 0 ? { energy: energyExported } : null,
951
619
  });
952
620
  }
953
- /**
954
- * Get the default Electrical Power Measurement Cluster Server options with features AlternatingCurrent.
955
- *
956
- * @param {number} voltage - The voltage value in millivolts.
957
- * @param {number} current - The current value in milliamperes.
958
- * @param {number} power - The power value in milliwatts.
959
- * @param {number} frequency - The frequency value in millihertz.
960
- * @returns {Behavior.Options<ElectricalPowerMeasurementServer>} - The default options for the Electrical Power Measurement Cluster Server.
961
- */
962
621
  export function getDefaultElectricalPowerMeasurementClusterServer(voltage = null, current = null, power = null, frequency = null) {
963
622
  return optionsFor(ElectricalPowerMeasurementServer.with(ElectricalPowerMeasurement.Feature.AlternatingCurrent), {
964
623
  powerMode: ElectricalPowerMeasurement.PowerMode.Ac,
@@ -999,15 +658,6 @@ export function getDefaultElectricalPowerMeasurementClusterServer(voltage = null
999
658
  frequency: frequency,
1000
659
  });
1001
660
  }
1002
- /**
1003
- * Get the default Electrical Apparent Power Measurement Cluster Server with features AlternatingCurrent.
1004
- *
1005
- * @param {number} voltage - The voltage value in millivolts.
1006
- * @param {number} apparentCurrent - The current value in milliamperes.
1007
- * @param {number} apparentPower - The apparent power value in millivoltamperes.
1008
- * @param {number} frequency - The frequency value in millihertz.
1009
- * @returns {Behavior.Options<ElectricalPowerMeasurementServer>} - The default options for the Electrical Apparent Power Measurement Cluster Server.
1010
- */
1011
661
  export function getApparentElectricalPowerMeasurementClusterServer(voltage = null, apparentCurrent = null, apparentPower = null, frequency = null) {
1012
662
  return optionsFor(ElectricalPowerMeasurementServer.with(ElectricalPowerMeasurement.Feature.AlternatingCurrent), {
1013
663
  powerMode: ElectricalPowerMeasurement.PowerMode.Ac,
@@ -1048,55 +698,19 @@ export function getApparentElectricalPowerMeasurementClusterServer(voltage = nul
1048
698
  frequency: frequency,
1049
699
  });
1050
700
  }
1051
- /**
1052
- * Get the default Device Energy Management Cluster Server with feature PowerForecastReporting and with the specified ESA type, ESA canGenerate, ESA state, and power limits.
1053
- *
1054
- * @param {DeviceEnergyManagement.EsaType} [esaType] - The ESA type. Defaults to `DeviceEnergyManagement.EsaType.Other`.
1055
- * @param {boolean} [esaCanGenerate] - Indicates if the ESA can generate energy. Defaults to `false`.
1056
- * @param {DeviceEnergyManagement.EsaState} [esaState] - The ESA state. Defaults to `DeviceEnergyManagement.EsaState.Online`.
1057
- * @param {number} [absMinPower] - Indicate the minimum electrical power in mw that the ESA can consume when switched on. Defaults to `0` if not provided.
1058
- * @param {number} [absMaxPower] - Indicate the maximum electrical power in mw that the ESA can consume when switched on. Defaults to `0` if not provided.
1059
- * @returns {Behavior.Options<DeviceEnergyManagementClusterServer>} - The default options for the Device Energy Management Cluster Server.
1060
- *
1061
- * @remarks
1062
- * - The forecast attribute is set to null, indicating that there is no forecast currently available.
1063
- * - The ESA type and canGenerate attributes are fixed and cannot be changed after creation.
1064
- * - The ESA state is set to Online by default.
1065
- * - The absolute minimum and maximum power attributes are set to 0 by default.
1066
- * - For example, a battery storage inverter that can charge its battery at a maximum power of 2000W and can
1067
- * discharge the battery at a maximum power of 3000W, would have a absMinPower: -3000W, absMaxPower: 2000W.
1068
- */
1069
701
  export function getDefaultDeviceEnergyManagementClusterServer(esaType = DeviceEnergyManagement.EsaType.Other, esaCanGenerate = false, esaState = DeviceEnergyManagement.EsaState.Online, absMinPower = 0, absMaxPower = 0) {
1070
702
  return optionsFor(MatterbridgeDeviceEnergyManagementServer.with(DeviceEnergyManagement.Feature.PowerForecastReporting, DeviceEnergyManagement.Feature.PowerAdjustment), {
1071
- esaType, // Fixed attribute
1072
- esaCanGenerate, // Fixed attribute
703
+ esaType,
704
+ esaCanGenerate,
1073
705
  esaState,
1074
706
  absMinPower,
1075
707
  absMaxPower,
1076
- // PowerAdjustment feature (commands: powerAdjustRequest and cancelPowerAdjustRequest events: powerAdjustStart and powerAdjustEnd)
1077
- powerAdjustmentCapability: null, // A null value indicates that no power adjustment is currently possible, and nor is any adjustment currently active
708
+ powerAdjustmentCapability: null,
1078
709
  optOutState: DeviceEnergyManagement.OptOutState.NoOptOut,
1079
- // PowerForecastReporting
1080
- forecast: null, // A null value indicates that there is no forecast currently available
710
+ forecast: null,
1081
711
  });
1082
712
  }
1083
- /**
1084
- * Get the default EnergyManagementMode Cluster Server.
1085
- *
1086
- * @param {number} [currentMode] - The current mode of the EnergyManagementMode cluster. Defaults to mode 1 (DeviceEnergyManagementMode.ModeTag.NoOptimization).
1087
- * @param {EnergyManagementMode.ModeOption[]} [supportedModes] - The supported modes for the DeviceEnergyManagementMode cluster. The attribute is fixed and defaults to a predefined set of cluster modes.
1088
- * @returns {Behavior.Options<DeviceEnergyManagementModeClusterServer>} - The default options for the Device Energy Management Mode cluster server.
1089
- *
1090
- * @remarks
1091
- * A few examples of Device Energy Management modes and their mode tags are provided below.
1092
- * - For the "No Energy Management (Forecast reporting only)" mode, tags: 0x4000 (NoOptimization).
1093
- * - For the "Device Energy Management" mode, tags: 0x4001 (DeviceOptimization).
1094
- * - For the "Home Energy Management" mode, tags: 0x4001 (DeviceOptimization), 0x4002 (LocalOptimization).
1095
- * - For the "Grid Energy Management" mode, tags: 0x4003 (GridOptimization).
1096
- * - For the "Full Energy Management" mode, tags: 0x4001 (DeviceOptimization), 0x4002 (LocalOptimization), 0x4003 (GridOptimization).
1097
- */
1098
713
  export function getDefaultDeviceEnergyManagementModeClusterServer(currentMode, supportedModes) {
1099
- // TODO: matter.js 0.16.0 needs a with() method
1100
714
  return optionsFor(MatterbridgeDeviceEnergyManagementModeServer.with(), {
1101
715
  supportedModes: supportedModes ?? [
1102
716
  { label: 'No Energy Management (Forecast reporting only)', mode: 1, modeTags: [{ value: DeviceEnergyManagementMode.ModeTag.NoOptimization }] },
@@ -1120,26 +734,11 @@ export function getDefaultDeviceEnergyManagementModeClusterServer(currentMode, s
1120
734
  { value: DeviceEnergyManagementMode.ModeTag.GridOptimization },
1121
735
  ],
1122
736
  },
1123
- ], // Fixed attribute
737
+ ],
1124
738
  currentMode: currentMode ?? 1,
1125
739
  });
1126
740
  }
1127
- /** Application Cluster Helpers */
1128
- /**
1129
- * Get the default OperationalState Cluster Server.
1130
- *
1131
- * @param {OperationalState.OperationalStateEnum} operationalState - The initial operational state id.
1132
- * @returns {Behavior.Options<MatterbridgeOperationalStateServer>} - The default options for the OperationalState cluster server.
1133
- *
1134
- * @remarks
1135
- * This method adds a cluster server with a default operational state configuration:
1136
- * - { operationalStateId: OperationalState.OperationalStateEnum.Stopped, operationalStateLabel: 'Stopped' },
1137
- * - { operationalStateId: OperationalState.OperationalStateEnum.Running, operationalStateLabel: 'Running' },
1138
- * - { operationalStateId: OperationalState.OperationalStateEnum.Paused, operationalStateLabel: 'Paused' },
1139
- * - { operationalStateId: OperationalState.OperationalStateEnum.Error, operationalStateLabel: 'Error' },
1140
- */
1141
741
  export function getDefaultOperationalStateClusterServer(operationalState = OperationalState.OperationalStateEnum.Stopped) {
1142
- // TODO: matter.js 0.16.0 needs a with() method
1143
742
  return optionsFor(MatterbridgeOperationalStateServer.with(), {
1144
743
  phaseList: [],
1145
744
  currentPhase: null,
@@ -1154,14 +753,6 @@ export function getDefaultOperationalStateClusterServer(operationalState = Opera
1154
753
  operationalError: { errorStateId: OperationalState.ErrorState.NoError, errorStateDetails: 'Fully operational' },
1155
754
  });
1156
755
  }
1157
- /**
1158
- * Get the default TemperatureMeasurement cluster server options.
1159
- *
1160
- * @param {number | null} measuredValue - The measured value of the temperature x 100.
1161
- * @param {number | null} minMeasuredValue - The minimum measured value of the temperature x 100.
1162
- * @param {number | null} maxMeasuredValue - The maximum measured value of the temperature x 100.
1163
- * @returns {Behavior.Options<MatterbridgeTemperatureMeasurementServer>} - The default options for the TemperatureMeasurement cluster server.
1164
- */
1165
756
  export function getDefaultTemperatureMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
1166
757
  return optionsFor(TemperatureMeasurementServer, {
1167
758
  measuredValue,
@@ -1170,14 +761,6 @@ export function getDefaultTemperatureMeasurementClusterServer(measuredValue = nu
1170
761
  tolerance: 0,
1171
762
  });
1172
763
  }
1173
- /**
1174
- * Get the default RelativeHumidityMeasurement cluster server options.
1175
- *
1176
- * @param {number | null} measuredValue - The measured value of the relative humidity x 100.
1177
- * @param {number | null} minMeasuredValue - The minimum measured value of the relative humidity x 100.
1178
- * @param {number | null} maxMeasuredValue - The maximum measured value of the relative humidity x 100.
1179
- * @returns {Behavior.Options<MatterbridgeRelativeHumidityMeasurementServer>} - The default options for the RelativeHumidityMeasurement cluster server.
1180
- */
1181
764
  export function getDefaultRelativeHumidityMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
1182
765
  return optionsFor(RelativeHumidityMeasurementServer, {
1183
766
  measuredValue,
@@ -1186,14 +769,6 @@ export function getDefaultRelativeHumidityMeasurementClusterServer(measuredValue
1186
769
  tolerance: 0,
1187
770
  });
1188
771
  }
1189
- /**
1190
- * Get the default PressureMeasurement cluster server options.
1191
- *
1192
- * @param {number | null} measuredValue - The measured value for the pressure in kPa x 10.
1193
- * @param {number | null} minMeasuredValue - The minimum measured value for the pressure in kPa x 10.
1194
- * @param {number | null} maxMeasuredValue - The maximum measured value for the pressure in kPa x 10.
1195
- * @returns {Behavior.Options<MatterbridgePressureMeasurementServer>} - The default options for the PressureMeasurement cluster server.
1196
- */
1197
772
  export function getDefaultPressureMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
1198
773
  return optionsFor(PressureMeasurementServer, {
1199
774
  measuredValue,
@@ -1202,21 +777,6 @@ export function getDefaultPressureMeasurementClusterServer(measuredValue = null,
1202
777
  tolerance: 0,
1203
778
  });
1204
779
  }
1205
- /**
1206
- * Get the default IlluminanceMeasurement cluster server options.
1207
- *
1208
- * @param {number | null} measuredValue - The measured value of illuminance.
1209
- * @param {number | null} minMeasuredValue - The minimum measured value of illuminance.
1210
- * @param {number | null} maxMeasuredValue - The maximum measured value of illuminance.
1211
- * @returns {Behavior.Options<MatterbridgeIlluminanceMeasurementServer>} - The default options for the IlluminanceMeasurement cluster server.
1212
- *
1213
- * @remarks The default value for the illuminance measurement is null.
1214
- * This attribute SHALL indicate the illuminance in Lux (symbol lx) as follows:
1215
- * • MeasuredValue = 10,000 x log10(illuminance) + 1,
1216
- * where 1 lx <= illuminance <= 3.576 Mlx, corresponding to a MeasuredValue in the range 1 to 0xFFFE.
1217
- * • 0 indicates a value of illuminance that is too low to be measured
1218
- * • null indicates that the illuminance measurement is invalid.
1219
- */
1220
780
  export function getDefaultIlluminanceMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
1221
781
  return optionsFor(IlluminanceMeasurementServer, {
1222
782
  measuredValue,
@@ -1225,14 +785,6 @@ export function getDefaultIlluminanceMeasurementClusterServer(measuredValue = nu
1225
785
  tolerance: 0,
1226
786
  });
1227
787
  }
1228
- /**
1229
- * Get the default FlowMeasurement cluster server options.
1230
- *
1231
- * @param {number | null} measuredValue - The measured value of the flow in 10 x m3/h.
1232
- * @param {number | null} minMeasuredValue - The minimum measured value of the flow in 10 x m3/h.
1233
- * @param {number | null} maxMeasuredValue - The maximum measured value of the flow in 10 x m3/h.
1234
- * @returns {Behavior.Options<MatterbridgeFlowMeasurementServer>} - The default options for the FlowMeasurement cluster server.
1235
- */
1236
788
  export function getDefaultFlowMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
1237
789
  return optionsFor(FlowMeasurementServer, {
1238
790
  measuredValue,
@@ -1241,20 +793,6 @@ export function getDefaultFlowMeasurementClusterServer(measuredValue = null, min
1241
793
  tolerance: 0,
1242
794
  });
1243
795
  }
1244
- /**
1245
- * Get the default OccupancySensing cluster server options.
1246
- *
1247
- * @param {boolean} occupied - A boolean indicating whether the occupancy is occupied or not. Default is false.
1248
- * @param {number} holdTime - The hold time in seconds. Default is 30.
1249
- * @param {number} holdTimeMin - The minimum hold time in seconds. Default is 1.
1250
- * @param {number} holdTimeMax - The maximum hold time in seconds. Default is 300.
1251
- * @returns {Behavior.Options<MatterbridgeOccupancySensingServer>} - The default options for the OccupancySensing cluster server.
1252
- *
1253
- * @remarks The default value for the occupancy sensor type is PIR.
1254
- * Servers SHALL set these attributes for backward compatibility with clients implementing a cluster revision <= 4 as
1255
- * described in OccupancySensorType and OccupancySensorTypeBitmap Attributes.
1256
- * This replaces the 9 legacy attributes PIROccupiedToUnoccupiedDelay through PhysicalContactUnoccupiedToOccupiedThreshold.
1257
- */
1258
796
  export function getDefaultOccupancySensingClusterServer(occupied = false, holdTime = 30, holdTimeMin = 1, holdTimeMax = 300) {
1259
797
  return optionsFor(OccupancySensingServer.with(OccupancySensing.Feature.PassiveInfrared), {
1260
798
  occupancy: { occupied },
@@ -1267,4 +805,3 @@ export function getDefaultOccupancySensingClusterServer(occupied = false, holdTi
1267
805
  holdTimeLimits: { holdTimeMin, holdTimeMax, holdTimeDefault: holdTime },
1268
806
  });
1269
807
  }
1270
- //# sourceMappingURL=matterbridgeEndpointHelpers.js.map