matterbridge 3.1.8-dev-20250727-662308b → 3.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (248) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/dist/cli.d.ts +26 -0
  3. package/dist/cli.d.ts.map +1 -0
  4. package/dist/cli.js +91 -2
  5. package/dist/cli.js.map +1 -0
  6. package/dist/cliEmitter.d.ts +34 -0
  7. package/dist/cliEmitter.d.ts.map +1 -0
  8. package/dist/cliEmitter.js +30 -0
  9. package/dist/cliEmitter.js.map +1 -0
  10. package/dist/clusters/export.d.ts +2 -0
  11. package/dist/clusters/export.d.ts.map +1 -0
  12. package/dist/clusters/export.js +2 -0
  13. package/dist/clusters/export.js.map +1 -0
  14. package/dist/defaultConfigSchema.d.ts +28 -0
  15. package/dist/defaultConfigSchema.d.ts.map +1 -0
  16. package/dist/defaultConfigSchema.js +24 -0
  17. package/dist/defaultConfigSchema.js.map +1 -0
  18. package/dist/deviceManager.d.ts +112 -0
  19. package/dist/deviceManager.d.ts.map +1 -0
  20. package/dist/deviceManager.js +94 -1
  21. package/dist/deviceManager.js.map +1 -0
  22. package/dist/devices/batteryStorage.d.ts +48 -0
  23. package/dist/devices/batteryStorage.d.ts.map +1 -0
  24. package/dist/devices/batteryStorage.js +48 -1
  25. package/dist/devices/batteryStorage.js.map +1 -0
  26. package/dist/devices/dishwasher.d.ts +91 -0
  27. package/dist/devices/dishwasher.d.ts.map +1 -0
  28. package/dist/devices/dishwasher.js +78 -3
  29. package/dist/devices/dishwasher.js.map +1 -0
  30. package/dist/devices/evse.d.ts +75 -0
  31. package/dist/devices/evse.d.ts.map +1 -0
  32. package/dist/devices/evse.js +74 -10
  33. package/dist/devices/evse.js.map +1 -0
  34. package/dist/devices/export.d.ts +11 -0
  35. package/dist/devices/export.d.ts.map +1 -0
  36. package/dist/devices/export.js +2 -0
  37. package/dist/devices/export.js.map +1 -0
  38. package/dist/devices/extractorHood.d.ts +46 -0
  39. package/dist/devices/extractorHood.d.ts.map +1 -0
  40. package/dist/devices/extractorHood.js +42 -0
  41. package/dist/devices/extractorHood.js.map +1 -0
  42. package/dist/devices/heatPump.d.ts +47 -0
  43. package/dist/devices/heatPump.d.ts.map +1 -0
  44. package/dist/devices/heatPump.js +50 -2
  45. package/dist/devices/heatPump.js.map +1 -0
  46. package/dist/devices/laundryDryer.d.ts +87 -0
  47. package/dist/devices/laundryDryer.d.ts.map +1 -0
  48. package/dist/devices/laundryDryer.js +83 -6
  49. package/dist/devices/laundryDryer.js.map +1 -0
  50. package/dist/devices/laundryWasher.d.ts +242 -0
  51. package/dist/devices/laundryWasher.d.ts.map +1 -0
  52. package/dist/devices/laundryWasher.js +91 -7
  53. package/dist/devices/laundryWasher.js.map +1 -0
  54. package/dist/devices/roboticVacuumCleaner.d.ts +112 -0
  55. package/dist/devices/roboticVacuumCleaner.d.ts.map +1 -0
  56. package/dist/devices/roboticVacuumCleaner.js +93 -7
  57. package/dist/devices/roboticVacuumCleaner.js.map +1 -0
  58. package/dist/devices/solarPower.d.ts +40 -0
  59. package/dist/devices/solarPower.d.ts.map +1 -0
  60. package/dist/devices/solarPower.js +38 -0
  61. package/dist/devices/solarPower.js.map +1 -0
  62. package/dist/devices/waterHeater.d.ts +111 -0
  63. package/dist/devices/waterHeater.d.ts.map +1 -0
  64. package/dist/devices/waterHeater.js +82 -2
  65. package/dist/devices/waterHeater.js.map +1 -0
  66. package/dist/dgram/coap.d.ts +205 -0
  67. package/dist/dgram/coap.d.ts.map +1 -0
  68. package/dist/dgram/coap.js +126 -13
  69. package/dist/dgram/coap.js.map +1 -0
  70. package/dist/dgram/dgram.d.ts +140 -0
  71. package/dist/dgram/dgram.d.ts.map +1 -0
  72. package/dist/dgram/dgram.js +113 -2
  73. package/dist/dgram/dgram.js.map +1 -0
  74. package/dist/dgram/mb_coap.d.ts +24 -0
  75. package/dist/dgram/mb_coap.d.ts.map +1 -0
  76. package/dist/dgram/mb_coap.js +41 -3
  77. package/dist/dgram/mb_coap.js.map +1 -0
  78. package/dist/dgram/mb_mdns.d.ts +24 -0
  79. package/dist/dgram/mb_mdns.d.ts.map +1 -0
  80. package/dist/dgram/mb_mdns.js +51 -13
  81. package/dist/dgram/mb_mdns.js.map +1 -0
  82. package/dist/dgram/mdns.d.ts +288 -0
  83. package/dist/dgram/mdns.d.ts.map +1 -0
  84. package/dist/dgram/mdns.js +298 -137
  85. package/dist/dgram/mdns.js.map +1 -0
  86. package/dist/dgram/multicast.d.ts +65 -0
  87. package/dist/dgram/multicast.d.ts.map +1 -0
  88. package/dist/dgram/multicast.js +60 -1
  89. package/dist/dgram/multicast.js.map +1 -0
  90. package/dist/dgram/unicast.d.ts +56 -0
  91. package/dist/dgram/unicast.d.ts.map +1 -0
  92. package/dist/dgram/unicast.js +54 -0
  93. package/dist/dgram/unicast.js.map +1 -0
  94. package/dist/frontend.d.ts +313 -0
  95. package/dist/frontend.d.ts.map +1 -0
  96. package/dist/frontend.js +449 -23
  97. package/dist/frontend.js.map +1 -0
  98. package/dist/globalMatterbridge.d.ts +59 -0
  99. package/dist/globalMatterbridge.d.ts.map +1 -0
  100. package/dist/globalMatterbridge.js +47 -0
  101. package/dist/globalMatterbridge.js.map +1 -0
  102. package/dist/helpers.d.ts +48 -0
  103. package/dist/helpers.d.ts.map +1 -0
  104. package/dist/helpers.js +53 -0
  105. package/dist/helpers.js.map +1 -0
  106. package/dist/index.d.ts +33 -0
  107. package/dist/index.d.ts.map +1 -0
  108. package/dist/index.js +30 -1
  109. package/dist/index.js.map +1 -0
  110. package/dist/logger/export.d.ts +2 -0
  111. package/dist/logger/export.d.ts.map +1 -0
  112. package/dist/logger/export.js +1 -0
  113. package/dist/logger/export.js.map +1 -0
  114. package/dist/matter/behaviors.d.ts +2 -0
  115. package/dist/matter/behaviors.d.ts.map +1 -0
  116. package/dist/matter/behaviors.js +2 -0
  117. package/dist/matter/behaviors.js.map +1 -0
  118. package/dist/matter/clusters.d.ts +2 -0
  119. package/dist/matter/clusters.d.ts.map +1 -0
  120. package/dist/matter/clusters.js +2 -0
  121. package/dist/matter/clusters.js.map +1 -0
  122. package/dist/matter/devices.d.ts +2 -0
  123. package/dist/matter/devices.d.ts.map +1 -0
  124. package/dist/matter/devices.js +2 -0
  125. package/dist/matter/devices.js.map +1 -0
  126. package/dist/matter/endpoints.d.ts +2 -0
  127. package/dist/matter/endpoints.d.ts.map +1 -0
  128. package/dist/matter/endpoints.js +2 -0
  129. package/dist/matter/endpoints.js.map +1 -0
  130. package/dist/matter/export.d.ts +5 -0
  131. package/dist/matter/export.d.ts.map +1 -0
  132. package/dist/matter/export.js +3 -0
  133. package/dist/matter/export.js.map +1 -0
  134. package/dist/matter/types.d.ts +3 -0
  135. package/dist/matter/types.d.ts.map +1 -0
  136. package/dist/matter/types.js +3 -0
  137. package/dist/matter/types.js.map +1 -0
  138. package/dist/matterbridge.d.ts +463 -0
  139. package/dist/matterbridge.d.ts.map +1 -0
  140. package/dist/matterbridge.js +803 -50
  141. package/dist/matterbridge.js.map +1 -0
  142. package/dist/matterbridgeAccessoryPlatform.d.ts +42 -0
  143. package/dist/matterbridgeAccessoryPlatform.d.ts.map +1 -0
  144. package/dist/matterbridgeAccessoryPlatform.js +36 -0
  145. package/dist/matterbridgeAccessoryPlatform.js.map +1 -0
  146. package/dist/matterbridgeBehaviors.d.ts +1351 -0
  147. package/dist/matterbridgeBehaviors.d.ts.map +1 -0
  148. package/dist/matterbridgeBehaviors.js +65 -5
  149. package/dist/matterbridgeBehaviors.js.map +1 -0
  150. package/dist/matterbridgeDeviceTypes.d.ts +709 -0
  151. package/dist/matterbridgeDeviceTypes.d.ts.map +1 -0
  152. package/dist/matterbridgeDeviceTypes.js +579 -15
  153. package/dist/matterbridgeDeviceTypes.js.map +1 -0
  154. package/dist/matterbridgeDynamicPlatform.d.ts +42 -0
  155. package/dist/matterbridgeDynamicPlatform.d.ts.map +1 -0
  156. package/dist/matterbridgeDynamicPlatform.js +36 -0
  157. package/dist/matterbridgeDynamicPlatform.js.map +1 -0
  158. package/dist/matterbridgeEndpoint.d.ts +1348 -0
  159. package/dist/matterbridgeEndpoint.d.ts.map +1 -0
  160. package/dist/matterbridgeEndpoint.js +1214 -54
  161. package/dist/matterbridgeEndpoint.js.map +1 -0
  162. package/dist/matterbridgeEndpointHelpers.d.ts +406 -0
  163. package/dist/matterbridgeEndpointHelpers.d.ts.map +1 -0
  164. package/dist/matterbridgeEndpointHelpers.js +344 -12
  165. package/dist/matterbridgeEndpointHelpers.js.map +1 -0
  166. package/dist/matterbridgePlatform.d.ts +310 -0
  167. package/dist/matterbridgePlatform.d.ts.map +1 -0
  168. package/dist/matterbridgePlatform.js +233 -0
  169. package/dist/matterbridgePlatform.js.map +1 -0
  170. package/dist/matterbridgeTypes.d.ts +197 -0
  171. package/dist/matterbridgeTypes.d.ts.map +1 -0
  172. package/dist/matterbridgeTypes.js +25 -0
  173. package/dist/matterbridgeTypes.js.map +1 -0
  174. package/dist/pluginManager.d.ts +270 -0
  175. package/dist/pluginManager.d.ts.map +1 -0
  176. package/dist/pluginManager.js +249 -3
  177. package/dist/pluginManager.js.map +1 -0
  178. package/dist/shelly.d.ts +174 -0
  179. package/dist/shelly.d.ts.map +1 -0
  180. package/dist/shelly.js +168 -7
  181. package/dist/shelly.js.map +1 -0
  182. package/dist/storage/export.d.ts +2 -0
  183. package/dist/storage/export.d.ts.map +1 -0
  184. package/dist/storage/export.js +1 -0
  185. package/dist/storage/export.js.map +1 -0
  186. package/dist/update.d.ts +68 -0
  187. package/dist/update.d.ts.map +1 -0
  188. package/dist/update.js +63 -0
  189. package/dist/update.js.map +1 -0
  190. package/dist/utils/colorUtils.d.ts +117 -0
  191. package/dist/utils/colorUtils.d.ts.map +1 -0
  192. package/dist/utils/colorUtils.js +263 -2
  193. package/dist/utils/colorUtils.js.map +1 -0
  194. package/dist/utils/commandLine.d.ts +59 -0
  195. package/dist/utils/commandLine.d.ts.map +1 -0
  196. package/dist/utils/commandLine.js +54 -0
  197. package/dist/utils/commandLine.js.map +1 -0
  198. package/dist/utils/copyDirectory.d.ts +33 -0
  199. package/dist/utils/copyDirectory.d.ts.map +1 -0
  200. package/dist/utils/copyDirectory.js +38 -1
  201. package/dist/utils/copyDirectory.js.map +1 -0
  202. package/dist/utils/createDirectory.d.ts +34 -0
  203. package/dist/utils/createDirectory.d.ts.map +1 -0
  204. package/dist/utils/createDirectory.js +33 -0
  205. package/dist/utils/createDirectory.js.map +1 -0
  206. package/dist/utils/createZip.d.ts +39 -0
  207. package/dist/utils/createZip.d.ts.map +1 -0
  208. package/dist/utils/createZip.js +47 -2
  209. package/dist/utils/createZip.js.map +1 -0
  210. package/dist/utils/deepCopy.d.ts +32 -0
  211. package/dist/utils/deepCopy.d.ts.map +1 -0
  212. package/dist/utils/deepCopy.js +39 -0
  213. package/dist/utils/deepCopy.js.map +1 -0
  214. package/dist/utils/deepEqual.d.ts +54 -0
  215. package/dist/utils/deepEqual.d.ts.map +1 -0
  216. package/dist/utils/deepEqual.js +72 -1
  217. package/dist/utils/deepEqual.js.map +1 -0
  218. package/dist/utils/error.d.ts +44 -0
  219. package/dist/utils/error.d.ts.map +1 -0
  220. package/dist/utils/error.js +41 -0
  221. package/dist/utils/error.js.map +1 -0
  222. package/dist/utils/export.d.ts +12 -0
  223. package/dist/utils/export.d.ts.map +1 -0
  224. package/dist/utils/export.js +1 -0
  225. package/dist/utils/export.js.map +1 -0
  226. package/dist/utils/hex.d.ts +89 -0
  227. package/dist/utils/hex.d.ts.map +1 -0
  228. package/dist/utils/hex.js +123 -0
  229. package/dist/utils/hex.js.map +1 -0
  230. package/dist/utils/isvalid.d.ts +103 -0
  231. package/dist/utils/isvalid.d.ts.map +1 -0
  232. package/dist/utils/isvalid.js +101 -0
  233. package/dist/utils/isvalid.js.map +1 -0
  234. package/dist/utils/network.d.ts +74 -0
  235. package/dist/utils/network.d.ts.map +1 -0
  236. package/dist/utils/network.js +81 -5
  237. package/dist/utils/network.js.map +1 -0
  238. package/dist/utils/spawn.d.ts +33 -0
  239. package/dist/utils/spawn.d.ts.map +1 -0
  240. package/dist/utils/spawn.js +40 -0
  241. package/dist/utils/spawn.js.map +1 -0
  242. package/dist/utils/wait.d.ts +56 -0
  243. package/dist/utils/wait.d.ts.map +1 -0
  244. package/dist/utils/wait.js +62 -9
  245. package/dist/utils/wait.js.map +1 -0
  246. package/npm-shrinkwrap.json +2 -2
  247. package/package.json +2 -1
  248. package/vitest/matterbridge.test.ts +0 -218
