matterbridge 3.3.6 → 3.3.7-dev-20251102-c85d574

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 (305) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/broadcastServer.js +1 -92
  3. package/dist/broadcastServerTypes.js +0 -24
  4. package/dist/cli.js +1 -97
  5. package/dist/cliEmitter.js +0 -37
  6. package/dist/cliHistory.js +0 -38
  7. package/dist/clusters/export.js +0 -2
  8. package/dist/defaultConfigSchema.js +0 -24
  9. package/dist/deviceManager.js +1 -124
  10. package/dist/devices/airConditioner.js +0 -57
  11. package/dist/devices/batteryStorage.js +1 -48
  12. package/dist/devices/cooktop.js +0 -55
  13. package/dist/devices/dishwasher.js +0 -57
  14. package/dist/devices/evse.js +10 -74
  15. package/dist/devices/export.js +0 -5
  16. package/dist/devices/extractorHood.js +0 -42
  17. package/dist/devices/heatPump.js +2 -50
  18. package/dist/devices/laundryDryer.js +3 -62
  19. package/dist/devices/laundryWasher.js +4 -70
  20. package/dist/devices/microwaveOven.js +5 -88
  21. package/dist/devices/oven.js +0 -85
  22. package/dist/devices/refrigerator.js +0 -102
  23. package/dist/devices/roboticVacuumCleaner.js +9 -100
  24. package/dist/devices/solarPower.js +0 -38
  25. package/dist/devices/speaker.js +0 -84
  26. package/dist/devices/temperatureControl.js +3 -24
  27. package/dist/devices/waterHeater.js +2 -82
  28. package/dist/dgram/coap.js +13 -126
  29. package/dist/dgram/dgram.js +2 -114
  30. package/dist/dgram/mb_coap.js +3 -41
  31. package/dist/dgram/mb_mdns.js +15 -80
  32. package/dist/dgram/mdns.js +137 -299
  33. package/dist/dgram/multicast.js +1 -62
  34. package/dist/dgram/unicast.js +0 -54
  35. package/dist/frontend.js +34 -431
  36. package/dist/frontendTypes.js +0 -45
  37. package/dist/helpers.js +0 -53
  38. package/dist/index.js +0 -25
  39. package/dist/logger/export.js +0 -1
  40. package/dist/matter/behaviors.js +0 -2
  41. package/dist/matter/clusters.js +0 -2
  42. package/dist/matter/devices.js +0 -2
  43. package/dist/matter/endpoints.js +0 -2
  44. package/dist/matter/export.js +0 -3
  45. package/dist/matter/types.js +0 -3
  46. package/dist/matterbridge.js +46 -828
  47. package/dist/matterbridgeAccessoryPlatform.js +0 -37
  48. package/dist/matterbridgeBehaviors.js +5 -68
  49. package/dist/matterbridgeDeviceTypes.js +17 -638
  50. package/dist/matterbridgeDynamicPlatform.js +0 -37
  51. package/dist/matterbridgeEndpoint.js +52 -1408
  52. package/dist/matterbridgeEndpointHelpers.js +19 -464
  53. package/dist/matterbridgePlatform.js +1 -341
  54. package/dist/matterbridgeTypes.js +0 -26
  55. package/dist/pluginManager.js +3 -319
  56. package/dist/shelly.js +7 -168
  57. package/dist/storage/export.js +0 -1
  58. package/dist/update.js +0 -69
  59. package/dist/utils/colorUtils.js +2 -97
  60. package/dist/utils/commandLine.js +0 -60
  61. package/dist/utils/copyDirectory.js +1 -38
  62. package/dist/utils/createDirectory.js +0 -33
  63. package/dist/utils/createZip.js +2 -47
  64. package/dist/utils/deepCopy.js +0 -39
  65. package/dist/utils/deepEqual.js +1 -72
  66. package/dist/utils/error.js +0 -41
  67. package/dist/utils/export.js +0 -1
  68. package/dist/utils/format.js +0 -49
  69. package/dist/utils/hex.js +0 -124
  70. package/dist/utils/inspector.js +1 -69
  71. package/dist/utils/isvalid.js +0 -101
  72. package/dist/utils/jestHelpers.js +3 -153
  73. package/dist/utils/network.js +5 -96
  74. package/dist/utils/spawn.js +0 -71
  75. package/dist/utils/tracker.js +1 -64
  76. package/dist/utils/wait.js +8 -60
  77. package/frontend/build/assets/index.js +4 -4
  78. package/frontend/package.json +1 -1
  79. package/npm-shrinkwrap.json +2 -2
  80. package/package.json +1 -2
  81. package/dist/broadcastServer.d.ts +0 -112
  82. package/dist/broadcastServer.d.ts.map +0 -1
  83. package/dist/broadcastServer.js.map +0 -1
  84. package/dist/broadcastServerTypes.d.ts +0 -803
  85. package/dist/broadcastServerTypes.d.ts.map +0 -1
  86. package/dist/broadcastServerTypes.js.map +0 -1
  87. package/dist/cli.d.ts +0 -30
  88. package/dist/cli.d.ts.map +0 -1
  89. package/dist/cli.js.map +0 -1
  90. package/dist/cliEmitter.d.ts +0 -50
  91. package/dist/cliEmitter.d.ts.map +0 -1
  92. package/dist/cliEmitter.js.map +0 -1
  93. package/dist/cliHistory.d.ts +0 -48
  94. package/dist/cliHistory.d.ts.map +0 -1
  95. package/dist/cliHistory.js.map +0 -1
  96. package/dist/clusters/export.d.ts +0 -2
  97. package/dist/clusters/export.d.ts.map +0 -1
  98. package/dist/clusters/export.js.map +0 -1
  99. package/dist/defaultConfigSchema.d.ts +0 -28
  100. package/dist/defaultConfigSchema.d.ts.map +0 -1
  101. package/dist/defaultConfigSchema.js.map +0 -1
  102. package/dist/deviceManager.d.ts +0 -117
  103. package/dist/deviceManager.d.ts.map +0 -1
  104. package/dist/deviceManager.js.map +0 -1
  105. package/dist/devices/airConditioner.d.ts +0 -98
  106. package/dist/devices/airConditioner.d.ts.map +0 -1
  107. package/dist/devices/airConditioner.js.map +0 -1
  108. package/dist/devices/batteryStorage.d.ts +0 -48
  109. package/dist/devices/batteryStorage.d.ts.map +0 -1
  110. package/dist/devices/batteryStorage.js.map +0 -1
  111. package/dist/devices/cooktop.d.ts +0 -60
  112. package/dist/devices/cooktop.d.ts.map +0 -1
  113. package/dist/devices/cooktop.js.map +0 -1
  114. package/dist/devices/dishwasher.d.ts +0 -71
  115. package/dist/devices/dishwasher.d.ts.map +0 -1
  116. package/dist/devices/dishwasher.js.map +0 -1
  117. package/dist/devices/evse.d.ts +0 -76
  118. package/dist/devices/evse.d.ts.map +0 -1
  119. package/dist/devices/evse.js.map +0 -1
  120. package/dist/devices/export.d.ts +0 -17
  121. package/dist/devices/export.d.ts.map +0 -1
  122. package/dist/devices/export.js.map +0 -1
  123. package/dist/devices/extractorHood.d.ts +0 -46
  124. package/dist/devices/extractorHood.d.ts.map +0 -1
  125. package/dist/devices/extractorHood.js.map +0 -1
  126. package/dist/devices/heatPump.d.ts +0 -47
  127. package/dist/devices/heatPump.d.ts.map +0 -1
  128. package/dist/devices/heatPump.js.map +0 -1
  129. package/dist/devices/laundryDryer.d.ts +0 -67
  130. package/dist/devices/laundryDryer.d.ts.map +0 -1
  131. package/dist/devices/laundryDryer.js.map +0 -1
  132. package/dist/devices/laundryWasher.d.ts +0 -81
  133. package/dist/devices/laundryWasher.d.ts.map +0 -1
  134. package/dist/devices/laundryWasher.js.map +0 -1
  135. package/dist/devices/microwaveOven.d.ts +0 -168
  136. package/dist/devices/microwaveOven.d.ts.map +0 -1
  137. package/dist/devices/microwaveOven.js.map +0 -1
  138. package/dist/devices/oven.d.ts +0 -105
  139. package/dist/devices/oven.d.ts.map +0 -1
  140. package/dist/devices/oven.js.map +0 -1
  141. package/dist/devices/refrigerator.d.ts +0 -118
  142. package/dist/devices/refrigerator.d.ts.map +0 -1
  143. package/dist/devices/refrigerator.js.map +0 -1
  144. package/dist/devices/roboticVacuumCleaner.d.ts +0 -112
  145. package/dist/devices/roboticVacuumCleaner.d.ts.map +0 -1
  146. package/dist/devices/roboticVacuumCleaner.js.map +0 -1
  147. package/dist/devices/solarPower.d.ts +0 -40
  148. package/dist/devices/solarPower.d.ts.map +0 -1
  149. package/dist/devices/solarPower.js.map +0 -1
  150. package/dist/devices/speaker.d.ts +0 -87
  151. package/dist/devices/speaker.d.ts.map +0 -1
  152. package/dist/devices/speaker.js.map +0 -1
  153. package/dist/devices/temperatureControl.d.ts +0 -166
  154. package/dist/devices/temperatureControl.d.ts.map +0 -1
  155. package/dist/devices/temperatureControl.js.map +0 -1
  156. package/dist/devices/waterHeater.d.ts +0 -111
  157. package/dist/devices/waterHeater.d.ts.map +0 -1
  158. package/dist/devices/waterHeater.js.map +0 -1
  159. package/dist/dgram/coap.d.ts +0 -205
  160. package/dist/dgram/coap.d.ts.map +0 -1
  161. package/dist/dgram/coap.js.map +0 -1
  162. package/dist/dgram/dgram.d.ts +0 -141
  163. package/dist/dgram/dgram.d.ts.map +0 -1
  164. package/dist/dgram/dgram.js.map +0 -1
  165. package/dist/dgram/mb_coap.d.ts +0 -24
  166. package/dist/dgram/mb_coap.d.ts.map +0 -1
  167. package/dist/dgram/mb_coap.js.map +0 -1
  168. package/dist/dgram/mb_mdns.d.ts +0 -24
  169. package/dist/dgram/mb_mdns.d.ts.map +0 -1
  170. package/dist/dgram/mb_mdns.js.map +0 -1
  171. package/dist/dgram/mdns.d.ts +0 -290
  172. package/dist/dgram/mdns.d.ts.map +0 -1
  173. package/dist/dgram/mdns.js.map +0 -1
  174. package/dist/dgram/multicast.d.ts +0 -67
  175. package/dist/dgram/multicast.d.ts.map +0 -1
  176. package/dist/dgram/multicast.js.map +0 -1
  177. package/dist/dgram/unicast.d.ts +0 -56
  178. package/dist/dgram/unicast.d.ts.map +0 -1
  179. package/dist/dgram/unicast.js.map +0 -1
  180. package/dist/frontend.d.ts +0 -236
  181. package/dist/frontend.d.ts.map +0 -1
  182. package/dist/frontend.js.map +0 -1
  183. package/dist/frontendTypes.d.ts +0 -529
  184. package/dist/frontendTypes.d.ts.map +0 -1
  185. package/dist/frontendTypes.js.map +0 -1
  186. package/dist/helpers.d.ts +0 -48
  187. package/dist/helpers.d.ts.map +0 -1
  188. package/dist/helpers.js.map +0 -1
  189. package/dist/index.d.ts +0 -33
  190. package/dist/index.d.ts.map +0 -1
  191. package/dist/index.js.map +0 -1
  192. package/dist/logger/export.d.ts +0 -2
  193. package/dist/logger/export.d.ts.map +0 -1
  194. package/dist/logger/export.js.map +0 -1
  195. package/dist/matter/behaviors.d.ts +0 -2
  196. package/dist/matter/behaviors.d.ts.map +0 -1
  197. package/dist/matter/behaviors.js.map +0 -1
  198. package/dist/matter/clusters.d.ts +0 -2
  199. package/dist/matter/clusters.d.ts.map +0 -1
  200. package/dist/matter/clusters.js.map +0 -1
  201. package/dist/matter/devices.d.ts +0 -2
  202. package/dist/matter/devices.d.ts.map +0 -1
  203. package/dist/matter/devices.js.map +0 -1
  204. package/dist/matter/endpoints.d.ts +0 -2
  205. package/dist/matter/endpoints.d.ts.map +0 -1
  206. package/dist/matter/endpoints.js.map +0 -1
  207. package/dist/matter/export.d.ts +0 -5
  208. package/dist/matter/export.d.ts.map +0 -1
  209. package/dist/matter/export.js.map +0 -1
  210. package/dist/matter/types.d.ts +0 -3
  211. package/dist/matter/types.d.ts.map +0 -1
  212. package/dist/matter/types.js.map +0 -1
  213. package/dist/matterbridge.d.ts +0 -476
  214. package/dist/matterbridge.d.ts.map +0 -1
  215. package/dist/matterbridge.js.map +0 -1
  216. package/dist/matterbridgeAccessoryPlatform.d.ts +0 -42
  217. package/dist/matterbridgeAccessoryPlatform.d.ts.map +0 -1
  218. package/dist/matterbridgeAccessoryPlatform.js.map +0 -1
  219. package/dist/matterbridgeBehaviors.d.ts +0 -2404
  220. package/dist/matterbridgeBehaviors.d.ts.map +0 -1
  221. package/dist/matterbridgeBehaviors.js.map +0 -1
  222. package/dist/matterbridgeDeviceTypes.d.ts +0 -770
  223. package/dist/matterbridgeDeviceTypes.d.ts.map +0 -1
  224. package/dist/matterbridgeDeviceTypes.js.map +0 -1
  225. package/dist/matterbridgeDynamicPlatform.d.ts +0 -42
  226. package/dist/matterbridgeDynamicPlatform.d.ts.map +0 -1
  227. package/dist/matterbridgeDynamicPlatform.js.map +0 -1
  228. package/dist/matterbridgeEndpoint.d.ts +0 -1556
  229. package/dist/matterbridgeEndpoint.d.ts.map +0 -1
  230. package/dist/matterbridgeEndpoint.js.map +0 -1
  231. package/dist/matterbridgeEndpointHelpers.d.ts +0 -758
  232. package/dist/matterbridgeEndpointHelpers.d.ts.map +0 -1
  233. package/dist/matterbridgeEndpointHelpers.js.map +0 -1
  234. package/dist/matterbridgePlatform.d.ts +0 -402
  235. package/dist/matterbridgePlatform.d.ts.map +0 -1
  236. package/dist/matterbridgePlatform.js.map +0 -1
  237. package/dist/matterbridgeTypes.d.ts +0 -226
  238. package/dist/matterbridgeTypes.d.ts.map +0 -1
  239. package/dist/matterbridgeTypes.js.map +0 -1
  240. package/dist/pluginManager.d.ts +0 -347
  241. package/dist/pluginManager.d.ts.map +0 -1
  242. package/dist/pluginManager.js.map +0 -1
  243. package/dist/shelly.d.ts +0 -174
  244. package/dist/shelly.d.ts.map +0 -1
  245. package/dist/shelly.js.map +0 -1
  246. package/dist/storage/export.d.ts +0 -2
  247. package/dist/storage/export.d.ts.map +0 -1
  248. package/dist/storage/export.js.map +0 -1
  249. package/dist/update.d.ts +0 -75
  250. package/dist/update.d.ts.map +0 -1
  251. package/dist/update.js.map +0 -1
  252. package/dist/utils/colorUtils.d.ts +0 -101
  253. package/dist/utils/colorUtils.d.ts.map +0 -1
  254. package/dist/utils/colorUtils.js.map +0 -1
  255. package/dist/utils/commandLine.d.ts +0 -66
  256. package/dist/utils/commandLine.d.ts.map +0 -1
  257. package/dist/utils/commandLine.js.map +0 -1
  258. package/dist/utils/copyDirectory.d.ts +0 -33
  259. package/dist/utils/copyDirectory.d.ts.map +0 -1
  260. package/dist/utils/copyDirectory.js.map +0 -1
  261. package/dist/utils/createDirectory.d.ts +0 -34
  262. package/dist/utils/createDirectory.d.ts.map +0 -1
  263. package/dist/utils/createDirectory.js.map +0 -1
  264. package/dist/utils/createZip.d.ts +0 -39
  265. package/dist/utils/createZip.d.ts.map +0 -1
  266. package/dist/utils/createZip.js.map +0 -1
  267. package/dist/utils/deepCopy.d.ts +0 -32
  268. package/dist/utils/deepCopy.d.ts.map +0 -1
  269. package/dist/utils/deepCopy.js.map +0 -1
  270. package/dist/utils/deepEqual.d.ts +0 -54
  271. package/dist/utils/deepEqual.d.ts.map +0 -1
  272. package/dist/utils/deepEqual.js.map +0 -1
  273. package/dist/utils/error.d.ts +0 -44
  274. package/dist/utils/error.d.ts.map +0 -1
  275. package/dist/utils/error.js.map +0 -1
  276. package/dist/utils/export.d.ts +0 -13
  277. package/dist/utils/export.d.ts.map +0 -1
  278. package/dist/utils/export.js.map +0 -1
  279. package/dist/utils/format.d.ts +0 -53
  280. package/dist/utils/format.d.ts.map +0 -1
  281. package/dist/utils/format.js.map +0 -1
  282. package/dist/utils/hex.d.ts +0 -89
  283. package/dist/utils/hex.d.ts.map +0 -1
  284. package/dist/utils/hex.js.map +0 -1
  285. package/dist/utils/inspector.d.ts +0 -87
  286. package/dist/utils/inspector.d.ts.map +0 -1
  287. package/dist/utils/inspector.js.map +0 -1
  288. package/dist/utils/isvalid.d.ts +0 -103
  289. package/dist/utils/isvalid.d.ts.map +0 -1
  290. package/dist/utils/isvalid.js.map +0 -1
  291. package/dist/utils/jestHelpers.d.ts +0 -139
  292. package/dist/utils/jestHelpers.d.ts.map +0 -1
  293. package/dist/utils/jestHelpers.js.map +0 -1
  294. package/dist/utils/network.d.ts +0 -101
  295. package/dist/utils/network.d.ts.map +0 -1
  296. package/dist/utils/network.js.map +0 -1
  297. package/dist/utils/spawn.d.ts +0 -35
  298. package/dist/utils/spawn.d.ts.map +0 -1
  299. package/dist/utils/spawn.js.map +0 -1
  300. package/dist/utils/tracker.d.ts +0 -108
  301. package/dist/utils/tracker.d.ts.map +0 -1
  302. package/dist/utils/tracker.js.map +0 -1
  303. package/dist/utils/wait.d.ts +0 -54
  304. package/dist/utils/wait.d.ts.map +0 -1
  305. package/dist/utils/wait.js.map +0 -1
