matterbridge 2.2.0-dev.4 → 2.2.0-dev.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 (127) hide show
  1. package/CHANGELOG.md +1 -0
  2. package/dist/cli.d.ts +28 -0
  3. package/dist/cli.d.ts.map +1 -0
  4. package/dist/cli.js +37 -2
  5. package/dist/cli.js.map +1 -0
  6. package/dist/cluster/export.d.ts.map +1 -0
  7. package/dist/cluster/export.js +2 -0
  8. package/dist/cluster/export.js.map +1 -0
  9. package/dist/defaultConfigSchema.d.ts.map +1 -0
  10. package/dist/defaultConfigSchema.js +23 -0
  11. package/dist/defaultConfigSchema.js.map +1 -0
  12. package/dist/deviceManager.d.ts +109 -0
  13. package/dist/deviceManager.d.ts.map +1 -0
  14. package/dist/deviceManager.js +94 -1
  15. package/dist/deviceManager.js.map +1 -0
  16. package/dist/frontend.d.ts +172 -0
  17. package/dist/frontend.d.ts.map +1 -0
  18. package/dist/frontend.js +265 -22
  19. package/dist/frontend.js.map +1 -0
  20. package/dist/index.d.ts.map +1 -0
  21. package/dist/index.js +29 -2
  22. package/dist/index.js.map +1 -0
  23. package/dist/logger/export.d.ts.map +1 -0
  24. package/dist/logger/export.js +1 -0
  25. package/dist/logger/export.js.map +1 -0
  26. package/dist/matter/behaviors.d.ts.map +1 -0
  27. package/dist/matter/behaviors.js +2 -0
  28. package/dist/matter/behaviors.js.map +1 -0
  29. package/dist/matter/clusters.d.ts.map +1 -0
  30. package/dist/matter/clusters.js +2 -0
  31. package/dist/matter/clusters.js.map +1 -0
  32. package/dist/matter/devices.d.ts.map +1 -0
  33. package/dist/matter/devices.js +2 -0
  34. package/dist/matter/devices.js.map +1 -0
  35. package/dist/matter/endpoints.d.ts.map +1 -0
  36. package/dist/matter/endpoints.js +2 -0
  37. package/dist/matter/endpoints.js.map +1 -0
  38. package/dist/matter/export.d.ts.map +1 -0
  39. package/dist/matter/export.js +2 -0
  40. package/dist/matter/export.js.map +1 -0
  41. package/dist/matter/types.d.ts.map +1 -0
  42. package/dist/matter/types.js +3 -1
  43. package/dist/matter/types.js.map +1 -0
  44. package/dist/matterbridge.d.ts +410 -0
  45. package/dist/matterbridge.d.ts.map +1 -0
  46. package/dist/matterbridge.js +718 -47
  47. package/dist/matterbridge.js.map +1 -0
  48. package/dist/matterbridgeAccessoryPlatform.d.ts.map +1 -0
  49. package/dist/matterbridgeAccessoryPlatform.js +33 -0
  50. package/dist/matterbridgeAccessoryPlatform.js.map +1 -0
  51. package/dist/matterbridgeBehaviors.d.ts +148 -0
  52. package/dist/matterbridgeBehaviors.d.ts.map +1 -0
  53. package/dist/matterbridgeBehaviors.js +32 -1
  54. package/dist/matterbridgeBehaviors.js.map +1 -0
  55. package/dist/matterbridgeDeviceTypes.d.ts.map +1 -0
  56. package/dist/matterbridgeDeviceTypes.js +112 -11
  57. package/dist/matterbridgeDeviceTypes.js.map +1 -0
  58. package/dist/matterbridgeDynamicPlatform.d.ts.map +1 -0
  59. package/dist/matterbridgeDynamicPlatform.js +33 -0
  60. package/dist/matterbridgeDynamicPlatform.js.map +1 -0
  61. package/dist/matterbridgeEndpoint.d.ts +827 -0
  62. package/dist/matterbridgeEndpoint.d.ts.map +1 -0
  63. package/dist/matterbridgeEndpoint.js +690 -6
  64. package/dist/matterbridgeEndpoint.js.map +1 -0
  65. package/dist/matterbridgeEndpointHelpers.d.ts +123 -0
  66. package/dist/matterbridgeEndpointHelpers.d.ts.map +1 -0
  67. package/dist/matterbridgeEndpointHelpers.js +118 -9
  68. package/dist/matterbridgeEndpointHelpers.js.map +1 -0
  69. package/dist/matterbridgePlatform.d.ts +159 -0
  70. package/dist/matterbridgePlatform.d.ts.map +1 -0
  71. package/dist/matterbridgePlatform.js +162 -23
  72. package/dist/matterbridgePlatform.js.map +1 -0
  73. package/dist/matterbridgeTypes.d.ts.map +1 -0
  74. package/dist/matterbridgeTypes.js +24 -0
  75. package/dist/matterbridgeTypes.js.map +1 -0
  76. package/dist/pluginManager.d.ts +236 -0
  77. package/dist/pluginManager.d.ts.map +1 -0
  78. package/dist/pluginManager.js +229 -3
  79. package/dist/pluginManager.js.map +1 -0
  80. package/dist/shelly.d.ts.map +1 -0
  81. package/dist/shelly.js +131 -4
  82. package/dist/shelly.js.map +1 -0
  83. package/dist/storage/export.d.ts.map +1 -0
  84. package/dist/storage/export.js +1 -0
  85. package/dist/storage/export.js.map +1 -0
  86. package/dist/update.d.ts.map +1 -0
  87. package/dist/update.js +45 -0
  88. package/dist/update.js.map +1 -0
  89. package/dist/utils/colorUtils.d.ts.map +1 -0
  90. package/dist/utils/colorUtils.js +205 -2
  91. package/dist/utils/colorUtils.js.map +1 -0
  92. package/dist/utils/copyDirectory.d.ts.map +1 -0
  93. package/dist/utils/copyDirectory.js +37 -1
  94. package/dist/utils/copyDirectory.js.map +1 -0
  95. package/dist/utils/createZip.d.ts.map +1 -0
  96. package/dist/utils/createZip.js +42 -2
  97. package/dist/utils/createZip.js.map +1 -0
  98. package/dist/utils/deepCopy.d.ts.map +1 -0
  99. package/dist/utils/deepCopy.js +40 -0
  100. package/dist/utils/deepCopy.js.map +1 -0
  101. package/dist/utils/deepEqual.d.ts.map +1 -0
  102. package/dist/utils/deepEqual.js +65 -1
  103. package/dist/utils/deepEqual.js.map +1 -0
  104. package/dist/utils/export.d.ts.map +1 -0
  105. package/dist/utils/export.js +1 -0
  106. package/dist/utils/export.js.map +1 -0
  107. package/dist/utils/isvalid.d.ts.map +1 -0
  108. package/dist/utils/isvalid.js +86 -0
  109. package/dist/utils/isvalid.js.map +1 -0
  110. package/dist/utils/network.d.ts.map +1 -0
  111. package/dist/utils/network.js +77 -5
  112. package/dist/utils/network.js.map +1 -0
  113. package/dist/utils/parameter.d.ts.map +1 -0
  114. package/dist/utils/parameter.js +41 -0
  115. package/dist/utils/parameter.js.map +1 -0
  116. package/dist/utils/wait.d.ts +43 -0
  117. package/dist/utils/wait.d.ts.map +1 -0
  118. package/dist/utils/wait.js +48 -5
  119. package/dist/utils/wait.js.map +1 -0
  120. package/frontend/build/asset-manifest.json +3 -3
  121. package/frontend/build/index.html +1 -1
  122. package/frontend/build/static/js/{main.f87f07b6.js → main.f60aae10.js} +8 -8
  123. package/frontend/build/static/js/main.f60aae10.js.map +1 -0
  124. package/npm-shrinkwrap.json +44 -44
  125. package/package.json +2 -2
  126. package/frontend/build/static/js/main.f87f07b6.js.map +0 -1
  127. /package/frontend/build/static/js/{main.f87f07b6.js.LICENSE.txt → main.f60aae10.js.LICENSE.txt} +0 -0
@@ -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, BLUE, CYAN, YELLOW, db, debugStringify, er, hk, or, zb } from './logger/export.js';
25
+ // Matterbridge
2
26
  import { bridgedNode } from './matterbridgeDeviceTypes.js';
3
27
  import { isValidNumber, isValidObject } from './utils/export.js';
4
28
  import { MatterbridgeBehavior, MatterbridgeBehaviorDevice, MatterbridgeIdentifyServer, MatterbridgeOnOffServer, MatterbridgeLevelControlServer, MatterbridgeColorControlServer, MatterbridgeWindowCoveringServer, MatterbridgeThermostatServer, MatterbridgeFanControlServer, MatterbridgeDoorLockServer, MatterbridgeModeSelectServer, MatterbridgeValveConfigurationAndControlServer, MatterbridgeSmokeCoAlarmServer, MatterbridgeBooleanStateConfigurationServer, MatterbridgeSwitchServer, } from './matterbridgeBehaviors.js';
5
29
  import { addClusterServers, addFixedLabel, addOptionalClusterServers, addRequiredClusterServers, addUserLabel, capitalizeFirstLetter, createUniqueId, getBehavior, getBehaviourTypesFromClusterClientIds, getBehaviourTypesFromClusterServerIds, getDefaultFlowMeasurementClusterServer, getDefaultIlluminanceMeasurementClusterServer, getDefaultPressureMeasurementClusterServer, getDefaultRelativeHumidityMeasurementClusterServer, getDefaultTemperatureMeasurementClusterServer, getDefaultOccupancySensingClusterServer, lowercaseFirstLetter, updateAttribute, getClusterId, getAttributeId, setAttribute, getAttribute, checkNotLatinCharacters, generateUniqueId, subscribeAttribute, } from './matterbridgeEndpointHelpers.js';
