matterbridge 3.3.3 → 3.3.4-dev-20251020-df40d12

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 (297) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/broadcastServer.js +1 -86
  3. package/dist/broadcastServerTypes.js +0 -24
  4. package/dist/cli.js +112 -445
  5. package/dist/cliEmitter.js +0 -37
  6. package/dist/cliHistory.js +15 -95
  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 +2 -59
  11. package/dist/devices/batteryStorage.js +4 -51
  12. package/dist/devices/cooktop.js +0 -55
  13. package/dist/devices/dishwasher.js +4 -61
  14. package/dist/devices/evse.js +16 -79
  15. package/dist/devices/export.js +0 -5
  16. package/dist/devices/extractorHood.js +1 -43
  17. package/dist/devices/heatPump.js +4 -52
  18. package/dist/devices/laundryDryer.js +6 -65
  19. package/dist/devices/laundryWasher.js +9 -75
  20. package/dist/devices/microwaveOven.js +10 -93
  21. package/dist/devices/oven.js +5 -90
  22. package/dist/devices/refrigerator.js +4 -106
  23. package/dist/devices/roboticVacuumCleaner.js +20 -111
  24. package/dist/devices/solarPower.js +2 -40
  25. package/dist/devices/speaker.js +2 -85
  26. package/dist/devices/temperatureControl.js +5 -27
  27. package/dist/devices/waterHeater.js +8 -88
  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 +61 -439
  36. package/dist/frontendTypes.js +0 -45
  37. package/dist/helpers.js +1 -54
  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 +67 -885
  47. package/dist/matterbridgeAccessoryPlatform.js +2 -36
  48. package/dist/matterbridgeBehaviors.js +25 -91
  49. package/dist/matterbridgeDeviceTypes.js +102 -715
  50. package/dist/matterbridgeDynamicPlatform.js +2 -36
  51. package/dist/matterbridgeEndpoint.js +122 -1473
  52. package/dist/matterbridgeEndpointHelpers.js +88 -443
  53. package/dist/matterbridgePlatform.js +3 -343
  54. package/dist/matterbridgeTypes.js +0 -26
  55. package/dist/pluginManager.js +3 -325
  56. package/dist/shelly.js +7 -168
  57. package/dist/storage/export.js +0 -1
  58. package/dist/update.js +1 -70
  59. package/dist/utils/colorUtils.js +2 -97
  60. package/dist/utils/commandLine.js +6 -55
  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 +29 -0
  69. package/dist/utils/hex.js +0 -124
  70. package/dist/utils/inspector.js +200 -0
  71. package/dist/utils/isvalid.js +0 -101
  72. package/dist/utils/jestHelpers.js +10 -156
  73. package/dist/utils/network.js +5 -134
  74. package/dist/utils/spawn.js +0 -71
  75. package/dist/utils/tracker.js +201 -0
  76. package/dist/utils/wait.js +8 -60
  77. package/frontend/build/assets/index.js +4 -4
  78. package/frontend/build/assets/vendor_mdi.js +1 -1
  79. package/frontend/package.json +1 -1
  80. package/npm-shrinkwrap.json +44 -44
  81. package/package.json +2 -3
  82. package/dist/broadcastServer.d.ts +0 -105
  83. package/dist/broadcastServer.d.ts.map +0 -1
  84. package/dist/broadcastServer.js.map +0 -1
  85. package/dist/broadcastServerTypes.d.ts +0 -719
  86. package/dist/broadcastServerTypes.d.ts.map +0 -1
  87. package/dist/broadcastServerTypes.js.map +0 -1
  88. package/dist/cli.d.ts +0 -26
  89. package/dist/cli.d.ts.map +0 -1
  90. package/dist/cli.js.map +0 -1
  91. package/dist/cliEmitter.d.ts +0 -50
  92. package/dist/cliEmitter.d.ts.map +0 -1
  93. package/dist/cliEmitter.js.map +0 -1
  94. package/dist/cliHistory.d.ts +0 -74
  95. package/dist/cliHistory.d.ts.map +0 -1
  96. package/dist/cliHistory.js.map +0 -1
  97. package/dist/clusters/export.d.ts +0 -2
  98. package/dist/clusters/export.d.ts.map +0 -1
  99. package/dist/clusters/export.js.map +0 -1
  100. package/dist/defaultConfigSchema.d.ts +0 -28
  101. package/dist/defaultConfigSchema.d.ts.map +0 -1
  102. package/dist/defaultConfigSchema.js.map +0 -1
  103. package/dist/deviceManager.d.ts +0 -117
  104. package/dist/deviceManager.d.ts.map +0 -1
  105. package/dist/deviceManager.js.map +0 -1
  106. package/dist/devices/airConditioner.d.ts +0 -98
  107. package/dist/devices/airConditioner.d.ts.map +0 -1
  108. package/dist/devices/airConditioner.js.map +0 -1
  109. package/dist/devices/batteryStorage.d.ts +0 -48
  110. package/dist/devices/batteryStorage.d.ts.map +0 -1
  111. package/dist/devices/batteryStorage.js.map +0 -1
  112. package/dist/devices/cooktop.d.ts +0 -60
  113. package/dist/devices/cooktop.d.ts.map +0 -1
  114. package/dist/devices/cooktop.js.map +0 -1
  115. package/dist/devices/dishwasher.d.ts +0 -71
  116. package/dist/devices/dishwasher.d.ts.map +0 -1
  117. package/dist/devices/dishwasher.js.map +0 -1
  118. package/dist/devices/evse.d.ts +0 -75
  119. package/dist/devices/evse.d.ts.map +0 -1
  120. package/dist/devices/evse.js.map +0 -1
  121. package/dist/devices/export.d.ts +0 -17
  122. package/dist/devices/export.d.ts.map +0 -1
  123. package/dist/devices/export.js.map +0 -1
  124. package/dist/devices/extractorHood.d.ts +0 -46
  125. package/dist/devices/extractorHood.d.ts.map +0 -1
  126. package/dist/devices/extractorHood.js.map +0 -1
  127. package/dist/devices/heatPump.d.ts +0 -47
  128. package/dist/devices/heatPump.d.ts.map +0 -1
  129. package/dist/devices/heatPump.js.map +0 -1
  130. package/dist/devices/laundryDryer.d.ts +0 -67
  131. package/dist/devices/laundryDryer.d.ts.map +0 -1
  132. package/dist/devices/laundryDryer.js.map +0 -1
  133. package/dist/devices/laundryWasher.d.ts +0 -81
  134. package/dist/devices/laundryWasher.d.ts.map +0 -1
  135. package/dist/devices/laundryWasher.js.map +0 -1
  136. package/dist/devices/microwaveOven.d.ts +0 -168
  137. package/dist/devices/microwaveOven.d.ts.map +0 -1
  138. package/dist/devices/microwaveOven.js.map +0 -1
  139. package/dist/devices/oven.d.ts +0 -105
  140. package/dist/devices/oven.d.ts.map +0 -1
  141. package/dist/devices/oven.js.map +0 -1
  142. package/dist/devices/refrigerator.d.ts +0 -118
  143. package/dist/devices/refrigerator.d.ts.map +0 -1
  144. package/dist/devices/refrigerator.js.map +0 -1
  145. package/dist/devices/roboticVacuumCleaner.d.ts +0 -112
  146. package/dist/devices/roboticVacuumCleaner.d.ts.map +0 -1
  147. package/dist/devices/roboticVacuumCleaner.js.map +0 -1
  148. package/dist/devices/solarPower.d.ts +0 -40
  149. package/dist/devices/solarPower.d.ts.map +0 -1
  150. package/dist/devices/solarPower.js.map +0 -1
  151. package/dist/devices/speaker.d.ts +0 -87
  152. package/dist/devices/speaker.d.ts.map +0 -1
  153. package/dist/devices/speaker.js.map +0 -1
  154. package/dist/devices/temperatureControl.d.ts +0 -166
  155. package/dist/devices/temperatureControl.d.ts.map +0 -1
  156. package/dist/devices/temperatureControl.js.map +0 -1
  157. package/dist/devices/waterHeater.d.ts +0 -111
  158. package/dist/devices/waterHeater.d.ts.map +0 -1
  159. package/dist/devices/waterHeater.js.map +0 -1
  160. package/dist/dgram/coap.d.ts +0 -205
  161. package/dist/dgram/coap.d.ts.map +0 -1
  162. package/dist/dgram/coap.js.map +0 -1
  163. package/dist/dgram/dgram.d.ts +0 -141
  164. package/dist/dgram/dgram.d.ts.map +0 -1
  165. package/dist/dgram/dgram.js.map +0 -1
  166. package/dist/dgram/mb_coap.d.ts +0 -24
  167. package/dist/dgram/mb_coap.d.ts.map +0 -1
  168. package/dist/dgram/mb_coap.js.map +0 -1
  169. package/dist/dgram/mb_mdns.d.ts +0 -24
  170. package/dist/dgram/mb_mdns.d.ts.map +0 -1
  171. package/dist/dgram/mb_mdns.js.map +0 -1
  172. package/dist/dgram/mdns.d.ts +0 -290
  173. package/dist/dgram/mdns.d.ts.map +0 -1
  174. package/dist/dgram/mdns.js.map +0 -1
  175. package/dist/dgram/multicast.d.ts +0 -67
  176. package/dist/dgram/multicast.d.ts.map +0 -1
  177. package/dist/dgram/multicast.js.map +0 -1
  178. package/dist/dgram/unicast.d.ts +0 -56
  179. package/dist/dgram/unicast.d.ts.map +0 -1
  180. package/dist/dgram/unicast.js.map +0 -1
  181. package/dist/frontend.d.ts +0 -235
  182. package/dist/frontend.d.ts.map +0 -1
  183. package/dist/frontend.js.map +0 -1
  184. package/dist/frontendTypes.d.ts +0 -529
  185. package/dist/frontendTypes.d.ts.map +0 -1
  186. package/dist/frontendTypes.js.map +0 -1
  187. package/dist/helpers.d.ts +0 -48
  188. package/dist/helpers.d.ts.map +0 -1
  189. package/dist/helpers.js.map +0 -1
  190. package/dist/index.d.ts +0 -33
  191. package/dist/index.d.ts.map +0 -1
  192. package/dist/index.js.map +0 -1
  193. package/dist/logger/export.d.ts +0 -2
  194. package/dist/logger/export.d.ts.map +0 -1
  195. package/dist/logger/export.js.map +0 -1
  196. package/dist/matter/behaviors.d.ts +0 -2
  197. package/dist/matter/behaviors.d.ts.map +0 -1
  198. package/dist/matter/behaviors.js.map +0 -1
  199. package/dist/matter/clusters.d.ts +0 -2
  200. package/dist/matter/clusters.d.ts.map +0 -1
  201. package/dist/matter/clusters.js.map +0 -1
  202. package/dist/matter/devices.d.ts +0 -2
  203. package/dist/matter/devices.d.ts.map +0 -1
  204. package/dist/matter/devices.js.map +0 -1
  205. package/dist/matter/endpoints.d.ts +0 -2
  206. package/dist/matter/endpoints.d.ts.map +0 -1
  207. package/dist/matter/endpoints.js.map +0 -1
  208. package/dist/matter/export.d.ts +0 -5
  209. package/dist/matter/export.d.ts.map +0 -1
  210. package/dist/matter/export.js.map +0 -1
  211. package/dist/matter/types.d.ts +0 -3
  212. package/dist/matter/types.d.ts.map +0 -1
  213. package/dist/matter/types.js.map +0 -1
  214. package/dist/matterbridge.d.ts +0 -469
  215. package/dist/matterbridge.d.ts.map +0 -1
  216. package/dist/matterbridge.js.map +0 -1
  217. package/dist/matterbridgeAccessoryPlatform.d.ts +0 -42
  218. package/dist/matterbridgeAccessoryPlatform.d.ts.map +0 -1
  219. package/dist/matterbridgeAccessoryPlatform.js.map +0 -1
  220. package/dist/matterbridgeBehaviors.d.ts +0 -2399
  221. package/dist/matterbridgeBehaviors.d.ts.map +0 -1
  222. package/dist/matterbridgeBehaviors.js.map +0 -1
  223. package/dist/matterbridgeDeviceTypes.d.ts +0 -761
  224. package/dist/matterbridgeDeviceTypes.d.ts.map +0 -1
  225. package/dist/matterbridgeDeviceTypes.js.map +0 -1
  226. package/dist/matterbridgeDynamicPlatform.d.ts +0 -42
  227. package/dist/matterbridgeDynamicPlatform.d.ts.map +0 -1
  228. package/dist/matterbridgeDynamicPlatform.js.map +0 -1
  229. package/dist/matterbridgeEndpoint.d.ts +0 -1545
  230. package/dist/matterbridgeEndpoint.d.ts.map +0 -1
  231. package/dist/matterbridgeEndpoint.js.map +0 -1
  232. package/dist/matterbridgeEndpointHelpers.d.ts +0 -560
  233. package/dist/matterbridgeEndpointHelpers.d.ts.map +0 -1
  234. package/dist/matterbridgeEndpointHelpers.js.map +0 -1
  235. package/dist/matterbridgePlatform.d.ts +0 -402
  236. package/dist/matterbridgePlatform.d.ts.map +0 -1
  237. package/dist/matterbridgePlatform.js.map +0 -1
  238. package/dist/matterbridgeTypes.d.ts +0 -209
  239. package/dist/matterbridgeTypes.d.ts.map +0 -1
  240. package/dist/matterbridgeTypes.js.map +0 -1
  241. package/dist/pluginManager.d.ts +0 -353
  242. package/dist/pluginManager.d.ts.map +0 -1
  243. package/dist/pluginManager.js.map +0 -1
  244. package/dist/shelly.d.ts +0 -174
  245. package/dist/shelly.d.ts.map +0 -1
  246. package/dist/shelly.js.map +0 -1
  247. package/dist/storage/export.d.ts +0 -2
  248. package/dist/storage/export.d.ts.map +0 -1
  249. package/dist/storage/export.js.map +0 -1
  250. package/dist/update.d.ts +0 -75
  251. package/dist/update.d.ts.map +0 -1
  252. package/dist/update.js.map +0 -1
  253. package/dist/utils/colorUtils.d.ts +0 -99
  254. package/dist/utils/colorUtils.d.ts.map +0 -1
  255. package/dist/utils/colorUtils.js.map +0 -1
  256. package/dist/utils/commandLine.d.ts +0 -59
  257. package/dist/utils/commandLine.d.ts.map +0 -1
  258. package/dist/utils/commandLine.js.map +0 -1
  259. package/dist/utils/copyDirectory.d.ts +0 -33
  260. package/dist/utils/copyDirectory.d.ts.map +0 -1
  261. package/dist/utils/copyDirectory.js.map +0 -1
  262. package/dist/utils/createDirectory.d.ts +0 -34
  263. package/dist/utils/createDirectory.d.ts.map +0 -1
  264. package/dist/utils/createDirectory.js.map +0 -1
  265. package/dist/utils/createZip.d.ts +0 -39
  266. package/dist/utils/createZip.d.ts.map +0 -1
  267. package/dist/utils/createZip.js.map +0 -1
  268. package/dist/utils/deepCopy.d.ts +0 -32
  269. package/dist/utils/deepCopy.d.ts.map +0 -1
  270. package/dist/utils/deepCopy.js.map +0 -1
  271. package/dist/utils/deepEqual.d.ts +0 -54
  272. package/dist/utils/deepEqual.d.ts.map +0 -1
  273. package/dist/utils/deepEqual.js.map +0 -1
  274. package/dist/utils/error.d.ts +0 -44
  275. package/dist/utils/error.d.ts.map +0 -1
  276. package/dist/utils/error.js.map +0 -1
  277. package/dist/utils/export.d.ts +0 -13
  278. package/dist/utils/export.d.ts.map +0 -1
  279. package/dist/utils/export.js.map +0 -1
  280. package/dist/utils/hex.d.ts +0 -89
  281. package/dist/utils/hex.d.ts.map +0 -1
  282. package/dist/utils/hex.js.map +0 -1
  283. package/dist/utils/isvalid.d.ts +0 -103
  284. package/dist/utils/isvalid.d.ts.map +0 -1
  285. package/dist/utils/isvalid.js.map +0 -1
  286. package/dist/utils/jestHelpers.d.ts +0 -137
  287. package/dist/utils/jestHelpers.d.ts.map +0 -1
  288. package/dist/utils/jestHelpers.js.map +0 -1
  289. package/dist/utils/network.d.ts +0 -115
  290. package/dist/utils/network.d.ts.map +0 -1
  291. package/dist/utils/network.js.map +0 -1
  292. package/dist/utils/spawn.d.ts +0 -35
  293. package/dist/utils/spawn.d.ts.map +0 -1
  294. package/dist/utils/spawn.js.map +0 -1
  295. package/dist/utils/wait.d.ts +0 -54
  296. package/dist/utils/wait.d.ts.map +0 -1
  297. package/dist/utils/wait.js.map +0 -1