@@ -1,38 +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-next-line no-console
25
1
  if (process.argv.includes('--loader') || process.argv.includes('-loader'))
26
2
  console.log('\u001B[32mMatterbridgeEndpointHelpers loaded.\u001B[40;0m');
27
- // Other modules
28
3
  import { createHash } from 'node:crypto';
29
- // AnsiLogger module
30
4
  import { BLUE, CYAN, db, debugStringify, er, hk, or, YELLOW, zb } from 'node-ansi-logger';
31
- // @matter
32
5
  import { Lifecycle } from '@matter/general';
33
6
  import { MeasurementType } from '@matter/types/globals';
34
7
  import { getClusterNameById } from '@matter/types/cluster';
35
- // @matter clusters
36
8
  import { PowerSource } from '@matter/types/clusters/power-source';
37
9
  import { UserLabel } from '@matter/types/clusters/user-label';
38
10
  import { FixedLabel } from '@matter/types/clusters/fixed-label';
@@ -77,7 +49,6 @@ import { TotalVolatileOrganicCompoundsConcentrationMeasurement } from '@matter/t
77
49
  import { OperationalState } from '@matter/types/clusters/operational-state';
78
50
  import { DeviceEnergyManagement } from '@matter/types/clusters/device-energy-management';
79
51
  import { DeviceEnergyManagementMode } from '@matter/types/clusters/device-energy-management-mode';