30
+ // @matter
6
31
  import { Endpoint, Lifecycle, MutableEndpoint, NamedHandler, SupportedBehaviors, 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';
@@ -26,6 +52,7 @@ import { ElectricalPowerMeasurement } from '@matter/main/clusters/electrical-pow
26
52
  import { ElectricalEnergyMeasurement } from '@matter/main/clusters/electrical-energy-measurement';
27
53
  import { AirQuality } from '@matter/main/clusters/air-quality';
28
54
  import { ConcentrationMeasurement } from '@matter/main/clusters/concentration-measurement';
55
+ // @matter behaviors
29
56
  import { DescriptorServer } from '@matter/main/behaviors/descriptor';
30
57
  import { PowerSourceServer } from '@matter/main/behaviors/power-source';
31
58
  import { BridgedDeviceBasicInformationServer } from '@matter/main/behaviors/bridged-device-basic-information';
@@ -56,7 +83,7 @@ import { RadonConcentrationMeasurementServer } from '@matter/main/behaviors/rado
56
83
  import { TotalVolatileOrganicCompoundsConcentrationMeasurementServer } from '@matter/main/behaviors/total-volatile-organic-compounds-concentration-measurement';
57
84
  export class MatterbridgeEndpoint extends Endpoint {
58
85
  static bridgeMode = '';
59
- static logLevel = "info";
86
+ static logLevel = "info" /* LogLevel.INFO */;
60
87
  log;
61
88
  plugin = undefined;
62
89
  configUrl = undefined;
@@ -72,14 +99,25 @@ export class MatterbridgeEndpoint extends Endpoint {
72
99
  hardwareVersion = undefined;
73
100
  hardwareVersionString = undefined;
74
101
  productUrl = 'https://www.npmjs.com/package/matterbridge';
102
+ // The first device type of the endpoint
75
103
  name = undefined;
76
104
  deviceType;
77
105
  uniqueStorageKey = undefined;
78
106
  tagList = undefined;
107
+ // Maps matter deviceTypes
79
108
  deviceTypes = new Map();
109
+ // Command handler
80
110
  commandHandler = new NamedHandler();
111
+ /**
112
+ * Represents a MatterbridgeEndpoint.
113
+ * @constructor
114
+ * @param {DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>} definition - The DeviceTypeDefinition(s) of the endpoint.
115
+ * @param {MatterbridgeEndpointOptions} [options={}] - The options for the device.
116
+ * @param {boolean} [debug=false] - Debug flag.
117
+ */
81
118
  constructor(definition, options = {}, debug = false) {
82
119
  let deviceTypeList = [];
120
+ // Get the first DeviceTypeDefinition
83
121
  let firstDefinition;
84
122
  if (Array.isArray(definition)) {
85
123
  firstDefinition = definition[0];
@@ -92,6 +130,7 @@ export class MatterbridgeEndpoint extends Endpoint {
92
130
  firstDefinition = definition;
93
131
  deviceTypeList = [{ deviceType: firstDefinition.code, revision: firstDefinition.revision }];
94
132
  }
133
+ // Convert the first DeviceTypeDefinition to an EndpointType.Options
95
134
  const deviceTypeDefinitionV8 = {
96
135
  name: firstDefinition.name.replace('-', '_'),
97
136
  deviceType: firstDefinition.code,
@@ -110,9 +149,11 @@ export class MatterbridgeEndpoint extends Endpoint {
110
149
  behaviors: options.tagList ? SupportedBehaviors(DescriptorServer.with(Descriptor.Feature.TagList)) : {},
111
150
  };
112
151
  const endpointV8 = MutableEndpoint(deviceTypeDefinitionV8);
152
+ // Check if the uniqueStorageKey is valid
113
153
  if (options.uniqueStorageKey && checkNotLatinCharacters(options.uniqueStorageKey)) {
114
154
  options.uniqueStorageKey = generateUniqueId(options.uniqueStorageKey);
115
155
  }
156
+ // Convert the options to an Endpoint.Options
116
157
  const optionsV8 = {
117
158
  id: options.uniqueStorageKey?.replace(/[ .]/g, ''),
118
159
  number: options.endpointId,
@@ -130,17 +171,41 @@ export class MatterbridgeEndpoint extends Endpoint {
130
171
  }
131
172
  else
132
173
  this.deviceTypes.set(firstDefinition.code, firstDefinition);
133
- this.log = new AnsiLogger({ logName: options.uniqueStorageKey ?? 'MatterbridgeEndpoint', logTimestampFormat: 4, logLevel: debug === true ? "debug" : MatterbridgeEndpoint.logLevel });
174
+ // console.log('MatterbridgeEndpoint.option', options);
175
+ // console.log('MatterbridgeEndpoint.endpointV8', endpointV8);
176
+ // console.log('MatterbridgeEndpoint.optionsV8', optionsV8);
177
+ // Create the logger
178
+ this.log = new AnsiLogger({ logName: options.uniqueStorageKey ?? 'MatterbridgeEndpoint', logTimestampFormat: 4 /* TimestampFormat.TIME_MILLIS */, logLevel: debug === true ? "debug" /* LogLevel.DEBUG */ : MatterbridgeEndpoint.logLevel });
134
179
  this.log.debug(`${YELLOW}new${db} MatterbridgeEndpoint: ${zb}${'0x' + firstDefinition.code.toString(16).padStart(4, '0')}${db}-${zb}${firstDefinition.name}${db} ` +
135
180
  `id: ${CYAN}${options.uniqueStorageKey}${db} number: ${CYAN}${options.endpointId}${db} taglist: ${CYAN}${options.tagList ? debugStringify(options.tagList) : 'undefined'}${db}`);
181
+ // Add MatterbridgeBehavior with MatterbridgeBehaviorDevice
136
182
  this.behaviors.require(MatterbridgeBehavior, { deviceCommand: new MatterbridgeBehaviorDevice(this.log, this.commandHandler, undefined) });
137
183
  }
184
+ /**
185
+ * Loads an instance of the MatterbridgeEndpoint class.
186
+ *
187
+ * @param {DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>} definition - The DeviceTypeDefinition(s) of the device.
188
+ * @param {MatterbridgeEndpointOptions} [options={}] - The options for the device.
189
+ * @param {boolean} [debug=false] - Debug flag.
190
+ * @returns {Promise<MatterbridgeEndpoint>} MatterbridgeEndpoint instance.
191
+ */
138
192
  static async loadInstance(definition, options = {}, debug = false) {
139
193
  return new MatterbridgeEndpoint(definition, options, debug);
140
194
  }
195
+ /**
196
+ * Get all the device types of this endpoint.
197
+ *
198
+ * @returns {DeviceTypeDefinition[]} The device types of this endpoint.
199
+ */
141
200
  getDeviceTypes() {
142
201
  return Array.from(this.deviceTypes.values());
143
202
  }
203
+ /**
204
+ * Checks if the provided cluster server is supported by this endpoint.
205
+ *
206
+ * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to check.
207
+ * @returns {boolean} True if the cluster server is supported, false otherwise.
208
+ */
144
209
  hasClusterServer(cluster) {
145
210
  const behavior = getBehavior(this, cluster);
146
211
  if (behavior)
@@ -148,6 +213,13 @@ export class MatterbridgeEndpoint extends Endpoint {
148
213
  else
149
214
  return false;
150
215
  }
216
+ /**
217
+ * Checks if the provided attribute server is supported for a given cluster of this endpoint.
218
+ *
219
+ * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to check.
220
+ * @param {string} attribute - The attribute name to check.
221
+ * @returns {boolean} True if the attribute server is supported, false otherwise.
222
+ */
151
223
  hasAttributeServer(cluster, attribute) {
152
224
  const behavior = getBehavior(this, cluster);
153
225
  if (!behavior || !this.behaviors.supported[behavior.id])
@@ -156,87 +228,219 @@ export class MatterbridgeEndpoint extends Endpoint {
156
228
  const defaults = this.behaviors.defaultsFor(behavior);
157
229
  return lowercaseFirstLetter(attribute) in options || lowercaseFirstLetter(attribute) in defaults;
158
230
  }
231
+ /**
232
+ * Retrieves the initial options for the provided cluster server.
233
+ *
234
+ * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to get options for.
235
+ * @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.
236
+ */
159
237
  getClusterServerOptions(cluster) {
160
238
  const behavior = getBehavior(this, cluster);
161
239
  if (!behavior)
162
240
  return undefined;
163
241
  return this.behaviors.optionsFor(behavior);
164
242
  }
243
+ /**
244
+ * Retrieves the value of the provided attribute from the given cluster.
245
+ *
246
+ * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to retrieve the attribute from.
247
+ * @param {string} attribute - The name of the attribute to retrieve.
248
+ * @param {AnsiLogger} [log] - Optional logger for error and info messages.
249
+ * @returns {any} The value of the attribute, or undefined if the attribute is not found.
250
+ */
251
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
165
252
  getAttribute(cluster, attribute, log) {
166
253
  return getAttribute(this, cluster, attribute, log);
167
254
  }
255
+ /**
256
+ * Sets the value of an attribute on a cluster server.
257
+ *
258
+ * @param {Behavior.Type | ClusterType | ClusterId | string} clusterId - The ID of the cluster.
259
+ * @param {string} attribute - The name of the attribute.
260
+ * @param {boolean | number | bigint | string | object | null} value - The value to set for the attribute.
261
+ * @param {AnsiLogger} [log] - (Optional) The logger to use for logging errors and information.
262
+ * @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the attribute was successfully set.
263
+ */
168
264
  async setAttribute(clusterId, attribute, value, log) {
169
265
  return await setAttribute(this, clusterId, attribute, value, log);
170
266
  }
267
+ /**
268
+ * Update the value of an attribute on a cluster server only if the value is different.
269
+ *
270
+ * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to set the attribute on.
271
+ * @param {string} attribute - The name of the attribute.
272
+ * @param {boolean | number | bigint | string | object | null} value - The value to set for the attribute.
273
+ * @param {AnsiLogger} [log] - (Optional) The logger to use for logging the update. Errors are logged to the endpoint logger.
274
+ * @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the attribute was successfully set.
275
+ */
171
276
  async updateAttribute(cluster, attribute, value, log) {
172
277
  return await updateAttribute(this, cluster, attribute, value, log);
173
278
  }
279
+ /**
280
+ * Subscribes to the provided attribute on a cluster.
281
+ *
282
+ * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to subscribe the attribute to.
283
+ * @param {string} attribute - The name of the attribute to subscribe to.
284
+ * @param {(newValue: any, oldValue: any) => void} listener - A callback function that will be called when the attribute value changes.
285
+ * @param {AnsiLogger} [log] - Optional logger for logging errors and information.
286
+ * @returns {Promise<boolean>} - A boolean indicating whether the subscription was successful.
287
+ */
288
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
174
289
  async subscribeAttribute(cluster, attribute, listener, log) {
175
290
  return await subscribeAttribute(this, cluster, attribute, listener, log);
176
291
  }
292
+ /**
293
+ * Triggers an event on the specified cluster.
294
+ *
295
+ * @param {ClusterId} clusterId - The ID of the cluster.
296
+ * @param {string} event - The name of the event to trigger.
297
+ * @param {Record<string, boolean | number | bigint | string | object | undefined | null>} payload - The payload to pass to the event.
298
+ * @param {AnsiLogger} [log] - Optional logger for logging information.
299
+ * @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the event was successfully triggered.
300
+ */
177
301
  async triggerEvent(clusterId, event, payload, log) {
178
302
  const clusterName = lowercaseFirstLetter(getClusterNameById(clusterId));
179
303
  if (this.construction.status !== Lifecycle.Status.Active) {
180
304
  this.log.error(`triggerEvent ${hk}${clusterName}.${event}${er} error: Endpoint ${or}${this.maybeId}${er}:${or}${this.maybeNumber}${er} is in the ${BLUE}${this.construction.status}${er} state`);
181
305
  return false;
182
306
  }
307
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
183
308
  const events = this.events;
184
309
  if (!(clusterName in events) || !(event in events[clusterName])) {
185
310
  this.log.error(`triggerEvent ${hk}${event}${er} error: Cluster ${'0x' + clusterId.toString(16).padStart(4, '0')}:${clusterName} not found on endpoint ${or}${this.id}${er}:${or}${this.number}${er}`);
186
311
  return false;
187
312
  }
313
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
314
+ // @ts-ignore
188
315
  await this.act((agent) => agent[clusterName].events[event].emit(payload, agent.context));
189
316
  log?.info(`${db}Trigger event ${hk}${capitalizeFirstLetter(clusterName)}${db}.${hk}${event}${db} with ${debugStringify(payload)}${db} on endpoint ${or}${this.id}${db}:${or}${this.number}${db} `);
190
317
  return true;
191
318
  }
319
+ /**
320
+ * Adds cluster servers from the provided server list.
321
+ *
322
+ * @param {ClusterId[]} serverList - The list of cluster IDs to add.
323
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
324
+ */
192
325
  addClusterServers(serverList) {
193
326
  addClusterServers(this, serverList);
194
327
  return this;
195
328
  }
329
+ /**
330
+ * Adds a fixed label to the FixedLabel cluster. If the cluster server is not present, it will be added.
331
+ *
332
+ * @param {string} label - The label to add.
333
+ * @param {string} value - The value of the label.
334
+ * @returns {Promise<this>} The current MatterbridgeEndpoint instance for chaining.
335
+ */
196
336
  async addFixedLabel(label, value) {
197
337
  await addFixedLabel(this, label, value);
198
338
  return this;
199
339
  }
340
+ /**
341
+ * Adds a user label to the UserLabel cluster. If the cluster server is not present, it will be added.
342
+ *
343
+ * @param {string} label - The label to add.
344
+ * @param {string} value - The value of the label.
345
+ * @returns {Promise<this>} The current MatterbridgeEndpoint instance for chaining.
346
+ */
200
347
  async addUserLabel(label, value) {
201
348
  await addUserLabel(this, label, value);
202
349
  return this;
203
350
  }
351
+ /**
352
+ * Adds a command handler for the specified command.
353
+ *
354
+ * @param {keyof MatterbridgeEndpointCommands} command - The command to add the handler for.
355
+ * @param {HandlerFunction} handler - The handler function to execute when the command is received.
356
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
357
+ */
204
358
  addCommandHandler(command, handler) {
205
359
  this.commandHandler.addHandler(command, handler);
206
360
  return this;
207
361
  }
362
+ /**
363
+ * Execute the command handler for the specified command. Mainly used in Jest tests.
364
+ *
365
+ * @param {keyof MatterbridgeEndpointCommands} command - The command to execute.
366
+ * @param {Record<string, boolean | number | bigint | string | object | null>} request - The optional request to pass to the handler function.
367
+ * @returns {Promise<void>} A promise that resolves when the command handler has been executed
368
+ */
208
369
  async executeCommandHandler(command, request) {
209
370
  await this.commandHandler.executeHandler(command, { request });
210
371
  }
372
+ /**
373
+ * Adds the required cluster servers (only if they are not present) for the device types of the specified endpoint.
374
+ *
375
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
376
+ */
211
377
  addRequiredClusterServers() {
212
378
  addRequiredClusterServers(this);
213
379
  return this;
214
380
  }
381
+ /**
382
+ * Adds the optional cluster servers (only if they are not present) for the device types of the specified endpoint.
383
+ *
384
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
385
+ */
215
386
  addOptionalClusterServers() {
216
387
  addOptionalClusterServers(this);
217
388
  return this;
218
389
  }
390
+ /**
391
+ * Retrieves all cluster servers.
392
+ *
393
+ * @returns {Behavior.Type[]} An array of all cluster servers.
394
+ */
219
395
  getAllClusterServers() {
220
396
  return Object.values(this.behaviors.supported);
221
397
  }
398
+ /**
399
+ * Retrieves the names of all cluster servers.
400
+ *
401
+ * @returns {string[]} An array of all cluster server names.
402
+ */
222
403
  getAllClusterServerNames() {
223
404
  return Object.keys(this.behaviors.supported);
224
405
  }
406
+ /**
407
+ * Iterates over each attribute of each cluster server of the device state and calls the provided callback function.
408
+ *
409
+ * @param {Function} callback - The callback function to call with the cluster name, cluster id, attribute name, attribute id and attribute value.
410
+ */
225
411
  forEachAttribute(callback) {
226
412
  for (const [clusterName, clusterAttributes] of Object.entries(this.state)) {
227
413
  for (const [attributeName, attributeValue] of Object.entries(clusterAttributes)) {
228
414
  const clusterId = getClusterId(this, clusterName);
229
415
  if (clusterId === undefined) {
416
+ // this.log.error(`forEachAttribute error: cluster ${clusterName} not found`);
230
417
  continue;
231
418
  }
232
419
  const attributeId = getAttributeId(this, clusterName, attributeName);
233
420
  if (attributeId === undefined) {
421
+ // this.log.error(`forEachAttribute error: attribute ${clusterName}.${attributeName} not found`);
234
422
  continue;
235
423
  }
236
424
  callback(clusterName, clusterId, attributeName, attributeId, attributeValue);
237
425
  }
238
426
  }
239
427
  }
428
+ /**
429
+ * Adds a child endpoint with the specified device types and options.
430
+ * If the child endpoint is not already present, it will be created and added.
431
+ * If the child endpoint is already present, the existing child endpoint will be returned.
432
+ *
433
+ * @param {string} endpointName - The name of the new endpoint to add.
434
+ * @param {DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>} definition - The device types to add.
435
+ * @param {MatterbridgeEndpointOptions} [options={}] - The options for the endpoint.
436
+ * @param {boolean} [debug=false] - Whether to enable debug logging.
437
+ * @returns {MatterbridgeEndpoint} - The child endpoint that was found or added.
438
+ *
439
+ * @example
440
+ * ```typescript
441
+ * const endpoint = device.addChildDeviceType('Temperature', [temperatureSensor], { tagList: [{ mfgCode: null, namespaceId: LocationTag.Indoor.namespaceId, tag: LocationTag.Indoor.tag, label: null }] }, true);
442
+ * ```
443
+ */
240
444
  addChildDeviceType(endpointName, definition, options = {}, debug = false) {
241
445
  this.log.debug(`addChildDeviceType: ${CYAN}${endpointName}${db}`);
242
446
  let alreadyAdded = false;
@@ -276,6 +480,23 @@ export class MatterbridgeEndpoint extends Endpoint {
276
480
  }
277
481
  return child;
278
482
  }
483
+ /**
484
+ * Adds a child endpoint with one or more device types with the required cluster servers and the specified cluster servers.
485
+ * If the child endpoint is not already present in the childEndpoints, it will be added.
486
+ * If the child endpoint is already present in the childEndpoints, the device types and cluster servers will be added to the existing child endpoint.
487
+ *
488
+ * @param {string} endpointName - The name of the new enpoint to add.
489
+ * @param {DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>} definition - The device types to add.
490
+ * @param {ClusterId[]} [serverList=[]] - The list of cluster IDs to include.
491
+ * @param {MatterbridgeEndpointOptions} [options={}] - The options for the device.
492
+ * @param {boolean} [debug=false] - Whether to enable debug logging.
493
+ * @returns {MatterbridgeEndpoint} - The child endpoint that was found or added.
494
+ *
495
+ * @example
496
+ * ```typescript
497
+ * const endpoint = device.addChildDeviceTypeWithClusterServer('Temperature', [temperatureSensor], [], { tagList: [{ mfgCode: null, namespaceId: LocationTag.Indoor.namespaceId, tag: LocationTag.Indoor.tag, label: null }] }, true);
498
+ * ```
499
+ */
279
500
  addChildDeviceTypeWithClusterServer(endpointName, definition, serverList = [], options = {}, debug = false) {
280
501
  this.log.debug(`addChildDeviceTypeWithClusterServer: ${CYAN}${endpointName}${db}`);
281
502
  let alreadyAdded = false;
@@ -338,15 +559,38 @@ export class MatterbridgeEndpoint extends Endpoint {
338
559
  }
339
560
  return child;
340
561
  }
562
+ /**
563
+ * Retrieves a child endpoint by its name.
564
+ *
565
+ * @param {string} endpointName - The name of the endpoint to retrieve.
566
+ * @returns {Endpoint | undefined} The child endpoint with the specified name, or undefined if not found.
567
+ */
341
568
  getChildEndpointByName(endpointName) {
342
569
  return this.parts.find((part) => part.id === endpointName);
343
570
  }
571
+ /**
572
+ * Retrieves a child endpoint by its EndpointNumber.
573
+ *
574
+ * @param {EndpointNumber} endpointNumber - The EndpointNumber of the endpoint to retrieve.
575
+ * @returns {MatterbridgeEndpoint | undefined} The child endpoint with the specified EndpointNumber, or undefined if not found.
576
+ */
344
577
  getChildEndpoint(endpointNumber) {
345
578
  return this.parts.find((part) => part.number === endpointNumber);
346
579
  }
580
+ /**
581
+ * Get all the child endpoints of this endpoint.
582
+ *
583
+ * @returns {MatterbridgeEndpoint[]} The child endpoints.
584
+ */
347
585
  getChildEndpoints() {
348
586
  return Array.from(this.parts);
349
587
  }
588
+ /**
589
+ * Serializes the Matterbridge device into a serialized object.
590
+ *
591
+ * @param pluginName - The name of the plugin.
592
+ * @returns The serialized Matterbridge device object.
593
+ */
350
594
  static serialize(device) {
351
595
  if (!device.serialNumber || !device.deviceName || !device.uniqueId)
352
596
  return;
@@ -369,9 +613,15 @@ export class MatterbridgeEndpoint extends Endpoint {
369
613
  serialized.clusterServersId.push(BridgedDeviceBasicInformation.Cluster.id);
370
614
  if (behaviorName === 'powerSource')
371
615
  serialized.clusterServersId.push(PowerSource.Cluster.id);
616
+ // serialized.clusterServersId.push(this.behaviors.supported[behaviorName]cluster.id);
372
617
  });
373
618
  return serialized;
374
619
  }
620
+ /**
621
+ * Deserializes the device into a serialized object.
622
+ *
623
+ * @returns The deserialized MatterbridgeDevice.
624
+ */
375
625
  static deserialize(serializedDevice) {
376
626
  const device = new MatterbridgeEndpoint(serializedDevice.deviceTypes, { uniqueStorageKey: serializedDevice.endpointName, endpointId: serializedDevice.endpoint }, false);
377
627
  device.plugin = serializedDevice.pluginName;
@@ -387,9 +637,16 @@ export class MatterbridgeEndpoint extends Endpoint {
387
637
  device.createDefaultBridgedDeviceBasicInformationClusterServer(serializedDevice.deviceName, serializedDevice.serialNumber, serializedDevice.vendorId ?? 0xfff1, serializedDevice.vendorName ?? 'Matterbridge', serializedDevice.productName ?? 'Matterbridge device');
388
638
  else if (clusterId === PowerSource.Cluster.id)
389
639
  device.createDefaultPowerSourceWiredClusterServer();
640
+ // else addClusterServerFromList(device, [clusterId]);
390
641
  }
391
642
  return device;
392
643
  }
644
+ /**
645
+ * Creates a default power source wired cluster server.
646
+ *
647
+ * @param wiredCurrentType - The type of wired current (default: PowerSource.WiredCurrentType.Ac)
648
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
649
+ */
393
650
  createDefaultPowerSourceWiredClusterServer(wiredCurrentType = PowerSource.WiredCurrentType.Ac) {
394
651
  this.behaviors.require(PowerSourceServer.with(PowerSource.Feature.Wired), {
395
652
  wiredCurrentType,
@@ -400,6 +657,16 @@ export class MatterbridgeEndpoint extends Endpoint {
400
657
  });
401
658
  return this;
402
659
  }
660
+ /**
661
+ * Creates a default power source replaceable battery cluster server.
662
+ *
663
+ * @param batPercentRemaining - The remaining battery percentage (default: 100).
664
+ * @param batChargeLevel - The battery charge level (default: PowerSource.BatChargeLevel.Ok).
665
+ * @param batVoltage - The battery voltage (default: 1500).
666
+ * @param batReplacementDescription - The battery replacement description (default: 'Battery type').
667
+ * @param batQuantity - The battery quantity (default: 1).
668
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
669
+ */
403
670
  createDefaultPowerSourceReplaceableBatteryClusterServer(batPercentRemaining = 100, batChargeLevel = PowerSource.BatChargeLevel.Ok, batVoltage = 1500, batReplacementDescription = 'Battery type', batQuantity = 1) {
404
671
  this.behaviors.require(PowerSourceServer.with(PowerSource.Feature.Battery, PowerSource.Feature.Replaceable), {
405
672
  status: PowerSource.PowerSourceStatus.Active,
@@ -417,6 +684,14 @@ export class MatterbridgeEndpoint extends Endpoint {
417
684
  });
418
685
  return this;
419
686
  }
687
+ /**
688
+ * Creates a default power source rechargeable battery cluster server.
689
+ *
690
+ * @param batPercentRemaining - The remaining battery percentage (default: 100).
691
+ * @param batChargeLevel - The battery charge level (default: PowerSource.BatChargeLevel.Ok).
692
+ * @param batVoltage - The battery voltage (default: 1500).
693
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
694
+ */
420
695
  createDefaultPowerSourceRechargeableBatteryClusterServer(batPercentRemaining = 100, batChargeLevel = PowerSource.BatChargeLevel.Ok, batVoltage = 1500) {
421
696
  this.behaviors.require(PowerSourceServer.with(PowerSource.Feature.Battery, PowerSource.Feature.Rechargeable), {
422
697
  status: PowerSource.PowerSourceStatus.Active,
@@ -435,6 +710,21 @@ export class MatterbridgeEndpoint extends Endpoint {
435
710
  });
436
711
  return this;
437
712
  }
713
+ /**
714
+ * Creates a default Basic Information Cluster Server for the server node.
715
+ *
716
+ * @param deviceName - The name of the device.
717
+ * @param serialNumber - The serial number of the device.
718
+ * @param vendorId - The vendor ID of the device.
719
+ * @param vendorName - The vendor name of the device.
720
+ * @param productId - The product ID of the device.
721
+ * @param productName - The product name of the device.
722
+ * @param softwareVersion - The software version of the device. Default is 1.
723
+ * @param softwareVersionString - The software version string of the device. Default is 'v.1.0.0'.
724
+ * @param hardwareVersion - The hardware version of the device. Default is 1.
725
+ * @param hardwareVersionString - The hardware version string of the device. Default is 'v.1.0.0'.
726
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
727
+ */
438
728
  createDefaultBasicInformationClusterServer(deviceName, serialNumber, vendorId, vendorName, productId, productName, softwareVersion = 1, softwareVersionString = '1.0.0', hardwareVersion = 1, hardwareVersionString = '1.0.0') {
439
729
  this.log.logName = deviceName;
440
730
  this.deviceName = deviceName;
@@ -458,6 +748,20 @@ export class MatterbridgeEndpoint extends Endpoint {
458
748
  }
459
749
  return this;
460
750
  }
751
+ /**
752
+ * Creates a default BridgedDeviceBasicInformationClusterServer for the aggregator endpoints.
753
+ *
754
+ * @param deviceName - The name of the device.
755
+ * @param serialNumber - The serial number of the device.
756
+ * @param vendorId - The vendor ID of the device.
757
+ * @param vendorName - The name of the vendor.
758
+ * @param productName - The name of the product.
759
+ * @param softwareVersion - The software version of the device. Default is 1.
760
+ * @param softwareVersionString - The software version string of the device. Default is 'v.1.0.0'.
761
+ * @param hardwareVersion - The hardware version of the device. Default is 1.
762
+ * @param hardwareVersionString - The hardware version string of the device. Default is 'v.1.0.0'.
763
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
764
+ */
461
765
  createDefaultBridgedDeviceBasicInformationClusterServer(deviceName, serialNumber, vendorId, vendorName, productName, softwareVersion = 1, softwareVersionString = '1.0.0', hardwareVersion = 1, hardwareVersionString = '1.0.0') {
462
766
  this.log.logName = deviceName;
463
767
  this.deviceName = deviceName;
@@ -474,7 +778,7 @@ export class MatterbridgeEndpoint extends Endpoint {
474
778
  this.behaviors.require(BridgedDeviceBasicInformationServer.enable({
475
779
  events: { leave: true, reachableChanged: true },
476
780
  }), {
477
- vendorId: vendorId !== undefined ? VendorId(vendorId) : undefined,
781
+ vendorId: vendorId !== undefined ? VendorId(vendorId) : undefined, // 4874
478
782
  vendorName: vendorName.slice(0, 32),
479
783
  productName: productName.slice(0, 32),
480
784
  productUrl: this.productUrl,
@@ -490,6 +794,13 @@ export class MatterbridgeEndpoint extends Endpoint {
490
794
  });
491
795
  return this;
492
796
  }
797
+ /**
798
+ * Creates a default identify cluster server with the specified identify time and type.
799
+ *
800
+ * @param {number} [identifyTime=0] - The time to identify the server. Defaults to 0.
801
+ * @param {Identify.IdentifyType} [identifyType=Identify.IdentifyType.None] - The type of identification. Defaults to Identify.IdentifyType.None.
802
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
803
+ */
493
804
  createDefaultIdentifyClusterServer(identifyTime = 0, identifyType = Identify.IdentifyType.None) {
494
805
  this.behaviors.require(MatterbridgeIdentifyServer, {
495
806
  identifyTime,
@@ -497,14 +808,32 @@ export class MatterbridgeEndpoint extends Endpoint {
497
808
  });
498
809
  return this;
499
810
  }
811
+ /**
812
+ * Creates a default groups cluster server.
813
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
814
+ */
500
815
  createDefaultGroupsClusterServer() {
501
816
  this.behaviors.require(GroupsServer);
502
817
  return this;
503
818
  }
819
+ /**
820
+ * Creates a default scenes management cluster server.
821
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
822
+ */
504
823
  createDefaultScenesClusterServer() {
505
824
  this.behaviors.require(ScenesManagementServer);
506
825
  return this;
507
826
  }
827
+ /**
828
+ * Creates a default OnOff cluster server for light devices.
829
+ *
830
+ * @param {boolean} [onOff=false] - The initial state of the OnOff cluster.
831
+ * @param {boolean} [globalSceneControl=false] - The global scene control state.
832
+ * @param {number} [onTime=0] - The on time value.
833
+ * @param {number} [offWaitTime=0] - The off wait time value.
834
+ * @param {OnOff.StartUpOnOff | null} [startUpOnOff=null] - The start-up OnOff state. Null means previous state.
835
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
836
+ */
508
837
  createDefaultOnOffClusterServer(onOff = false, globalSceneControl = false, onTime = 0, offWaitTime = 0, startUpOnOff = null) {
509
838
  this.behaviors.require(MatterbridgeOnOffServer.with(OnOff.Feature.Lighting), {
510
839
  onOff,
@@ -515,18 +844,40 @@ export class MatterbridgeEndpoint extends Endpoint {
515
844
  });
516
845
  return this;
517
846
  }
847
+ /**
848
+ * Creates an OnOff cluster server without features.
849
+ *
850
+ * @param {boolean} [onOff=false] - The initial state of the OnOff cluster.
851
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
852
+ */
518
853
  createOnOffClusterServer(onOff = false) {
519
854
  this.behaviors.require(MatterbridgeOnOffServer, {
520
855
  onOff,
521
856
  });
522
857
  return this;
523
858
  }
859
+ /**
860
+ * Creates a DeadFront OnOff cluster server.
861
+ *
862
+ * @param {boolean} [onOff=false] - The initial state of the OnOff cluster.
863
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
864
+ */
524
865
  createDeadFrontOnOffClusterServer(onOff = false) {
525
866
  this.behaviors.require(MatterbridgeOnOffServer.with(OnOff.Feature.DeadFrontBehavior), {
526
867
  onOff,
527
868
  });
528
869
  return this;
529
870
  }
871
+ /**
872
+ * Creates a default level control cluster server for light devices.
873
+ *
874
+ * @param {number} [currentLevel=254] - The current level (default: 254).
875
+ * @param {number} [minLevel=1] - The minimum level (default: 1).
876
+ * @param {number} [maxLevel=254] - The maximum level (default: 254).
877
+ * @param {number | null} [onLevel=null] - The on level (default: null).
878
+ * @param {number | null} [startUpCurrentLevel=null] - The startUp on level (default: null).
879
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
880
+ */
530
881
  createDefaultLevelControlClusterServer(currentLevel = 254, minLevel = 1, maxLevel = 254, onLevel = null, startUpCurrentLevel = null) {
531
882
  this.behaviors.require(MatterbridgeLevelControlServer.with(LevelControl.Feature.OnOff, LevelControl.Feature.Lighting), {
532
883
  currentLevel,
@@ -542,6 +893,18 @@ export class MatterbridgeEndpoint extends Endpoint {
542
893
  });
543
894
  return this;
544
895
  }
896
+ /**
897
+ * Creates a default color control cluster server with Xy, HueSaturation and ColorTemperature.
898
+ *
899
+ * @param currentX - The current X value.
900
+ * @param currentY - The current Y value.
901
+ * @param currentHue - The current hue value.
902
+ * @param currentSaturation - The current saturation value.
903
+ * @param colorTemperatureMireds - The color temperature in mireds.
904
+ * @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds.
905
+ * @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds.
906
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
907
+ */
545
908
  createDefaultColorControlClusterServer(currentX = 0, currentY = 0, currentHue = 0, currentSaturation = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
546
909
  this.behaviors.require(MatterbridgeColorControlServer.with(ColorControl.Feature.Xy, ColorControl.Feature.HueSaturation, ColorControl.Feature.ColorTemperature), {
547
910
  colorMode: ColorControl.ColorMode.CurrentHueAndCurrentSaturation,
@@ -564,6 +927,19 @@ export class MatterbridgeEndpoint extends Endpoint {
564
927
  });
565
928
  return this;
566
929
  }
930
+ /**
931
+ * Creates a Xy color control cluster server with Xy and ColorTemperature.
932
+ *
933
+ * @param currentX - The current X value.
934
+ * @param currentY - The current Y value.
935
+ * @param colorTemperatureMireds - The color temperature in mireds.
936
+ * @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds.
937
+ * @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds.
938
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
939
+ *
940
+ * @remarks
941
+ * From zigbee to matter = Math.max(Math.min(Math.round(x * 65536), 65279), 0)
942
+ */
567
943
  createXyColorControlClusterServer(currentX = 0, currentY = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
568
944
  this.behaviors.require(MatterbridgeColorControlServer.with(ColorControl.Feature.Xy, ColorControl.Feature.ColorTemperature), {
569
945
  colorMode: ColorControl.ColorMode.CurrentXAndCurrentY,
@@ -584,6 +960,16 @@ export class MatterbridgeEndpoint extends Endpoint {
584
960
  });
585
961
  return this;
586
962
  }
963
+ /**
964
+ * Creates a default hue and saturation control cluster server with HueSaturation and ColorTemperature.
965
+ *
966
+ * @param currentHue - The current hue value.
967
+ * @param currentSaturation - The current saturation value.
968
+ * @param colorTemperatureMireds - The color temperature in mireds.
969
+ * @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds.
970
+ * @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds.
971
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
972
+ */
587
973
  createHsColorControlClusterServer(currentHue = 0, currentSaturation = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
588
974
  this.behaviors.require(MatterbridgeColorControlServer.with(ColorControl.Feature.HueSaturation, ColorControl.Feature.ColorTemperature), {
589
975
  colorMode: ColorControl.ColorMode.CurrentHueAndCurrentSaturation,
@@ -604,6 +990,14 @@ export class MatterbridgeEndpoint extends Endpoint {
604
990
  });
605
991
  return this;
606
992
  }
993
+ /**
994
+ * Creates a color temperature color control cluster server.
995
+ *
996
+ * @param colorTemperatureMireds - The color temperature in mireds.
997
+ * @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds.
998
+ * @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds.
999
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1000
+ */
607
1001
  createCtColorControlClusterServer(colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
608
1002
  this.behaviors.require(MatterbridgeColorControlServer.with(ColorControl.Feature.ColorTemperature), {
609
1003
  colorMode: ColorControl.ColorMode.ColorTemperatureMireds,
@@ -622,12 +1016,23 @@ export class MatterbridgeEndpoint extends Endpoint {
622
1016
  });
623
1017
  return this;
624
1018
  }
1019
+ /**
1020
+ * Configures the color control mode for the device.
1021
+ *
1022
+ * @param {ColorControl.ColorMode} colorMode - The color mode to set.
1023
+ */
625
1024
  async configureColorControlMode(colorMode) {
626
1025
  if (isValidNumber(colorMode, ColorControl.ColorMode.CurrentHueAndCurrentSaturation, ColorControl.ColorMode.ColorTemperatureMireds)) {
627
1026
  await this.setAttribute(ColorControl.Cluster.id, 'colorMode', colorMode, this.log);
628
1027
  await this.setAttribute(ColorControl.Cluster.id, 'enhancedColorMode', colorMode, this.log);
629
1028
  }
630
1029
  }
1030
+ /**
1031
+ * Creates a default window covering cluster server (Lift and PositionAwareLift).
1032
+ *
1033
+ * @param positionPercent100ths - The position percentage in 100ths (0-10000). Defaults to 0. Matter uses 10000 = fully closed 0 = fully opened.
1034
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1035
+ */
631
1036
  createDefaultWindowCoveringClusterServer(positionPercent100ths) {
632
1037
  this.behaviors.require(MatterbridgeWindowCoveringServer.with(WindowCovering.Feature.Lift, WindowCovering.Feature.PositionAwareLift), {
633
1038
  type: WindowCovering.WindowCoveringType.Rollershade,
@@ -643,11 +1048,15 @@ export class MatterbridgeEndpoint extends Endpoint {
643
1048
  operationalStatus: { global: WindowCovering.MovementStatus.Stopped, lift: WindowCovering.MovementStatus.Stopped, tilt: WindowCovering.MovementStatus.Stopped },
644
1049
  endProductType: WindowCovering.EndProductType.RollerShade,
645
1050
  mode: { motorDirectionReversed: false, calibrationMode: false, maintenanceMode: false, ledFeedback: false },
646
- targetPositionLiftPercent100ths: positionPercent100ths ?? 0,
647
- currentPositionLiftPercent100ths: positionPercent100ths ?? 0,
1051
+ targetPositionLiftPercent100ths: positionPercent100ths ?? 0, // 0 Fully open 10000 fully closed
1052
+ currentPositionLiftPercent100ths: positionPercent100ths ?? 0, // 0 Fully open 10000 fully closed
648
1053
  });
649
1054
  return this;
650
1055
  }
1056
+ /**
1057
+ * Sets the window covering target position as the current position and stops the movement.
1058
+ *
1059
+ */
651
1060
  async setWindowCoveringTargetAsCurrentAndStopped() {
652
1061
  const position = this.getAttribute(WindowCovering.Cluster.id, 'currentPositionLiftPercent100ths', this.log);
653
1062
  if (isValidNumber(position, 0, 10000)) {
@@ -660,6 +1069,12 @@ export class MatterbridgeEndpoint extends Endpoint {
660
1069
  }
661
1070
  this.log.debug(`Set WindowCovering currentPositionLiftPercent100ths and targetPositionLiftPercent100ths to ${position} and operationalStatus to Stopped.`);
662
1071
  }
1072
+ /**
1073
+ * Sets the current and target status of a window covering.
1074
+ * @param {number} current - The current position of the window covering.
1075
+ * @param {number} target - The target position of the window covering.
1076
+ * @param {WindowCovering.MovementStatus} status - The movement status of the window covering.
1077
+ */
663
1078
  async setWindowCoveringCurrentTargetStatus(current, target, status) {
664
1079
  await this.setAttribute(WindowCovering.Cluster.id, 'currentPositionLiftPercent100ths', current, this.log);
665
1080
  await this.setAttribute(WindowCovering.Cluster.id, 'targetPositionLiftPercent100ths', target, this.log);
@@ -670,6 +1085,10 @@ export class MatterbridgeEndpoint extends Endpoint {
670
1085
  }, this.log);
671
1086
  this.log.debug(`Set WindowCovering currentPositionLiftPercent100ths: ${current}, targetPositionLiftPercent100ths: ${target} and operationalStatus: ${status}.`);
672
1087
  }
1088
+ /**
1089
+ * Sets the status of the window covering.
1090
+ * @param {WindowCovering.MovementStatus} status - The movement status to set.
1091
+ */
673
1092
  async setWindowCoveringStatus(status) {
674
1093
  await this.setAttribute(WindowCovering.Cluster.id, 'operationalStatus', {
675
1094
  global: status,
@@ -678,6 +1097,11 @@ export class MatterbridgeEndpoint extends Endpoint {
678
1097
  }, this.log);
679
1098
  this.log.debug(`Set WindowCovering operationalStatus: ${status}`);
680
1099
  }
1100
+ /**
1101
+ * Retrieves the status of the window covering.
1102
+ *
1103
+ * @returns The global operational status of the window covering or undefined.
1104
+ */
681
1105
  getWindowCoveringStatus() {
682
1106
  const status = this.getAttribute(WindowCovering.Cluster.id, 'operationalStatus', this.log);
683
1107
  if (isValidObject(status, 3) && 'global' in status && typeof status.global === 'number') {
@@ -685,36 +1109,66 @@ export class MatterbridgeEndpoint extends Endpoint {
685
1109
  return status.global;
686
1110
  }
687
1111
  }
1112
+ /**
1113
+ * Sets the target and current position of the window covering.
1114
+ *
1115
+ * @param position - The position to set, specified as a number.
1116
+ */
688
1117
  async setWindowCoveringTargetAndCurrentPosition(position) {
689
1118
  await this.setAttribute(WindowCovering.Cluster.id, 'currentPositionLiftPercent100ths', position, this.log);
690
1119
  await this.setAttribute(WindowCovering.Cluster.id, 'targetPositionLiftPercent100ths', position, this.log);
691
1120
  this.log.debug(`Set WindowCovering currentPositionLiftPercent100ths: ${position} and targetPositionLiftPercent100ths: ${position}.`);
692
1121
  }
1122
+ /**
1123
+ * Creates a default thermostat cluster server with Thermostat.Feature.Heating, Thermostat.Feature.Cooling, Thermostat.Feature.AutoMode.
1124
+ *
1125
+ * @param {number} [localTemperature=23] - The local temperature value in degrees Celsius. Defaults to 23°.
1126
+ * @param {number} [occupiedHeatingSetpoint=21] - The occupied heating setpoint value in degrees Celsius. Defaults to 21°.
1127
+ * @param {number} [occupiedCoolingSetpoint=25] - The occupied cooling setpoint value in degrees Celsius. Defaults to 25°.
1128
+ * @param {number} [minSetpointDeadBand=1] - The minimum setpoint dead band value. Defaults to 1°.
1129
+ * @param {number} [minHeatSetpointLimit=0] - The minimum heat setpoint limit value. Defaults to 0°.
1130
+ * @param {number} [maxHeatSetpointLimit=50] - The maximum heat setpoint limit value. Defaults to 50°.
1131
+ * @param {number} [minCoolSetpointLimit=0] - The minimum cool setpoint limit value. Defaults to 0°.
1132
+ * @param {number} [maxCoolSetpointLimit=50] - The maximum cool setpoint limit value. Defaults to 50°.
1133
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1134
+ */
693
1135
  createDefaultThermostatClusterServer(localTemperature = 23, occupiedHeatingSetpoint = 21, occupiedCoolingSetpoint = 25, minSetpointDeadBand = 1, minHeatSetpointLimit = 0, maxHeatSetpointLimit = 50, minCoolSetpointLimit = 0, maxCoolSetpointLimit = 50) {
694
1136
  this.behaviors.require(MatterbridgeThermostatServer.with(Thermostat.Feature.Heating, Thermostat.Feature.Cooling, Thermostat.Feature.AutoMode), {
695
1137
  localTemperature: localTemperature * 100,
696
1138
  systemMode: Thermostat.SystemMode.Auto,
697
1139
  controlSequenceOfOperation: Thermostat.ControlSequenceOfOperation.CoolingAndHeating,
1140
+ // Thermostat.Feature.Heating
698
1141
  occupiedHeatingSetpoint: occupiedHeatingSetpoint * 100,
699
1142
  minHeatSetpointLimit: minHeatSetpointLimit * 100,
700
1143
  maxHeatSetpointLimit: maxHeatSetpointLimit * 100,
701
1144
  absMinHeatSetpointLimit: minHeatSetpointLimit * 100,
702
1145
  absMaxHeatSetpointLimit: maxHeatSetpointLimit * 100,
1146
+ // Thermostat.Feature.Cooling
703
1147
  occupiedCoolingSetpoint: occupiedCoolingSetpoint * 100,
704
1148
  minCoolSetpointLimit: minCoolSetpointLimit * 100,
705
1149
  maxCoolSetpointLimit: maxCoolSetpointLimit * 100,
706
1150
  absMinCoolSetpointLimit: minCoolSetpointLimit * 100,
707
1151
  absMaxCoolSetpointLimit: maxCoolSetpointLimit * 100,
1152
+ // Thermostat.Feature.AutoMode
708
1153
  minSetpointDeadBand: minSetpointDeadBand * 100,
709
1154
  thermostatRunningMode: Thermostat.ThermostatRunningMode.Off,
710
1155
  });
711
1156
  return this;
712
1157
  }
1158
+ /**
1159
+ * Creates a default heating thermostat cluster server with Thermostat.Feature.Heating.
1160
+ * @param {number} [localTemperature] - The local temperature value in degrees Celsius. Defaults to 23°.
1161
+ * @param {number} [occupiedHeatingSetpoint] - The occupied heating setpoint value in degrees Celsius. Defaults to 21°.
1162
+ * @param {number} [minHeatSetpointLimit] - The minimum heat setpoint limit value. Defaults to 0°.
1163
+ * @param {number} [maxHeatSetpointLimit] - The maximum heat setpoint limit value. Defaults to 50°.
1164
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1165
+ */
713
1166
  createDefaultHeatingThermostatClusterServer(localTemperature = 23, occupiedHeatingSetpoint = 21, minHeatSetpointLimit = 0, maxHeatSetpointLimit = 50) {
714
1167
  this.behaviors.require(MatterbridgeThermostatServer.with(Thermostat.Feature.Heating), {
715
1168
  localTemperature: localTemperature * 100,
716
1169
  systemMode: Thermostat.SystemMode.Heat,
717
1170
  controlSequenceOfOperation: Thermostat.ControlSequenceOfOperation.HeatingOnly,
1171
+ // Thermostat.Feature.Heating
718
1172
  occupiedHeatingSetpoint: occupiedHeatingSetpoint * 100,
719
1173
  minHeatSetpointLimit: minHeatSetpointLimit * 100,
720
1174
  maxHeatSetpointLimit: maxHeatSetpointLimit * 100,
@@ -723,11 +1177,20 @@ export class MatterbridgeEndpoint extends Endpoint {
723
1177
  });
724
1178
  return this;
725
1179
  }
1180
+ /**
1181
+ * Creates a default cooling thermostat cluster server with Thermostat.Feature.Cooling.
1182
+ * @param {number} [localTemperature] - The local temperature value in degrees Celsius. Defaults to 23°.
1183
+ * @param {number} [occupiedCoolingSetpoint] - The occupied cooling setpoint value in degrees Celsius. Defaults to 25°.
1184
+ * @param {number} [minCoolSetpointLimit] - The minimum cool setpoint limit value. Defaults to 0°.
1185
+ * @param {number} [maxCoolSetpointLimit] - The maximum cool setpoint limit value. Defaults to 50°.
1186
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1187
+ */
726
1188
  createDefaultCoolingThermostatClusterServer(localTemperature = 23, occupiedCoolingSetpoint = 25, minCoolSetpointLimit = 0, maxCoolSetpointLimit = 50) {
727
1189
  this.behaviors.require(MatterbridgeThermostatServer.with(Thermostat.Feature.Cooling), {
728
1190
  localTemperature: localTemperature * 100,
729
1191
  systemMode: Thermostat.SystemMode.Cool,
730
1192
  controlSequenceOfOperation: Thermostat.ControlSequenceOfOperation.CoolingOnly,
1193
+ // Thermostat.Feature.Cooling
731
1194
  occupiedCoolingSetpoint: occupiedCoolingSetpoint * 100,
732
1195
  minCoolSetpointLimit: minCoolSetpointLimit * 100,
733
1196
  maxCoolSetpointLimit: maxCoolSetpointLimit * 100,
@@ -736,6 +1199,12 @@ export class MatterbridgeEndpoint extends Endpoint {
736
1199
  });
737
1200
  return this;
738
1201
  }
1202
+ /**
1203
+ * Creates a default fan control cluster server.
1204
+ *
1205
+ * @param fanMode The fan mode to set. Defaults to `FanControl.FanMode.Off`.
1206
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1207
+ */
739
1208
  createDefaultFanControlClusterServer(fanMode = FanControl.FanMode.Off) {
740
1209
  this.behaviors.require(MatterbridgeFanControlServer.with(FanControl.Feature.MultiSpeed, FanControl.Feature.Auto, FanControl.Feature.Step), {
741
1210
  fanMode,
@@ -748,6 +1217,13 @@ export class MatterbridgeEndpoint extends Endpoint {
748
1217
  });
749
1218
  return this;
750
1219
  }
1220
+ /**
1221
+ * Creates a default door lock cluster server.
1222
+ *
1223
+ * @param {DoorLock.LockState} [lockState=DoorLock.LockState.Locked] - The initial state of the lock (default: Locked).
1224
+ * @param {DoorLock.LockType} [lockType=DoorLock.LockType.DeadBolt] - The type of the lock (default: DeadBolt).
1225
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1226
+ */
751
1227
  createDefaultDoorLockClusterServer(lockState = DoorLock.LockState.Locked, lockType = DoorLock.LockType.DeadBolt) {
752
1228
  this.behaviors.require(MatterbridgeDoorLockServer.enable({ events: { doorLockAlarm: true, lockOperation: true, lockOperationError: true } }), {
753
1229
  operatingMode: DoorLock.OperatingMode.Normal,
@@ -758,6 +1234,18 @@ export class MatterbridgeEndpoint extends Endpoint {
758
1234
  });
759
1235
  return this;
760
1236
  }
1237
+ /**
1238
+ * Creates a default Mode Select cluster server.
1239
+ *
1240
+ * @param {string} description - The description of the mode select cluster.
1241
+ * @param {ModeSelect.ModeOption[]} supportedModes - The list of supported modes.
1242
+ * @param {number} [currentMode=0] - The current mode (default: 0).
1243
+ * @param {number} [startUpMode=0] - The startup mode (default: 0).
1244
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1245
+ *
1246
+ * @remarks
1247
+ * endpoint.createDefaultModeSelectClusterServer('Night mode', [{ label: 'Led ON', mode: 0, semanticTags: [] }, { label: 'Led OFF', mode: 1, semanticTags: [] }], 0, 0);
1248
+ */
761
1249
  createDefaultModeSelectClusterServer(description, supportedModes, currentMode = 0, startUpMode = 0) {
762
1250
  this.behaviors.require(MatterbridgeModeSelectServer, {
763
1251
  description: description,
@@ -768,6 +1256,13 @@ export class MatterbridgeEndpoint extends Endpoint {
768
1256
  });
769
1257
  return this;
770
1258
  }
1259
+ /**
1260
+ * Creates the default Valve Configuration And Control cluster server.
1261
+ *
1262
+ * @param {ValveConfigurationAndControl.ValveState} [valveState=ValveConfigurationAndControl.ValveState.Closed] - The valve state to set. Defaults to `ValveConfigurationAndControl.ValveState.Closed`.
1263
+ * @param {number} [valveLevel=0] - The valve level to set. Defaults to 0.
1264
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1265
+ */
771
1266
  createDefaultValveConfigurationAndControlClusterServer(valveState = ValveConfigurationAndControl.ValveState.Closed, valveLevel = 0) {
772
1267
  this.behaviors.require(MatterbridgeValveConfigurationAndControlServer.with(ValveConfigurationAndControl.Feature.Level), {
773
1268
  currentState: valveState,
@@ -780,6 +1275,12 @@ export class MatterbridgeEndpoint extends Endpoint {
780
1275
  });
781
1276
  return this;
782
1277
  }
1278
+ /**
1279
+ * Creates the default PumpConfigurationAndControl cluster server.
1280
+ *
1281
+ * @param {PumpConfigurationAndControl.OperationMode} [pumpMode=PumpConfigurationAndControl.OperationMode.Normal] - The pump mode to set. Defaults to `PumpConfigurationAndControl.OperationMode.Normal`.
1282
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1283
+ */
783
1284
  createDefaultPumpConfigurationAndControlClusterServer(pumpMode = PumpConfigurationAndControl.OperationMode.Normal) {
784
1285
  this.behaviors.require(PumpConfigurationAndControlServer.with(PumpConfigurationAndControl.Feature.ConstantSpeed), {
785
1286
  minConstSpeed: null,
@@ -794,6 +1295,13 @@ export class MatterbridgeEndpoint extends Endpoint {
794
1295
  });
795
1296
  return this;
796
1297
  }
1298
+ /**
1299
+ * Creates the default SmokeCOAlarm Cluster Server.
1300
+ *
1301
+ * @param {SmokeCoAlarm.AlarmState} smokeState - The state of the smoke alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
1302
+ * @param {SmokeCoAlarm.AlarmState} coState - The state of the CO alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
1303
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1304
+ */
797
1305
  createDefaultSmokeCOAlarmClusterServer(smokeState = SmokeCoAlarm.AlarmState.Normal, coState = SmokeCoAlarm.AlarmState.Normal) {
798
1306
  this.behaviors.require(MatterbridgeSmokeCoAlarmServer.with(SmokeCoAlarm.Feature.SmokeAlarm, SmokeCoAlarm.Feature.CoAlarm).enable({
799
1307
  events: { smokeAlarm: true, interconnectSmokeAlarm: true, coAlarm: true, interconnectCoAlarm: true, lowBattery: true, hardwareFault: true, endOfService: true, selfTestComplete: true, alarmMuted: true, muteEnded: true, allClear: true },
@@ -811,6 +1319,13 @@ export class MatterbridgeEndpoint extends Endpoint {
811
1319
  });
812
1320
  return this;
813
1321
  }
1322
+ /**
1323
+ * Creates a default momentary switch cluster server.
1324
+ *
1325
+ * @remarks
1326
+ * This method adds a cluster server with default momentary switch features and configuration suitable for (AppleHome) Single Double Long automations.
1327
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1328
+ */
814
1329
  createDefaultSwitchClusterServer() {
815
1330
  this.behaviors.require(MatterbridgeSwitchServer.with(Switch.Feature.MomentarySwitch, Switch.Feature.MomentarySwitchRelease, Switch.Feature.MomentarySwitchLongPress, Switch.Feature.MomentarySwitchMultiPress).enable({
816
1331
  events: { initialPress: true, longPress: true, shortRelease: true, longRelease: true, multiPressOngoing: true, multiPressComplete: true },
@@ -821,6 +1336,13 @@ export class MatterbridgeEndpoint extends Endpoint {
821
1336
  });
822
1337
  return this;
823
1338
  }
1339
+ /**
1340
+ * Creates a default latching switch cluster server.
1341
+ *
1342
+ * @remarks
1343
+ * This method adds a cluster server with default latching switch features and configuration suitable for a latching switch with 2 positions.
1344
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1345
+ */
824
1346
  createDefaultLatchingSwitchClusterServer() {
825
1347
  this.behaviors.require(SwitchServer.with(Switch.Feature.LatchingSwitch).enable({
826
1348
  events: { switchLatched: true },
@@ -830,6 +1352,13 @@ export class MatterbridgeEndpoint extends Endpoint {
830
1352
  });
831
1353
  return this;
832
1354
  }
1355
+ /**
1356
+ * Triggers a switch event on the specified endpoint.
1357
+ *
1358
+ * @param {string} event - The type of event to trigger. Possible values are 'Single', 'Double', 'Long' for momentarySwitch and 'Press', 'Release' for latchingSwitch.
1359
+ * @param {Endpoint} endpoint - The endpoint on which to trigger the event (default the device endpoint).
1360
+ * @returns {boolean} - A boolean indicating whether the event was successfully triggered.
1361
+ */
833
1362
  async triggerSwitchEvent(event, log) {
834
1363
  if (this.maybeNumber === undefined) {
835
1364
  this.log.error(`triggerSwitchEvent ${event} error: Endpoint number not assigned on endpoint ${this.maybeId}:${this.maybeNumber}`);
@@ -889,14 +1418,31 @@ export class MatterbridgeEndpoint extends Endpoint {
889
1418
  }
890
1419
  return true;
891
1420
  }
1421
+ /**
1422
+ * Creates a default boolean state cluster server.
1423
+ *
1424
+ * @param {boolean} contact - The state of the cluster. Defaults to true (true = contact).
1425
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1426
+ */
892
1427
  createDefaultBooleanStateClusterServer(contact) {
893
1428
  this.behaviors.require(BooleanStateServer.enable({
894
1429
  events: { stateChange: true },
895
1430
  }), {
896
- stateValue: contact ?? true,
1431
+ stateValue: contact ?? true, // true=contact false=no_contact
897
1432
  });
898
1433
  return this;
899
1434
  }
1435
+ /**
1436
+ * Creates a default boolean state configuration cluster server to be used with the waterFreezeDetector, waterLeakDetector, and rainSensor device types.
1437
+ *
1438
+ * @remarks Supports the enableDisableAlarm command.
1439
+ *
1440
+ * @param {boolean} [sensorFault=false] - Optional boolean value indicating the sensor fault state. Defaults to `false` if not provided.
1441
+ * @param {number} [currentSensitivityLevel=0] - The current sensitivity level. Defaults to `0` if not provided.
1442
+ * @param {number} [supportedSensitivityLevels=2] - The number of supported sensitivity levels. Defaults to `2` if not provided (min 2, max 10).
1443
+ * @param {number} [defaultSensitivityLevel=0] - The default sensitivity level. Defaults to `0` if not provided.
1444
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1445
+ */
900
1446
  createDefaultBooleanStateConfigurationClusterServer(sensorFault = false, currentSensitivityLevel = 0, supportedSensitivityLevels = 2, defaultSensitivityLevel = 0) {
901
1447
  this.behaviors.require(MatterbridgeBooleanStateConfigurationServer.with(BooleanStateConfiguration.Feature.Visual, BooleanStateConfiguration.Feature.Audible, BooleanStateConfiguration.Feature.SensitivityLevel).enable({
902
1448
  events: { alarmsStateChanged: true, sensorFault: true },
@@ -911,10 +1457,21 @@ export class MatterbridgeEndpoint extends Endpoint {
911
1457
  });
912
1458
  return this;
913
1459
  }
1460
+ /**
1461
+ * Creates a default Power Topology Cluster Server with feature TreeTopology. Only needed for an electricalSensor device type.
1462
+ *
1463
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1464
+ */
914
1465
  createDefaultPowerTopologyClusterServer() {
915
1466
  this.behaviors.require(PowerTopologyServer.with(PowerTopology.Feature.TreeTopology));
916
1467
  return this;
917
1468
  }
1469
+ /**
1470
+ * Creates a default Electrical Energy Measurement Cluster Server.
1471
+ *
1472
+ * @param {number} energy - The total consumption value in mW/h.
1473
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1474
+ */
918
1475
  createDefaultElectricalEnergyMeasurementClusterServer(energy = null) {
919
1476
  this.behaviors.require(ElectricalEnergyMeasurementServer.with(ElectricalEnergyMeasurement.Feature.ImportedEnergy, ElectricalEnergyMeasurement.Feature.ExportedEnergy, ElectricalEnergyMeasurement.Feature.CumulativeEnergy), {
920
1477
  accuracy: {
@@ -930,6 +1487,15 @@ export class MatterbridgeEndpoint extends Endpoint {
930
1487
  });
931
1488
  return this;
932
1489
  }
1490
+ /**
1491
+ * Creates a default Electrical Power Measurement Cluster Server.
1492
+ *
1493
+ * @param {number} voltage - The voltage value in millivolts.
1494
+ * @param {number} current - The current value in milliamperes.
1495
+ * @param {number} power - The power value in milliwatts.
1496
+ * @param {number} frequency - The frequency value in millihertz.
1497
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1498
+ */
933
1499
  createDefaultElectricalPowerMeasurementClusterServer(voltage = null, current = null, power = null, frequency = null) {
934
1500
  this.behaviors.require(ElectricalPowerMeasurementServer.with(ElectricalPowerMeasurement.Feature.AlternatingCurrent), {
935
1501
  powerMode: ElectricalPowerMeasurement.PowerMode.Ac,
@@ -971,36 +1537,90 @@ export class MatterbridgeEndpoint extends Endpoint {
971
1537
  });
972
1538
  return this;
973
1539
  }
1540
+ /**
1541
+ * Creates a default TemperatureMeasurement cluster server.
1542
+ *
1543
+ * @param {number} measuredValue - The measured value of the temperature x 100.
1544
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1545
+ */
974
1546
  createDefaultTemperatureMeasurementClusterServer(measuredValue = 0) {
975
1547
  this.behaviors.require(TemperatureMeasurementServer, getDefaultTemperatureMeasurementClusterServer(measuredValue));
976
1548
  return this;
977
1549
  }
1550
+ /**
1551
+ * Creates a default RelativeHumidityMeasurement cluster server.
1552
+ *
1553
+ * @param {number} measuredValue - The measured value of the relative humidity x 100.
1554
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1555
+ */
978
1556
  createDefaultRelativeHumidityMeasurementClusterServer(measuredValue = 0) {
979
1557
  this.behaviors.require(RelativeHumidityMeasurementServer, getDefaultRelativeHumidityMeasurementClusterServer(measuredValue));
980
1558
  return this;
981
1559
  }
1560
+ /**
1561
+ * Creates a default PressureMeasurement cluster server.
1562
+ *
1563
+ * @param {number} measuredValue - The measured value for the pressure.
1564
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1565
+ */
982
1566
  createDefaultPressureMeasurementClusterServer(measuredValue = 1000) {
983
1567
  this.behaviors.require(PressureMeasurementServer, getDefaultPressureMeasurementClusterServer(measuredValue));
984
1568
  return this;
985
1569
  }
1570
+ /**
1571
+ * Creates a default IlluminanceMeasurement cluster server.
1572
+ *
1573
+ * @param {number} measuredValue - The measured value of illuminance.
1574
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1575
+ *
1576
+ * @remarks
1577
+ * Lux to matter = Math.round(Math.max(Math.min(10000 * Math.log10(lux), 0xfffe), 0))
1578
+ * Matter to Lux = Math.round(Math.max(Math.pow(10, value / 10000), 0))
1579
+ */
986
1580
  createDefaultIlluminanceMeasurementClusterServer(measuredValue = 0) {
987
1581
  this.behaviors.require(IlluminanceMeasurementServer, getDefaultIlluminanceMeasurementClusterServer(measuredValue));
988
1582
  return this;
989
1583
  }
1584
+ /**
1585
+ * Creates a default FlowMeasurement cluster server.
1586
+ *
1587
+ * @param {number} measuredValue - The measured value of the flow in 10 x m/h.
1588
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1589
+ */
990
1590
  createDefaultFlowMeasurementClusterServer(measuredValue = 0) {
991
1591
  this.behaviors.require(FlowMeasurementServer, getDefaultFlowMeasurementClusterServer(measuredValue));
992
1592
  return this;
993
1593
  }
1594
+ /**
1595
+ * Creates a default OccupancySensing cluster server.
1596
+ *
1597
+ * @param {boolean} occupied - A boolean indicating whether the occupancy is occupied or not. Default is false.
1598
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1599
+ */
994
1600
  createDefaultOccupancySensingClusterServer(occupied = false) {
995
1601
  this.behaviors.require(OccupancySensingServer, getDefaultOccupancySensingClusterServer(occupied));
996
1602
  return this;
997
1603
  }
1604
+ /**
1605
+ * Creates a default AirQuality cluster server.
1606
+ *
1607
+ * @param {AirQuality.AirQualityEnum} airQuality The air quality level. Defaults to `AirQuality.AirQualityType.Unknown`.
1608
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1609
+ */
998
1610
  createDefaultAirQualityClusterServer(airQuality = AirQuality.AirQualityEnum.Unknown) {
999
1611
  this.behaviors.require(AirQualityServer.with(AirQuality.Feature.Fair, AirQuality.Feature.Moderate, AirQuality.Feature.VeryPoor, AirQuality.Feature.ExtremelyPoor), {
1000
1612
  airQuality,
1001
1613
  });
1002
1614
  return this;
1003
1615
  }
1616
+ /**
1617
+ * Creates a default TotalVolatileOrganicCompoundsConcentrationMeasurement cluster server.
1618
+ *
1619
+ * @param {number} measuredValue - The measured value of the concentration.
1620
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
1621
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
1622
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1623
+ */
1004
1624
  createDefaultTvocMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1005
1625
  this.behaviors.require(TotalVolatileOrganicCompoundsConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1006
1626
  measuredValue,
@@ -1012,6 +1632,13 @@ export class MatterbridgeEndpoint extends Endpoint {
1012
1632
  });
1013
1633
  return this;
1014
1634
  }
1635
+ /**
1636
+ * Create a default CarbonMonoxideConcentrationMeasurement cluster server.
1637
+ *
1638
+ * @param {number} measuredValue - The measured value of the concentration.
1639
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
1640
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
1641
+ */
1015
1642
  createDefaultCarbonMonoxideConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1016
1643
  this.behaviors.require(CarbonMonoxideConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1017
1644
  measuredValue,
@@ -1023,6 +1650,13 @@ export class MatterbridgeEndpoint extends Endpoint {
1023
1650
  });
1024
1651
  return this;
1025
1652
  }
1653
+ /**
1654
+ * Create a default CarbonDioxideConcentrationMeasurement cluster server.
1655
+ *
1656
+ * @param {number} measuredValue - The measured value of the concentration.
1657
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
1658
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
1659
+ */
1026
1660
  createDefaultCarbonDioxideConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1027
1661
  this.behaviors.require(CarbonDioxideConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1028
1662
  measuredValue,
@@ -1034,6 +1668,13 @@ export class MatterbridgeEndpoint extends Endpoint {
1034
1668
  });
1035
1669
  return this;
1036
1670
  }
1671
+ /**
1672
+ * Create a default FormaldehydeConcentrationMeasurement cluster server.
1673
+ *
1674
+ * @param {number} measuredValue - The measured value of the concentration.
1675
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
1676
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
1677
+ */
1037
1678
  createDefaultFormaldehydeConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1038
1679
  this.behaviors.require(FormaldehydeConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1039
1680
  measuredValue,
@@ -1045,6 +1686,13 @@ export class MatterbridgeEndpoint extends Endpoint {
1045
1686
  });
1046
1687
  return this;
1047
1688
  }
1689
+ /**
1690
+ * Create a default Pm1ConcentrationMeasurement cluster server.
1691
+ *
1692
+ * @param {number} measuredValue - The measured value of the concentration.
1693
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
1694
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
1695
+ */
1048
1696
  createDefaultPm1ConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1049
1697
  this.behaviors.require(Pm1ConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1050
1698
  measuredValue,
@@ -1056,6 +1704,13 @@ export class MatterbridgeEndpoint extends Endpoint {
1056
1704
  });
1057
1705
  return this;
1058
1706
  }
1707
+ /**
1708
+ * Create a default Pm25ConcentrationMeasurement cluster server.
1709
+ *
1710
+ * @param {number} measuredValue - The measured value of the concentration.
1711
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
1712
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
1713
+ */
1059
1714
  createDefaultPm25ConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1060
1715
  this.behaviors.require(Pm25ConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1061
1716
  measuredValue,
@@ -1067,6 +1722,13 @@ export class MatterbridgeEndpoint extends Endpoint {
1067
1722
  });
1068
1723
  return this;
1069
1724
  }
1725
+ /**
1726
+ * Create a default Pm10ConcentrationMeasurement cluster server.
1727
+ *
1728
+ * @param {number} measuredValue - The measured value of the concentration.
1729
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
1730
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
1731
+ */
1070
1732
  createDefaultPm10ConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1071
1733
  this.behaviors.require(Pm10ConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1072
1734
  measuredValue,
@@ -1078,6 +1740,13 @@ export class MatterbridgeEndpoint extends Endpoint {
1078
1740
  });
1079
1741
  return this;
1080
1742
  }
1743
+ /**
1744
+ * Create a default OzoneConcentrationMeasurement cluster server.
1745
+ *
1746
+ * @param {number} measuredValue - The measured value of the concentration.
1747
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ugm3).
1748
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
1749
+ */
1081
1750
  createDefaultOzoneConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ugm3, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1082
1751
  this.behaviors.require(OzoneConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1083
1752
  measuredValue,
@@ -1089,6 +1758,13 @@ export class MatterbridgeEndpoint extends Endpoint {
1089
1758
  });
1090
1759
  return this;
1091
1760
  }
1761
+ /**
1762
+ * Create a default RadonConcentrationMeasurement cluster server.
1763
+ *
1764
+ * @param {number} measuredValue - The measured value of the concentration.
1765
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
1766
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
1767
+ */
1092
1768
  createDefaultRadonConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1093
1769
  this.behaviors.require(RadonConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1094
1770
  measuredValue,
@@ -1100,6 +1776,13 @@ export class MatterbridgeEndpoint extends Endpoint {
1100
1776
  });
1101
1777
  return this;
1102
1778
  }
1779
+ /**
1780
+ * Create a default NitrogenDioxideConcentrationMeasurement cluster server.
1781
+ *
1782
+ * @param {number} measuredValue - The measured value of the concentration.
1783
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ugm3).
1784
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
1785
+ */
1103
1786
  createDefaultNitrogenDioxideConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ugm3, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1104
1787
  this.behaviors.require(NitrogenDioxideConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1105
1788
  measuredValue,
@@ -1112,3 +1795,4 @@ export class MatterbridgeEndpoint extends Endpoint {
1112
1795
  return this;
1113
1796
  }
1114
1797
  }
1798
+ //# sourceMappingURL=matterbridgeEndpoint.js.map