@@ -1,229 +1,134 @@
1
- /**
2
- * This file contains the helpers for the class MatterbridgeEndpoint.
3
- *
4
- * @file matterbridgeEndpointHelpers.ts
5
- * @author Luca Liguori
6
- * @created 2024-10-01
7
- * @version 2.1.0
8
- * @license Apache-2.0
9
- *
10
- * Copyright 2024, 2025, 2026 Luca Liguori.
11
- *
12
- * Licensed under the Apache License, Version 2.0 (the "License");
13
- * you may not use this file except in compliance with the License.
14
- * You may obtain a copy of the License at
15
- *
16
- * http://www.apache.org/licenses/LICENSE-2.0
17
- *
18
- * Unless required by applicable law or agreed to in writing, software
19
- * distributed under the License is distributed on an "AS IS" BASIS,
20
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
- * See the License for the specific language governing permissions and
22
- * limitations under the License.
23
- */
24
- // Other modules
1
+ if (process.argv.includes('--loader') || process.argv.includes('-loader'))
2
+ console.log('\u001B[32mMatterbridgeEndpointHelpers loaded.\u001B[40;0m');
25
3
  import { createHash } from 'node:crypto';
26
- // AnsiLogger module
27
4
  import { BLUE, CYAN, db, debugStringify, er, hk, or, YELLOW, zb } from 'node-ansi-logger';