80
- // @matter behaviors
81
52
  import { PowerSourceServer } from '@matter/node/behaviors/power-source';
82
53
  import { UserLabelServer } from '@matter/node/behaviors/user-label';
83
54
  import { FixedLabelServer } from '@matter/node/behaviors/fixed-label';
@@ -108,128 +79,58 @@ import { Pm10ConcentrationMeasurementServer } from '@matter/node/behaviors/pm10-
108
79
  import { RadonConcentrationMeasurementServer } from '@matter/node/behaviors/radon-concentration-measurement';
109
80
  import { TotalVolatileOrganicCompoundsConcentrationMeasurementServer } from '@matter/node/behaviors/total-volatile-organic-compounds-concentration-measurement';
110
81
  import { DeviceEnergyManagementServer } from '@matter/node/behaviors/device-energy-management';
111
- // Matterbridge
112
82
  import { deepCopy } from './utils/deepCopy.js';
113
83
  import { deepEqual } from './utils/deepEqual.js';
114
84
  import { isValidArray } from './utils/isvalid.js';
115
85
  import { MatterbridgeIdentifyServer, MatterbridgeOnOffServer, MatterbridgeLevelControlServer, MatterbridgeColorControlServer, MatterbridgeLiftWindowCoveringServer, MatterbridgeThermostatServer, MatterbridgeFanControlServer, MatterbridgeDoorLockServer, MatterbridgeModeSelectServer, MatterbridgeValveConfigurationAndControlServer, MatterbridgeSmokeCoAlarmServer, MatterbridgeBooleanStateConfigurationServer, MatterbridgeOperationalStateServer, MatterbridgeDeviceEnergyManagementModeServer, MatterbridgePowerSourceServer, MatterbridgeDeviceEnergyManagementServer, } from './matterbridgeBehaviors.js';
116
- /**
117
- * Capitalizes the first letter of a string.
118
- *
119
- * @param {string} name - The string to capitalize.
120
- * @returns {string} The string with the first letter capitalized.
121
- */
122
86
  export function capitalizeFirstLetter(name) {
123
87
  if (!name)
124
88
  return name;
125
89
  return name.charAt(0).toUpperCase() + name.slice(1);
126
90
  }
127
- /**
128
- * Lowercases the first letter of a string.
129
- *
130
- * @param {string} name - The string to lowercase the first letter of.
131
- * @returns {string} The string with the first letter lowercased.
132
- */
133
91
  export function lowercaseFirstLetter(name) {
134
92
  if (!name)
135
93
  return name;
136
94
  return name.charAt(0).toLowerCase() + name.slice(1);
137
95
  }
138
- /**
139
- * Checks if the device name contains non-Latin characters.
140
- *
141
- * @param {string} deviceName - The name of the device to check.
142
- * @returns {boolean} Returns true if the device name contains non-Latin characters, false otherwise.
143
- */
144
96
  export function checkNotLatinCharacters(deviceName) {
145
97
  const nonLatinRegexList = [
146
- /[\u0400-\u04FF\u0500-\u052F]/, // Cyrillic
147
- /[\u2E80-\u9FFF]/, // CJK (Chinese, Japanese, Korean)
148
- /[\uAC00-\uD7AF]/, // Korean Hangul
149
- /[\u0600-\u06FF\u0750-\u077F]/, // Arabic, Persian
150
- /[\u0590-\u05FF]/, // Hebrew
151
- /[\u0900-\u097F]/, // Devanagari (Hindi, Sanskrit)
152
- /[\u0E00-\u0E7F]/, // Thai
153
- /[\u1200-\u137F]/, // Ethiopic (Amharic, Tigrinya)
98
+ /[\u0400-\u04FF\u0500-\u052F]/,
99
+ /[\u2E80-\u9FFF]/,
100
+ /[\uAC00-\uD7AF]/,
101
+ /[\u0600-\u06FF\u0750-\u077F]/,
102
+ /[\u0590-\u05FF]/,
103
+ /[\u0900-\u097F]/,
104
+ /[\u0E00-\u0E7F]/,
105
+ /[\u1200-\u137F]/,
154
106
  ];
155
107
  return nonLatinRegexList.some((regex) => regex.test(deviceName));
156
108
  }
157
- /**
158
- * Generates a unique ID based on the device name.
159
- *
160
- * @param {string} deviceName - The name of the device to generate a unique ID for.
161
- * @returns {string} A unique ID generated from the device name using MD5 hashing.
162
- */
163
109
  export function generateUniqueId(deviceName) {
164
- return createHash('md5').update(deviceName).digest('hex'); // MD5 hash of the device name
110
+ return createHash('md5').update(deviceName).digest('hex');
165
111
  }
