matterbridge 3.0.7-dev-20250618-fb768ee → 3.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (188) hide show
  1. package/CHANGELOG.md +3 -2
  2. package/README-DEV.md +4 -4
  3. package/dist/cli.d.ts +29 -0
  4. package/dist/cli.d.ts.map +1 -0
  5. package/dist/cli.js +62 -2
  6. package/dist/cli.js.map +1 -0
  7. package/dist/clusters/export.d.ts +2 -0
  8. package/dist/clusters/export.d.ts.map +1 -0
  9. package/dist/clusters/export.js +2 -0
  10. package/dist/clusters/export.js.map +1 -0
  11. package/dist/defaultConfigSchema.d.ts +27 -0
  12. package/dist/defaultConfigSchema.d.ts.map +1 -0
  13. package/dist/defaultConfigSchema.js +23 -0
  14. package/dist/defaultConfigSchema.js.map +1 -0
  15. package/dist/deviceManager.d.ts +114 -0
  16. package/dist/deviceManager.d.ts.map +1 -0
  17. package/dist/deviceManager.js +94 -1
  18. package/dist/deviceManager.js.map +1 -0
  19. package/dist/devices/export.d.ts +5 -0
  20. package/dist/devices/export.d.ts.map +1 -0
  21. package/dist/devices/export.js +2 -0
  22. package/dist/devices/export.js.map +1 -0
  23. package/dist/evse.d.ts +67 -0
  24. package/dist/evse.d.ts.map +1 -0
  25. package/dist/evse.js +65 -9
  26. package/dist/evse.js.map +1 -0
  27. package/dist/frontend.d.ts +256 -0
  28. package/dist/frontend.d.ts.map +1 -0
  29. package/dist/frontend.js +374 -16
  30. package/dist/frontend.js.map +1 -0
  31. package/dist/globalMatterbridge.d.ts +32 -0
  32. package/dist/globalMatterbridge.d.ts.map +1 -0
  33. package/dist/globalMatterbridge.js +20 -0
  34. package/dist/globalMatterbridge.js.map +1 -0
  35. package/dist/helpers.d.ts +47 -0
  36. package/dist/helpers.d.ts.map +1 -0
  37. package/dist/helpers.js +51 -0
  38. package/dist/helpers.js.map +1 -0
  39. package/dist/index.d.ts +37 -0
  40. package/dist/index.d.ts.map +1 -0
  41. package/dist/index.js +28 -1
  42. package/dist/index.js.map +1 -0
  43. package/dist/laundryWasher.d.ts +243 -0
  44. package/dist/laundryWasher.d.ts.map +1 -0
  45. package/dist/laundryWasher.js +92 -7
  46. package/dist/laundryWasher.js.map +1 -0
  47. package/dist/logger/export.d.ts +2 -0
  48. package/dist/logger/export.d.ts.map +1 -0
  49. package/dist/logger/export.js +1 -0
  50. package/dist/logger/export.js.map +1 -0
  51. package/dist/matter/behaviors.d.ts +2 -0
  52. package/dist/matter/behaviors.d.ts.map +1 -0
  53. package/dist/matter/behaviors.js +2 -0
  54. package/dist/matter/behaviors.js.map +1 -0
  55. package/dist/matter/clusters.d.ts +2 -0
  56. package/dist/matter/clusters.d.ts.map +1 -0
  57. package/dist/matter/clusters.js +2 -0
  58. package/dist/matter/clusters.js.map +1 -0
  59. package/dist/matter/devices.d.ts +2 -0
  60. package/dist/matter/devices.d.ts.map +1 -0
  61. package/dist/matter/devices.js +2 -0
  62. package/dist/matter/devices.js.map +1 -0
  63. package/dist/matter/endpoints.d.ts +2 -0
  64. package/dist/matter/endpoints.d.ts.map +1 -0
  65. package/dist/matter/endpoints.js +2 -0
  66. package/dist/matter/endpoints.js.map +1 -0
  67. package/dist/matter/export.d.ts +5 -0
  68. package/dist/matter/export.d.ts.map +1 -0
  69. package/dist/matter/export.js +2 -0
  70. package/dist/matter/export.js.map +1 -0
  71. package/dist/matter/types.d.ts +3 -0
  72. package/dist/matter/types.d.ts.map +1 -0
  73. package/dist/matter/types.js +2 -0
  74. package/dist/matter/types.js.map +1 -0
  75. package/dist/matterbridge.d.ts +445 -0
  76. package/dist/matterbridge.d.ts.map +1 -0
  77. package/dist/matterbridge.js +748 -46
  78. package/dist/matterbridge.js.map +1 -0
  79. package/dist/matterbridgeAccessoryPlatform.d.ts +40 -0
  80. package/dist/matterbridgeAccessoryPlatform.d.ts.map +1 -0
  81. package/dist/matterbridgeAccessoryPlatform.js +34 -0
  82. package/dist/matterbridgeAccessoryPlatform.js.map +1 -0
  83. package/dist/matterbridgeBehaviors.d.ts +1333 -0
  84. package/dist/matterbridgeBehaviors.d.ts.map +1 -0
  85. package/dist/matterbridgeBehaviors.js +54 -1
  86. package/dist/matterbridgeBehaviors.js.map +1 -0
  87. package/dist/matterbridgeDeviceTypes.d.ts +644 -0
  88. package/dist/matterbridgeDeviceTypes.d.ts.map +1 -0
  89. package/dist/matterbridgeDeviceTypes.js +578 -15
  90. package/dist/matterbridgeDeviceTypes.js.map +1 -0
  91. package/dist/matterbridgeDynamicPlatform.d.ts +40 -0
  92. package/dist/matterbridgeDynamicPlatform.d.ts.map +1 -0
  93. package/dist/matterbridgeDynamicPlatform.js +34 -0
  94. package/dist/matterbridgeDynamicPlatform.js.map +1 -0
  95. package/dist/matterbridgeEndpoint.d.ts +1145 -0
  96. package/dist/matterbridgeEndpoint.d.ts.map +1 -0
  97. package/dist/matterbridgeEndpoint.js +995 -40
  98. package/dist/matterbridgeEndpoint.js.map +1 -0
  99. package/dist/matterbridgeEndpointHelpers.d.ts +3083 -0
  100. package/dist/matterbridgeEndpointHelpers.d.ts.map +1 -0
  101. package/dist/matterbridgeEndpointHelpers.js +204 -10
  102. package/dist/matterbridgeEndpointHelpers.js.map +1 -0
  103. package/dist/matterbridgePlatform.d.ts +290 -0
  104. package/dist/matterbridgePlatform.d.ts.map +1 -0
  105. package/dist/matterbridgePlatform.js +221 -6
  106. package/dist/matterbridgePlatform.js.map +1 -0
  107. package/dist/matterbridgeTypes.d.ts +196 -0
  108. package/dist/matterbridgeTypes.d.ts.map +1 -0
  109. package/dist/matterbridgeTypes.js +24 -0
  110. package/dist/matterbridgeTypes.js.map +1 -0
  111. package/dist/pluginManager.d.ts +273 -0
  112. package/dist/pluginManager.d.ts.map +1 -0
  113. package/dist/pluginManager.js +269 -3
  114. package/dist/pluginManager.js.map +1 -0
  115. package/dist/roboticVacuumCleaner.d.ts +102 -0
  116. package/dist/roboticVacuumCleaner.d.ts.map +1 -0
  117. package/dist/roboticVacuumCleaner.js +81 -6
  118. package/dist/roboticVacuumCleaner.js.map +1 -0
  119. package/dist/shelly.d.ts +161 -0
  120. package/dist/shelly.d.ts.map +1 -0
  121. package/dist/shelly.js +155 -7
  122. package/dist/shelly.js.map +1 -0
  123. package/dist/storage/export.d.ts +2 -0
  124. package/dist/storage/export.d.ts.map +1 -0
  125. package/dist/storage/export.js +1 -0
  126. package/dist/storage/export.js.map +1 -0
  127. package/dist/update.d.ts +58 -0
  128. package/dist/update.d.ts.map +1 -0
  129. package/dist/update.js +53 -0
  130. package/dist/update.js.map +1 -0
  131. package/dist/utils/colorUtils.d.ts +61 -0
  132. package/dist/utils/colorUtils.d.ts.map +1 -0
  133. package/dist/utils/colorUtils.js +205 -2
  134. package/dist/utils/colorUtils.js.map +1 -0
  135. package/dist/utils/commandLine.d.ts +58 -0
  136. package/dist/utils/commandLine.d.ts.map +1 -0
  137. package/dist/utils/commandLine.js +53 -0
  138. package/dist/utils/commandLine.js.map +1 -0
  139. package/dist/utils/copyDirectory.d.ts +32 -0
  140. package/dist/utils/copyDirectory.d.ts.map +1 -0
  141. package/dist/utils/copyDirectory.js +37 -1
  142. package/dist/utils/copyDirectory.js.map +1 -0
  143. package/dist/utils/createDirectory.d.ts +32 -0
  144. package/dist/utils/createDirectory.d.ts.map +1 -0
  145. package/dist/utils/createDirectory.js +31 -0
  146. package/dist/utils/createDirectory.js.map +1 -0
  147. package/dist/utils/createZip.d.ts +38 -0
  148. package/dist/utils/createZip.d.ts.map +1 -0
  149. package/dist/utils/createZip.js +42 -2
  150. package/dist/utils/createZip.js.map +1 -0
  151. package/dist/utils/deepCopy.d.ts +31 -0
  152. package/dist/utils/deepCopy.d.ts.map +1 -0
  153. package/dist/utils/deepCopy.js +38 -0
  154. package/dist/utils/deepCopy.js.map +1 -0
  155. package/dist/utils/deepEqual.d.ts +53 -0
  156. package/dist/utils/deepEqual.d.ts.map +1 -0
  157. package/dist/utils/deepEqual.js +71 -1
  158. package/dist/utils/deepEqual.js.map +1 -0
  159. package/dist/utils/export.d.ts +12 -0
  160. package/dist/utils/export.d.ts.map +1 -0
  161. package/dist/utils/export.js +1 -0
  162. package/dist/utils/export.js.map +1 -0
  163. package/dist/utils/hex.d.ts +48 -0
  164. package/dist/utils/hex.d.ts.map +1 -0
  165. package/dist/utils/hex.js +57 -0
  166. package/dist/utils/hex.js.map +1 -0
  167. package/dist/utils/isvalid.d.ts +102 -0
  168. package/dist/utils/isvalid.d.ts.map +1 -0
  169. package/dist/utils/isvalid.js +100 -0
  170. package/dist/utils/isvalid.js.map +1 -0
  171. package/dist/utils/network.d.ts +69 -0
  172. package/dist/utils/network.d.ts.map +1 -0
  173. package/dist/utils/network.js +76 -5
  174. package/dist/utils/network.js.map +1 -0
  175. package/dist/utils/spawn.d.ts +12 -0
  176. package/dist/utils/spawn.d.ts.map +1 -0
  177. package/dist/utils/spawn.js +16 -0
  178. package/dist/utils/spawn.js.map +1 -0
  179. package/dist/utils/wait.d.ts +52 -0
  180. package/dist/utils/wait.d.ts.map +1 -0
  181. package/dist/utils/wait.js +58 -9
  182. package/dist/utils/wait.js.map +1 -0
  183. package/dist/waterHeater.d.ts +90 -0
  184. package/dist/waterHeater.d.ts.map +1 -0
  185. package/dist/waterHeater.js +62 -2
  186. package/dist/waterHeater.js.map +1 -0
  187. package/npm-shrinkwrap.json +2 -2
  188. package/package.json +2 -1
@@ -1,10 +1,36 @@
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
+ * @date 2024-10-01
7
+ * @version 2.1.1
8
+ *
9
+ * Copyright 2024, 2025, 2026 Luca Liguori.
10
+ *
11
+ * Licensed under the Apache License, Version 2.0 (the "License");
12
+ * you may not use this file except in compliance with the License.
13
+ * You may obtain a copy of the License at
14
+ *
15
+ * http://www.apache.org/licenses/LICENSE-2.0
16
+ *
17
+ * Unless required by applicable law or agreed to in writing, software
18
+ * distributed under the License is distributed on an "AS IS" BASIS,
19
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
+ * See the License for the specific language governing permissions and
21
+ * limitations under the License. *
22
+ */
23
+ // AnsiLogger module
1
24
  import { AnsiLogger, CYAN, YELLOW, db, debugStringify, hk, or, zb } from './logger/export.js';
25
+ // Matterbridge
2
26
  import { bridgedNode } from './matterbridgeDeviceTypes.js';
3
27
  import { isValidNumber, isValidObject, isValidString } from './utils/export.js';
4
28
  import { MatterbridgeServer, MatterbridgeIdentifyServer, MatterbridgeOnOffServer, MatterbridgeLevelControlServer, MatterbridgeColorControlServer, MatterbridgeLiftWindowCoveringServer, MatterbridgeLiftTiltWindowCoveringServer, MatterbridgeThermostatServer, MatterbridgeFanControlServer, MatterbridgeDoorLockServer, MatterbridgeModeSelectServer, MatterbridgeValveConfigurationAndControlServer, MatterbridgeSmokeCoAlarmServer, MatterbridgeBooleanStateConfigurationServer, MatterbridgeSwitchServer, MatterbridgeOperationalStateServer, MatterbridgeDeviceEnergyManagementModeServer, } from './matterbridgeBehaviors.js';
5
29
  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, } from './matterbridgeEndpointHelpers.js';
30
+ // @matter
6
31
  import { Endpoint, Lifecycle, MutableEndpoint, NamedHandler, SupportedBehaviors, UINT16_MAX, UINT32_MAX, VendorId } from '@matter/main';
7
32
  import { getClusterNameById, MeasurementType } from '@matter/main/types';
33
+ // @matter clusters
8
34
  import { Descriptor } from '@matter/main/clusters/descriptor';
9
35
  import { PowerSource } from '@matter/main/clusters/power-source';
10
36
  import { BridgedDeviceBasicInformation } from '@matter/main/clusters/bridged-device-basic-information';
@@ -31,6 +57,7 @@ import { ThermostatUserInterfaceConfiguration } from '@matter/main/clusters/ther
31
57
  import { OperationalState } from '@matter/main/clusters/operational-state';
32
58
  import { DeviceEnergyManagement } from '@matter/main/clusters/device-energy-management';
33
59
  import { DeviceEnergyManagementMode } from '@matter/main/clusters/device-energy-management-mode';