28
- // @matter
29
- import { Lifecycle } from '@matter/main';
30
- import { getClusterNameById, MeasurementType } from '@matter/main/types';
31
- // @matter clusters
32
- import { PowerSource } from '@matter/main/clusters/power-source';
33
- import { UserLabel } from '@matter/main/clusters/user-label';
34
- import { FixedLabel } from '@matter/main/clusters/fixed-label';
35
- import { BasicInformation } from '@matter/main/clusters/basic-information';
36
- import { BridgedDeviceBasicInformation } from '@matter/main/clusters/bridged-device-basic-information';
37
- import { Identify } from '@matter/main/clusters/identify';
38
- import { Groups } from '@matter/main/clusters/groups';
39
- import { OnOff } from '@matter/main/clusters/on-off';
40
- import { LevelControl } from '@matter/main/clusters/level-control';
41
- import { ColorControl } from '@matter/main/clusters/color-control';
42
- import { WindowCovering } from '@matter/main/clusters/window-covering';
43
- import { Thermostat } from '@matter/main/clusters/thermostat';
44
- import { FanControl } from '@matter/main/clusters/fan-control';
45
- import { DoorLock } from '@matter/main/clusters/door-lock';
46
- import { ModeSelect } from '@matter/main/clusters/mode-select';
47
- import { ValveConfigurationAndControl } from '@matter/main/clusters/valve-configuration-and-control';
48
- import { PumpConfigurationAndControl } from '@matter/main/clusters/pump-configuration-and-control';
49
- import { SmokeCoAlarm } from '@matter/main/clusters/smoke-co-alarm';
50
- import { Switch } from '@matter/main/clusters/switch';
51
- import { BooleanState } from '@matter/main/clusters/boolean-state';
52
- import { BooleanStateConfiguration } from '@matter/main/clusters/boolean-state-configuration';
53
- import { PowerTopology } from '@matter/main/clusters/power-topology';
54
- import { ElectricalPowerMeasurement } from '@matter/main/clusters/electrical-power-measurement';
55
- import { ElectricalEnergyMeasurement } from '@matter/main/clusters/electrical-energy-measurement';
56
- import { TemperatureMeasurement } from '@matter/main/clusters/temperature-measurement';
57
- import { RelativeHumidityMeasurement } from '@matter/main/clusters/relative-humidity-measurement';
58
- import { PressureMeasurement } from '@matter/main/clusters/pressure-measurement';
59
- import { FlowMeasurement } from '@matter/main/clusters/flow-measurement';
60
- import { IlluminanceMeasurement } from '@matter/main/clusters/illuminance-measurement';
61
- import { OccupancySensing } from '@matter/main/clusters/occupancy-sensing';
62
- import { AirQuality } from '@matter/main/clusters/air-quality';
63
- import { CarbonMonoxideConcentrationMeasurement } from '@matter/main/clusters/carbon-monoxide-concentration-measurement';
64
- import { CarbonDioxideConcentrationMeasurement } from '@matter/main/clusters/carbon-dioxide-concentration-measurement';
65
- import { NitrogenDioxideConcentrationMeasurement } from '@matter/main/clusters/nitrogen-dioxide-concentration-measurement';
66
- import { OzoneConcentrationMeasurement } from '@matter/main/clusters/ozone-concentration-measurement';
67
- import { FormaldehydeConcentrationMeasurement } from '@matter/main/clusters/formaldehyde-concentration-measurement';
68
- import { Pm1ConcentrationMeasurement } from '@matter/main/clusters/pm1-concentration-measurement';
69
- import { Pm25ConcentrationMeasurement } from '@matter/main/clusters/pm25-concentration-measurement';
70
- import { Pm10ConcentrationMeasurement } from '@matter/main/clusters/pm10-concentration-measurement';
71
- import { RadonConcentrationMeasurement } from '@matter/main/clusters/radon-concentration-measurement';
72
- import { TotalVolatileOrganicCompoundsConcentrationMeasurement } from '@matter/main/clusters/total-volatile-organic-compounds-concentration-measurement';
73
- import { OperationalState } from '@matter/main/clusters/operational-state';
74
- import { DeviceEnergyManagement } from '@matter/main/clusters/device-energy-management';
75
- import { DeviceEnergyManagementMode } from '@matter/main/clusters/device-energy-management-mode';
76
- // @matter behaviors
77
- import { PowerSourceServer } from '@matter/main/behaviors/power-source';
78
- import { UserLabelServer } from '@matter/main/behaviors/user-label';
79
- import { FixedLabelServer } from '@matter/main/behaviors/fixed-label';
80
- import { BasicInformationServer } from '@matter/main/behaviors/basic-information';
81
- import { BridgedDeviceBasicInformationServer } from '@matter/main/behaviors/bridged-device-basic-information';
82
- import { GroupsServer } from '@matter/main/behaviors/groups';
83
- import { PumpConfigurationAndControlServer } from '@matter/main/behaviors/pump-configuration-and-control';
84
- import { SwitchServer } from '@matter/main/behaviors/switch';
85
- import { BooleanStateServer } from '@matter/main/behaviors/boolean-state';
86
- import { PowerTopologyServer } from '@matter/main/behaviors/power-topology';
87
- import { ElectricalPowerMeasurementServer } from '@matter/main/behaviors/electrical-power-measurement';
88
- import { ElectricalEnergyMeasurementServer } from '@matter/main/behaviors/electrical-energy-measurement';
89
- import { TemperatureMeasurementServer } from '@matter/main/behaviors/temperature-measurement';
90
- import { RelativeHumidityMeasurementServer } from '@matter/main/behaviors/relative-humidity-measurement';
91
- import { PressureMeasurementServer } from '@matter/main/behaviors/pressure-measurement';
92
- import { FlowMeasurementServer } from '@matter/main/behaviors/flow-measurement';
93
- import { IlluminanceMeasurementServer } from '@matter/main/behaviors/illuminance-measurement';
94
- import { OccupancySensingServer } from '@matter/main/behaviors/occupancy-sensing';
95
- import { AirQualityServer } from '@matter/main/behaviors/air-quality';
96
- import { CarbonMonoxideConcentrationMeasurementServer } from '@matter/main/behaviors/carbon-monoxide-concentration-measurement';
97
- import { CarbonDioxideConcentrationMeasurementServer } from '@matter/main/behaviors/carbon-dioxide-concentration-measurement';
98
- import { NitrogenDioxideConcentrationMeasurementServer } from '@matter/main/behaviors/nitrogen-dioxide-concentration-measurement';
99
- import { OzoneConcentrationMeasurementServer } from '@matter/main/behaviors/ozone-concentration-measurement';
100
- import { FormaldehydeConcentrationMeasurementServer } from '@matter/main/behaviors/formaldehyde-concentration-measurement';
101
- import { Pm1ConcentrationMeasurementServer } from '@matter/main/behaviors/pm1-concentration-measurement';
102
- import { Pm25ConcentrationMeasurementServer } from '@matter/main/behaviors/pm25-concentration-measurement';
103
- import { Pm10ConcentrationMeasurementServer } from '@matter/main/behaviors/pm10-concentration-measurement';
104
- import { RadonConcentrationMeasurementServer } from '@matter/main/behaviors/radon-concentration-measurement';
105
- import { TotalVolatileOrganicCompoundsConcentrationMeasurementServer } from '@matter/main/behaviors/total-volatile-organic-compounds-concentration-measurement';
5
+ import { Lifecycle } from '@matter/general';
6
+ import { MeasurementType } from '@matter/types/globals';
7
+ import { getClusterNameById } from '@matter/types/cluster';
8
+ import { PowerSource } from '@matter/types/clusters/power-source';
9
+ import { UserLabel } from '@matter/types/clusters/user-label';
10
+ import { FixedLabel } from '@matter/types/clusters/fixed-label';
11
+ import { BasicInformation } from '@matter/types/clusters/basic-information';
12
+ import { BridgedDeviceBasicInformation } from '@matter/types/clusters/bridged-device-basic-information';
13
+ import { Identify } from '@matter/types/clusters/identify';
14
+ import { Groups } from '@matter/types/clusters/groups';
15
+ import { OnOff } from '@matter/types/clusters/on-off';
16
+ import { LevelControl } from '@matter/types/clusters/level-control';
17
+ import { ColorControl } from '@matter/types/clusters/color-control';
18
+ import { WindowCovering } from '@matter/types/clusters/window-covering';
19
+ import { Thermostat } from '@matter/types/clusters/thermostat';
20
+ import { FanControl } from '@matter/types/clusters/fan-control';
21
+ import { DoorLock } from '@matter/types/clusters/door-lock';
22
+ import { ModeSelect } from '@matter/types/clusters/mode-select';
23
+ import { ValveConfigurationAndControl } from '@matter/types/clusters/valve-configuration-and-control';
24
+ import { PumpConfigurationAndControl } from '@matter/types/clusters/pump-configuration-and-control';
25
+ import { SmokeCoAlarm } from '@matter/types/clusters/smoke-co-alarm';
26
+ import { Switch } from '@matter/types/clusters/switch';
27
+ import { BooleanState } from '@matter/types/clusters/boolean-state';
28
+ import { BooleanStateConfiguration } from '@matter/types/clusters/boolean-state-configuration';
29
+ import { PowerTopology } from '@matter/types/clusters/power-topology';
30
+ import { ElectricalPowerMeasurement } from '@matter/types/clusters/electrical-power-measurement';
31
+ import { ElectricalEnergyMeasurement } from '@matter/types/clusters/electrical-energy-measurement';
32
+ import { TemperatureMeasurement } from '@matter/types/clusters/temperature-measurement';
33
+ import { RelativeHumidityMeasurement } from '@matter/types/clusters/relative-humidity-measurement';
34
+ import { PressureMeasurement } from '@matter/types/clusters/pressure-measurement';
35
+ import { FlowMeasurement } from '@matter/types/clusters/flow-measurement';
36
+ import { IlluminanceMeasurement } from '@matter/types/clusters/illuminance-measurement';
37
+ import { OccupancySensing } from '@matter/types/clusters/occupancy-sensing';
38
+ import { AirQuality } from '@matter/types/clusters/air-quality';
39
+ import { CarbonMonoxideConcentrationMeasurement } from '@matter/types/clusters/carbon-monoxide-concentration-measurement';
40
+ import { CarbonDioxideConcentrationMeasurement } from '@matter/types/clusters/carbon-dioxide-concentration-measurement';
41
+ import { NitrogenDioxideConcentrationMeasurement } from '@matter/types/clusters/nitrogen-dioxide-concentration-measurement';
42
+ import { OzoneConcentrationMeasurement } from '@matter/types/clusters/ozone-concentration-measurement';
43
+ import { FormaldehydeConcentrationMeasurement } from '@matter/types/clusters/formaldehyde-concentration-measurement';
44
+ import { Pm1ConcentrationMeasurement } from '@matter/types/clusters/pm1-concentration-measurement';
45
+ import { Pm25ConcentrationMeasurement } from '@matter/types/clusters/pm25-concentration-measurement';
46
+ import { Pm10ConcentrationMeasurement } from '@matter/types/clusters/pm10-concentration-measurement';
47
+ import { RadonConcentrationMeasurement } from '@matter/types/clusters/radon-concentration-measurement';
48
+ import { TotalVolatileOrganicCompoundsConcentrationMeasurement } from '@matter/types/clusters/total-volatile-organic-compounds-concentration-measurement';
49
+ import { OperationalState } from '@matter/types/clusters/operational-state';
50
+ import { DeviceEnergyManagement } from '@matter/types/clusters/device-energy-management';
51
+ import { DeviceEnergyManagementMode } from '@matter/types/clusters/device-energy-management-mode';
52
+ import { PowerSourceServer } from '@matter/node/behaviors/power-source';
53
+ import { UserLabelServer } from '@matter/node/behaviors/user-label';
54
+ import { FixedLabelServer } from '@matter/node/behaviors/fixed-label';
55
+ import { BasicInformationServer } from '@matter/node/behaviors/basic-information';
56
+ import { BridgedDeviceBasicInformationServer } from '@matter/node/behaviors/bridged-device-basic-information';
57
+ import { GroupsServer } from '@matter/node/behaviors/groups';
58
+ import { PumpConfigurationAndControlServer } from '@matter/node/behaviors/pump-configuration-and-control';
59
+ import { SwitchServer } from '@matter/node/behaviors/switch';
60
+ import { BooleanStateServer } from '@matter/node/behaviors/boolean-state';
61
+ import { PowerTopologyServer } from '@matter/node/behaviors/power-topology';
62
+ import { ElectricalPowerMeasurementServer } from '@matter/node/behaviors/electrical-power-measurement';
63
+ import { ElectricalEnergyMeasurementServer } from '@matter/node/behaviors/electrical-energy-measurement';
64
+ import { TemperatureMeasurementServer } from '@matter/node/behaviors/temperature-measurement';
65
+ import { RelativeHumidityMeasurementServer } from '@matter/node/behaviors/relative-humidity-measurement';
66
+ import { PressureMeasurementServer } from '@matter/node/behaviors/pressure-measurement';
67
+ import { FlowMeasurementServer } from '@matter/node/behaviors/flow-measurement';
68
+ import { IlluminanceMeasurementServer } from '@matter/node/behaviors/illuminance-measurement';
69
+ import { OccupancySensingServer } from '@matter/node/behaviors/occupancy-sensing';
70
+ import { AirQualityServer } from '@matter/node/behaviors/air-quality';
71
+ import { CarbonMonoxideConcentrationMeasurementServer } from '@matter/node/behaviors/carbon-monoxide-concentration-measurement';
72
+ import { CarbonDioxideConcentrationMeasurementServer } from '@matter/node/behaviors/carbon-dioxide-concentration-measurement';
73
+ import { NitrogenDioxideConcentrationMeasurementServer } from '@matter/node/behaviors/nitrogen-dioxide-concentration-measurement';
74
+ import { OzoneConcentrationMeasurementServer } from '@matter/node/behaviors/ozone-concentration-measurement';
75
+ import { FormaldehydeConcentrationMeasurementServer } from '@matter/node/behaviors/formaldehyde-concentration-measurement';
76
+ import { Pm1ConcentrationMeasurementServer } from '@matter/node/behaviors/pm1-concentration-measurement';
77
+ import { Pm25ConcentrationMeasurementServer } from '@matter/node/behaviors/pm25-concentration-measurement';
78
+ import { Pm10ConcentrationMeasurementServer } from '@matter/node/behaviors/pm10-concentration-measurement';
79
+ import { RadonConcentrationMeasurementServer } from '@matter/node/behaviors/radon-concentration-measurement';
80
+ import { TotalVolatileOrganicCompoundsConcentrationMeasurementServer } from '@matter/node/behaviors/total-volatile-organic-compounds-concentration-measurement';
106
81
  import { DeviceEnergyManagementServer } from '@matter/node/behaviors/device-energy-management';