166
- /**
167
- * Generates a unique ID based on four parameters.
168
- *
169
- * @param {string} param1 - The first parameter.
170
- * @param {string} param2 - The second parameter.
171
- * @param {string} param3 - The third parameter.
172
- * @param {string} param4 - The fourth parameter.
173
- * @returns {string} A unique ID generated from the concatenation of the parameters using MD5 hashing.
174
- */
175
112
  export function createUniqueId(param1, param2, param3, param4) {
176
113
  const hash = createHash('md5');
177
114
  hash.update(param1 + param2 + param3 + param4);
178
115
  return hash.digest('hex');
179
116
  }
180
- /**
181
- * Retrieves the features for a specific behavior.
182
- *
183
- * @param {Endpoint} endpoint - The endpoint to retrieve the features from.
184
- * @param {string} behavior - The behavior to retrieve the features for.
185
- *
186
- * @returns {Record<string, boolean | undefined>} The features for the specified behavior.
187
- *
188
- * @remarks Use with:
189
- * ```typescript
190
- * expect(featuresFor(device, 'powerSource').wired).toBe(true);
191
- * ```
192
- */
193
117
  export function featuresFor(endpoint, behavior) {
194
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
195
118
  return endpoint.behaviors.supported[lowercaseFirstLetter(behavior)]['cluster']['supportedFeatures'];
196
119
  }
197
- /**
198
- * Maps a list of ClusterId to Behavior.Type for server clusters.
199
- *
200
- * @param {ClusterId[]} clusterServerList - The list of ClusterId to map.
201
- * @returns {Behavior.Type[]} An array of Behavior.Type corresponding to the ClusterId in the server list.
202
- */
203
120
  export function getBehaviourTypesFromClusterServerIds(clusterServerList) {
204
- // Map Server ClusterId to Behavior.Type
205
121
  const behaviorTypes = [];
206
122
  clusterServerList.forEach((clusterId) => {
207
123
  behaviorTypes.push(getBehaviourTypeFromClusterServerId(clusterId));
208
124
  });
209
125
  return behaviorTypes;
210
126
  }
211
- /**
212
- * Maps a list of ClusterId to Behavior.Type for client clusters.
213
- *
214
- * @param {ClusterId[]} clusterClientList - The list of ClusterId to map.
215
- * @returns {Behavior.Type[]} An array of Behavior.Type corresponding to the ClusterId in the client list.
216
- */
217
127
  export function getBehaviourTypesFromClusterClientIds(clusterClientList) {
218
- // Map Client ClusterId to Behavior.Type
219
128
  const behaviorTypes = [];
220
129
  clusterClientList.forEach((_clusterId) => {
221
- // behaviorTypes.push(getBehaviourTypeFromClusterClientId(clusterId));
222
130
  });
223
131
  return behaviorTypes;
224
132
  }
