matterbridge 3.0.5-dev-20250607-353b662 → 3.0.5

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 (171) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/dist/cli.d.ts +29 -0
  3. package/dist/cli.d.ts.map +1 -0
  4. package/dist/cli.js +79 -5
  5. package/dist/cli.js.map +1 -0
  6. package/dist/cluster/export.d.ts +2 -0
  7. package/dist/cluster/export.d.ts.map +1 -0
  8. package/dist/cluster/export.js +2 -0
  9. package/dist/cluster/export.js.map +1 -0
  10. package/dist/defaultConfigSchema.d.ts +27 -0
  11. package/dist/defaultConfigSchema.d.ts.map +1 -0
  12. package/dist/defaultConfigSchema.js +23 -0
  13. package/dist/defaultConfigSchema.js.map +1 -0
  14. package/dist/deviceManager.d.ts +114 -0
  15. package/dist/deviceManager.d.ts.map +1 -0
  16. package/dist/deviceManager.js +94 -1
  17. package/dist/deviceManager.js.map +1 -0
  18. package/dist/evse.d.ts +63 -0
  19. package/dist/evse.d.ts.map +1 -0
  20. package/dist/evse.js +79 -26
  21. package/dist/evse.js.map +1 -0
  22. package/dist/frontend.d.ts +256 -0
  23. package/dist/frontend.d.ts.map +1 -0
  24. package/dist/frontend.js +374 -16
  25. package/dist/frontend.js.map +1 -0
  26. package/dist/helpers.d.ts +47 -0
  27. package/dist/helpers.d.ts.map +1 -0
  28. package/dist/helpers.js +51 -0
  29. package/dist/helpers.js.map +1 -0
  30. package/dist/index.d.ts +37 -0
  31. package/dist/index.d.ts.map +1 -0
  32. package/dist/index.js +28 -1
  33. package/dist/index.js.map +1 -0
  34. package/dist/laundryWasher.d.ts +243 -0
  35. package/dist/laundryWasher.d.ts.map +1 -0
  36. package/dist/laundryWasher.js +92 -7
  37. package/dist/laundryWasher.js.map +1 -0
  38. package/dist/logger/export.d.ts +2 -0
  39. package/dist/logger/export.d.ts.map +1 -0
  40. package/dist/logger/export.js +1 -0
  41. package/dist/logger/export.js.map +1 -0
  42. package/dist/matter/behaviors.d.ts +2 -0
  43. package/dist/matter/behaviors.d.ts.map +1 -0
  44. package/dist/matter/behaviors.js +2 -0
  45. package/dist/matter/behaviors.js.map +1 -0
  46. package/dist/matter/clusters.d.ts +2 -0
  47. package/dist/matter/clusters.d.ts.map +1 -0
  48. package/dist/matter/clusters.js +2 -0
  49. package/dist/matter/clusters.js.map +1 -0
  50. package/dist/matter/devices.d.ts +2 -0
  51. package/dist/matter/devices.d.ts.map +1 -0
  52. package/dist/matter/devices.js +2 -0
  53. package/dist/matter/devices.js.map +1 -0
  54. package/dist/matter/endpoints.d.ts +2 -0
  55. package/dist/matter/endpoints.d.ts.map +1 -0
  56. package/dist/matter/endpoints.js +2 -0
  57. package/dist/matter/endpoints.js.map +1 -0
  58. package/dist/matter/export.d.ts +5 -0
  59. package/dist/matter/export.d.ts.map +1 -0
  60. package/dist/matter/export.js +2 -0
  61. package/dist/matter/export.js.map +1 -0
  62. package/dist/matter/types.d.ts +3 -0
  63. package/dist/matter/types.d.ts.map +1 -0
  64. package/dist/matter/types.js +2 -0
  65. package/dist/matter/types.js.map +1 -0
  66. package/dist/matterbridge.d.ts +449 -0
  67. package/dist/matterbridge.d.ts.map +1 -0
  68. package/dist/matterbridge.js +747 -47
  69. package/dist/matterbridge.js.map +1 -0
  70. package/dist/matterbridgeAccessoryPlatform.d.ts +40 -0
  71. package/dist/matterbridgeAccessoryPlatform.d.ts.map +1 -0
  72. package/dist/matterbridgeAccessoryPlatform.js +34 -0
  73. package/dist/matterbridgeAccessoryPlatform.js.map +1 -0
  74. package/dist/matterbridgeBehaviors.d.ts +1379 -0
  75. package/dist/matterbridgeBehaviors.d.ts.map +1 -0
  76. package/dist/matterbridgeBehaviors.js +49 -1
  77. package/dist/matterbridgeBehaviors.js.map +1 -0
  78. package/dist/matterbridgeDeviceTypes.d.ts +644 -0
  79. package/dist/matterbridgeDeviceTypes.d.ts.map +1 -0
  80. package/dist/matterbridgeDeviceTypes.js +578 -15
  81. package/dist/matterbridgeDeviceTypes.js.map +1 -0
  82. package/dist/matterbridgeDynamicPlatform.d.ts +40 -0
  83. package/dist/matterbridgeDynamicPlatform.d.ts.map +1 -0
  84. package/dist/matterbridgeDynamicPlatform.js +34 -0
  85. package/dist/matterbridgeDynamicPlatform.js.map +1 -0
  86. package/dist/matterbridgeEndpoint.d.ts +1079 -0
  87. package/dist/matterbridgeEndpoint.d.ts.map +1 -0
  88. package/dist/matterbridgeEndpoint.js +924 -24
  89. package/dist/matterbridgeEndpoint.js.map +1 -0
  90. package/dist/matterbridgeEndpointHelpers.d.ts +2749 -0
  91. package/dist/matterbridgeEndpointHelpers.d.ts.map +1 -0
  92. package/dist/matterbridgeEndpointHelpers.js +172 -10
  93. package/dist/matterbridgeEndpointHelpers.js.map +1 -0
  94. package/dist/matterbridgePlatform.d.ts +294 -0
  95. package/dist/matterbridgePlatform.d.ts.map +1 -0
  96. package/dist/matterbridgePlatform.js +225 -7
  97. package/dist/matterbridgePlatform.js.map +1 -0
  98. package/dist/matterbridgeTypes.d.ts +196 -0
  99. package/dist/matterbridgeTypes.d.ts.map +1 -0
  100. package/dist/matterbridgeTypes.js +24 -0
  101. package/dist/matterbridgeTypes.js.map +1 -0
  102. package/dist/pluginManager.d.ts +273 -0
  103. package/dist/pluginManager.d.ts.map +1 -0
  104. package/dist/pluginManager.js +264 -3
  105. package/dist/pluginManager.js.map +1 -0
  106. package/dist/roboticVacuumCleaner.d.ts +102 -0
  107. package/dist/roboticVacuumCleaner.d.ts.map +1 -0
  108. package/dist/roboticVacuumCleaner.js +81 -6
  109. package/dist/roboticVacuumCleaner.js.map +1 -0
  110. package/dist/shelly.d.ts +153 -0
  111. package/dist/shelly.d.ts.map +1 -0
  112. package/dist/shelly.js +155 -7
  113. package/dist/shelly.js.map +1 -0
  114. package/dist/storage/export.d.ts +2 -0
  115. package/dist/storage/export.d.ts.map +1 -0
  116. package/dist/storage/export.js +1 -0
  117. package/dist/storage/export.js.map +1 -0
  118. package/dist/update.d.ts +58 -0
  119. package/dist/update.d.ts.map +1 -0
  120. package/dist/update.js +53 -0
  121. package/dist/update.js.map +1 -0
  122. package/dist/utils/colorUtils.d.ts +61 -0
  123. package/dist/utils/colorUtils.d.ts.map +1 -0
  124. package/dist/utils/colorUtils.js +205 -2
  125. package/dist/utils/colorUtils.js.map +1 -0
  126. package/dist/utils/commandLine.d.ts +58 -0
  127. package/dist/utils/commandLine.d.ts.map +1 -0
  128. package/dist/utils/commandLine.js +53 -0
  129. package/dist/utils/commandLine.js.map +1 -0
  130. package/dist/utils/copyDirectory.d.ts +32 -0
  131. package/dist/utils/copyDirectory.d.ts.map +1 -0
  132. package/dist/utils/copyDirectory.js +37 -1
  133. package/dist/utils/copyDirectory.js.map +1 -0
  134. package/dist/utils/createZip.d.ts +38 -0
  135. package/dist/utils/createZip.d.ts.map +1 -0
  136. package/dist/utils/createZip.js +42 -2
  137. package/dist/utils/createZip.js.map +1 -0
  138. package/dist/utils/deepCopy.d.ts +31 -0
  139. package/dist/utils/deepCopy.d.ts.map +1 -0
  140. package/dist/utils/deepCopy.js +38 -0
  141. package/dist/utils/deepCopy.js.map +1 -0
  142. package/dist/utils/deepEqual.d.ts +53 -0
  143. package/dist/utils/deepEqual.d.ts.map +1 -0
  144. package/dist/utils/deepEqual.js +71 -1
  145. package/dist/utils/deepEqual.js.map +1 -0
  146. package/dist/utils/export.d.ts +11 -0
  147. package/dist/utils/export.d.ts.map +1 -0
  148. package/dist/utils/export.js +1 -0
  149. package/dist/utils/export.js.map +1 -0
  150. package/dist/utils/hex.d.ts +48 -0
  151. package/dist/utils/hex.d.ts.map +1 -0
  152. package/dist/utils/hex.js +57 -0
  153. package/dist/utils/hex.js.map +1 -0
  154. package/dist/utils/isvalid.d.ts +102 -0
  155. package/dist/utils/isvalid.d.ts.map +1 -0
  156. package/dist/utils/isvalid.js +100 -0
  157. package/dist/utils/isvalid.js.map +1 -0
  158. package/dist/utils/network.d.ts +69 -0
  159. package/dist/utils/network.d.ts.map +1 -0
  160. package/dist/utils/network.js +76 -5
  161. package/dist/utils/network.js.map +1 -0
  162. package/dist/utils/wait.d.ts +52 -0
  163. package/dist/utils/wait.d.ts.map +1 -0
  164. package/dist/utils/wait.js +58 -9
  165. package/dist/utils/wait.js.map +1 -0
  166. package/dist/waterHeater.d.ts +90 -0
  167. package/dist/waterHeater.d.ts.map +1 -0
  168. package/dist/waterHeater.js +62 -2
  169. package/dist/waterHeater.js.map +1 -0
  170. package/npm-shrinkwrap.json +17 -8
  171. 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.0.0
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, MatterbridgeServerDevice, 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';
@@ -67,7 +94,7 @@ import { ThermostatUserInterfaceConfigurationServer } from '@matter/main/behavio
67
94
  import { DeviceEnergyManagementServer } from '@matter/main/behaviors/device-energy-management';