107
- // Matterbridge
108
82
  import { deepCopy, deepEqual, isValidArray } from './utils/export.js';
109
83
  import { MatterbridgeIdentifyServer, MatterbridgeOnOffServer, MatterbridgeLevelControlServer, MatterbridgeColorControlServer, MatterbridgeLiftWindowCoveringServer, MatterbridgeThermostatServer, MatterbridgeFanControlServer, MatterbridgeDoorLockServer, MatterbridgeModeSelectServer, MatterbridgeValveConfigurationAndControlServer, MatterbridgeSmokeCoAlarmServer, MatterbridgeBooleanStateConfigurationServer, MatterbridgeOperationalStateServer, MatterbridgeDeviceEnergyManagementModeServer, } from './matterbridgeBehaviors.js';
110
- /**
111
- * Capitalizes the first letter of a string.
112
- *
113
- * @param {string} name - The string to capitalize.
114
- * @returns {string} The string with the first letter capitalized.
115
- */
116
84
  export function capitalizeFirstLetter(name) {
117
85
  if (!name)
118
86
  return name;
119
87
  return name.charAt(0).toUpperCase() + name.slice(1);
120
88
  }
121
- /**
122
- * Lowercases the first letter of a string.
123
- *
124
- * @param {string} name - The string to lowercase the first letter of.
125
- * @returns {string} The string with the first letter lowercased.
126
- */
127
89
  export function lowercaseFirstLetter(name) {
128
90
  if (!name)
129
91
  return name;
130
92
  return name.charAt(0).toLowerCase() + name.slice(1);
131
93
  }