225
- /**
226
- * Maps a ClusterId to a Behavior.Type for server clusters.
227
- *
228
- * @param {ClusterId} clusterId - The ClusterId to map.
229
- * @returns {Behavior.Type} The corresponding Behavior.Type for the given ClusterId.
230
- */
231
133
  export function getBehaviourTypeFromClusterServerId(clusterId) {
232
- // Map ClusterId to Server Behavior.Type
233
134
  if (clusterId === PowerSource.Cluster.id)
234
135
  return PowerSourceServer.with(PowerSource.Feature.Wired);
235
136
  if (clusterId === UserLabel.Cluster.id)
@@ -320,22 +221,8 @@ export function getBehaviourTypeFromClusterServerId(clusterId) {
320
221
  return MatterbridgeDeviceEnergyManagementModeServer;
321
222
  return MatterbridgeIdentifyServer;
322
223
  }
323
- /**
324
- * Maps a ClusterId to a Behavior.Type for client clusters.
325
- *
326
- * @param {ClusterId} _clusterId - The ClusterId to map.
327
- */
328
224
  export function getBehaviourTypeFromClusterClientId(_clusterId) {
329
- // Map ClusterId to Client Behavior.Type
330
- // return IdentifyClient;
331
225
  }
332
- /**
333
- * Retrieves the Behavior.Type for a given cluster from the endpoint's supported behaviors.
334
- *
335
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to retrieve the behavior from.
336
- * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to retrieve the behavior for.
337
- * @returns {Behavior.Type | undefined} The Behavior.Type for the given cluster, or undefined if not found.
338
- */
339
226
  export function getBehavior(endpoint, cluster) {
340
227
  let behavior;
341
228
  if (typeof cluster === 'string') {
@@ -352,18 +239,6 @@ export function getBehavior(endpoint, cluster) {
352
239
  }
353
240
  return behavior;
354
241
  }
355
- /**
356
- * Invokes a command on the specified behavior of the endpoint. Used ONLY in Jest tests.
357
- *
358
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to invoke the command on.
359
- * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to invoke the command on.
360
- * @param {keyof MatterbridgeEndpointCommands} command - The command to invoke.
361
- * @param {Record<string, boolean | number | bigint | string | object | null>} [params] - The parameters to pass to the command.
362
- *
363
- * @returns {Promise<boolean>} A promise that resolves to true if the command was invoked successfully, false otherwise.
364
- *
365
- * @deprecated Used ONLY in Jest tests.
366
- */
367
242
  export async function invokeBehaviorCommand(endpoint, cluster, command, params) {
368
243
  const behaviorId = getBehavior(endpoint, cluster)?.id;
369
244
  if (!behaviorId) {
@@ -371,7 +246,6 @@ export async function invokeBehaviorCommand(endpoint, cluster, command, params)
371
246
  return false;
372
247
  }
373
248
  await endpoint.act((agent) => {
374
- // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
375
249
  const behavior = agent[behaviorId];
376
250
  if (!(command in behavior) || typeof behavior[command] !== 'function') {
377
251
  endpoint.log?.error(`invokeBehaviorCommand error: command ${hk}${command}${er} not found on agent for endpoint ${or}${endpoint.maybeId}${er}:${or}${endpoint.maybeNumber}${er}`);
@@ -381,19 +255,6 @@ export async function invokeBehaviorCommand(endpoint, cluster, command, params)
381
255
  });
382
256
  return true;
383
257
  }
384
- /**
385
- * Invokes the subscription handler on the specified cluster and attribute of the endpoint. Used ONLY in Jest tests.
386
- *
387
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to invoke the subscription handler on.
388
- * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to invoke the subscription handler on.
389
- * @param {string} attribute - The attribute to invoke the subscription handler on.
390
- * @param {unknown} newValue - The new value of the attribute.
391
- * @param {unknown} oldValue - The old value of the attribute.
392
- *
393
- * @returns {Promise<boolean>} A promise that resolves to true if the subscription handler was invoked successfully, false otherwise.
394
- *
395
- * @deprecated Used ONLY in Jest tests.
396
- */
397
258
  export async function invokeSubscribeHandler(endpoint, cluster, attribute, newValue, oldValue) {
398
259
  const event = attribute + '$Changed';
399
260
  const clusterName = getBehavior(endpoint, cluster)?.id;
@@ -410,17 +271,9 @@ export async function invokeSubscribeHandler(endpoint, cluster, attribute, newVa
410
271
  endpoint.log.error(`invokeSubscribeHandler ${hk}${event}${er} error: cluster ${clusterName} not found on endpoint ${or}${endpoint.id}${er}:${or}${endpoint.number}${er}`);
411
272
  return false;
412
273
  }
413
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
414
- // @ts-ignore
415
274
  await endpoint.act((agent) => agent[clusterName].events[event].emit(newValue, oldValue, { ...agent.context, offline: false }));
416
275
  return true;
417
276
  }
418
- /**
419
- * Adds required cluster servers to the specified endpoint based on the device types.
420
- *
421
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to add the required cluster servers to.
422
- * @returns {void}
423
- */
424
277
  export function addRequiredClusterServers(endpoint) {
425
278
  const requiredServerList = [];
426
279
  endpoint.log.debug(`addRequiredClusterServers for ${CYAN}${endpoint.maybeId}${db}`);
@@ -435,12 +288,6 @@ export function addRequiredClusterServers(endpoint) {
435
288
  });
436
289
  addClusterServers(endpoint, requiredServerList);
437
290
  }
438
- /**
439
- * Adds optional cluster servers to the specified endpoint based on the device types.
440
- *
441
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to add the optional cluster servers to.
442
- * @returns {void}
443
- */
444
291
  export function addOptionalClusterServers(endpoint) {
445
292
  const optionalServerList = [];
446
293
  endpoint.log.debug(`addOptionalClusterServers for ${CYAN}${endpoint.maybeId}${db}`);
@@ -455,12 +302,6 @@ export function addOptionalClusterServers(endpoint) {
455
302
  });
456
303
  addClusterServers(endpoint, optionalServerList);
457
304
  }
458
- /**
459
- * Adds cluster servers to the specified endpoint based on the provided server list.
460
- *
461
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to add the cluster servers to.
462
- * @param {ClusterId[]} serverList - The list of cluster IDs to add.
463
- */
464
305
  export function addClusterServers(endpoint, serverList) {
465
306
  if (serverList.includes(PowerSource.Cluster.id))
466
307
  endpoint.createDefaultPowerSourceWiredClusterServer();
@@ -541,13 +382,6 @@ export function addClusterServers(endpoint, serverList) {
541
382
  if (serverList.includes(DeviceEnergyManagementMode.Cluster.id))
542
383
  endpoint.createDefaultDeviceEnergyManagementModeClusterServer();
543
384
  }
544
- /**
545
- * Adds a fixed label to the FixedLabel cluster. The FixedLabel cluster is created if it does not exist.
546
- *
547
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to add the cluster servers to.
548
- * @param {string} label - The label to add. Max 16 characters.
549
- * @param {string} value - The value of the label. Max 16 characters.
550
- */
551
385
  export async function addFixedLabel(endpoint, label, value) {
552
386
  if (!endpoint.hasClusterServer(FixedLabel.Cluster.id)) {
553
387
  endpoint.log.debug(`addFixedLabel: add cluster ${hk}FixedLabel${db}:${hk}fixedLabel${db} with label ${CYAN}${label}${db} value ${CYAN}${value}${db}`);
@@ -564,13 +398,6 @@ export async function addFixedLabel(endpoint, label, value) {
564
398
  await endpoint.setAttribute(FixedLabel.Cluster.id, 'labelList', labelList, endpoint.log);
565
399
  }
566
400
  }
567
- /**
568
- * Adds a user label to the UserLabel cluster. The UserLabel cluster is created if it does not exist.
569
- *
570
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to add the cluster servers to.
571
- * @param {string} label - The label to add. Max 16 characters.
572
- * @param {string} value - The value of the label. Max 16 characters.
573
- */
574
401
  export async function addUserLabel(endpoint, label, value) {
575
402
  if (!endpoint.hasClusterServer(UserLabel.Cluster.id)) {
576
403
  endpoint.log.debug(`addUserLabel: add cluster ${hk}UserLabel${db}:${hk}userLabel${db} with label ${CYAN}${label}${db} value ${CYAN}${value}${db}`);
@@ -587,48 +414,16 @@ export async function addUserLabel(endpoint, label, value) {
587
414
  await endpoint.setAttribute(UserLabel.Cluster.id, 'labelList', labelList, endpoint.log);
588
415
  }
589
416
  }
590
- /**
591
- * Returns the options for a given behavior type.
592
- *
593
- * @param {T} type - The behavior type.
594
- * @param {Behavior.Options<T>} options - The options for the behavior type.
595
- * @returns {Behavior.Options<T>} The options for the behavior type.
596
- */
597
417
  export function optionsFor(type, options) {
598
418
  return options;
599
419
  }
600
- /**
601
- * Retrieves the cluster ID.
602
- *
603
- * @param {Endpoint} endpoint - The endpoint to retrieve the cluster ID from.
604
- * @param {ClusterId} cluster - The ID of the cluster.
605
- * @returns {number | undefined} The ID of the cluster.
606
- */
607
420
  export function getClusterId(endpoint, cluster) {
608
421
  return endpoint.behaviors.supported[lowercaseFirstLetter(cluster)]?.schema?.id;
609
422
  }
610
- /**
611
- * Retrieves the ID of an attribute from a cluster behavior.
612
- *
613
- * @param {Endpoint} endpoint - The endpoint to retrieve the attribute ID from.
614
- * @param {string} cluster - The name of the cluster.
615
- * @param {string} attribute - The name of the attribute.
616
- * @returns {number | undefined} The ID of the attribute, or undefined if not found.
617
- */
618
423
  export function getAttributeId(endpoint, cluster, attribute) {
619
424
  const clusterBehavior = endpoint.behaviors.supported[lowercaseFirstLetter(cluster)];
620
425
  return clusterBehavior?.cluster?.attributes[lowercaseFirstLetter(attribute)]?.id;
621
426
  }
622
- /**
623
- * Retrieves the value of the provided attribute from the given cluster.
624
- *
625
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to retrieve the attribute from.
626
- * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to retrieve the attribute from.
627
- * @param {string} attribute - The name of the attribute to retrieve.
628
- * @param {AnsiLogger} [log] - (Optional) The logger to use for logging the retrieve. Errors are logged to the endpoint logger.
629
- * @returns {any} The value of the attribute, or undefined if the attribute is not found.
630
- */
631
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
632
427
  export function getAttribute(endpoint, cluster, attribute, log) {
633
428
  const clusterName = getBehavior(endpoint, cluster)?.id;
634
429
  if (!clusterName) {
@@ -651,16 +446,6 @@ export function getAttribute(endpoint, cluster, attribute, log) {
651
446
  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}`);
652
447
  return value;
653
448
  }
654
- /**
655
- * Sets the value of an attribute on a cluster server.
656
- *
657
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to set the attribute on.
658
- * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to set the attribute on.
659
- * @param {string} attribute - The name of the attribute.
660
- * @param {boolean | number | bigint | string | object | null} value - The value to set for the attribute.
661
- * @param {AnsiLogger} [log] - (Optional) The logger to use for logging the set. Errors are logged to the endpoint logger.
662
- * @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the attribute was successfully set.
663
- */
664
449
  export async function setAttribute(endpoint, cluster, attribute, value, log) {
665
450
  const clusterName = getBehavior(endpoint, cluster)?.id;
666
451
  if (!clusterName) {
@@ -686,16 +471,6 @@ export async function setAttribute(endpoint, cluster, attribute, value, log) {
686
471
  `to ${YELLOW}${value !== null && typeof value === 'object' ? debugStringify(value) : value}${db}`);
687
472
  return true;
688
473
  }
689
- /**
690
- * Sets the value of an attribute on a cluster server.
691
- *
692
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to update the attribute on.
693
- * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to update the attribute on.
694
- * @param {string} attribute - The name of the attribute.
695
- * @param {boolean | number | bigint | string | object | null} value - The value to set for the attribute.
696
- * @param {AnsiLogger} [log] - (Optional) The logger to use for logging the update. Errors are logged to the endpoint logger.
697
- * @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the attribute was successfully set.
698
- */
699
474
  export async function updateAttribute(endpoint, cluster, attribute, value, log) {
700
475
  const clusterName = getBehavior(endpoint, cluster)?.id;
701
476
  if (!clusterName) {
@@ -726,24 +501,7 @@ export async function updateAttribute(endpoint, cluster, attribute, value, log)
726
501
  `to ${YELLOW}${value !== null && typeof value === 'object' ? debugStringify(value) : value}${db}`);
727
502
  return true;
728
503
  }
729
- /**
730
- * Subscribes to the provided attribute on a cluster.
731
- *
732
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to subscribe the attribute to.
733
- * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to subscribe the attribute to.
734
- * @param {string} attribute - The name of the attribute to subscribe to.
735
- * @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.
736
- * @param {AnsiLogger} [log] - Optional logger for logging errors and information.
737
- * @returns {boolean} - A boolean indicating whether the subscription was successful.
738
- *
739
- * @remarks The listener function (cannot be async) will receive three parameters:
740
- * - `newValue`: The new value of the attribute.
741
- * - `oldValue`: The old value of the attribute.
742
- * - `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.
743
- */
744
- export async function subscribeAttribute(endpoint, cluster, attribute,
745
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
746
- listener, log) {
504
+ export async function subscribeAttribute(endpoint, cluster, attribute, listener, log) {
747
505
  const clusterName = getBehavior(endpoint, cluster)?.id;
748
506
  if (!clusterName) {
749
507
  endpoint.log.error(`subscribeAttribute ${hk}${attribute}${er} error: cluster not found on endpoint ${or}${endpoint.maybeId}${er}:${or}${endpoint.maybeNumber}${er}`);
@@ -753,7 +511,6 @@ listener, log) {
753
511
  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`);
754
512
  await endpoint.construction.ready;
755
513
  }
756
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
757
514
  const events = endpoint.events;
758
515
  attribute = lowercaseFirstLetter(attribute) + '$Changed';
759
516
  if (!(clusterName in events) || !(attribute in events[clusterName])) {
@@ -764,17 +521,6 @@ listener, log) {
764
521
  log?.info(`${db}Subscribed endpoint ${or}${endpoint.id}${db}:${or}${endpoint.number}${db} attribute ${hk}${capitalizeFirstLetter(clusterName)}${db}.${hk}${attribute}${db}`);
765
522
  return true;
766
523
  }
767
- /**
768
- * Triggers an event on the specified cluster.
769
- *
770
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to trigger the event on.
771
- * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The ID of the cluster.
772
- * @param {string} event - The name of the event to trigger.
773
- * @param {Record<string, boolean | number | bigint | string | object | undefined | null>} payload - The payload to pass to the event.
774
- * @param {AnsiLogger} [log] - Optional logger for logging information.
775
- *
776
- * @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the event was successfully triggered.
777
- */
778
524
  export async function triggerEvent(endpoint, cluster, event, payload, log) {
779
525
  const clusterName = getBehavior(endpoint, cluster)?.id;
780
526
  if (!clusterName) {
@@ -785,120 +531,58 @@ export async function triggerEvent(endpoint, cluster, event, payload, log) {
785
531
  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`);
786
532
  return false;
787
533
  }
788
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
789
534
  const events = endpoint.events;
790
535
  if (!(clusterName in events) || !(event in events[clusterName])) {
791
536
  endpoint.log.error(`triggerEvent ${hk}${event}${er} error: cluster ${clusterName} not found on endpoint ${or}${endpoint.id}${er}:${or}${endpoint.number}${er}`);
792
537
  return false;
793
538
  }
794
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
795
- // @ts-ignore
796
539
  await endpoint.act((agent) => agent[clusterName].events[event].emit(payload, agent.context));
797
540
  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} `);
798
541
  return true;
799
542
  }
800
- /** Utility Cluster Helpers */
801
- /**
802
- * Get the default power source wired cluster server options.
803
- *
804
- * @param {PowerSource.WiredCurrentType} wiredCurrentType - The type of wired current (default: PowerSource.WiredCurrentType.Ac)
805
- * @returns {Behavior.Options<PowerSourceClusterServer>} The options for the power source wired cluster server.
806
- *
807
- * @remarks
808
- * - order: The order of the power source is a persisted attribute that indicates the order in which the power sources are used.
809
- * - description: The description of the power source is a fixed attribute that describes the power source type.
810
- * - 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).
811
- */
812
543
  export function getDefaultPowerSourceWiredClusterServer(wiredCurrentType = PowerSource.WiredCurrentType.Ac) {
813
544
  return optionsFor(MatterbridgePowerSourceServer.with(PowerSource.Feature.Wired), {
814
- // Base attributes
815
545
  status: PowerSource.PowerSourceStatus.Active,
816
546
  order: 0,
817
547
  description: wiredCurrentType === PowerSource.WiredCurrentType.Ac ? 'AC Power' : 'DC Power',
818
- endpointList: [], // Will be filled by the MatterbridgePowerSourceServer
819
- // Wired feature attributes
548
+ endpointList: [],
820
549
  wiredCurrentType,
821
550
  });
822
551
  }
823
- /**
824
- * Get the default power source replaceable battery cluster server options.
825
- *
826
- * @param {number} batPercentRemaining - The remaining battery percentage (default: 100). The attribute is in the range 0-200.
827
- * @param {PowerSource.BatChargeLevel} batChargeLevel - The battery charge level (default: PowerSource.BatChargeLevel.Ok).
828
- * @param {number} batVoltage - The battery voltage (default: 1500).
829
- * @param {string} batReplacementDescription - The description of the battery replacement (default: 'Battery type').
830
- * @param {number} batQuantity - The quantity of the battery (default: 1).
831
- * @param {PowerSource.BatReplaceability} batReplaceability - The replaceability of the battery (default: PowerSource.BatReplaceability.Unspecified).
832
- * @returns {Behavior.Options<PowerSourceClusterServer>} The options for the power source replaceable battery cluster server.
833
- *
834
- * @remarks
835
- * - order: The order of the power source is a persisted attribute that indicates the order in which the power sources are used.
836
- * - description: The description of the power source is a fixed attribute that describes the power source type.
837
- * - batReplaceability: The replaceability of the battery is a fixed attribute that indicates whether the battery is user-replaceable or not.
838
- * - batReplacementDescription: The description of the battery replacement is a fixed attribute that describes the battery type.
839
- * - batQuantity: The quantity of the battery is a fixed attribute that indicates how many batteries are present in the device.
840
- */
841
552
  export function getDefaultPowerSourceReplaceableBatteryClusterServer(batPercentRemaining = 100, batChargeLevel = PowerSource.BatChargeLevel.Ok, batVoltage = 1500, batReplacementDescription = 'Battery type', batQuantity = 1, batReplaceability = PowerSource.BatReplaceability.UserReplaceable) {
842
553
  return optionsFor(MatterbridgePowerSourceServer.with(PowerSource.Feature.Battery, PowerSource.Feature.Replaceable), {
843
- // Base attributes
844
554
  status: PowerSource.PowerSourceStatus.Active,
845
555
  order: 0,
846
556
  description: 'Primary battery',
847
- endpointList: [], // Will be filled by the MatterbridgePowerSourceServer
848
- // Battery feature attributes
557
+ endpointList: [],
849
558
  batVoltage,
850
559
  batPercentRemaining: Math.min(Math.max(batPercentRemaining * 2, 0), 200),
851
560
  batChargeLevel,
852
561
  batReplacementNeeded: false,
853
562
  batReplaceability,
854
563
  activeBatFaults: undefined,
855
- // Replaceable feature attributes
856
564
  batReplacementDescription,
857
565
  batQuantity,
858
566
  });
859
567
  }
860
- /**
861
- * Creates a default power source rechargeable battery cluster server.
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 in mV (default: 1500).
866
- * @param {PowerSource.BatReplaceability} [batReplaceability] - The replaceability of the battery (default: PowerSource.BatReplaceability.Unspecified).
867
- * @returns {Behavior.Options<PowerSourceClusterServer>} The options for the power source rechargeable battery cluster server.
868
- *
869
- * @remarks
870
- * - order: The order of the power source is a persisted attribute that indicates the order in which the power sources are used.
871
- * - description: The description of the power source is a fixed attribute that describes the power source type.
872
- * - batReplaceability: The replaceability of the battery is a fixed attribute that indicates whether the battery is user-replaceable or not.
873
- */
874
568
  export function getDefaultPowerSourceRechargeableBatteryClusterServer(batPercentRemaining = 100, batChargeLevel = PowerSource.BatChargeLevel.Ok, batVoltage = 1500, batReplaceability = PowerSource.BatReplaceability.Unspecified) {
875
569
  return optionsFor(MatterbridgePowerSourceServer.with(PowerSource.Feature.Battery, PowerSource.Feature.Rechargeable), {
876
- // Base attributes
877
570
  status: PowerSource.PowerSourceStatus.Active,
878
571
  order: 0,
879
572
  description: 'Primary battery',
880
- endpointList: [], // Will be filled by the MatterbridgePowerSourceServer
881
- // Battery feature attributes
573
+ endpointList: [],
882
574
  batVoltage,
883
575
  batPercentRemaining: Math.min(Math.max(batPercentRemaining * 2, 0), 200),
884
- batTimeRemaining: null, // Indicates the estimated time in seconds before the battery will no longer be able to provide power to the Node
576
+ batTimeRemaining: null,
885
577
  batChargeLevel,
886
578
  batReplacementNeeded: false,
887
579
  batReplaceability,
888
580
  batPresent: true,
889
581
  activeBatFaults: [],
890
- // Rechargeable feature attributes
891
582
  batChargeState: PowerSource.BatChargeState.IsNotCharging,
892
583
  batFunctionalWhileCharging: true,
893
584
  });
894
585
  }
895
- /**
896
- * Get the default Electrical Energy Measurement Cluster Server options with features ImportedEnergy, ExportedEnergy, and CumulativeEnergy.
897
- *
898
- * @param {number} energyImported - The total consumption value in mW/h.
899
- * @param {number} energyExported - The total production value in mW/h.
900
- * @returns {Behavior.Options<ElectricalEnergyMeasurementServer>} - The default options for the Electrical Energy Measurement Cluster Server.
901
- */
902
586
  export function getDefaultElectricalEnergyMeasurementClusterServer(energyImported = null, energyExported = null) {
903
587
  return optionsFor(ElectricalEnergyMeasurementServer.with(ElectricalEnergyMeasurement.Feature.ImportedEnergy, ElectricalEnergyMeasurement.Feature.ExportedEnergy, ElectricalEnergyMeasurement.Feature.CumulativeEnergy), {
904
588
  accuracy: {
@@ -913,15 +597,6 @@ export function getDefaultElectricalEnergyMeasurementClusterServer(energyImporte
913
597
  cumulativeEnergyExported: energyExported !== null && energyExported >= 0 ? { energy: energyExported } : null,
914
598
  });
915
599
  }
916
- /**
917
- * Get the default Electrical Power Measurement Cluster Server options with features AlternatingCurrent.
918
- *
919
- * @param {number} voltage - The voltage value in millivolts.
920
- * @param {number} current - The current value in milliamperes.
921
- * @param {number} power - The power value in milliwatts.
922
- * @param {number} frequency - The frequency value in millihertz.
923
- * @returns {Behavior.Options<ElectricalPowerMeasurementServer>} - The default options for the Electrical Power Measurement Cluster Server.
924
- */
925
600
  export function getDefaultElectricalPowerMeasurementClusterServer(voltage = null, current = null, power = null, frequency = null) {
926
601
  return optionsFor(ElectricalPowerMeasurementServer.with(ElectricalPowerMeasurement.Feature.AlternatingCurrent), {
927
602
  powerMode: ElectricalPowerMeasurement.PowerMode.Ac,
@@ -962,15 +637,6 @@ export function getDefaultElectricalPowerMeasurementClusterServer(voltage = null
962
637
  frequency: frequency,
963
638
  });
964
639
  }
965
- /**
966
- * Get the default Electrical Apparent Power Measurement Cluster Server with features AlternatingCurrent.
967
- *
968
- * @param {number} voltage - The voltage value in millivolts.
969
- * @param {number} apparentCurrent - The current value in milliamperes.
970
- * @param {number} apparentPower - The apparent power value in millivoltamperes.
971
- * @param {number} frequency - The frequency value in millihertz.
972
- * @returns {Behavior.Options<ElectricalPowerMeasurementServer>} - The default options for the Electrical Apparent Power Measurement Cluster Server.
973
- */
974
640
  export function getApparentElectricalPowerMeasurementClusterServer(voltage = null, apparentCurrent = null, apparentPower = null, frequency = null) {
975
641
  return optionsFor(ElectricalPowerMeasurementServer.with(ElectricalPowerMeasurement.Feature.AlternatingCurrent), {
976
642
  powerMode: ElectricalPowerMeasurement.PowerMode.Ac,
@@ -1011,53 +677,18 @@ export function getApparentElectricalPowerMeasurementClusterServer(voltage = nul
1011
677
  frequency: frequency,
1012
678
  });
1013
679
  }
1014
- /**
1015
- * Get the default Device Energy Management Cluster Server with feature PowerForecastReporting and with the specified ESA type, ESA canGenerate, ESA state, and power limits.
1016
- *
1017
- * @param {DeviceEnergyManagement.EsaType} [esaType] - The ESA type. Defaults to `DeviceEnergyManagement.EsaType.Other`.
1018
- * @param {boolean} [esaCanGenerate] - Indicates if the ESA can generate energy. Defaults to `false`.
1019
- * @param {DeviceEnergyManagement.EsaState} [esaState] - The ESA state. Defaults to `DeviceEnergyManagement.EsaState.Online`.
1020
- * @param {number} [absMinPower] - Indicate the minimum electrical power in mw that the ESA can consume when switched on. Defaults to `0` if not provided.
1021
- * @param {number} [absMaxPower] - Indicate the maximum electrical power in mw that the ESA can consume when switched on. Defaults to `0` if not provided.
1022
- * @returns {Behavior.Options<DeviceEnergyManagementClusterServer>} - The default options for the Device Energy Management Cluster Server.
1023
- *
1024
- * @remarks
1025
- * - The forecast attribute is set to null, indicating that there is no forecast currently available.
1026
- * - The ESA type and canGenerate attributes are fixed and cannot be changed after creation.
1027
- * - The ESA state is set to Online by default.
1028
- * - The absolute minimum and maximum power attributes are set to 0 by default.
1029
- * - For example, a battery storage inverter that can charge its battery at a maximum power of 2000W and can
1030
- * discharge the battery at a maximum power of 3000W, would have a absMinPower: -3000W, absMaxPower: 2000W.
1031
- */
1032
680
  export function getDefaultDeviceEnergyManagementClusterServer(esaType = DeviceEnergyManagement.EsaType.Other, esaCanGenerate = false, esaState = DeviceEnergyManagement.EsaState.Online, absMinPower = 0, absMaxPower = 0) {
1033
681
  return optionsFor(MatterbridgeDeviceEnergyManagementServer.with(DeviceEnergyManagement.Feature.PowerForecastReporting, DeviceEnergyManagement.Feature.PowerAdjustment), {
1034
- esaType, // Fixed attribute
1035
- esaCanGenerate, // Fixed attribute
682
+ esaType,
683
+ esaCanGenerate,
1036
684
  esaState,
1037
685
  absMinPower,
1038
686
  absMaxPower,
1039
- // PowerAdjustment feature (commands: powerAdjustRequest and cancelPowerAdjustRequest events: powerAdjustStart and powerAdjustEnd)
1040
- powerAdjustmentCapability: null, // A null value indicates that no power adjustment is currently possible, and nor is any adjustment currently active
687
+ powerAdjustmentCapability: null,
1041
688
  optOutState: DeviceEnergyManagement.OptOutState.NoOptOut,
1042
- // PowerForecastReporting
1043
- forecast: null, // A null value indicates that there is no forecast currently available
689
+ forecast: null,
1044
690
  });
1045
691
  }
1046
- /**
1047
- * Get the default EnergyManagementMode Cluster Server.
1048
- *
1049
- * @param {number} [currentMode] - The current mode of the EnergyManagementMode cluster. Defaults to mode 1 (DeviceEnergyManagementMode.ModeTag.NoOptimization).
1050
- * @param {EnergyManagementMode.ModeOption[]} [supportedModes] - The supported modes for the DeviceEnergyManagementMode cluster. The attribute is fixed and defaults to a predefined set of cluster modes.
1051
- * @returns {Behavior.Options<DeviceEnergyManagementModeClusterServer>} - The default options for the Device Energy Management Mode cluster server.
1052
- *
1053
- * @remarks
1054
- * A few examples of Device Energy Management modes and their mode tags are provided below.
1055
- * - For the "No Energy Management (Forecast reporting only)" mode, tags: 0x4000 (NoOptimization).
1056
- * - For the "Device Energy Management" mode, tags: 0x4001 (DeviceOptimization).
1057
- * - For the "Home Energy Management" mode, tags: 0x4001 (DeviceOptimization), 0x4002 (LocalOptimization).
1058
- * - For the "Grid Energy Management" mode, tags: 0x4003 (GridOptimization).
1059
- * - For the "Full Energy Management" mode, tags: 0x4001 (DeviceOptimization), 0x4002 (LocalOptimization), 0x4003 (GridOptimization).
1060
- */
1061
692
  export function getDefaultDeviceEnergyManagementModeClusterServer(currentMode, supportedModes) {
1062
693
  return optionsFor(MatterbridgeDeviceEnergyManagementModeServer, {
1063
694
  supportedModes: supportedModes ?? [
@@ -1078,24 +709,10 @@ export function getDefaultDeviceEnergyManagementModeClusterServer(currentMode, s
1078
709
  mode: 5,
1079
710
  modeTags: [{ value: DeviceEnergyManagementMode.ModeTag.DeviceOptimization }, { value: DeviceEnergyManagementMode.ModeTag.LocalOptimization }, { value: DeviceEnergyManagementMode.ModeTag.GridOptimization }],
1080
711
  },
1081
- ], // Fixed attribute
712
+ ],
1082
713
  currentMode: currentMode ?? 1,
1083
714
  });
1084
715
  }
1085
- /** Application Cluster Helpers */
1086
- /**
1087
- * Get the default OperationalState Cluster Server.
1088
- *
1089
- * @param {OperationalState.OperationalStateEnum} operationalState - The initial operational state id.
1090
- * @returns {Behavior.Options<MatterbridgeOperationalStateServer>} - The default options for the OperationalState cluster server.
1091
- *
1092
- * @remarks
1093
- * This method adds a cluster server with a default operational state configuration:
1094
- * - { operationalStateId: OperationalState.OperationalStateEnum.Stopped, operationalStateLabel: 'Stopped' },
1095
- * - { operationalStateId: OperationalState.OperationalStateEnum.Running, operationalStateLabel: 'Running' },
1096
- * - { operationalStateId: OperationalState.OperationalStateEnum.Paused, operationalStateLabel: 'Paused' },
1097
- * - { operationalStateId: OperationalState.OperationalStateEnum.Error, operationalStateLabel: 'Error' },
1098
- */
1099
716
  export function getDefaultOperationalStateClusterServer(operationalState = OperationalState.OperationalStateEnum.Stopped) {
1100
717
  return optionsFor(MatterbridgeOperationalStateServer, {
1101
718
  phaseList: [],
@@ -1111,14 +728,6 @@ export function getDefaultOperationalStateClusterServer(operationalState = Opera
1111
728
  operationalError: { errorStateId: OperationalState.ErrorState.NoError, errorStateLabel: 'No error', errorStateDetails: 'Fully operational' },
1112
729
  });
1113
730
  }
1114
- /**
1115
- * Get the default TemperatureMeasurement cluster server options.
1116
- *
1117
- * @param {number | null} measuredValue - The measured value of the temperature x 100.
1118
- * @param {number | null} minMeasuredValue - The minimum measured value of the temperature x 100.
1119
- * @param {number | null} maxMeasuredValue - The maximum measured value of the temperature x 100.
1120
- * @returns {Behavior.Options<MatterbridgeTemperatureMeasurementServer>} - The default options for the TemperatureMeasurement cluster server.
1121
- */
1122
731
  export function getDefaultTemperatureMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
1123
732
  return optionsFor(TemperatureMeasurementServer, {
1124
733
  measuredValue,
@@ -1127,14 +736,6 @@ export function getDefaultTemperatureMeasurementClusterServer(measuredValue = nu
1127
736
  tolerance: 0,
1128
737
  });
1129
738
  }
1130
- /**
1131
- * Get the default RelativeHumidityMeasurement cluster server options.
1132
- *
1133
- * @param {number | null} measuredValue - The measured value of the relative humidity x 100.
1134
- * @param {number | null} minMeasuredValue - The minimum measured value of the relative humidity x 100.
1135
- * @param {number | null} maxMeasuredValue - The maximum measured value of the relative humidity x 100.
1136
- * @returns {Behavior.Options<MatterbridgeRelativeHumidityMeasurementServer>} - The default options for the RelativeHumidityMeasurement cluster server.
1137
- */
1138
739
  export function getDefaultRelativeHumidityMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
1139
740
  return optionsFor(RelativeHumidityMeasurementServer, {
1140
741
  measuredValue,
@@ -1143,14 +744,6 @@ export function getDefaultRelativeHumidityMeasurementClusterServer(measuredValue
1143
744
  tolerance: 0,
1144
745
  });
1145
746
  }
1146
- /**
1147
- * Get the default PressureMeasurement cluster server options.
1148
- *
1149
- * @param {number | null} measuredValue - The measured value for the pressure in kPa x 10.
1150
- * @param {number | null} minMeasuredValue - The minimum measured value for the pressure in kPa x 10.
1151
- * @param {number | null} maxMeasuredValue - The maximum measured value for the pressure in kPa x 10.
1152
- * @returns {Behavior.Options<MatterbridgePressureMeasurementServer>} - The default options for the PressureMeasurement cluster server.
1153
- */
1154
747
  export function getDefaultPressureMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
1155
748
  return optionsFor(PressureMeasurementServer, {
1156
749
  measuredValue,
@@ -1159,21 +752,6 @@ export function getDefaultPressureMeasurementClusterServer(measuredValue = null,
1159
752
  tolerance: 0,
1160
753
  });
1161
754
  }
1162
- /**
1163
- * Get the default IlluminanceMeasurement cluster server options.
1164
- *
1165
- * @param {number | null} measuredValue - The measured value of illuminance.
1166
- * @param {number | null} minMeasuredValue - The minimum measured value of illuminance.
1167
- * @param {number | null} maxMeasuredValue - The maximum measured value of illuminance.
1168
- * @returns {Behavior.Options<MatterbridgeIlluminanceMeasurementServer>} - The default options for the IlluminanceMeasurement cluster server.
1169
- *
1170
- * @remarks The default value for the illuminance measurement is null.
1171
- * This attribute SHALL indicate the illuminance in Lux (symbol lx) as follows:
1172
- * • MeasuredValue = 10,000 x log10(illuminance) + 1,
1173
- * where 1 lx <= illuminance <= 3.576 Mlx, corresponding to a MeasuredValue in the range 1 to 0xFFFE.
1174
- * • 0 indicates a value of illuminance that is too low to be measured
1175
- * • null indicates that the illuminance measurement is invalid.
1176
- */
1177
755
  export function getDefaultIlluminanceMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
1178
756
  return optionsFor(IlluminanceMeasurementServer, {
1179
757
  measuredValue,
@@ -1182,14 +760,6 @@ export function getDefaultIlluminanceMeasurementClusterServer(measuredValue = nu
1182
760
  tolerance: 0,
1183
761
  });
1184
762
  }
1185
- /**
1186
- * Get the default FlowMeasurement cluster server options.
1187
- *
1188
- * @param {number | null} measuredValue - The measured value of the flow in 10 x m3/h.
1189
- * @param {number | null} minMeasuredValue - The minimum measured value of the flow in 10 x m3/h.
1190
- * @param {number | null} maxMeasuredValue - The maximum measured value of the flow in 10 x m3/h.
1191
- * @returns {Behavior.Options<MatterbridgeFlowMeasurementServer>} - The default options for the FlowMeasurement cluster server.
1192
- */
1193
763
  export function getDefaultFlowMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
1194
764
  return optionsFor(FlowMeasurementServer, {
1195
765
  measuredValue,
@@ -1198,20 +768,6 @@ export function getDefaultFlowMeasurementClusterServer(measuredValue = null, min
1198
768
  tolerance: 0,
1199
769
  });
1200
770
  }
1201
- /**
1202
- * Get the default OccupancySensing cluster server options.
1203
- *
1204
- * @param {boolean} occupied - A boolean indicating whether the occupancy is occupied or not. Default is false.
1205
- * @param {number} holdTime - The hold time in seconds. Default is 30.
1206
- * @param {number} holdTimeMin - The minimum hold time in seconds. Default is 1.
1207
- * @param {number} holdTimeMax - The maximum hold time in seconds. Default is 300.
1208
- * @returns {Behavior.Options<MatterbridgeOccupancySensingServer>} - The default options for the OccupancySensing cluster server.
1209
- *
1210
- * @remarks The default value for the occupancy sensor type is PIR.
1211
- * Servers SHALL set these attributes for backward compatibility with clients implementing a cluster revision <= 4 as
1212
- * described in OccupancySensorType and OccupancySensorTypeBitmap Attributes.
1213
- * This replaces the 9 legacy attributes PIROccupiedToUnoccupiedDelay through PhysicalContactUnoccupiedToOccupiedThreshold.
1214
- */
1215
771
  export function getDefaultOccupancySensingClusterServer(occupied = false, holdTime = 30, holdTimeMin = 1, holdTimeMax = 300) {
1216
772
  return optionsFor(OccupancySensingServer.with(OccupancySensing.Feature.PassiveInfrared), {
1217
773
  occupancy: { occupied },
@@ -1223,4 +779,3 @@ export function getDefaultOccupancySensingClusterServer(occupied = false, holdTi
1223
779
  holdTimeLimits: { holdTimeMin, holdTimeMax, holdTimeDefault: holdTime },
1224
780
  });
1225
781
  }
1226
- //# sourceMappingURL=matterbridgeEndpointHelpers.js.map