68
95
  export class MatterbridgeEndpoint extends Endpoint {
69
96
  static bridgeMode = '';
70
- static logLevel = "info";
97
+ static logLevel = "info" /* LogLevel.INFO */;
71
98
  log;
72
99
  plugin = undefined;
73
100
  configUrl = undefined;
@@ -83,14 +110,25 @@ export class MatterbridgeEndpoint extends Endpoint {
83
110
  hardwareVersion = undefined;
84
111
  hardwareVersionString = undefined;
85
112
  productUrl = 'https://www.npmjs.com/package/matterbridge';
113
+ // The first device type of the endpoint
86
114
  name = undefined;
87
115
  deviceType;
88
116
  uniqueStorageKey = undefined;
89
117
  tagList = undefined;
118
+ // Maps matter deviceTypes
90
119
  deviceTypes = new Map();
120
+ // Command handler
91
121
  commandHandler = new NamedHandler();
122
+ /**
123
+ * Represents a MatterbridgeEndpoint.
124
+ * @constructor
125
+ * @param {DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>} definition - The DeviceTypeDefinition(s) of the endpoint.
126
+ * @param {MatterbridgeEndpointOptions} [options={}] - The options for the device.
127
+ * @param {boolean} [debug=false] - Debug flag.
128
+ */
92
129
  constructor(definition, options = {}, debug = false) {
93
130
  let deviceTypeList = [];
131
+ // Get the first DeviceTypeDefinition
94
132
  let firstDefinition;
95
133
  if (Array.isArray(definition)) {
96
134
  firstDefinition = definition[0];
@@ -103,6 +141,7 @@ export class MatterbridgeEndpoint extends Endpoint {
103
141
  firstDefinition = definition;
104
142
  deviceTypeList = [{ deviceType: firstDefinition.code, revision: firstDefinition.revision }];
105
143
  }
144
+ // Convert the first DeviceTypeDefinition to an EndpointType.Options
106
145
  const deviceTypeDefinitionV8 = {
107
146
  name: firstDefinition.name.replace('-', '_'),
108
147
  deviceType: firstDefinition.code,
@@ -121,9 +160,11 @@ export class MatterbridgeEndpoint extends Endpoint {
121
160
  behaviors: options.tagList ? SupportedBehaviors(DescriptorServer.with(Descriptor.Feature.TagList)) : {},
122
161
  };
123
162
  const endpointV8 = MutableEndpoint(deviceTypeDefinitionV8);
163
+ // Check if the uniqueStorageKey is valid
124
164
  if (options.uniqueStorageKey && checkNotLatinCharacters(options.uniqueStorageKey)) {
125
165
  options.uniqueStorageKey = generateUniqueId(options.uniqueStorageKey);
126
166
  }
167
+ // Convert the options to an Endpoint.Options
127
168
  const optionsV8 = {
128
169
  id: options.uniqueStorageKey?.replace(/[ .]/g, ''),
129
170
  number: options.endpointId,
@@ -141,16 +182,40 @@ export class MatterbridgeEndpoint extends Endpoint {
141
182
  }
142
183
  else
143
184
  this.deviceTypes.set(firstDefinition.code, firstDefinition);
144
- this.log = new AnsiLogger({ logName: options.uniqueStorageKey ?? 'MatterbridgeEndpoint', logTimestampFormat: 4, logLevel: debug === true ? "debug" : MatterbridgeEndpoint.logLevel });
185
+ // console.log('MatterbridgeEndpoint.option', options);
186
+ // console.log('MatterbridgeEndpoint.endpointV8', endpointV8);
187
+ // console.log('MatterbridgeEndpoint.optionsV8', optionsV8);
188
+ // Create the logger
189
+ this.log = new AnsiLogger({ logName: options.uniqueStorageKey ?? 'MatterbridgeEndpoint', logTimestampFormat: 4 /* TimestampFormat.TIME_MILLIS */, logLevel: debug === true ? "debug" /* LogLevel.DEBUG */ : MatterbridgeEndpoint.logLevel });
145
190
  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}`);
191
+ // Add MatterbridgeBehavior with MatterbridgeBehaviorDevice
146
192
  this.behaviors.require(MatterbridgeServer, { deviceCommand: new MatterbridgeServerDevice(this.log, this.commandHandler, undefined) });
147
193
  }
194
+ /**
195
+ * Loads an instance of the MatterbridgeEndpoint class.
196
+ *
197
+ * @param {DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>} definition - The DeviceTypeDefinition(s) of the device.
198
+ * @param {MatterbridgeEndpointOptions} [options={}] - The options for the device.
199
+ * @param {boolean} [debug=false] - Debug flag.
200
+ * @returns {Promise<MatterbridgeEndpoint>} MatterbridgeEndpoint instance.
201
+ */
148
202
  static async loadInstance(definition, options = {}, debug = false) {
149
203
  return new MatterbridgeEndpoint(definition, options, debug);
150
204
  }
205
+ /**
206
+ * Get all the device types of this endpoint.
207
+ *
208
+ * @returns {DeviceTypeDefinition[]} The device types of this endpoint.
209
+ */
151
210
  getDeviceTypes() {
152
211
  return Array.from(this.deviceTypes.values());
153
212
  }
213
+ /**
214
+ * Checks if the provided cluster server is supported by this endpoint.
215
+ *
216
+ * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to check.
217
+ * @returns {boolean} True if the cluster server is supported, false otherwise.
218
+ */
154
219
  hasClusterServer(cluster) {
155
220
  const behavior = getBehavior(this, cluster);
156
221
  if (behavior)
@@ -158,6 +223,13 @@ export class MatterbridgeEndpoint extends Endpoint {
158
223
  else
159
224
  return false;
160
225
  }
226
+ /**
227
+ * Checks if the provided attribute server is supported for a given cluster of this endpoint.
228
+ *
229
+ * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to check.
230
+ * @param {string} attribute - The attribute name to check.
231
+ * @returns {boolean} True if the attribute server is supported, false otherwise.
232
+ */
161
233
  hasAttributeServer(cluster, attribute) {
162
234
  const behavior = getBehavior(this, cluster);
163
235
  if (!behavior || !this.behaviors.supported[behavior.id])
@@ -166,82 +238,228 @@ export class MatterbridgeEndpoint extends Endpoint {
166
238
  const defaults = this.behaviors.defaultsFor(behavior);
167
239
  return lowercaseFirstLetter(attribute) in options || lowercaseFirstLetter(attribute) in defaults;
168
240
  }
241
+ /**
242
+ * Retrieves the initial options for the provided cluster server.
243
+ *
244
+ * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to get options for.
245
+ * @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.
246
+ */
169
247
  getClusterServerOptions(cluster) {
170
248
  const behavior = getBehavior(this, cluster);
171
249
  if (!behavior)
172
250
  return undefined;
173
251
  return this.behaviors.optionsFor(behavior);
174
252
  }
253
+ /**
254
+ * Retrieves the value of the provided attribute from the given cluster.
255
+ *
256
+ * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to retrieve the attribute from.
257
+ * @param {string} attribute - The name of the attribute to retrieve.
258
+ * @param {AnsiLogger} [log] - Optional logger for error and info messages.
259
+ * @returns {any} The value of the attribute, or undefined if the attribute is not found.
260
+ */
261
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
175
262
  getAttribute(cluster, attribute, log) {
176
263
  return getAttribute(this, cluster, attribute, log);
177
264
  }
265
+ /**
266
+ * Sets the value of an attribute on a cluster server.
267
+ *
268
+ * @param {Behavior.Type | ClusterType | ClusterId | string} clusterId - The ID of the cluster.
269
+ * @param {string} attribute - The name of the attribute.
270
+ * @param {boolean | number | bigint | string | object | null} value - The value to set for the attribute.
271
+ * @param {AnsiLogger} [log] - (Optional) The logger to use for logging errors and information.
272
+ * @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the attribute was successfully set.
273
+ */
178
274
  async setAttribute(clusterId, attribute, value, log) {
179
275
  return await setAttribute(this, clusterId, attribute, value, log);
180
276
  }
277
+ /**
278
+ * Update the value of an attribute on a cluster server only if the value is different.
279
+ *
280
+ * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to set the attribute on.
281
+ * @param {string} attribute - The name of the attribute.
282
+ * @param {boolean | number | bigint | string | object | null} value - The value to set for the attribute.
283
+ * @param {AnsiLogger} [log] - (Optional) The logger to use for logging the update. Errors are logged to the endpoint logger.
284
+ * @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the attribute was successfully set.
285
+ */
181
286
  async updateAttribute(cluster, attribute, value, log) {
182
287
  return await updateAttribute(this, cluster, attribute, value, log);
183
288
  }
289
+ /**
290
+ * Subscribes to the provided attribute on a cluster.
291
+ *
292
+ * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to subscribe the attribute to.
293
+ * @param {string} attribute - The name of the attribute to subscribe to.
294
+ * @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.
295
+ * @param {AnsiLogger} [log] - Optional logger for logging errors and information.
296
+ * @returns {Promise<boolean>} - A boolean indicating whether the subscription was successful.
297
+ *
298
+ * @remarks The listener function (cannot be async) will receive three parameters:
299
+ * - `newValue`: The new value of the attribute.
300
+ * - `oldValue`: The old value of the attribute.
301
+ * - `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.
302
+ */
303
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
184
304
  async subscribeAttribute(cluster, attribute, listener, log) {
185
305
  return await subscribeAttribute(this, cluster, attribute, listener, log);
186
306
  }
307
+ /**
308
+ * Triggers an event on the specified cluster.
309
+ * @param {ClusterId} cluster - The ID of the cluster.
310
+ * @param {string} event - The name of the event to trigger.
311
+ * @param {Record<string, boolean | number | bigint | string | object | undefined | null>} payload - The payload to pass to the event.
312
+ * @param {AnsiLogger} [log] - Optional logger for logging information.
313
+ * @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the event was successfully triggered.
314
+ */
187
315
  async triggerEvent(cluster, event, payload, log) {
188
316
  return await triggerEvent(this, cluster, event, payload, log);
189
317
  }
318
+ /**
319
+ * Adds cluster servers from the provided server list.
320
+ *
321
+ * @param {ClusterId[]} serverList - The list of cluster IDs to add.
322
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
323
+ */
190
324
  addClusterServers(serverList) {
191
325
  addClusterServers(this, serverList);
192
326
  return this;
193
327
  }
328
+ /**
329
+ * Adds a fixed label to the FixedLabel cluster. If the cluster server is not present, it will be added.
330
+ *
331
+ * @param {string} label - The label to add.
332
+ * @param {string} value - The value of the label.
333
+ * @returns {Promise<this>} The current MatterbridgeEndpoint instance for chaining.
334
+ */
194
335
  async addFixedLabel(label, value) {
195
336
  await addFixedLabel(this, label, value);
196
337
  return this;
197
338
  }
339
+ /**
340
+ * Adds a user label to the UserLabel cluster. If the cluster server is not present, it will be added.
341
+ *
342
+ * @param {string} label - The label to add.
343
+ * @param {string} value - The value of the label.
344
+ * @returns {Promise<this>} The current MatterbridgeEndpoint instance for chaining.
345
+ */
198
346
  async addUserLabel(label, value) {
199
347
  await addUserLabel(this, label, value);
200
348
  return this;
201
349
  }
350
+ /**
351
+ * Adds a command handler for the specified command.
352
+ *
353
+ * @param {keyof MatterbridgeEndpointCommands} command - The command to add the handler for.
354
+ * @param {HandlerFunction} handler - The handler function to execute when the command is received.
355
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
356
+ */
202
357
  addCommandHandler(command, handler) {
203
358
  this.commandHandler.addHandler(command, handler);
204
359
  return this;
205
360
  }
361
+ /**
362
+ * Execute the command handler for the specified command. Used ONLY in Jest tests.
363
+ *
364
+ * @param {keyof MatterbridgeEndpointCommands} command - The command to execute.
365
+ * @param {Record<string, boolean | number | bigint | string | object | null>} [request] - The optional request to pass to the handler function.
366
+ *
367
+ * @deprecated Used ONLY in Jest tests.
368
+ */
206
369
  async executeCommandHandler(command, request) {
207
370
  await this.commandHandler.executeHandler(command, { request });
208
371
  }
372
+ /**
373
+ * Invokes a behavior command on the specified cluster. Used ONLY in Jest tests.
374
+ *
375
+ * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to invoke the command on.
376
+ * @param {string} command - The command to invoke.
377
+ * @param {Record<string, boolean | number | bigint | string | object | null>} [params] - The optional parameters to pass to the command.
378
+ *
379
+ * @deprecated Used ONLY in Jest tests.
380
+ */
209
381
  async invokeBehaviorCommand(cluster, command, params) {
210
382
  await invokeBehaviorCommand(this, cluster, command, params);
211
383
  }
384
+ /**
385
+ * Adds the required cluster servers (only if they are not present) for the device types of the specified endpoint.
386
+ *
387
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
388
+ */
212
389
  addRequiredClusterServers() {
213
390
  addRequiredClusterServers(this);
214
391
  return this;
215
392
  }
393
+ /**
394
+ * Adds the optional cluster servers (only if they are not present) for the device types of the specified endpoint.
395
+ *
396
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
397
+ */
216
398
  addOptionalClusterServers() {
217
399
  addOptionalClusterServers(this);
218
400
  return this;
219
401
  }
402
+ /**
403
+ * Retrieves all cluster servers.
404
+ *
405
+ * @returns {Behavior.Type[]} An array of all cluster servers.
406
+ */
220
407
  getAllClusterServers() {
221
408
  return Object.values(this.behaviors.supported);
222
409
  }
410
+ /**
411
+ * Retrieves the names of all cluster servers.
412
+ *
413
+ * @returns {string[]} An array of all cluster server names.
414
+ */
223
415
  getAllClusterServerNames() {
224
416
  return Object.keys(this.behaviors.supported);
225
417
  }
418
+ /**
419
+ * Iterates over each attribute of each cluster server of the device state and calls the provided callback function.
420
+ *
421
+ * @param {Function} callback - The callback function to call with the cluster name, cluster id, attribute name, attribute id and attribute value.
422
+ */
226
423
  forEachAttribute(callback) {
227
424
  if (!this.lifecycle.isReady || this.construction.status !== Lifecycle.Status.Active)
228
425
  return;
229
426
  for (const [clusterName, clusterAttributes] of Object.entries(this.state)) {
427
+ // Skip if the key / cluster name is a number, cause they are double indexed.
230
428
  if (!isNaN(Number(clusterName)))
231
429
  continue;
232
430
  for (const [attributeName, attributeValue] of Object.entries(clusterAttributes)) {
431
+ // Skip if the behavior has no associated cluster (i.e. matterbridge server)
233
432
  const clusterId = getClusterId(this, clusterName);
234
433
  if (clusterId === undefined) {
434
+ // this.log.debug(`***forEachAttribute: cluster ${clusterName} not found`);
235
435
  continue;
236
436
  }
437
+ // Skip if the attribute is not present in the ClusterBehavior.Type. Also skip if the attribute it is an internal state.
237
438
  const attributeId = getAttributeId(this, clusterName, attributeName);
238
439
  if (attributeId === undefined) {
440
+ // this.log.debug(`***forEachAttribute: attribute ${clusterName}.${attributeName} not found`);
239
441
  continue;
240
442
  }
241
443
  callback(clusterName, clusterId, attributeName, attributeId, attributeValue);
242
444
  }
243
445
  }
244
446
  }
447
+ /**
448
+ * Adds a child endpoint with the specified device types and options.
449
+ * If the child endpoint is not already present, it will be created and added.
450
+ * If the child endpoint is already present, the existing child endpoint will be returned.
451
+ *
452
+ * @param {string} endpointName - The name of the new endpoint to add.
453
+ * @param {DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>} definition - The device types to add.
454
+ * @param {MatterbridgeEndpointOptions} [options={}] - The options for the endpoint.
455
+ * @param {boolean} [debug=false] - Whether to enable debug logging.
456
+ * @returns {MatterbridgeEndpoint} - The child endpoint that was found or added.
457
+ *
458
+ * @example
459
+ * ```typescript
460
+ * const endpoint = device.addChildDeviceType('Temperature', [temperatureSensor], { tagList: [{ mfgCode: null, namespaceId: LocationTag.Indoor.namespaceId, tag: LocationTag.Indoor.tag, label: null }] }, true);
461
+ * ```
462
+ */
245
463
  addChildDeviceType(endpointName, definition, options = {}, debug = false) {
246
464
  this.log.debug(`addChildDeviceType: ${CYAN}${endpointName}${db}`);
247
465
  let alreadyAdded = false;
@@ -281,6 +499,23 @@ export class MatterbridgeEndpoint extends Endpoint {
281
499
  }
282
500
  return child;
283
501
  }
502
+ /**
503
+ * Adds a child endpoint with one or more device types with the required cluster servers and the specified cluster servers.
504
+ * If the child endpoint is not already present in the childEndpoints, it will be added.
505
+ * If the child endpoint is already present in the childEndpoints, the device types and cluster servers will be added to the existing child endpoint.
506
+ *
507
+ * @param {string} endpointName - The name of the new enpoint to add.
508
+ * @param {DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>} definition - The device types to add.
509
+ * @param {ClusterId[]} [serverList=[]] - The list of cluster IDs to include.
510
+ * @param {MatterbridgeEndpointOptions} [options={}] - The options for the device.
511
+ * @param {boolean} [debug=false] - Whether to enable debug logging.
512
+ * @returns {MatterbridgeEndpoint} - The child endpoint that was found or added.
513
+ *
514
+ * @example
515
+ * ```typescript
516
+ * const endpoint = device.addChildDeviceTypeWithClusterServer('Temperature', [temperatureSensor], [], { tagList: [{ mfgCode: null, namespaceId: LocationTag.Indoor.namespaceId, tag: LocationTag.Indoor.tag, label: null }] }, true);
517
+ * ```
518
+ */
284
519
  addChildDeviceTypeWithClusterServer(endpointName, definition, serverList = [], options = {}, debug = false) {
285
520
  this.log.debug(`addChildDeviceTypeWithClusterServer: ${CYAN}${endpointName}${db}`);
286
521
  let alreadyAdded = false;
@@ -343,15 +578,38 @@ export class MatterbridgeEndpoint extends Endpoint {
343
578
  }
344
579
  return child;
345
580
  }
581
+ /**
582
+ * Retrieves a child endpoint by its name.
583
+ *
584
+ * @param {string} endpointName - The name of the endpoint to retrieve.
585
+ * @returns {Endpoint | undefined} The child endpoint with the specified name, or undefined if not found.
586
+ */
346
587
  getChildEndpointByName(endpointName) {
347
588
  return this.parts.find((part) => part.id === endpointName);
348
589
  }
590
+ /**
591
+ * Retrieves a child endpoint by its EndpointNumber.
592
+ *
593
+ * @param {EndpointNumber} endpointNumber - The EndpointNumber of the endpoint to retrieve.
594
+ * @returns {MatterbridgeEndpoint | undefined} The child endpoint with the specified EndpointNumber, or undefined if not found.
595
+ */
349
596
  getChildEndpoint(endpointNumber) {
350
597
  return this.parts.find((part) => part.number === endpointNumber);
351
598
  }
599
+ /**
600
+ * Get all the child endpoints of this endpoint.
601
+ *
602
+ * @returns {MatterbridgeEndpoint[]} The child endpoints.
603
+ */
352
604
  getChildEndpoints() {
353
605
  return Array.from(this.parts);
354
606
  }
607
+ /**
608
+ * Serializes the Matterbridge device into a serialized object.
609
+ *
610
+ * @param pluginName - The name of the plugin.
611
+ * @returns The serialized Matterbridge device object.
612
+ */
355
613
  static serialize(device) {
356
614
  if (!device.serialNumber || !device.deviceName || !device.uniqueId)
357
615
  return;
@@ -374,9 +632,15 @@ export class MatterbridgeEndpoint extends Endpoint {
374
632
  serialized.clusterServersId.push(BridgedDeviceBasicInformation.Cluster.id);
375
633
  if (behaviorName === 'powerSource')
376
634
  serialized.clusterServersId.push(PowerSource.Cluster.id);
635
+ // serialized.clusterServersId.push(this.behaviors.supported[behaviorName]cluster.id);
377
636
  });
378
637
  return serialized;
379
638
  }
639
+ /**
640
+ * Deserializes the device into a serialized object.
641
+ *
642
+ * @returns The deserialized MatterbridgeDevice.
643
+ */
380
644
  static deserialize(serializedDevice) {
381
645
  const device = new MatterbridgeEndpoint(serializedDevice.deviceTypes, { uniqueStorageKey: serializedDevice.endpointName, endpointId: serializedDevice.endpoint }, false);
382
646
  device.plugin = serializedDevice.pluginName;
@@ -392,9 +656,16 @@ export class MatterbridgeEndpoint extends Endpoint {
392
656
  device.createDefaultBridgedDeviceBasicInformationClusterServer(serializedDevice.deviceName, serializedDevice.serialNumber, serializedDevice.vendorId ?? 0xfff1, serializedDevice.vendorName ?? 'Matterbridge', serializedDevice.productName ?? 'Matterbridge device');
393
657
  else if (clusterId === PowerSource.Cluster.id)
394
658
  device.createDefaultPowerSourceWiredClusterServer();
659
+ // else addClusterServerFromList(device, [clusterId]);
395
660
  }
396
661
  return device;
397
662
  }
663
+ /**
664
+ * Creates a default power source wired cluster server.
665
+ *
666
+ * @param wiredCurrentType - The type of wired current (default: PowerSource.WiredCurrentType.Ac)
667
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
668
+ */
398
669
  createDefaultPowerSourceWiredClusterServer(wiredCurrentType = PowerSource.WiredCurrentType.Ac) {
399
670
  this.behaviors.require(PowerSourceServer.with(PowerSource.Feature.Wired), {
400
671
  wiredCurrentType,
@@ -405,6 +676,16 @@ export class MatterbridgeEndpoint extends Endpoint {
405
676
  });
406
677
  return this;
407
678
  }
679
+ /**
680
+ * Creates a default power source replaceable battery cluster server.
681
+ *
682
+ * @param batPercentRemaining - The remaining battery percentage (default: 100).
683
+ * @param batChargeLevel - The battery charge level (default: PowerSource.BatChargeLevel.Ok).
684
+ * @param batVoltage - The battery voltage (default: 1500).
685
+ * @param batReplacementDescription - The battery replacement description (default: 'Battery type').
686
+ * @param batQuantity - The battery quantity (default: 1).
687
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
688
+ */
408
689
  createDefaultPowerSourceReplaceableBatteryClusterServer(batPercentRemaining = 100, batChargeLevel = PowerSource.BatChargeLevel.Ok, batVoltage = 1500, batReplacementDescription = 'Battery type', batQuantity = 1) {
409
690
  this.behaviors.require(PowerSourceServer.with(PowerSource.Feature.Battery, PowerSource.Feature.Replaceable), {
410
691
  status: PowerSource.PowerSourceStatus.Active,
@@ -422,6 +703,14 @@ export class MatterbridgeEndpoint extends Endpoint {
422
703
  });
423
704
  return this;
424
705
  }
706
+ /**
707
+ * Creates a default power source rechargeable battery cluster server.
708
+ *
709
+ * @param batPercentRemaining - The remaining battery percentage (default: 100).
710
+ * @param batChargeLevel - The battery charge level (default: PowerSource.BatChargeLevel.Ok).
711
+ * @param batVoltage - The battery voltage (default: 1500).
712
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
713
+ */
425
714
  createDefaultPowerSourceRechargeableBatteryClusterServer(batPercentRemaining = 100, batChargeLevel = PowerSource.BatChargeLevel.Ok, batVoltage = 1500) {
426
715
  this.behaviors.require(PowerSourceServer.with(PowerSource.Feature.Battery, PowerSource.Feature.Rechargeable), {
427
716
  status: PowerSource.PowerSourceStatus.Active,
@@ -440,6 +729,21 @@ export class MatterbridgeEndpoint extends Endpoint {
440
729
  });
441
730
  return this;
442
731
  }
732
+ /**
733
+ * Setup the default Basic Information Cluster Server attributes for the server node.
734
+ *
735
+ * @param deviceName - The name of the device.
736
+ * @param serialNumber - The serial number of the device.
737
+ * @param vendorId - The vendor ID of the device.
738
+ * @param vendorName - The vendor name of the device.
739
+ * @param productId - The product ID of the device.
740
+ * @param productName - The product name of the device.
741
+ * @param softwareVersion - The software version of the device. Default is 1.
742
+ * @param softwareVersionString - The software version string of the device. Default is 'v.1.0.0'.
743
+ * @param hardwareVersion - The hardware version of the device. Default is 1.
744
+ * @param hardwareVersionString - The hardware version string of the device. Default is 'v.1.0.0'.
745
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
746
+ */
443
747
  createDefaultBasicInformationClusterServer(deviceName, serialNumber, vendorId, vendorName, productId, productName, softwareVersion = 1, softwareVersionString = '1.0.0', hardwareVersion = 1, hardwareVersionString = '1.0.0') {
444
748
  this.log.logName = deviceName;
445
749
  this.deviceName = deviceName;
@@ -463,6 +767,22 @@ export class MatterbridgeEndpoint extends Endpoint {
463
767
  }
464
768
  return this;
465
769
  }
770
+ /**
771
+ * Creates a default BridgedDeviceBasicInformationClusterServer for the aggregator endpoints.
772
+ *
773
+ * @param deviceName - The name of the device.
774
+ * @param serialNumber - The serial number of the device.
775
+ * @param vendorId - The vendor ID of the device.
776
+ * @param vendorName - The name of the vendor.
777
+ * @param productName - The name of the product.
778
+ * @param softwareVersion - The software version of the device. Default is 1.
779
+ * @param softwareVersionString - The software version string of the device. Default is 'v.1.0.0'.
780
+ * @param hardwareVersion - The hardware version of the device. Default is 1.
781
+ * @param hardwareVersionString - The hardware version string of the device. Default is 'v.1.0.0'.
782
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
783
+ *
784
+ * @remarks The bridgedNode device type must be added to the deviceTypeList of the Descriptor cluster.
785
+ */
466
786
  createDefaultBridgedDeviceBasicInformationClusterServer(deviceName, serialNumber, vendorId, vendorName, productName, softwareVersion = 1, softwareVersionString = '1.0.0', hardwareVersion = 1, hardwareVersionString = '1.0.0') {
467
787
  this.log.logName = deviceName;
468
788
  this.deviceName = deviceName;
@@ -479,7 +799,7 @@ export class MatterbridgeEndpoint extends Endpoint {
479
799
  this.behaviors.require(BridgedDeviceBasicInformationServer.enable({
480
800
  events: { leave: true, reachableChanged: true },
481
801
  }), {
482
- vendorId: vendorId !== undefined ? VendorId(vendorId) : undefined,
802
+ vendorId: vendorId !== undefined ? VendorId(vendorId) : undefined, // 4874
483
803
  vendorName: vendorName.slice(0, 32),
484
804
  productName: productName.slice(0, 32),
485
805
  productUrl: this.productUrl.slice(0, 256),
@@ -495,6 +815,13 @@ export class MatterbridgeEndpoint extends Endpoint {
495
815
  });
496
816
  return this;
497
817
  }
818
+ /**
819
+ * Creates a default identify cluster server with the specified identify time and type.
820
+ *
821
+ * @param {number} [identifyTime=0] - The time to identify the server. Defaults to 0.
822
+ * @param {Identify.IdentifyType} [identifyType=Identify.IdentifyType.None] - The type of identification. Defaults to Identify.IdentifyType.None.
823
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
824
+ */
498
825
  createDefaultIdentifyClusterServer(identifyTime = 0, identifyType = Identify.IdentifyType.None) {
499
826
  this.behaviors.require(MatterbridgeIdentifyServer, {
500
827
  identifyTime,
@@ -502,14 +829,34 @@ export class MatterbridgeEndpoint extends Endpoint {
502
829
  });
503
830
  return this;
504
831
  }
832
+ /**
833
+ * Creates a default groups cluster server.
834
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
835
+ */
505
836
  createDefaultGroupsClusterServer() {
506
837
  this.behaviors.require(GroupsServer);
507
838
  return this;
508
839
  }
840
+ /**
841
+ * Creates a default scenes management cluster server.
842
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
843
+ *
844
+ * @remarks The scenes management cluster server is still provisional and so not yet implemented.
845
+ */
509
846
  createDefaultScenesClusterServer() {
510
847
  this.behaviors.require(ScenesManagementServer);
511
848
  return this;
512
849
  }
850
+ /**
851
+ * Creates a default OnOff cluster server for light devices with feature Lighting.
852
+ *
853
+ * @param {boolean} [onOff=false] - The initial state of the OnOff cluster.
854
+ * @param {boolean} [globalSceneControl=false] - The global scene control state.
855
+ * @param {number} [onTime=0] - The on time value.
856
+ * @param {number} [offWaitTime=0] - The off wait time value.
857
+ * @param {OnOff.StartUpOnOff | null} [startUpOnOff=null] - The start-up OnOff state. Null means previous state.
858
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
859
+ */
513
860
  createDefaultOnOffClusterServer(onOff = false, globalSceneControl = false, onTime = 0, offWaitTime = 0, startUpOnOff = null) {
514
861
  this.behaviors.require(MatterbridgeOnOffServer.with(OnOff.Feature.Lighting), {
515
862
  onOff,
@@ -520,24 +867,52 @@ export class MatterbridgeEndpoint extends Endpoint {
520
867
  });
521
868
  return this;
522
869
  }
870
+ /**
871
+ * Creates an OnOff cluster server without features.
872
+ *
873
+ * @param {boolean} [onOff=false] - The initial state of the OnOff cluster.
874
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
875
+ */
523
876
  createOnOffClusterServer(onOff = false) {
524
877
  this.behaviors.require(MatterbridgeOnOffServer, {
525
878
  onOff,
526
879
  });
527
880
  return this;
528
881
  }
882
+ /**
883
+ * Creates a DeadFront OnOff cluster server with feature DeadFrontBehavior.
884
+ *
885
+ * @param {boolean} [onOff=false] - The initial state of the OnOff cluster.
886
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
887
+ */
529
888
  createDeadFrontOnOffClusterServer(onOff = false) {
530
889
  this.behaviors.require(MatterbridgeOnOffServer.with(OnOff.Feature.DeadFrontBehavior), {
531
890
  onOff,
532
891
  });
533
892
  return this;
534
893
  }
894
+ /**
895
+ * Creates an OffOnly OnOff cluster server with feature OffOnly.
896
+ *
897
+ * @param {boolean} [onOff=false] - The initial state of the OnOff cluster.
898
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
899
+ */
535
900
  createOffOnlyOnOffClusterServer(onOff = false) {
536
901
  this.behaviors.require(MatterbridgeOnOffServer.with(OnOff.Feature.OffOnly), {
537
902
  onOff,
538
903
  });
539
904
  return this;
540
905
  }
906
+ /**
907
+ * Creates a default level control cluster server for light devices with feature OnOff and Lighting.
908
+ *
909
+ * @param {number} [currentLevel=254] - The current level (default: 254).
910
+ * @param {number} [minLevel=1] - The minimum level (default: 1).
911
+ * @param {number} [maxLevel=254] - The maximum level (default: 254).
912
+ * @param {number | null} [onLevel=null] - The on level (default: null).
913
+ * @param {number | null} [startUpCurrentLevel=null] - The startUp on level (default: null).
914
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
915
+ */
541
916
  createDefaultLevelControlClusterServer(currentLevel = 254, minLevel = 1, maxLevel = 254, onLevel = null, startUpCurrentLevel = null) {
542
917
  this.behaviors.require(MatterbridgeLevelControlServer.with(LevelControl.Feature.OnOff, LevelControl.Feature.Lighting), {
543
918
  currentLevel,
@@ -553,6 +928,13 @@ export class MatterbridgeEndpoint extends Endpoint {
553
928
  });
554
929
  return this;
555
930
  }
931
+ /**
932
+ * Creates a level control cluster server without features.
933
+ *
934
+ * @param {number} [currentLevel=254] - The current level (default: 254).
935
+ * @param {number | null} [onLevel=null] - The on level (default: null).
936
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
937
+ */
556
938
  createLevelControlClusterServer(currentLevel = 254, onLevel = null) {
557
939
  this.behaviors.require(MatterbridgeLevelControlServer, {
558
940
  currentLevel,
@@ -564,6 +946,25 @@ export class MatterbridgeEndpoint extends Endpoint {
564
946
  });
565
947
  return this;
566
948
  }
949
+ /**
950
+ * Creates a default color control cluster server with features Xy, HueSaturation and ColorTemperature.
951
+ *
952
+ * @param currentX - The current X value (range 0-65279).
953
+ * @param currentY - The current Y value (range 0-65279).
954
+ * @param currentHue - The current hue value (range: 0-254).
955
+ * @param currentSaturation - The current saturation value (range: 0-254).
956
+ * @param colorTemperatureMireds - The color temperature in mireds (default range 147-500).
957
+ * @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds (default range 147).
958
+ * @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds (default range 500).
959
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
960
+ *
961
+ * @remarks colorMode and enhancedColorMode persist across restarts.
962
+ * @remarks currentHue and currentSaturation persist across restarts.
963
+ * @remarks currentX and currentY persist across restarts.
964
+ * @remarks colorTemperatureMireds persists across restarts.
965
+ * @remarks startUpColorTemperatureMireds persists across restarts.
966
+ * @remarks coupleColorTempToLevelMinMireds persists across restarts.
967
+ */
567
968
  createDefaultColorControlClusterServer(currentX = 0, currentY = 0, currentHue = 0, currentSaturation = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
568
969
  this.behaviors.require(MatterbridgeColorControlServer.with(ColorControl.Feature.Xy, ColorControl.Feature.HueSaturation, ColorControl.Feature.ColorTemperature), {
569
970
  colorMode: ColorControl.ColorMode.CurrentHueAndCurrentSaturation,
@@ -586,6 +987,25 @@ export class MatterbridgeEndpoint extends Endpoint {
586
987
  });
587
988
  return this;
588
989
  }
990
+ /**
991
+ * Creates a Xy color control cluster server with feature Xy and ColorTemperature.
992
+ *
993
+ * @param currentX - The current X value.
994
+ * @param currentY - The current Y value.
995
+ * @param colorTemperatureMireds - The color temperature in mireds.
996
+ * @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds.
997
+ * @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds.
998
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
999
+ *
1000
+ * @remarks
1001
+ * From zigbee to matter = Math.max(Math.min(Math.round(x * 65536), 65279), 0)
1002
+ *
1003
+ * @remarks colorMode and enhancedColorMode persist across restarts.
1004
+ * @remarks currentX and currentY persist across restarts.
1005
+ * @remarks colorTemperatureMireds persists across restarts.
1006
+ * @remarks startUpColorTemperatureMireds persists across restarts.
1007
+ * @remarks coupleColorTempToLevelMinMireds persists across restarts.
1008
+ */
589
1009
  createXyColorControlClusterServer(currentX = 0, currentY = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
590
1010
  this.behaviors.require(MatterbridgeColorControlServer.with(ColorControl.Feature.Xy, ColorControl.Feature.ColorTemperature), {
591
1011
  colorMode: ColorControl.ColorMode.CurrentXAndCurrentY,
@@ -606,6 +1026,22 @@ export class MatterbridgeEndpoint extends Endpoint {
606
1026
  });
607
1027
  return this;
608
1028
  }
1029
+ /**
1030
+ * Creates a default hue and saturation control cluster server with feature HueSaturation and ColorTemperature.
1031
+ *
1032
+ * @param currentHue - The current hue value.
1033
+ * @param currentSaturation - The current saturation value.
1034
+ * @param colorTemperatureMireds - The color temperature in mireds.
1035
+ * @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds.
1036
+ * @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds.
1037
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1038
+ *
1039
+ * @remarks colorMode and enhancedColorMode persist across restarts.
1040
+ * @remarks currentHue and currentSaturation persist across restarts.
1041
+ * @remarks colorTemperatureMireds persists across restarts.
1042
+ * @remarks startUpColorTemperatureMireds persists across restarts.
1043
+ * @remarks coupleColorTempToLevelMinMireds persists across restarts.
1044
+ */
609
1045
  createHsColorControlClusterServer(currentHue = 0, currentSaturation = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
610
1046
  this.behaviors.require(MatterbridgeColorControlServer.with(ColorControl.Feature.HueSaturation, ColorControl.Feature.ColorTemperature), {
611
1047
  colorMode: ColorControl.ColorMode.CurrentHueAndCurrentSaturation,
@@ -626,6 +1062,20 @@ export class MatterbridgeEndpoint extends Endpoint {
626
1062
  });
627
1063
  return this;
628
1064
  }
1065
+ /**
1066
+ * Creates a color temperature color control cluster server with feature ColorTemperature.
1067
+ * This cluster server is used for devices that only support color temperature control.
1068
+ *
1069
+ * @param colorTemperatureMireds - The color temperature in mireds. Defaults to 250.
1070
+ * @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds. Defaults to 147.
1071
+ * @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds. Defaults to 500.
1072
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1073
+ *
1074
+ * @remarks colorMode and enhancedColorMode persist across restarts.
1075
+ * @remarks colorTemperatureMireds persists across restarts.
1076
+ * @remarks startUpColorTemperatureMireds persists across restarts.
1077
+ * @remarks coupleColorTempToLevelMinMireds persists across restarts.
1078
+ */
629
1079
  createCtColorControlClusterServer(colorTemperatureMireds = 250, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
630
1080
  this.behaviors.require(MatterbridgeColorControlServer.with(ColorControl.Feature.ColorTemperature), {
631
1081
  colorMode: ColorControl.ColorMode.ColorTemperatureMireds,
@@ -644,15 +1094,34 @@ export class MatterbridgeEndpoint extends Endpoint {
644
1094
  });
645
1095
  return this;
646
1096
  }
1097
+ /**
1098
+ * Configures the color control mode for the device.
1099
+ *
1100
+ * @param {ColorControl.ColorMode} colorMode - The color mode to set.
1101
+ *
1102
+ * @remarks colorMode and enhancedColorMode persist across restarts.
1103
+ */
647
1104
  async configureColorControlMode(colorMode) {
648
1105
  if (isValidNumber(colorMode, ColorControl.ColorMode.CurrentHueAndCurrentSaturation, ColorControl.ColorMode.ColorTemperatureMireds)) {
649
1106
  await this.setAttribute(ColorControl.Cluster.id, 'colorMode', colorMode, this.log);
650
1107
  await this.setAttribute(ColorControl.Cluster.id, 'enhancedColorMode', colorMode, this.log);
651
1108
  }
652
1109
  }
1110
+ /**
1111
+ * Creates a default window covering cluster server with feature Lift and PositionAwareLift.
1112
+ *
1113
+ * @param {number} positionPercent100ths - The position percentage in 100ths (0-10000). Defaults to 0. Matter uses 10000 = fully closed 0 = fully opened.
1114
+ * @param {WindowCovering.WindowCoveringType} type - The type of window covering (default: WindowCovering.WindowCoveringType.Rollershade). Must support feature Lift.
1115
+ * @param {WindowCovering.EndProductType} endProductType - The end product type (default: WindowCovering.EndProductType.RollerShade). Must support feature Lift.
1116
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1117
+ *
1118
+ * @remarks mode attributes is writable and persists across restarts.
1119
+ * currentPositionLiftPercent100ths persists across restarts.
1120
+ * configStatus attributes persists across restarts.
1121
+ */
653
1122
  createDefaultWindowCoveringClusterServer(positionPercent100ths, type = WindowCovering.WindowCoveringType.Rollershade, endProductType = WindowCovering.EndProductType.RollerShade) {
654
1123
  this.behaviors.require(MatterbridgeLiftWindowCoveringServer.with(WindowCovering.Feature.Lift, WindowCovering.Feature.PositionAwareLift), {
655
- type,
1124
+ type, // Must support feature Lift
656
1125
  numberOfActuationsLift: 0,
657
1126
  configStatus: {
658
1127
  operational: true,
@@ -660,20 +1129,33 @@ export class MatterbridgeEndpoint extends Endpoint {
660
1129
  liftMovementReversed: false,
661
1130
  liftPositionAware: true,
662
1131
  tiltPositionAware: false,
663
- liftEncoderControlled: false,
664
- tiltEncoderControlled: false,
1132
+ liftEncoderControlled: false, // 0 = Timer Controlled 1 = Encoder Controlled
1133
+ tiltEncoderControlled: false, // 0 = Timer Controlled 1 = Encoder Controlled
665
1134
  },
666
1135
  operationalStatus: { global: WindowCovering.MovementStatus.Stopped, lift: WindowCovering.MovementStatus.Stopped, tilt: WindowCovering.MovementStatus.Stopped },
667
- endProductType,
1136
+ endProductType, // Must support feature Lift
668
1137
  mode: { motorDirectionReversed: false, calibrationMode: false, maintenanceMode: false, ledFeedback: false },
669
- targetPositionLiftPercent100ths: positionPercent100ths ?? 0,
670
- currentPositionLiftPercent100ths: positionPercent100ths ?? 0,
1138
+ targetPositionLiftPercent100ths: positionPercent100ths ?? 0, // 0 Fully open 10000 fully closed
1139
+ currentPositionLiftPercent100ths: positionPercent100ths ?? 0, // 0 Fully open 10000 fully closed
671
1140
  });
672
1141
  return this;
673
1142
  }
1143
+ /**
1144
+ * Creates a default window covering cluster server with features Lift, PositionAwareLift, Tilt, PositionAwareTilt.
1145
+ *
1146
+ * @param {number} positionLiftPercent100ths - The lift position percentage in 100ths (0-10000). Defaults to 0. Matter uses 10000 = fully closed 0 = fully opened.
1147
+ * @param {number} positionTiltPercent100ths - The tilt position percentage in 100ths (0-10000). Defaults to 0. Matter uses 10000 = fully closed 0 = fully opened.
1148
+ * @param {WindowCovering.WindowCoveringType} type - The type of window covering (default: WindowCovering.WindowCoveringType.TiltBlindLift). Must support features Lift and Tilt.
1149
+ * @param {WindowCovering.EndProductType} endProductType - The end product type (default: WindowCovering.EndProductType.InteriorBlind). Must support features Lift and Tilt.
1150
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1151
+ *
1152
+ * @remarks mode attributes is writable and persists across restarts.
1153
+ * currentPositionTiltPercent100ths persists across restarts.
1154
+ * configStatus attributes persists across restarts.
1155
+ */
674
1156
  createDefaultLiftTiltWindowCoveringClusterServer(positionLiftPercent100ths, positionTiltPercent100ths, type = WindowCovering.WindowCoveringType.TiltBlindLift, endProductType = WindowCovering.EndProductType.InteriorBlind) {
675
1157
  this.behaviors.require(MatterbridgeLiftTiltWindowCoveringServer.with(WindowCovering.Feature.Lift, WindowCovering.Feature.PositionAwareLift, WindowCovering.Feature.Tilt, WindowCovering.Feature.PositionAwareTilt), {
676
- type,
1158
+ type, // Must support features Lift and Tilt
677
1159
  numberOfActuationsLift: 0,
678
1160
  numberOfActuationsTilt: 0,
679
1161
  configStatus: {
@@ -682,19 +1164,23 @@ export class MatterbridgeEndpoint extends Endpoint {
682
1164
  liftMovementReversed: false,
683
1165
  liftPositionAware: true,
684
1166
  tiltPositionAware: true,
685
- liftEncoderControlled: false,
686
- tiltEncoderControlled: false,
1167
+ liftEncoderControlled: false, // 0 = Timer Controlled 1 = Encoder Controlled
1168
+ tiltEncoderControlled: false, // 0 = Timer Controlled 1 = Encoder Controlled
687
1169
  },
688
1170
  operationalStatus: { global: WindowCovering.MovementStatus.Stopped, lift: WindowCovering.MovementStatus.Stopped, tilt: WindowCovering.MovementStatus.Stopped },
689
- endProductType,
1171
+ endProductType, // Must support features Lift and Tilt
690
1172
  mode: { motorDirectionReversed: false, calibrationMode: false, maintenanceMode: false, ledFeedback: false },
691
- targetPositionLiftPercent100ths: positionLiftPercent100ths ?? 0,
692
- currentPositionLiftPercent100ths: positionLiftPercent100ths ?? 0,
693
- targetPositionTiltPercent100ths: positionTiltPercent100ths ?? 0,
694
- currentPositionTiltPercent100ths: positionTiltPercent100ths ?? 0,
1173
+ targetPositionLiftPercent100ths: positionLiftPercent100ths ?? 0, // 0 Fully open 10000 fully closed
1174
+ currentPositionLiftPercent100ths: positionLiftPercent100ths ?? 0, // 0 Fully open 10000 fully closed
1175
+ targetPositionTiltPercent100ths: positionTiltPercent100ths ?? 0, // 0 Fully open 10000 fully closed
1176
+ currentPositionTiltPercent100ths: positionTiltPercent100ths ?? 0, // 0 Fully open 10000 fully closed
695
1177
  });
696
1178
  return this;
697
1179
  }
1180
+ /**
1181
+ * Sets the window covering lift target position as the current position and stops the movement.
1182
+ *
1183
+ */
698
1184
  async setWindowCoveringTargetAsCurrentAndStopped() {
699
1185
  const position = this.getAttribute(WindowCovering.Cluster.id, 'currentPositionLiftPercent100ths', this.log);
700
1186
  if (isValidNumber(position, 0, 10000)) {
@@ -714,6 +1200,12 @@ export class MatterbridgeEndpoint extends Endpoint {
714
1200
  this.log.debug(`Set WindowCovering currentPositionTiltPercent100ths and targetPositionTiltPercent100ths to ${position} and operationalStatus to Stopped.`);
715
1201
  }
716
1202
  }
1203
+ /**
1204
+ * Sets the lift current and target position and the status of a window covering.
1205
+ * @param {number} current - The current position of the window covering.
1206
+ * @param {number} target - The target position of the window covering.
1207
+ * @param {WindowCovering.MovementStatus} status - The movement status of the window covering.
1208
+ */
717
1209
  async setWindowCoveringCurrentTargetStatus(current, target, status) {
718
1210
  await this.setAttribute(WindowCovering.Cluster.id, 'currentPositionLiftPercent100ths', current, this.log);
719
1211
  await this.setAttribute(WindowCovering.Cluster.id, 'targetPositionLiftPercent100ths', target, this.log);
@@ -724,6 +1216,10 @@ export class MatterbridgeEndpoint extends Endpoint {
724
1216
  }, this.log);
725
1217
  this.log.debug(`Set WindowCovering currentPositionLiftPercent100ths: ${current}, targetPositionLiftPercent100ths: ${target} and operationalStatus: ${status}.`);
726
1218
  }
1219
+ /**
1220
+ * Sets the status of the window covering.
1221
+ * @param {WindowCovering.MovementStatus} status - The movement status to set.
1222
+ */
727
1223
  async setWindowCoveringStatus(status) {
728
1224
  await this.setAttribute(WindowCovering.Cluster.id, 'operationalStatus', {
729
1225
  global: status,
@@ -732,6 +1228,11 @@ export class MatterbridgeEndpoint extends Endpoint {
732
1228
  }, this.log);
733
1229
  this.log.debug(`Set WindowCovering operationalStatus: ${status}`);
734
1230
  }
1231
+ /**
1232
+ * Retrieves the status of the window covering.
1233
+ *
1234
+ * @returns The global operational status of the window covering or undefined.
1235
+ */
735
1236
  getWindowCoveringStatus() {
736
1237
  const status = this.getAttribute(WindowCovering.Cluster.id, 'operationalStatus', this.log);
737
1238
  if (isValidObject(status, 3) && 'global' in status && typeof status.global === 'number') {
@@ -739,6 +1240,12 @@ export class MatterbridgeEndpoint extends Endpoint {
739
1240
  return status.global;
740
1241
  }
741
1242
  }
1243
+ /**
1244
+ * Sets the lift target and current position of the window covering.
1245
+ *
1246
+ * @param {number} liftPosition - The position to set, specified as a number.
1247
+ * @param {number} [tiltPosition] - The tilt position to set, specified as a number.
1248
+ */
742
1249
  async setWindowCoveringTargetAndCurrentPosition(liftPosition, tiltPosition) {
743
1250
  await this.setAttribute(WindowCovering.Cluster.id, 'currentPositionLiftPercent100ths', liftPosition, this.log);
744
1251
  await this.setAttribute(WindowCovering.Cluster.id, 'targetPositionLiftPercent100ths', liftPosition, this.log);
@@ -749,31 +1256,56 @@ export class MatterbridgeEndpoint extends Endpoint {
749
1256
  this.log.debug(`Set WindowCovering currentPositionTiltPercent100ths: ${tiltPosition} and targetPositionTiltPercent100ths: ${tiltPosition}.`);
750
1257
  }
751
1258
  }
1259
+ /**
1260
+ * Creates a default thermostat cluster server with features Heating, Cooling and AutoMode.
1261
+ *
1262
+ * @param {number} [localTemperature=23] - The local temperature value in degrees Celsius. Defaults to 23°.
1263
+ * @param {number} [occupiedHeatingSetpoint=21] - The occupied heating setpoint value in degrees Celsius. Defaults to 21°.
1264
+ * @param {number} [occupiedCoolingSetpoint=25] - The occupied cooling setpoint value in degrees Celsius. Defaults to 25°.
1265
+ * @param {number} [minSetpointDeadBand=1] - The minimum setpoint dead band value. Defaults to 1°.
1266
+ * @param {number} [minHeatSetpointLimit=0] - The minimum heat setpoint limit value. Defaults to 0°.
1267
+ * @param {number} [maxHeatSetpointLimit=50] - The maximum heat setpoint limit value. Defaults to 50°.
1268
+ * @param {number} [minCoolSetpointLimit=0] - The minimum cool setpoint limit value. Defaults to 0°.
1269
+ * @param {number} [maxCoolSetpointLimit=50] - The maximum cool setpoint limit value. Defaults to 50°.
1270
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1271
+ */
752
1272
  createDefaultThermostatClusterServer(localTemperature = 23, occupiedHeatingSetpoint = 21, occupiedCoolingSetpoint = 25, minSetpointDeadBand = 1, minHeatSetpointLimit = 0, maxHeatSetpointLimit = 50, minCoolSetpointLimit = 0, maxCoolSetpointLimit = 50) {
753
1273
  this.behaviors.require(MatterbridgeThermostatServer.with(Thermostat.Feature.Heating, Thermostat.Feature.Cooling, Thermostat.Feature.AutoMode), {
754
1274
  localTemperature: localTemperature * 100,
755
1275
  systemMode: Thermostat.SystemMode.Auto,
756
1276
  controlSequenceOfOperation: Thermostat.ControlSequenceOfOperation.CoolingAndHeating,
1277
+ // Thermostat.Feature.Heating
757
1278
  occupiedHeatingSetpoint: occupiedHeatingSetpoint * 100,
758
1279
  minHeatSetpointLimit: minHeatSetpointLimit * 100,
759
1280
  maxHeatSetpointLimit: maxHeatSetpointLimit * 100,
760
1281
  absMinHeatSetpointLimit: minHeatSetpointLimit * 100,
761
1282
  absMaxHeatSetpointLimit: maxHeatSetpointLimit * 100,
1283
+ // Thermostat.Feature.Cooling
762
1284
  occupiedCoolingSetpoint: occupiedCoolingSetpoint * 100,
763
1285
  minCoolSetpointLimit: minCoolSetpointLimit * 100,
764
1286
  maxCoolSetpointLimit: maxCoolSetpointLimit * 100,
765
1287
  absMinCoolSetpointLimit: minCoolSetpointLimit * 100,
766
1288
  absMaxCoolSetpointLimit: maxCoolSetpointLimit * 100,
1289
+ // Thermostat.Feature.AutoMode
767
1290
  minSetpointDeadBand: minSetpointDeadBand * 100,
768
1291
  thermostatRunningMode: Thermostat.ThermostatRunningMode.Off,
769
1292
  });
770
1293
  return this;
771
1294
  }
1295
+ /**
1296
+ * Creates a default heating thermostat cluster server with feature Heating.
1297
+ * @param {number} [localTemperature] - The local temperature value in degrees Celsius. Defaults to 23°.
1298
+ * @param {number} [occupiedHeatingSetpoint] - The occupied heating setpoint value in degrees Celsius. Defaults to 21°.
1299
+ * @param {number} [minHeatSetpointLimit] - The minimum heat setpoint limit value. Defaults to 0°.
1300
+ * @param {number} [maxHeatSetpointLimit] - The maximum heat setpoint limit value. Defaults to 50°.
1301
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1302
+ */
772
1303
  createDefaultHeatingThermostatClusterServer(localTemperature = 23, occupiedHeatingSetpoint = 21, minHeatSetpointLimit = 0, maxHeatSetpointLimit = 50) {
773
1304
  this.behaviors.require(MatterbridgeThermostatServer.with(Thermostat.Feature.Heating), {
774
1305
  localTemperature: localTemperature * 100,
775
1306
  systemMode: Thermostat.SystemMode.Heat,
776
1307
  controlSequenceOfOperation: Thermostat.ControlSequenceOfOperation.HeatingOnly,
1308
+ // Thermostat.Feature.Heating
777
1309
  occupiedHeatingSetpoint: occupiedHeatingSetpoint * 100,
778
1310
  minHeatSetpointLimit: minHeatSetpointLimit * 100,
779
1311
  maxHeatSetpointLimit: maxHeatSetpointLimit * 100,
@@ -782,11 +1314,20 @@ export class MatterbridgeEndpoint extends Endpoint {
782
1314
  });
783
1315
  return this;
784
1316
  }
1317
+ /**
1318
+ * Creates a default cooling thermostat cluster server with feature Cooling.
1319
+ * @param {number} [localTemperature] - The local temperature value in degrees Celsius. Defaults to 23°.
1320
+ * @param {number} [occupiedCoolingSetpoint] - The occupied cooling setpoint value in degrees Celsius. Defaults to 25°.
1321
+ * @param {number} [minCoolSetpointLimit] - The minimum cool setpoint limit value. Defaults to 0°.
1322
+ * @param {number} [maxCoolSetpointLimit] - The maximum cool setpoint limit value. Defaults to 50°.
1323
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1324
+ */
785
1325
  createDefaultCoolingThermostatClusterServer(localTemperature = 23, occupiedCoolingSetpoint = 25, minCoolSetpointLimit = 0, maxCoolSetpointLimit = 50) {
786
1326
  this.behaviors.require(MatterbridgeThermostatServer.with(Thermostat.Feature.Cooling), {
787
1327
  localTemperature: localTemperature * 100,
788
1328
  systemMode: Thermostat.SystemMode.Cool,
789
1329
  controlSequenceOfOperation: Thermostat.ControlSequenceOfOperation.CoolingOnly,
1330
+ // Thermostat.Feature.Cooling
790
1331
  occupiedCoolingSetpoint: occupiedCoolingSetpoint * 100,
791
1332
  minCoolSetpointLimit: minCoolSetpointLimit * 100,
792
1333
  maxCoolSetpointLimit: maxCoolSetpointLimit * 100,
@@ -795,6 +1336,15 @@ export class MatterbridgeEndpoint extends Endpoint {
795
1336
  });
796
1337
  return this;
797
1338
  }
1339
+ /**
1340
+ * Creates a default thermostat user interface configuration cluster server.
1341
+ *
1342
+ * @remarks
1343
+ * The default values are:
1344
+ * - temperatureDisplayMode: ThermostatUserInterfaceConfiguration.TemperatureDisplayMode.Celsius (writeble).
1345
+ * - keypadLockout: ThermostatUserInterfaceConfiguration.KeypadLockout.NoLockout (writeble).
1346
+ * - scheduleProgrammingVisibility: ThermostatUserInterfaceConfiguration.ScheduleProgrammingVisibility.ScheduleProgrammingPermitted (writeble).
1347
+ */
798
1348
  createDefaultThermostatUserInterfaceConfigurationClusterServer() {
799
1349
  this.behaviors.require(ThermostatUserInterfaceConfigurationServer, {
800
1350
  temperatureDisplayMode: ThermostatUserInterfaceConfiguration.TemperatureDisplayMode.Celsius,
@@ -803,6 +1353,17 @@ export class MatterbridgeEndpoint extends Endpoint {
803
1353
  });
804
1354
  return this;
805
1355
  }
1356
+ /**
1357
+ * Creates a default fan control cluster server with features MultiSpeed, Auto, and Step.
1358
+ *
1359
+ * @param {FanControl.FanMode} [fanMode=FanControl.FanMode.Off] - The fan mode to set. Defaults to `FanControl.FanMode.Off`.
1360
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1361
+ *
1362
+ * @remarks
1363
+ * fanmode is writable and persists across reboots.
1364
+ * percentSetting is writable.
1365
+ * speedSetting is writable.
1366
+ */
806
1367
  createDefaultFanControlClusterServer(fanMode = FanControl.FanMode.Off) {
807
1368
  this.behaviors.require(MatterbridgeFanControlServer.with(FanControl.Feature.MultiSpeed, FanControl.Feature.Auto, FanControl.Feature.Step), {
808
1369
  fanMode,
@@ -815,6 +1376,16 @@ export class MatterbridgeEndpoint extends Endpoint {
815
1376
  });
816
1377
  return this;
817
1378
  }
1379
+ /**
1380
+ * Creates a base fan control cluster server without features.
1381
+ *
1382
+ * @param {FanControl.FanMode} [fanMode=FanControl.FanMode.Off] - The fan mode to set. Defaults to `FanControl.FanMode.Off`.
1383
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1384
+ *
1385
+ * @remarks
1386
+ * fanmode is writable and persists across reboots.
1387
+ * percentSetting is writable.
1388
+ */
818
1389
  createBaseFanControlClusterServer(fanMode = FanControl.FanMode.Off) {
819
1390
  this.behaviors.require(FanControlServer, {
820
1391
  fanMode,
@@ -824,39 +1395,81 @@ export class MatterbridgeEndpoint extends Endpoint {
824
1395
  });
825
1396
  return this;
826
1397
  }
1398
+ /**
1399
+ * Creates a default HEPA Filter Monitoring Cluster Server with features Condition and ReplacementProductList.
1400
+ * It supports ResourceMonitoring.Feature.Condition and ResourceMonitoring.Feature.ReplacementProductList.
1401
+ *
1402
+ * @param {ResourceMonitoring.ChangeIndication} changeIndication - The initial change indication. Default is ResourceMonitoring.ChangeIndication.Ok.
1403
+ * @param {boolean | undefined} inPlaceIndicator - The in-place indicator. Default is undefined.
1404
+ * @param {number | undefined} lastChangedTime - The last changed time (EpochS). Default is undefined.
1405
+ *
1406
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1407
+ */
827
1408
  createDefaultHepaFilterMonitoringClusterServer(changeIndication = ResourceMonitoring.ChangeIndication.Ok, inPlaceIndicator = undefined, lastChangedTime = undefined) {
828
1409
  this.behaviors.require(HepaFilterMonitoringServer.with(ResourceMonitoring.Feature.Condition, ResourceMonitoring.Feature.ReplacementProductList), {
829
- condition: 100,
830
- degradationDirection: ResourceMonitoring.DegradationDirection.Down,
1410
+ condition: 100, // Feature.Condition
1411
+ degradationDirection: ResourceMonitoring.DegradationDirection.Down, // Feature.Condition
831
1412
  changeIndication,
832
1413
  inPlaceIndicator,
833
1414
  lastChangedTime,
834
- replacementProductList: [],
1415
+ replacementProductList: [], // Feature.ReplacementProductList
835
1416
  });
836
1417
  return this;
837
1418
  }
1419
+ /**
1420
+ * Creates a default Activated Carbon Filter Monitoring Cluster Server with features Condition and ReplacementProductList.
1421
+ *
1422
+ * @param {ResourceMonitoring.ChangeIndication} changeIndication - The initial change indication. Default is ResourceMonitoring.ChangeIndication.Ok.
1423
+ * @param {boolean | undefined} inPlaceIndicator - The in-place indicator. Default is undefined.
1424
+ * @param {number | undefined} lastChangedTime - The last changed time (EpochS). Default is undefined.
1425
+ *
1426
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1427
+ */
838
1428
  createDefaultActivatedCarbonFilterMonitoringClusterServer(changeIndication = ResourceMonitoring.ChangeIndication.Ok, inPlaceIndicator = undefined, lastChangedTime = undefined) {
839
1429
  this.behaviors.require(ActivatedCarbonFilterMonitoringServer.with(ResourceMonitoring.Feature.Condition, ResourceMonitoring.Feature.ReplacementProductList), {
840
- condition: 100,
841
- degradationDirection: ResourceMonitoring.DegradationDirection.Down,
1430
+ condition: 100, // Feature.Condition
1431
+ degradationDirection: ResourceMonitoring.DegradationDirection.Down, // Feature.Condition
842
1432
  changeIndication,
843
1433
  inPlaceIndicator,
844
1434
  lastChangedTime,
845
- replacementProductList: [],
1435
+ replacementProductList: [], // Feature.ReplacementProductList
846
1436
  });
847
1437
  return this;
848
1438
  }
1439
+ /**
1440
+ * Creates a default door lock cluster server.
1441
+ *
1442
+ * @param {DoorLock.LockState} [lockState=DoorLock.LockState.Locked] - The initial state of the lock (default: Locked).
1443
+ * @param {DoorLock.LockType} [lockType=DoorLock.LockType.DeadBolt] - The type of the lock (default: DeadBolt).
1444
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1445
+ *
1446
+ * @remarks
1447
+ * 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.
1448
+ */
849
1449
  createDefaultDoorLockClusterServer(lockState = DoorLock.LockState.Locked, lockType = DoorLock.LockType.DeadBolt) {
850
1450
  this.behaviors.require(MatterbridgeDoorLockServer.enable({ events: { doorLockAlarm: true, lockOperation: true, lockOperationError: true } }), {
851
1451
  lockState,
852
1452
  lockType,
853
1453
  actuatorEnabled: false,
854
1454
  operatingMode: DoorLock.OperatingMode.Normal,
1455
+ // Special case of inverted bitmap: add also alwaysSet = 2047
855
1456
  supportedOperatingModes: { normal: false, vacation: true, privacy: true, noRemoteLockUnlock: true, passage: true, alwaysSet: 2047 },
856
1457
  alarmMask: { lockJammed: false, lockFactoryReset: false, lockRadioPowerCycled: false, wrongCodeEntryLimit: false, frontEscutcheonRemoved: false, doorForcedOpen: false },
857
1458
  });
858
1459
  return this;
859
1460
  }
1461
+ /**
1462
+ * Creates a default Mode Select cluster server.
1463
+ *
1464
+ * @param {string} description - The description of the mode select cluster.
1465
+ * @param {ModeSelect.ModeOption[]} supportedModes - The list of supported modes.
1466
+ * @param {number} [currentMode=0] - The current mode (default: 0).
1467
+ * @param {number} [startUpMode=0] - The startup mode (default: 0).
1468
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1469
+ *
1470
+ * @remarks
1471
+ * endpoint.createDefaultModeSelectClusterServer('Night mode', [{ label: 'Led ON', mode: 0, semanticTags: [] }, { label: 'Led OFF', mode: 1, semanticTags: [] }], 0, 0);
1472
+ */
860
1473
  createDefaultModeSelectClusterServer(description, supportedModes, currentMode = 0, startUpMode = 0) {
861
1474
  this.behaviors.require(MatterbridgeModeSelectServer, {
862
1475
  description: description,
@@ -867,6 +1480,13 @@ export class MatterbridgeEndpoint extends Endpoint {
867
1480
  });
868
1481
  return this;
869
1482
  }
1483
+ /**
1484
+ * Creates the default Valve Configuration And Control cluster server with features Level.
1485
+ *
1486
+ * @param {ValveConfigurationAndControl.ValveState} [valveState=ValveConfigurationAndControl.ValveState.Closed] - The valve state to set. Defaults to `ValveConfigurationAndControl.ValveState.Closed`.
1487
+ * @param {number} [valveLevel=0] - The valve level to set. Defaults to 0.
1488
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1489
+ */
870
1490
  createDefaultValveConfigurationAndControlClusterServer(valveState = ValveConfigurationAndControl.ValveState.Closed, valveLevel = 0) {
871
1491
  this.behaviors.require(MatterbridgeValveConfigurationAndControlServer.with(ValveConfigurationAndControl.Feature.Level), {
872
1492
  currentState: valveState,
@@ -882,6 +1502,12 @@ export class MatterbridgeEndpoint extends Endpoint {
882
1502
  });
883
1503
  return this;
884
1504
  }
1505
+ /**
1506
+ * Creates the default PumpConfigurationAndControl cluster server with features ConstantSpeed.
1507
+ *
1508
+ * @param {PumpConfigurationAndControl.OperationMode} [pumpMode=PumpConfigurationAndControl.OperationMode.Normal] - The pump mode to set. Defaults to `PumpConfigurationAndControl.OperationMode.Normal`.
1509
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1510
+ */
885
1511
  createDefaultPumpConfigurationAndControlClusterServer(pumpMode = PumpConfigurationAndControl.OperationMode.Normal) {
886
1512
  this.behaviors.require(PumpConfigurationAndControlServer.with(PumpConfigurationAndControl.Feature.ConstantSpeed), {
887
1513
  minConstSpeed: null,
@@ -896,6 +1522,13 @@ export class MatterbridgeEndpoint extends Endpoint {
896
1522
  });
897
1523
  return this;
898
1524
  }
1525
+ /**
1526
+ * Creates the default SmokeCOAlarm Cluster Server with features SmokeAlarm and CoAlarm.
1527
+ *
1528
+ * @param {SmokeCoAlarm.AlarmState} smokeState - The state of the smoke alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
1529
+ * @param {SmokeCoAlarm.AlarmState} coState - The state of the CO alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
1530
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1531
+ */
899
1532
  createDefaultSmokeCOAlarmClusterServer(smokeState = SmokeCoAlarm.AlarmState.Normal, coState = SmokeCoAlarm.AlarmState.Normal) {
900
1533
  this.behaviors.require(MatterbridgeSmokeCoAlarmServer.with(SmokeCoAlarm.Feature.SmokeAlarm, SmokeCoAlarm.Feature.CoAlarm).enable({
901
1534
  events: { smokeAlarm: true, interconnectSmokeAlarm: false, coAlarm: true, interconnectCoAlarm: false, lowBattery: true, hardwareFault: true, endOfService: true, selfTestComplete: true, alarmMuted: true, muteEnded: true, allClear: true },
@@ -911,6 +1544,12 @@ export class MatterbridgeEndpoint extends Endpoint {
911
1544
  });
912
1545
  return this;
913
1546
  }
1547
+ /**
1548
+ * Creates a smoke only SmokeCOAlarm Cluster Server with features SmokeAlarm.
1549
+ *
1550
+ * @param {SmokeCoAlarm.AlarmState} smokeState - The state of the smoke alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
1551
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1552
+ */
914
1553
  createSmokeOnlySmokeCOAlarmClusterServer(smokeState = SmokeCoAlarm.AlarmState.Normal) {
915
1554
  this.behaviors.require(MatterbridgeSmokeCoAlarmServer.with(SmokeCoAlarm.Feature.SmokeAlarm).enable({
916
1555
  events: { smokeAlarm: true, interconnectSmokeAlarm: false, coAlarm: false, interconnectCoAlarm: false, lowBattery: true, hardwareFault: true, endOfService: true, selfTestComplete: true, alarmMuted: true, muteEnded: true, allClear: true },
@@ -925,6 +1564,12 @@ export class MatterbridgeEndpoint extends Endpoint {
925
1564
  });
926
1565
  return this;
927
1566
  }
1567
+ /**
1568
+ * Creates a co only SmokeCOAlarm Cluster Server with features CoAlarm.
1569
+ *
1570
+ * @param {SmokeCoAlarm.AlarmState} coState - The state of the CO alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
1571
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1572
+ */
928
1573
  createCoOnlySmokeCOAlarmClusterServer(coState = SmokeCoAlarm.AlarmState.Normal) {
929
1574
  this.behaviors.require(MatterbridgeSmokeCoAlarmServer.with(SmokeCoAlarm.Feature.CoAlarm).enable({
930
1575
  events: { smokeAlarm: false, interconnectSmokeAlarm: false, coAlarm: true, interconnectCoAlarm: false, lowBattery: true, hardwareFault: true, endOfService: true, selfTestComplete: true, alarmMuted: true, muteEnded: true, allClear: true },
@@ -939,6 +1584,13 @@ export class MatterbridgeEndpoint extends Endpoint {
939
1584
  });
940
1585
  return this;
941
1586
  }
1587
+ /**
1588
+ * Creates a default momentary switch cluster server with features MomentarySwitch, MomentarySwitchRelease, MomentarySwitchLongPress and MomentarySwitchMultiPress.
1589
+ *
1590
+ * @remarks
1591
+ * This method adds a cluster server with default momentary switch features and configuration suitable for (AppleHome) Single Double Long automations.
1592
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1593
+ */
942
1594
  createDefaultSwitchClusterServer() {
943
1595
  this.behaviors.require(MatterbridgeSwitchServer.with(Switch.Feature.MomentarySwitch, Switch.Feature.MomentarySwitchRelease, Switch.Feature.MomentarySwitchLongPress, Switch.Feature.MomentarySwitchMultiPress).enable({
944
1596
  events: { initialPress: true, longPress: true, shortRelease: true, longRelease: true, multiPressOngoing: true, multiPressComplete: true },
@@ -949,6 +1601,13 @@ export class MatterbridgeEndpoint extends Endpoint {
949
1601
  });
950
1602
  return this;
951
1603
  }
1604
+ /**
1605
+ * Creates a default latching switch cluster server with features LatchingSwitch.
1606
+ *
1607
+ * @remarks
1608
+ * This method adds a cluster server with default latching switch features and configuration suitable for a latching switch with 2 positions.
1609
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1610
+ */
952
1611
  createDefaultLatchingSwitchClusterServer() {
953
1612
  this.behaviors.require(SwitchServer.with(Switch.Feature.LatchingSwitch).enable({
954
1613
  events: { switchLatched: true },
@@ -958,6 +1617,13 @@ export class MatterbridgeEndpoint extends Endpoint {
958
1617
  });
959
1618
  return this;
960
1619
  }
1620
+ /**
1621
+ * Triggers a switch event on the specified endpoint.
1622
+ *
1623
+ * @param {string} event - The type of event to trigger. Possible values are 'Single', 'Double', 'Long' for momentarySwitch and 'Press', 'Release' for latchingSwitch.
1624
+ * @param {Endpoint} endpoint - The endpoint on which to trigger the event (default the device endpoint).
1625
+ * @returns {boolean} - A boolean indicating whether the event was successfully triggered.
1626
+ */
961
1627
  async triggerSwitchEvent(event, log) {
962
1628
  if (this.maybeNumber === undefined) {
963
1629
  this.log.error(`triggerSwitchEvent ${event} error: Endpoint number not assigned on endpoint ${this.maybeId}:${this.maybeNumber}`);
@@ -1017,10 +1683,30 @@ export class MatterbridgeEndpoint extends Endpoint {
1017
1683
  }
1018
1684
  return true;
1019
1685
  }
1686
+ /**
1687
+ * Creates a default OperationalState Cluster Server.
1688
+ *
1689
+ * @param {OperationalState.OperationalStateEnum} operationalState - The initial operational state.
1690
+ *
1691
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1692
+ */
1020
1693
  createDefaultOperationalStateClusterServer(operationalState = OperationalState.OperationalStateEnum.Stopped) {
1021
1694
  this.behaviors.require(MatterbridgeOperationalStateServer, getDefaultOperationalStateClusterServer(operationalState));
1022
1695
  return this;
1023
1696
  }
1697
+ /**
1698
+ * Creates a default boolean state cluster server.
1699
+ * The stateChange event is enabled.
1700
+ *
1701
+ * @param {boolean} contact - The state of the cluster. Defaults to true (true = contact).
1702
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1703
+ *
1704
+ * @remarks
1705
+ * Water Leak Detector: true = leak, false = no leak
1706
+ * Water Freeze Detector: true = freeze, false = no freeze
1707
+ * Rain Sensor: true = rain, false = no rain
1708
+ * Contact Sensor: true = closed or contact, false = open or no contact
1709
+ */
1024
1710
  createDefaultBooleanStateClusterServer(contact) {
1025
1711
  this.behaviors.require(BooleanStateServer.enable({
1026
1712
  events: { stateChange: true },
@@ -1029,6 +1715,23 @@ export class MatterbridgeEndpoint extends Endpoint {
1029
1715
  });
1030
1716
  return this;
1031
1717
  }
1718
+ /**
1719
+ * Creates a default boolean state configuration cluster server to be used with the waterFreezeDetector, waterLeakDetector, and rainSensor device types.
1720
+ *
1721
+ * Features:
1722
+ * - Visual
1723
+ * - Audible
1724
+ * - SensitivityLevel
1725
+ *
1726
+ * @remarks Supports the enableDisableAlarm command.
1727
+ *
1728
+ * @param {boolean} [sensorFault=false] - Optional boolean value indicating the sensor fault state. Defaults to `false` if not provided.
1729
+ * @param {number} [currentSensitivityLevel=0] - The current sensitivity level. Defaults to `0` if not provided.
1730
+ * @param {number} [supportedSensitivityLevels=2] - The number of supported sensitivity levels. Defaults to `2` if not provided (min 2, max 10).
1731
+ * @param {number} [defaultSensitivityLevel=0] - The default sensitivity level. Defaults to `0` if not provided.
1732
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1733
+ *
1734
+ */
1032
1735
  createDefaultBooleanStateConfigurationClusterServer(sensorFault = false, currentSensitivityLevel = 0, supportedSensitivityLevels = 2, defaultSensitivityLevel = 0) {
1033
1736
  this.behaviors.require(MatterbridgeBooleanStateConfigurationServer.with(BooleanStateConfiguration.Feature.Visual, BooleanStateConfiguration.Feature.Audible, BooleanStateConfiguration.Feature.SensitivityLevel).enable({
1034
1737
  events: { alarmsStateChanged: true, sensorFault: true },
@@ -1043,9 +1746,14 @@ export class MatterbridgeEndpoint extends Endpoint {
1043
1746
  });
1044
1747
  return this;
1045
1748
  }
1749
+ /**
1750
+ * Creates a default Device Energy Management Cluster Server with feature PowerForecastReporting. Only needed for an evse device type.
1751
+ *
1752
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1753
+ */
1046
1754
  createDefaultDeviceEnergyManagementCluster() {
1047
1755
  this.behaviors.require(DeviceEnergyManagementServer.with(DeviceEnergyManagement.Feature.PowerForecastReporting), {
1048
- forecast: null,
1756
+ forecast: null, // A null value indicates that there is no forecast currently available
1049
1757
  esaType: DeviceEnergyManagement.EsaType.Other,
1050
1758
  esaCanGenerate: false,
1051
1759
  esaState: DeviceEnergyManagement.EsaState.Offline,
@@ -1054,6 +1762,21 @@ export class MatterbridgeEndpoint extends Endpoint {
1054
1762
  });
1055
1763
  return this;
1056
1764
  }
1765
+ /**
1766
+ * Creates a default EnergyManagementMode Cluster Server.
1767
+ *
1768
+ * A few examples of Device Energy Management modes and their mode tags are provided below.
1769
+ * - For the "No Energy Management (Forecast reporting only)" mode, tags: 0x4000 (NoOptimization).
1770
+ * - For the "Device Energy Management" mode, tags: 0x4001 (DeviceOptimization).
1771
+ * - For the "Home Energy Management" mode, tags: 0x4001 (DeviceOptimization), 0x4002 (LocalOptimization).
1772
+ * - For the "Grid Energy Management" mode, tags: 0x4003 (GridOptimization).
1773
+ * - For the "Full Energy Management" mode, tags: 0x4001 (DeviceOptimization), 0x4002 (LocalOptimization), 0x4003 (GridOptimization).
1774
+ *
1775
+ * @param {number} [currentMode] - The current mode of the EnergyManagementMode cluster. Defaults to mode 1 (DeviceEnergyManagementMode.ModeTag.NoOptimization).
1776
+ * @param {EnergyManagementMode.ModeOption[]} [supportedModes] - The supported modes for the DeviceEnergyManagementMode cluster. Defaults all cluster modes.
1777
+ *
1778
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1779
+ */
1057
1780
  createDefaultDeviceEnergyManagementModeCluster(currentMode, supportedModes) {
1058
1781
  this.behaviors.require(MatterbridgeDeviceEnergyManagementModeServer, {
1059
1782
  supportedModes: supportedModes ?? [
@@ -1079,10 +1802,21 @@ export class MatterbridgeEndpoint extends Endpoint {
1079
1802
  });
1080
1803
  return this;
1081
1804
  }
1805
+ /**
1806
+ * Creates a default Power Topology Cluster Server with feature TreeTopology. Only needed for an electricalSensor device type.
1807
+ *
1808
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1809
+ */
1082
1810
  createDefaultPowerTopologyClusterServer() {
1083
1811
  this.behaviors.require(PowerTopologyServer.with(PowerTopology.Feature.TreeTopology));
1084
1812
  return this;
1085
1813
  }
1814
+ /**
1815
+ * Creates a default Electrical Energy Measurement Cluster Server with features ImportedEnergy, ExportedEnergy, and CumulativeEnergy.
1816
+ *
1817
+ * @param {number} energy - The total consumption value in mW/h.
1818
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1819
+ */
1086
1820
  createDefaultElectricalEnergyMeasurementClusterServer(energy = null) {
1087
1821
  this.behaviors.require(ElectricalEnergyMeasurementServer.with(ElectricalEnergyMeasurement.Feature.ImportedEnergy, ElectricalEnergyMeasurement.Feature.ExportedEnergy, ElectricalEnergyMeasurement.Feature.CumulativeEnergy), {
1088
1822
  accuracy: {
@@ -1098,6 +1832,15 @@ export class MatterbridgeEndpoint extends Endpoint {
1098
1832
  });
1099
1833
  return this;
1100
1834
  }
1835
+ /**
1836
+ * Creates a default Electrical Power Measurement Cluster Server with features AlternatingCurrent.
1837
+ *
1838
+ * @param {number} voltage - The voltage value in millivolts.
1839
+ * @param {number} current - The current value in milliamperes.
1840
+ * @param {number} power - The power value in milliwatts.
1841
+ * @param {number} frequency - The frequency value in millihertz.
1842
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1843
+ */
1101
1844
  createDefaultElectricalPowerMeasurementClusterServer(voltage = null, current = null, power = null, frequency = null) {
1102
1845
  this.behaviors.require(ElectricalPowerMeasurementServer.with(ElectricalPowerMeasurement.Feature.AlternatingCurrent), {
1103
1846
  powerMode: ElectricalPowerMeasurement.PowerMode.Ac,
@@ -1139,36 +1882,113 @@ export class MatterbridgeEndpoint extends Endpoint {
1139
1882
  });
1140
1883
  return this;
1141
1884
  }
1885
+ /**
1886
+ * Creates a default TemperatureMeasurement cluster server.
1887
+ *
1888
+ * @param {number | null} measuredValue - The measured value of the temperature x 100.
1889
+ * @param {number | null} minMeasuredValue - The minimum measured value of the temperature x 100.
1890
+ * @param {number | null} maxMeasuredValue - The maximum measured value of the temperature x 100.
1891
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1892
+ */
1142
1893
  createDefaultTemperatureMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
1143
1894
  this.behaviors.require(TemperatureMeasurementServer, getDefaultTemperatureMeasurementClusterServer(measuredValue, minMeasuredValue, maxMeasuredValue));
1144
1895
  return this;
1145
1896
  }
1897
+ /**
1898
+ * Creates a default RelativeHumidityMeasurement cluster server.
1899
+ *
1900
+ * @param {number | null} measuredValue - The measured value of the relative humidity x 100.
1901
+ * @param {number | null} minMeasuredValue - The minimum measured value of the relative humidity x 100.
1902
+ * @param {number | null} maxMeasuredValue - The maximum measured value of the relative humidity x 100.
1903
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1904
+ */
1146
1905
  createDefaultRelativeHumidityMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
1147
1906
  this.behaviors.require(RelativeHumidityMeasurementServer, getDefaultRelativeHumidityMeasurementClusterServer(measuredValue, minMeasuredValue, maxMeasuredValue));
1148
1907
  return this;
1149
1908
  }
1909
+ /**
1910
+ * Creates a default PressureMeasurement cluster server.
1911
+ *
1912
+ * @param {number | null} measuredValue - The measured value for the pressure.
1913
+ * @param {number | null} minMeasuredValue - The minimum measured value for the pressure.
1914
+ * @param {number | null} maxMeasuredValue - The maximum measured value for the pressure.
1915
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1916
+ */
1150
1917
  createDefaultPressureMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
1151
1918
  this.behaviors.require(PressureMeasurementServer, getDefaultPressureMeasurementClusterServer(measuredValue, minMeasuredValue, maxMeasuredValue));
1152
1919
  return this;
1153
1920
  }
1921
+ /**
1922
+ * Creates a default IlluminanceMeasurement cluster server.
1923
+ *
1924
+ * @param {number | null} measuredValue - The measured value of illuminance.
1925
+ * @param {number | null} minMeasuredValue - The minimum measured value of illuminance.
1926
+ * @param {number | null} maxMeasuredValue - The maximum measured value of illuminance.
1927
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1928
+ *
1929
+ * @remark The default value for the illuminance measurement is null.
1930
+ * This attribute SHALL indicate the illuminance in Lux (symbol lx) as follows:
1931
+ * • MeasuredValue = 10,000 x log10(illuminance) + 1,
1932
+ * where 1 lx <= illuminance <= 3.576 Mlx, corresponding to a MeasuredValue in the range 1 to 0xFFFE.
1933
+ * • 0 indicates a value of illuminance that is too low to be measured
1934
+ * • null indicates that the illuminance measurement is invalid.
1935
+ *
1936
+ * @remarks
1937
+ * Lux to matter = Math.round(Math.max(Math.min(10000 * Math.log10(lux), 0xfffe), 0))
1938
+ * Matter to Lux = Math.round(Math.max(Math.pow(10, value / 10000), 0))
1939
+ */
1154
1940
  createDefaultIlluminanceMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
1155
1941
  this.behaviors.require(IlluminanceMeasurementServer, getDefaultIlluminanceMeasurementClusterServer(measuredValue, minMeasuredValue, maxMeasuredValue));
1156
1942
  return this;
1157
1943
  }
1944
+ /**
1945
+ * Creates a default FlowMeasurement cluster server.
1946
+ *
1947
+ * @param {number | null} measuredValue - The measured value of the flow in 10 x m3/h.
1948
+ * @param {number | null} minMeasuredValue - The minimum measured value of the flow in 10 x m3/h.
1949
+ * @param {number | null} maxMeasuredValue - The maximum measured value of the flow in 10 x m3/h.
1950
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1951
+ */
1158
1952
  createDefaultFlowMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
1159
1953
  this.behaviors.require(FlowMeasurementServer, getDefaultFlowMeasurementClusterServer(measuredValue, minMeasuredValue, maxMeasuredValue));
1160
1954
  return this;
1161
1955
  }
1956
+ /**
1957
+ * Creates a default OccupancySensing cluster server with feature PassiveInfrared.
1958
+ *
1959
+ * @param {boolean} occupied - A boolean indicating whether the occupancy is occupied or not. Default is false.
1960
+ * @param {number} holdTime - The hold time in seconds. Default is 30.
1961
+ * @param {number} holdTimeMin - The minimum hold time in seconds. Default is 1.
1962
+ * @param {number} holdTimeMax - The maximum hold time in seconds. Default is 300.
1963
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1964
+ *
1965
+ * @remark The default value for the occupancy sensor type is PIR.
1966
+ */
1162
1967
  createDefaultOccupancySensingClusterServer(occupied = false, holdTime = 30, holdTimeMin = 1, holdTimeMax = 300) {
1163
1968
  this.behaviors.require(OccupancySensingServer.with(OccupancySensing.Feature.PassiveInfrared), getDefaultOccupancySensingClusterServer(occupied, holdTime, holdTimeMin, holdTimeMax));
1164
1969
  return this;
1165
1970
  }
1971
+ /**
1972
+ * Creates a default AirQuality cluster server.
1973
+ *
1974
+ * @param {AirQuality.AirQualityEnum} airQuality The air quality level. Defaults to `AirQuality.AirQualityType.Unknown`.
1975
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1976
+ */
1166
1977
  createDefaultAirQualityClusterServer(airQuality = AirQuality.AirQualityEnum.Unknown) {
1167
1978
  this.behaviors.require(AirQualityServer.with(AirQuality.Feature.Fair, AirQuality.Feature.Moderate, AirQuality.Feature.VeryPoor, AirQuality.Feature.ExtremelyPoor), {
1168
1979
  airQuality,
1169
1980
  });
1170
1981
  return this;
1171
1982
  }
1983
+ /**
1984
+ * Creates a default TotalVolatileOrganicCompoundsConcentrationMeasurement cluster server with feature NumericMeasurement.
1985
+ *
1986
+ * @param {number | null} measuredValue - The measured value of the concentration.
1987
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
1988
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
1989
+ * @param {number} [uncertainty] - The uncertainty value (optional).
1990
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1991
+ */
1172
1992
  createDefaultTvocMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air, uncertainty) {
1173
1993
  this.behaviors.require(TotalVolatileOrganicCompoundsConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1174
1994
  measuredValue,
@@ -1180,6 +2000,13 @@ export class MatterbridgeEndpoint extends Endpoint {
1180
2000
  });
1181
2001
  return this;
1182
2002
  }
2003
+ /**
2004
+ * Creates a default TotalVolatileOrganicCompoundsConcentrationMeasurement cluster server with feature LevelIndication.
2005
+
2006
+ * @param {ConcentrationMeasurement.LevelValue} levelValue - The level value of the measurement (default to ConcentrationMeasurement.LevelValue.Unknown).
2007
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The measurement medium (default to ConcentrationMeasurement.MeasurementMedium.Air).
2008
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2009
+ */
1183
2010
  createLevelTvocMeasurementClusterServer(levelValue = ConcentrationMeasurement.LevelValue.Unknown, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1184
2011
  this.behaviors.require(TotalVolatileOrganicCompoundsConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.LevelIndication, ConcentrationMeasurement.Feature.MediumLevel, ConcentrationMeasurement.Feature.CriticalLevel), {
1185
2012
  levelValue,
@@ -1187,6 +2014,14 @@ export class MatterbridgeEndpoint extends Endpoint {
1187
2014
  });
1188
2015
  return this;
1189
2016
  }
2017
+ /**
2018
+ * Create a default CarbonMonoxideConcentrationMeasurement cluster server with feature NumericMeasurement.
2019
+ *
2020
+ * @param {number | null} measuredValue - The measured value of the concentration.
2021
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
2022
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2023
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2024
+ */
1190
2025
  createDefaultCarbonMonoxideConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1191
2026
  this.behaviors.require(CarbonMonoxideConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1192
2027
  measuredValue,
@@ -1198,6 +2033,14 @@ export class MatterbridgeEndpoint extends Endpoint {
1198
2033
  });
1199
2034
  return this;
1200
2035
  }
2036
+ /**
2037
+ * Create a default CarbonDioxideConcentrationMeasurement cluster server with feature NumericMeasurement.
2038
+ *
2039
+ * @param {number | null} measuredValue - The measured value of the concentration.
2040
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
2041
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2042
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2043
+ */
1201
2044
  createDefaultCarbonDioxideConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1202
2045
  this.behaviors.require(CarbonDioxideConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1203
2046
  measuredValue,
@@ -1209,6 +2052,14 @@ export class MatterbridgeEndpoint extends Endpoint {
1209
2052
  });
1210
2053
  return this;
1211
2054
  }
2055
+ /**
2056
+ * Create a default FormaldehydeConcentrationMeasurement cluster server with feature NumericMeasurement.
2057
+ *
2058
+ * @param {number | null} measuredValue - The measured value of the concentration.
2059
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
2060
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2061
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2062
+ */
1212
2063
  createDefaultFormaldehydeConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1213
2064
  this.behaviors.require(FormaldehydeConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1214
2065
  measuredValue,
@@ -1220,6 +2071,14 @@ export class MatterbridgeEndpoint extends Endpoint {
1220
2071
  });
1221
2072
  return this;
1222
2073
  }
2074
+ /**
2075
+ * Create a default Pm1ConcentrationMeasurement cluster server with feature NumericMeasurement.
2076
+ *
2077
+ * @param {number | null} measuredValue - The measured value of the concentration.
2078
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
2079
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2080
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2081
+ */
1223
2082
  createDefaultPm1ConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1224
2083
  this.behaviors.require(Pm1ConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1225
2084
  measuredValue,
@@ -1231,6 +2090,14 @@ export class MatterbridgeEndpoint extends Endpoint {
1231
2090
  });
1232
2091
  return this;
1233
2092
  }
2093
+ /**
2094
+ * Create a default Pm25ConcentrationMeasurement cluster server with feature NumericMeasurement.
2095
+ *
2096
+ * @param {number | null} measuredValue - The measured value of the concentration.
2097
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
2098
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2099
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2100
+ */
1234
2101
  createDefaultPm25ConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1235
2102
  this.behaviors.require(Pm25ConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1236
2103
  measuredValue,
@@ -1242,6 +2109,14 @@ export class MatterbridgeEndpoint extends Endpoint {
1242
2109
  });
1243
2110
  return this;
1244
2111
  }
2112
+ /**
2113
+ * Create a default Pm10ConcentrationMeasurement cluster server with feature NumericMeasurement.
2114
+ *
2115
+ * @param {number | null} measuredValue - The measured value of the concentration.
2116
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
2117
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2118
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2119
+ */
1245
2120
  createDefaultPm10ConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1246
2121
  this.behaviors.require(Pm10ConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1247
2122
  measuredValue,
@@ -1253,6 +2128,14 @@ export class MatterbridgeEndpoint extends Endpoint {
1253
2128
  });
1254
2129
  return this;
1255
2130
  }
2131
+ /**
2132
+ * Create a default OzoneConcentrationMeasurement cluster server with feature NumericMeasurement.
2133
+ *
2134
+ * @param {number | null} measuredValue - The measured value of the concentration.
2135
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ugm3).
2136
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2137
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2138
+ */
1256
2139
  createDefaultOzoneConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ugm3, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1257
2140
  this.behaviors.require(OzoneConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1258
2141
  measuredValue,
@@ -1264,6 +2147,14 @@ export class MatterbridgeEndpoint extends Endpoint {
1264
2147
  });
1265
2148
  return this;
1266
2149
  }
2150
+ /**
2151
+ * Create a default RadonConcentrationMeasurement cluster server with feature NumericMeasurement.
2152
+ *
2153
+ * @param {number | null} measuredValue - The measured value of the concentration.
2154
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
2155
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2156
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2157
+ */
1267
2158
  createDefaultRadonConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1268
2159
  this.behaviors.require(RadonConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1269
2160
  measuredValue,
@@ -1275,6 +2166,14 @@ export class MatterbridgeEndpoint extends Endpoint {
1275
2166
  });
1276
2167
  return this;
1277
2168
  }
2169
+ /**
2170
+ * Create a default NitrogenDioxideConcentrationMeasurement cluster server with feature NumericMeasurement.
2171
+ *
2172
+ * @param {number | null} measuredValue - The measured value of the concentration.
2173
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ugm3).
2174
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2175
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2176
+ */
1278
2177
  createDefaultNitrogenDioxideConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ugm3, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1279
2178
  this.behaviors.require(NitrogenDioxideConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1280
2179
  measuredValue,
@@ -1287,3 +2186,4 @@ export class MatterbridgeEndpoint extends Endpoint {
1287
2186
  return this;
1288
2187
  }
1289
2188
  }
2189
+ //# sourceMappingURL=matterbridgeEndpoint.js.map