132
- /**
133
- * Checks if the device name contains non-Latin characters.
134
- *
135
- * @param {string} deviceName - The name of the device to check.
136
- * @returns {boolean} Returns true if the device name contains non-Latin characters, false otherwise.
137
- */
138
94
  export function checkNotLatinCharacters(deviceName) {
139
95
  const nonLatinRegexList = [
140
- /[\u0400-\u04FF\u0500-\u052F]/, // Cyrillic
141
- /[\u2E80-\u9FFF]/, // CJK (Chinese, Japanese, Korean)
142
- /[\uAC00-\uD7AF]/, // Korean Hangul
143
- /[\u0600-\u06FF\u0750-\u077F]/, // Arabic, Persian
144
- /[\u0590-\u05FF]/, // Hebrew
145
- /[\u0900-\u097F]/, // Devanagari (Hindi, Sanskrit)
146
- /[\u0E00-\u0E7F]/, // Thai
147
- /[\u1200-\u137F]/, // Ethiopic (Amharic, Tigrinya)
96
+ /[\u0400-\u04FF\u0500-\u052F]/,
97
+ /[\u2E80-\u9FFF]/,
98
+ /[\uAC00-\uD7AF]/,
99
+ /[\u0600-\u06FF\u0750-\u077F]/,
100
+ /[\u0590-\u05FF]/,
101
+ /[\u0900-\u097F]/,
102
+ /[\u0E00-\u0E7F]/,
103
+ /[\u1200-\u137F]/,
148
104
  ];
149
105
  return nonLatinRegexList.some((regex) => regex.test(deviceName));
150
106
  }
151
- /**
152
- * Generates a unique ID based on the device name.
153
- *
154
- * @param {string} deviceName - The name of the device to generate a unique ID for.
155
- * @returns {string} A unique ID generated from the device name using MD5 hashing.
156
- */
157
107
  export function generateUniqueId(deviceName) {
158
- return createHash('md5').update(deviceName).digest('hex'); // MD5 hash of the device name
108
+ return createHash('md5').update(deviceName).digest('hex');
159
109
  }
160
- /**
161
- * Generates a unique ID based on four parameters.
162
- *
163
- * @param {string} param1 - The first parameter.
164
- * @param {string} param2 - The second parameter.
165
- * @param {string} param3 - The third parameter.
166
- * @param {string} param4 - The fourth parameter.
167
- * @returns {string} A unique ID generated from the concatenation of the parameters using MD5 hashing.
168
- */
169
110
  export function createUniqueId(param1, param2, param3, param4) {
170
111
  const hash = createHash('md5');
171
112
  hash.update(param1 + param2 + param3 + param4);
172
113
  return hash.digest('hex');
173
114
  }
174
- /**
175
- * Retrieves the features for a specific behavior.
176
- *
177
- * @param {Endpoint} endpoint - The endpoint to retrieve the features from.
178
- * @param {string} behavior - The behavior to retrieve the features for.
179
- *
180
- * @returns {Record<string, boolean | undefined>} The features for the specified behavior.
181
- *
182
- * @remarks Use with:
183
- * ```typescript
184
- * expect(featuresFor(device, 'powerSource').wired).toBe(true);
185
- * ```
186
- */
187
115
  export function featuresFor(endpoint, behavior) {
188
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
189
116
  return endpoint.behaviors.supported[lowercaseFirstLetter(behavior)]['cluster']['supportedFeatures'];
190
117
  }
191
- /**
192
- * Maps a list of ClusterId to Behavior.Type for server clusters.
193
- *
194
- * @param {ClusterId[]} clusterServerList - The list of ClusterId to map.
195
- * @returns {Behavior.Type[]} An array of Behavior.Type corresponding to the ClusterId in the server list.
196
- */
197
118
  export function getBehaviourTypesFromClusterServerIds(clusterServerList) {
198
- // Map Server ClusterId to Behavior.Type
199
119
  const behaviorTypes = [];
200
120
  clusterServerList.forEach((clusterId) => {
201
121
  behaviorTypes.push(getBehaviourTypeFromClusterServerId(clusterId));
202
122
  });
203
123
  return behaviorTypes;
204
124
  }
205
- /**
206
- * Maps a list of ClusterId to Behavior.Type for client clusters.
207
- *
208
- * @param {ClusterId[]} clusterClientList - The list of ClusterId to map.
209
- * @returns {Behavior.Type[]} An array of Behavior.Type corresponding to the ClusterId in the client list.
210
- */
211
125
  export function getBehaviourTypesFromClusterClientIds(clusterClientList) {
212
- // Map Client ClusterId to Behavior.Type
213
126
  const behaviorTypes = [];
214
127
  clusterClientList.forEach((_clusterId) => {
215
- // behaviorTypes.push(getBehaviourTypeFromClusterClientId(clusterId));
216
128
  });
217
129
  return behaviorTypes;
218
130
  }