60
+ // @matter behaviors
34
61
  import { DescriptorServer } from '@matter/main/behaviors/descriptor';
35
62
  import { PowerSourceServer } from '@matter/main/behaviors/power-source';
36
63
  import { BridgedDeviceBasicInformationServer } from '@matter/main/behaviors/bridged-device-basic-information';
@@ -66,10 +93,15 @@ import { ActivatedCarbonFilterMonitoringServer } from '@matter/main/behaviors/ac
66
93
  import { ThermostatUserInterfaceConfigurationServer } from '@matter/main/behaviors/thermostat-user-interface-configuration';
67
94
  import { DeviceEnergyManagementServer } from '@matter/main/behaviors/device-energy-management';
68
95
  export class MatterbridgeEndpoint extends Endpoint {
96
+ /** The bridge mode of Matterbridge */
69
97
  static bridgeMode = '';
70
- static logLevel = "info";
98
+ /** The default log level of the new MatterbridgeEndpoints */
99
+ static logLevel = "info" /* LogLevel.INFO */;
100
+ /** The logger instance for the MatterbridgeEndpoint */
71
101
  log;
102
+ /** The plugin name this MatterbridgeEndpoint belongs to */
72
103
  plugin = undefined;
104
+ /** The configuration URL of the device, if available */
73
105
  configUrl = undefined;
74
106
  deviceName = undefined;
75
107
  serialNumber = undefined;
@@ -83,15 +115,29 @@ export class MatterbridgeEndpoint extends Endpoint {
83
115
  hardwareVersion = undefined;
84
116
  hardwareVersionString = undefined;
85
117
  productUrl = 'https://www.npmjs.com/package/matterbridge';
118
+ /** The server node of the endpoint, if it is a single not bridged endpoint */
86
119
  serverNode;
120
+ /** The name of the first device type of the endpoint (old api compatibility) */
87
121
  name = undefined;
122
+ /** The code of the first device type of the endpoint (old api compatibility) */
88
123
  deviceType;
124
+ /** The id of the endpoint (old api compatibility) */
89
125
  uniqueStorageKey = undefined;
90
126
  tagList = undefined;
127
+ /** Maps the DeviceTypeDefinitions with their code */
91
128
  deviceTypes = new Map();
129
+ /** Command handler for the MatterbridgeEndpoint commands */
92
130
  commandHandler = new NamedHandler();
131
+ /**
132
+ * Represents a MatterbridgeEndpoint.
133
+ * @constructor
134
+ * @param {DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>} definition - The DeviceTypeDefinition(s) of the endpoint.
135
+ * @param {MatterbridgeEndpointOptions} [options={}] - The options for the device.
136
+ * @param {boolean} [debug=false] - Debug flag.
137
+ */
93
138
  constructor(definition, options = {}, debug = false) {
94
139
  let deviceTypeList = [];
140
+ // Get the first DeviceTypeDefinition
95
141
  let firstDefinition;
96
142
  if (Array.isArray(definition)) {
97
143
  firstDefinition = definition[0];
@@ -104,6 +150,7 @@ export class MatterbridgeEndpoint extends Endpoint {
104
150
  firstDefinition = definition;
105
151
  deviceTypeList = [{ deviceType: firstDefinition.code, revision: firstDefinition.revision }];
106
152
  }
153
+ // Convert the first DeviceTypeDefinition to an EndpointType.Options
107
154
  const deviceTypeDefinitionV8 = {
108
155
  name: firstDefinition.name.replace('-', '_'),
109
156
  deviceType: firstDefinition.code,
@@ -122,9 +169,11 @@ export class MatterbridgeEndpoint extends Endpoint {
122
169
  behaviors: options.tagList ? SupportedBehaviors(DescriptorServer.with(Descriptor.Feature.TagList)) : {},
123
170
  };
124
171
  const endpointV8 = MutableEndpoint(deviceTypeDefinitionV8);
172
+ // Check if the uniqueStorageKey is valid
125
173
  if (options.uniqueStorageKey && checkNotLatinCharacters(options.uniqueStorageKey)) {
126
174
  options.uniqueStorageKey = generateUniqueId(options.uniqueStorageKey);
127
175
  }
176
+ // Convert the options to an Endpoint.Options
128
177
  const optionsV8 = {
129
178
  id: options.uniqueStorageKey?.replace(/[ .]/g, ''),
130
179
  number: options.endpointId,
@@ -142,16 +191,40 @@ export class MatterbridgeEndpoint extends Endpoint {
142
191
  }
143
192
  else
144
193
  this.deviceTypes.set(firstDefinition.code, firstDefinition);
145
- this.log = new AnsiLogger({ logName: options.uniqueStorageKey ?? 'MatterbridgeEndpoint', logTimestampFormat: 4, logLevel: debug === true ? "debug" : MatterbridgeEndpoint.logLevel });
194
+ // console.log('MatterbridgeEndpoint.option', options);
195
+ // console.log('MatterbridgeEndpoint.endpointV8', endpointV8);
196
+ // console.log('MatterbridgeEndpoint.optionsV8', optionsV8);
197
+ // Create the logger
198
+ this.log = new AnsiLogger({ logName: options.uniqueStorageKey ?? 'MatterbridgeEndpoint', logTimestampFormat: 4 /* TimestampFormat.TIME_MILLIS */, logLevel: debug === true ? "debug" /* LogLevel.DEBUG */ : MatterbridgeEndpoint.logLevel });
146
199
  this.log.debug(`${YELLOW}new${db} MatterbridgeEndpoint: ${zb}${'0x' + firstDefinition.code.toString(16).padStart(4, '0')}${db}-${zb}${firstDefinition.name}${db} id: ${CYAN}${options.uniqueStorageKey}${db} number: ${CYAN}${options.endpointId}${db} taglist: ${CYAN}${options.tagList ? debugStringify(options.tagList) : 'undefined'}${db}`);
200
+ // Add MatterbridgeServer
147
201
  this.behaviors.require(MatterbridgeServer, { log: this.log, commandHandler: this.commandHandler });
148
202
  }
203
+ /**
204
+ * Loads an instance of the MatterbridgeEndpoint class.
205
+ *
206
+ * @param {DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>} definition - The DeviceTypeDefinition(s) of the device.
207
+ * @param {MatterbridgeEndpointOptions} [options={}] - The options for the device.
208
+ * @param {boolean} [debug=false] - Debug flag.
209
+ * @returns {Promise<MatterbridgeEndpoint>} MatterbridgeEndpoint instance.
210
+ */
149
211
  static async loadInstance(definition, options = {}, debug = false) {
150
212
  return new MatterbridgeEndpoint(definition, options, debug);
151
213
  }
214
+ /**
215
+ * Get all the device types of this endpoint.
216
+ *
217
+ * @returns {DeviceTypeDefinition[]} The device types of this endpoint.
218
+ */
152
219
  getDeviceTypes() {
153
220
  return Array.from(this.deviceTypes.values());
154
221
  }
222
+ /**
223
+ * Checks if the provided cluster server is supported by this endpoint.
224
+ *
225
+ * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to check.
226
+ * @returns {boolean} True if the cluster server is supported, false otherwise.
227
+ */
155
228
  hasClusterServer(cluster) {
156
229
  const behavior = getBehavior(this, cluster);
157
230
  if (behavior)
@@ -159,6 +232,13 @@ export class MatterbridgeEndpoint extends Endpoint {
159
232
  else
160
233
  return false;
161
234
  }
235
+ /**
236
+ * Checks if the provided attribute server is supported for a given cluster of this endpoint.
237
+ *
238
+ * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to check.
239
+ * @param {string} attribute - The attribute name to check.
240
+ * @returns {boolean} True if the attribute server is supported, false otherwise.
241
+ */
162
242
  hasAttributeServer(cluster, attribute) {
163
243
  const behavior = getBehavior(this, cluster);
164
244
  if (!behavior || !this.behaviors.supported[behavior.id])
@@ -167,82 +247,235 @@ export class MatterbridgeEndpoint extends Endpoint {
167
247
  const defaults = this.behaviors.defaultsFor(behavior);
168
248
  return lowercaseFirstLetter(attribute) in options || lowercaseFirstLetter(attribute) in defaults;
169
249
  }
250
+ /**
251
+ * Retrieves the initial options for the provided cluster server.
252
+ *
253
+ * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to get options for.
254
+ * @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.
255
+ */
170
256
  getClusterServerOptions(cluster) {
171
257
  const behavior = getBehavior(this, cluster);
172
258
  if (!behavior)
173
259
  return undefined;
174
260
  return this.behaviors.optionsFor(behavior);
175
261
  }
262
+ /**
263
+ * Retrieves the value of the provided attribute from the given cluster.
264
+ *
265
+ * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to retrieve the attribute from.
266
+ * @param {string} attribute - The name of the attribute to retrieve.
267
+ * @param {AnsiLogger} [log] - Optional logger for error and info messages.
268
+ * @returns {any} The value of the attribute, or undefined if the attribute is not found.
269
+ */
270
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
176
271
  getAttribute(cluster, attribute, log) {
177
272
  return getAttribute(this, cluster, attribute, log);
178
273
  }
274
+ /**
275
+ * Sets the value of an attribute on a cluster server.
276
+ *
277
+ * @param {Behavior.Type | ClusterType | ClusterId | string} clusterId - The ID of the cluster.
278
+ * @param {string} attribute - The name of the attribute.
279
+ * @param {boolean | number | bigint | string | object | null} value - The value to set for the attribute.
280
+ * @param {AnsiLogger} [log] - (Optional) The logger to use for logging errors and information.
281
+ * @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the attribute was successfully set.
282
+ */
179
283
  async setAttribute(clusterId, attribute, value, log) {
180
284
  return await setAttribute(this, clusterId, attribute, value, log);
181
285
  }
286
+ /**
287
+ * Update the value of an attribute on a cluster server only if the value is different.
288
+ *
289
+ * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to set the attribute on.
290
+ * @param {string} attribute - The name of the attribute.
291
+ * @param {boolean | number | bigint | string | object | null} value - The value to set for the attribute.
292
+ * @param {AnsiLogger} [log] - (Optional) The logger to use for logging the update. Errors are logged to the endpoint logger.
293
+ * @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the attribute was successfully set.
294
+ */
182
295
  async updateAttribute(cluster, attribute, value, log) {
183
296
  return await updateAttribute(this, cluster, attribute, value, log);
184
297
  }
298
+ /**
299
+ * Subscribes to the provided attribute on a cluster.
300
+ *
301
+ * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to subscribe the attribute to.
302
+ * @param {string} attribute - The name of the attribute to subscribe to.
303
+ * @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.
304
+ * @param {AnsiLogger} [log] - Optional logger for logging errors and information.
305
+ * @returns {Promise<boolean>} - A boolean indicating whether the subscription was successful.
306
+ *
307
+ * @remarks The listener function (cannot be async) will receive three parameters:
308
+ * - `newValue`: The new value of the attribute.
309
+ * - `oldValue`: The old value of the attribute.
310
+ * - `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.
311
+ */
312
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
185
313
  async subscribeAttribute(cluster, attribute, listener, log) {
186
314
  return await subscribeAttribute(this, cluster, attribute, listener, log);
187
315
  }
316
+ /**
317
+ * Triggers an event on the specified cluster.
318
+ * @param {ClusterId} cluster - The ID of the cluster.
319
+ * @param {string} event - The name of the event to trigger.
320
+ * @param {Record<string, boolean | number | bigint | string | object | undefined | null>} payload - The payload to pass to the event.
321
+ * @param {AnsiLogger} [log] - Optional logger for logging information.
322
+ * @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the event was successfully triggered.
323
+ */
188
324
  async triggerEvent(cluster, event, payload, log) {
189
325
  return await triggerEvent(this, cluster, event, payload, log);
190
326
  }
327
+ /**
328
+ * Adds cluster servers from the provided server list.
329
+ *
330
+ * @param {ClusterId[]} serverList - The list of cluster IDs to add.
331
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
332
+ */
191
333
  addClusterServers(serverList) {
192
334
  addClusterServers(this, serverList);
193
335
  return this;
194
336
  }
337
+ /**
338
+ * Adds a fixed label to the FixedLabel cluster. If the cluster server is not present, it will be added.
339
+ *
340
+ * @param {string} label - The label to add.
341
+ * @param {string} value - The value of the label.
342
+ * @returns {Promise<this>} The current MatterbridgeEndpoint instance for chaining.
343
+ */
195
344
  async addFixedLabel(label, value) {
196
345
  await addFixedLabel(this, label, value);
197
346
  return this;
198
347
  }
348
+ /**
349
+ * Adds a user label to the UserLabel cluster. If the cluster server is not present, it will be added.
350
+ *
351
+ * @param {string} label - The label to add.
352
+ * @param {string} value - The value of the label.
353
+ * @returns {Promise<this>} The current MatterbridgeEndpoint instance for chaining.
354
+ */
199
355
  async addUserLabel(label, value) {
200
356
  await addUserLabel(this, label, value);
201
357
  return this;
202
358
  }
359
+ /**
360
+ * Adds a command handler for the specified command.
361
+ *
362
+ * @param {keyof MatterbridgeEndpointCommands} command - The command to add the handler for.
363
+ * @param {CommandHandlerFunction} handler - The handler function to execute when the command is received.
364
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
365
+ *
366
+ * @remarks
367
+ * The handler function will receive an object with the following properties:
368
+ * - `request`: The request object sent with the command.
369
+ * - `cluster`: The id of the cluster that received the command (i.e. "onOff").
370
+ * - `attributes`: The current attributes of the cluster that received the command (i.e. { onOff: true}).
371
+ * - `endpoint`: The MatterbridgeEndpoint instance that received the command.
372
+ */
203
373
  addCommandHandler(command, handler) {
204
374
  this.commandHandler.addHandler(command, handler);
205
375
  return this;
206
376
  }
377
+ /**
378
+ * Execute the command handler for the specified command. Used ONLY in Jest tests.
379
+ *
380
+ * @param {keyof MatterbridgeEndpointCommands} command - The command to execute.
381
+ * @param {Record<string, boolean | number | bigint | string | object | null>} [request] - The optional request to pass to the handler function.
382
+ *
383
+ * @deprecated Used ONLY in Jest tests.
384
+ */
207
385
  async executeCommandHandler(command, request) {
208
386
  await this.commandHandler.executeHandler(command, { request });
209
387
  }
388
+ /**
389
+ * Invokes a behavior command on the specified cluster. Used ONLY in Jest tests.
390
+ *
391
+ * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to invoke the command on.
392
+ * @param {string} command - The command to invoke.
393
+ * @param {Record<string, boolean | number | bigint | string | object | null>} [params] - The optional parameters to pass to the command.
394
+ *
395
+ * @deprecated Used ONLY in Jest tests.
396
+ */
210
397
  async invokeBehaviorCommand(cluster, command, params) {
211
398
  await invokeBehaviorCommand(this, cluster, command, params);
212
399
  }
400
+ /**
401
+ * Adds the required cluster servers (only if they are not present) for the device types of the specified endpoint.
402
+ *
403
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
404
+ */
213
405
  addRequiredClusterServers() {
214
406
  addRequiredClusterServers(this);
215
407
  return this;
216
408
  }
409
+ /**
410
+ * Adds the optional cluster servers (only if they are not present) for the device types of the specified endpoint.
411
+ *
412
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
413
+ */
217
414
  addOptionalClusterServers() {
218
415
  addOptionalClusterServers(this);
219
416
  return this;
220
417
  }
418
+ /**
419
+ * Retrieves all cluster servers.
420
+ *
421
+ * @returns {Behavior.Type[]} An array of all cluster servers.
422
+ */
221
423
  getAllClusterServers() {
222
424
  return Object.values(this.behaviors.supported);
223
425
  }
426
+ /**
427
+ * Retrieves the names of all cluster servers.
428
+ *
429
+ * @returns {string[]} An array of all cluster server names.
430
+ */
224
431
  getAllClusterServerNames() {
225
432
  return Object.keys(this.behaviors.supported);
226
433
  }
434
+ /**
435
+ * Iterates over each attribute of each cluster server of the device state and calls the provided callback function.
436
+ *
437
+ * @param {Function} callback - The callback function to call with the cluster name, cluster id, attribute name, attribute id and attribute value.
438
+ */
227
439
  forEachAttribute(callback) {
228
440
  if (!this.lifecycle.isReady || this.construction.status !== Lifecycle.Status.Active)
229
441
  return;
230
442
  for (const [clusterName, clusterAttributes] of Object.entries(this.state)) {
443
+ // Skip if the key / cluster name is a number, cause they are double indexed.
231
444
  if (!isNaN(Number(clusterName)))
232
445
  continue;
233
446
  for (const [attributeName, attributeValue] of Object.entries(clusterAttributes)) {
447
+ // Skip if the behavior has no associated cluster (i.e. matterbridge server)
234
448
  const clusterId = getClusterId(this, clusterName);
235
449
  if (clusterId === undefined) {
450
+ // this.log.debug(`***forEachAttribute: cluster ${clusterName} not found`);
236
451
  continue;
237
452
  }
453
+ // Skip if the attribute is not present in the ClusterBehavior.Type. Also skip if the attribute it is an internal state.
238
454
  const attributeId = getAttributeId(this, clusterName, attributeName);
239
455
  if (attributeId === undefined) {
456
+ // this.log.debug(`***forEachAttribute: attribute ${clusterName}.${attributeName} not found`);
240
457
  continue;
241
458
  }
242
459
  callback(clusterName, clusterId, attributeName, attributeId, attributeValue);
243
460
  }
244
461
  }
245
462
  }
463
+ /**
464
+ * Adds a child endpoint with the specified device types and options.
465
+ * If the child endpoint is not already present, it will be created and added.
466
+ * If the child endpoint is already present, the existing child endpoint will be returned.
467
+ *
468
+ * @param {string} endpointName - The name of the new endpoint to add.
469
+ * @param {DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>} definition - The device types to add.
470
+ * @param {MatterbridgeEndpointOptions} [options={}] - The options for the endpoint.
471
+ * @param {boolean} [debug=false] - Whether to enable debug logging.
472
+ * @returns {MatterbridgeEndpoint} - The child endpoint that was found or added.
473
+ *
474
+ * @example
475
+ * ```typescript
476
+ * const endpoint = device.addChildDeviceType('Temperature', [temperatureSensor], { tagList: [{ mfgCode: null, namespaceId: LocationTag.Indoor.namespaceId, tag: LocationTag.Indoor.tag, label: null }] }, true);
477
+ * ```
478
+ */
246
479
  addChildDeviceType(endpointName, definition, options = {}, debug = false) {
247
480
  this.log.debug(`addChildDeviceType: ${CYAN}${endpointName}${db}`);
248
481
  let alreadyAdded = false;
@@ -282,6 +515,23 @@ export class MatterbridgeEndpoint extends Endpoint {
282
515
  }
283
516
  return child;
284
517
  }
518
+ /**
519
+ * Adds a child endpoint with one or more device types with the required cluster servers and the specified cluster servers.
520
+ * If the child endpoint is not already present in the childEndpoints, it will be added.
521
+ * If the child endpoint is already present in the childEndpoints, the device types and cluster servers will be added to the existing child endpoint.
522
+ *
523
+ * @param {string} endpointName - The name of the new enpoint to add.
524
+ * @param {DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>} definition - The device types to add.
525
+ * @param {ClusterId[]} [serverList=[]] - The list of cluster IDs to include.
526
+ * @param {MatterbridgeEndpointOptions} [options={}] - The options for the device.
527
+ * @param {boolean} [debug=false] - Whether to enable debug logging.
528
+ * @returns {MatterbridgeEndpoint} - The child endpoint that was found or added.
529
+ *
530
+ * @example
531
+ * ```typescript
532
+ * const endpoint = device.addChildDeviceTypeWithClusterServer('Temperature', [temperatureSensor], [], { tagList: [{ mfgCode: null, namespaceId: LocationTag.Indoor.namespaceId, tag: LocationTag.Indoor.tag, label: null }] }, true);
533
+ * ```
534
+ */
285
535
  addChildDeviceTypeWithClusterServer(endpointName, definition, serverList = [], options = {}, debug = false) {
286
536
  this.log.debug(`addChildDeviceTypeWithClusterServer: ${CYAN}${endpointName}${db}`);
287
537
  let alreadyAdded = false;
@@ -344,15 +594,38 @@ export class MatterbridgeEndpoint extends Endpoint {
344
594
  }
345
595
  return child;
346
596
  }
597
+ /**
598
+ * Retrieves a child endpoint by its name.
599
+ *
600
+ * @param {string} endpointName - The name of the endpoint to retrieve.
601
+ * @returns {Endpoint | undefined} The child endpoint with the specified name, or undefined if not found.
602
+ */
347
603
  getChildEndpointByName(endpointName) {
348
604
  return this.parts.find((part) => part.id === endpointName);
349
605
  }
606
+ /**
607
+ * Retrieves a child endpoint by its EndpointNumber.
608
+ *
609
+ * @param {EndpointNumber} endpointNumber - The EndpointNumber of the endpoint to retrieve.
610
+ * @returns {MatterbridgeEndpoint | undefined} The child endpoint with the specified EndpointNumber, or undefined if not found.
611
+ */
350
612
  getChildEndpoint(endpointNumber) {
351
613
  return this.parts.find((part) => part.number === endpointNumber);
352
614
  }
615
+ /**
616
+ * Get all the child endpoints of this endpoint.
617
+ *
618
+ * @returns {MatterbridgeEndpoint[]} The child endpoints.
619
+ */
353
620
  getChildEndpoints() {
354
621
  return Array.from(this.parts);
355
622
  }
623
+ /**
624
+ * Serializes the Matterbridge device into a serialized object.
625
+ *
626
+ * @param pluginName - The name of the plugin.
627
+ * @returns The serialized Matterbridge device object.
628
+ */
356
629
  static serialize(device) {
357
630
  if (!device.serialNumber || !device.deviceName || !device.uniqueId)
358
631
  return;
@@ -375,9 +648,15 @@ export class MatterbridgeEndpoint extends Endpoint {
375
648
  serialized.clusterServersId.push(BridgedDeviceBasicInformation.Cluster.id);
376
649
  if (behaviorName === 'powerSource')
377
650
  serialized.clusterServersId.push(PowerSource.Cluster.id);
651
+ // serialized.clusterServersId.push(this.behaviors.supported[behaviorName]cluster.id);
378
652
  });
379
653
  return serialized;
380
654
  }
655
+ /**
656
+ * Deserializes the device into a serialized object.
657
+ *
658
+ * @returns The deserialized MatterbridgeDevice.
659
+ */
381
660
  static deserialize(serializedDevice) {
382
661
  const device = new MatterbridgeEndpoint(serializedDevice.deviceTypes, { uniqueStorageKey: serializedDevice.endpointName, endpointId: serializedDevice.endpoint }, false);
383
662
  device.plugin = serializedDevice.pluginName;
@@ -393,9 +672,16 @@ export class MatterbridgeEndpoint extends Endpoint {
393
672
  device.createDefaultBridgedDeviceBasicInformationClusterServer(serializedDevice.deviceName, serializedDevice.serialNumber, serializedDevice.vendorId ?? 0xfff1, serializedDevice.vendorName ?? 'Matterbridge', serializedDevice.productName ?? 'Matterbridge device');
394
673
  else if (clusterId === PowerSource.Cluster.id)
395
674
  device.createDefaultPowerSourceWiredClusterServer();
675
+ // else addClusterServerFromList(device, [clusterId]);
396
676
  }
397
677
  return device;
398
678
  }
679
+ /**
680
+ * Creates a default power source wired cluster server.
681
+ *
682
+ * @param wiredCurrentType - The type of wired current (default: PowerSource.WiredCurrentType.Ac)
683
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
684
+ */
399
685
  createDefaultPowerSourceWiredClusterServer(wiredCurrentType = PowerSource.WiredCurrentType.Ac) {
400
686
  this.behaviors.require(PowerSourceServer.with(PowerSource.Feature.Wired), {
401
687
  wiredCurrentType,
@@ -406,6 +692,16 @@ export class MatterbridgeEndpoint extends Endpoint {
406
692
  });
407
693
  return this;
408
694
  }
695
+ /**
696
+ * Creates a default power source replaceable battery cluster server.
697
+ *
698
+ * @param batPercentRemaining - The remaining battery percentage (default: 100).
699
+ * @param batChargeLevel - The battery charge level (default: PowerSource.BatChargeLevel.Ok).
700
+ * @param batVoltage - The battery voltage (default: 1500).
701
+ * @param batReplacementDescription - The battery replacement description (default: 'Battery type').
702
+ * @param batQuantity - The battery quantity (default: 1).
703
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
704
+ */
409
705
  createDefaultPowerSourceReplaceableBatteryClusterServer(batPercentRemaining = 100, batChargeLevel = PowerSource.BatChargeLevel.Ok, batVoltage = 1500, batReplacementDescription = 'Battery type', batQuantity = 1) {
410
706
  this.behaviors.require(PowerSourceServer.with(PowerSource.Feature.Battery, PowerSource.Feature.Replaceable), {
411
707
  status: PowerSource.PowerSourceStatus.Active,
@@ -423,6 +719,14 @@ export class MatterbridgeEndpoint extends Endpoint {
423
719
  });
424
720
  return this;
425
721
  }
722
+ /**
723
+ * Creates a default power source rechargeable battery cluster server.
724
+ *
725
+ * @param batPercentRemaining - The remaining battery percentage (default: 100).
726
+ * @param batChargeLevel - The battery charge level (default: PowerSource.BatChargeLevel.Ok).
727
+ * @param batVoltage - The battery voltage (default: 1500).
728
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
729
+ */
426
730
  createDefaultPowerSourceRechargeableBatteryClusterServer(batPercentRemaining = 100, batChargeLevel = PowerSource.BatChargeLevel.Ok, batVoltage = 1500) {
427
731
  this.behaviors.require(PowerSourceServer.with(PowerSource.Feature.Battery, PowerSource.Feature.Rechargeable), {
428
732
  status: PowerSource.PowerSourceStatus.Active,
@@ -441,6 +745,21 @@ export class MatterbridgeEndpoint extends Endpoint {
441
745
  });
442
746
  return this;
443
747
  }
748
+ /**
749
+ * Setup the default Basic Information Cluster Server attributes for the server node.
750
+ *
751
+ * @param deviceName - The name of the device.
752
+ * @param serialNumber - The serial number of the device.
753
+ * @param vendorId - The vendor ID of the device.
754
+ * @param vendorName - The vendor name of the device.
755
+ * @param productId - The product ID of the device.
756
+ * @param productName - The product name of the device.
757
+ * @param softwareVersion - The software version of the device. Default is 1.
758
+ * @param softwareVersionString - The software version string of the device. Default is 'v.1.0.0'.
759
+ * @param hardwareVersion - The hardware version of the device. Default is 1.
760
+ * @param hardwareVersionString - The hardware version string of the device. Default is 'v.1.0.0'.
761
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
762
+ */
444
763
  createDefaultBasicInformationClusterServer(deviceName, serialNumber, vendorId, vendorName, productId, productName, softwareVersion = 1, softwareVersionString = '1.0.0', hardwareVersion = 1, hardwareVersionString = '1.0.0') {
445
764
  this.log.logName = deviceName;
446
765
  this.deviceName = deviceName;
@@ -464,6 +783,22 @@ export class MatterbridgeEndpoint extends Endpoint {
464
783
  }
465
784
  return this;
466
785
  }
786
+ /**
787
+ * Creates a default BridgedDeviceBasicInformationClusterServer for the aggregator endpoints.
788
+ *
789
+ * @param deviceName - The name of the device.
790
+ * @param serialNumber - The serial number of the device.
791
+ * @param vendorId - The vendor ID of the device.
792
+ * @param vendorName - The name of the vendor.
793
+ * @param productName - The name of the product.
794
+ * @param softwareVersion - The software version of the device. Default is 1.
795
+ * @param softwareVersionString - The software version string of the device. Default is 'v.1.0.0'.
796
+ * @param hardwareVersion - The hardware version of the device. Default is 1.
797
+ * @param hardwareVersionString - The hardware version string of the device. Default is 'v.1.0.0'.
798
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
799
+ *
800
+ * @remarks The bridgedNode device type must be added to the deviceTypeList of the Descriptor cluster.
801
+ */
467
802
  createDefaultBridgedDeviceBasicInformationClusterServer(deviceName, serialNumber, vendorId, vendorName, productName, softwareVersion = 1, softwareVersionString = '1.0.0', hardwareVersion = 1, hardwareVersionString = '1.0.0') {
468
803
  this.log.logName = deviceName;
469
804
  this.deviceName = deviceName;
@@ -496,6 +831,13 @@ export class MatterbridgeEndpoint extends Endpoint {
496
831
  });
497
832
  return this;
498
833
  }
834
+ /**
835
+ * Creates a default identify cluster server with the specified identify time and type.
836
+ *
837
+ * @param {number} [identifyTime=0] - The time to identify the server. Defaults to 0.
838
+ * @param {Identify.IdentifyType} [identifyType=Identify.IdentifyType.None] - The type of identification. Defaults to Identify.IdentifyType.None.
839
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
840
+ */
499
841
  createDefaultIdentifyClusterServer(identifyTime = 0, identifyType = Identify.IdentifyType.None) {
500
842
  this.behaviors.require(MatterbridgeIdentifyServer, {
501
843
  identifyTime,
@@ -503,14 +845,34 @@ export class MatterbridgeEndpoint extends Endpoint {
503
845
  });
504
846
  return this;
505
847
  }
848
+ /**
849
+ * Creates a default groups cluster server.
850
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
851
+ */
506
852
  createDefaultGroupsClusterServer() {
507
853
  this.behaviors.require(GroupsServer);
508
854
  return this;
509
855
  }
856
+ /**
857
+ * Creates a default scenes management cluster server.
858
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
859
+ *
860
+ * @remarks The scenes management cluster server is still provisional and so not yet implemented.
861
+ */
510
862
  createDefaultScenesClusterServer() {
511
863
  this.behaviors.require(ScenesManagementServer);
512
864
  return this;
513
865
  }
866
+ /**
867
+ * Creates a default OnOff cluster server for light devices with feature Lighting.
868
+ *
869
+ * @param {boolean} [onOff=false] - The initial state of the OnOff cluster.
870
+ * @param {boolean} [globalSceneControl=false] - The global scene control state.
871
+ * @param {number} [onTime=0] - The on time value.
872
+ * @param {number} [offWaitTime=0] - The off wait time value.
873
+ * @param {OnOff.StartUpOnOff | null} [startUpOnOff=null] - The start-up OnOff state. Null means previous state.
874
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
875
+ */
514
876
  createDefaultOnOffClusterServer(onOff = false, globalSceneControl = false, onTime = 0, offWaitTime = 0, startUpOnOff = null) {
515
877
  this.behaviors.require(MatterbridgeOnOffServer.with(OnOff.Feature.Lighting), {
516
878
  onOff,
@@ -521,24 +883,52 @@ export class MatterbridgeEndpoint extends Endpoint {
521
883
  });
522
884
  return this;
523
885
  }
886
+ /**
887
+ * Creates an OnOff cluster server without features.
888
+ *
889
+ * @param {boolean} [onOff=false] - The initial state of the OnOff cluster.
890
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
891
+ */
524
892
  createOnOffClusterServer(onOff = false) {
525
893
  this.behaviors.require(MatterbridgeOnOffServer, {
526
894
  onOff,
527
895
  });
528
896
  return this;
529
897
  }
898
+ /**
899
+ * Creates a DeadFront OnOff cluster server with feature DeadFrontBehavior.
900
+ *
901
+ * @param {boolean} [onOff=false] - The initial state of the OnOff cluster.
902
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
903
+ */
530
904
  createDeadFrontOnOffClusterServer(onOff = false) {
531
905
  this.behaviors.require(MatterbridgeOnOffServer.with(OnOff.Feature.DeadFrontBehavior), {
532
906
  onOff,
533
907
  });
534
908
  return this;
535
909
  }
910
+ /**
911
+ * Creates an OffOnly OnOff cluster server with feature OffOnly.
912
+ *
913
+ * @param {boolean} [onOff=false] - The initial state of the OnOff cluster.
914
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
915
+ */
536
916
  createOffOnlyOnOffClusterServer(onOff = false) {
537
917
  this.behaviors.require(MatterbridgeOnOffServer.with(OnOff.Feature.OffOnly), {
538
918
  onOff,
539
919
  });
540
920
  return this;
541
921
  }
922
+ /**
923
+ * Creates a default level control cluster server for light devices with feature OnOff and Lighting.
924
+ *
925
+ * @param {number} [currentLevel=254] - The current level (default: 254).
926
+ * @param {number} [minLevel=1] - The minimum level (default: 1).
927
+ * @param {number} [maxLevel=254] - The maximum level (default: 254).
928
+ * @param {number | null} [onLevel=null] - The on level (default: null).
929
+ * @param {number | null} [startUpCurrentLevel=null] - The startUp on level (default: null).
930
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
931
+ */
542
932
  createDefaultLevelControlClusterServer(currentLevel = 254, minLevel = 1, maxLevel = 254, onLevel = null, startUpCurrentLevel = null) {
543
933
  this.behaviors.require(MatterbridgeLevelControlServer.with(LevelControl.Feature.OnOff, LevelControl.Feature.Lighting), {
544
934
  currentLevel,
@@ -554,6 +944,13 @@ export class MatterbridgeEndpoint extends Endpoint {
554
944
  });
555
945
  return this;
556
946
  }
947
+ /**
948
+ * Creates a level control cluster server without features.
949
+ *
950
+ * @param {number} [currentLevel=254] - The current level (default: 254).
951
+ * @param {number | null} [onLevel=null] - The on level (default: null).
952
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
953
+ */
557
954
  createLevelControlClusterServer(currentLevel = 254, onLevel = null) {
558
955
  this.behaviors.require(MatterbridgeLevelControlServer, {
559
956
  currentLevel,
@@ -565,6 +962,25 @@ export class MatterbridgeEndpoint extends Endpoint {
565
962
  });
566
963
  return this;
567
964
  }
965
+ /**
966
+ * Creates a default color control cluster server with features Xy, HueSaturation and ColorTemperature.
967
+ *
968
+ * @param currentX - The current X value (range 0-65279).
969
+ * @param currentY - The current Y value (range 0-65279).
970
+ * @param currentHue - The current hue value (range: 0-254).
971
+ * @param currentSaturation - The current saturation value (range: 0-254).
972
+ * @param colorTemperatureMireds - The color temperature in mireds (default range 147-500).
973
+ * @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds (default range 147).
974
+ * @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds (default range 500).
975
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
976
+ *
977
+ * @remarks colorMode and enhancedColorMode persist across restarts.
978
+ * @remarks currentHue and currentSaturation persist across restarts.
979
+ * @remarks currentX and currentY persist across restarts.
980
+ * @remarks colorTemperatureMireds persists across restarts.
981
+ * @remarks startUpColorTemperatureMireds persists across restarts.
982
+ * @remarks coupleColorTempToLevelMinMireds persists across restarts.
983
+ */
568
984
  createDefaultColorControlClusterServer(currentX = 0, currentY = 0, currentHue = 0, currentSaturation = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
569
985
  this.behaviors.require(MatterbridgeColorControlServer.with(ColorControl.Feature.Xy, ColorControl.Feature.HueSaturation, ColorControl.Feature.ColorTemperature), {
570
986
  colorMode: ColorControl.ColorMode.CurrentHueAndCurrentSaturation,
@@ -587,6 +1003,25 @@ export class MatterbridgeEndpoint extends Endpoint {
587
1003
  });
588
1004
  return this;
589
1005
  }
1006
+ /**
1007
+ * Creates a Xy color control cluster server with feature Xy and ColorTemperature.
1008
+ *
1009
+ * @param currentX - The current X value.
1010
+ * @param currentY - The current Y value.
1011
+ * @param colorTemperatureMireds - The color temperature in mireds.
1012
+ * @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds.
1013
+ * @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds.
1014
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1015
+ *
1016
+ * @remarks
1017
+ * From zigbee to matter = Math.max(Math.min(Math.round(x * 65536), 65279), 0)
1018
+ *
1019
+ * @remarks colorMode and enhancedColorMode persist across restarts.
1020
+ * @remarks currentX and currentY persist across restarts.
1021
+ * @remarks colorTemperatureMireds persists across restarts.
1022
+ * @remarks startUpColorTemperatureMireds persists across restarts.
1023
+ * @remarks coupleColorTempToLevelMinMireds persists across restarts.
1024
+ */
590
1025
  createXyColorControlClusterServer(currentX = 0, currentY = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
591
1026
  this.behaviors.require(MatterbridgeColorControlServer.with(ColorControl.Feature.Xy, ColorControl.Feature.ColorTemperature), {
592
1027
  colorMode: ColorControl.ColorMode.CurrentXAndCurrentY,
@@ -607,6 +1042,22 @@ export class MatterbridgeEndpoint extends Endpoint {
607
1042
  });
608
1043
  return this;
609
1044
  }
1045
+ /**
1046
+ * Creates a default hue and saturation control cluster server with feature HueSaturation and ColorTemperature.
1047
+ *
1048
+ * @param currentHue - The current hue value.
1049
+ * @param currentSaturation - The current saturation value.
1050
+ * @param colorTemperatureMireds - The color temperature in mireds.
1051
+ * @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds.
1052
+ * @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds.
1053
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1054
+ *
1055
+ * @remarks colorMode and enhancedColorMode persist across restarts.
1056
+ * @remarks currentHue and currentSaturation persist across restarts.
1057
+ * @remarks colorTemperatureMireds persists across restarts.
1058
+ * @remarks startUpColorTemperatureMireds persists across restarts.
1059
+ * @remarks coupleColorTempToLevelMinMireds persists across restarts.
1060
+ */
610
1061
  createHsColorControlClusterServer(currentHue = 0, currentSaturation = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
611
1062
  this.behaviors.require(MatterbridgeColorControlServer.with(ColorControl.Feature.HueSaturation, ColorControl.Feature.ColorTemperature), {
612
1063
  colorMode: ColorControl.ColorMode.CurrentHueAndCurrentSaturation,
@@ -627,6 +1078,20 @@ export class MatterbridgeEndpoint extends Endpoint {
627
1078
  });
628
1079
  return this;
629
1080
  }
1081
+ /**
1082
+ * Creates a color temperature color control cluster server with feature ColorTemperature.
1083
+ * This cluster server is used for devices that only support color temperature control.
1084
+ *
1085
+ * @param colorTemperatureMireds - The color temperature in mireds. Defaults to 250.
1086
+ * @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds. Defaults to 147.
1087
+ * @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds. Defaults to 500.
1088
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1089
+ *
1090
+ * @remarks colorMode and enhancedColorMode persist across restarts.
1091
+ * @remarks colorTemperatureMireds persists across restarts.
1092
+ * @remarks startUpColorTemperatureMireds persists across restarts.
1093
+ * @remarks coupleColorTempToLevelMinMireds persists across restarts.
1094
+ */
630
1095
  createCtColorControlClusterServer(colorTemperatureMireds = 250, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
631
1096
  this.behaviors.require(MatterbridgeColorControlServer.with(ColorControl.Feature.ColorTemperature), {
632
1097
  colorMode: ColorControl.ColorMode.ColorTemperatureMireds,
@@ -645,15 +1110,34 @@ export class MatterbridgeEndpoint extends Endpoint {
645
1110
  });
646
1111
  return this;
647
1112
  }
1113
+ /**
1114
+ * Configures the color control mode for the device.
1115
+ *
1116
+ * @param {ColorControl.ColorMode} colorMode - The color mode to set.
1117
+ *
1118
+ * @remarks colorMode and enhancedColorMode persist across restarts.
1119
+ */
648
1120
  async configureColorControlMode(colorMode) {
649
1121
  if (isValidNumber(colorMode, ColorControl.ColorMode.CurrentHueAndCurrentSaturation, ColorControl.ColorMode.ColorTemperatureMireds)) {
650
1122
  await this.setAttribute(ColorControl.Cluster.id, 'colorMode', colorMode, this.log);
651
1123
  await this.setAttribute(ColorControl.Cluster.id, 'enhancedColorMode', colorMode, this.log);
652
1124
  }
653
1125
  }
1126
+ /**
1127
+ * Creates a default window covering cluster server with feature Lift and PositionAwareLift.
1128
+ *
1129
+ * @param {number} positionPercent100ths - The position percentage in 100ths (0-10000). Defaults to 0. Matter uses 10000 = fully closed 0 = fully opened.
1130
+ * @param {WindowCovering.WindowCoveringType} type - The type of window covering (default: WindowCovering.WindowCoveringType.Rollershade). Must support feature Lift.
1131
+ * @param {WindowCovering.EndProductType} endProductType - The end product type (default: WindowCovering.EndProductType.RollerShade). Must support feature Lift.
1132
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1133
+ *
1134
+ * @remarks mode attributes is writable and persists across restarts.
1135
+ * currentPositionLiftPercent100ths persists across restarts.
1136
+ * configStatus attributes persists across restarts.
1137
+ */
654
1138
  createDefaultWindowCoveringClusterServer(positionPercent100ths, type = WindowCovering.WindowCoveringType.Rollershade, endProductType = WindowCovering.EndProductType.RollerShade) {
655
1139
  this.behaviors.require(MatterbridgeLiftWindowCoveringServer.with(WindowCovering.Feature.Lift, WindowCovering.Feature.PositionAwareLift), {
656
- type,
1140
+ type, // Must support feature Lift
657
1141
  numberOfActuationsLift: 0,
658
1142
  configStatus: {
659
1143
  operational: true,
@@ -661,20 +1145,33 @@ export class MatterbridgeEndpoint extends Endpoint {
661
1145
  liftMovementReversed: false,
662
1146
  liftPositionAware: true,
663
1147
  tiltPositionAware: false,
664
- liftEncoderControlled: false,
665
- tiltEncoderControlled: false,
1148
+ liftEncoderControlled: false, // 0 = Timer Controlled 1 = Encoder Controlled
1149
+ tiltEncoderControlled: false, // 0 = Timer Controlled 1 = Encoder Controlled
666
1150
  },
667
1151
  operationalStatus: { global: WindowCovering.MovementStatus.Stopped, lift: WindowCovering.MovementStatus.Stopped, tilt: WindowCovering.MovementStatus.Stopped },
668
- endProductType,
1152
+ endProductType, // Must support feature Lift
669
1153
  mode: { motorDirectionReversed: false, calibrationMode: false, maintenanceMode: false, ledFeedback: false },
670
- targetPositionLiftPercent100ths: positionPercent100ths ?? 0,
671
- currentPositionLiftPercent100ths: positionPercent100ths ?? 0,
1154
+ targetPositionLiftPercent100ths: positionPercent100ths ?? 0, // 0 Fully open 10000 fully closed
1155
+ currentPositionLiftPercent100ths: positionPercent100ths ?? 0, // 0 Fully open 10000 fully closed
672
1156
  });
673
1157
  return this;
674
1158
  }
1159
+ /**
1160
+ * Creates a default window covering cluster server with features Lift, PositionAwareLift, Tilt, PositionAwareTilt.
1161
+ *
1162
+ * @param {number} positionLiftPercent100ths - The lift position percentage in 100ths (0-10000). Defaults to 0. Matter uses 10000 = fully closed 0 = fully opened.
1163
+ * @param {number} positionTiltPercent100ths - The tilt position percentage in 100ths (0-10000). Defaults to 0. Matter uses 10000 = fully closed 0 = fully opened.
1164
+ * @param {WindowCovering.WindowCoveringType} type - The type of window covering (default: WindowCovering.WindowCoveringType.TiltBlindLift). Must support features Lift and Tilt.
1165
+ * @param {WindowCovering.EndProductType} endProductType - The end product type (default: WindowCovering.EndProductType.InteriorBlind). Must support features Lift and Tilt.
1166
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1167
+ *
1168
+ * @remarks mode attributes is writable and persists across restarts.
1169
+ * currentPositionTiltPercent100ths persists across restarts.
1170
+ * configStatus attributes persists across restarts.
1171
+ */
675
1172
  createDefaultLiftTiltWindowCoveringClusterServer(positionLiftPercent100ths, positionTiltPercent100ths, type = WindowCovering.WindowCoveringType.TiltBlindLift, endProductType = WindowCovering.EndProductType.InteriorBlind) {
676
1173
  this.behaviors.require(MatterbridgeLiftTiltWindowCoveringServer.with(WindowCovering.Feature.Lift, WindowCovering.Feature.PositionAwareLift, WindowCovering.Feature.Tilt, WindowCovering.Feature.PositionAwareTilt), {
677
- type,
1174
+ type, // Must support features Lift and Tilt
678
1175
  numberOfActuationsLift: 0,
679
1176
  numberOfActuationsTilt: 0,
680
1177
  configStatus: {
@@ -683,19 +1180,23 @@ export class MatterbridgeEndpoint extends Endpoint {
683
1180
  liftMovementReversed: false,
684
1181
  liftPositionAware: true,
685
1182
  tiltPositionAware: true,
686
- liftEncoderControlled: false,
687
- tiltEncoderControlled: false,
1183
+ liftEncoderControlled: false, // 0 = Timer Controlled 1 = Encoder Controlled
1184
+ tiltEncoderControlled: false, // 0 = Timer Controlled 1 = Encoder Controlled
688
1185
  },
689
1186
  operationalStatus: { global: WindowCovering.MovementStatus.Stopped, lift: WindowCovering.MovementStatus.Stopped, tilt: WindowCovering.MovementStatus.Stopped },
690
- endProductType,
1187
+ endProductType, // Must support features Lift and Tilt
691
1188
  mode: { motorDirectionReversed: false, calibrationMode: false, maintenanceMode: false, ledFeedback: false },
692
- targetPositionLiftPercent100ths: positionLiftPercent100ths ?? 0,
693
- currentPositionLiftPercent100ths: positionLiftPercent100ths ?? 0,
694
- targetPositionTiltPercent100ths: positionTiltPercent100ths ?? 0,
695
- currentPositionTiltPercent100ths: positionTiltPercent100ths ?? 0,
1189
+ targetPositionLiftPercent100ths: positionLiftPercent100ths ?? 0, // 0 Fully open 10000 fully closed
1190
+ currentPositionLiftPercent100ths: positionLiftPercent100ths ?? 0, // 0 Fully open 10000 fully closed
1191
+ targetPositionTiltPercent100ths: positionTiltPercent100ths ?? 0, // 0 Fully open 10000 fully closed
1192
+ currentPositionTiltPercent100ths: positionTiltPercent100ths ?? 0, // 0 Fully open 10000 fully closed
696
1193
  });
697
1194
  return this;
698
1195
  }
1196
+ /**
1197
+ * Sets the window covering lift target position as the current position and stops the movement.
1198
+ *
1199
+ */
699
1200
  async setWindowCoveringTargetAsCurrentAndStopped() {
700
1201
  const position = this.getAttribute(WindowCovering.Cluster.id, 'currentPositionLiftPercent100ths', this.log);
701
1202
  if (isValidNumber(position, 0, 10000)) {
@@ -715,6 +1216,12 @@ export class MatterbridgeEndpoint extends Endpoint {
715
1216
  this.log.debug(`Set WindowCovering currentPositionTiltPercent100ths and targetPositionTiltPercent100ths to ${position} and operationalStatus to Stopped.`);
716
1217
  }
717
1218
  }
1219
+ /**
1220
+ * Sets the lift current and target position and the status of a window covering.
1221
+ * @param {number} current - The current position of the window covering.
1222
+ * @param {number} target - The target position of the window covering.
1223
+ * @param {WindowCovering.MovementStatus} status - The movement status of the window covering.
1224
+ */
718
1225
  async setWindowCoveringCurrentTargetStatus(current, target, status) {
719
1226
  await this.setAttribute(WindowCovering.Cluster.id, 'currentPositionLiftPercent100ths', current, this.log);
720
1227
  await this.setAttribute(WindowCovering.Cluster.id, 'targetPositionLiftPercent100ths', target, this.log);
@@ -725,6 +1232,10 @@ export class MatterbridgeEndpoint extends Endpoint {
725
1232
  }, this.log);
726
1233
  this.log.debug(`Set WindowCovering currentPositionLiftPercent100ths: ${current}, targetPositionLiftPercent100ths: ${target} and operationalStatus: ${status}.`);
727
1234
  }
1235
+ /**
1236
+ * Sets the status of the window covering.
1237
+ * @param {WindowCovering.MovementStatus} status - The movement status to set.
1238
+ */
728
1239
  async setWindowCoveringStatus(status) {
729
1240
  await this.setAttribute(WindowCovering.Cluster.id, 'operationalStatus', {
730
1241
  global: status,
@@ -733,6 +1244,11 @@ export class MatterbridgeEndpoint extends Endpoint {
733
1244
  }, this.log);
734
1245
  this.log.debug(`Set WindowCovering operationalStatus: ${status}`);
735
1246
  }
1247
+ /**
1248
+ * Retrieves the status of the window covering.
1249
+ *
1250
+ * @returns The global operational status of the window covering or undefined.
1251
+ */
736
1252
  getWindowCoveringStatus() {
737
1253
  const status = this.getAttribute(WindowCovering.Cluster.id, 'operationalStatus', this.log);
738
1254
  if (isValidObject(status, 3) && 'global' in status && typeof status.global === 'number') {
@@ -740,6 +1256,12 @@ export class MatterbridgeEndpoint extends Endpoint {
740
1256
  return status.global;
741
1257
  }
742
1258
  }
1259
+ /**
1260
+ * Sets the lift target and current position of the window covering.
1261
+ *
1262
+ * @param {number} liftPosition - The position to set, specified as a number.
1263
+ * @param {number} [tiltPosition] - The tilt position to set, specified as a number.
1264
+ */
743
1265
  async setWindowCoveringTargetAndCurrentPosition(liftPosition, tiltPosition) {
744
1266
  await this.setAttribute(WindowCovering.Cluster.id, 'currentPositionLiftPercent100ths', liftPosition, this.log);
745
1267
  await this.setAttribute(WindowCovering.Cluster.id, 'targetPositionLiftPercent100ths', liftPosition, this.log);
@@ -750,31 +1272,56 @@ export class MatterbridgeEndpoint extends Endpoint {
750
1272
  this.log.debug(`Set WindowCovering currentPositionTiltPercent100ths: ${tiltPosition} and targetPositionTiltPercent100ths: ${tiltPosition}.`);
751
1273
  }
752
1274
  }
1275
+ /**
1276
+ * Creates a default thermostat cluster server with features Heating, Cooling and AutoMode.
1277
+ *
1278
+ * @param {number} [localTemperature=23] - The local temperature value in degrees Celsius. Defaults to 23°.
1279
+ * @param {number} [occupiedHeatingSetpoint=21] - The occupied heating setpoint value in degrees Celsius. Defaults to 21°.
1280
+ * @param {number} [occupiedCoolingSetpoint=25] - The occupied cooling setpoint value in degrees Celsius. Defaults to 25°.
1281
+ * @param {number} [minSetpointDeadBand=1] - The minimum setpoint dead band value. Defaults to 1°.
1282
+ * @param {number} [minHeatSetpointLimit=0] - The minimum heat setpoint limit value. Defaults to 0°.
1283
+ * @param {number} [maxHeatSetpointLimit=50] - The maximum heat setpoint limit value. Defaults to 50°.
1284
+ * @param {number} [minCoolSetpointLimit=0] - The minimum cool setpoint limit value. Defaults to 0°.
1285
+ * @param {number} [maxCoolSetpointLimit=50] - The maximum cool setpoint limit value. Defaults to 50°.
1286
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1287
+ */
753
1288
  createDefaultThermostatClusterServer(localTemperature = 23, occupiedHeatingSetpoint = 21, occupiedCoolingSetpoint = 25, minSetpointDeadBand = 1, minHeatSetpointLimit = 0, maxHeatSetpointLimit = 50, minCoolSetpointLimit = 0, maxCoolSetpointLimit = 50) {
754
1289
  this.behaviors.require(MatterbridgeThermostatServer.with(Thermostat.Feature.Heating, Thermostat.Feature.Cooling, Thermostat.Feature.AutoMode), {
755
1290
  localTemperature: localTemperature * 100,
756
1291
  systemMode: Thermostat.SystemMode.Auto,
757
1292
  controlSequenceOfOperation: Thermostat.ControlSequenceOfOperation.CoolingAndHeating,
1293
+ // Thermostat.Feature.Heating
758
1294
  occupiedHeatingSetpoint: occupiedHeatingSetpoint * 100,
759
1295
  minHeatSetpointLimit: minHeatSetpointLimit * 100,
760
1296
  maxHeatSetpointLimit: maxHeatSetpointLimit * 100,
761
1297
  absMinHeatSetpointLimit: minHeatSetpointLimit * 100,
762
1298
  absMaxHeatSetpointLimit: maxHeatSetpointLimit * 100,
1299
+ // Thermostat.Feature.Cooling
763
1300
  occupiedCoolingSetpoint: occupiedCoolingSetpoint * 100,
764
1301
  minCoolSetpointLimit: minCoolSetpointLimit * 100,
765
1302
  maxCoolSetpointLimit: maxCoolSetpointLimit * 100,
766
1303
  absMinCoolSetpointLimit: minCoolSetpointLimit * 100,
767
1304
  absMaxCoolSetpointLimit: maxCoolSetpointLimit * 100,
1305
+ // Thermostat.Feature.AutoMode
768
1306
  minSetpointDeadBand: minSetpointDeadBand * 100,
769
1307
  thermostatRunningMode: Thermostat.ThermostatRunningMode.Off,
770
1308
  });
771
1309
  return this;
772
1310
  }
1311
+ /**
1312
+ * Creates a default heating thermostat cluster server with feature Heating.
1313
+ * @param {number} [localTemperature] - The local temperature value in degrees Celsius. Defaults to 23°.
1314
+ * @param {number} [occupiedHeatingSetpoint] - The occupied heating setpoint value in degrees Celsius. Defaults to 21°.
1315
+ * @param {number} [minHeatSetpointLimit] - The minimum heat setpoint limit value. Defaults to 0°.
1316
+ * @param {number} [maxHeatSetpointLimit] - The maximum heat setpoint limit value. Defaults to 50°.
1317
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1318
+ */
773
1319
  createDefaultHeatingThermostatClusterServer(localTemperature = 23, occupiedHeatingSetpoint = 21, minHeatSetpointLimit = 0, maxHeatSetpointLimit = 50) {
774
1320
  this.behaviors.require(MatterbridgeThermostatServer.with(Thermostat.Feature.Heating), {
775
1321
  localTemperature: localTemperature * 100,
776
1322
  systemMode: Thermostat.SystemMode.Heat,
777
1323
  controlSequenceOfOperation: Thermostat.ControlSequenceOfOperation.HeatingOnly,
1324
+ // Thermostat.Feature.Heating
778
1325
  occupiedHeatingSetpoint: occupiedHeatingSetpoint * 100,
779
1326
  minHeatSetpointLimit: minHeatSetpointLimit * 100,
780
1327
  maxHeatSetpointLimit: maxHeatSetpointLimit * 100,
@@ -783,11 +1330,20 @@ export class MatterbridgeEndpoint extends Endpoint {
783
1330
  });
784
1331
  return this;
785
1332
  }
1333
+ /**
1334
+ * Creates a default cooling thermostat cluster server with feature Cooling.
1335
+ * @param {number} [localTemperature] - The local temperature value in degrees Celsius. Defaults to 23°.
1336
+ * @param {number} [occupiedCoolingSetpoint] - The occupied cooling setpoint value in degrees Celsius. Defaults to 25°.
1337
+ * @param {number} [minCoolSetpointLimit] - The minimum cool setpoint limit value. Defaults to 0°.
1338
+ * @param {number} [maxCoolSetpointLimit] - The maximum cool setpoint limit value. Defaults to 50°.
1339
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1340
+ */
786
1341
  createDefaultCoolingThermostatClusterServer(localTemperature = 23, occupiedCoolingSetpoint = 25, minCoolSetpointLimit = 0, maxCoolSetpointLimit = 50) {
787
1342
  this.behaviors.require(MatterbridgeThermostatServer.with(Thermostat.Feature.Cooling), {
788
1343
  localTemperature: localTemperature * 100,
789
1344
  systemMode: Thermostat.SystemMode.Cool,
790
1345
  controlSequenceOfOperation: Thermostat.ControlSequenceOfOperation.CoolingOnly,
1346
+ // Thermostat.Feature.Cooling
791
1347
  occupiedCoolingSetpoint: occupiedCoolingSetpoint * 100,
792
1348
  minCoolSetpointLimit: minCoolSetpointLimit * 100,
793
1349
  maxCoolSetpointLimit: maxCoolSetpointLimit * 100,
@@ -796,6 +1352,15 @@ export class MatterbridgeEndpoint extends Endpoint {
796
1352
  });
797
1353
  return this;
798
1354
  }
1355
+ /**
1356
+ * Creates a default thermostat user interface configuration cluster server.
1357
+ *
1358
+ * @remarks
1359
+ * The default values are:
1360
+ * - temperatureDisplayMode: ThermostatUserInterfaceConfiguration.TemperatureDisplayMode.Celsius (writeble).
1361
+ * - keypadLockout: ThermostatUserInterfaceConfiguration.KeypadLockout.NoLockout (writeble).
1362
+ * - scheduleProgrammingVisibility: ThermostatUserInterfaceConfiguration.ScheduleProgrammingVisibility.ScheduleProgrammingPermitted (writeble).
1363
+ */
799
1364
  createDefaultThermostatUserInterfaceConfigurationClusterServer() {
800
1365
  this.behaviors.require(ThermostatUserInterfaceConfigurationServer, {
801
1366
  temperatureDisplayMode: ThermostatUserInterfaceConfiguration.TemperatureDisplayMode.Celsius,
@@ -804,69 +1369,158 @@ export class MatterbridgeEndpoint extends Endpoint {
804
1369
  });
805
1370
  return this;
806
1371
  }
1372
+ /**
1373
+ * Creates a default fan control cluster server with features Auto, and Step.
1374
+ *
1375
+ * @param {FanControl.FanMode} [fanMode=FanControl.FanMode.Off] - The fan mode to set. Defaults to `FanControl.FanMode.Off`.
1376
+ * @param {FanControl.FanModeSequence} [fanModeSequence=FanControl.FanModeSequence.OffLowMedHighAuto] - The fan mode sequence to set. Defaults to `FanControl.FanModeSequence.OffLowMedHighAuto`.
1377
+ * @param {number} [percentSetting=0] - The initial percent setting. Defaults to 0.
1378
+ * @param {number} [percentCurrent=0] - The initial percent current. Defaults to 0.
1379
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1380
+ *
1381
+ * @remarks
1382
+ * - fanmode is writable and persists across reboots.
1383
+ * - fanModeSequence is fixed.
1384
+ * - percentSetting is writable.
1385
+ */
807
1386
  createDefaultFanControlClusterServer(fanMode = FanControl.FanMode.Off, fanModeSequence = FanControl.FanModeSequence.OffLowMedHighAuto, percentSetting = 0, percentCurrent = 0) {
808
1387
  this.behaviors.require(MatterbridgeFanControlServer.with(FanControl.Feature.Auto, FanControl.Feature.Step), {
809
- fanMode,
810
- fanModeSequence,
811
- percentSetting,
1388
+ fanMode, // Writable and persistent attribute
1389
+ fanModeSequence, // Fixed attribute
1390
+ percentSetting, // Writable attribute
812
1391
  percentCurrent,
813
1392
  });
814
1393
  return this;
815
1394
  }
1395
+ /**
1396
+ * Creates a fan control cluster server with features MultiSpeed, Auto, and Step.
1397
+ *
1398
+ * @param {FanControl.FanMode} [fanMode=FanControl.FanMode.Off] - The fan mode to set. Defaults to `FanControl.FanMode.Off`.
1399
+ * @param {number} [percentSetting=0] - The initial percent setting. Defaults to 0.
1400
+ * @param {number} [percentCurrent=0] - The initial percent current. Defaults to 0.
1401
+ * @param {number} [speedMax=10] - The maximum speed setting. Defaults to 10.
1402
+ * @param {number} [speedSetting=0] - The initial speed setting. Defaults to 0.
1403
+ * @param {number} [speedCurrent=0] - The initial speed current. Defaults to 0.
1404
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1405
+ *
1406
+ * @remarks
1407
+ * - fanmode is writable and persists across reboots.
1408
+ * - fanModeSequence is fixed.
1409
+ * - percentSetting is writable.
1410
+ * - speedMax is fixed.
1411
+ * - speedSetting is writable.
1412
+ */
816
1413
  createMultiSpeedFanControlClusterServer(fanMode = FanControl.FanMode.Off, fanModeSequence = FanControl.FanModeSequence.OffLowMedHighAuto, percentSetting = 0, percentCurrent = 0, speedMax = 10, speedSetting = 0, speedCurrent = 0) {
817
1414
  this.behaviors.require(MatterbridgeFanControlServer.with(FanControl.Feature.MultiSpeed, FanControl.Feature.Auto, FanControl.Feature.Step), {
818
- fanMode,
819
- fanModeSequence,
820
- percentSetting,
1415
+ fanMode, // Writable and persistent attribute
1416
+ fanModeSequence, // Fixed attribute
1417
+ percentSetting, // Writable attribute
821
1418
  percentCurrent,
822
- speedMax,
823
- speedSetting,
1419
+ // MultiSpeed feature
1420
+ speedMax, // Fixed attribute
1421
+ speedSetting, // Writable attribute
824
1422
  speedCurrent,
825
1423
  });
826
1424
  return this;
827
1425
  }
1426
+ /**
1427
+ * Creates a base fan control cluster server without features.
1428
+ *
1429
+ * @param {FanControl.FanMode} [fanMode=FanControl.FanMode.Off] - The fan mode to set. Defaults to `FanControl.FanMode.Off`.
1430
+ * @param {FanControl.FanModeSequence} [fanModeSequence=FanControl.FanModeSequence.OffLowMedHigh] - The fan mode sequence to set. Defaults to `FanControl.FanModeSequence.OffLowMedHigh`.
1431
+ * @param {number} [percentSetting=0] - The initial percent setting. Defaults to 0.
1432
+ * @param {number} [percentCurrent=0] - The initial percent current. Defaults to 0.
1433
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1434
+ *
1435
+ * @remarks
1436
+ * fanmode is writable and persists across reboots.
1437
+ * fanModeSequence is fixed.
1438
+ * percentSetting is writable.
1439
+ */
828
1440
  createBaseFanControlClusterServer(fanMode = FanControl.FanMode.Off, fanModeSequence = FanControl.FanModeSequence.OffLowMedHigh, percentSetting = 0, percentCurrent = 0) {
829
1441
  this.behaviors.require(FanControlServer, {
830
- fanMode,
831
- fanModeSequence,
832
- percentSetting,
1442
+ fanMode, // Writable and persistent attribute
1443
+ fanModeSequence, // Fixed attribute
1444
+ percentSetting, // Writable attribute
833
1445
  percentCurrent,
834
1446
  });
835
1447
  return this;
836
1448
  }
1449
+ /**
1450
+ * Creates a default HEPA Filter Monitoring Cluster Server with features Condition and ReplacementProductList.
1451
+ * It supports ResourceMonitoring.Feature.Condition and ResourceMonitoring.Feature.ReplacementProductList.
1452
+ *
1453
+ * @param {ResourceMonitoring.ChangeIndication} changeIndication - The initial change indication. Default is ResourceMonitoring.ChangeIndication.Ok.
1454
+ * @param {boolean | undefined} inPlaceIndicator - The in-place indicator. Default is undefined.
1455
+ * @param {number | undefined} lastChangedTime - The last changed time (EpochS). Default is undefined.
1456
+ *
1457
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1458
+ */
837
1459
  createDefaultHepaFilterMonitoringClusterServer(changeIndication = ResourceMonitoring.ChangeIndication.Ok, inPlaceIndicator = undefined, lastChangedTime = undefined) {
838
1460
  this.behaviors.require(HepaFilterMonitoringServer.with(ResourceMonitoring.Feature.Condition, ResourceMonitoring.Feature.ReplacementProductList), {
839
- condition: 100,
840
- degradationDirection: ResourceMonitoring.DegradationDirection.Down,
1461
+ condition: 100, // Feature.Condition
1462
+ degradationDirection: ResourceMonitoring.DegradationDirection.Down, // Feature.Condition
841
1463
  changeIndication,
842
1464
  inPlaceIndicator,
843
1465
  lastChangedTime,
844
- replacementProductList: [],
1466
+ replacementProductList: [], // Feature.ReplacementProductList
845
1467
  });
846
1468
  return this;
847
1469
  }
1470
+ /**
1471
+ * Creates a default Activated Carbon Filter Monitoring Cluster Server with features Condition and ReplacementProductList.
1472
+ *
1473
+ * @param {ResourceMonitoring.ChangeIndication} changeIndication - The initial change indication. Default is ResourceMonitoring.ChangeIndication.Ok.
1474
+ * @param {boolean | undefined} inPlaceIndicator - The in-place indicator. Default is undefined.
1475
+ * @param {number | undefined} lastChangedTime - The last changed time (EpochS). Default is undefined.
1476
+ *
1477
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1478
+ */
848
1479
  createDefaultActivatedCarbonFilterMonitoringClusterServer(changeIndication = ResourceMonitoring.ChangeIndication.Ok, inPlaceIndicator = undefined, lastChangedTime = undefined) {
849
1480
  this.behaviors.require(ActivatedCarbonFilterMonitoringServer.with(ResourceMonitoring.Feature.Condition, ResourceMonitoring.Feature.ReplacementProductList), {
850
- condition: 100,
851
- degradationDirection: ResourceMonitoring.DegradationDirection.Down,
1481
+ condition: 100, // Feature.Condition
1482
+ degradationDirection: ResourceMonitoring.DegradationDirection.Down, // Feature.Condition
852
1483
  changeIndication,
853
1484
  inPlaceIndicator,
854
1485
  lastChangedTime,
855
- replacementProductList: [],
1486
+ replacementProductList: [], // Feature.ReplacementProductList
856
1487
  });
857
1488
  return this;
858
1489
  }
1490
+ /**
1491
+ * Creates a default door lock cluster server.
1492
+ *
1493
+ * @param {DoorLock.LockState} [lockState=DoorLock.LockState.Locked] - The initial state of the lock (default: Locked).
1494
+ * @param {DoorLock.LockType} [lockType=DoorLock.LockType.DeadBolt] - The type of the lock (default: DeadBolt).
1495
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1496
+ *
1497
+ * @remarks
1498
+ * 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.
1499
+ */
859
1500
  createDefaultDoorLockClusterServer(lockState = DoorLock.LockState.Locked, lockType = DoorLock.LockType.DeadBolt) {
860
1501
  this.behaviors.require(MatterbridgeDoorLockServer.enable({ events: { doorLockAlarm: true, lockOperation: true, lockOperationError: true } }), {
861
1502
  lockState,
862
1503
  lockType,
863
1504
  actuatorEnabled: false,
864
1505
  operatingMode: DoorLock.OperatingMode.Normal,
1506
+ // Special case of inverted bitmap: add also alwaysSet = 2047
865
1507
  supportedOperatingModes: { normal: false, vacation: true, privacy: true, noRemoteLockUnlock: true, passage: true, alwaysSet: 2047 },
866
1508
  alarmMask: { lockJammed: false, lockFactoryReset: false, lockRadioPowerCycled: false, wrongCodeEntryLimit: false, frontEscutcheonRemoved: false, doorForcedOpen: false },
867
1509
  });
868
1510
  return this;
869
1511
  }
1512
+ /**
1513
+ * Creates a default Mode Select cluster server.
1514
+ *
1515
+ * @param {string} description - The description of the mode select cluster.
1516
+ * @param {ModeSelect.ModeOption[]} supportedModes - The list of supported modes.
1517
+ * @param {number} [currentMode=0] - The current mode (default: 0).
1518
+ * @param {number} [startUpMode=0] - The startup mode (default: 0).
1519
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1520
+ *
1521
+ * @remarks
1522
+ * endpoint.createDefaultModeSelectClusterServer('Night mode', [{ label: 'Led ON', mode: 0, semanticTags: [] }, { label: 'Led OFF', mode: 1, semanticTags: [] }], 0, 0);
1523
+ */
870
1524
  createDefaultModeSelectClusterServer(description, supportedModes, currentMode = 0, startUpMode = 0) {
871
1525
  this.behaviors.require(MatterbridgeModeSelectServer, {
872
1526
  description: description,
@@ -877,21 +1531,35 @@ export class MatterbridgeEndpoint extends Endpoint {
877
1531
  });
878
1532
  return this;
879
1533
  }
1534
+ /**
1535
+ * Creates the default Valve Configuration And Control cluster server with features Level.
1536
+ *
1537
+ * @param {ValveConfigurationAndControl.ValveState} [valveState=ValveConfigurationAndControl.ValveState.Closed] - The valve state to set. Defaults to `ValveConfigurationAndControl.ValveState.Closed`.
1538
+ * @param {number} [valveLevel=0] - The valve level to set. Defaults to 0.
1539
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1540
+ */
880
1541
  createDefaultValveConfigurationAndControlClusterServer(valveState = ValveConfigurationAndControl.ValveState.Closed, valveLevel = 0) {
881
1542
  this.behaviors.require(MatterbridgeValveConfigurationAndControlServer.with(ValveConfigurationAndControl.Feature.Level), {
882
1543
  currentState: valveState,
883
1544
  targetState: valveState,
884
1545
  openDuration: null,
885
- defaultOpenDuration: null,
1546
+ defaultOpenDuration: null, // Writable and persistent across restarts
886
1547
  remainingDuration: null,
887
1548
  valveFault: { generalFault: false, blocked: false, leaking: false, notConnected: false, shortCircuit: false, currentExceeded: false },
1549
+ // Feature.Level
888
1550
  currentLevel: valveLevel,
889
1551
  targetLevel: valveLevel,
890
- defaultOpenLevel: 100,
891
- levelStep: 1,
1552
+ defaultOpenLevel: 100, // Writable and persistent across restarts
1553
+ levelStep: 1, // Fixed
892
1554
  });
893
1555
  return this;
894
1556
  }
1557
+ /**
1558
+ * Creates the default PumpConfigurationAndControl cluster server with features ConstantSpeed.
1559
+ *
1560
+ * @param {PumpConfigurationAndControl.OperationMode} [pumpMode=PumpConfigurationAndControl.OperationMode.Normal] - The pump mode to set. Defaults to `PumpConfigurationAndControl.OperationMode.Normal`.
1561
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1562
+ */
895
1563
  createDefaultPumpConfigurationAndControlClusterServer(pumpMode = PumpConfigurationAndControl.OperationMode.Normal) {
896
1564
  this.behaviors.require(PumpConfigurationAndControlServer.with(PumpConfigurationAndControl.Feature.ConstantSpeed), {
897
1565
  minConstSpeed: null,
@@ -906,6 +1574,13 @@ export class MatterbridgeEndpoint extends Endpoint {
906
1574
  });
907
1575
  return this;
908
1576
  }
1577
+ /**
1578
+ * Creates the default SmokeCOAlarm Cluster Server with features SmokeAlarm and CoAlarm.
1579
+ *
1580
+ * @param {SmokeCoAlarm.AlarmState} smokeState - The state of the smoke alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
1581
+ * @param {SmokeCoAlarm.AlarmState} coState - The state of the CO alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
1582
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1583
+ */
909
1584
  createDefaultSmokeCOAlarmClusterServer(smokeState = SmokeCoAlarm.AlarmState.Normal, coState = SmokeCoAlarm.AlarmState.Normal) {
910
1585
  this.behaviors.require(MatterbridgeSmokeCoAlarmServer.with(SmokeCoAlarm.Feature.SmokeAlarm, SmokeCoAlarm.Feature.CoAlarm).enable({
911
1586
  events: { smokeAlarm: true, interconnectSmokeAlarm: false, coAlarm: true, interconnectCoAlarm: false, lowBattery: true, hardwareFault: true, endOfService: true, selfTestComplete: true, alarmMuted: true, muteEnded: true, allClear: true },
@@ -921,6 +1596,12 @@ export class MatterbridgeEndpoint extends Endpoint {
921
1596
  });
922
1597
  return this;
923
1598
  }
1599
+ /**
1600
+ * Creates a smoke only SmokeCOAlarm Cluster Server with features SmokeAlarm.
1601
+ *
1602
+ * @param {SmokeCoAlarm.AlarmState} smokeState - The state of the smoke alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
1603
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1604
+ */
924
1605
  createSmokeOnlySmokeCOAlarmClusterServer(smokeState = SmokeCoAlarm.AlarmState.Normal) {
925
1606
  this.behaviors.require(MatterbridgeSmokeCoAlarmServer.with(SmokeCoAlarm.Feature.SmokeAlarm).enable({
926
1607
  events: { smokeAlarm: true, interconnectSmokeAlarm: false, coAlarm: false, interconnectCoAlarm: false, lowBattery: true, hardwareFault: true, endOfService: true, selfTestComplete: true, alarmMuted: true, muteEnded: true, allClear: true },
@@ -935,6 +1616,12 @@ export class MatterbridgeEndpoint extends Endpoint {
935
1616
  });
936
1617
  return this;
937
1618
  }
1619
+ /**
1620
+ * Creates a co only SmokeCOAlarm Cluster Server with features CoAlarm.
1621
+ *
1622
+ * @param {SmokeCoAlarm.AlarmState} coState - The state of the CO alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
1623
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1624
+ */
938
1625
  createCoOnlySmokeCOAlarmClusterServer(coState = SmokeCoAlarm.AlarmState.Normal) {
939
1626
  this.behaviors.require(MatterbridgeSmokeCoAlarmServer.with(SmokeCoAlarm.Feature.CoAlarm).enable({
940
1627
  events: { smokeAlarm: false, interconnectSmokeAlarm: false, coAlarm: true, interconnectCoAlarm: false, lowBattery: true, hardwareFault: true, endOfService: true, selfTestComplete: true, alarmMuted: true, muteEnded: true, allClear: true },
@@ -949,6 +1636,13 @@ export class MatterbridgeEndpoint extends Endpoint {
949
1636
  });
950
1637
  return this;
951
1638
  }
1639
+ /**
1640
+ * Creates a default momentary switch cluster server with features MomentarySwitch, MomentarySwitchRelease, MomentarySwitchLongPress and MomentarySwitchMultiPress.
1641
+ *
1642
+ * @remarks
1643
+ * This method adds a cluster server with default momentary switch features and configuration suitable for (AppleHome) Single Double Long automations.
1644
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1645
+ */
952
1646
  createDefaultSwitchClusterServer() {
953
1647
  this.behaviors.require(MatterbridgeSwitchServer.with(Switch.Feature.MomentarySwitch, Switch.Feature.MomentarySwitchRelease, Switch.Feature.MomentarySwitchLongPress, Switch.Feature.MomentarySwitchMultiPress).enable({
954
1648
  events: { initialPress: true, longPress: true, shortRelease: true, longRelease: true, multiPressOngoing: true, multiPressComplete: true },
@@ -959,6 +1653,13 @@ export class MatterbridgeEndpoint extends Endpoint {
959
1653
  });
960
1654
  return this;
961
1655
  }
1656
+ /**
1657
+ * Creates a default latching switch cluster server with features LatchingSwitch.
1658
+ *
1659
+ * @remarks
1660
+ * This method adds a cluster server with default latching switch features and configuration suitable for a latching switch with 2 positions.
1661
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1662
+ */
962
1663
  createDefaultLatchingSwitchClusterServer() {
963
1664
  this.behaviors.require(SwitchServer.with(Switch.Feature.LatchingSwitch).enable({
964
1665
  events: { switchLatched: true },
@@ -968,6 +1669,13 @@ export class MatterbridgeEndpoint extends Endpoint {
968
1669
  });
969
1670
  return this;
970
1671
  }
1672
+ /**
1673
+ * Triggers a switch event on the specified endpoint.
1674
+ *
1675
+ * @param {string} event - The type of event to trigger. Possible values are 'Single', 'Double', 'Long' for momentarySwitch and 'Press', 'Release' for latchingSwitch.
1676
+ * @param {Endpoint} endpoint - The endpoint on which to trigger the event (default the device endpoint).
1677
+ * @returns {boolean} - A boolean indicating whether the event was successfully triggered.
1678
+ */
971
1679
  async triggerSwitchEvent(event, log) {
972
1680
  if (this.maybeNumber === undefined) {
973
1681
  this.log.error(`triggerSwitchEvent ${event} error: Endpoint number not assigned on endpoint ${this.maybeId}:${this.maybeNumber}`);
@@ -1027,10 +1735,30 @@ export class MatterbridgeEndpoint extends Endpoint {
1027
1735
  }
1028
1736
  return true;
1029
1737
  }
1738
+ /**
1739
+ * Creates a default OperationalState Cluster Server.
1740
+ *
1741
+ * @param {OperationalState.OperationalStateEnum} operationalState - The initial operational state.
1742
+ *
1743
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1744
+ */
1030
1745
  createDefaultOperationalStateClusterServer(operationalState = OperationalState.OperationalStateEnum.Stopped) {
1031
1746
  this.behaviors.require(MatterbridgeOperationalStateServer, getDefaultOperationalStateClusterServer(operationalState));
1032
1747
  return this;
1033
1748
  }
1749
+ /**
1750
+ * Creates a default boolean state cluster server.
1751
+ * The stateChange event is enabled.
1752
+ *
1753
+ * @param {boolean} contact - The state of the cluster. Defaults to true (true = contact).
1754
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1755
+ *
1756
+ * @remarks
1757
+ * Water Leak Detector: true = leak, false = no leak
1758
+ * Water Freeze Detector: true = freeze, false = no freeze
1759
+ * Rain Sensor: true = rain, false = no rain
1760
+ * Contact Sensor: true = closed or contact, false = open or no contact
1761
+ */
1034
1762
  createDefaultBooleanStateClusterServer(contact) {
1035
1763
  this.behaviors.require(BooleanStateServer.enable({
1036
1764
  events: { stateChange: true },
@@ -1039,6 +1767,23 @@ export class MatterbridgeEndpoint extends Endpoint {
1039
1767
  });
1040
1768
  return this;
1041
1769
  }
1770
+ /**
1771
+ * Creates a default boolean state configuration cluster server to be used with the waterFreezeDetector, waterLeakDetector, and rainSensor device types.
1772
+ *
1773
+ * Features:
1774
+ * - Visual
1775
+ * - Audible
1776
+ * - SensitivityLevel
1777
+ *
1778
+ * @remarks Supports the enableDisableAlarm command.
1779
+ *
1780
+ * @param {boolean} [sensorFault=false] - Optional boolean value indicating the sensor fault state. Defaults to `false` if not provided.
1781
+ * @param {number} [currentSensitivityLevel=0] - The current sensitivity level. Defaults to `0` if not provided.
1782
+ * @param {number} [supportedSensitivityLevels=2] - The number of supported sensitivity levels. Defaults to `2` if not provided (min 2, max 10).
1783
+ * @param {number} [defaultSensitivityLevel=0] - The default sensitivity level. Defaults to `0` if not provided.
1784
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1785
+ *
1786
+ */
1042
1787
  createDefaultBooleanStateConfigurationClusterServer(sensorFault = false, currentSensitivityLevel = 0, supportedSensitivityLevels = 2, defaultSensitivityLevel = 0) {
1043
1788
  this.behaviors.require(MatterbridgeBooleanStateConfigurationServer.with(BooleanStateConfiguration.Feature.Visual, BooleanStateConfiguration.Feature.Audible, BooleanStateConfiguration.Feature.SensitivityLevel).enable({
1044
1789
  events: { alarmsStateChanged: true, sensorFault: true },
@@ -1053,17 +1798,50 @@ export class MatterbridgeEndpoint extends Endpoint {
1053
1798
  });
1054
1799
  return this;
1055
1800
  }
1801
+ /**
1802
+ * Creates a default Device Energy Management Cluster Server with feature PowerForecastReporting and with the specified ESA type, ESA canGenerate, ESA state, and power limits.
1803
+ *
1804
+ * @param {DeviceEnergyManagement.EsaType} [esaType=DeviceEnergyManagement.EsaType.Other] - The ESA type. Defaults to `DeviceEnergyManagement.EsaType.Other`.
1805
+ * @param {boolean} [esaCanGenerate=false] - Indicates if the ESA can generate energy. Defaults to `false`.
1806
+ * @param {DeviceEnergyManagement.EsaState} [esaState=DeviceEnergyManagement.EsaState.Online] - The ESA state. Defaults to `DeviceEnergyManagement.EsaState.Online`.
1807
+ * @param {number} [absMinPower=0] - The absolute minimum power in mW. Defaults to `0`.
1808
+ * @param {number} [absMaxPower=0] - The absolute maximum power in mW. Defaults to `0`.
1809
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1810
+ *
1811
+ * @remarks
1812
+ * - The forecast attribute is set to null, indicating that there is no forecast currently available.
1813
+ * - The ESA type and canGenerate attributes are fixed and cannot be changed after creation.
1814
+ * - The ESA state is set to Online by default.
1815
+ * - The absolute minimum and maximum power attributes are set to 0 by default.
1816
+ * - For example, a battery storage inverter that can charge its battery at a maximum power of 2000W and can
1817
+ * discharge the battery at a maximum power of 3000W, would have a absMinPower: -3000W, absMaxPower: 2000W.
1818
+ */
1056
1819
  createDefaultDeviceEnergyManagementClusterServer(esaType = DeviceEnergyManagement.EsaType.Other, esaCanGenerate = false, esaState = DeviceEnergyManagement.EsaState.Online, absMinPower = 0, absMaxPower = 0) {
1057
1820
  this.behaviors.require(DeviceEnergyManagementServer.with(DeviceEnergyManagement.Feature.PowerForecastReporting), {
1058
- forecast: null,
1059
- esaType,
1060
- esaCanGenerate,
1821
+ forecast: null, // A null value indicates that there is no forecast currently available
1822
+ esaType, // Fixed attribute
1823
+ esaCanGenerate, // Fixed attribute
1061
1824
  esaState,
1062
1825
  absMinPower,
1063
1826
  absMaxPower,
1064
1827
  });
1065
1828
  return this;
1066
1829
  }
1830
+ /**
1831
+ * Creates a default EnergyManagementMode Cluster Server.
1832
+ *
1833
+ * @param {number} [currentMode] - The current mode of the EnergyManagementMode cluster. Defaults to mode 1 (DeviceEnergyManagementMode.ModeTag.NoOptimization).
1834
+ * @param {EnergyManagementMode.ModeOption[]} [supportedModes] - The supported modes for the DeviceEnergyManagementMode cluster. The attribute is fixed and defaults to a predefined set of cluster modes.
1835
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1836
+ *
1837
+ * @remarks
1838
+ * A few examples of Device Energy Management modes and their mode tags are provided below.
1839
+ * - For the "No Energy Management (Forecast reporting only)" mode, tags: 0x4000 (NoOptimization).
1840
+ * - For the "Device Energy Management" mode, tags: 0x4001 (DeviceOptimization).
1841
+ * - For the "Home Energy Management" mode, tags: 0x4001 (DeviceOptimization), 0x4002 (LocalOptimization).
1842
+ * - For the "Grid Energy Management" mode, tags: 0x4003 (GridOptimization).
1843
+ * - For the "Full Energy Management" mode, tags: 0x4001 (DeviceOptimization), 0x4002 (LocalOptimization), 0x4003 (GridOptimization).
1844
+ */
1067
1845
  createDefaultDeviceEnergyManagementModeClusterServer(currentMode, supportedModes) {
1068
1846
  this.behaviors.require(MatterbridgeDeviceEnergyManagementModeServer, {
1069
1847
  supportedModes: supportedModes ?? [
@@ -1084,15 +1862,27 @@ export class MatterbridgeEndpoint extends Endpoint {
1084
1862
  mode: 5,
1085
1863
  modeTags: [{ value: DeviceEnergyManagementMode.ModeTag.DeviceOptimization }, { value: DeviceEnergyManagementMode.ModeTag.LocalOptimization }, { value: DeviceEnergyManagementMode.ModeTag.GridOptimization }],
1086
1864
  },
1087
- ],
1865
+ ], // Fixed attribute
1088
1866
  currentMode: currentMode ?? 1,
1089
1867
  });
1090
1868
  return this;
1091
1869
  }
1870
+ /**
1871
+ * Creates a default Power Topology Cluster Server with feature TreeTopology. Only needed for an electricalSensor device type.
1872
+ *
1873
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1874
+ */
1092
1875
  createDefaultPowerTopologyClusterServer() {
1093
1876
  this.behaviors.require(PowerTopologyServer.with(PowerTopology.Feature.TreeTopology));
1094
1877
  return this;
1095
1878
  }
1879
+ /**
1880
+ * Creates a default Electrical Energy Measurement Cluster Server with features ImportedEnergy, ExportedEnergy, and CumulativeEnergy.
1881
+ *
1882
+ * @param {number} energyImported - The total consumption value in mW/h.
1883
+ * @param {number} energyExported - The total production value in mW/h.
1884
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1885
+ */
1096
1886
  createDefaultElectricalEnergyMeasurementClusterServer(energyImported = null, energyExported = null) {
1097
1887
  this.behaviors.require(ElectricalEnergyMeasurementServer.with(ElectricalEnergyMeasurement.Feature.ImportedEnergy, ElectricalEnergyMeasurement.Feature.ExportedEnergy, ElectricalEnergyMeasurement.Feature.CumulativeEnergy), {
1098
1888
  accuracy: {
@@ -1108,6 +1898,15 @@ export class MatterbridgeEndpoint extends Endpoint {
1108
1898
  });
1109
1899
  return this;
1110
1900
  }
1901
+ /**
1902
+ * Creates a default Electrical Power Measurement Cluster Server with features AlternatingCurrent.
1903
+ *
1904
+ * @param {number} voltage - The voltage value in millivolts.
1905
+ * @param {number} current - The current value in milliamperes.
1906
+ * @param {number} power - The power value in milliwatts.
1907
+ * @param {number} frequency - The frequency value in millihertz.
1908
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1909
+ */
1111
1910
  createDefaultElectricalPowerMeasurementClusterServer(voltage = null, current = null, power = null, frequency = null) {
1112
1911
  this.behaviors.require(ElectricalPowerMeasurementServer.with(ElectricalPowerMeasurement.Feature.AlternatingCurrent), {
1113
1912
  powerMode: ElectricalPowerMeasurement.PowerMode.Ac,
@@ -1149,36 +1948,112 @@ export class MatterbridgeEndpoint extends Endpoint {
1149
1948
  });
1150
1949
  return this;
1151
1950
  }
1951
+ /**
1952
+ * Creates a default TemperatureMeasurement cluster server.
1953
+ *
1954
+ * @param {number | null} measuredValue - The measured value of the temperature x 100.
1955
+ * @param {number | null} minMeasuredValue - The minimum measured value of the temperature x 100.
1956
+ * @param {number | null} maxMeasuredValue - The maximum measured value of the temperature x 100.
1957
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1958
+ */
1152
1959
  createDefaultTemperatureMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
1153
1960
  this.behaviors.require(TemperatureMeasurementServer, getDefaultTemperatureMeasurementClusterServer(measuredValue, minMeasuredValue, maxMeasuredValue));
1154
1961
  return this;
1155
1962
  }
1963
+ /**
1964
+ * Creates a default RelativeHumidityMeasurement cluster server.
1965
+ *
1966
+ * @param {number | null} measuredValue - The measured value of the relative humidity x 100.
1967
+ * @param {number | null} minMeasuredValue - The minimum measured value of the relative humidity x 100.
1968
+ * @param {number | null} maxMeasuredValue - The maximum measured value of the relative humidity x 100.
1969
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1970
+ */
1156
1971
  createDefaultRelativeHumidityMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
1157
1972
  this.behaviors.require(RelativeHumidityMeasurementServer, getDefaultRelativeHumidityMeasurementClusterServer(measuredValue, minMeasuredValue, maxMeasuredValue));
1158
1973
  return this;
1159
1974
  }
1975
+ /**
1976
+ * Creates a default PressureMeasurement cluster server.
1977
+ *
1978
+ * @param {number | null} measuredValue - The measured value for the pressure.
1979
+ * @param {number | null} minMeasuredValue - The minimum measured value for the pressure.
1980
+ * @param {number | null} maxMeasuredValue - The maximum measured value for the pressure.
1981
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1982
+ */
1160
1983
  createDefaultPressureMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
1161
1984
  this.behaviors.require(PressureMeasurementServer, getDefaultPressureMeasurementClusterServer(measuredValue, minMeasuredValue, maxMeasuredValue));
1162
1985
  return this;
1163
1986
  }
1987
+ /**
1988
+ * Creates a default IlluminanceMeasurement cluster server.
1989
+ *
1990
+ * @param {number | null} measuredValue - The measured value of illuminance.
1991
+ * @param {number | null} minMeasuredValue - The minimum measured value of illuminance.
1992
+ * @param {number | null} maxMeasuredValue - The maximum measured value of illuminance.
1993
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1994
+ *
1995
+ * @remark The default value for the illuminance measurement is null.
1996
+ * This attribute SHALL indicate the illuminance in Lux (symbol lx) as follows:
1997
+ * • MeasuredValue = 10,000 x log10(illuminance) + 1,
1998
+ * where 1 lx <= illuminance <= 3.576 Mlx, corresponding to a MeasuredValue in the range 1 to 0xFFFE.
1999
+ * • 0 indicates a value of illuminance that is too low to be measured
2000
+ * • null indicates that the illuminance measurement is invalid.
2001
+ *
2002
+ * - Lux to matter = Math.round(Math.max(Math.min(10000 * Math.log10(lux), 0xfffe), 0))
2003
+ * - Matter to Lux = Math.round(Math.max(Math.pow(10, value / 10000), 0))
2004
+ */
1164
2005
  createDefaultIlluminanceMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
1165
2006
  this.behaviors.require(IlluminanceMeasurementServer, getDefaultIlluminanceMeasurementClusterServer(measuredValue, minMeasuredValue, maxMeasuredValue));
1166
2007
  return this;
1167
2008
  }
2009
+ /**
2010
+ * Creates a default FlowMeasurement cluster server.
2011
+ *
2012
+ * @param {number | null} measuredValue - The measured value of the flow in 10 x m3/h.
2013
+ * @param {number | null} minMeasuredValue - The minimum measured value of the flow in 10 x m3/h.
2014
+ * @param {number | null} maxMeasuredValue - The maximum measured value of the flow in 10 x m3/h.
2015
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2016
+ */
1168
2017
  createDefaultFlowMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
1169
2018
  this.behaviors.require(FlowMeasurementServer, getDefaultFlowMeasurementClusterServer(measuredValue, minMeasuredValue, maxMeasuredValue));
1170
2019
  return this;
1171
2020
  }
2021
+ /**
2022
+ * Creates a default OccupancySensing cluster server with feature PassiveInfrared.
2023
+ *
2024
+ * @param {boolean} occupied - A boolean indicating whether the occupancy is occupied or not. Default is false.
2025
+ * @param {number} holdTime - The hold time in seconds. Default is 30.
2026
+ * @param {number} holdTimeMin - The minimum hold time in seconds. Default is 1.
2027
+ * @param {number} holdTimeMax - The maximum hold time in seconds. Default is 300.
2028
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2029
+ *
2030
+ * @remark The default value for the occupancy sensor type is PIR.
2031
+ */
1172
2032
  createDefaultOccupancySensingClusterServer(occupied = false, holdTime = 30, holdTimeMin = 1, holdTimeMax = 300) {
1173
2033
  this.behaviors.require(OccupancySensingServer.with(OccupancySensing.Feature.PassiveInfrared), getDefaultOccupancySensingClusterServer(occupied, holdTime, holdTimeMin, holdTimeMax));
1174
2034
  return this;
1175
2035
  }
2036
+ /**
2037
+ * Creates a default AirQuality cluster server.
2038
+ *
2039
+ * @param {AirQuality.AirQualityEnum} airQuality The air quality level. Defaults to `AirQuality.AirQualityType.Unknown`.
2040
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2041
+ */
1176
2042
  createDefaultAirQualityClusterServer(airQuality = AirQuality.AirQualityEnum.Unknown) {
1177
2043
  this.behaviors.require(AirQualityServer.with(AirQuality.Feature.Fair, AirQuality.Feature.Moderate, AirQuality.Feature.VeryPoor, AirQuality.Feature.ExtremelyPoor), {
1178
2044
  airQuality,
1179
2045
  });
1180
2046
  return this;
1181
2047
  }
2048
+ /**
2049
+ * Creates a default TotalVolatileOrganicCompoundsConcentrationMeasurement cluster server with feature NumericMeasurement.
2050
+ *
2051
+ * @param {number | null} measuredValue - The measured value of the concentration.
2052
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
2053
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2054
+ * @param {number} [uncertainty] - The uncertainty value (optional).
2055
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2056
+ */
1182
2057
  createDefaultTvocMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air, uncertainty) {
1183
2058
  this.behaviors.require(TotalVolatileOrganicCompoundsConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1184
2059
  measuredValue,
@@ -1190,6 +2065,13 @@ export class MatterbridgeEndpoint extends Endpoint {
1190
2065
  });
1191
2066
  return this;
1192
2067
  }
2068
+ /**
2069
+ * Creates a default TotalVolatileOrganicCompoundsConcentrationMeasurement cluster server with feature LevelIndication.
2070
+
2071
+ * @param {ConcentrationMeasurement.LevelValue} levelValue - The level value of the measurement (default to ConcentrationMeasurement.LevelValue.Unknown).
2072
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The measurement medium (default to ConcentrationMeasurement.MeasurementMedium.Air).
2073
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2074
+ */
1193
2075
  createLevelTvocMeasurementClusterServer(levelValue = ConcentrationMeasurement.LevelValue.Unknown, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1194
2076
  this.behaviors.require(TotalVolatileOrganicCompoundsConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.LevelIndication, ConcentrationMeasurement.Feature.MediumLevel, ConcentrationMeasurement.Feature.CriticalLevel), {
1195
2077
  levelValue,
@@ -1197,6 +2079,14 @@ export class MatterbridgeEndpoint extends Endpoint {
1197
2079
  });
1198
2080
  return this;
1199
2081
  }
2082
+ /**
2083
+ * Create a default CarbonMonoxideConcentrationMeasurement cluster server with feature NumericMeasurement.
2084
+ *
2085
+ * @param {number | null} measuredValue - The measured value of the concentration.
2086
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
2087
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2088
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2089
+ */
1200
2090
  createDefaultCarbonMonoxideConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1201
2091
  this.behaviors.require(CarbonMonoxideConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1202
2092
  measuredValue,
@@ -1208,6 +2098,14 @@ export class MatterbridgeEndpoint extends Endpoint {
1208
2098
  });
1209
2099
  return this;
1210
2100
  }
2101
+ /**
2102
+ * Create a default CarbonDioxideConcentrationMeasurement cluster server with feature NumericMeasurement.
2103
+ *
2104
+ * @param {number | null} measuredValue - The measured value of the concentration.
2105
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
2106
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2107
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2108
+ */
1211
2109
  createDefaultCarbonDioxideConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1212
2110
  this.behaviors.require(CarbonDioxideConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1213
2111
  measuredValue,
@@ -1219,6 +2117,14 @@ export class MatterbridgeEndpoint extends Endpoint {
1219
2117
  });
1220
2118
  return this;
1221
2119
  }
2120
+ /**
2121
+ * Create a default FormaldehydeConcentrationMeasurement cluster server with feature NumericMeasurement.
2122
+ *
2123
+ * @param {number | null} measuredValue - The measured value of the concentration.
2124
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
2125
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2126
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2127
+ */
1222
2128
  createDefaultFormaldehydeConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1223
2129
  this.behaviors.require(FormaldehydeConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1224
2130
  measuredValue,
@@ -1230,6 +2136,14 @@ export class MatterbridgeEndpoint extends Endpoint {
1230
2136
  });
1231
2137
  return this;
1232
2138
  }
2139
+ /**
2140
+ * Create a default Pm1ConcentrationMeasurement cluster server with feature NumericMeasurement.
2141
+ *
2142
+ * @param {number | null} measuredValue - The measured value of the concentration.
2143
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
2144
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2145
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2146
+ */
1233
2147
  createDefaultPm1ConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1234
2148
  this.behaviors.require(Pm1ConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1235
2149
  measuredValue,
@@ -1241,6 +2155,14 @@ export class MatterbridgeEndpoint extends Endpoint {
1241
2155
  });
1242
2156
  return this;
1243
2157
  }
2158
+ /**
2159
+ * Create a default Pm25ConcentrationMeasurement cluster server with feature NumericMeasurement.
2160
+ *
2161
+ * @param {number | null} measuredValue - The measured value of the concentration.
2162
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
2163
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2164
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2165
+ */
1244
2166
  createDefaultPm25ConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1245
2167
  this.behaviors.require(Pm25ConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1246
2168
  measuredValue,
@@ -1252,6 +2174,14 @@ export class MatterbridgeEndpoint extends Endpoint {
1252
2174
  });
1253
2175
  return this;
1254
2176
  }
2177
+ /**
2178
+ * Create a default Pm10ConcentrationMeasurement cluster server with feature NumericMeasurement.
2179
+ *
2180
+ * @param {number | null} measuredValue - The measured value of the concentration.
2181
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
2182
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2183
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2184
+ */
1255
2185
  createDefaultPm10ConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1256
2186
  this.behaviors.require(Pm10ConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1257
2187
  measuredValue,
@@ -1263,6 +2193,14 @@ export class MatterbridgeEndpoint extends Endpoint {
1263
2193
  });
1264
2194
  return this;
1265
2195
  }
2196
+ /**
2197
+ * Create a default OzoneConcentrationMeasurement cluster server with feature NumericMeasurement.
2198
+ *
2199
+ * @param {number | null} measuredValue - The measured value of the concentration.
2200
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ugm3).
2201
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2202
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2203
+ */
1266
2204
  createDefaultOzoneConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ugm3, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1267
2205
  this.behaviors.require(OzoneConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1268
2206
  measuredValue,
@@ -1274,6 +2212,14 @@ export class MatterbridgeEndpoint extends Endpoint {
1274
2212
  });
1275
2213
  return this;
1276
2214
  }
2215
+ /**
2216
+ * Create a default RadonConcentrationMeasurement cluster server with feature NumericMeasurement.
2217
+ *
2218
+ * @param {number | null} measuredValue - The measured value of the concentration.
2219
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
2220
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2221
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2222
+ */
1277
2223
  createDefaultRadonConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1278
2224
  this.behaviors.require(RadonConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1279
2225
  measuredValue,
@@ -1285,6 +2231,14 @@ export class MatterbridgeEndpoint extends Endpoint {
1285
2231
  });
1286
2232
  return this;
1287
2233
  }
2234
+ /**
2235
+ * Create a default NitrogenDioxideConcentrationMeasurement cluster server with feature NumericMeasurement.
2236
+ *
2237
+ * @param {number | null} measuredValue - The measured value of the concentration.
2238
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ugm3).
2239
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2240
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2241
+ */
1288
2242
  createDefaultNitrogenDioxideConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ugm3, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1289
2243
  this.behaviors.require(NitrogenDioxideConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1290
2244
  measuredValue,
@@ -1297,3 +2251,4 @@ export class MatterbridgeEndpoint extends Endpoint {
1297
2251
  return this;
1298
2252
  }
1299
2253
  }
2254
+ //# sourceMappingURL=matterbridgeEndpoint.js.map