@@ -1,5 +1,30 @@
1
+ /**
2
+ * This file contains the class MatterbridgeEndpoint that extends the Endpoint class from the Matter.js library.
3
+ *
4
+ * @file matterbridgeEndpoint.ts
5
+ * @author Luca Liguori
6
+ * @created 2024-10-01
7
+ * @version 2.1.1
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
+ // @matter
1
25
  import { Endpoint, Lifecycle, MutableEndpoint, NamedHandler, SupportedBehaviors, UINT16_MAX, UINT32_MAX, VendorId } from '@matter/main';
2
26
  import { getClusterNameById, MeasurementType } from '@matter/main/types';
27
+ // @matter clusters
3
28
  import { Descriptor } from '@matter/main/clusters/descriptor';
4
29
  import { PowerSource } from '@matter/main/clusters/power-source';
5
30
  import { BridgedDeviceBasicInformation } from '@matter/main/clusters/bridged-device-basic-information';
@@ -26,6 +51,7 @@ import { ThermostatUserInterfaceConfiguration } from '@matter/main/clusters/ther
26
51
  import { OperationalState } from '@matter/main/clusters/operational-state';
27
52
  import { DeviceEnergyManagement } from '@matter/main/clusters/device-energy-management';
28
53
  import { DeviceEnergyManagementMode } from '@matter/main/clusters/device-energy-management-mode';
54
+ // @matter behaviors
29
55
  import { DescriptorServer } from '@matter/main/behaviors/descriptor';
30
56
  import { PowerSourceServer } from '@matter/main/behaviors/power-source';
31
57
  import { BridgedDeviceBasicInformationServer } from '@matter/main/behaviors/bridged-device-basic-information';
@@ -57,18 +83,39 @@ import { TotalVolatileOrganicCompoundsConcentrationMeasurementServer } from '@ma
57
83
  import { FanControlServer } from '@matter/main/behaviors/fan-control';
58
84
  import { ResourceMonitoring } from '@matter/main/clusters/resource-monitoring';
59
85
  import { ThermostatUserInterfaceConfigurationServer } from '@matter/main/behaviors/thermostat-user-interface-configuration';
86
+ // AnsiLogger module
60
87
  import { AnsiLogger, CYAN, YELLOW, db, debugStringify, hk, or, zb } from './logger/export.js';
88
+ // Matterbridge
61
89
  import { bridgedNode } from './matterbridgeDeviceTypes.js';
62
90
  import { isValidNumber, isValidObject, isValidString } from './utils/export.js';
63
91
  import { MatterbridgeServer, MatterbridgeIdentifyServer, MatterbridgeOnOffServer, MatterbridgeLevelControlServer, MatterbridgeColorControlServer, MatterbridgeLiftWindowCoveringServer, MatterbridgeLiftTiltWindowCoveringServer, MatterbridgeThermostatServer, MatterbridgeFanControlServer, MatterbridgeDoorLockServer, MatterbridgeModeSelectServer, MatterbridgeValveConfigurationAndControlServer, MatterbridgeSmokeCoAlarmServer, MatterbridgeBooleanStateConfigurationServer, MatterbridgeSwitchServer, MatterbridgeOperationalStateServer, MatterbridgeDeviceEnergyManagementModeServer, MatterbridgeDeviceEnergyManagementServer, MatterbridgeActivatedCarbonFilterMonitoringServer, MatterbridgeHepaFilterMonitoringServer, } from './matterbridgeBehaviors.js';
64
92
  import { addClusterServers, addFixedLabel, addOptionalClusterServers, addRequiredClusterServers, addUserLabel, createUniqueId, getBehavior, getBehaviourTypesFromClusterClientIds, getBehaviourTypesFromClusterServerIds, getDefaultOperationalStateClusterServer, getDefaultFlowMeasurementClusterServer, getDefaultIlluminanceMeasurementClusterServer, getDefaultPressureMeasurementClusterServer, getDefaultRelativeHumidityMeasurementClusterServer, getDefaultTemperatureMeasurementClusterServer, getDefaultOccupancySensingClusterServer, lowercaseFirstLetter, updateAttribute, getClusterId, getAttributeId, setAttribute, getAttribute, checkNotLatinCharacters, generateUniqueId, subscribeAttribute, invokeBehaviorCommand, triggerEvent, featuresFor, } from './matterbridgeEndpointHelpers.js';
65
93
  export class MatterbridgeEndpoint extends Endpoint {
94
+ /** The bridge mode of Matterbridge */
66
95
  static bridgeMode = '';
67
- static logLevel = "info";
96
+ /** The default log level of the new MatterbridgeEndpoints */
97
+ static logLevel = "info" /* LogLevel.INFO */;
98
+ /**
99
+ * Activates a special mode for this endpoint.
100
+ * - 'server': it creates the device server node and add the device as Matter device that needs to be paired individually.
101
+ * In this case the bridge mode is not relevant. The device is autonomous. The main use case is a workaround for the Apple Home rvc issue.
102
+ *
103
+ * - 'matter': it adds the device directly to the bridge server node as Matter device. In this case the implementation must respect
104
+ * the 9.2.3. Disambiguation rule (i.e. use taglist if needed cause the device doesn't have nodeLabel).
105
+ * Furthermore the device will be a part of the bridge (i.e. will have the same name and will be in the same room).
106
+ * See 9.12.2.2. Native Matter functionality in Bridge.
107
+ *
108
+ * @remarks
109
+ * Always use createDefaultBasicInformationClusterServer() to create the BasicInformation cluster server.
110
+ */
68
111
  mode = undefined;
112
+ /** The server node of the endpoint, if it is a single not bridged endpoint */
69
113
  serverNode;
114
+ /** The logger instance for the MatterbridgeEndpoint */
70
115
  log;
116
+ /** The plugin name this MatterbridgeEndpoint belongs to */
71
117
  plugin = undefined;
118
+ /** The configuration URL of the device, if available */
72
119
  configUrl = undefined;
73
120
  deviceName = undefined;
74
121
  serialNumber = undefined;