219
- /**
220
- * Maps a ClusterId to a Behavior.Type for server clusters.
221
- *
222
- * @param {ClusterId} clusterId - The ClusterId to map.
223
- * @returns {Behavior.Type} The corresponding Behavior.Type for the given ClusterId.
224
- */
225
131
  export function getBehaviourTypeFromClusterServerId(clusterId) {
226
- // Map ClusterId to Server Behavior.Type
227
132
  if (clusterId === PowerSource.Cluster.id)
228
133
  return PowerSourceServer.with(PowerSource.Feature.Wired);
229
134
  if (clusterId === UserLabel.Cluster.id)
@@ -314,22 +219,8 @@ export function getBehaviourTypeFromClusterServerId(clusterId) {
314
219
  return MatterbridgeDeviceEnergyManagementModeServer;
315
220
  return MatterbridgeIdentifyServer;
316
221
  }
317
- /**
318
- * Maps a ClusterId to a Behavior.Type for client clusters.
319
- *
320
- * @param {ClusterId} _clusterId - The ClusterId to map.
321
- */
322
222
  export function getBehaviourTypeFromClusterClientId(_clusterId) {
323
- // Map ClusterId to Client Behavior.Type
324
- // return IdentifyClient;
325
223
  }
326
- /**
327
- * Retrieves the Behavior.Type for a given cluster from the endpoint's supported behaviors.
328
- *
329
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to retrieve the behavior from.
330
- * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to retrieve the behavior for.
331
- * @returns {Behavior.Type | undefined} The Behavior.Type for the given cluster, or undefined if not found.
332
- */
333
224
  export function getBehavior(endpoint, cluster) {
334
225
  let behavior;
335
226
  if (typeof cluster === 'string') {
@@ -346,18 +237,6 @@ export function getBehavior(endpoint, cluster) {
346
237
  }
347
238
  return behavior;
348
239
  }
349
- /**
350
- * Invokes a command on the specified behavior of the endpoint. Used ONLY in Jest tests.
351
- *
352
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to invoke the command on.
353
- * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to invoke the command on.
354
- * @param {keyof MatterbridgeEndpointCommands} command - The command to invoke.
355
- * @param {Record<string, boolean | number | bigint | string | object | null>} [params] - The parameters to pass to the command.
356
- *
357
- * @returns {Promise<boolean>} A promise that resolves to true if the command was invoked successfully, false otherwise.
358
- *
359
- * @deprecated Used ONLY in Jest tests.
360
- */
361
240
  export async function invokeBehaviorCommand(endpoint, cluster, command, params) {
362
241
  const behaviorId = getBehavior(endpoint, cluster)?.id;
363
242
  if (!behaviorId) {
@@ -365,7 +244,6 @@ export async function invokeBehaviorCommand(endpoint, cluster, command, params)
365
244
  return false;
366
245
  }
367
246
  await endpoint.act((agent) => {
368
- // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
369
247
  const behavior = agent[behaviorId];
370
248
  if (!(command in behavior) || typeof behavior[command] !== 'function') {
371
249
  endpoint.log?.error(`invokeBehaviorCommand error: command ${hk}${command}${er} not found on agent for endpoint ${or}${endpoint.maybeId}${er}:${or}${endpoint.maybeNumber}${er}`);
@@ -375,19 +253,6 @@ export async function invokeBehaviorCommand(endpoint, cluster, command, params)
375
253
  });
376
254
  return true;
377
255
  }
378
- /**
379
- * Invokes the subscription handler on the specified cluster and attribute of the endpoint. Used ONLY in Jest tests.
380
- *
381
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to invoke the subscription handler on.
382
- * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to invoke the subscription handler on.
383
- * @param {string} attribute - The attribute to invoke the subscription handler on.
384
- * @param {unknown} newValue - The new value of the attribute.
385
- * @param {unknown} oldValue - The old value of the attribute.
386
- *
387
- * @returns {Promise<boolean>} A promise that resolves to true if the subscription handler was invoked successfully, false otherwise.
388
- *
389
- * @deprecated Used ONLY in Jest tests.
390
- */
391
256
  export async function invokeSubscribeHandler(endpoint, cluster, attribute, newValue, oldValue) {
392
257
  const event = attribute + '$Changed';
393
258
  const clusterName = getBehavior(endpoint, cluster)?.id;
@@ -404,17 +269,9 @@ export async function invokeSubscribeHandler(endpoint, cluster, attribute, newVa
404
269
  endpoint.log.error(`invokeSubscribeHandler ${hk}${event}${er} error: cluster ${clusterName} not found on endpoint ${or}${endpoint.id}${er}:${or}${endpoint.number}${er}`);
405
270
  return false;
406
271
  }
407
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
408
- // @ts-ignore
409
272
  await endpoint.act((agent) => agent[clusterName].events[event].emit(newValue, oldValue, { ...agent.context, offline: false }));
410
273
  return true;
411
274
  }
412
- /**
413
- * Adds required cluster servers to the specified endpoint based on the device types.
414
- *
415
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to add the required cluster servers to.
416
- * @returns {void}
417
- */
418
275
  export function addRequiredClusterServers(endpoint) {
419
276
  const requiredServerList = [];
420
277
  endpoint.log.debug(`addRequiredClusterServers for ${CYAN}${endpoint.maybeId}${db}`);
@@ -429,12 +286,6 @@ export function addRequiredClusterServers(endpoint) {
429
286
  });
430
287
  addClusterServers(endpoint, requiredServerList);
431
288
  }
432
- /**
433
- * Adds optional cluster servers to the specified endpoint based on the device types.
434
- *
435
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to add the optional cluster servers to.
436
- * @returns {void}
437
- */
438
289
  export function addOptionalClusterServers(endpoint) {
439
290
  const optionalServerList = [];
440
291
  endpoint.log.debug(`addOptionalClusterServers for ${CYAN}${endpoint.maybeId}${db}`);
@@ -449,12 +300,6 @@ export function addOptionalClusterServers(endpoint) {
449
300
  });
450
301
  addClusterServers(endpoint, optionalServerList);
451
302
  }
452
- /**
453
- * Adds cluster servers to the specified endpoint based on the provided server list.
454
- *
455
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to add the cluster servers to.
456
- * @param {ClusterId[]} serverList - The list of cluster IDs to add.
457
- */
458
303
  export function addClusterServers(endpoint, serverList) {
459
304
  if (serverList.includes(PowerSource.Cluster.id))
460
305
  endpoint.createDefaultPowerSourceWiredClusterServer();
@@ -535,13 +380,6 @@ export function addClusterServers(endpoint, serverList) {
535
380
  if (serverList.includes(DeviceEnergyManagementMode.Cluster.id))
536
381
  endpoint.createDefaultDeviceEnergyManagementModeClusterServer();
537
382
  }
538
- /**
539
- * Adds a fixed label to the FixedLabel cluster. The FixedLabel cluster is created if it does not exist.
540
- *
541
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to add the cluster servers to.
542
- * @param {string} label - The label to add. Max 16 characters.
543
- * @param {string} value - The value of the label. Max 16 characters.
544
- */
545
383
  export async function addFixedLabel(endpoint, label, value) {
546
384
  if (!endpoint.hasClusterServer(FixedLabel.Cluster.id)) {
547
385
  endpoint.log.debug(`addFixedLabel: add cluster ${hk}FixedLabel${db}:${hk}fixedLabel${db} with label ${CYAN}${label}${db} value ${CYAN}${value}${db}`);
@@ -558,13 +396,6 @@ export async function addFixedLabel(endpoint, label, value) {
558
396
  await endpoint.setAttribute(FixedLabel.Cluster.id, 'labelList', labelList, endpoint.log);
559
397
  }
560
398
  }
561
- /**
562
- * Adds a user label to the UserLabel cluster. The UserLabel cluster is created if it does not exist.
563
- *
564
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to add the cluster servers to.
565
- * @param {string} label - The label to add. Max 16 characters.
566
- * @param {string} value - The value of the label. Max 16 characters.
567
- */
568
399
  export async function addUserLabel(endpoint, label, value) {
569
400
  if (!endpoint.hasClusterServer(UserLabel.Cluster.id)) {
570
401
  endpoint.log.debug(`addUserLabel: add cluster ${hk}UserLabel${db}:${hk}userLabel${db} with label ${CYAN}${label}${db} value ${CYAN}${value}${db}`);
@@ -581,48 +412,16 @@ export async function addUserLabel(endpoint, label, value) {
581
412
  await endpoint.setAttribute(UserLabel.Cluster.id, 'labelList', labelList, endpoint.log);
582
413
  }
583
414
  }
584
- /**
585
- * Returns the options for a given behavior type.
586
- *
587
- * @param {T} type - The behavior type.
588
- * @param {Behavior.Options<T>} options - The options for the behavior type.
589
- * @returns {Behavior.Options<T>} The options for the behavior type.
590
- */
591
415
  export function optionsFor(type, options) {
592
416
  return options;
593
417
  }
594
- /**
595
- * Retrieves the cluster ID.
596
- *
597
- * @param {Endpoint} endpoint - The endpoint to retrieve the cluster ID from.
598
- * @param {ClusterId} cluster - The ID of the cluster.
599
- * @returns {number | undefined} The ID of the cluster.
600
- */
601
418
  export function getClusterId(endpoint, cluster) {
602
419
  return endpoint.behaviors.supported[lowercaseFirstLetter(cluster)]?.schema?.id;
603
420
  }
604
- /**
605
- * Retrieves the ID of an attribute from a cluster behavior.
606
- *
607
- * @param {Endpoint} endpoint - The endpoint to retrieve the attribute ID from.
608
- * @param {string} cluster - The name of the cluster.
609
- * @param {string} attribute - The name of the attribute.
610
- * @returns {number | undefined} The ID of the attribute, or undefined if not found.
611
- */
612
421
  export function getAttributeId(endpoint, cluster, attribute) {
613
422
  const clusterBehavior = endpoint.behaviors.supported[lowercaseFirstLetter(cluster)];
614
423
  return clusterBehavior?.cluster?.attributes[lowercaseFirstLetter(attribute)]?.id;
615
424
  }
616
- /**
617
- * Retrieves the value of the provided attribute from the given cluster.
618
- *
619
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to retrieve the attribute from.
620
- * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to retrieve the attribute from.
621
- * @param {string} attribute - The name of the attribute to retrieve.
622
- * @param {AnsiLogger} [log] - (Optional) The logger to use for logging the retrieve. Errors are logged to the endpoint logger.
623
- * @returns {any} The value of the attribute, or undefined if the attribute is not found.
624
- */
625
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
626
425
  export function getAttribute(endpoint, cluster, attribute, log) {
627
426
  const clusterName = getBehavior(endpoint, cluster)?.id;
628
427
  if (!clusterName) {
@@ -645,16 +444,6 @@ export function getAttribute(endpoint, cluster, attribute, log) {
645
444
  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}`);
646
445
  return value;
647
446
  }
648
- /**
649
- * Sets the value of an attribute on a cluster server.
650
- *
651
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to set the attribute on.
652
- * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to set the attribute on.
653
- * @param {string} attribute - The name of the attribute.
654
- * @param {boolean | number | bigint | string | object | null} value - The value to set for the attribute.
655
- * @param {AnsiLogger} [log] - (Optional) The logger to use for logging the set. Errors are logged to the endpoint logger.
656
- * @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the attribute was successfully set.
657
- */
658
447
  export async function setAttribute(endpoint, cluster, attribute, value, log) {
659
448
  const clusterName = getBehavior(endpoint, cluster)?.id;
660
449
  if (!clusterName) {
@@ -680,16 +469,6 @@ export async function setAttribute(endpoint, cluster, attribute, value, log) {
680
469
  `to ${YELLOW}${value !== null && typeof value === 'object' ? debugStringify(value) : value}${db}`);
681
470
  return true;
682
471
  }
683
- /**
684
- * Sets the value of an attribute on a cluster server.
685
- *
686
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to update the attribute on.
687
- * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to update the attribute on.
688
- * @param {string} attribute - The name of the attribute.
689
- * @param {boolean | number | bigint | string | object | null} value - The value to set for the attribute.
690
- * @param {AnsiLogger} [log] - (Optional) The logger to use for logging the update. Errors are logged to the endpoint logger.
691
- * @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the attribute was successfully set.
692
- */
693
472
  export async function updateAttribute(endpoint, cluster, attribute, value, log) {
694
473
  const clusterName = getBehavior(endpoint, cluster)?.id;
695
474
  if (!clusterName) {
@@ -720,24 +499,7 @@ export async function updateAttribute(endpoint, cluster, attribute, value, log)
720
499
  `to ${YELLOW}${value !== null && typeof value === 'object' ? debugStringify(value) : value}${db}`);
721
500
  return true;
722
501
  }
723
- /**
724
- * Subscribes to the provided attribute on a cluster.
725
- *
726
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to subscribe the attribute to.
727
- * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to subscribe the attribute to.
728
- * @param {string} attribute - The name of the attribute to subscribe to.
729
- * @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.
730
- * @param {AnsiLogger} [log] - Optional logger for logging errors and information.
731
- * @returns {boolean} - A boolean indicating whether the subscription was successful.
732
- *
733
- * @remarks The listener function (cannot be async) will receive three parameters:
734
- * - `newValue`: The new value of the attribute.
735
- * - `oldValue`: The old value of the attribute.
736
- * - `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.
737
- */
738
- export async function subscribeAttribute(endpoint, cluster, attribute,
739
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
740
- listener, log) {
502
+ export async function subscribeAttribute(endpoint, cluster, attribute, listener, log) {
741
503
  const clusterName = getBehavior(endpoint, cluster)?.id;
742
504
  if (!clusterName) {
743
505
  endpoint.log.error(`subscribeAttribute ${hk}${attribute}${er} error: cluster not found on endpoint ${or}${endpoint.maybeId}${er}:${or}${endpoint.maybeNumber}${er}`);
@@ -747,7 +509,6 @@ listener, log) {
747
509
  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`);
748
510
  await endpoint.construction.ready;
749
511
  }
750
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
751
512
  const events = endpoint.events;
752
513
  attribute = lowercaseFirstLetter(attribute) + '$Changed';
753
514
  if (!(clusterName in events) || !(attribute in events[clusterName])) {
@@ -758,17 +519,6 @@ listener, log) {
758
519
  log?.info(`${db}Subscribed endpoint ${or}${endpoint.id}${db}:${or}${endpoint.number}${db} attribute ${hk}${capitalizeFirstLetter(clusterName)}${db}.${hk}${attribute}${db}`);
759
520
  return true;
760
521
  }
761
- /**
762
- * Triggers an event on the specified cluster.
763
- *
764
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to trigger the event on.
765
- * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The ID of the cluster.
766
- * @param {string} event - The name of the event to trigger.
767
- * @param {Record<string, boolean | number | bigint | string | object | undefined | null>} payload - The payload to pass to the event.
768
- * @param {AnsiLogger} [log] - Optional logger for logging information.
769
- *
770
- * @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the event was successfully triggered.
771
- */
772
522
  export async function triggerEvent(endpoint, cluster, event, payload, log) {
773
523
  const clusterName = getBehavior(endpoint, cluster)?.id;
774
524
  if (!clusterName) {
@@ -779,32 +529,15 @@ export async function triggerEvent(endpoint, cluster, event, payload, log) {
779
529
  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`);
780
530
  return false;
781
531
  }
782
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
783
532
  const events = endpoint.events;
784
533
  if (!(clusterName in events) || !(event in events[clusterName])) {
785
534
  endpoint.log.error(`triggerEvent ${hk}${event}${er} error: cluster ${clusterName} not found on endpoint ${or}${endpoint.id}${er}:${or}${endpoint.number}${er}`);
786
535
  return false;
787
536
  }
788
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
789
- // @ts-ignore
790
537
  await endpoint.act((agent) => agent[clusterName].events[event].emit(payload, agent.context));
791
538
  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} `);
792
539
  return true;
793
540
  }
794
- /**
795
- * Get the default OperationalState Cluster Server.
796
- *
797
- * @param {OperationalState.OperationalStateEnum} operationalState - The initial operational state id.
798
- *
799
- * @returns {Behavior.Options<MatterbridgeOperationalStateServer>} - The default options for the OperationalState cluster server.
800
- *
801
- * @remarks
802
- * This method adds a cluster server with a default operational state configuration:
803
- * - { operationalStateId: OperationalState.OperationalStateEnum.Stopped, operationalStateLabel: 'Stopped' },
804
- * - { operationalStateId: OperationalState.OperationalStateEnum.Running, operationalStateLabel: 'Running' },
805
- * - { operationalStateId: OperationalState.OperationalStateEnum.Paused, operationalStateLabel: 'Paused' },
806
- * - { operationalStateId: OperationalState.OperationalStateEnum.Error, operationalStateLabel: 'Error' },
807
- */
808
541
  export function getDefaultOperationalStateClusterServer(operationalState = OperationalState.OperationalStateEnum.Stopped) {
809
542
  return optionsFor(MatterbridgeOperationalStateServer, {
810
543
  phaseList: [],
@@ -820,14 +553,6 @@ export function getDefaultOperationalStateClusterServer(operationalState = Opera
820
553
  operationalError: { errorStateId: OperationalState.ErrorState.NoError, errorStateLabel: 'No error', errorStateDetails: 'Fully operational' },
821
554
  });
822
555
  }
823
- /**
824
- * Get the default TemperatureMeasurement cluster server options.
825
- *
826
- * @param {number | null} measuredValue - The measured value of the temperature x 100.
827
- * @param {number | null} minMeasuredValue - The minimum measured value of the temperature x 100.
828
- * @param {number | null} maxMeasuredValue - The maximum measured value of the temperature x 100.
829
- * @returns {Behavior.Options<MatterbridgeTemperatureMeasurementServer>} - The default options for the TemperatureMeasurement cluster server.
830
- */
831
556
  export function getDefaultTemperatureMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
832
557
  return optionsFor(TemperatureMeasurementServer, {
833
558
  measuredValue,
@@ -836,14 +561,6 @@ export function getDefaultTemperatureMeasurementClusterServer(measuredValue = nu
836
561
  tolerance: 0,
837
562
  });
838
563
  }
839
- /**
840
- * Get the default RelativeHumidityMeasurement cluster server options.
841
- *
842
- * @param {number | null} measuredValue - The measured value of the relative humidity x 100.
843
- * @param {number | null} minMeasuredValue - The minimum measured value of the relative humidity x 100.
844
- * @param {number | null} maxMeasuredValue - The maximum measured value of the relative humidity x 100.
845
- * @returns {Behavior.Options<MatterbridgeRelativeHumidityMeasurementServer>} - The default options for the RelativeHumidityMeasurement cluster server.
846
- */
847
564
  export function getDefaultRelativeHumidityMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
848
565
  return optionsFor(RelativeHumidityMeasurementServer, {
849
566
  measuredValue,
@@ -852,14 +569,6 @@ export function getDefaultRelativeHumidityMeasurementClusterServer(measuredValue
852
569
  tolerance: 0,
853
570
  });
854
571
  }
855
- /**
856
- * Get the default PressureMeasurement cluster server options.
857
- *
858
- * @param {number | null} measuredValue - The measured value for the pressure in kPa x 10.
859
- * @param {number | null} minMeasuredValue - The minimum measured value for the pressure in kPa x 10.
860
- * @param {number | null} maxMeasuredValue - The maximum measured value for the pressure in kPa x 10.
861
- * @returns {Behavior.Options<MatterbridgePressureMeasurementServer>} - The default options for the PressureMeasurement cluster server.
862
- */
863
572
  export function getDefaultPressureMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
864
573
  return optionsFor(PressureMeasurementServer, {
865
574
  measuredValue,
@@ -868,22 +577,6 @@ export function getDefaultPressureMeasurementClusterServer(measuredValue = null,
868
577
  tolerance: 0,
869
578
  });
870
579
  }
871
- /**
872
- * Get the default IlluminanceMeasurement cluster server options.
873
- *
874
- * @param {number | null} measuredValue - The measured value of illuminance.
875
- * @param {number | null} minMeasuredValue - The minimum measured value of illuminance.
876
- * @param {number | null} maxMeasuredValue - The maximum measured value of illuminance.
877
- *
878
- * @returns {Behavior.Options<MatterbridgeIlluminanceMeasurementServer>} - The default options for the IlluminanceMeasurement cluster server.
879
- *
880
- * @remarks The default value for the illuminance measurement is null.
881
- * This attribute SHALL indicate the illuminance in Lux (symbol lx) as follows:
882
- * • MeasuredValue = 10,000 x log10(illuminance) + 1,
883
- * where 1 lx <= illuminance <= 3.576 Mlx, corresponding to a MeasuredValue in the range 1 to 0xFFFE.
884
- * • 0 indicates a value of illuminance that is too low to be measured
885
- * • null indicates that the illuminance measurement is invalid.
886
- */
887
580
  export function getDefaultIlluminanceMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
888
581
  return optionsFor(IlluminanceMeasurementServer, {
889
582
  measuredValue,
@@ -892,14 +585,6 @@ export function getDefaultIlluminanceMeasurementClusterServer(measuredValue = nu
892
585
  tolerance: 0,
893
586
  });
894
587
  }
895
- /**
896
- * Get the default FlowMeasurement cluster server options.
897
- *
898
- * @param {number | null} measuredValue - The measured value of the flow in 10 x m3/h.
899
- * @param {number | null} minMeasuredValue - The minimum measured value of the flow in 10 x m3/h.
900
- * @param {number | null} maxMeasuredValue - The maximum measured value of the flow in 10 x m3/h.
901
- * @returns {Behavior.Options<MatterbridgeFlowMeasurementServer>} - The default options for the FlowMeasurement cluster server.
902
- */
903
588
  export function getDefaultFlowMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
904
589
  return optionsFor(FlowMeasurementServer, {
905
590
  measuredValue,
@@ -908,20 +593,6 @@ export function getDefaultFlowMeasurementClusterServer(measuredValue = null, min
908
593
  tolerance: 0,
909
594
  });
910
595
  }
911
- /**
912
- * Get the default OccupancySensing cluster server options.
913
- *
914
- * @param {boolean} occupied - A boolean indicating whether the occupancy is occupied or not. Default is false.
915
- * @param {number} holdTime - The hold time in seconds. Default is 30.
916
- * @param {number} holdTimeMin - The minimum hold time in seconds. Default is 1.
917
- * @param {number} holdTimeMax - The maximum hold time in seconds. Default is 300.
918
- * @returns {Behavior.Options<MatterbridgeOccupancySensingServer>} - The default options for the OccupancySensing cluster server.
919
- *
920
- * @remarks The default value for the occupancy sensor type is PIR.
921
- * Servers SHALL set these attributes for backward compatibility with clients implementing a cluster revision <= 4 as
922
- * described in OccupancySensorType and OccupancySensorTypeBitmap Attributes.
923
- * This replaces the 9 legacy attributes PIROccupiedToUnoccupiedDelay through PhysicalContactUnoccupiedToOccupiedThreshold.
924
- */
925
596
  export function getDefaultOccupancySensingClusterServer(occupied = false, holdTime = 30, holdTimeMin = 1, holdTimeMax = 300) {
926
597
  return optionsFor(OccupancySensingServer.with(OccupancySensing.Feature.PassiveInfrared), {
927
598
  occupancy: { occupied },
@@ -933,13 +604,6 @@ export function getDefaultOccupancySensingClusterServer(occupied = false, holdTi
933
604
  holdTimeLimits: { holdTimeMin, holdTimeMax, holdTimeDefault: holdTime },
934
605
  });
935
606
  }
936
- /**
937
- * Get the default Electrical Energy Measurement Cluster Server options with features ImportedEnergy, ExportedEnergy, and CumulativeEnergy.
938
- *
939
- * @param {number} energyImported - The total consumption value in mW/h.
940
- * @param {number} energyExported - The total production value in mW/h.
941
- * @returns {Behavior.Options<ElectricalEnergyMeasurementServer>} - The default options for the Electrical Energy Measurement Cluster Server.
942
- */
943
607
  export function getDefaultElectricalEnergyMeasurementClusterServer(energyImported = null, energyExported = null) {
944
608
  return optionsFor(ElectricalEnergyMeasurementServer.with(ElectricalEnergyMeasurement.Feature.ImportedEnergy, ElectricalEnergyMeasurement.Feature.ExportedEnergy, ElectricalEnergyMeasurement.Feature.CumulativeEnergy), {
945
609
  accuracy: {
@@ -954,15 +618,6 @@ export function getDefaultElectricalEnergyMeasurementClusterServer(energyImporte
954
618
  cumulativeEnergyExported: energyExported !== null && energyExported >= 0 ? { energy: energyExported } : null,
955
619
  });
956
620
  }
957
- /**
958
- * Get the default Electrical Power Measurement Cluster Server options with features AlternatingCurrent.
959
- *
960
- * @param {number} voltage - The voltage value in millivolts.
961
- * @param {number} current - The current value in milliamperes.
962
- * @param {number} power - The power value in milliwatts.
963
- * @param {number} frequency - The frequency value in millihertz.
964
- * @returns {Behavior.Options<ElectricalPowerMeasurementServer>} - The default options for the Electrical Power Measurement Cluster Server.
965
- */
966
621
  export function getDefaultElectricalPowerMeasurementClusterServer(voltage = null, current = null, power = null, frequency = null) {
967
622
  return optionsFor(ElectricalPowerMeasurementServer.with(ElectricalPowerMeasurement.Feature.AlternatingCurrent), {
968
623
  powerMode: ElectricalPowerMeasurement.PowerMode.Ac,
@@ -1003,15 +658,6 @@ export function getDefaultElectricalPowerMeasurementClusterServer(voltage = null
1003
658
  frequency: frequency,
1004
659
  });
1005
660
  }
1006
- /**
1007
- * Get the default Electrical Apparent Power Measurement Cluster Server with features AlternatingCurrent.
1008
- *
1009
- * @param {number} voltage - The voltage value in millivolts.
1010
- * @param {number} apparentCurrent - The current value in milliamperes.
1011
- * @param {number} apparentPower - The apparent power value in millivoltamperes.
1012
- * @param {number} frequency - The frequency value in millihertz.
1013
- * @returns {Behavior.Options<ElectricalPowerMeasurementServer>} - The default options for the Electrical Apparent Power Measurement Cluster Server.
1014
- */
1015
661
  export function getApparentElectricalPowerMeasurementClusterServer(voltage = null, apparentCurrent = null, apparentPower = null, frequency = null) {
1016
662
  return optionsFor(ElectricalPowerMeasurementServer.with(ElectricalPowerMeasurement.Feature.AlternatingCurrent), {
1017
663
  powerMode: ElectricalPowerMeasurement.PowerMode.Ac,
@@ -1052,4 +698,3 @@ export function getApparentElectricalPowerMeasurementClusterServer(voltage = nul
1052
698
  frequency: frequency,
1053
699
  });
1054
700
  }
1055
- //# sourceMappingURL=matterbridgeEndpointHelpers.js.map