@@ -82,14 +129,28 @@ export class MatterbridgeEndpoint extends Endpoint {
82
129
  hardwareVersion = undefined;
83
130
  hardwareVersionString = undefined;
84
131
  productUrl = 'https://www.npmjs.com/package/matterbridge';
132
+ /** The name of the first device type of the endpoint (old api compatibility) */
85
133
  name = undefined;
134
+ /** The code of the first device type of the endpoint (old api compatibility) */
86
135
  deviceType = undefined;
136
+ /** The original id (with spaces and .) of the endpoint (old api compatibility) */
87
137
  uniqueStorageKey = undefined;
88
138
  tagList = undefined;
139
+ /** Maps the DeviceTypeDefinitions with their code */
89
140
  deviceTypes = new Map();
141
+ /** Command handler for the MatterbridgeEndpoint commands */
90
142
  commandHandler = new NamedHandler();
143
+ /**
144
+ * Represents a MatterbridgeEndpoint.
145
+ *
146
+ * @class MatterbridgeEndpoint
147
+ * @param {DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>} definition - The DeviceTypeDefinition(s) of the endpoint.
148
+ * @param {MatterbridgeEndpointOptions} [options] - The options for the device.
149
+ * @param {boolean} [debug] - Debug flag.
150
+ */
91
151
  constructor(definition, options = {}, debug = false) {
92
152
  let deviceTypeList = [];
153
+ // Get the first DeviceTypeDefinition
93
154
  let firstDefinition;
94
155
  if (Array.isArray(definition)) {
95
156
  firstDefinition = definition[0];
@@ -102,6 +163,7 @@ export class MatterbridgeEndpoint extends Endpoint {
102
163
  firstDefinition = definition;
103
164
  deviceTypeList = [{ deviceType: firstDefinition.code, revision: firstDefinition.revision }];
104
165
  }
166
+ // Convert the first DeviceTypeDefinition to an EndpointType.Options
105
167
  const deviceTypeDefinitionV8 = {
106
168
  name: firstDefinition.name.replace('-', '_'),
107
169
  deviceType: firstDefinition.code,
@@ -120,17 +182,20 @@ export class MatterbridgeEndpoint extends Endpoint {
120
182
  behaviors: options.tagList ? SupportedBehaviors(DescriptorServer.with(Descriptor.Feature.TagList)) : {},
121
183
  };
122
184
  const endpointV8 = MutableEndpoint(deviceTypeDefinitionV8);
185
+ // Check if the uniqueStorageKey is valid
123
186
  if (options.uniqueStorageKey && checkNotLatinCharacters(options.uniqueStorageKey)) {
124
187
  options.uniqueStorageKey = generateUniqueId(options.uniqueStorageKey);
125
188
  }
126
189
  if (options.id && checkNotLatinCharacters(options.id)) {
127
190
  options.id = generateUniqueId(options.id);
128
191
  }
192
+ // Convert the options to an Endpoint.Options
129
193
  const optionsV8 = {
130
194
  id: options.uniqueStorageKey?.replace(/[ .]/g, ''),
131
195
  number: options.endpointId,
132
196
  descriptor: options.tagList ? { tagList: options.tagList, deviceTypeList } : { deviceTypeList },
133
197
  };
198
+ // Override the deprecated uniqueStorageKey && endpointId with id and number if provided
134
199
  if (options.id !== undefined) {
135
200
  optionsV8.id = options.id.replace(/[ .]/g, '');
136
201
  }
@@ -150,16 +215,40 @@ export class MatterbridgeEndpoint extends Endpoint {
150
215
  }
151
216
  else
152
217
  this.deviceTypes.set(firstDefinition.code, firstDefinition);
153
- this.log = new AnsiLogger({ logName: options.uniqueStorageKey ?? 'MatterbridgeEndpoint', logTimestampFormat: 4, logLevel: debug === true ? "debug" : MatterbridgeEndpoint.logLevel });
218
+ // console.log('MatterbridgeEndpoint.option', options);
219
+ // console.log('MatterbridgeEndpoint.endpointV8', endpointV8);
220
+ // console.log('MatterbridgeEndpoint.optionsV8', optionsV8);
221
+ // Create the logger
222
+ this.log = new AnsiLogger({ logName: options.uniqueStorageKey ?? 'MatterbridgeEndpoint', logTimestampFormat: 4 /* TimestampFormat.TIME_MILLIS */, logLevel: debug === true ? "debug" /* LogLevel.DEBUG */ : MatterbridgeEndpoint.logLevel });
154
223
  this.log.debug(`${YELLOW}new${db} MatterbridgeEndpoint: ${zb}${'0x' + firstDefinition.code.toString(16).padStart(4, '0')}${db}-${zb}${firstDefinition.name}${db} mode: ${CYAN}${this.mode}${db} id: ${CYAN}${optionsV8.id}${db} number: ${CYAN}${optionsV8.number}${db} taglist: ${CYAN}${options.tagList ? debugStringify(options.tagList) : 'undefined'}${db}`);
224
+ // Add MatterbridgeServer
155
225
  this.behaviors.require(MatterbridgeServer, { log: this.log, commandHandler: this.commandHandler });
156
226
  }
227
+ /**
228
+ * Loads an instance of the MatterbridgeEndpoint class.
229
+ *
230
+ * @param {DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>} definition - The DeviceTypeDefinition(s) of the device.
231
+ * @param {MatterbridgeEndpointOptions} [options] - The options for the device.
232
+ * @param {boolean} [debug] - Debug flag.
233
+ * @returns {Promise<MatterbridgeEndpoint>} MatterbridgeEndpoint instance.
234
+ */
157
235
  static async loadInstance(definition, options = {}, debug = false) {
158
236
  return new MatterbridgeEndpoint(definition, options, debug);
159
237
  }
238
+ /**
239
+ * Get all the device types of this endpoint.
240
+ *
241
+ * @returns {DeviceTypeDefinition[]} The device types of this endpoint.
242
+ */
160
243
  getDeviceTypes() {
161
244
  return Array.from(this.deviceTypes.values());
162
245
  }
246
+ /**
247
+ * Checks if the provided cluster server is supported by this endpoint.
248
+ *
249
+ * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to check.
250
+ * @returns {boolean} True if the cluster server is supported, false otherwise.
251
+ */
163
252
  hasClusterServer(cluster) {
164
253
  const behavior = getBehavior(this, cluster);
165
254
  if (behavior)
@@ -167,6 +256,13 @@ export class MatterbridgeEndpoint extends Endpoint {
167
256
  else
168
257
  return false;
169
258
  }
259
+ /**
260
+ * Checks if the provided attribute server is supported for a given cluster of this endpoint.
261
+ *
262
+ * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to check.
263
+ * @param {string} attribute - The attribute name to check.
264
+ * @returns {boolean} True if the attribute server is supported, false otherwise.
265
+ */
170
266
  hasAttributeServer(cluster, attribute) {
171
267
  const behavior = getBehavior(this, cluster);
172
268
  if (!behavior || !this.behaviors.supported[behavior.id])
@@ -175,82 +271,239 @@ export class MatterbridgeEndpoint extends Endpoint {
175
271
  const defaults = this.behaviors.defaultsFor(behavior);
176
272
  return lowercaseFirstLetter(attribute) in options || lowercaseFirstLetter(attribute) in defaults;
177
273
  }
274
+ /**
275
+ * Retrieves the initial options for the provided cluster server.
276
+ *
277
+ * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to get options for.
278
+ * @returns {Record<string, boolean | number | bigint | string | object | null> | undefined} The options for the provided cluster server, or undefined if the cluster is not supported.
279
+ */
178
280
  getClusterServerOptions(cluster) {
179
281
  const behavior = getBehavior(this, cluster);
180
282
  if (!behavior)
181
283
  return undefined;
182
284
  return this.behaviors.optionsFor(behavior);
183
285
  }
286
+ /**
287
+ * Retrieves the value of the provided attribute from the given cluster.
288
+ *
289
+ * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to retrieve the attribute from.
290
+ * @param {string} attribute - The name of the attribute to retrieve.
291
+ * @param {AnsiLogger} [log] - Optional logger for error and info messages.
292
+ * @returns {any} The value of the attribute, or undefined if the attribute is not found.
293
+ */
294
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
184
295
  getAttribute(cluster, attribute, log) {
185
296
  return getAttribute(this, cluster, attribute, log);
186
297
  }
298
+ /**
299
+ * Sets the value of an attribute on a cluster server.
300
+ *
301
+ * @param {Behavior.Type | ClusterType | ClusterId | string} clusterId - The ID of the cluster.
302
+ * @param {string} attribute - The name of the attribute.
303
+ * @param {boolean | number | bigint | string | object | null} value - The value to set for the attribute.
304
+ * @param {AnsiLogger} [log] - (Optional) The logger to use for logging errors and information.
305
+ * @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the attribute was successfully set.
306
+ */
187
307
  async setAttribute(clusterId, attribute, value, log) {
188
308
  return await setAttribute(this, clusterId, attribute, value, log);
189
309
  }
310
+ /**
311
+ * Update the value of an attribute on a cluster server only if the value is different.
312
+ *
313
+ * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to set the attribute on.
314
+ * @param {string} attribute - The name of the attribute.
315
+ * @param {boolean | number | bigint | string | object | null} value - The value to set for the attribute.
316
+ * @param {AnsiLogger} [log] - (Optional) The logger to use for logging the update. Errors are logged to the endpoint logger.
317
+ * @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the attribute was successfully set.
318
+ */
190
319
  async updateAttribute(cluster, attribute, value, log) {
191
320
  return await updateAttribute(this, cluster, attribute, value, log);
192
321
  }
322
+ /**
323
+ * Subscribes to the provided attribute on a cluster.
324
+ *
325
+ * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to subscribe the attribute to.
326
+ * @param {string} attribute - The name of the attribute to subscribe to.
327
+ * @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.
328
+ * @param {AnsiLogger} [log] - Optional logger for logging errors and information.
329
+ * @returns {Promise<boolean>} - A boolean indicating whether the subscription was successful.
330
+ *
331
+ * @remarks The listener function (cannot be async) will receive three parameters:
332
+ * - `newValue`: The new value of the attribute.
333
+ * - `oldValue`: The old value of the attribute.
334
+ * - `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.
335
+ */
336
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
193
337
  async subscribeAttribute(cluster, attribute, listener, log) {
194
338
  return await subscribeAttribute(this, cluster, attribute, listener, log);
195
339
  }
340
+ /**
341
+ * Triggers an event on the specified cluster.
342
+ *
343
+ * @param {ClusterId} cluster - The ID of the cluster.
344
+ * @param {string} event - The name of the event to trigger.
345
+ * @param {Record<string, boolean | number | bigint | string | object | undefined | null>} payload - The payload to pass to the event.
346
+ * @param {AnsiLogger} [log] - Optional logger for logging information.
347
+ * @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the event was successfully triggered.
348
+ */
196
349
  async triggerEvent(cluster, event, payload, log) {
197
350
  return await triggerEvent(this, cluster, event, payload, log);
198
351
  }
352
+ /**
353
+ * Adds cluster servers from the provided server list.
354
+ *
355
+ * @param {ClusterId[]} serverList - The list of cluster IDs to add.
356
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
357
+ */
199
358
  addClusterServers(serverList) {
200
359
  addClusterServers(this, serverList);
201
360
  return this;
202
361
  }
362
+ /**
363
+ * Adds a fixed label to the FixedLabel cluster. If the cluster server is not present, it will be added.
364
+ *
365
+ * @param {string} label - The label to add.
366
+ * @param {string} value - The value of the label.
367
+ * @returns {Promise<this>} The current MatterbridgeEndpoint instance for chaining.
368
+ */
203
369
  async addFixedLabel(label, value) {
204
370
  await addFixedLabel(this, label, value);
205
371
  return this;
206
372
  }
373
+ /**
374
+ * Adds a user label to the UserLabel cluster. If the cluster server is not present, it will be added.
375
+ *
376
+ * @param {string} label - The label to add.
377
+ * @param {string} value - The value of the label.
378
+ * @returns {Promise<this>} The current MatterbridgeEndpoint instance for chaining.
379
+ */
207
380
  async addUserLabel(label, value) {
208
381
  await addUserLabel(this, label, value);
209
382
  return this;
210
383
  }
384
+ /**
385
+ * Adds a command handler for the specified command.
386
+ *
387
+ * @param {keyof MatterbridgeEndpointCommands} command - The command to add the handler for.
388
+ * @param {CommandHandlerFunction} handler - The handler function to execute when the command is received.
389
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
390
+ *
391
+ * @remarks
392
+ * The handler function will receive an object with the following properties:
393
+ * - `request`: The request object sent with the command.
394
+ * - `cluster`: The id of the cluster that received the command (i.e. "onOff").
395
+ * - `attributes`: The current attributes of the cluster that received the command (i.e. { onOff: true}).
396
+ * - `endpoint`: The MatterbridgeEndpoint instance that received the command.
397
+ */
211
398
  addCommandHandler(command, handler) {
212
399
  this.commandHandler.addHandler(command, handler);
213
400
  return this;
214
401
  }
402
+ /**
403
+ * Execute the command handler for the specified command. Used ONLY in Jest tests.
404
+ *
405
+ * @param {keyof MatterbridgeEndpointCommands} command - The command to execute.
406
+ * @param {Record<string, boolean | number | bigint | string | object | null>} [request] - The optional request to pass to the handler function.
407
+ * @param {string} [cluster] - The optional cluster to pass to the handler function.
408
+ * @param {Record<string, boolean | number | bigint | string | object | null>} [attributes] - The optional attributes to pass to the handler function.
409
+ * @param {MatterbridgeEndpoint} [endpoint] - The optional MatterbridgeEndpoint instance to pass to the handler function
410
+ *
411
+ * @deprecated Used ONLY in Jest tests.
412
+ */
215
413
  async executeCommandHandler(command, request, cluster, attributes, endpoint) {
216
414
  await this.commandHandler.executeHandler(command, { request, cluster, attributes, endpoint });
217
415
  }
416
+ /**
417
+ * Invokes a behavior command on the specified cluster. Used ONLY in Jest tests.
418
+ *
419
+ * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to invoke the command on.
420
+ * @param {string} command - The command to invoke.
421
+ * @param {Record<string, boolean | number | bigint | string | object | null>} [params] - The optional parameters to pass to the command.
422
+ *
423
+ * @deprecated Used ONLY in Jest tests.
424
+ */
218
425
  async invokeBehaviorCommand(cluster, command, params) {
219
426
  await invokeBehaviorCommand(this, cluster, command, params);
220
427
  }
428
+ /**
429
+ * Adds the required cluster servers (only if they are not present) for the device types of the specified endpoint.
430
+ *
431
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
432
+ */
221
433
  addRequiredClusterServers() {
222
434
  addRequiredClusterServers(this);
223
435
  return this;
224
436
  }
437
+ /**
438
+ * Adds the optional cluster servers (only if they are not present) for the device types of the specified endpoint.
439
+ *
440
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
441
+ */
225
442
  addOptionalClusterServers() {
226
443
  addOptionalClusterServers(this);
227
444
  return this;
228
445
  }
446
+ /**
447
+ * Retrieves all cluster servers.
448
+ *
449
+ * @returns {Behavior.Type[]} An array of all cluster servers.
450
+ */
229
451
  getAllClusterServers() {
230
452
  return Object.values(this.behaviors.supported);
231
453
  }
454
+ /**
455
+ * Retrieves the names of all cluster servers.
456
+ *
457
+ * @returns {string[]} An array of all cluster server names.
458
+ */
232
459
  getAllClusterServerNames() {
233
460
  return Object.keys(this.behaviors.supported);
234
461
  }
462
+ /**
463
+ * Iterates over each attribute of each cluster server of the device state and calls the provided callback function.
464
+ *
465
+ * @param {Function} callback - The callback function to call with the cluster name, cluster id, attribute name, attribute id and attribute value.
466
+ */
235
467
  forEachAttribute(callback) {
236
468
  if (!this.lifecycle.isReady || this.construction.status !== Lifecycle.Status.Active)
237
469
  return;
238
470
  for (const [clusterName, clusterAttributes] of Object.entries(this.state)) {
471
+ // Skip if the key / cluster name is a number, cause they are double indexed.
239
472
  if (!isNaN(Number(clusterName)))
240
473
  continue;
241
474
  for (const [attributeName, attributeValue] of Object.entries(clusterAttributes)) {
475
+ // Skip if the behavior has no associated cluster (i.e. matterbridge server)
242
476
  const clusterId = getClusterId(this, clusterName);
243
477
  if (clusterId === undefined) {
478
+ // this.log.debug(`***forEachAttribute: cluster ${clusterName} not found`);
244
479
  continue;
245
480
  }
481
+ // Skip if the attribute is not present in the ClusterBehavior.Type. Also skip if the attribute it is an internal state.
246
482
  const attributeId = getAttributeId(this, clusterName, attributeName);
247
483
  if (attributeId === undefined) {
484
+ // this.log.debug(`***forEachAttribute: attribute ${clusterName}.${attributeName} not found`);
248
485
  continue;
249
486
  }
250
487
  callback(clusterName, clusterId, attributeName, attributeId, attributeValue);
251
488
  }
252
489
  }
253
490
  }
491
+ /**
492
+ * Adds a child endpoint with the specified device types and options.
493
+ * If the child endpoint is not already present, it will be created and added.
494
+ * If the child endpoint is already present, the existing child endpoint will be returned.
495
+ *
496
+ * @param {string} endpointName - The name of the new endpoint to add.
497
+ * @param {DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>} definition - The device types to add.
498
+ * @param {MatterbridgeEndpointOptions} [options] - The options for the endpoint.
499
+ * @param {boolean} [debug] - Whether to enable debug logging.
500
+ * @returns {MatterbridgeEndpoint} - The child endpoint that was found or added.
501
+ *
502
+ * @example
503
+ * ```typescript
504
+ * const endpoint = device.addChildDeviceType('Temperature', [temperatureSensor], { tagList: [{ mfgCode: null, namespaceId: LocationTag.Indoor.namespaceId, tag: LocationTag.Indoor.tag, label: null }] }, true);
505
+ * ```
506
+ */
254
507
  addChildDeviceType(endpointName, definition, options = {}, debug = false) {
255
508
  this.log.debug(`addChildDeviceType: ${CYAN}${endpointName}${db}`);
256
509
  let alreadyAdded = false;
@@ -290,6 +543,23 @@ export class MatterbridgeEndpoint extends Endpoint {
290
543
  }
291
544
  return child;
292
545
  }
546
+ /**
547
+ * Adds a child endpoint with one or more device types with the required cluster servers and the specified cluster servers.
548
+ * If the child endpoint is not already present in the childEndpoints, it will be added.
549
+ * If the child endpoint is already present in the childEndpoints, the device types and cluster servers will be added to the existing child endpoint.
550
+ *
551
+ * @param {string} endpointName - The name of the new enpoint to add.
552
+ * @param {DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>} definition - The device types to add.
553
+ * @param {ClusterId[]} [serverList] - The list of cluster IDs to include.
554
+ * @param {MatterbridgeEndpointOptions} [options] - The options for the device.
555
+ * @param {boolean} [debug] - Whether to enable debug logging.
556
+ * @returns {MatterbridgeEndpoint} - The child endpoint that was found or added.
557
+ *
558
+ * @example
559
+ * ```typescript
560
+ * const endpoint = device.addChildDeviceTypeWithClusterServer('Temperature', [temperatureSensor], [], { tagList: [{ mfgCode: null, namespaceId: LocationTag.Indoor.namespaceId, tag: LocationTag.Indoor.tag, label: null }] }, true);
561
+ * ```
562
+ */
293
563
  addChildDeviceTypeWithClusterServer(endpointName, definition, serverList = [], options = {}, debug = false) {
294
564
  this.log.debug(`addChildDeviceTypeWithClusterServer: ${CYAN}${endpointName}${db}`);
295
565
  let alreadyAdded = false;
@@ -352,15 +622,39 @@ export class MatterbridgeEndpoint extends Endpoint {
352
622
  }
353
623
  return child;
354
624
  }
625
+ /**
626
+ * Retrieves a child endpoint by its name.
627
+ *
628
+ * @param {string} endpointName - The name of the endpoint to retrieve.
629
+ * @returns {Endpoint | undefined} The child endpoint with the specified name, or undefined if not found.
630
+ */
355
631
  getChildEndpointByName(endpointName) {
356
632
  return this.parts.find((part) => part.id === endpointName);
357
633
  }
634
+ /**
635
+ * Retrieves a child endpoint by its EndpointNumber.
636
+ *
637
+ * @param {EndpointNumber} endpointNumber - The EndpointNumber of the endpoint to retrieve.
638
+ * @returns {MatterbridgeEndpoint | undefined} The child endpoint with the specified EndpointNumber, or undefined if not found.
639
+ */
358
640
  getChildEndpoint(endpointNumber) {
359
641
  return this.parts.find((part) => part.number === endpointNumber);
360
642
  }
643
+ /**
644
+ * Get all the child endpoints of this endpoint.
645
+ *
646
+ * @returns {MatterbridgeEndpoint[]} The child endpoints.
647
+ */
361
648
  getChildEndpoints() {
362
649
  return Array.from(this.parts);
363
650
  }
651
+ /**
652
+ * Serializes the Matterbridge device into a serialized object.
653
+ *
654
+ * @param {MatterbridgeEndpoint} device - The Matterbridge device to serialize.
655
+ *
656
+ * @returns {SerializedMatterbridgeEndpoint | undefined} The serialized Matterbridge device object.
657
+ */
364
658
  static serialize(device) {
365
659
  if (!device.serialNumber || !device.deviceName || !device.uniqueId)
366
660
  return;
@@ -383,9 +677,16 @@ export class MatterbridgeEndpoint extends Endpoint {
383
677
  serialized.clusterServersId.push(BridgedDeviceBasicInformation.Cluster.id);
384
678
  if (behaviorName === 'powerSource')
385
679
  serialized.clusterServersId.push(PowerSource.Cluster.id);
680
+ // serialized.clusterServersId.push(this.behaviors.supported[behaviorName]cluster.id);
386
681
  });
387
682
  return serialized;
388
683
  }
684
+ /**
685
+ * Deserializes the device into a serialized object.
686
+ *
687
+ * @param {SerializedMatterbridgeEndpoint} serializedDevice - The serialized Matterbridge device object.
688
+ * @returns {MatterbridgeEndpoint | undefined} The deserialized Matterbridge device.
689
+ */
389
690
  static deserialize(serializedDevice) {
390
691
  const device = new MatterbridgeEndpoint(serializedDevice.deviceTypes, { uniqueStorageKey: serializedDevice.endpointName, endpointId: serializedDevice.endpoint }, false);
391
692
  device.plugin = serializedDevice.pluginName;
@@ -401,55 +702,122 @@ export class MatterbridgeEndpoint extends Endpoint {
401
702
  device.createDefaultBridgedDeviceBasicInformationClusterServer(serializedDevice.deviceName, serializedDevice.serialNumber, serializedDevice.vendorId ?? 0xfff1, serializedDevice.vendorName ?? 'Matterbridge', serializedDevice.productName ?? 'Matterbridge device');
402
703
  else if (clusterId === PowerSource.Cluster.id)
403
704
  device.createDefaultPowerSourceWiredClusterServer();
705
+ // else addClusterServerFromList(device, [clusterId]);
404
706
  }
405
707
  return device;
406
708
  }
709
+ /**
710
+ * Creates a default power source wired cluster server.
711
+ *
712
+ * @param {PowerSource.WiredCurrentType} wiredCurrentType - The type of wired current (default: PowerSource.WiredCurrentType.Ac)
713
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
714
+ *
715
+ * @remarks
716
+ * - order: The order of the power source is a persisted attribute that indicates the order in which the power sources are used.
717
+ * - description: The description of the power source is a fixed attribute that describes the power source type.
718
+ * - 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).
719
+ */
407
720
  createDefaultPowerSourceWiredClusterServer(wiredCurrentType = PowerSource.WiredCurrentType.Ac) {
408
721
  this.behaviors.require(PowerSourceServer.with(PowerSource.Feature.Wired), {
722
+ // Base attributes
409
723
  status: PowerSource.PowerSourceStatus.Active,
410
724
  order: 0,
411
725
  description: wiredCurrentType === PowerSource.WiredCurrentType.Ac ? 'AC Power' : 'DC Power',
412
726
  endpointList: [],
727
+ // Wired feature attributes
413
728
  wiredCurrentType,
414
729
  });
415
730
  return this;
416
731
  }
732
+ /**
733
+ * Creates a default power source replaceable battery cluster server.
734
+ *
735
+ * @param {number} batPercentRemaining - The remaining battery percentage (default: 100).
736
+ * @param {PowerSource.BatChargeLevel} batChargeLevel - The battery charge level (default: PowerSource.BatChargeLevel.Ok).
737
+ * @param {number} batVoltage - The battery voltage (default: 1500).
738
+ * @param {string} batReplacementDescription - The description of the battery replacement (default: 'Battery type').
739
+ * @param {number} batQuantity - The quantity of the battery (default: 1).
740
+ * @param {PowerSource.BatReplaceability} batReplaceability - The replaceability of the battery (default: PowerSource.BatReplaceability.Unspecified).
741
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
742
+ *
743
+ * @remarks
744
+ * - order: The order of the power source is a persisted attribute that indicates the order in which the power sources are used.
745
+ * - description: The description of the power source is a fixed attribute that describes the power source type.
746
+ * - batReplaceability: The replaceability of the battery is a fixed attribute that indicates whether the battery is user-replaceable or not.
747
+ * - batReplacementDescription: The description of the battery replacement is a fixed attribute that describes the battery type.
748
+ * - batQuantity: The quantity of the battery is a fixed attribute that indicates how many batteries are present in the device.
749
+ */
417
750
  createDefaultPowerSourceReplaceableBatteryClusterServer(batPercentRemaining = 100, batChargeLevel = PowerSource.BatChargeLevel.Ok, batVoltage = 1500, batReplacementDescription = 'Battery type', batQuantity = 1, batReplaceability = PowerSource.BatReplaceability.UserReplaceable) {
418
751
  this.behaviors.require(PowerSourceServer.with(PowerSource.Feature.Battery, PowerSource.Feature.Replaceable), {
752
+ // Base attributes
419
753
  status: PowerSource.PowerSourceStatus.Active,
420
754
  order: 0,
421
755
  description: 'Primary battery',
422
756
  endpointList: [],
757
+ // Battery feature attributes
423
758
  batVoltage,
424
759
  batPercentRemaining: Math.min(Math.max(batPercentRemaining * 2, 0), 200),
425
760
  batChargeLevel,
426
761
  batReplacementNeeded: false,
427
762
  batReplaceability,
428
763
  activeBatFaults: undefined,
764
+ // Replaceable feature attributes
429
765
  batReplacementDescription,
430
766
  batQuantity,
431
767
  });
432
768
  return this;
433
769
  }
770
+ /**
771
+ * Creates a default power source rechargeable battery cluster server.
772
+ *
773
+ * @param {number} [batPercentRemaining] - The remaining battery percentage (default: 100).
774
+ * @param {PowerSource.BatChargeLevel} [batChargeLevel] - The battery charge level (default: PowerSource.BatChargeLevel.Ok).
775
+ * @param {number} [batVoltage] - The battery voltage in mV (default: 1500).
776
+ * @param {PowerSource.BatReplaceability} [batReplaceability] - The replaceability of the battery (default: PowerSource.BatReplaceability.Unspecified).
777
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
778
+ *
779
+ * @remarks
780
+ * - order: The order of the power source is a persisted attribute that indicates the order in which the power sources are used.
781
+ * - description: The description of the power source is a fixed attribute that describes the power source type.
782
+ * - batReplaceability: The replaceability of the battery is a fixed attribute that indicates whether the battery is user-replaceable or not.
783
+ */
434
784
  createDefaultPowerSourceRechargeableBatteryClusterServer(batPercentRemaining = 100, batChargeLevel = PowerSource.BatChargeLevel.Ok, batVoltage = 1500, batReplaceability = PowerSource.BatReplaceability.Unspecified) {
435
785
  this.behaviors.require(PowerSourceServer.with(PowerSource.Feature.Battery, PowerSource.Feature.Rechargeable), {
786
+ // Base attributes
436
787
  status: PowerSource.PowerSourceStatus.Active,
437
788
  order: 0,
438
789
  description: 'Primary battery',
439
790
  endpointList: [],
791
+ // Battery feature attributes
440
792
  batVoltage,
441
793
  batPercentRemaining: Math.min(Math.max(batPercentRemaining * 2, 0), 200),
442
- batTimeRemaining: null,
794
+ batTimeRemaining: null, // Indicates the estimated time in seconds before the battery will no longer be able to provide power to the Node
443
795
  batChargeLevel,
444
796
  batReplacementNeeded: false,
445
797
  batReplaceability,
446
798
  batPresent: true,
447
799
  activeBatFaults: [],
800
+ // Rechargeable feature attributes
448
801
  batChargeState: PowerSource.BatChargeState.IsNotCharging,
449
802
  batFunctionalWhileCharging: true,
450
803
  });
451
804
  return this;
452
805
  }
806
+ /**
807
+ * Setup the default Basic Information Cluster Server attributes for the server node.
808
+ *
809
+ * @param {string} deviceName - The name of the device.
810
+ * @param {string} serialNumber - The serial number of the device.
811
+ * @param {number} [vendorId] - The vendor ID of the device. Default is 0xfff1 (Matter Test VendorId).
812
+ * @param {string} [vendorName] - The name of the vendor. Default is 'Matterbridge'.
813
+ * @param {number} [productId] - The product ID of the device. Default is 0x8000 (Matter Test ProductId).
814
+ * @param {string} [productName] - The name of the product. Default is 'Matterbridge device'.
815
+ * @param {number} [softwareVersion] - The software version of the device. Default is 1.
816
+ * @param {string} [softwareVersionString] - The software version string of the device. Default is '1.0.0'.
817
+ * @param {number} [hardwareVersion] - The hardware version of the device. Default is 1.
818
+ * @param {string} [hardwareVersionString] - The hardware version string of the device. Default is '1.0.0'.
819
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
820
+ */
453
821
  createDefaultBasicInformationClusterServer(deviceName, serialNumber, vendorId = 0xfff1, vendorName = 'Matterbridge', productId = 0x8000, productName = 'Matterbridge device', softwareVersion = 1, softwareVersionString = '1.0.0', hardwareVersion = 1, hardwareVersionString = '1.0.0') {
454
822
  this.log.logName = deviceName;
455
823
  this.deviceName = deviceName;
@@ -473,6 +841,22 @@ export class MatterbridgeEndpoint extends Endpoint {
473
841
  }
474
842
  return this;
475
843
  }
844
+ /**
845
+ * Creates a default BridgedDeviceBasicInformationClusterServer for the aggregator endpoints.
846
+ *
847
+ * @param {string} deviceName - The name of the device.
848
+ * @param {string} serialNumber - The serial number of the device.
849
+ * @param {number} [vendorId] - The vendor ID of the device. Default is 0xfff1 (Matter Test VendorId).
850
+ * @param {string} [vendorName] - The name of the vendor. Default is 'Matterbridge'.
851
+ * @param {string} [productName] - The name of the product. Default is 'Matterbridge device'.
852
+ * @param {number} [softwareVersion] - The software version of the device. Default is 1.
853
+ * @param {string} [softwareVersionString] - The software version string of the device. Default is '1.0.0'.
854
+ * @param {number} [hardwareVersion] - The hardware version of the device. Default is 1.
855
+ * @param {string} [hardwareVersionString] - The hardware version string of the device. Default is '1.0.0'.
856
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
857
+ *
858
+ * @remarks The bridgedNode device type must be added to the deviceTypeList of the Descriptor cluster.
859
+ */
476
860
  createDefaultBridgedDeviceBasicInformationClusterServer(deviceName, serialNumber, vendorId = 0xfff1, vendorName = 'Matterbridge', productName = 'Matterbridge device', softwareVersion = 1, softwareVersionString = '1.0.0', hardwareVersion = 1, hardwareVersionString = '1.0.0') {
477
861
  this.log.logName = deviceName;
478
862
  this.deviceName = deviceName;
@@ -505,6 +889,13 @@ export class MatterbridgeEndpoint extends Endpoint {
505
889
  });
506
890
  return this;
507
891
  }
892
+ /**
893
+ * Creates a default identify cluster server with the specified identify time and type.
894
+ *
895
+ * @param {number} [identifyTime] - The time to identify the server. Defaults to 0.
896
+ * @param {Identify.IdentifyType} [identifyType] - The type of identification. Defaults to Identify.IdentifyType.None.
897
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
898
+ */
508
899
  createDefaultIdentifyClusterServer(identifyTime = 0, identifyType = Identify.IdentifyType.None) {
509
900
  this.behaviors.require(MatterbridgeIdentifyServer, {
510
901
  identifyTime,
@@ -512,14 +903,36 @@ export class MatterbridgeEndpoint extends Endpoint {
512
903
  });
513
904
  return this;
514
905
  }
906
+ /**
907
+ * Creates a default groups cluster server.
908
+ *
909
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
910
+ */
515
911
  createDefaultGroupsClusterServer() {
516
912
  this.behaviors.require(GroupsServer);
517
913
  return this;
518
914
  }
915
+ /**
916
+ * Creates a default scenes management cluster server.
917
+ *
918
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
919
+ *
920
+ * @remarks The scenes management cluster server is still provisional and so not yet implemented.
921
+ */
519
922
  createDefaultScenesClusterServer() {
520
923
  this.behaviors.require(ScenesManagementServer);
521
924
  return this;
522
925
  }
926
+ /**
927
+ * Creates a default OnOff cluster server for light devices with feature Lighting.
928
+ *
929
+ * @param {boolean} [onOff] - The initial state of the OnOff cluster.
930
+ * @param {boolean} [globalSceneControl] - The global scene control state.
931
+ * @param {number} [onTime] - The on time value.
932
+ * @param {number} [offWaitTime] - The off wait time value.
933
+ * @param {OnOff.StartUpOnOff | null} [startUpOnOff] - The start-up OnOff state. Null means previous state.
934
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
935
+ */
523
936
  createDefaultOnOffClusterServer(onOff = false, globalSceneControl = false, onTime = 0, offWaitTime = 0, startUpOnOff = null) {
524
937
  this.behaviors.require(MatterbridgeOnOffServer.with(OnOff.Feature.Lighting), {
525
938
  onOff,
@@ -530,24 +943,52 @@ export class MatterbridgeEndpoint extends Endpoint {
530
943
  });
531
944
  return this;
532
945
  }
946
+ /**
947
+ * Creates an OnOff cluster server without features.
948
+ *
949
+ * @param {boolean} [onOff] - The initial state of the OnOff cluster.
950
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
951
+ */
533
952
  createOnOffClusterServer(onOff = false) {
534
953
  this.behaviors.require(MatterbridgeOnOffServer, {
535
954
  onOff,
536
955
  });
537
956
  return this;
538
957
  }
958
+ /**
959
+ * Creates a DeadFront OnOff cluster server with feature DeadFrontBehavior.
960
+ *
961
+ * @param {boolean} [onOff] - The initial state of the OnOff cluster.
962
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
963
+ */
539
964
  createDeadFrontOnOffClusterServer(onOff = false) {
540
965
  this.behaviors.require(MatterbridgeOnOffServer.with(OnOff.Feature.DeadFrontBehavior), {
541
966
  onOff,
542
967
  });
543
968
  return this;
544
969
  }
970
+ /**
971
+ * Creates an OffOnly OnOff cluster server with feature OffOnly.
972
+ *
973
+ * @param {boolean} [onOff] - The initial state of the OnOff cluster.
974
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
975
+ */
545
976
  createOffOnlyOnOffClusterServer(onOff = false) {
546
977
  this.behaviors.require(MatterbridgeOnOffServer.with(OnOff.Feature.OffOnly), {
547
978
  onOff,
548
979
  });
549
980
  return this;
550
981
  }
982
+ /**
983
+ * Creates a default level control cluster server for light devices with feature OnOff and Lighting.
984
+ *
985
+ * @param {number} [currentLevel] - The current level (default: 254).
986
+ * @param {number} [minLevel] - The minimum level (default: 1).
987
+ * @param {number} [maxLevel] - The maximum level (default: 254).
988
+ * @param {number | null} [onLevel] - The on level (default: null).
989
+ * @param {number | null} [startUpCurrentLevel] - The startUp on level (default: null).
990
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
991
+ */
551
992
  createDefaultLevelControlClusterServer(currentLevel = 254, minLevel = 1, maxLevel = 254, onLevel = null, startUpCurrentLevel = null) {
552
993
  this.behaviors.require(MatterbridgeLevelControlServer.with(LevelControl.Feature.OnOff, LevelControl.Feature.Lighting), {
553
994
  currentLevel,
@@ -563,6 +1004,13 @@ export class MatterbridgeEndpoint extends Endpoint {
563
1004
  });
564
1005
  return this;
565
1006
  }
1007
+ /**
1008
+ * Creates a level control cluster server without features.
1009
+ *
1010
+ * @param {number} [currentLevel] - The current level (default: 254).
1011
+ * @param {number | null} [onLevel] - The on level (default: null).
1012
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1013
+ */
566
1014
  createLevelControlClusterServer(currentLevel = 254, onLevel = null) {
567
1015
  this.behaviors.require(MatterbridgeLevelControlServer, {
568
1016
  currentLevel,
@@ -574,6 +1022,25 @@ export class MatterbridgeEndpoint extends Endpoint {
574
1022
  });
575
1023
  return this;
576
1024
  }
1025
+ /**
1026
+ * Creates a default color control cluster server with features Xy, HueSaturation and ColorTemperature.
1027
+ *
1028
+ * @param {number} currentX - The current X value (range 0-65279).
1029
+ * @param {number} currentY - The current Y value (range 0-65279).
1030
+ * @param {number} currentHue - The current hue value (range: 0-254).
1031
+ * @param {number} currentSaturation - The current saturation value (range: 0-254).
1032
+ * @param {number} colorTemperatureMireds - The color temperature in mireds (default range 147-500).
1033
+ * @param {number} colorTempPhysicalMinMireds - The physical minimum color temperature in mireds (default range 147).
1034
+ * @param {number} colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds (default range 500).
1035
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1036
+ *
1037
+ * @remarks colorMode and enhancedColorMode persist across restarts.
1038
+ * @remarks currentHue and currentSaturation persist across restarts.
1039
+ * @remarks currentX and currentY persist across restarts.
1040
+ * @remarks colorTemperatureMireds persists across restarts.
1041
+ * @remarks startUpColorTemperatureMireds persists across restarts.
1042
+ * @remarks coupleColorTempToLevelMinMireds persists across restarts.
1043
+ */
577
1044
  createDefaultColorControlClusterServer(currentX = 0, currentY = 0, currentHue = 0, currentSaturation = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
578
1045
  this.behaviors.require(MatterbridgeColorControlServer.with(ColorControl.Feature.Xy, ColorControl.Feature.HueSaturation, ColorControl.Feature.ColorTemperature), {
579
1046
  colorMode: ColorControl.ColorMode.CurrentHueAndCurrentSaturation,
@@ -596,6 +1063,25 @@ export class MatterbridgeEndpoint extends Endpoint {
596
1063
  });
597
1064
  return this;
598
1065
  }
1066
+ /**
1067
+ * Creates a Xy color control cluster server with feature Xy and ColorTemperature.
1068
+ *
1069
+ * @param {number} currentX - The current X value (range 0-65279).
1070
+ * @param {number} currentY - The current Y value (range 0-65279).
1071
+ * @param {number} colorTemperatureMireds - The color temperature in mireds (default range 147-500).
1072
+ * @param {number} colorTempPhysicalMinMireds - The physical minimum color temperature in mireds (default range 147).
1073
+ * @param {number} colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds (default range 500).
1074
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1075
+ *
1076
+ * @remarks
1077
+ * From zigbee to matter = Math.max(Math.min(Math.round(x * 65536), 65279), 0)
1078
+ *
1079
+ * @remarks colorMode and enhancedColorMode persist across restarts.
1080
+ * @remarks currentX and currentY persist across restarts.
1081
+ * @remarks colorTemperatureMireds persists across restarts.
1082
+ * @remarks startUpColorTemperatureMireds persists across restarts.
1083
+ * @remarks coupleColorTempToLevelMinMireds persists across restarts.
1084
+ */
599
1085
  createXyColorControlClusterServer(currentX = 0, currentY = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
600
1086
  this.behaviors.require(MatterbridgeColorControlServer.with(ColorControl.Feature.Xy, ColorControl.Feature.ColorTemperature), {
601
1087
  colorMode: ColorControl.ColorMode.CurrentXAndCurrentY,
@@ -616,6 +1102,22 @@ export class MatterbridgeEndpoint extends Endpoint {
616
1102
  });
617
1103
  return this;
618
1104
  }
1105
+ /**
1106
+ * Creates a default hue and saturation control cluster server with feature HueSaturation and ColorTemperature.
1107
+ *
1108
+ * @param {number} currentHue - The current hue value (range: 0-254).
1109
+ * @param {number} currentSaturation - The current saturation value (range: 0-254).
1110
+ * @param {number} colorTemperatureMireds - The color temperature in mireds (default range 147-500).
1111
+ * @param {number} colorTempPhysicalMinMireds - The physical minimum color temperature in mireds (default range 147).
1112
+ * @param {number} colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds (default range 500).
1113
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1114
+ *
1115
+ * @remarks colorMode and enhancedColorMode persist across restarts.
1116
+ * @remarks currentHue and currentSaturation persist across restarts.
1117
+ * @remarks colorTemperatureMireds persists across restarts.
1118
+ * @remarks startUpColorTemperatureMireds persists across restarts.
1119
+ * @remarks coupleColorTempToLevelMinMireds persists across restarts.
1120
+ */
619
1121
  createHsColorControlClusterServer(currentHue = 0, currentSaturation = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
620
1122
  this.behaviors.require(MatterbridgeColorControlServer.with(ColorControl.Feature.HueSaturation, ColorControl.Feature.ColorTemperature), {
621
1123
  colorMode: ColorControl.ColorMode.CurrentHueAndCurrentSaturation,
@@ -636,6 +1138,20 @@ export class MatterbridgeEndpoint extends Endpoint {
636
1138
  });
637
1139
  return this;
638
1140
  }
1141
+ /**
1142
+ * Creates a color temperature color control cluster server with feature ColorTemperature.
1143
+ * This cluster server is used for devices that only support color temperature control.
1144
+ *
1145
+ * @param {number} colorTemperatureMireds - The color temperature in mireds (default range 147-500).
1146
+ * @param {number} colorTempPhysicalMinMireds - The physical minimum color temperature in mireds (default range 147).
1147
+ * @param {number} colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds (default range 500).
1148
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1149
+ *
1150
+ * @remarks colorMode and enhancedColorMode persist across restarts.
1151
+ * @remarks colorTemperatureMireds persists across restarts.
1152
+ * @remarks startUpColorTemperatureMireds persists across restarts.
1153
+ * @remarks coupleColorTempToLevelMinMireds persists across restarts.
1154
+ */
639
1155
  createCtColorControlClusterServer(colorTemperatureMireds = 250, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
640
1156
  this.behaviors.require(MatterbridgeColorControlServer.with(ColorControl.Feature.ColorTemperature), {
641
1157
  colorMode: ColorControl.ColorMode.ColorTemperatureMireds,
@@ -654,15 +1170,34 @@ export class MatterbridgeEndpoint extends Endpoint {
654
1170
  });
655
1171
  return this;
656
1172
  }
1173
+ /**
1174
+ * Configures the color control mode for the device.
1175
+ *
1176
+ * @param {ColorControl.ColorMode} colorMode - The color mode to set.
1177
+ *
1178
+ * @remarks colorMode and enhancedColorMode persist across restarts.
1179
+ */
657
1180
  async configureColorControlMode(colorMode) {
658
1181
  if (isValidNumber(colorMode, ColorControl.ColorMode.CurrentHueAndCurrentSaturation, ColorControl.ColorMode.ColorTemperatureMireds)) {
659
1182
  await this.setAttribute(ColorControl.Cluster.id, 'colorMode', colorMode, this.log);
660
1183
  await this.setAttribute(ColorControl.Cluster.id, 'enhancedColorMode', colorMode, this.log);
661
1184
  }
662
1185
  }
1186
+ /**
1187
+ * Creates a default window covering cluster server with feature Lift and PositionAwareLift.
1188
+ *
1189
+ * @param {number} positionPercent100ths - The position percentage in 100ths (0-10000). Defaults to 0. Matter uses 10000 = fully closed 0 = fully opened.
1190
+ * @param {WindowCovering.WindowCoveringType} type - The type of window covering (default: WindowCovering.WindowCoveringType.Rollershade). Must support feature Lift.
1191
+ * @param {WindowCovering.EndProductType} endProductType - The end product type (default: WindowCovering.EndProductType.RollerShade). Must support feature Lift.
1192
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1193
+ *
1194
+ * @remarks mode attributes is writable and persists across restarts.
1195
+ * currentPositionLiftPercent100ths persists across restarts.
1196
+ * configStatus attributes persists across restarts.
1197
+ */
663
1198
  createDefaultWindowCoveringClusterServer(positionPercent100ths, type = WindowCovering.WindowCoveringType.Rollershade, endProductType = WindowCovering.EndProductType.RollerShade) {
664
1199
  this.behaviors.require(MatterbridgeLiftWindowCoveringServer.with(WindowCovering.Feature.Lift, WindowCovering.Feature.PositionAwareLift), {
665
- type,
1200
+ type, // Must support feature Lift
666
1201
  numberOfActuationsLift: 0,
667
1202
  configStatus: {
668
1203
  operational: true,
@@ -670,20 +1205,33 @@ export class MatterbridgeEndpoint extends Endpoint {
670
1205
  liftMovementReversed: false,
671
1206
  liftPositionAware: true,
672
1207
  tiltPositionAware: false,
673
- liftEncoderControlled: false,
674
- tiltEncoderControlled: false,
1208
+ liftEncoderControlled: false, // 0 = Timer Controlled 1 = Encoder Controlled
1209
+ tiltEncoderControlled: false, // 0 = Timer Controlled 1 = Encoder Controlled
675
1210
  },
676
1211
  operationalStatus: { global: WindowCovering.MovementStatus.Stopped, lift: WindowCovering.MovementStatus.Stopped, tilt: WindowCovering.MovementStatus.Stopped },
677
- endProductType,
1212
+ endProductType, // Must support feature Lift
678
1213
  mode: { motorDirectionReversed: false, calibrationMode: false, maintenanceMode: false, ledFeedback: false },
679
- targetPositionLiftPercent100ths: positionPercent100ths ?? 0,
680
- currentPositionLiftPercent100ths: positionPercent100ths ?? 0,
1214
+ targetPositionLiftPercent100ths: positionPercent100ths ?? 0, // 0 Fully open 10000 fully closed
1215
+ currentPositionLiftPercent100ths: positionPercent100ths ?? 0, // 0 Fully open 10000 fully closed
681
1216
  });
682
1217
  return this;
683
1218
  }
1219
+ /**
1220
+ * Creates a default window covering cluster server with features Lift, PositionAwareLift, Tilt, PositionAwareTilt.
1221
+ *
1222
+ * @param {number} positionLiftPercent100ths - The lift position percentage in 100ths (0-10000). Defaults to 0. Matter uses 10000 = fully closed 0 = fully opened.
1223
+ * @param {number} positionTiltPercent100ths - The tilt position percentage in 100ths (0-10000). Defaults to 0. Matter uses 10000 = fully closed 0 = fully opened.
1224
+ * @param {WindowCovering.WindowCoveringType} type - The type of window covering (default: WindowCovering.WindowCoveringType.TiltBlindLift). Must support features Lift and Tilt.
1225
+ * @param {WindowCovering.EndProductType} endProductType - The end product type (default: WindowCovering.EndProductType.InteriorBlind). Must support features Lift and Tilt.
1226
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1227
+ *
1228
+ * @remarks mode attributes is writable and persists across restarts.
1229
+ * currentPositionTiltPercent100ths persists across restarts.
1230
+ * configStatus attributes persists across restarts.
1231
+ */
684
1232
  createDefaultLiftTiltWindowCoveringClusterServer(positionLiftPercent100ths, positionTiltPercent100ths, type = WindowCovering.WindowCoveringType.TiltBlindLift, endProductType = WindowCovering.EndProductType.InteriorBlind) {
685
1233
  this.behaviors.require(MatterbridgeLiftTiltWindowCoveringServer.with(WindowCovering.Feature.Lift, WindowCovering.Feature.PositionAwareLift, WindowCovering.Feature.Tilt, WindowCovering.Feature.PositionAwareTilt), {
686
- type,
1234
+ type, // Must support features Lift and Tilt
687
1235
  numberOfActuationsLift: 0,
688
1236
  numberOfActuationsTilt: 0,
689
1237
  configStatus: {
@@ -692,19 +1240,23 @@ export class MatterbridgeEndpoint extends Endpoint {
692
1240
  liftMovementReversed: false,
693
1241
  liftPositionAware: true,
694
1242
  tiltPositionAware: true,
695
- liftEncoderControlled: false,
696
- tiltEncoderControlled: false,
1243
+ liftEncoderControlled: false, // 0 = Timer Controlled 1 = Encoder Controlled
1244
+ tiltEncoderControlled: false, // 0 = Timer Controlled 1 = Encoder Controlled
697
1245
  },
698
1246
  operationalStatus: { global: WindowCovering.MovementStatus.Stopped, lift: WindowCovering.MovementStatus.Stopped, tilt: WindowCovering.MovementStatus.Stopped },
699
- endProductType,
1247
+ endProductType, // Must support features Lift and Tilt
700
1248
  mode: { motorDirectionReversed: false, calibrationMode: false, maintenanceMode: false, ledFeedback: false },
701
- targetPositionLiftPercent100ths: positionLiftPercent100ths ?? 0,
702
- currentPositionLiftPercent100ths: positionLiftPercent100ths ?? 0,
703
- targetPositionTiltPercent100ths: positionTiltPercent100ths ?? 0,
704
- currentPositionTiltPercent100ths: positionTiltPercent100ths ?? 0,
1249
+ targetPositionLiftPercent100ths: positionLiftPercent100ths ?? 0, // 0 Fully open 10000 fully closed
1250
+ currentPositionLiftPercent100ths: positionLiftPercent100ths ?? 0, // 0 Fully open 10000 fully closed
1251
+ targetPositionTiltPercent100ths: positionTiltPercent100ths ?? 0, // 0 Fully open 10000 fully closed
1252
+ currentPositionTiltPercent100ths: positionTiltPercent100ths ?? 0, // 0 Fully open 10000 fully closed
705
1253
  });
706
1254
  return this;
707
1255
  }
1256
+ /**
1257
+ * Sets the window covering lift target position as the current position and stops the movement.
1258
+ *
1259
+ */
708
1260
  async setWindowCoveringTargetAsCurrentAndStopped() {
709
1261
  const position = this.getAttribute(WindowCovering.Cluster.id, 'currentPositionLiftPercent100ths', this.log);
710
1262
  if (isValidNumber(position, 0, 10000)) {
@@ -724,6 +1276,13 @@ export class MatterbridgeEndpoint extends Endpoint {
724
1276
  this.log.debug(`Set WindowCovering currentPositionTiltPercent100ths and targetPositionTiltPercent100ths to ${position} and operationalStatus to Stopped.`);
725
1277
  }
726
1278
  }
1279
+ /**
1280
+ * Sets the lift current and target position and the status of a window covering.
1281
+ *
1282
+ * @param {number} current - The current position of the window covering.
1283
+ * @param {number} target - The target position of the window covering.
1284
+ * @param {WindowCovering.MovementStatus} status - The movement status of the window covering.
1285
+ */
727
1286
  async setWindowCoveringCurrentTargetStatus(current, target, status) {
728
1287
  await this.setAttribute(WindowCovering.Cluster.id, 'currentPositionLiftPercent100ths', current, this.log);
729
1288
  await this.setAttribute(WindowCovering.Cluster.id, 'targetPositionLiftPercent100ths', target, this.log);
@@ -734,6 +1293,11 @@ export class MatterbridgeEndpoint extends Endpoint {
734
1293
  }, this.log);
735
1294
  this.log.debug(`Set WindowCovering currentPositionLiftPercent100ths: ${current}, targetPositionLiftPercent100ths: ${target} and operationalStatus: ${status}.`);
736
1295
  }
1296
+ /**
1297
+ * Sets the status of the window covering.
1298
+ *
1299
+ * @param {WindowCovering.MovementStatus} status - The movement status to set.
1300
+ */
737
1301
  async setWindowCoveringStatus(status) {
738
1302
  await this.setAttribute(WindowCovering.Cluster.id, 'operationalStatus', {
739
1303
  global: status,
@@ -742,6 +1306,11 @@ export class MatterbridgeEndpoint extends Endpoint {
742
1306
  }, this.log);
743
1307
  this.log.debug(`Set WindowCovering operationalStatus: ${status}`);
744
1308
  }
1309
+ /**
1310
+ * Retrieves the status of the window covering.
1311
+ *
1312
+ * @returns {WindowCovering.MovementStatus | undefined} The movement status of the window covering, or undefined if not available.
1313
+ */
745
1314
  getWindowCoveringStatus() {
746
1315
  const status = this.getAttribute(WindowCovering.Cluster.id, 'operationalStatus', this.log);
747
1316
  if (isValidObject(status, 3) && 'global' in status && typeof status.global === 'number') {
@@ -749,6 +1318,12 @@ export class MatterbridgeEndpoint extends Endpoint {
749
1318
  return status.global;
750
1319
  }
751
1320
  }
1321
+ /**
1322
+ * Sets the lift target and current position of the window covering.
1323
+ *
1324
+ * @param {number} liftPosition - The position to set, specified as a number.
1325
+ * @param {number} [tiltPosition] - The tilt position to set, specified as a number.
1326
+ */
752
1327
  async setWindowCoveringTargetAndCurrentPosition(liftPosition, tiltPosition) {
753
1328
  await this.setAttribute(WindowCovering.Cluster.id, 'currentPositionLiftPercent100ths', liftPosition, this.log);
754
1329
  await this.setAttribute(WindowCovering.Cluster.id, 'targetPositionLiftPercent100ths', liftPosition, this.log);
@@ -759,31 +1334,57 @@ export class MatterbridgeEndpoint extends Endpoint {
759
1334
  this.log.debug(`Set WindowCovering currentPositionTiltPercent100ths: ${tiltPosition} and targetPositionTiltPercent100ths: ${tiltPosition}.`);
760
1335
  }
761
1336
  }
1337
+ /**
1338
+ * Creates a default thermostat cluster server with features Heating, Cooling and AutoMode.
1339
+ *
1340
+ * @param {number} [localTemperature] - The local temperature value in degrees Celsius. Defaults to 23°.
1341
+ * @param {number} [occupiedHeatingSetpoint] - The occupied heating setpoint value in degrees Celsius. Defaults to 21°.
1342
+ * @param {number} [occupiedCoolingSetpoint] - The occupied cooling setpoint value in degrees Celsius. Defaults to 25°.
1343
+ * @param {number} [minSetpointDeadBand] - The minimum setpoint dead band value. Defaults to 1°.
1344
+ * @param {number} [minHeatSetpointLimit] - The minimum heat setpoint limit value. Defaults to 0°.
1345
+ * @param {number} [maxHeatSetpointLimit] - The maximum heat setpoint limit value. Defaults to 50°.
1346
+ * @param {number} [minCoolSetpointLimit] - The minimum cool setpoint limit value. Defaults to 0°.
1347
+ * @param {number} [maxCoolSetpointLimit] - The maximum cool setpoint limit value. Defaults to 50°.
1348
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1349
+ */
762
1350
  createDefaultThermostatClusterServer(localTemperature = 23, occupiedHeatingSetpoint = 21, occupiedCoolingSetpoint = 25, minSetpointDeadBand = 1, minHeatSetpointLimit = 0, maxHeatSetpointLimit = 50, minCoolSetpointLimit = 0, maxCoolSetpointLimit = 50) {
763
1351
  this.behaviors.require(MatterbridgeThermostatServer.with(Thermostat.Feature.Heating, Thermostat.Feature.Cooling, Thermostat.Feature.AutoMode), {
764
1352
  localTemperature: localTemperature * 100,
765
1353
  systemMode: Thermostat.SystemMode.Auto,
766
1354
  controlSequenceOfOperation: Thermostat.ControlSequenceOfOperation.CoolingAndHeating,
1355
+ // Thermostat.Feature.Heating
767
1356
  occupiedHeatingSetpoint: occupiedHeatingSetpoint * 100,
768
1357
  minHeatSetpointLimit: minHeatSetpointLimit * 100,
769
1358
  maxHeatSetpointLimit: maxHeatSetpointLimit * 100,
770
1359
  absMinHeatSetpointLimit: minHeatSetpointLimit * 100,
771
1360
  absMaxHeatSetpointLimit: maxHeatSetpointLimit * 100,
1361
+ // Thermostat.Feature.Cooling
772
1362
  occupiedCoolingSetpoint: occupiedCoolingSetpoint * 100,
773
1363
  minCoolSetpointLimit: minCoolSetpointLimit * 100,
774
1364
  maxCoolSetpointLimit: maxCoolSetpointLimit * 100,
775
1365
  absMinCoolSetpointLimit: minCoolSetpointLimit * 100,
776
1366
  absMaxCoolSetpointLimit: maxCoolSetpointLimit * 100,
1367
+ // Thermostat.Feature.AutoMode
777
1368
  minSetpointDeadBand: minSetpointDeadBand * 100,
778
1369
  thermostatRunningMode: Thermostat.ThermostatRunningMode.Off,
779
1370
  });
780
1371
  return this;
781
1372
  }
1373
+ /**
1374
+ * Creates a default heating thermostat cluster server with feature Heating.
1375
+ *
1376
+ * @param {number} [localTemperature] - The local temperature value in degrees Celsius. Defaults to 23°.
1377
+ * @param {number} [occupiedHeatingSetpoint] - The occupied heating setpoint value in degrees Celsius. Defaults to 21°.
1378
+ * @param {number} [minHeatSetpointLimit] - The minimum heat setpoint limit value. Defaults to 0°.
1379
+ * @param {number} [maxHeatSetpointLimit] - The maximum heat setpoint limit value. Defaults to 50°.
1380
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1381
+ */
782
1382
  createDefaultHeatingThermostatClusterServer(localTemperature = 23, occupiedHeatingSetpoint = 21, minHeatSetpointLimit = 0, maxHeatSetpointLimit = 50) {
783
1383
  this.behaviors.require(MatterbridgeThermostatServer.with(Thermostat.Feature.Heating), {
784
1384
  localTemperature: localTemperature * 100,
785
1385
  systemMode: Thermostat.SystemMode.Heat,
786
1386
  controlSequenceOfOperation: Thermostat.ControlSequenceOfOperation.HeatingOnly,
1387
+ // Thermostat.Feature.Heating
787
1388
  occupiedHeatingSetpoint: occupiedHeatingSetpoint * 100,
788
1389
  minHeatSetpointLimit: minHeatSetpointLimit * 100,
789
1390
  maxHeatSetpointLimit: maxHeatSetpointLimit * 100,
@@ -792,11 +1393,21 @@ export class MatterbridgeEndpoint extends Endpoint {
792
1393
  });
793
1394
  return this;
794
1395
  }
1396
+ /**
1397
+ * Creates a default cooling thermostat cluster server with feature Cooling.
1398
+ *
1399
+ * @param {number} [localTemperature] - The local temperature value in degrees Celsius. Defaults to 23°.
1400
+ * @param {number} [occupiedCoolingSetpoint] - The occupied cooling setpoint value in degrees Celsius. Defaults to 25°.
1401
+ * @param {number} [minCoolSetpointLimit] - The minimum cool setpoint limit value. Defaults to 0°.
1402
+ * @param {number} [maxCoolSetpointLimit] - The maximum cool setpoint limit value. Defaults to 50°.
1403
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1404
+ */
795
1405
  createDefaultCoolingThermostatClusterServer(localTemperature = 23, occupiedCoolingSetpoint = 25, minCoolSetpointLimit = 0, maxCoolSetpointLimit = 50) {
796
1406
  this.behaviors.require(MatterbridgeThermostatServer.with(Thermostat.Feature.Cooling), {
797
1407
  localTemperature: localTemperature * 100,
798
1408
  systemMode: Thermostat.SystemMode.Cool,
799
1409
  controlSequenceOfOperation: Thermostat.ControlSequenceOfOperation.CoolingOnly,
1410
+ // Thermostat.Feature.Cooling
800
1411
  occupiedCoolingSetpoint: occupiedCoolingSetpoint * 100,
801
1412
  minCoolSetpointLimit: minCoolSetpointLimit * 100,
802
1413
  maxCoolSetpointLimit: maxCoolSetpointLimit * 100,
@@ -805,6 +1416,16 @@ export class MatterbridgeEndpoint extends Endpoint {
805
1416
  });
806
1417
  return this;
807
1418
  }
1419
+ /**
1420
+ * Creates a default thermostat user interface configuration cluster server.
1421
+ *
1422
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1423
+ * @remarks
1424
+ * The default values are:
1425
+ * - temperatureDisplayMode: ThermostatUserInterfaceConfiguration.TemperatureDisplayMode.Celsius (writeble).
1426
+ * - keypadLockout: ThermostatUserInterfaceConfiguration.KeypadLockout.NoLockout (writeble).
1427
+ * - scheduleProgrammingVisibility: ThermostatUserInterfaceConfiguration.ScheduleProgrammingVisibility.ScheduleProgrammingPermitted (writeble).
1428
+ */
808
1429
  createDefaultThermostatUserInterfaceConfigurationClusterServer() {
809
1430
  this.behaviors.require(ThermostatUserInterfaceConfigurationServer, {
810
1431
  temperatureDisplayMode: ThermostatUserInterfaceConfiguration.TemperatureDisplayMode.Celsius,
@@ -813,95 +1434,273 @@ export class MatterbridgeEndpoint extends Endpoint {
813
1434
  });
814
1435
  return this;
815
1436
  }
1437
+ /**
1438
+ * Creates a default fan control cluster server with features Auto, and Step and mode Off Low Med High Auto.
1439
+ *
1440
+ * @param {FanControl.FanMode} [fanMode] - The fan mode to set. Defaults to `FanControl.FanMode.Off`.
1441
+ * @param {FanControl.FanModeSequence} [fanModeSequence] - The fan mode sequence to set. Defaults to `FanControl.FanModeSequence.OffLowMedHighAuto`.
1442
+ * @param {number} [percentSetting] - The initial percent setting. Defaults to 0.
1443
+ * @param {number} [percentCurrent] - The initial percent current. Defaults to 0.
1444
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1445
+ *
1446
+ * @remarks
1447
+ * - fanmode is writable and persists across reboots.
1448
+ * - fanModeSequence is fixed.
1449
+ * - percentSetting is writable.
1450
+ */
816
1451
  createDefaultFanControlClusterServer(fanMode = FanControl.FanMode.Off, fanModeSequence = FanControl.FanModeSequence.OffLowMedHighAuto, percentSetting = 0, percentCurrent = 0) {
817
1452
  this.behaviors.require(MatterbridgeFanControlServer.with(FanControl.Feature.Auto, FanControl.Feature.Step), {
818
- fanMode,
819
- fanModeSequence,
820
- percentSetting,
1453
+ // Base fan control attributes
1454
+ fanMode, // Writable and persistent attribute
1455
+ fanModeSequence, // Fixed attribute
1456
+ percentSetting, // Writable attribute
821
1457
  percentCurrent,
822
1458
  });
823
1459
  return this;
824
1460
  }
1461
+ /**
1462
+ * Creates an On Off fan control cluster server without features and mode Off High.
1463
+ *
1464
+ * @param {FanControl.FanMode} [fanMode] - The fan mode to set. Defaults to `FanControl.FanMode.Off`.
1465
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1466
+ *
1467
+ * @remarks
1468
+ * fanmode is writable and persists across reboots.
1469
+ * fanModeSequence is fixed.
1470
+ * percentSetting is writable.
1471
+ */
825
1472
  createOnOffFanControlClusterServer(fanMode = FanControl.FanMode.Off) {
826
1473
  this.behaviors.require(FanControlServer, {
827
- fanMode,
828
- fanModeSequence: FanControl.FanModeSequence.OffHigh,
829
- percentSetting: 0,
1474
+ // Base fan control attributes
1475
+ fanMode, // Writable and persistent attribute
1476
+ fanModeSequence: FanControl.FanModeSequence.OffHigh, // Fixed attribute
1477
+ percentSetting: 0, // Writable attribute
830
1478
  percentCurrent: 0,
831
1479
  });
832
1480
  return this;
833
1481
  }
1482
+ /**
1483
+ * Creates a base fan control cluster server without features and mode Off Low Med High.
1484
+ *
1485
+ * @param {FanControl.FanMode} [fanMode] - The fan mode to set. Defaults to `FanControl.FanMode.Off`.
1486
+ * @param {FanControl.FanModeSequence} [fanModeSequence] - The fan mode sequence to set. Defaults to `FanControl.FanModeSequence.OffLowMedHigh`.
1487
+ * @param {number} [percentSetting] - The initial percent setting. Defaults to 0.
1488
+ * @param {number} [percentCurrent] - The initial percent current. Defaults to 0.
1489
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1490
+ *
1491
+ * @remarks
1492
+ * fanmode is writable and persists across reboots.
1493
+ * fanModeSequence is fixed.
1494
+ * percentSetting is writable.
1495
+ */
834
1496
  createBaseFanControlClusterServer(fanMode = FanControl.FanMode.Off, fanModeSequence = FanControl.FanModeSequence.OffLowMedHigh, percentSetting = 0, percentCurrent = 0) {
835
1497
  this.behaviors.require(FanControlServer, {
836
- fanMode,
837
- fanModeSequence,
838
- percentSetting,
1498
+ // Base fan control attributes
1499
+ fanMode, // Writable and persistent attribute
1500
+ fanModeSequence, // Fixed attribute
1501
+ percentSetting, // Writable attribute
839
1502
  percentCurrent,
840
1503
  });
841
1504
  return this;
842
1505
  }
1506
+ /**
1507
+ * Creates a fan control cluster server with features MultiSpeed, Auto, and Step and mode Off Low Med High Auto.
1508
+ *
1509
+ * @param {FanControl.FanMode} [fanMode] - The fan mode to set. Defaults to `FanControl.FanMode.Off`.
1510
+ * @param {FanControl.FanModeSequence} [fanModeSequence] - The fan mode sequence to set. Defaults to `FanControl.FanModeSequence.OffLowMedHighAuto`.
1511
+ * @param {number} [percentSetting] - The initial percent setting. Defaults to 0.
1512
+ * @param {number} [percentCurrent] - The initial percent current. Defaults to 0.
1513
+ * @param {number} [speedMax] - The maximum speed setting. Defaults to 10.
1514
+ * @param {number} [speedSetting] - The initial speed setting. Defaults to 0.
1515
+ * @param {number} [speedCurrent] - The initial speed current. Defaults to 0.
1516
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1517
+ *
1518
+ * @remarks
1519
+ * - fanmode is writable and persists across reboots.
1520
+ * - fanModeSequence is fixed.
1521
+ * - percentSetting is writable.
1522
+ * - speedMax is fixed.
1523
+ * - speedSetting is writable.
1524
+ */
843
1525
  createMultiSpeedFanControlClusterServer(fanMode = FanControl.FanMode.Off, fanModeSequence = FanControl.FanModeSequence.OffLowMedHighAuto, percentSetting = 0, percentCurrent = 0, speedMax = 10, speedSetting = 0, speedCurrent = 0) {
844
1526
  this.behaviors.require(MatterbridgeFanControlServer.with(FanControl.Feature.MultiSpeed, FanControl.Feature.Auto, FanControl.Feature.Step), {
845
- fanMode,
846
- fanModeSequence,
847
- percentSetting,
1527
+ // Base fan control attributes
1528
+ fanMode, // Writable and persistent attribute
1529
+ fanModeSequence, // Fixed attribute
1530
+ percentSetting, // Writable attribute
848
1531
  percentCurrent,
849
- speedMax,
850
- speedSetting,
1532
+ // MultiSpeed feature
1533
+ speedMax, // Fixed attribute
1534
+ speedSetting, // Writable attribute
851
1535
  speedCurrent,
852
1536
  });
853
1537
  return this;
854
1538
  }
1539
+ /**
1540
+ * Creates a fan control cluster server with features MultiSpeed, Auto, Step, Rock, Wind and AirflowDirection and mode Off Low Med High Auto.
1541
+ *
1542
+ * @param {FanControl.FanMode} [fanMode] - The fan mode to set. Defaults to `FanControl.FanMode.Off`.
1543
+ * @param {FanControl.FanModeSequence} [fanModeSequence] - The fan mode sequence to set. Defaults to `FanControl.FanModeSequence.OffLowMedHighAuto`.
1544
+ * @param {number} [percentSetting] - The initial percent setting. Defaults to 0.
1545
+ * @param {number} [percentCurrent] - The initial percent current. Defaults to 0.
1546
+ * @param {number} [speedMax] - The maximum speed setting. Defaults to 10.
1547
+ * @param {number} [speedSetting] - The initial speed setting. Defaults to 0.
1548
+ * @param {number} [speedCurrent] - The initial speed current. Defaults to 0.
1549
+ * @param {object} [rockSupport] - The rock support configuration.
1550
+ * @param {boolean} rockSupport.rockLeftRight - Indicates support for rocking left to right. Defaults to true.
1551
+ * @param {boolean} rockSupport.rockUpDown - Indicates support for rocking up and down. Defaults to true.
1552
+ * @param {boolean} rockSupport.rockRound - Indicates support for round rocking. Defaults to true.
1553
+ * @param {object} [rockSetting] - The rock setting configuration.
1554
+ * @param {boolean} rockSetting.rockLeftRight - Indicates the current setting for rocking left to right. Defaults to true.
1555
+ * @param {boolean} rockSetting.rockUpDown - Indicates the current setting for rocking up and down. Defaults to true.
1556
+ * @param {boolean} rockSetting.rockRound - Indicates the current setting for round rocking. Defaults to true.
1557
+ * @param {object} [windSupport] - The wind support configuration.
1558
+ * @param {boolean} windSupport.sleepWind - Indicates support for sleep wind. Defaults to true.
1559
+ * @param {boolean} windSupport.naturalWind - Indicates support for natural wind. Defaults to true.
1560
+ * @param {object} [windSetting] - The wind setting configuration.
1561
+ * @param {boolean} windSetting.sleepWind - Indicates the current setting for sleep wind. Defaults to false.
1562
+ * @param {boolean} windSetting.naturalWind - Indicates the current setting for natural wind. Defaults to true.
1563
+ * @param {FanControl.AirflowDirection} [airflowDirection] - The airflow direction. Defaults to `FanControl.AirflowDirection.Forward`.
1564
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1565
+ *
1566
+ * @remarks
1567
+ * - fanmode is writable and persists across reboots.
1568
+ * - fanModeSequence is fixed.
1569
+ * - percentSetting is writable.
1570
+ * - speedMax is fixed.
1571
+ * - speedSetting is writable.
1572
+ * - rockSupport is fixed.
1573
+ * - rockSetting is writable.
1574
+ * - windSupport is fixed.
1575
+ * - windSetting is writable.
1576
+ * - airflowDirection is writable.
1577
+ */
855
1578
  createCompleteFanControlClusterServer(fanMode = FanControl.FanMode.Off, fanModeSequence = FanControl.FanModeSequence.OffLowMedHighAuto, percentSetting = 0, percentCurrent = 0, speedMax = 10, speedSetting = 0, speedCurrent = 0, rockSupport = { rockLeftRight: true, rockUpDown: true, rockRound: true }, rockSetting = { rockLeftRight: true, rockUpDown: false, rockRound: false }, windSupport = { sleepWind: true, naturalWind: true }, windSetting = { sleepWind: false, naturalWind: true }, airflowDirection = FanControl.AirflowDirection.Forward) {
856
1579
  this.behaviors.require(MatterbridgeFanControlServer.with(FanControl.Feature.MultiSpeed, FanControl.Feature.Auto, FanControl.Feature.Step, FanControl.Feature.Rocking, FanControl.Feature.Wind, FanControl.Feature.AirflowDirection), {
857
- fanMode,
858
- fanModeSequence,
859
- percentSetting,
1580
+ // Base fan control attributes
1581
+ fanMode, // Writable and persistent attribute
1582
+ fanModeSequence, // Fixed attribute
1583
+ percentSetting, // Writable attribute
860
1584
  percentCurrent,
861
- speedMax,
862
- speedSetting,
1585
+ // MultiSpeed feature
1586
+ speedMax, // Fixed attribute
1587
+ speedSetting, // Writable attribute
863
1588
  speedCurrent,
864
- rockSupport,
865
- rockSetting,
866
- windSupport,
867
- windSetting,
868
- airflowDirection,
1589
+ // Rocking feature
1590
+ rockSupport, // Fixed attribute
1591
+ rockSetting, // Writable attribute
1592
+ // Wind feature
1593
+ windSupport, // Fixed attribute
1594
+ windSetting, // Writable attribute
1595
+ // AirflowDirection feature
1596
+ airflowDirection, // Writable attribute
869
1597
  });
870
1598
  return this;
871
1599
  }
1600
+ /**
1601
+ * Creates a default HEPA Filter Monitoring Cluster Server with features Condition and ReplacementProductList.
1602
+ * It supports ResourceMonitoring.Feature.Condition, ResourceMonitoring.Feature.Warning, and ResourceMonitoring.Feature.ReplacementProductList.
1603
+ *
1604
+ * @param {number} condition - The initial condition value (range 0-100). Default is 100.
1605
+ * @param {ResourceMonitoring.ChangeIndication} changeIndication - The initial change indication. Default is ResourceMonitoring.ChangeIndication.Ok.
1606
+ * @param {boolean | undefined} inPlaceIndicator - The in-place indicator. Default is true.
1607
+ * @param {number | undefined} lastChangedTime - The last changed time (EpochS). Default is null.
1608
+ * @param {ResourceMonitoring.ReplacementProduct[]} replacementProductList - The list of replacement products. Default is an empty array. It is a fixed attribute.
1609
+ *
1610
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1611
+ *
1612
+ * @remarks
1613
+ * The HEPA Filter Monitoring Cluster Server is used to monitor the status of HEPA filters.
1614
+ * It provides information about the condition of the filter, whether it is in place, and the last time it was changed.
1615
+ * The change indication can be used to indicate if the filter needs to be replaced or serviced.
1616
+ * The replacement product list can be used to provide a list of replacement products for the filter.
1617
+ * The condition attribute is fixed at 100, indicating a healthy filter.
1618
+ * The degradation direction is fixed at ResourceMonitoring.DegradationDirection.Down, indicating that a lower value indicates a worse condition.
1619
+ * The replacement product list is initialized as an empty array.
1620
+ */
872
1621
  createDefaultHepaFilterMonitoringClusterServer(condition = 100, changeIndication = ResourceMonitoring.ChangeIndication.Ok, inPlaceIndicator = true, lastChangedTime = null, replacementProductList = []) {
873
1622
  this.behaviors.require(MatterbridgeHepaFilterMonitoringServer.with(ResourceMonitoring.Feature.Condition, ResourceMonitoring.Feature.Warning, ResourceMonitoring.Feature.ReplacementProductList), {
1623
+ // Feature.Condition
874
1624
  condition,
875
- degradationDirection: ResourceMonitoring.DegradationDirection.Down,
876
- replacementProductList,
1625
+ degradationDirection: ResourceMonitoring.DegradationDirection.Down, // Fixed attribute
1626
+ // Feature.ReplacementProductList
1627
+ replacementProductList, // Fixed attribute
1628
+ // Base attributes
877
1629
  changeIndication,
878
1630
  inPlaceIndicator,
879
- lastChangedTime,
1631
+ lastChangedTime, // Writable and persistent across restarts
880
1632
  });
881
1633
  return this;
882
1634
  }
1635
+ /**
1636
+ * Creates a default Activated Carbon Filter Monitoring Cluster Server with features Condition and ReplacementProductList.
1637
+ * It supports ResourceMonitoring.Feature.Condition, ResourceMonitoring.Feature.Warning, and ResourceMonitoring.Feature.ReplacementProductList.
1638
+ *
1639
+ * @param {number} condition - The initial condition value (range 0-100). Default is 100.
1640
+ * @param {ResourceMonitoring.ChangeIndication} changeIndication - The initial change indication. Default is ResourceMonitoring.ChangeIndication.Ok.
1641
+ * @param {boolean | undefined} inPlaceIndicator - The in-place indicator. Default is undefined.
1642
+ * @param {number | undefined} lastChangedTime - The last changed time (EpochS). Default is undefined.
1643
+ * @param {ResourceMonitoring.ReplacementProduct[]} replacementProductList - The list of replacement products. Default is an empty array. It is a fixed attribute.
1644
+ *
1645
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1646
+ *
1647
+ * @remarks
1648
+ * The Activated Carbon Filter Monitoring Cluster Server is used to monitor the status of activated carbon filters.
1649
+ * It provides information about the condition of the filter, whether it is in place, and the last time it was changed.
1650
+ * The change indication can be used to indicate if the filter needs to be replaced or serviced.
1651
+ * The replacement product list can be used to provide a list of replacement products for the filter.
1652
+ * The condition attribute is fixed at 100, indicating a healthy filter.
1653
+ * The degradation direction is fixed at ResourceMonitoring.DegradationDirection.Down, indicating that a lower value indicates a worse condition.
1654
+ * The replacement product list is initialized as an empty array.
1655
+ */
883
1656
  createDefaultActivatedCarbonFilterMonitoringClusterServer(condition = 100, changeIndication = ResourceMonitoring.ChangeIndication.Ok, inPlaceIndicator = true, lastChangedTime = null, replacementProductList = []) {
884
1657
  this.behaviors.require(MatterbridgeActivatedCarbonFilterMonitoringServer.with(ResourceMonitoring.Feature.Condition, ResourceMonitoring.Feature.Warning, ResourceMonitoring.Feature.ReplacementProductList), {
1658
+ // Feature.Condition
885
1659
  condition,
886
1660
  degradationDirection: ResourceMonitoring.DegradationDirection.Down,
887
- replacementProductList,
1661
+ // Feature.ReplacementProductList
1662
+ replacementProductList, // Fixed attribute
1663
+ // Base attributes
888
1664
  changeIndication,
889
1665
  inPlaceIndicator,
890
- lastChangedTime,
1666
+ lastChangedTime, // Writable and persistent across restarts
891
1667
  });
892
1668
  return this;
893
1669
  }
1670
+ /**
1671
+ * Creates a default door lock cluster server.
1672
+ *
1673
+ * @param {DoorLock.LockState} [lockState] - The initial state of the lock (default: Locked).
1674
+ * @param {DoorLock.LockType} [lockType] - The type of the lock (default: DeadBolt).
1675
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1676
+ *
1677
+ * @remarks
1678
+ * All operating modes NOT supported by a lock SHALL be set to one. The value of the OperatingMode enumeration defines the related bit to be set.
1679
+ */
894
1680
  createDefaultDoorLockClusterServer(lockState = DoorLock.LockState.Locked, lockType = DoorLock.LockType.DeadBolt) {
895
1681
  this.behaviors.require(MatterbridgeDoorLockServer.enable({ events: { doorLockAlarm: true, lockOperation: true, lockOperationError: true } }), {
896
1682
  lockState,
897
1683
  lockType,
898
1684
  actuatorEnabled: false,
899
1685
  operatingMode: DoorLock.OperatingMode.Normal,
1686
+ // Special case of inverted bitmap: add also alwaysSet = 2047
900
1687
  supportedOperatingModes: { normal: false, vacation: true, privacy: true, noRemoteLockUnlock: true, passage: true, alwaysSet: 2047 },
901
1688
  alarmMask: { lockJammed: false, lockFactoryReset: false, lockRadioPowerCycled: false, wrongCodeEntryLimit: false, frontEscutcheonRemoved: false, doorForcedOpen: false },
902
1689
  });
903
1690
  return this;
904
1691
  }
1692
+ /**
1693
+ * Creates a default Mode Select cluster server.
1694
+ *
1695
+ * @param {string} description - The description of the mode select cluster.
1696
+ * @param {ModeSelect.ModeOption[]} supportedModes - The list of supported modes.
1697
+ * @param {number} [currentMode] - The current mode (default: 0).
1698
+ * @param {number} [startUpMode] - The startup mode (default: 0).
1699
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1700
+ *
1701
+ * @remarks
1702
+ * endpoint.createDefaultModeSelectClusterServer('Night mode', [{ label: 'Led ON', mode: 0, semanticTags: [] }, { label: 'Led OFF', mode: 1, semanticTags: [] }], 0, 0);
1703
+ */
905
1704
  createDefaultModeSelectClusterServer(description, supportedModes, currentMode = 0, startUpMode = 0) {
906
1705
  this.behaviors.require(MatterbridgeModeSelectServer, {
907
1706
  description: description,
@@ -912,21 +1711,35 @@ export class MatterbridgeEndpoint extends Endpoint {
912
1711
  });
913
1712
  return this;
914
1713
  }
1714
+ /**
1715
+ * Creates the default Valve Configuration And Control cluster server with features Level.
1716
+ *
1717
+ * @param {ValveConfigurationAndControl.ValveState} [valveState] - The valve state to set. Defaults to `ValveConfigurationAndControl.ValveState.Closed`.
1718
+ * @param {number} [valveLevel] - The valve level to set. Defaults to 0.
1719
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1720
+ */
915
1721
  createDefaultValveConfigurationAndControlClusterServer(valveState = ValveConfigurationAndControl.ValveState.Closed, valveLevel = 0) {
916
1722
  this.behaviors.require(MatterbridgeValveConfigurationAndControlServer.with(ValveConfigurationAndControl.Feature.Level), {
917
1723
  currentState: valveState,
918
1724
  targetState: valveState,
919
1725
  openDuration: null,
920
- defaultOpenDuration: null,
1726
+ defaultOpenDuration: null, // Writable and persistent across restarts
921
1727
  remainingDuration: null,
922
1728
  valveFault: { generalFault: false, blocked: false, leaking: false, notConnected: false, shortCircuit: false, currentExceeded: false },
1729
+ // Feature.Level
923
1730
  currentLevel: valveLevel,
924
1731
  targetLevel: valveLevel,
925
- defaultOpenLevel: 100,
926
- levelStep: 1,
1732
+ defaultOpenLevel: 100, // Writable and persistent across restarts
1733
+ levelStep: 1, // Fixed
927
1734
  });
928
1735
  return this;
929
1736
  }
1737
+ /**
1738
+ * Creates the default PumpConfigurationAndControl cluster server with features ConstantSpeed.
1739
+ *
1740
+ * @param {PumpConfigurationAndControl.OperationMode} [pumpMode] - The pump mode to set. Defaults to `PumpConfigurationAndControl.OperationMode.Normal`.
1741
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1742
+ */
930
1743
  createDefaultPumpConfigurationAndControlClusterServer(pumpMode = PumpConfigurationAndControl.OperationMode.Normal) {
931
1744
  this.behaviors.require(PumpConfigurationAndControlServer.with(PumpConfigurationAndControl.Feature.ConstantSpeed), {
932
1745
  minConstSpeed: null,
@@ -941,6 +1754,13 @@ export class MatterbridgeEndpoint extends Endpoint {
941
1754
  });
942
1755
  return this;
943
1756
  }
1757
+ /**
1758
+ * Creates the default SmokeCOAlarm Cluster Server with features SmokeAlarm and CoAlarm.
1759
+ *
1760
+ * @param {SmokeCoAlarm.AlarmState} smokeState - The state of the smoke alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
1761
+ * @param {SmokeCoAlarm.AlarmState} coState - The state of the CO alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
1762
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1763
+ */
944
1764
  createDefaultSmokeCOAlarmClusterServer(smokeState = SmokeCoAlarm.AlarmState.Normal, coState = SmokeCoAlarm.AlarmState.Normal) {
945
1765
  this.behaviors.require(MatterbridgeSmokeCoAlarmServer.with(SmokeCoAlarm.Feature.SmokeAlarm, SmokeCoAlarm.Feature.CoAlarm).enable({
946
1766
  events: { smokeAlarm: true, interconnectSmokeAlarm: false, coAlarm: true, interconnectCoAlarm: false, lowBattery: true, hardwareFault: true, endOfService: true, selfTestComplete: true, alarmMuted: true, muteEnded: true, allClear: true },
@@ -956,6 +1776,12 @@ export class MatterbridgeEndpoint extends Endpoint {
956
1776
  });
957
1777
  return this;
958
1778
  }
1779
+ /**
1780
+ * Creates a smoke only SmokeCOAlarm Cluster Server with features SmokeAlarm.
1781
+ *
1782
+ * @param {SmokeCoAlarm.AlarmState} smokeState - The state of the smoke alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
1783
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1784
+ */
959
1785
  createSmokeOnlySmokeCOAlarmClusterServer(smokeState = SmokeCoAlarm.AlarmState.Normal) {
960
1786
  this.behaviors.require(MatterbridgeSmokeCoAlarmServer.with(SmokeCoAlarm.Feature.SmokeAlarm).enable({
961
1787
  events: { smokeAlarm: true, interconnectSmokeAlarm: false, coAlarm: false, interconnectCoAlarm: false, lowBattery: true, hardwareFault: true, endOfService: true, selfTestComplete: true, alarmMuted: true, muteEnded: true, allClear: true },
@@ -970,6 +1796,12 @@ export class MatterbridgeEndpoint extends Endpoint {
970
1796
  });
971
1797
  return this;
972
1798
  }
1799
+ /**
1800
+ * Creates a co only SmokeCOAlarm Cluster Server with features CoAlarm.
1801
+ *
1802
+ * @param {SmokeCoAlarm.AlarmState} coState - The state of the CO alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
1803
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1804
+ */
973
1805
  createCoOnlySmokeCOAlarmClusterServer(coState = SmokeCoAlarm.AlarmState.Normal) {
974
1806
  this.behaviors.require(MatterbridgeSmokeCoAlarmServer.with(SmokeCoAlarm.Feature.CoAlarm).enable({
975
1807
  events: { smokeAlarm: false, interconnectSmokeAlarm: false, coAlarm: true, interconnectCoAlarm: false, lowBattery: true, hardwareFault: true, endOfService: true, selfTestComplete: true, alarmMuted: true, muteEnded: true, allClear: true },
@@ -984,6 +1816,15 @@ export class MatterbridgeEndpoint extends Endpoint {
984
1816
  });
985
1817
  return this;
986
1818
  }
1819
+ /**
1820
+ * Creates a default momentary switch cluster server with features MomentarySwitch, MomentarySwitchRelease, MomentarySwitchLongPress and MomentarySwitchMultiPress
1821
+ * and events initialPress, longPress, shortRelease, longRelease, multiPressOngoing, multiPressComplete.
1822
+ *
1823
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1824
+ *
1825
+ * @remarks
1826
+ * This method adds a cluster server with default momentary switch features and configuration suitable for (AppleHome) Single Double Long automations.
1827
+ */
987
1828
  createDefaultSwitchClusterServer() {
988
1829
  this.behaviors.require(MatterbridgeSwitchServer.with(Switch.Feature.MomentarySwitch, Switch.Feature.MomentarySwitchRelease, Switch.Feature.MomentarySwitchLongPress, Switch.Feature.MomentarySwitchMultiPress).enable({
989
1830
  events: { initialPress: true, longPress: true, shortRelease: true, longRelease: true, multiPressOngoing: true, multiPressComplete: true },
@@ -994,6 +1835,15 @@ export class MatterbridgeEndpoint extends Endpoint {
994
1835
  });
995
1836
  return this;
996
1837
  }
1838
+ /**
1839
+ * Creates a default momentary switch cluster server with feature MomentarySwitch and event initialPress.
1840
+ *
1841
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1842
+ *
1843
+ * @remarks
1844
+ * This method adds a cluster server with default momentary switch features and configuration suitable for a Single press automations.
1845
+ * It is supported by the Home app.
1846
+ */
997
1847
  createDefaultMomentarySwitchClusterServer() {
998
1848
  this.behaviors.require(MatterbridgeSwitchServer.with(Switch.Feature.MomentarySwitch).enable({
999
1849
  events: { initialPress: true },
@@ -1003,6 +1853,14 @@ export class MatterbridgeEndpoint extends Endpoint {
1003
1853
  });
1004
1854
  return this;
1005
1855
  }
1856
+ /**
1857
+ * Creates a default latching switch cluster server with features LatchingSwitch.
1858
+ *
1859
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1860
+ *
1861
+ * @remarks
1862
+ * This method adds a cluster server with default latching switch features and configuration suitable for a latching switch with 2 positions.
1863
+ */
1006
1864
  createDefaultLatchingSwitchClusterServer() {
1007
1865
  this.behaviors.require(SwitchServer.with(Switch.Feature.LatchingSwitch).enable({
1008
1866
  events: { switchLatched: true },
@@ -1012,6 +1870,13 @@ export class MatterbridgeEndpoint extends Endpoint {
1012
1870
  });
1013
1871
  return this;
1014
1872
  }
1873
+ /**
1874
+ * Triggers a switch event on the specified endpoint.
1875
+ *
1876
+ * @param {string} event - The type of event to trigger. Possible values are 'Single', 'Double', 'Long' for momentarySwitch and 'Press', 'Release' for latchingSwitch.
1877
+ * @param {AnsiLogger} log - Optional logger to log the event.
1878
+ * @returns {boolean} - A boolean indicating whether the event was successfully triggered.
1879
+ */
1015
1880
  async triggerSwitchEvent(event, log) {
1016
1881
  if (this.maybeNumber === undefined) {
1017
1882
  this.log.error(`triggerSwitchEvent ${event} error: Endpoint number not assigned on endpoint ${this.maybeId}:${this.maybeNumber}`);
@@ -1073,10 +1938,37 @@ export class MatterbridgeEndpoint extends Endpoint {
1073
1938
  }
1074
1939
  return true;
1075
1940
  }
1941
+ /**
1942
+ * Creates a default OperationalState Cluster Server.
1943
+ *
1944
+ * @param {OperationalState.OperationalStateEnum} operationalState - The initial operational state id.
1945
+ *
1946
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1947
+ *
1948
+ * @remarks
1949
+ * This method adds a cluster server with a default operational state configuration:
1950
+ * - { operationalStateId: OperationalState.OperationalStateEnum.Stopped, operationalStateLabel: 'Stopped' },
1951
+ * - { operationalStateId: OperationalState.OperationalStateEnum.Running, operationalStateLabel: 'Running' },
1952
+ * - { operationalStateId: OperationalState.OperationalStateEnum.Paused, operationalStateLabel: 'Paused' },
1953
+ * - { operationalStateId: OperationalState.OperationalStateEnum.Error, operationalStateLabel: 'Error' },
1954
+ */
1076
1955
  createDefaultOperationalStateClusterServer(operationalState = OperationalState.OperationalStateEnum.Stopped) {
1077
1956
  this.behaviors.require(MatterbridgeOperationalStateServer, getDefaultOperationalStateClusterServer(operationalState));
1078
1957
  return this;
1079
1958
  }
1959
+ /**
1960
+ * Creates a default boolean state cluster server.
1961
+ * The stateChange event is enabled.
1962
+ *
1963
+ * @param {boolean} contact - The state of the cluster. Defaults to true (true = contact).
1964
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1965
+ *
1966
+ * @remarks
1967
+ * Water Leak Detector: true = leak, false = no leak
1968
+ * Water Freeze Detector: true = freeze, false = no freeze
1969
+ * Rain Sensor: true = rain, false = no rain
1970
+ * Contact Sensor: true = closed or contact, false = open or no contact
1971
+ */
1080
1972
  createDefaultBooleanStateClusterServer(contact) {
1081
1973
  this.behaviors.require(BooleanStateServer.enable({
1082
1974
  events: { stateChange: true },
@@ -1085,6 +1977,22 @@ export class MatterbridgeEndpoint extends Endpoint {
1085
1977
  });
1086
1978
  return this;
1087
1979
  }
1980
+ /**
1981
+ * Creates a default boolean state configuration cluster server to be used with the waterFreezeDetector, waterLeakDetector, and rainSensor device types.
1982
+ *
1983
+ * Features:
1984
+ * - Visual
1985
+ * - Audible
1986
+ * - SensitivityLevel
1987
+ *
1988
+ * @remarks Supports the enableDisableAlarm command.
1989
+ *
1990
+ * @param {boolean} [sensorFault] - Optional boolean value indicating the sensor fault state. Defaults to `false` if not provided.
1991
+ * @param {number} [currentSensitivityLevel] - The current sensitivity level. Defaults to `0` if not provided.
1992
+ * @param {number} [supportedSensitivityLevels] - The number of supported sensitivity levels. Defaults to `2` if not provided (min 2, max 10).
1993
+ * @param {number} [defaultSensitivityLevel] - The default sensitivity level. Defaults to `0` if not provided.
1994
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1995
+ */
1088
1996
  createDefaultBooleanStateConfigurationClusterServer(sensorFault = false, currentSensitivityLevel = 0, supportedSensitivityLevels = 2, defaultSensitivityLevel = 0) {
1089
1997
  this.behaviors.require(MatterbridgeBooleanStateConfigurationServer.with(BooleanStateConfiguration.Feature.Visual, BooleanStateConfiguration.Feature.Audible, BooleanStateConfiguration.Feature.SensitivityLevel).enable({
1090
1998
  events: { alarmsStateChanged: true, sensorFault: true },
@@ -1099,18 +2007,51 @@ export class MatterbridgeEndpoint extends Endpoint {
1099
2007
  });
1100
2008
  return this;
1101
2009
  }
2010
+ /**
2011
+ * Creates a default Device Energy Management Cluster Server with feature PowerForecastReporting and with the specified ESA type, ESA canGenerate, ESA state, and power limits.
2012
+ *
2013
+ * @param {DeviceEnergyManagement.EsaType} [esaType] - The ESA type. Defaults to `DeviceEnergyManagement.EsaType.Other`.
2014
+ * @param {boolean} [esaCanGenerate] - Indicates if the ESA can generate energy. Defaults to `false`.
2015
+ * @param {DeviceEnergyManagement.EsaState} [esaState] - The ESA state. Defaults to `DeviceEnergyManagement.EsaState.Online`.
2016
+ * @param {number} [absMinPower] - Indicate the minimum electrical power in mw that the ESA can consume when switched on. Defaults to `0` if not provided.
2017
+ * @param {number} [absMaxPower] - Indicate the maximum electrical power in mw that the ESA can consume when switched on. Defaults to `0` if not provided.
2018
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2019
+ *
2020
+ * @remarks
2021
+ * - The forecast attribute is set to null, indicating that there is no forecast currently available.
2022
+ * - The ESA type and canGenerate attributes are fixed and cannot be changed after creation.
2023
+ * - The ESA state is set to Online by default.
2024
+ * - The absolute minimum and maximum power attributes are set to 0 by default.
2025
+ * - For example, a battery storage inverter that can charge its battery at a maximum power of 2000W and can
2026
+ * discharge the battery at a maximum power of 3000W, would have a absMinPower: -3000W, absMaxPower: 2000W.
2027
+ */
1102
2028
  createDefaultDeviceEnergyManagementClusterServer(esaType = DeviceEnergyManagement.EsaType.Other, esaCanGenerate = false, esaState = DeviceEnergyManagement.EsaState.Online, absMinPower = 0, absMaxPower = 0) {
1103
2029
  this.behaviors.require(MatterbridgeDeviceEnergyManagementServer.with(DeviceEnergyManagement.Feature.PowerForecastReporting, DeviceEnergyManagement.Feature.PowerAdjustment), {
1104
- forecast: null,
1105
- powerAdjustmentCapability: null,
1106
- esaType,
1107
- esaCanGenerate,
2030
+ forecast: null, // A null value indicates that there is no forecast currently available
2031
+ powerAdjustmentCapability: null, // A null value indicates that no power adjustment is currently possible, and nor is any adjustment currently active
2032
+ esaType, // Fixed attribute
2033
+ esaCanGenerate, // Fixed attribute
1108
2034
  esaState,
1109
2035
  absMinPower,
1110
2036
  absMaxPower,
1111
2037
  });
1112
2038
  return this;
1113
2039
  }
2040
+ /**
2041
+ * Creates a default EnergyManagementMode Cluster Server.
2042
+ *
2043
+ * @param {number} [currentMode] - The current mode of the EnergyManagementMode cluster. Defaults to mode 1 (DeviceEnergyManagementMode.ModeTag.NoOptimization).
2044
+ * @param {EnergyManagementMode.ModeOption[]} [supportedModes] - The supported modes for the DeviceEnergyManagementMode cluster. The attribute is fixed and defaults to a predefined set of cluster modes.
2045
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2046
+ *
2047
+ * @remarks
2048
+ * A few examples of Device Energy Management modes and their mode tags are provided below.
2049
+ * - For the "No Energy Management (Forecast reporting only)" mode, tags: 0x4000 (NoOptimization).
2050
+ * - For the "Device Energy Management" mode, tags: 0x4001 (DeviceOptimization).
2051
+ * - For the "Home Energy Management" mode, tags: 0x4001 (DeviceOptimization), 0x4002 (LocalOptimization).
2052
+ * - For the "Grid Energy Management" mode, tags: 0x4003 (GridOptimization).
2053
+ * - For the "Full Energy Management" mode, tags: 0x4001 (DeviceOptimization), 0x4002 (LocalOptimization), 0x4003 (GridOptimization).
2054
+ */
1114
2055
  createDefaultDeviceEnergyManagementModeClusterServer(currentMode, supportedModes) {
1115
2056
  this.behaviors.require(MatterbridgeDeviceEnergyManagementModeServer, {
1116
2057
  supportedModes: supportedModes ?? [
@@ -1131,15 +2072,27 @@ export class MatterbridgeEndpoint extends Endpoint {
1131
2072
  mode: 5,
1132
2073
  modeTags: [{ value: DeviceEnergyManagementMode.ModeTag.DeviceOptimization }, { value: DeviceEnergyManagementMode.ModeTag.LocalOptimization }, { value: DeviceEnergyManagementMode.ModeTag.GridOptimization }],
1133
2074
  },
1134
- ],
2075
+ ], // Fixed attribute
1135
2076
  currentMode: currentMode ?? 1,
1136
2077
  });
1137
2078
  return this;
1138
2079
  }
2080
+ /**
2081
+ * Creates a default Power Topology Cluster Server with feature TreeTopology (the endpoint provides or consumes power to/from itself and its child endpoints). Only needed for an electricalSensor device type.
2082
+ *
2083
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2084
+ */
1139
2085
  createDefaultPowerTopologyClusterServer() {
1140
2086
  this.behaviors.require(PowerTopologyServer.with(PowerTopology.Feature.TreeTopology));
1141
2087
  return this;
1142
2088
  }
2089
+ /**
2090
+ * Creates a default Electrical Energy Measurement Cluster Server with features ImportedEnergy, ExportedEnergy, and CumulativeEnergy.
2091
+ *
2092
+ * @param {number} energyImported - The total consumption value in mW/h.
2093
+ * @param {number} energyExported - The total production value in mW/h.
2094
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2095
+ */
1143
2096
  createDefaultElectricalEnergyMeasurementClusterServer(energyImported = null, energyExported = null) {
1144
2097
  this.behaviors.require(ElectricalEnergyMeasurementServer.with(ElectricalEnergyMeasurement.Feature.ImportedEnergy, ElectricalEnergyMeasurement.Feature.ExportedEnergy, ElectricalEnergyMeasurement.Feature.CumulativeEnergy), {
1145
2098
  accuracy: {
@@ -1155,6 +2108,15 @@ export class MatterbridgeEndpoint extends Endpoint {
1155
2108
  });
1156
2109
  return this;
1157
2110
  }
2111
+ /**
2112
+ * Creates a default Electrical Power Measurement Cluster Server with features AlternatingCurrent.
2113
+ *
2114
+ * @param {number} voltage - The voltage value in millivolts.
2115
+ * @param {number} current - The current value in milliamperes.
2116
+ * @param {number} power - The power value in milliwatts.
2117
+ * @param {number} frequency - The frequency value in millihertz.
2118
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2119
+ */
1158
2120
  createDefaultElectricalPowerMeasurementClusterServer(voltage = null, current = null, power = null, frequency = null) {
1159
2121
  this.behaviors.require(ElectricalPowerMeasurementServer.with(ElectricalPowerMeasurement.Feature.AlternatingCurrent), {
1160
2122
  powerMode: ElectricalPowerMeasurement.PowerMode.Ac,
@@ -1196,36 +2158,124 @@ export class MatterbridgeEndpoint extends Endpoint {
1196
2158
  });
1197
2159
  return this;
1198
2160
  }
2161
+ /**
2162
+ * Creates a default TemperatureMeasurement cluster server.
2163
+ *
2164
+ * @param {number | null} measuredValue - The measured value of the temperature x 100.
2165
+ * @param {number | null} minMeasuredValue - The minimum measured value of the temperature x 100.
2166
+ * @param {number | null} maxMeasuredValue - The maximum measured value of the temperature x 100.
2167
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2168
+ */
1199
2169
  createDefaultTemperatureMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
1200
2170
  this.behaviors.require(TemperatureMeasurementServer, getDefaultTemperatureMeasurementClusterServer(measuredValue, minMeasuredValue, maxMeasuredValue));
1201
2171
  return this;
1202
2172
  }
2173
+ /**
2174
+ * Creates a default RelativeHumidityMeasurement cluster server.
2175
+ *
2176
+ * @param {number | null} measuredValue - The measured value of the relative humidity x 100.
2177
+ * @param {number | null} minMeasuredValue - The minimum measured value of the relative humidity x 100.
2178
+ * @param {number | null} maxMeasuredValue - The maximum measured value of the relative humidity x 100.
2179
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2180
+ */
1203
2181
  createDefaultRelativeHumidityMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
1204
2182
  this.behaviors.require(RelativeHumidityMeasurementServer, getDefaultRelativeHumidityMeasurementClusterServer(measuredValue, minMeasuredValue, maxMeasuredValue));
1205
2183
  return this;
1206
2184
  }
2185
+ /**
2186
+ * Creates a default PressureMeasurement cluster server.
2187
+ *
2188
+ * @param {number | null} measuredValue - The measured value for the pressure in kPa x 10.
2189
+ * @param {number | null} minMeasuredValue - The minimum measured value for the pressure in kPa x 10.
2190
+ * @param {number | null} maxMeasuredValue - The maximum measured value for the pressure in kPa x 10.
2191
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2192
+ *
2193
+ * @remarks
2194
+ * - MeasuredValue = 10 x Pressure in kPa
2195
+ * - MeasuredValue = 1 x Pressure in hPa
2196
+ * - MeasuredValue = 33.8639 x Pressure in inHg
2197
+ *
2198
+ * Conversion:
2199
+ * - 1 kPa = 10 hPa
2200
+ * - 1 inHg = 33.8639 hPa
2201
+ */
1207
2202
  createDefaultPressureMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
1208
2203
  this.behaviors.require(PressureMeasurementServer, getDefaultPressureMeasurementClusterServer(measuredValue, minMeasuredValue, maxMeasuredValue));
1209
2204
  return this;
1210
2205
  }
2206
+ /**
2207
+ * Creates a default IlluminanceMeasurement cluster server.
2208
+ *
2209
+ * @param {number | null} measuredValue - The measured value of illuminance.
2210
+ * @param {number | null} minMeasuredValue - The minimum measured value of illuminance.
2211
+ * @param {number | null} maxMeasuredValue - The maximum measured value of illuminance.
2212
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2213
+ *
2214
+ * @remarks The default value for the illuminance measurement is null.
2215
+ * This attribute SHALL indicate the illuminance in Lux (symbol lx) as follows:
2216
+ * • MeasuredValue = 10,000 x log10(illuminance) + 1,
2217
+ * where 1 lx <= illuminance <= 3.576 Mlx, corresponding to a MeasuredValue in the range 1 to 0xFFFE.
2218
+ * • 0 indicates a value of illuminance that is too low to be measured
2219
+ * • null indicates that the illuminance measurement is invalid.
2220
+ *
2221
+ * - Lux to matter = Math.round(Math.max(Math.min(10000 * Math.log10(lux), 0xfffe), 0))
2222
+ * - Matter to Lux = Math.round(Math.max(Math.pow(10, value / 10000), 0))
2223
+ */
1211
2224
  createDefaultIlluminanceMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
1212
2225
  this.behaviors.require(IlluminanceMeasurementServer, getDefaultIlluminanceMeasurementClusterServer(measuredValue, minMeasuredValue, maxMeasuredValue));
1213
2226
  return this;
1214
2227
  }
2228
+ /**
2229
+ * Creates a default FlowMeasurement cluster server.
2230
+ *
2231
+ * @param {number | null} measuredValue - The measured value of the flow in 10 x m3/h.
2232
+ * @param {number | null} minMeasuredValue - The minimum measured value of the flow in 10 x m3/h.
2233
+ * @param {number | null} maxMeasuredValue - The maximum measured value of the flow in 10 x m3/h.
2234
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2235
+ */
1215
2236
  createDefaultFlowMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
1216
2237
  this.behaviors.require(FlowMeasurementServer, getDefaultFlowMeasurementClusterServer(measuredValue, minMeasuredValue, maxMeasuredValue));
1217
2238
  return this;
1218
2239
  }
2240
+ /**
2241
+ * Creates a default OccupancySensing cluster server with feature PassiveInfrared.
2242
+ *
2243
+ * @param {boolean} occupied - A boolean indicating whether the occupancy is occupied or not. Default is false.
2244
+ * @param {number} holdTime - The hold time in seconds. Default is 30.
2245
+ * @param {number} holdTimeMin - The minimum hold time in seconds. Default is 1.
2246
+ * @param {number} holdTimeMax - The maximum hold time in seconds. Default is 300.
2247
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2248
+ *
2249
+ * @remarks The default value for the occupancy sensor type is PIR.
2250
+ */
1219
2251
  createDefaultOccupancySensingClusterServer(occupied = false, holdTime = 30, holdTimeMin = 1, holdTimeMax = 300) {
1220
2252
  this.behaviors.require(OccupancySensingServer.with(OccupancySensing.Feature.PassiveInfrared), getDefaultOccupancySensingClusterServer(occupied, holdTime, holdTimeMin, holdTimeMax));
1221
2253
  return this;
1222
2254
  }
2255
+ /**
2256
+ * Creates a default AirQuality cluster server.
2257
+ *
2258
+ * @param {AirQuality.AirQualityEnum} airQuality The air quality level. Defaults to `AirQuality.AirQualityType.Unknown`.
2259
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2260
+ */
1223
2261
  createDefaultAirQualityClusterServer(airQuality = AirQuality.AirQualityEnum.Unknown) {
1224
2262
  this.behaviors.require(AirQualityServer.with(AirQuality.Feature.Fair, AirQuality.Feature.Moderate, AirQuality.Feature.VeryPoor, AirQuality.Feature.ExtremelyPoor), {
1225
2263
  airQuality,
1226
2264
  });
1227
2265
  return this;
1228
2266
  }
2267
+ /**
2268
+ * Creates a default TotalVolatileOrganicCompoundsConcentrationMeasurement cluster server with feature NumericMeasurement.
2269
+ *
2270
+ * @param {number | null} measuredValue - The measured value of the concentration.
2271
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
2272
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2273
+ * @param {number} [uncertainty] - The uncertainty value (optional).
2274
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2275
+ *
2276
+ * @remarks
2277
+ * The measurementUnit and the measurementMedium attributes are fixed and cannot be changed after creation.
2278
+ */
1229
2279
  createDefaultTvocMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air, uncertainty) {
1230
2280
  this.behaviors.require(TotalVolatileOrganicCompoundsConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1231
2281
  measuredValue,
@@ -1237,6 +2287,16 @@ export class MatterbridgeEndpoint extends Endpoint {
1237
2287
  });
1238
2288
  return this;
1239
2289
  }
2290
+ /**
2291
+ * Creates a default TotalVolatileOrganicCompoundsConcentrationMeasurement cluster server with feature LevelIndication.
2292
+
2293
+ * @param {ConcentrationMeasurement.LevelValue} levelValue - The level value of the measurement (default to ConcentrationMeasurement.LevelValue.Unknown).
2294
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The measurement medium (default to ConcentrationMeasurement.MeasurementMedium.Air).
2295
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2296
+ *
2297
+ * @remarks
2298
+ * The measurementMedium attribute is fixed and cannot be changed after creation.
2299
+ */
1240
2300
  createLevelTvocMeasurementClusterServer(levelValue = ConcentrationMeasurement.LevelValue.Unknown, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1241
2301
  this.behaviors.require(TotalVolatileOrganicCompoundsConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.LevelIndication, ConcentrationMeasurement.Feature.MediumLevel, ConcentrationMeasurement.Feature.CriticalLevel), {
1242
2302
  levelValue,
@@ -1244,6 +2304,17 @@ export class MatterbridgeEndpoint extends Endpoint {
1244
2304
  });
1245
2305
  return this;
1246
2306
  }
2307
+ /**
2308
+ * Create a default CarbonMonoxideConcentrationMeasurement cluster server with feature NumericMeasurement.
2309
+ *
2310
+ * @param {number | null} measuredValue - The measured value of the concentration.
2311
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
2312
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2313
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2314
+ *
2315
+ * @remarks
2316
+ * The measurementUnit and the measurementMedium attributes are fixed and cannot be changed after creation.
2317
+ */
1247
2318
  createDefaultCarbonMonoxideConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1248
2319
  this.behaviors.require(CarbonMonoxideConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1249
2320
  measuredValue,
@@ -1255,6 +2326,17 @@ export class MatterbridgeEndpoint extends Endpoint {
1255
2326
  });
1256
2327
  return this;
1257
2328
  }
2329
+ /**
2330
+ * Create a default CarbonDioxideConcentrationMeasurement cluster server with feature NumericMeasurement.
2331
+ *
2332
+ * @param {number | null} measuredValue - The measured value of the concentration.
2333
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
2334
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2335
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2336
+ *
2337
+ * @remarks
2338
+ * The measurementUnit and the measurementMedium attributes are fixed and cannot be changed after creation.
2339
+ */
1258
2340
  createDefaultCarbonDioxideConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1259
2341
  this.behaviors.require(CarbonDioxideConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1260
2342
  measuredValue,
@@ -1266,6 +2348,17 @@ export class MatterbridgeEndpoint extends Endpoint {
1266
2348
  });
1267
2349
  return this;
1268
2350
  }
2351
+ /**
2352
+ * Create a default FormaldehydeConcentrationMeasurement cluster server with feature NumericMeasurement.
2353
+ *
2354
+ * @param {number | null} measuredValue - The measured value of the concentration.
2355
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
2356
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2357
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2358
+ *
2359
+ * @remarks
2360
+ * The measurementUnit and the measurementMedium attributes are fixed and cannot be changed after creation.
2361
+ */
1269
2362
  createDefaultFormaldehydeConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1270
2363
  this.behaviors.require(FormaldehydeConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1271
2364
  measuredValue,
@@ -1277,6 +2370,17 @@ export class MatterbridgeEndpoint extends Endpoint {
1277
2370
  });
1278
2371
  return this;
1279
2372
  }
2373
+ /**
2374
+ * Create a default Pm1ConcentrationMeasurement cluster server with feature NumericMeasurement.
2375
+ *
2376
+ * @param {number | null} measuredValue - The measured value of the concentration.
2377
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
2378
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2379
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2380
+ *
2381
+ * @remarks
2382
+ * The measurementUnit and the measurementMedium attributes are fixed and cannot be changed after creation.
2383
+ */
1280
2384
  createDefaultPm1ConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1281
2385
  this.behaviors.require(Pm1ConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1282
2386
  measuredValue,
@@ -1288,6 +2392,17 @@ export class MatterbridgeEndpoint extends Endpoint {
1288
2392
  });
1289
2393
  return this;
1290
2394
  }
2395
+ /**
2396
+ * Create a default Pm25ConcentrationMeasurement cluster server with feature NumericMeasurement.
2397
+ *
2398
+ * @param {number | null} measuredValue - The measured value of the concentration.
2399
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
2400
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2401
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2402
+ *
2403
+ * @remarks
2404
+ * The measurementUnit and the measurementMedium attributes are fixed and cannot be changed after creation.
2405
+ */
1291
2406
  createDefaultPm25ConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1292
2407
  this.behaviors.require(Pm25ConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1293
2408
  measuredValue,
@@ -1299,6 +2414,17 @@ export class MatterbridgeEndpoint extends Endpoint {
1299
2414
  });
1300
2415
  return this;
1301
2416
  }
2417
+ /**
2418
+ * Create a default Pm10ConcentrationMeasurement cluster server with feature NumericMeasurement.
2419
+ *
2420
+ * @param {number | null} measuredValue - The measured value of the concentration.
2421
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
2422
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2423
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2424
+ *
2425
+ * @remarks
2426
+ * The measurementUnit and the measurementMedium attributes are fixed and cannot be changed after creation.
2427
+ */
1302
2428
  createDefaultPm10ConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1303
2429
  this.behaviors.require(Pm10ConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1304
2430
  measuredValue,
@@ -1310,6 +2436,17 @@ export class MatterbridgeEndpoint extends Endpoint {
1310
2436
  });
1311
2437
  return this;
1312
2438
  }
2439
+ /**
2440
+ * Create a default OzoneConcentrationMeasurement cluster server with feature NumericMeasurement.
2441
+ *
2442
+ * @param {number | null} measuredValue - The measured value of the concentration.
2443
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ugm3).
2444
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2445
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2446
+ *
2447
+ * @remarks
2448
+ * The measurementUnit and the measurementMedium attributes are fixed and cannot be changed after creation.
2449
+ */
1313
2450
  createDefaultOzoneConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ugm3, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1314
2451
  this.behaviors.require(OzoneConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1315
2452
  measuredValue,
@@ -1321,6 +2458,17 @@ export class MatterbridgeEndpoint extends Endpoint {
1321
2458
  });
1322
2459
  return this;
1323
2460
  }
2461
+ /**
2462
+ * Create a default RadonConcentrationMeasurement cluster server with feature NumericMeasurement.
2463
+ *
2464
+ * @param {number | null} measuredValue - The measured value of the concentration.
2465
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
2466
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2467
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2468
+ *
2469
+ * @remarks
2470
+ * The measurementUnit and the measurementMedium attributes are fixed and cannot be changed after creation.
2471
+ */
1324
2472
  createDefaultRadonConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1325
2473
  this.behaviors.require(RadonConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1326
2474
  measuredValue,
@@ -1332,6 +2480,17 @@ export class MatterbridgeEndpoint extends Endpoint {
1332
2480
  });
1333
2481
  return this;
1334
2482
  }
2483
+ /**
2484
+ * Create a default NitrogenDioxideConcentrationMeasurement cluster server with feature NumericMeasurement.
2485
+ *
2486
+ * @param {number | null} measuredValue - The measured value of the concentration.
2487
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ugm3).
2488
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2489
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2490
+ *
2491
+ * @remarks
2492
+ * The measurementUnit and the measurementMedium attributes are fixed and cannot be changed after creation.
2493
+ */
1335
2494
  createDefaultNitrogenDioxideConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ugm3, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1336
2495
  this.behaviors.require(NitrogenDioxideConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1337
2496
  measuredValue,
@@ -1344,3 +2503,4 @@ export class MatterbridgeEndpoint extends Endpoint {
1344
2503
  return this;
1345
2504
  }
1346
2505
  }
2506
+ //# sourceMappingURL=matterbridgeEndpoint.js.map