matterbridge 2.0.0-edge.5 → 2.0.0

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 (91) hide show
  1. package/CHANGELOG.md +3 -2
  2. package/dist/cli.d.ts +25 -0
  3. package/dist/cli.d.ts.map +1 -0
  4. package/dist/cli.js +26 -0
  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 +46 -0
  15. package/dist/deviceManager.d.ts.map +1 -0
  16. package/dist/deviceManager.js +26 -1
  17. package/dist/deviceManager.js.map +1 -0
  18. package/dist/frontend.d.ts +98 -0
  19. package/dist/frontend.d.ts.map +1 -0
  20. package/dist/frontend.js +239 -22
  21. package/dist/frontend.js.map +1 -0
  22. package/dist/index.d.ts +34 -0
  23. package/dist/index.d.ts.map +1 -0
  24. package/dist/index.js +29 -0
  25. package/dist/index.js.map +1 -0
  26. package/dist/logger/export.d.ts +2 -0
  27. package/dist/logger/export.d.ts.map +1 -0
  28. package/dist/logger/export.js +1 -0
  29. package/dist/logger/export.js.map +1 -0
  30. package/dist/matter/export.d.ts +10 -0
  31. package/dist/matter/export.d.ts.map +1 -0
  32. package/dist/matter/export.js +4 -0
  33. package/dist/matter/export.js.map +1 -0
  34. package/dist/matterbridge.d.ts +356 -0
  35. package/dist/matterbridge.d.ts.map +1 -0
  36. package/dist/matterbridge.js +687 -38
  37. package/dist/matterbridge.js.map +1 -0
  38. package/dist/matterbridgeAccessoryPlatform.d.ts +39 -0
  39. package/dist/matterbridgeAccessoryPlatform.d.ts.map +1 -0
  40. package/dist/matterbridgeAccessoryPlatform.js +33 -0
  41. package/dist/matterbridgeAccessoryPlatform.js.map +1 -0
  42. package/dist/matterbridgeBehaviors.d.ts +963 -0
  43. package/dist/matterbridgeBehaviors.d.ts.map +1 -0
  44. package/dist/matterbridgeBehaviors.js +31 -1
  45. package/dist/matterbridgeBehaviors.js.map +1 -0
  46. package/dist/matterbridgeDeviceTypes.d.ts +177 -0
  47. package/dist/matterbridgeDeviceTypes.d.ts.map +1 -0
  48. package/dist/matterbridgeDeviceTypes.js +112 -11
  49. package/dist/matterbridgeDeviceTypes.js.map +1 -0
  50. package/dist/matterbridgeDynamicPlatform.d.ts +39 -0
  51. package/dist/matterbridgeDynamicPlatform.d.ts.map +1 -0
  52. package/dist/matterbridgeDynamicPlatform.js +33 -0
  53. package/dist/matterbridgeDynamicPlatform.js.map +1 -0
  54. package/dist/matterbridgeEndpoint.d.ts +10254 -0
  55. package/dist/matterbridgeEndpoint.d.ts.map +1 -0
  56. package/dist/matterbridgeEndpoint.js +1174 -10
  57. package/dist/matterbridgeEndpoint.js.map +1 -0
  58. package/dist/matterbridgeEndpointDefault.d.ts +2 -0
  59. package/dist/matterbridgeEndpointDefault.d.ts.map +1 -0
  60. package/dist/matterbridgeEndpointDefault.js +55 -0
  61. package/dist/matterbridgeEndpointDefault.js.map +1 -0
  62. package/dist/matterbridgePlatform.d.ts +164 -0
  63. package/dist/matterbridgePlatform.d.ts.map +1 -0
  64. package/dist/matterbridgePlatform.js +123 -3
  65. package/dist/matterbridgePlatform.js.map +1 -0
  66. package/dist/matterbridgeTypes.d.ts +167 -0
  67. package/dist/matterbridgeTypes.d.ts.map +1 -0
  68. package/dist/matterbridgeTypes.js +25 -0
  69. package/dist/matterbridgeTypes.js.map +1 -0
  70. package/dist/pluginManager.d.ts +238 -0
  71. package/dist/pluginManager.d.ts.map +1 -0
  72. package/dist/pluginManager.js +240 -3
  73. package/dist/pluginManager.js.map +1 -0
  74. package/dist/storage/export.d.ts +2 -0
  75. package/dist/storage/export.d.ts.map +1 -0
  76. package/dist/storage/export.js +1 -0
  77. package/dist/storage/export.js.map +1 -0
  78. package/dist/utils/colorUtils.d.ts +61 -0
  79. package/dist/utils/colorUtils.d.ts.map +1 -0
  80. package/dist/utils/colorUtils.js +205 -2
  81. package/dist/utils/colorUtils.js.map +1 -0
  82. package/dist/utils/export.d.ts +3 -0
  83. package/dist/utils/export.d.ts.map +1 -0
  84. package/dist/utils/export.js +1 -0
  85. package/dist/utils/export.js.map +1 -0
  86. package/dist/utils/utils.d.ts +221 -0
  87. package/dist/utils/utils.d.ts.map +1 -0
  88. package/dist/utils/utils.js +253 -9
  89. package/dist/utils/utils.js.map +1 -0
  90. package/npm-shrinkwrap.json +2 -2
  91. package/package.json +2 -1
@@ -1,11 +1,39 @@
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 1.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
+ /* eslint-disable @typescript-eslint/no-unused-vars */
24
+ // Node.js modules
1
25
  import { createHash } from 'crypto';
26
+ // AnsiLogger module
2
27
  import { AnsiLogger, BLUE, CYAN, YELLOW, db, debugStringify, er, hk, or, rs, zb } from './logger/export.js';
28
+ // Matterbridge behaviors
3
29
  import { MatterbridgeBehavior, MatterbridgeBehaviorDevice, MatterbridgeBooleanStateConfigurationServer, MatterbridgeColorControlServer, MatterbridgeDoorLockServer, MatterbridgeFanControlServer, MatterbridgeIdentifyServer, MatterbridgeLevelControlServer, MatterbridgeOnOffServer, MatterbridgeThermostatServer, MatterbridgeValveConfigurationAndControlServer, MatterbridgeWindowCoveringServer, } from './matterbridgeBehaviors.js';
4
30
  import { bridgedNode } from './matterbridgeDeviceTypes.js';
5
31
  import { deepCopy, isValidNumber } from './utils/utils.js';
32
+ // @matter
6
33
  import { Endpoint, MutableEndpoint, SupportedBehaviors, NamedHandler, Lifecycle, VendorId } from '@matter/main';
7
34
  import { MeasurementType, getClusterNameById } from '@matter/main/types';
8
35
  import { Specification } from '@matter/main/model';
36
+ // @matter clusters
9
37
  import { BasicInformation, BasicInformationCluster } from '@matter/main/clusters/basic-information';
10
38
  import { BooleanState, BooleanStateCluster } from '@matter/main/clusters/boolean-state';
11
39
  import { BooleanStateConfiguration, BooleanStateConfigurationCluster } from '@matter/main/clusters/boolean-state-configuration';
@@ -49,6 +77,7 @@ import { UserLabel, UserLabelCluster } from '@matter/main/clusters/user-label';
49
77
  import { ValveConfigurationAndControl, ValveConfigurationAndControlCluster } from '@matter/main/clusters/valve-configuration-and-control';
50
78
  import { WindowCovering, WindowCoveringCluster } from '@matter/main/clusters/window-covering';
51
79
  import { AirQuality, AirQualityCluster } from '@matter/main/clusters/air-quality';
80
+ // @matter behaviors
52
81
  import { DescriptorServer } from '@matter/node/behaviors/descriptor';
53
82
  import { IdentifyBehavior } from '@matter/node/behaviors/identify';
54
83
  import { GroupsServer } from '@matter/node/behaviors/groups';
@@ -81,10 +110,11 @@ import { SmokeCoAlarmServer } from '@matter/main/behaviors/smoke-co-alarm';
81
110
  import { SwitchServer } from '@matter/main/behaviors/switch';
82
111
  import { TotalVolatileOrganicCompoundsConcentrationMeasurementServer } from '@matter/main/behaviors/total-volatile-organic-compounds-concentration-measurement';
83
112
  import { UserLabelServer } from '@matter/main/behaviors/user-label';
113
+ // @project-chip
84
114
  import { ClusterServer, GroupsClusterHandler } from '@project-chip/matter.js/cluster';
85
115
  export class MatterbridgeEndpoint extends Endpoint {
86
116
  static bridgeMode = '';
87
- static logLevel = "info";
117
+ static logLevel = "info" /* LogLevel.INFO */;
88
118
  log;
89
119
  plugin = undefined;
90
120
  configUrl = undefined;
@@ -105,12 +135,21 @@ export class MatterbridgeEndpoint extends Endpoint {
105
135
  uniqueStorageKey = undefined;
106
136
  tagList = undefined;
107
137
  subType = '';
138
+ // Maps matter deviceTypes and endpoints
108
139
  deviceTypes = new Map();
109
140
  clusterServers = new Map();
110
141
  clusterClients = new Map();
111
142
  commandHandler = new NamedHandler();
143
+ /**
144
+ * Represents a MatterbridgeEndpoint.
145
+ * @constructor
146
+ * @param {DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>} definition - The DeviceTypeDefinition(s) of the endpoint.
147
+ * @param {MatterbridgeEndpointOptions} [options={}] - The options for the device.
148
+ * @param {boolean} [debug=false] - Debug flag.
149
+ */
112
150
  constructor(definition, options = {}, debug = false) {
113
151
  let deviceTypeList = [];
152
+ // Get the first DeviceTypeDefinition
114
153
  let firstDefinition;
115
154
  if (Array.isArray(definition)) {
116
155
  firstDefinition = definition[0];
@@ -123,6 +162,7 @@ export class MatterbridgeEndpoint extends Endpoint {
123
162
  firstDefinition = definition;
124
163
  deviceTypeList = [{ deviceType: firstDefinition.code, revision: firstDefinition.revision }];
125
164
  }
165
+ // Convert the first DeviceTypeDefinition to an EndpointType.Options
126
166
  const deviceTypeDefinitionV8 = {
127
167
  name: firstDefinition.name.replace('-', '_'),
128
168
  deviceType: firstDefinition.code,
@@ -141,6 +181,7 @@ export class MatterbridgeEndpoint extends Endpoint {
141
181
  behaviors: options.tagList ? SupportedBehaviors(DescriptorServer.with(Descriptor.Feature.TagList)) : {},
142
182
  };
143
183
  const endpointV8 = MutableEndpoint(deviceTypeDefinitionV8);
184
+ // Convert the options to an Endpoint.Options
144
185
  const optionsV8 = {
145
186
  id: options.uniqueStorageKey?.replace(/[ .]/g, ''),
146
187
  number: options.endpointId,
@@ -158,15 +199,29 @@ export class MatterbridgeEndpoint extends Endpoint {
158
199
  }
159
200
  else
160
201
  this.deviceTypes.set(firstDefinition.code, firstDefinition);
161
- this.log = new AnsiLogger({ logName: 'MatterbridgeEndpoint', logTimestampFormat: 4, logLevel: debug === true ? "debug" : MatterbridgeEndpoint.logLevel });
202
+ // console.log('MatterbridgeEndpoint.option', options);
203
+ // console.log('MatterbridgeEndpoint.endpointV8', endpointV8);
204
+ // console.log('MatterbridgeEndpoint.optionsV8', optionsV8);
205
+ // Create the logger
206
+ this.log = new AnsiLogger({ logName: 'MatterbridgeEndpoint', logTimestampFormat: 4 /* TimestampFormat.TIME_MILLIS */, logLevel: debug === true ? "debug" /* LogLevel.DEBUG */ : MatterbridgeEndpoint.logLevel });
162
207
  this.log.debug(`${YELLOW}new${db} MatterbridgeEndpoint: ${zb}${'0x' + firstDefinition.code.toString(16).padStart(4, '0')}${db}-${zb}${firstDefinition.name}${db} ` +
163
208
  `id: ${CYAN}${options.uniqueStorageKey}${db} number: ${CYAN}${options.endpointId}${db} taglist: ${CYAN}${options.tagList ? debugStringify(options.tagList) : 'undefined'}${db}`);
209
+ // Add MatterbridgeBehavior with MatterbridgeBehaviorDevice
164
210
  this.behaviors.require(MatterbridgeBehavior, { deviceCommand: new MatterbridgeBehaviorDevice(this.log, this.commandHandler, undefined) });
165
211
  }
212
+ /**
213
+ * Loads an instance of the MatterbridgeEndpoint class.
214
+ *
215
+ * @param {DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>} definition - The DeviceTypeDefinition(s) of the device.
216
+ * @param {MatterbridgeEndpointOptions} [options={}] - The options for the device.
217
+ * @param {boolean} [debug=false] - Debug flag.
218
+ * @returns {Promise<MatterbridgeEndpoint>} MatterbridgeEndpoint instance.
219
+ */
166
220
  static async loadInstance(definition, options = {}, debug = false) {
167
221
  return new MatterbridgeEndpoint(definition, options, debug);
168
222
  }
169
223
  static getBehaviourTypesFromClusterServerIds(clusterServerList) {
224
+ // Map Server ClusterId to Behavior.Type
170
225
  const behaviorTypes = [];
171
226
  clusterServerList.forEach((clusterId) => {
172
227
  behaviorTypes.push(MatterbridgeEndpoint.getBehaviourTypeFromClusterServerId(clusterId));
@@ -174,12 +229,15 @@ export class MatterbridgeEndpoint extends Endpoint {
174
229
  return behaviorTypes;
175
230
  }
176
231
  static getBehaviourTypesFromClusterClientIds(clusterClientList) {
232
+ // Map Client ClusterId to Behavior.Type
177
233
  const behaviorTypes = [];
178
234
  clusterClientList.forEach((clusterId) => {
235
+ // behaviorTypes.push(MatterbridgeEndpoint.getBehaviourTypeFromClusterClientId(clusterId));
179
236
  });
180
237
  return behaviorTypes;
181
238
  }
182
239
  static getBehaviourTypeFromClusterServerId(clusterId, subType) {
240
+ // Map ClusterId to Behavior.Type
183
241
  if (clusterId === Identify.Cluster.id)
184
242
  return MatterbridgeIdentifyServer;
185
243
  if (clusterId === Groups.Cluster.id)
@@ -293,12 +351,23 @@ export class MatterbridgeEndpoint extends Endpoint {
293
351
  return MatterbridgeIdentifyServer;
294
352
  }
295
353
  static getBehaviourTypeFromClusterClientId(clusterId) {
354
+ // Map ClusterId to Behavior.Type
296
355
  return IdentifyBehavior;
297
356
  }
357
+ /**
358
+ * Adds a device type to the list of device types.
359
+ * If the device type is not already present in the list, it will be added.
360
+ *
361
+ * @param {DeviceTypeDefinition} deviceType - The device type to add.
362
+ *
363
+ * @deprecated This method is deprecated and will be removed in future versions. Use the constructor options instead.
364
+ */
298
365
  addDeviceType(deviceType) {
299
366
  if (!this.deviceTypes.has(deviceType.code)) {
367
+ // Keep the Matterbridge internal map
300
368
  this.log.debug(`addDeviceType: ${zb}${'0x' + deviceType.code.toString(16).padStart(4, '0')}${db}-${zb}${deviceType.name}${db}`);
301
369
  this.deviceTypes.set(deviceType.code, deviceType);
370
+ // Add the device types to the descriptor server
302
371
  const deviceTypeList = Array.from(this.deviceTypes.values()).map((dt) => ({
303
372
  deviceType: dt.code,
304
373
  revision: dt.revision,
@@ -316,6 +385,14 @@ export class MatterbridgeEndpoint extends Endpoint {
316
385
  }
317
386
  }
318
387
  }
388
+ /**
389
+ * Adds one or more device types with the required cluster servers and the specified cluster servers.
390
+ *
391
+ * @param {AtLeastOne<DeviceTypeDefinition>} deviceTypes - The device types to add.
392
+ * @param {ClusterId[]} includeServerList - The list of cluster IDs to include.
393
+ *
394
+ * @deprecated This method is deprecated and will be removed in future versions. Use the constructor options instead.
395
+ */
319
396
  addDeviceTypeWithClusterServer(deviceTypes, includeServerList) {
320
397
  this.log.debug('addDeviceTypeWithClusterServer:');
321
398
  deviceTypes.forEach((deviceType) => {
@@ -338,6 +415,12 @@ export class MatterbridgeEndpoint extends Endpoint {
338
415
  });
339
416
  this.addClusterServerFromList(this, includeServerList);
340
417
  }
418
+ /**
419
+ * Adds the required cluster servers (only if they are not present) for the device types of the specified endpoint.
420
+ *
421
+ * @param {MatterbridgeEndpoint} endpoint - The endpoint to add the required cluster servers to.
422
+ * @returns {MatterbridgeEndpoint} The updated endpoint with the required cluster servers added.
423
+ */
341
424
  addRequiredClusterServers(endpoint) {
342
425
  const requiredServerList = [];
343
426
  this.log.debug(`addRequiredClusterServer for ${CYAN}${endpoint.maybeId}${db}`);
@@ -354,6 +437,12 @@ export class MatterbridgeEndpoint extends Endpoint {
354
437
  this.addClusterServerFromList(endpoint, requiredServerList);
355
438
  return endpoint;
356
439
  }
440
+ /**
441
+ * Adds the optional cluster servers (only if they are not present) for the device types of the specified endpoint.
442
+ *
443
+ * @param {MatterbridgeEndpoint} endpoint - The endpoint to add the required cluster servers to.
444
+ * @returns {MatterbridgeEndpoint} The updated endpoint with the required cluster servers added.
445
+ */
357
446
  addOptionalClusterServers(endpoint) {
358
447
  const optionalServerList = [];
359
448
  this.log.debug(`addRequiredClusterServer for ${CYAN}${endpoint.id}${db}`);
@@ -370,6 +459,22 @@ export class MatterbridgeEndpoint extends Endpoint {
370
459
  this.addClusterServerFromList(endpoint, optionalServerList);
371
460
  return endpoint;
372
461
  }
462
+ /**
463
+ * Adds a child endpoint with the specified device types and options.
464
+ * If the child endpoint is not already present, it will be created and added.
465
+ * If the child endpoint is already present, the device types will be added to the existing child endpoint.
466
+ *
467
+ * @param {string} endpointName - The name of the new endpoint to add.
468
+ * @param {DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>} definition - The device types to add.
469
+ * @param {MatterbridgeEndpointOptions} [options={}] - The options for the endpoint.
470
+ * @param {boolean} [debug=false] - Whether to enable debug logging.
471
+ * @returns {MatterbridgeEndpoint} - The child endpoint that was found or added.
472
+ *
473
+ * @example
474
+ * ```typescript
475
+ * const endpoint = device.addChildDeviceType('Temperature', [temperatureSensor], { tagList: [{ mfgCode: null, namespaceId: LocationTag.Indoor.namespaceId, tag: LocationTag.Indoor.tag, label: null }] }, true);
476
+ * ```
477
+ */
373
478
  addChildDeviceType(endpointName, definition, options = {}, debug = false) {
374
479
  this.log.debug(`addChildDeviceType: ${CYAN}${endpointName}${db}`);
375
480
  let child = this.getChildEndpointByName(endpointName);
@@ -402,6 +507,23 @@ export class MatterbridgeEndpoint extends Endpoint {
402
507
  }
403
508
  return child;
404
509
  }
510
+ /**
511
+ * Adds a child endpoint with one or more device types with the required cluster servers and the specified cluster servers.
512
+ * If the child endpoint is not already present in the childEndpoints, it will be added.
513
+ * If the child endpoint is already present in the childEndpoints, the device types and cluster servers will be added to the existing child endpoint.
514
+ *
515
+ * @param {string} endpointName - The name of the new enpoint to add.
516
+ * @param {DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>} definition - The device types to add.
517
+ * @param {ClusterId[]} [includeServerList=[]] - The list of cluster IDs to include.
518
+ * @param {MatterbridgeEndpointOptions} [options={}] - The options for the device.
519
+ * @param {boolean} [debug=false] - Whether to enable debug logging.
520
+ * @returns {MatterbridgeEndpoint} - The child endpoint that was found or added.
521
+ *
522
+ * @example
523
+ * ```typescript
524
+ * const endpoint = device.addChildDeviceTypeWithClusterServer('Temperature', [temperatureSensor], [], { tagList: [{ mfgCode: null, namespaceId: LocationTag.Indoor.namespaceId, tag: LocationTag.Indoor.tag, label: null }] }, true);
525
+ * ```
526
+ */
405
527
  addChildDeviceTypeWithClusterServer(endpointName, definition, includeServerList = [], options = {}, debug = false) {
406
528
  this.log.debug(`addChildDeviceTypeWithClusterServer: ${CYAN}${endpointName}${db}`);
407
529
  let child = this.getChildEndpointByName(endpointName);
@@ -451,50 +573,117 @@ export class MatterbridgeEndpoint extends Endpoint {
451
573
  }
452
574
  return child;
453
575
  }
576
+ /**
577
+ * Retrieves a child endpoint by its name.
578
+ *
579
+ * @param {string} endpointName - The name of the endpoint to retrieve.
580
+ * @returns {Endpoint | undefined} The child endpoint with the specified name, or undefined if not found.
581
+ */
454
582
  getChildEndpointByName(endpointName) {
455
583
  return this.parts.find((part) => part.id === endpointName);
456
584
  }
585
+ /**
586
+ * Retrieves a child endpoint by its EndpointNumber.
587
+ *
588
+ * @param {EndpointNumber} endpointNumber - The EndpointNumber of the endpoint to retrieve.
589
+ * @returns {MatterbridgeEndpoint | undefined} The child endpoint with the specified EndpointNumber, or undefined if not found.
590
+ */
457
591
  getChildEndpoint(endpointNumber) {
458
592
  return this.parts.find((part) => part.number === endpointNumber);
459
593
  }
594
+ /**
595
+ * Get all the child endpoints of this endpoint.
596
+ *
597
+ * @returns {MatterbridgeEndpoint[]} The child endpoints.
598
+ */
460
599
  getChildEndpoints() {
461
600
  return Array.from(this.parts);
462
601
  }
602
+ /**
603
+ * Get all the device types of this endpoint.
604
+ *
605
+ * @returns {DeviceTypeDefinition[]} The device types of this endpoint.
606
+ */
463
607
  getDeviceTypes() {
464
608
  return Array.from(this.deviceTypes.values());
465
609
  }
610
+ /**
611
+ * Sets the device types.
612
+ *
613
+ * @param {AtLeastOne<DeviceTypeDefinition>} deviceTypes - The device types to set.
614
+ *
615
+ * @deprecated This method is deprecated and will be removed in future versions.
616
+ */
466
617
  setDeviceTypes(deviceTypes) {
467
618
  deviceTypes.forEach((deviceType) => {
468
619
  this.addDeviceType(deviceType);
469
620
  });
470
621
  }
622
+ /**
623
+ * Sets the device reachable attribute and trigger the event.
624
+ *
625
+ * @param {boolean} reachable - The device types to set.
626
+ *
627
+ * @deprecated This method is deprecated and will be removed in future versions.
628
+ */
471
629
  async setBridgedDeviceReachability(reachable) {
630
+ // await this.setAttribute(BridgedDeviceBasicInformationCluster.id, 'reachable', reachable, this.log);
631
+ // await this.triggerEvent(BridgedDeviceBasicInformationCluster.id, 'reachableChanged', { reachableNewValue: reachable }, this.log);
472
632
  }
633
+ /**
634
+ * @deprecated This method is deprecated and will be removed in future versions.
635
+ */
473
636
  hasClusterServer(cluster) {
637
+ // const clusterName = this.lowercaseFirstLetter(getClusterNameById(cluster.id));
638
+ // return this.behaviors.supported[clusterName] !== undefined;
474
639
  return this.clusterServers.has(cluster.id);
475
640
  }
641
+ /**
642
+ * @deprecated This method is deprecated and will be removed in future versions.
643
+ */
476
644
  getClusterServer(cluster) {
477
645
  const clusterServer = this.clusterServers.get(cluster.id);
478
646
  if (clusterServer !== undefined) {
479
647
  return clusterServer;
480
648
  }
481
649
  }
650
+ /**
651
+ * @deprecated This method is deprecated and will be removed in future versions.
652
+ */
482
653
  getClusterServerById(clusterId) {
483
654
  return this.clusterServers.get(clusterId);
484
655
  }
656
+ /**
657
+ * @deprecated This method is deprecated and will be removed in future versions.
658
+ */
485
659
  getAllClusterServers() {
486
660
  return [...this.clusterServers.values()];
487
661
  }
662
+ /**
663
+ * Add a tagList.
664
+ *
665
+ * @deprecated This method is deprecated and will be removed in future versions. Use the constructor options instead.
666
+ */
488
667
  addTagList(endpoint, mfgCode, namespaceId, tag, label) {
668
+ // Do nothing here only for old api compatibility
489
669
  }
490
670
  addClusterServer(cluster) {
671
+ // console.log('addClusterServer:', cluster.id, cluster.name, cluster.attributes, cluster.events, cluster.commands);
491
672
  let features = {};
673
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
492
674
  const options = {};
493
675
  for (const attribute of Object.values(cluster.attributes)) {
676
+ // console.error('Attribute:', (attribute as any).id, (attribute as any).name, (attribute as any).value);
677
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
494
678
  if (attribute.name === 'featureMap') {
679
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
495
680
  features = attribute.value;
681
+ // console.log('Cluster', cluster.name, 'FeatureMap:', features);
682
+ // options[(attribute as any).name] = (attribute as any).value;
496
683
  }
684
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
497
685
  if (attribute.id < 0xfff0) {
686
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
498
687
  options[attribute.name] = attribute.value;
499
688
  }
500
689
  }
@@ -534,9 +723,16 @@ export class MatterbridgeEndpoint extends Endpoint {
534
723
  const behavior = MatterbridgeEndpoint.getBehaviourTypeFromClusterServerId(cluster.id, this.subType);
535
724
  this.clusterServers.set(cluster.id, cluster);
536
725
  if (cluster.id === BasicInformationCluster.id)
537
- return;
726
+ return; // Not used in Matterbridge edge for devices. Only on server node.
538
727
  this.behaviors.require(behavior, options);
539
728
  }
729
+ /**
730
+ * Adds cluster servers to the specified endpoint based on the provided server list.
731
+ *
732
+ * @param {MatterbridgeEndpoint} endpoint - The endpoint to add cluster servers to.
733
+ * @param {ClusterId[]} includeServerList - The list of cluster IDs to include.
734
+ * @returns void
735
+ */
540
736
  addClusterServerFromList(endpoint, includeServerList) {
541
737
  if (includeServerList.includes(Identify.Cluster.id))
542
738
  endpoint.addClusterServer(this.getDefaultIdentifyClusterServer());
@@ -606,6 +802,8 @@ export class MatterbridgeEndpoint extends Endpoint {
606
802
  endpoint.addClusterServer(this.getDefaultRadonConcentrationMeasurementClusterServer());
607
803
  if (includeServerList.includes(TotalVolatileOrganicCompoundsConcentrationMeasurement.Cluster.id))
608
804
  endpoint.addClusterServer(this.getDefaultTvocMeasurementClusterServer());
805
+ // if (includeServerList.includes(DeviceEnergyManagement.Cluster.id)) endpoint.addClusterServer(this.getDefaultDeviceEnergyManagementClusterServer());
806
+ // if (includeServerList.includes(DeviceEnergyManagementMode.Cluster.id)) endpoint.addClusterServer(this.getDefaultDeviceEnergyManagementModeClusterServer());
609
807
  }
610
808
  async addFixedLabel(label, value) {
611
809
  if (!this.clusterServers.get(FixedLabelCluster.id)) {
@@ -643,6 +841,16 @@ export class MatterbridgeEndpoint extends Endpoint {
643
841
  return name;
644
842
  return name.charAt(0).toLowerCase() + name.slice(1);
645
843
  }
844
+ /**
845
+ * Retrieves the value of the specified attribute from the given endpoint and cluster.
846
+ *
847
+ * @param {ClusterId} clusterId - The ID of the cluster to retrieve the attribute from.
848
+ * @param {string} attribute - The name of the attribute to retrieve.
849
+ * @param {AnsiLogger} [log] - Optional logger for error and info messages.
850
+ * @param {MatterbridgeEndpoint} [endpoint] - Optional the child endpoint to retrieve the attribute from.
851
+ * @returns {any} The value of the attribute, or undefined if the attribute is not found.
852
+ */
853
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
646
854
  getAttribute(clusterId, attribute, log, endpoint) {
647
855
  if (!endpoint)
648
856
  endpoint = this;
@@ -651,6 +859,7 @@ export class MatterbridgeEndpoint extends Endpoint {
651
859
  this.log.error(`getAttribute ${hk}${clusterName}.${attribute}${er} error: Endpoint ${or}${endpoint.id}${er} is in the ${BLUE}${endpoint.construction.status}${er} state`);
652
860
  return undefined;
653
861
  }
862
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
654
863
  const state = endpoint.state;
655
864
  if (!(clusterName in state)) {
656
865
  this.log.error(`getAttribute error: Cluster ${'0x' + clusterId.toString(16).padStart(4, '0')}:${clusterName} not found on endpoint ${or}${endpoint.id}${er}:${or}${endpoint.number}${er}`);
@@ -665,6 +874,17 @@ export class MatterbridgeEndpoint extends Endpoint {
665
874
  log?.info(`${db}Get endpoint ${or}${endpoint.id}${db}:${or}${endpoint.number}${db} attribute ${hk}${this.capitalizeFirstLetter(clusterName)}${db}.${hk}${attribute}${db} value ${YELLOW}${typeof value === 'object' ? debugStringify(value) : value}${db}`);
666
875
  return value;
667
876
  }
877
+ /**
878
+ * Sets the value of an attribute on a cluster server endpoint.
879
+ *
880
+ * @param {ClusterId} clusterId - The ID of the cluster.
881
+ * @param {string} attribute - The name of the attribute.
882
+ * @param {any} value - The value to set for the attribute.
883
+ * @param {AnsiLogger} [log] - (Optional) The logger to use for logging errors and information.
884
+ * @param {MatterbridgeEndpoint} [endpoint] - (Optional) The endpoint to set the attribute on. If not provided, the attribute will be set on the current endpoint.
885
+ * @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the attribute was successfully set.
886
+ */
887
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
668
888
  async setAttribute(clusterId, attribute, value, log, endpoint) {
669
889
  if (!endpoint)
670
890
  endpoint = this;
@@ -673,6 +893,7 @@ export class MatterbridgeEndpoint extends Endpoint {
673
893
  this.log.error(`setAttribute ${hk}${clusterName}.${attribute}${er} error: Endpoint ${or}${endpoint.id}${er} is in the ${BLUE}${endpoint.construction.status}${er} state`);
674
894
  return false;
675
895
  }
896
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
676
897
  const state = endpoint.state;
677
898
  if (!(clusterName in state)) {
678
899
  this.log.error(`setAttribute ${hk}${attribute}${er} error: Cluster ${'0x' + clusterId.toString(16).padStart(4, '0')}:${clusterName} not found on endpoint ${or}${endpoint.id}${er}:${or}${endpoint.number}${er}`);
@@ -692,13 +913,26 @@ export class MatterbridgeEndpoint extends Endpoint {
692
913
  `to ${YELLOW}${typeof value === 'object' ? debugStringify(value) : value}${db}`);
693
914
  return true;
694
915
  }
916
+ /**
917
+ * Subscribes to an attribute on a cluster.
918
+ *
919
+ * @param {ClusterId} clusterId - The ID of the cluster.
920
+ * @param {string} attribute - The name of the attribute to subscribe to.
921
+ * @param {(newValue: any, oldValue: any) => void} listener - A callback function that will be called when the attribute value changes.
922
+ * @param {AnsiLogger} [log] - Optional logger for logging errors and information.
923
+ * @param {MatterbridgeEndpoint} [endpoint] - Optional endpoint to subscribe the attribute on. Defaults to the current endpoint.
924
+ * @returns {boolean} - A boolean indicating whether the subscription was successful.
925
+ */
926
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
695
927
  async subscribeAttribute(clusterId, attribute, listener, log, endpoint) {
696
928
  if (!endpoint)
697
929
  endpoint = this;
698
930
  const clusterName = this.lowercaseFirstLetter(getClusterNameById(clusterId));
699
931
  if (endpoint.construction.status !== Lifecycle.Status.Active) {
932
+ // this.log.error(`subscribeAttribute ${hk}${clusterName}.${attribute}${er} error: Endpoint ${or}${endpoint.id}${er} is in the ${BLUE}${endpoint.construction.status}${er} state`);
700
933
  await endpoint.construction.ready;
701
934
  }
935
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
702
936
  const events = endpoint.events;
703
937
  if (!(clusterName in events)) {
704
938
  this.log.error(`subscribeAttribute ${hk}${attribute}${er} error: Cluster ${'0x' + clusterId.toString(16).padStart(4, '0')}:${clusterName} not found on endpoint ${or}${endpoint.id}${er}:${or}${endpoint.number}${er}`);
@@ -713,46 +947,143 @@ export class MatterbridgeEndpoint extends Endpoint {
713
947
  log?.info(`${db}Subscribe endpoint ${or}${endpoint.id}${db}:${or}${endpoint.number}${db} attribute ${hk}${this.capitalizeFirstLetter(clusterName)}${db}.${hk}${attribute}${db}`);
714
948
  return true;
715
949
  }
950
+ /**
951
+ * Triggers an event on the specified cluster.
952
+ *
953
+ * @param {ClusterId} clusterId - The ID of the cluster.
954
+ * @param {string} event - The name of the event to trigger.
955
+ * @param {Record<string, boolean | number | bigint | string | object | undefined | null>} payload - The payload to pass to the event.
956
+ * @param {AnsiLogger} [log] - Optional logger for logging information.
957
+ * @param {MatterbridgeEndpoint} [endpoint] - Optional endpoint to trigger the event on. Defaults to the current endpoint.
958
+ * @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the event was successfully triggered.
959
+ */
716
960
  async triggerEvent(clusterId, event, payload, log, endpoint) {
717
961
  if (!endpoint)
718
962
  endpoint = this;
719
963
  const clusterName = this.lowercaseFirstLetter(getClusterNameById(clusterId));
720
964
  if (endpoint.construction.status !== Lifecycle.Status.Active) {
965
+ // this.log.error(`triggerEvent ${hk}${clusterName}.${event}${er} error: Endpoint ${or}${endpoint.id}${er} is in the ${BLUE}${endpoint.construction.status}${er} state`);
721
966
  await endpoint.construction.ready;
967
+ // return false;
722
968
  }
969
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
723
970
  const events = endpoint.events;
724
971
  if (!(clusterName in events) || !(event in events[clusterName])) {
725
972
  this.log.error(`triggerEvent ${hk}${event}${er} error: Cluster ${'0x' + clusterId.toString(16).padStart(4, '0')}:${clusterName} not found on endpoint ${or}${endpoint.id}${er}:${or}${endpoint.number}${er}`);
726
973
  return false;
727
974
  }
975
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
976
+ // @ts-ignore
728
977
  await endpoint.act((agent) => agent[clusterName].events[event].emit(payload, agent.context));
729
978
  log?.info(`${db}Trigger event ${hk}${this.capitalizeFirstLetter(clusterName)}${db}.${hk}${event}${db} with ${debugStringify(payload)}${db} on endpoint ${or}${endpoint.id}${db}:${or}${endpoint.number}${db} `);
730
979
  return true;
731
980
  }
981
+ /**
982
+ * Adds a command handler for the specified command.
983
+ *
984
+ * @param {keyof MatterbridgeEndpointCommands} command - The command to add the handler for.
985
+ * @param {(data: any) => void} handler - The handler function to execute when the command is received.
986
+ * @returns {void}
987
+ */
988
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
732
989
  addCommandHandler(command, handler) {
733
990
  this.commandHandler.addHandler(command, handler);
734
991
  }
992
+ /**
993
+ * Serializes the Matterbridge device into a serialized object.
994
+ *
995
+ * @param pluginName - The name of the plugin.
996
+ * @returns The serialized Matterbridge device object.
997
+ */
735
998
  serialize() {
736
999
  return undefined;
737
- }
1000
+ /*
1001
+ if (!this.serialNumber || !this.deviceName || !this.uniqueId) return;
1002
+ const cluster = this.getClusterServer(BasicInformationCluster) ?? this.getClusterServer(BridgedDeviceBasicInformationCluster);
1003
+ if (!cluster) return;
1004
+ const serialized: SerializedMatterbridgeDevice = {
1005
+ pluginName: this.plugin ?? 'Unknown',
1006
+ serialNumber: this.serialNumber,
1007
+ deviceName: this.deviceName,
1008
+ uniqueId: this.uniqueId,
1009
+ productName: cluster.attributes.productName?.getLocal(),
1010
+ vendorId: cluster.attributes.vendorId?.getLocal(),
1011
+ vendorName: cluster.attributes.vendorName?.getLocal(),
1012
+ deviceTypes: Array.from(this.deviceTypes.values()),
1013
+ endpoint: this.number,
1014
+ endpointName: this.id,
1015
+ clusterServersId: [],
1016
+ };
1017
+ this.getAllClusterServers().forEach((clusterServer) => {
1018
+ serialized.clusterServersId.push(clusterServer.id);
1019
+ });
1020
+ return serialized;
1021
+ */
1022
+ }
1023
+ /**
1024
+ * Deserializes the device into a serialized object.
1025
+ *
1026
+ * @returns The deserialized MatterbridgeDevice.
1027
+ */
738
1028
  static deserialize(serializedDevice) {
739
1029
  return undefined;
740
- }
1030
+ /*
1031
+ const device = new MatterbridgeDevice(serializedDevice.deviceTypes);
1032
+ device.serialNumber = serializedDevice.serialNumber;
1033
+ device.deviceName = serializedDevice.deviceName;
1034
+ device.uniqueId = serializedDevice.uniqueId;
1035
+ for (const clusterId of serializedDevice.clusterServersId) {
1036
+ if (clusterId === BasicInformationCluster.id)
1037
+ device.createDefaultBasicInformationClusterServer(
1038
+ serializedDevice.deviceName,
1039
+ serializedDevice.serialNumber,
1040
+ serializedDevice.vendorId ?? 0xfff1,
1041
+ serializedDevice.vendorName ?? 'Matterbridge',
1042
+ serializedDevice.productId ?? 0x8000,
1043
+ serializedDevice.productName ?? 'Matterbridge device',
1044
+ );
1045
+ else if (clusterId === BridgedDeviceBasicInformationCluster.id)
1046
+ device.createDefaultBridgedDeviceBasicInformationClusterServer(
1047
+ serializedDevice.deviceName,
1048
+ serializedDevice.serialNumber,
1049
+ serializedDevice.vendorId ?? 0xfff1,
1050
+ serializedDevice.vendorName ?? 'Matterbridge',
1051
+ serializedDevice.productName ?? 'Matterbridge device',
1052
+ );
1053
+ else device.addClusterServerFromList(device, [clusterId]);
1054
+ }
1055
+ return device;
1056
+ */
1057
+ }
1058
+ /**
1059
+ * From here copy paste from MatterbridgeDevice
1060
+ */
1061
+ /**
1062
+ * Get a default IdentifyCluster server.
1063
+ */
741
1064
  getDefaultIdentifyClusterServer(identifyTime = 0, identifyType = Identify.IdentifyType.None) {
742
1065
  return ClusterServer(IdentifyCluster, {
743
1066
  identifyTime,
744
1067
  identifyType,
745
1068
  }, {
746
1069
  identify: async (data) => {
1070
+ // Never called in edge
747
1071
  },
748
1072
  triggerEffect: async (data) => {
1073
+ // Never called in edge
749
1074
  },
750
1075
  });
751
1076
  }
1077
+ /**
1078
+ * Creates a default IdentifyCluster server.
1079
+ */
752
1080
  createDefaultIdentifyClusterServer(identifyTime = 0, identifyType = Identify.IdentifyType.None) {
753
1081
  this.addClusterServer(this.getDefaultIdentifyClusterServer(identifyTime, identifyType));
754
1082
  return this;
755
1083
  }
1084
+ /**
1085
+ * Get a default IdentifyCluster server.
1086
+ */
756
1087
  getDefaultGroupsClusterServer() {
757
1088
  return ClusterServer(GroupsCluster, {
758
1089
  nameSupport: {
@@ -760,20 +1091,73 @@ export class MatterbridgeEndpoint extends Endpoint {
760
1091
  },
761
1092
  }, GroupsClusterHandler());
762
1093
  }
1094
+ /**
1095
+ * Creates a default groups cluster server and adds it to the device.
1096
+ */
763
1097
  createDefaultGroupsClusterServer() {
764
1098
  this.addClusterServer(this.getDefaultGroupsClusterServer());
765
1099
  return this;
766
1100
  }
1101
+ /**
1102
+ * Get a default scenes cluster server and adds it to the current instance.
1103
+ * @deprecated This method is deprecated.
1104
+ *
1105
+ */
767
1106
  getDefaultScenesClusterServer() {
768
- }
1107
+ /*
1108
+ return ClusterServer(
1109
+ ScenesCluster,
1110
+ {
1111
+ sceneCount: 0,
1112
+ currentScene: 0,
1113
+ currentGroup: GroupId(0),
1114
+ sceneValid: false,
1115
+ nameSupport: {
1116
+ nameSupport: true,
1117
+ },
1118
+ lastConfiguredBy: null,
1119
+ },
1120
+ {},
1121
+ );
1122
+ */
1123
+ }
1124
+ /**
1125
+ * Creates a default scenes cluster server and adds it to the current instance.
1126
+ * @deprecated This method is deprecated.
1127
+ */
769
1128
  createDefaultScenesClusterServer() {
1129
+ /*
1130
+ this.addClusterServer(this.getDefaultScenesClusterServer());
1131
+ */
770
1132
  return this;
771
1133
  }
1134
+ /**
1135
+ * Creates a unique identifier based on the provided parameters.
1136
+ * @param param1 - The first parameter.
1137
+ * @param param2 - The second parameter.
1138
+ * @param param3 - The third parameter.
1139
+ * @param param4 - The fourth parameter.
1140
+ * @returns A unique identifier generated using the MD5 hash algorithm.
1141
+ */
772
1142
  createUniqueId(param1, param2, param3, param4) {
773
1143
  const hash = createHash('md5');
774
1144
  hash.update(param1 + param2 + param3 + param4);
775
1145
  return hash.digest('hex');
776
1146
  }
1147
+ /**
1148
+ * Get a default Basic Information Cluster Server.
1149
+ *
1150
+ * @param deviceName - The name of the device.
1151
+ * @param serialNumber - The serial number of the device.
1152
+ * @param vendorId - The vendor ID of the device.
1153
+ * @param vendorName - The vendor name of the device.
1154
+ * @param productId - The product ID of the device.
1155
+ * @param productName - The product name of the device.
1156
+ * @param softwareVersion - The software version of the device. Default is 1.
1157
+ * @param softwareVersionString - The software version string of the device. Default is 'v.1.0.0'.
1158
+ * @param hardwareVersion - The hardware version of the device. Default is 1.
1159
+ * @param hardwareVersionString - The hardware version string of the device. Default is 'v.1.0.0'.
1160
+ */
777
1161
  getDefaultBasicInformationClusterServer(deviceName, serialNumber, vendorId, vendorName, productId, productName, softwareVersion = 1, softwareVersionString = '1.0.0', hardwareVersion = 1, hardwareVersionString = '1.0.0') {
778
1162
  this.log.logName = deviceName;
779
1163
  this.deviceName = deviceName;
@@ -814,6 +1198,20 @@ export class MatterbridgeEndpoint extends Endpoint {
814
1198
  reachableChanged: true,
815
1199
  });
816
1200
  }
1201
+ /**
1202
+ * Creates a default Basic Information Cluster Server.
1203
+ *
1204
+ * @param deviceName - The name of the device.
1205
+ * @param serialNumber - The serial number of the device.
1206
+ * @param vendorId - The vendor ID of the device.
1207
+ * @param vendorName - The vendor name of the device.
1208
+ * @param productId - The product ID of the device.
1209
+ * @param productName - The product name of the device.
1210
+ * @param softwareVersion - The software version of the device. Default is 1.
1211
+ * @param softwareVersionString - The software version string of the device. Default is 'v.1.0.0'.
1212
+ * @param hardwareVersion - The hardware version of the device. Default is 1.
1213
+ * @param hardwareVersionString - The hardware version string of the device. Default is 'v.1.0.0'.
1214
+ */
817
1215
  createDefaultBasicInformationClusterServer(deviceName, serialNumber, vendorId, vendorName, productId, productName, softwareVersion = 1, softwareVersionString = '1.0.0', hardwareVersion = 1, hardwareVersionString = '1.0.0') {
818
1216
  if (MatterbridgeEndpoint.bridgeMode === 'bridge') {
819
1217
  this.addDeviceType(bridgedNode);
@@ -823,6 +1221,19 @@ export class MatterbridgeEndpoint extends Endpoint {
823
1221
  this.addClusterServer(this.getDefaultBasicInformationClusterServer(deviceName, serialNumber, vendorId, vendorName, productId, productName, softwareVersion, softwareVersionString, hardwareVersion, hardwareVersionString));
824
1222
  return this;
825
1223
  }
1224
+ /**
1225
+ * Get a default BridgedDeviceBasicInformationClusterServer.
1226
+ *
1227
+ * @param deviceName - The name of the device.
1228
+ * @param serialNumber - The serial number of the device.
1229
+ * @param vendorId - The vendor ID of the device.
1230
+ * @param vendorName - The name of the vendor.
1231
+ * @param productName - The name of the product.
1232
+ * @param softwareVersion - The software version of the device. Default is 1.
1233
+ * @param softwareVersionString - The software version string of the device. Default is 'v.1.0.0'.
1234
+ * @param hardwareVersion - The hardware version of the device. Default is 1.
1235
+ * @param hardwareVersionString - The hardware version string of the device. Default is 'v.1.0.0'.
1236
+ */
826
1237
  getDefaultBridgedDeviceBasicInformationClusterServer(deviceName, serialNumber, vendorId, vendorName, productName, softwareVersion = 1, softwareVersionString = '1.0.0', hardwareVersion = 1, hardwareVersionString = '1.0.0') {
827
1238
  this.log.logName = deviceName;
828
1239
  this.deviceName = deviceName;
@@ -837,7 +1248,7 @@ export class MatterbridgeEndpoint extends Endpoint {
837
1248
  this.hardwareVersion = hardwareVersion;
838
1249
  this.hardwareVersionString = hardwareVersionString;
839
1250
  return ClusterServer(BridgedDeviceBasicInformationCluster, {
840
- vendorId: vendorId !== undefined ? VendorId(vendorId) : undefined,
1251
+ vendorId: vendorId !== undefined ? VendorId(vendorId) : undefined, // 4874
841
1252
  vendorName: vendorName.slice(0, 32),
842
1253
  productName: productName.slice(0, 32),
843
1254
  productUrl: this.productUrl,
@@ -857,13 +1268,37 @@ export class MatterbridgeEndpoint extends Endpoint {
857
1268
  reachableChanged: true,
858
1269
  });
859
1270
  }
1271
+ /**
1272
+ * Creates a default BridgedDeviceBasicInformationClusterServer.
1273
+ *
1274
+ * @param deviceName - The name of the device.
1275
+ * @param serialNumber - The serial number of the device.
1276
+ * @param vendorId - The vendor ID of the device.
1277
+ * @param vendorName - The name of the vendor.
1278
+ * @param productName - The name of the product.
1279
+ * @param softwareVersion - The software version of the device. Default is 1.
1280
+ * @param softwareVersionString - The software version string of the device. Default is 'v.1.0.0'.
1281
+ * @param hardwareVersion - The hardware version of the device. Default is 1.
1282
+ * @param hardwareVersionString - The hardware version string of the device. Default is 'v.1.0.0'.
1283
+ */
860
1284
  createDefaultBridgedDeviceBasicInformationClusterServer(deviceName, serialNumber, vendorId, vendorName, productName, softwareVersion = 1, softwareVersionString = '1.0.0', hardwareVersion = 1, hardwareVersionString = '1.0.0') {
861
1285
  this.addClusterServer(this.getDefaultBridgedDeviceBasicInformationClusterServer(deviceName, serialNumber, vendorId, vendorName, productName, softwareVersion, softwareVersionString, hardwareVersion, hardwareVersionString));
862
1286
  return this;
863
1287
  }
1288
+ /**
1289
+ * Get a default Power Topology Cluster Server. Only needed for an electricalSensor device type.
1290
+ *
1291
+ * @returns {ClusterServer} - The configured Power Topology Cluster Server.
1292
+ */
864
1293
  getDefaultPowerTopologyClusterServer() {
865
1294
  return ClusterServer(PowerTopologyCluster.with(PowerTopology.Feature.TreeTopology), {}, {}, {});
866
1295
  }
1296
+ /**
1297
+ * Get a default Electrical Energy Measurement Cluster Server.
1298
+ *
1299
+ * @param {number} energy - The total consumption value in mW/h.
1300
+ * @returns {ClusterServer} - The configured Electrical Energy Measurement Cluster Server.
1301
+ */
867
1302
  getDefaultElectricalEnergyMeasurementClusterServer(energy = null) {
868
1303
  return ClusterServer(ElectricalEnergyMeasurementCluster.with(ElectricalEnergyMeasurement.Feature.ImportedEnergy, ElectricalEnergyMeasurement.Feature.ExportedEnergy, ElectricalEnergyMeasurement.Feature.CumulativeEnergy), {
869
1304
  accuracy: {
@@ -880,6 +1315,15 @@ export class MatterbridgeEndpoint extends Endpoint {
880
1315
  cumulativeEnergyMeasured: true,
881
1316
  });
882
1317
  }
1318
+ /**
1319
+ * Get a default Electrical Power Measurement Cluster Server.
1320
+ *
1321
+ * @param {number} voltage - The voltage value in millivolts.
1322
+ * @param {number} current - The current value in milliamperes.
1323
+ * @param {number} power - The power value in milliwatts.
1324
+ * @param {number} frequency - The frequency value in millihertz.
1325
+ * @returns {ClusterServer} - The configured Electrical Power Measurement Cluster Server.
1326
+ */
883
1327
  getDefaultElectricalPowerMeasurementClusterServer(voltage = null, current = null, power = null, frequency = null) {
884
1328
  return ClusterServer(ElectricalPowerMeasurementCluster.with(ElectricalPowerMeasurement.Feature.AlternatingCurrent), {
885
1329
  powerMode: ElectricalPowerMeasurement.PowerMode.Ac,
@@ -920,6 +1364,16 @@ export class MatterbridgeEndpoint extends Endpoint {
920
1364
  frequency: frequency,
921
1365
  }, {}, {});
922
1366
  }
1367
+ /**
1368
+ * Get a default OnOff cluster server for light devices.
1369
+ *
1370
+ * @param {boolean} [onOff=false] - The initial state of the OnOff cluster.
1371
+ * @param {boolean} [globalSceneControl=false] - The global scene control state.
1372
+ * @param {number} [onTime=0] - The on time value.
1373
+ * @param {number} [offWaitTime=0] - The off wait time value.
1374
+ * @param {OnOff.StartUpOnOff | null} [startUpOnOff=null] - The start-up OnOff state. Null means previous state.
1375
+ * @returns {ClusterServer} - The configured OnOff cluster server.
1376
+ */
923
1377
  getDefaultOnOffClusterServer(onOff = false, globalSceneControl = false, onTime = 0, offWaitTime = 0, startUpOnOff = null) {
924
1378
  return ClusterServer(OnOffCluster.with(OnOff.Feature.Lighting), {
925
1379
  onOff,
@@ -929,55 +1383,110 @@ export class MatterbridgeEndpoint extends Endpoint {
929
1383
  startUpOnOff,
930
1384
  }, {
931
1385
  on: async (data) => {
1386
+ // Never called in edge
932
1387
  },
933
1388
  off: async (data) => {
1389
+ // Never called in edge
934
1390
  },
935
1391
  toggle: async (data) => {
1392
+ // Never called in edge
936
1393
  },
937
1394
  offWithEffect: async () => {
1395
+ // Never called in edge
938
1396
  },
939
1397
  onWithRecallGlobalScene: async () => {
1398
+ // Never called in edge
940
1399
  },
941
1400
  onWithTimedOff: async () => {
1401
+ // Never called in edge
942
1402
  },
943
1403
  }, {});
944
1404
  }
1405
+ /**
1406
+ * Creates a default OnOff cluster server for light devices.
1407
+ *
1408
+ * @param {boolean} [onOff=false] - The initial state of the OnOff cluster.
1409
+ * @param {boolean} [globalSceneControl=false] - The global scene control state.
1410
+ * @param {number} [onTime=0] - The on time value.
1411
+ * @param {number} [offWaitTime=0] - The off wait time value.
1412
+ * @param {OnOff.StartUpOnOff | null} [startUpOnOff=null] - The start-up OnOff state. Null means previous state.
1413
+ * @returns {void}
1414
+ */
945
1415
  createDefaultOnOffClusterServer(onOff = false, globalSceneControl = false, onTime = 0, offWaitTime = 0, startUpOnOff = null) {
946
1416
  this.addClusterServer(this.getDefaultOnOffClusterServer(onOff, globalSceneControl, onTime, offWaitTime, startUpOnOff));
947
1417
  return this;
948
1418
  }
1419
+ /**
1420
+ * Get an OnOff cluster server without features.
1421
+ *
1422
+ * @param {boolean} [onOff=false] - The initial state of the OnOff cluster.
1423
+ *
1424
+ * @returns {ClusterServer} - The configured OnOff cluster server.
1425
+ */
949
1426
  getOnOffClusterServer(onOff = false) {
950
1427
  return ClusterServer(OnOffCluster, {
951
1428
  onOff,
952
1429
  }, {
953
1430
  on: async (data) => {
1431
+ // Never called in edge
954
1432
  },
955
1433
  off: async (data) => {
1434
+ // Never called in edge
956
1435
  },
957
1436
  toggle: async (data) => {
1437
+ // Never called in edge
958
1438
  },
959
1439
  }, {});
960
1440
  }
1441
+ /**
1442
+ * Creates an OnOff cluster server without features.
1443
+ *
1444
+ * @param {boolean} [onOff=false] - The initial state of the OnOff cluster.
1445
+ */
961
1446
  createOnOffClusterServer(onOff = false) {
962
1447
  this.addClusterServer(this.getOnOffClusterServer(onOff));
963
1448
  return this;
964
1449
  }
1450
+ /**
1451
+ * Get a DeadFront OnOff cluster server.
1452
+ *
1453
+ * @param {boolean} [onOff=false] - The initial state of the OnOff cluster.
1454
+ *
1455
+ * @returns {ClusterServer} - The configured OnOff cluster server.
1456
+ */
965
1457
  getDeadFrontOnOffClusterServer(onOff = false) {
966
1458
  return ClusterServer(OnOffCluster.with(OnOff.Feature.DeadFrontBehavior), {
967
1459
  onOff,
968
1460
  }, {
969
1461
  on: async (data) => {
1462
+ // Never called in edge
970
1463
  },
971
1464
  off: async (data) => {
1465
+ // Never called in edge
972
1466
  },
973
1467
  toggle: async (data) => {
1468
+ // Never called in edge
974
1469
  },
975
1470
  }, {});
976
1471
  }
1472
+ /**
1473
+ * Creates a DeadFront OnOff cluster server.
1474
+ *
1475
+ * @param {boolean} [onOff=false] - The initial state of the OnOff cluster.
1476
+ */
977
1477
  createDeadFrontOnOffClusterServer(onOff = false) {
978
1478
  this.addClusterServer(this.getDeadFrontOnOffClusterServer(onOff));
979
1479
  return this;
980
1480
  }
1481
+ /**
1482
+ * Get a default level control cluster server.
1483
+ *
1484
+ * @param currentLevel - The current level (default: 254).
1485
+ * @param minLevel - The minimum level (default: 1).
1486
+ * @param maxLevel - The maximum level (default: 254).
1487
+ * @param onLevel - The on level (default: null).
1488
+ * @param startUpCurrentLevel - The startUp on level (default: null).
1489
+ */
981
1490
  getDefaultLevelControlClusterServer(currentLevel = 254, minLevel = 1, maxLevel = 254, onLevel = null, startUpCurrentLevel = null) {
982
1491
  return ClusterServer(LevelControlCluster.with(LevelControl.Feature.OnOff, LevelControl.Feature.Lighting), {
983
1492
  currentLevel,
@@ -992,27 +1501,55 @@ export class MatterbridgeEndpoint extends Endpoint {
992
1501
  },
993
1502
  }, {
994
1503
  moveToLevel: async (data) => {
1504
+ // Never called in edge
995
1505
  },
996
1506
  move: async () => {
1507
+ // Never called in edge
997
1508
  },
998
1509
  step: async () => {
1510
+ // Never called in edge
999
1511
  },
1000
1512
  stop: async () => {
1513
+ // Never called in edge
1001
1514
  },
1002
1515
  moveToLevelWithOnOff: async (data) => {
1516
+ // Never called in edge
1003
1517
  },
1004
1518
  moveWithOnOff: async () => {
1519
+ // Never called in edge
1005
1520
  },
1006
1521
  stepWithOnOff: async () => {
1522
+ // Never called in edge
1007
1523
  },
1008
1524
  stopWithOnOff: async () => {
1525
+ // Never called in edge
1009
1526
  },
1010
1527
  });
1011
1528
  }
1529
+ /**
1530
+ * Creates a default level control cluster server.
1531
+ *
1532
+ * @param currentLevel - The current level (default: 254).
1533
+ * @param minLevel - The minimum level (default: 1).
1534
+ * @param maxLevel - The maximum level (default: 254).
1535
+ * @param onLevel - The on level (default: null).
1536
+ * @param startUpCurrentLevel - The startUp on level (default: null).
1537
+ */
1012
1538
  createDefaultLevelControlClusterServer(currentLevel = 254, minLevel = 1, maxLevel = 254, onLevel = null, startUpCurrentLevel = null) {
1013
1539
  this.addClusterServer(this.getDefaultLevelControlClusterServer(currentLevel, minLevel, maxLevel, onLevel, startUpCurrentLevel));
1014
1540
  return this;
1015
1541
  }
1542
+ /**
1543
+ * Get a default color control cluster server with Xy, HueSaturation and ColorTemperature.
1544
+ *
1545
+ * @param currentX - The current X value.
1546
+ * @param currentY - The current Y value.
1547
+ * @param currentHue - The current hue value.
1548
+ * @param currentSaturation - The current saturation value.
1549
+ * @param colorTemperatureMireds - The color temperature in mireds.
1550
+ * @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds.
1551
+ * @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds.
1552
+ */
1016
1553
  getDefaultColorControlClusterServer(currentX = 0, currentY = 0, currentHue = 0, currentSaturation = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
1017
1554
  return ClusterServer(ColorControlCluster.with(ColorControl.Feature.Xy, ColorControl.Feature.HueSaturation, ColorControl.Feature.ColorTemperature), {
1018
1555
  colorMode: ColorControl.ColorMode.CurrentHueAndCurrentSaturation,
@@ -1034,39 +1571,73 @@ export class MatterbridgeEndpoint extends Endpoint {
1034
1571
  startUpColorTemperatureMireds: null,
1035
1572
  }, {
1036
1573
  moveToColor: async (data) => {
1574
+ // Never called in edge
1037
1575
  },
1038
1576
  moveColor: async () => {
1577
+ // Never called in edge
1039
1578
  },
1040
1579
  stepColor: async () => {
1580
+ // Never called in edge
1041
1581
  },
1042
1582
  moveToHue: async (data) => {
1583
+ // Never called in edge
1043
1584
  },
1044
1585
  moveHue: async () => {
1586
+ // Never called in edge
1045
1587
  },
1046
1588
  stepHue: async () => {
1589
+ // Never called in edge
1047
1590
  },
1048
1591
  moveToSaturation: async (data) => {
1592
+ // Never called in edge
1049
1593
  },
1050
1594
  moveSaturation: async () => {
1595
+ // Never called in edge
1051
1596
  },
1052
1597
  stepSaturation: async () => {
1598
+ // Never called in edge
1053
1599
  },
1054
1600
  moveToHueAndSaturation: async (data) => {
1601
+ // Never called in edge
1055
1602
  },
1056
1603
  stopMoveStep: async () => {
1604
+ // Never called in edge
1057
1605
  },
1058
1606
  moveToColorTemperature: async (data) => {
1607
+ // Never called in edge
1059
1608
  },
1060
1609
  moveColorTemperature: async () => {
1610
+ // Never called in edge
1061
1611
  },
1062
1612
  stepColorTemperature: async () => {
1613
+ // Never called in edge
1063
1614
  },
1064
1615
  }, {});
1065
1616
  }
1617
+ /**
1618
+ * Creates a default color control cluster server with Xy, HueSaturation and ColorTemperature.
1619
+ *
1620
+ * @param currentX - The current X value.
1621
+ * @param currentY - The current Y value.
1622
+ * @param currentHue - The current hue value.
1623
+ * @param currentSaturation - The current saturation value.
1624
+ * @param colorTemperatureMireds - The color temperature in mireds.
1625
+ * @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds.
1626
+ * @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds.
1627
+ */
1066
1628
  createDefaultColorControlClusterServer(currentX = 0, currentY = 0, currentHue = 0, currentSaturation = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
1067
1629
  this.addClusterServer(this.getDefaultColorControlClusterServer(currentX, currentY, currentHue, currentSaturation, colorTemperatureMireds, colorTempPhysicalMinMireds, colorTempPhysicalMaxMireds));
1068
1630
  return this;
1069
1631
  }
1632
+ /**
1633
+ * Get a Xy color control cluster server with Xy and ColorTemperature.
1634
+ *
1635
+ * @param currentX - The current X value.
1636
+ * @param currentY - The current Y value.
1637
+ * @param colorTemperatureMireds - The color temperature in mireds.
1638
+ * @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds.
1639
+ * @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds.
1640
+ */
1070
1641
  getXyColorControlClusterServer(currentX = 0, currentY = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
1071
1642
  return ClusterServer(ColorControlCluster.with(ColorControl.Feature.Xy, ColorControl.Feature.ColorTemperature), {
1072
1643
  colorMode: ColorControl.ColorMode.CurrentXAndCurrentY,
@@ -1086,25 +1657,50 @@ export class MatterbridgeEndpoint extends Endpoint {
1086
1657
  remainingTime: 0,
1087
1658
  }, {
1088
1659
  moveToColor: async () => {
1660
+ // Never called in edge
1089
1661
  },
1090
1662
  moveColor: async () => {
1663
+ // Never called in edge
1091
1664
  },
1092
1665
  stepColor: async () => {
1666
+ // Never called in edge
1093
1667
  },
1094
1668
  stopMoveStep: async () => {
1669
+ // Never called in edge
1095
1670
  },
1096
1671
  moveToColorTemperature: async () => {
1672
+ // Never called in edge
1097
1673
  },
1098
1674
  moveColorTemperature: async () => {
1675
+ // Never called in edge
1099
1676
  },
1100
1677
  stepColorTemperature: async () => {
1678
+ // Never called in edge
1101
1679
  },
1102
1680
  }, {});
1103
1681
  }
1682
+ /**
1683
+ * Creates a Xy color control cluster server with Xy and ColorTemperature.
1684
+ *
1685
+ * @param currentX - The current X value.
1686
+ * @param currentY - The current Y value.
1687
+ * @param colorTemperatureMireds - The color temperature in mireds.
1688
+ * @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds.
1689
+ * @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds.
1690
+ */
1104
1691
  createXyColorControlClusterServer(currentX = 0, currentY = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
1105
1692
  this.addClusterServer(this.getXyColorControlClusterServer(currentX, currentY, colorTemperatureMireds, colorTempPhysicalMinMireds, colorTempPhysicalMaxMireds));
1106
1693
  return this;
1107
1694
  }
1695
+ /**
1696
+ * Get a default hue and saturation control cluster server with HueSaturation and ColorTemperature.
1697
+ *
1698
+ * @param currentHue - The current hue value.
1699
+ * @param currentSaturation - The current saturation value.
1700
+ * @param colorTemperatureMireds - The color temperature in mireds.
1701
+ * @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds.
1702
+ * @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds.
1703
+ */
1108
1704
  getHsColorControlClusterServer(currentHue = 0, currentSaturation = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
1109
1705
  return ClusterServer(ColorControlCluster.with(ColorControl.Feature.HueSaturation, ColorControl.Feature.ColorTemperature), {
1110
1706
  colorMode: ColorControl.ColorMode.CurrentHueAndCurrentSaturation,
@@ -1124,33 +1720,60 @@ export class MatterbridgeEndpoint extends Endpoint {
1124
1720
  remainingTime: 0,
1125
1721
  }, {
1126
1722
  moveToHue: async () => {
1723
+ // Never called in edge
1127
1724
  },
1128
1725
  moveHue: async () => {
1726
+ // Never called in edge
1129
1727
  },
1130
1728
  stepHue: async () => {
1729
+ // Never called in edge
1131
1730
  },
1132
1731
  moveToSaturation: async () => {
1732
+ // Never called in edge
1133
1733
  },
1134
1734
  moveSaturation: async () => {
1735
+ // Never called in edge
1135
1736
  },
1136
1737
  stepSaturation: async () => {
1738
+ // Never called in edge
1137
1739
  },
1138
1740
  moveToHueAndSaturation: async () => {
1741
+ // Never called in edge
1139
1742
  },
1140
1743
  stopMoveStep: async () => {
1744
+ // Never called in edge
1141
1745
  },
1142
1746
  moveToColorTemperature: async () => {
1747
+ // Never called in edge
1143
1748
  },
1144
1749
  moveColorTemperature: async () => {
1750
+ // Never called in edge
1145
1751
  },
1146
1752
  stepColorTemperature: async () => {
1753
+ // Never called in edge
1147
1754
  },
1148
1755
  }, {});
1149
1756
  }
1757
+ /**
1758
+ * Creates a hue and saturation color control cluster server with HueSaturation and ColorTemperature.
1759
+ *
1760
+ * @param currentHue - The current hue value.
1761
+ * @param currentSaturation - The current saturation value.
1762
+ * @param colorTemperatureMireds - The color temperature in mireds.
1763
+ * @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds.
1764
+ * @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds.
1765
+ */
1150
1766
  createHsColorControlClusterServer(currentHue = 0, currentSaturation = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
1151
1767
  this.addClusterServer(this.getHsColorControlClusterServer(currentHue, currentSaturation, colorTemperatureMireds, colorTempPhysicalMinMireds, colorTempPhysicalMaxMireds));
1152
1768
  return this;
1153
1769
  }
1770
+ /**
1771
+ * Get a color temperature color control cluster server.
1772
+ *
1773
+ * @param colorTemperatureMireds - The color temperature in mireds.
1774
+ * @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds.
1775
+ * @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds.
1776
+ */
1154
1777
  getCtColorControlClusterServer(colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
1155
1778
  return ClusterServer(ColorControlCluster.with(ColorControl.Feature.ColorTemperature), {
1156
1779
  colorMode: ColorControl.ColorMode.ColorTemperatureMireds,
@@ -1168,20 +1791,45 @@ export class MatterbridgeEndpoint extends Endpoint {
1168
1791
  startUpColorTemperatureMireds: null,
1169
1792
  }, {
1170
1793
  stopMoveStep: async () => {
1794
+ // Never called in edge
1171
1795
  },
1172
1796
  moveToColorTemperature: async () => {
1797
+ // Never called in edge
1173
1798
  },
1174
1799
  moveColorTemperature: async () => {
1800
+ // Never called in edge
1175
1801
  },
1176
1802
  stepColorTemperature: async () => {
1803
+ // Never called in edge
1177
1804
  },
1178
1805
  }, {});
1179
1806
  }
1807
+ /**
1808
+ * Creates a color temperature color control cluster server.
1809
+ *
1810
+ * @param colorTemperatureMireds - The color temperature in mireds.
1811
+ * @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds.
1812
+ * @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds.
1813
+ */
1180
1814
  createCtColorControlClusterServer(colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
1181
1815
  this.addClusterServer(this.getCtColorControlClusterServer(colorTemperatureMireds, colorTempPhysicalMinMireds, colorTempPhysicalMaxMireds));
1182
1816
  return this;
1183
1817
  }
1184
1818
  isColorControlConfigured = false;
1819
+ /**
1820
+ * Configures the color control cluster for a device.
1821
+ *
1822
+ * @remark This method must be called only after creating the cluster with getDefaultColorControlClusterServer or createDefaultColorControlClusterServer
1823
+ * and before starting the matter node.
1824
+ *
1825
+ * @deprecated Use configureColorControlMode instead.
1826
+ *
1827
+ * @param {boolean} hueSaturation - A boolean indicating whether the device supports hue and saturation control.
1828
+ * @param {boolean} xy - A boolean indicating whether the device supports XY control.
1829
+ * @param {boolean} colorTemperature - A boolean indicating whether the device supports color temperature control.
1830
+ * @param {ColorControl.ColorMode} colorMode - An optional parameter specifying the color mode of the device.
1831
+ * @param {Endpoint} endpoint - An optional parameter specifying the endpoint to configure. If not provided, the device endpoint will be used.
1832
+ */
1185
1833
  async configureColorControlCluster(hueSaturation, xy, colorTemperature, colorMode, endpoint) {
1186
1834
  if (!endpoint)
1187
1835
  endpoint = this;
@@ -1205,6 +1853,12 @@ export class MatterbridgeEndpoint extends Endpoint {
1205
1853
  this.isColorControlConfigured = true;
1206
1854
  return this;
1207
1855
  }
1856
+ /**
1857
+ * Configures the color control mode for the device.
1858
+ *
1859
+ * @param {ColorControl.ColorMode} colorMode - The color mode to set.
1860
+ * @param {Endpoint} endpoint - The optional endpoint to configure. If not provided, the method will configure the current endpoint.
1861
+ */
1208
1862
  async configureColorControlMode(colorMode, endpoint) {
1209
1863
  if (!endpoint)
1210
1864
  endpoint = this;
@@ -1214,6 +1868,11 @@ export class MatterbridgeEndpoint extends Endpoint {
1214
1868
  }
1215
1869
  return this;
1216
1870
  }
1871
+ /**
1872
+ * Get a default window covering cluster server.
1873
+ *
1874
+ * @param positionPercent100ths - The position percentage in 100ths (0-10000). Defaults to 0. Matter uses 10000 = fully closed 0 = fully opened.
1875
+ */
1217
1876
  getDefaultWindowCoveringClusterServer(positionPercent100ths) {
1218
1877
  return ClusterServer(WindowCoveringCluster.with(WindowCovering.Feature.Lift, WindowCovering.Feature.PositionAwareLift), {
1219
1878
  type: WindowCovering.WindowCoveringType.Rollershade,
@@ -1229,22 +1888,35 @@ export class MatterbridgeEndpoint extends Endpoint {
1229
1888
  operationalStatus: { global: WindowCovering.MovementStatus.Stopped, lift: WindowCovering.MovementStatus.Stopped, tilt: WindowCovering.MovementStatus.Stopped },
1230
1889
  endProductType: WindowCovering.EndProductType.RollerShade,
1231
1890
  mode: { motorDirectionReversed: false, calibrationMode: false, maintenanceMode: false, ledFeedback: false },
1232
- targetPositionLiftPercent100ths: positionPercent100ths ?? 0,
1233
- currentPositionLiftPercent100ths: positionPercent100ths ?? 0,
1891
+ targetPositionLiftPercent100ths: positionPercent100ths ?? 0, // 0 Fully open 10000 fully closed
1892
+ currentPositionLiftPercent100ths: positionPercent100ths ?? 0, // 0 Fully open 10000 fully closed
1234
1893
  }, {
1235
1894
  upOrOpen: async (data) => {
1895
+ // Never called in edge
1236
1896
  },
1237
1897
  downOrClose: async (data) => {
1898
+ // Never called in edge
1238
1899
  },
1239
1900
  stopMotion: async (data) => {
1901
+ // Never called in edge
1240
1902
  },
1241
1903
  goToLiftPercentage: async (data) => {
1904
+ // Never called in edge
1242
1905
  },
1243
1906
  }, {});
1244
1907
  }
1908
+ /**
1909
+ * Creates a default window covering cluster server.
1910
+ *
1911
+ * @param positionPercent100ths - The position percentage in 100ths (0-10000). Defaults to 0. Matter uses 10000 = fully closed 0 = fully opened.
1912
+ */
1245
1913
  createDefaultWindowCoveringClusterServer(positionPercent100ths) {
1246
1914
  this.addClusterServer(this.getDefaultWindowCoveringClusterServer(positionPercent100ths));
1247
1915
  }
1916
+ /**
1917
+ * Sets the window covering target position as the current position and stops the movement.
1918
+ * @param {Endpoint} endpoint - The endpoint on which to set the window covering (default the device endpoint).
1919
+ */
1248
1920
  async setWindowCoveringTargetAsCurrentAndStopped(endpoint) {
1249
1921
  if (!endpoint)
1250
1922
  endpoint = this;
@@ -1259,6 +1931,13 @@ export class MatterbridgeEndpoint extends Endpoint {
1259
1931
  }
1260
1932
  this.log.debug(`Set WindowCovering currentPositionLiftPercent100ths and targetPositionLiftPercent100ths to ${position} and operationalStatus to Stopped.`);
1261
1933
  }
1934
+ /**
1935
+ * Sets the current and target status of a window covering.
1936
+ * @param {number} current - The current position of the window covering.
1937
+ * @param {number} target - The target position of the window covering.
1938
+ * @param {WindowCovering.MovementStatus} status - The movement status of the window covering.
1939
+ * @param {Endpoint} endpoint - The endpoint on which to set the window covering (default the device endpoint).
1940
+ */
1262
1941
  async setWindowCoveringCurrentTargetStatus(current, target, status, endpoint) {
1263
1942
  if (!endpoint)
1264
1943
  endpoint = this;
@@ -1271,6 +1950,11 @@ export class MatterbridgeEndpoint extends Endpoint {
1271
1950
  }, this.log, endpoint);
1272
1951
  this.log.debug(`Set WindowCovering currentPositionLiftPercent100ths: ${current}, targetPositionLiftPercent100ths: ${target} and operationalStatus: ${status}.`);
1273
1952
  }
1953
+ /**
1954
+ * Sets the status of the window covering.
1955
+ * @param {WindowCovering.MovementStatus} status - The movement status to set.
1956
+ * @param {Endpoint} endpoint - The endpoint on which to set the window covering (default the device endpoint).
1957
+ */
1274
1958
  async setWindowCoveringStatus(status, endpoint) {
1275
1959
  if (!endpoint)
1276
1960
  endpoint = this;
@@ -1281,6 +1965,12 @@ export class MatterbridgeEndpoint extends Endpoint {
1281
1965
  }, this.log, endpoint);
1282
1966
  this.log.debug(`Set WindowCovering operationalStatus: ${status}`);
1283
1967
  }
1968
+ /**
1969
+ * Retrieves the status of the window covering.
1970
+ * @param {Endpoint} endpoint - The endpoint on which to get the window covering (default the device endpoint).
1971
+ *
1972
+ * @returns The global operational status of the window covering.
1973
+ */
1284
1974
  getWindowCoveringStatus(endpoint) {
1285
1975
  if (!endpoint)
1286
1976
  endpoint = this;
@@ -1288,6 +1978,12 @@ export class MatterbridgeEndpoint extends Endpoint {
1288
1978
  this.log.debug(`Get WindowCovering operationalStatus: ${status.global}`);
1289
1979
  return status.global;
1290
1980
  }
1981
+ /**
1982
+ * Sets the target and current position of the window covering.
1983
+ *
1984
+ * @param position - The position to set, specified as a number.
1985
+ * @param {Endpoint} endpoint - The endpoint on which to set the window covering (default the device endpoint).
1986
+ */
1291
1987
  async setWindowCoveringTargetAndCurrentPosition(position, endpoint) {
1292
1988
  if (!endpoint)
1293
1989
  endpoint = this;
@@ -1295,6 +1991,13 @@ export class MatterbridgeEndpoint extends Endpoint {
1295
1991
  await endpoint.setAttribute(WindowCoveringCluster.id, 'targetPositionLiftPercent100ths', position, this.log, endpoint);
1296
1992
  this.log.debug(`Set WindowCovering currentPositionLiftPercent100ths: ${position} and targetPositionLiftPercent100ths: ${position}.`);
1297
1993
  }
1994
+ /**
1995
+ * Get a default door lock cluster server.
1996
+ *
1997
+ * @remarks
1998
+ * This method adds a cluster server for a door lock cluster with default settings.
1999
+ *
2000
+ */
1298
2001
  getDefaultDoorLockClusterServer(lockState = DoorLock.LockState.Locked, lockType = DoorLock.LockType.DeadBolt) {
1299
2002
  return ClusterServer(DoorLockCluster, {
1300
2003
  operatingMode: DoorLock.OperatingMode.Normal,
@@ -1304,8 +2007,10 @@ export class MatterbridgeEndpoint extends Endpoint {
1304
2007
  supportedOperatingModes: { normal: true, vacation: false, privacy: false, noRemoteLockUnlock: false, passage: false },
1305
2008
  }, {
1306
2009
  lockDoor: async (data) => {
2010
+ // Never called in edge
1307
2011
  },
1308
2012
  unlockDoor: async (data) => {
2013
+ // Never called in edge
1309
2014
  },
1310
2015
  }, {
1311
2016
  doorLockAlarm: true,
@@ -1313,9 +2018,22 @@ export class MatterbridgeEndpoint extends Endpoint {
1313
2018
  lockOperationError: true,
1314
2019
  });
1315
2020
  }
2021
+ /**
2022
+ * Creates a default door lock cluster server.
2023
+ *
2024
+ * @remarks
2025
+ * This method adds a cluster server for a door lock cluster with default settings.
2026
+ *
2027
+ */
1316
2028
  createDefaultDoorLockClusterServer(lockState = DoorLock.LockState.Locked, lockType = DoorLock.LockType.DeadBolt) {
1317
2029
  this.addClusterServer(this.getDefaultDoorLockClusterServer(lockState, lockType));
1318
2030
  }
2031
+ /**
2032
+ * Get a default momentary switch cluster server.
2033
+ *
2034
+ * @remarks
2035
+ * This method adds a cluster server with default momentary switch features and configurations suitable for (AppleHome) Single Double Long automations.
2036
+ */
1319
2037
  getDefaultSwitchClusterServer() {
1320
2038
  return ClusterServer(SwitchCluster.with(Switch.Feature.MomentarySwitch, Switch.Feature.MomentarySwitchRelease, Switch.Feature.MomentarySwitchLongPress, Switch.Feature.MomentarySwitchMultiPress), {
1321
2039
  numberOfPositions: 2,
@@ -1330,9 +2048,21 @@ export class MatterbridgeEndpoint extends Endpoint {
1330
2048
  multiPressComplete: true,
1331
2049
  });
1332
2050
  }
2051
+ /**
2052
+ * Creates a default momentary switch cluster server.
2053
+ *
2054
+ * @remarks
2055
+ * This method adds a cluster server with default momentary switch features and configurations.
2056
+ */
1333
2057
  createDefaultSwitchClusterServer() {
1334
2058
  this.addClusterServer(this.getDefaultSwitchClusterServer());
1335
2059
  }
2060
+ /**
2061
+ * Get a default latching switch cluster server.
2062
+ *
2063
+ * @remarks
2064
+ * This method adds a cluster server with default latching switch features and configuration.
2065
+ */
1336
2066
  getDefaultLatchingSwitchClusterServer() {
1337
2067
  return ClusterServer(SwitchCluster.with(Switch.Feature.LatchingSwitch), {
1338
2068
  numberOfPositions: 2,
@@ -1341,9 +2071,22 @@ export class MatterbridgeEndpoint extends Endpoint {
1341
2071
  switchLatched: true,
1342
2072
  });
1343
2073
  }
2074
+ /**
2075
+ * Creates a default latching switch cluster server.
2076
+ *
2077
+ * @remarks
2078
+ * This method adds a cluster server with default latching switch features and configuration.
2079
+ */
1344
2080
  createDefaultLatchingSwitchClusterServer() {
1345
2081
  this.addClusterServer(this.getDefaultLatchingSwitchClusterServer());
1346
2082
  }
2083
+ /**
2084
+ * Triggers a switch event on the specified endpoint.
2085
+ *
2086
+ * @param {string} event - The type of event to trigger. Possible values are 'Single', 'Double', 'Long' for momentarySwitch and 'Press', 'Release' for latchingSwitch.
2087
+ * @param {Endpoint} endpoint - The endpoint on which to trigger the event (default the device endpoint).
2088
+ * @returns {void}
2089
+ */
1347
2090
  async triggerSwitchEvent(event, log, endpoint) {
1348
2091
  if (!endpoint)
1349
2092
  endpoint = this;
@@ -1411,6 +2154,15 @@ export class MatterbridgeEndpoint extends Endpoint {
1411
2154
  }
1412
2155
  return true;
1413
2156
  }
2157
+ /**
2158
+ * Retrieves the default mode select cluster server.
2159
+ *
2160
+ * @param description - The description of the cluster server.
2161
+ * @param supportedModes - The supported modes for the cluster server.
2162
+ * @param currentMode - The current mode of the cluster server. Defaults to 0.
2163
+ * @param startUpMode - The startup mode of the cluster server. Defaults to 0.
2164
+ * @returns The default mode select cluster server.
2165
+ */
1414
2166
  getDefaultModeSelectClusterServer(description, supportedModes, currentMode = 0, startUpMode = 0) {
1415
2167
  return ClusterServer(ModeSelectCluster, {
1416
2168
  description: description,
@@ -1420,14 +2172,30 @@ export class MatterbridgeEndpoint extends Endpoint {
1420
2172
  startUpMode: startUpMode,
1421
2173
  }, {
1422
2174
  changeToMode: async (data) => {
2175
+ // Never called in edge
1423
2176
  },
1424
2177
  });
1425
2178
  }
2179
+ /**
2180
+ * Creates a default mode select cluster server.
2181
+ *
2182
+ * @param description - The description of the cluster server.
2183
+ * @param supportedModes - The supported modes for the cluster server.
2184
+ * @param currentMode - The current mode of the cluster server. Defaults to 0.
2185
+ * @param startUpMode - The startup mode of the cluster server. Defaults to 0.
2186
+ * @param endpoint - The endpoint to add the cluster server to. Defaults to `this` if not provided.
2187
+ *
2188
+ */
1426
2189
  createDefaultModeSelectClusterServer(description, supportedModes, currentMode = 0, startUpMode = 0, endpoint) {
1427
2190
  if (!endpoint)
1428
2191
  endpoint = this;
1429
2192
  endpoint.addClusterServer(this.getDefaultModeSelectClusterServer(description, supportedModes, currentMode, startUpMode));
1430
2193
  }
2194
+ /**
2195
+ * Get a default occupancy sensing cluster server.
2196
+ *
2197
+ * @param occupied - A boolean indicating whether the occupancy is occupied or not. Default is false.
2198
+ */
1431
2199
  getDefaultOccupancySensingClusterServer(occupied = false) {
1432
2200
  return ClusterServer(OccupancySensingCluster, {
1433
2201
  occupancy: { occupied },
@@ -1436,9 +2204,19 @@ export class MatterbridgeEndpoint extends Endpoint {
1436
2204
  pirOccupiedToUnoccupiedDelay: 30,
1437
2205
  }, {});
1438
2206
  }
2207
+ /**
2208
+ * Creates a default occupancy sensing cluster server.
2209
+ *
2210
+ * @param occupied - A boolean indicating whether the occupancy is occupied or not. Default is false.
2211
+ */
1439
2212
  createDefaultOccupancySensingClusterServer(occupied = false) {
1440
2213
  this.addClusterServer(this.getDefaultOccupancySensingClusterServer(occupied));
1441
2214
  }
2215
+ /**
2216
+ * Get a default Illuminance Measurement Cluster Server.
2217
+ *
2218
+ * @param measuredValue - The measured value of illuminance.
2219
+ */
1442
2220
  getDefaultIlluminanceMeasurementClusterServer(measuredValue = 0) {
1443
2221
  return ClusterServer(IlluminanceMeasurementCluster, {
1444
2222
  measuredValue,
@@ -1447,9 +2225,19 @@ export class MatterbridgeEndpoint extends Endpoint {
1447
2225
  tolerance: 0,
1448
2226
  }, {}, {});
1449
2227
  }
2228
+ /**
2229
+ * Creates a default Illuminance Measurement Cluster Server.
2230
+ *
2231
+ * @param measuredValue - The measured value of illuminance.
2232
+ */
1450
2233
  createDefaultIlluminanceMeasurementClusterServer(measuredValue = 0) {
1451
2234
  this.addClusterServer(this.getDefaultIlluminanceMeasurementClusterServer(measuredValue));
1452
2235
  }
2236
+ /**
2237
+ * Get a default flow measurement cluster server.
2238
+ *
2239
+ * @param measuredValue - The measured value of the flow in 10 x m/h.
2240
+ */
1453
2241
  getDefaultFlowMeasurementClusterServer(measuredValue = 0) {
1454
2242
  return ClusterServer(FlowMeasurementCluster, {
1455
2243
  measuredValue,
@@ -1458,9 +2246,19 @@ export class MatterbridgeEndpoint extends Endpoint {
1458
2246
  tolerance: 0,
1459
2247
  }, {}, {});
1460
2248
  }
2249
+ /**
2250
+ * Creates a default flow measurement cluster server.
2251
+ *
2252
+ * @param measuredValue - The measured value of the flow in 10 x m/h.
2253
+ */
1461
2254
  createDefaultFlowMeasurementClusterServer(measuredValue = 0) {
1462
2255
  this.addClusterServer(this.getDefaultFlowMeasurementClusterServer(measuredValue));
1463
2256
  }
2257
+ /**
2258
+ * Get a default temperature measurement cluster server.
2259
+ *
2260
+ * @param measuredValue - The measured value of the temperature x 100.
2261
+ */
1464
2262
  getDefaultTemperatureMeasurementClusterServer(measuredValue = 0) {
1465
2263
  return ClusterServer(TemperatureMeasurementCluster, {
1466
2264
  measuredValue,
@@ -1469,9 +2267,19 @@ export class MatterbridgeEndpoint extends Endpoint {
1469
2267
  tolerance: 0,
1470
2268
  }, {}, {});
1471
2269
  }
2270
+ /**
2271
+ * Creates a default temperature measurement cluster server.
2272
+ *
2273
+ * @param measuredValue - The measured value of the temperature x 100.
2274
+ */
1472
2275
  createDefaultTemperatureMeasurementClusterServer(measuredValue = 0) {
1473
2276
  this.addClusterServer(this.getDefaultTemperatureMeasurementClusterServer(measuredValue));
1474
2277
  }
2278
+ /**
2279
+ * Get a default RelativeHumidityMeasurementCluster server.
2280
+ *
2281
+ * @param measuredValue - The measured value of the relative humidity x 100.
2282
+ */
1475
2283
  getDefaultRelativeHumidityMeasurementClusterServer(measuredValue = 0) {
1476
2284
  return ClusterServer(RelativeHumidityMeasurementCluster, {
1477
2285
  measuredValue,
@@ -1480,9 +2288,19 @@ export class MatterbridgeEndpoint extends Endpoint {
1480
2288
  tolerance: 0,
1481
2289
  }, {}, {});
1482
2290
  }
2291
+ /**
2292
+ * Creates a default RelativeHumidityMeasurementCluster server.
2293
+ *
2294
+ * @param measuredValue - The measured value of the relative humidity x 100.
2295
+ */
1483
2296
  createDefaultRelativeHumidityMeasurementClusterServer(measuredValue = 0) {
1484
2297
  this.addClusterServer(this.getDefaultRelativeHumidityMeasurementClusterServer(measuredValue));
1485
2298
  }
2299
+ /**
2300
+ * Get a default Pressure Measurement Cluster Server.
2301
+ *
2302
+ * @param measuredValue - The measured value for the pressure.
2303
+ */
1486
2304
  getDefaultPressureMeasurementClusterServer(measuredValue = 1000) {
1487
2305
  return ClusterServer(PressureMeasurementCluster, {
1488
2306
  measuredValue,
@@ -1491,19 +2309,39 @@ export class MatterbridgeEndpoint extends Endpoint {
1491
2309
  tolerance: 0,
1492
2310
  }, {}, {});
1493
2311
  }
2312
+ /**
2313
+ * Creates a default Pressure Measurement Cluster Server.
2314
+ *
2315
+ * @param measuredValue - The measured value for the pressure.
2316
+ */
1494
2317
  createDefaultPressureMeasurementClusterServer(measuredValue = 1000) {
1495
2318
  this.addClusterServer(this.getDefaultPressureMeasurementClusterServer(measuredValue));
1496
2319
  }
2320
+ /**
2321
+ * Get a default boolean state cluster server.
2322
+ *
2323
+ * @param contact - Optional boolean value indicating the contact state. Defaults to `true` if not provided.
2324
+ */
1497
2325
  getDefaultBooleanStateClusterServer(contact) {
1498
2326
  return ClusterServer(BooleanStateCluster, {
1499
- stateValue: contact ?? true,
2327
+ stateValue: contact ?? true, // true=contact false=no_contact
1500
2328
  }, {}, {
1501
2329
  stateChange: true,
1502
2330
  });
1503
2331
  }
2332
+ /**
2333
+ * Creates a default boolean state configuration cluster server.
2334
+ *
2335
+ * @param contact - Optional boolean value indicating the contact state. Defaults to `true` if not provided.
2336
+ */
1504
2337
  createDefaultBooleanStateClusterServer(contact) {
1505
2338
  this.addClusterServer(this.getDefaultBooleanStateClusterServer(contact));
1506
2339
  }
2340
+ /**
2341
+ * Get a default boolean state configuration cluster server.
2342
+ *
2343
+ * @param contact - Optional boolean value indicating the sensor fault state. Defaults to `false` if not provided.
2344
+ */
1507
2345
  getDefaultBooleanStateConfigurationClusterServer(sensorFault = false) {
1508
2346
  return ClusterServer(BooleanStateConfigurationCluster.with(BooleanStateConfiguration.Feature.Visual, BooleanStateConfiguration.Feature.Audible, BooleanStateConfiguration.Feature.SensitivityLevel), {
1509
2347
  currentSensitivityLevel: 0,
@@ -1512,18 +2350,34 @@ export class MatterbridgeEndpoint extends Endpoint {
1512
2350
  alarmsActive: { visual: false, audible: false },
1513
2351
  alarmsEnabled: { visual: false, audible: false },
1514
2352
  alarmsSupported: { visual: true, audible: true },
2353
+ // alarmsSuppressed: { visual: false, audible: false },
1515
2354
  sensorFault: { generalFault: sensorFault },
1516
2355
  }, {
1517
2356
  enableDisableAlarm: async (data) => {
2357
+ // Never called in edge
1518
2358
  },
1519
2359
  }, {
1520
2360
  alarmsStateChanged: true,
1521
2361
  sensorFault: true,
1522
2362
  });
1523
2363
  }
2364
+ /**
2365
+ * Creates a default boolean state configuration cluster server.
2366
+ *
2367
+ * @param contact - Optional boolean value indicating the sensor fault state. Defaults to `false` if not provided.
2368
+ */
1524
2369
  createDefaultBooleanStateConfigurationClusterServer(sensorFault = false) {
1525
2370
  this.addClusterServer(this.getDefaultBooleanStateConfigurationClusterServer(sensorFault));
1526
2371
  }
2372
+ /**
2373
+ * Get a default power source replaceable battery cluster server.
2374
+ *
2375
+ * @param batPercentRemaining - The remaining battery percentage (default: 100).
2376
+ * @param batChargeLevel - The battery charge level (default: PowerSource.BatChargeLevel.Ok).
2377
+ * @param batVoltage - The battery voltage (default: 1500).
2378
+ * @param batReplacementDescription - The battery replacement description (default: 'Battery type').
2379
+ * @param batQuantity - The battery quantity (default: 1).
2380
+ */
1527
2381
  getDefaultPowerSourceReplaceableBatteryClusterServer(batPercentRemaining = 100, batChargeLevel = PowerSource.BatChargeLevel.Ok, batVoltage = 1500, batReplacementDescription = 'Battery type', batQuantity = 1) {
1528
2382
  return ClusterServer(PowerSourceCluster.with(PowerSource.Feature.Battery, PowerSource.Feature.Replaceable), {
1529
2383
  status: PowerSource.PowerSourceStatus.Active,
@@ -1540,9 +2394,25 @@ export class MatterbridgeEndpoint extends Endpoint {
1540
2394
  endpointList: [],
1541
2395
  }, {}, {});
1542
2396
  }
2397
+ /**
2398
+ * Creates a default power source replaceable battery cluster server.
2399
+ *
2400
+ * @param batPercentRemaining - The remaining battery percentage (default: 100).
2401
+ * @param batChargeLevel - The battery charge level (default: PowerSource.BatChargeLevel.Ok).
2402
+ * @param batVoltage - The battery voltage (default: 1500).
2403
+ * @param batReplacementDescription - The battery replacement description (default: 'Battery type').
2404
+ * @param batQuantity - The battery quantity (default: 1).
2405
+ */
1543
2406
  createDefaultPowerSourceReplaceableBatteryClusterServer(batPercentRemaining = 100, batChargeLevel = PowerSource.BatChargeLevel.Ok, batVoltage = 1500, batReplacementDescription = 'Battery type', batQuantity = 1) {
1544
2407
  this.addClusterServer(this.getDefaultPowerSourceReplaceableBatteryClusterServer(batPercentRemaining, batChargeLevel, batVoltage, batReplacementDescription, batQuantity));
1545
2408
  }
2409
+ /**
2410
+ * Get a default power source rechargeable battery cluster server.
2411
+ *
2412
+ * @param batPercentRemaining - The remaining battery percentage (default: 100).
2413
+ * @param batChargeLevel - The battery charge level (default: PowerSource.BatChargeLevel.Ok).
2414
+ * @param batVoltage - The battery voltage (default: 1500).
2415
+ */
1546
2416
  getDefaultPowerSourceRechargeableBatteryClusterServer(batPercentRemaining = 100, batChargeLevel = PowerSource.BatChargeLevel.Ok, batVoltage = 1500) {
1547
2417
  return ClusterServer(PowerSourceCluster.with(PowerSource.Feature.Battery, PowerSource.Feature.Rechargeable), {
1548
2418
  status: PowerSource.PowerSourceStatus.Active,
@@ -1560,9 +2430,21 @@ export class MatterbridgeEndpoint extends Endpoint {
1560
2430
  endpointList: [],
1561
2431
  }, {}, {});
1562
2432
  }
2433
+ /**
2434
+ * Creates a default power source rechargeable battery cluster server.
2435
+ *
2436
+ * @param batPercentRemaining - The remaining battery percentage (default: 100).
2437
+ * @param batChargeLevel - The battery charge level (default: PowerSource.BatChargeLevel.Ok).
2438
+ * @param batVoltage - The battery voltage (default: 1500).
2439
+ */
1563
2440
  createDefaultPowerSourceRechargeableBatteryClusterServer(batPercentRemaining = 100, batChargeLevel = PowerSource.BatChargeLevel.Ok, batVoltage = 1500) {
1564
2441
  this.addClusterServer(this.getDefaultPowerSourceRechargeableBatteryClusterServer(batPercentRemaining, batChargeLevel, batVoltage));
1565
2442
  }
2443
+ /**
2444
+ * Get a default power source wired cluster server.
2445
+ *
2446
+ * @param wiredCurrentType - The type of wired current (default: PowerSource.WiredCurrentType.Ac)
2447
+ */
1566
2448
  getDefaultPowerSourceWiredClusterServer(wiredCurrentType = PowerSource.WiredCurrentType.Ac) {
1567
2449
  return ClusterServer(PowerSourceCluster.with(PowerSource.Feature.Wired), {
1568
2450
  wiredCurrentType,
@@ -1572,17 +2454,37 @@ export class MatterbridgeEndpoint extends Endpoint {
1572
2454
  endpointList: [],
1573
2455
  }, {}, {});
1574
2456
  }
2457
+ /**
2458
+ * Creates a default power source wired cluster server.
2459
+ *
2460
+ * @param wiredCurrentType - The type of wired current (default: PowerSource.WiredCurrentType.Ac)
2461
+ */
1575
2462
  createDefaultPowerSourceWiredClusterServer(wiredCurrentType = PowerSource.WiredCurrentType.Ac) {
1576
2463
  this.addClusterServer(this.getDefaultPowerSourceWiredClusterServer(wiredCurrentType));
1577
2464
  }
2465
+ /**
2466
+ * Get a default air quality cluster server.
2467
+ *
2468
+ * @param airQuality The air quality type. Defaults to `AirQuality.AirQualityType.Unknown`.
2469
+ */
1578
2470
  getDefaultAirQualityClusterServer(airQuality = AirQuality.AirQualityEnum.Unknown) {
1579
2471
  return ClusterServer(AirQualityCluster.with(AirQuality.Feature.Fair, AirQuality.Feature.Moderate, AirQuality.Feature.VeryPoor, AirQuality.Feature.ExtremelyPoor), {
1580
2472
  airQuality,
1581
2473
  }, {}, {});
1582
2474
  }
2475
+ /**
2476
+ * Creates a default air quality cluster server.
2477
+ *
2478
+ * @param airQuality The air quality type. Defaults to `AirQuality.AirQualityType.Unknown`.
2479
+ */
1583
2480
  createDefaultAirQualityClusterServer(airQuality = AirQuality.AirQualityEnum.Unknown) {
1584
2481
  this.addClusterServer(this.getDefaultAirQualityClusterServer(airQuality));
1585
2482
  }
2483
+ /**
2484
+ * Get a default TVOC measurement cluster server.
2485
+ *
2486
+ * @param measuredValue - The measured value for TVOC.
2487
+ */
1586
2488
  getDefaultTvocMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1587
2489
  return ClusterServer(TotalVolatileOrganicCompoundsConcentrationMeasurementCluster.with('NumericMeasurement'), {
1588
2490
  measuredValue,
@@ -1593,14 +2495,28 @@ export class MatterbridgeEndpoint extends Endpoint {
1593
2495
  measurementMedium,
1594
2496
  }, {}, {});
1595
2497
  }
2498
+ /**
2499
+ * Creates a default TVOC measurement cluster server.
2500
+ *
2501
+ * @param measuredValue - The measured value for TVOC.
2502
+ */
1596
2503
  createDefaultTvocMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1597
2504
  this.addClusterServer(this.getDefaultTvocMeasurementClusterServer(measuredValue, measurementUnit, measurementMedium));
1598
2505
  }
2506
+ /**
2507
+ * Get a default heating thermostat cluster server with the specified parameters.
2508
+ * @param {number} [localTemperature] - The local temperature value in degrees Celsius. Defaults to 23°.
2509
+ * @param {number} [occupiedHeatingSetpoint] - The occupied heating setpoint value in degrees Celsius. Defaults to 21°.
2510
+ * @param {number} [minHeatSetpointLimit] - The minimum heat setpoint limit value. Defaults to 0°.
2511
+ * @param {number} [maxHeatSetpointLimit] - The maximum heat setpoint limit value. Defaults to 50°.
2512
+ * @returns {ThermostatClusterServer} A default thermostat cluster server configured with the specified parameters.
2513
+ */
1599
2514
  getDefaultHeatingThermostatClusterServer(localTemperature = 23, occupiedHeatingSetpoint = 21, minHeatSetpointLimit = 0, maxHeatSetpointLimit = 50) {
1600
2515
  return ClusterServer(ThermostatCluster.with(Thermostat.Feature.Heating), {
1601
2516
  localTemperature: localTemperature * 100,
1602
2517
  systemMode: Thermostat.SystemMode.Heat,
1603
2518
  controlSequenceOfOperation: Thermostat.ControlSequenceOfOperation.HeatingOnly,
2519
+ // Thermostat.Feature.Heating
1604
2520
  occupiedHeatingSetpoint: occupiedHeatingSetpoint * 100,
1605
2521
  minHeatSetpointLimit: minHeatSetpointLimit * 100,
1606
2522
  maxHeatSetpointLimit: maxHeatSetpointLimit * 100,
@@ -1608,17 +2524,35 @@ export class MatterbridgeEndpoint extends Endpoint {
1608
2524
  absMaxHeatSetpointLimit: maxHeatSetpointLimit * 100,
1609
2525
  }, {
1610
2526
  setpointRaiseLower: async (data) => {
2527
+ // Never called in edge
1611
2528
  },
1612
2529
  }, {});
1613
2530
  }
2531
+ /**
2532
+ * Creates and adds a default heating thermostat cluster server to the device.
2533
+ *
2534
+ * @param {number} [localTemperature] - The local temperature value in degrees Celsius. Defaults to 23°.
2535
+ * @param {number} [occupiedHeatingSetpoint] - The occupied heating setpoint value in degrees Celsius. Defaults to 21°.
2536
+ * @param {number} [minHeatSetpointLimit] - The minimum heat setpoint limit value. Defaults to 0°.
2537
+ * @param {number} [maxHeatSetpointLimit] - The maximum heat setpoint limit value. Defaults to 50°.
2538
+ */
1614
2539
  createDefaultHeatingThermostatClusterServer(localTemperature = 23, occupiedHeatingSetpoint = 25, minHeatSetpointLimit = 0, maxHeatSetpointLimit = 50) {
1615
2540
  this.addClusterServer(this.getDefaultHeatingThermostatClusterServer(localTemperature, occupiedHeatingSetpoint, minHeatSetpointLimit, maxHeatSetpointLimit));
1616
2541
  }
2542
+ /**
2543
+ * Get a default cooling thermostat cluster server with the specified parameters.
2544
+ * @param {number} [localTemperature] - The local temperature value in degrees Celsius. Defaults to 23°.
2545
+ * @param {number} [occupiedCoolingSetpoint] - The occupied cooling setpoint value in degrees Celsius. Defaults to 25°.
2546
+ * @param {number} [minCoolSetpointLimit] - The minimum cool setpoint limit value. Defaults to 0°.
2547
+ * @param {number} [maxCoolSetpointLimit] - The maximum cool setpoint limit value. Defaults to 50°.
2548
+ * @returns {ThermostatClusterServer} A default thermostat cluster server configured with the specified parameters.
2549
+ */
1617
2550
  getDefaultCoolingThermostatClusterServer(localTemperature = 23, occupiedCoolingSetpoint = 25, minCoolSetpointLimit = 0, maxCoolSetpointLimit = 50) {
1618
2551
  return ClusterServer(ThermostatCluster.with(Thermostat.Feature.Cooling), {
1619
2552
  localTemperature: localTemperature * 100,
1620
2553
  systemMode: Thermostat.SystemMode.Cool,
1621
2554
  controlSequenceOfOperation: Thermostat.ControlSequenceOfOperation.CoolingOnly,
2555
+ // Thermostat.Feature.Cooling
1622
2556
  occupiedCoolingSetpoint: occupiedCoolingSetpoint * 100,
1623
2557
  minCoolSetpointLimit: minCoolSetpointLimit * 100,
1624
2558
  maxCoolSetpointLimit: maxCoolSetpointLimit * 100,
@@ -1626,37 +2560,82 @@ export class MatterbridgeEndpoint extends Endpoint {
1626
2560
  absMaxCoolSetpointLimit: maxCoolSetpointLimit * 100,
1627
2561
  }, {
1628
2562
  setpointRaiseLower: async (data) => {
2563
+ // Never called in edge
1629
2564
  },
1630
2565
  }, {});
1631
2566
  }
2567
+ /**
2568
+ * Creates and adds a default cooling thermostat cluster server to the device.
2569
+ *
2570
+ * @param {number} [localTemperature] - The local temperature value in degrees Celsius. Defaults to 23°.
2571
+ * @param {number} [occupiedCoolingSetpoint] - The occupied cooling setpoint value in degrees Celsius. Defaults to 25°.
2572
+ * @param {number} [minCoolSetpointLimit] - The minimum cool setpoint limit value. Defaults to 0°.
2573
+ * @param {number} [maxCoolSetpointLimit] - The maximum cool setpoint limit value. Defaults to 50°.
2574
+ */
1632
2575
  createDefaultCoolingThermostatClusterServer(localTemperature = 23, occupiedCoolingSetpoint = 25, minCoolSetpointLimit = 0, maxCoolSetpointLimit = 50) {
1633
2576
  this.addClusterServer(this.getDefaultCoolingThermostatClusterServer(localTemperature, occupiedCoolingSetpoint, minCoolSetpointLimit, maxCoolSetpointLimit));
1634
2577
  }
2578
+ /**
2579
+ * Get a default thermostat cluster server with the specified parameters.
2580
+ *
2581
+ * @param {number} [localTemperature=23] - The local temperature value in degrees Celsius. Defaults to 23°.
2582
+ * @param {number} [occupiedHeatingSetpoint=21] - The occupied heating setpoint value in degrees Celsius. Defaults to 21°.
2583
+ * @param {number} [occupiedCoolingSetpoint=25] - The occupied cooling setpoint value in degrees Celsius. Defaults to 25°.
2584
+ * @param {number} [minSetpointDeadBand=1] - The minimum setpoint dead band value. Defaults to 1°.
2585
+ * @param {number} [minHeatSetpointLimit=0] - The minimum heat setpoint limit value. Defaults to 0°.
2586
+ * @param {number} [maxHeatSetpointLimit=50] - The maximum heat setpoint limit value. Defaults to 50°.
2587
+ * @param {number} [minCoolSetpointLimit=0] - The minimum cool setpoint limit value. Defaults to 0°.
2588
+ * @param {number} [maxCoolSetpointLimit=50] - The maximum cool setpoint limit value. Defaults to 50°.
2589
+ * @returns {ThermostatClusterServer} A default thermostat cluster server configured with the specified parameters.
2590
+ */
1635
2591
  getDefaultThermostatClusterServer(localTemperature = 23, occupiedHeatingSetpoint = 21, occupiedCoolingSetpoint = 25, minSetpointDeadBand = 1, minHeatSetpointLimit = 0, maxHeatSetpointLimit = 50, minCoolSetpointLimit = 0, maxCoolSetpointLimit = 50) {
1636
2592
  return ClusterServer(ThermostatCluster.with(Thermostat.Feature.Heating, Thermostat.Feature.Cooling, Thermostat.Feature.AutoMode), {
1637
2593
  localTemperature: localTemperature * 100,
1638
2594
  systemMode: Thermostat.SystemMode.Auto,
1639
2595
  controlSequenceOfOperation: Thermostat.ControlSequenceOfOperation.CoolingAndHeating,
2596
+ // Thermostat.Feature.Heating
1640
2597
  occupiedHeatingSetpoint: occupiedHeatingSetpoint * 100,
1641
2598
  minHeatSetpointLimit: minHeatSetpointLimit * 100,
1642
2599
  maxHeatSetpointLimit: maxHeatSetpointLimit * 100,
1643
2600
  absMinHeatSetpointLimit: minHeatSetpointLimit * 100,
1644
2601
  absMaxHeatSetpointLimit: maxHeatSetpointLimit * 100,
2602
+ // Thermostat.Feature.Cooling
1645
2603
  occupiedCoolingSetpoint: occupiedCoolingSetpoint * 100,
1646
2604
  minCoolSetpointLimit: minCoolSetpointLimit * 100,
1647
2605
  maxCoolSetpointLimit: maxCoolSetpointLimit * 100,
1648
2606
  absMinCoolSetpointLimit: minCoolSetpointLimit * 100,
1649
2607
  absMaxCoolSetpointLimit: maxCoolSetpointLimit * 100,
2608
+ // Thermostat.Feature.AutoMode
1650
2609
  minSetpointDeadBand: minSetpointDeadBand * 100,
1651
2610
  thermostatRunningMode: Thermostat.ThermostatRunningMode.Off,
1652
2611
  }, {
1653
2612
  setpointRaiseLower: async (data) => {
2613
+ // Never called in edge
1654
2614
  },
1655
2615
  }, {});
1656
2616
  }
2617
+ /**
2618
+ * Creates and adds a default thermostat cluster server to the device.
2619
+ *
2620
+ * @param {number} [localTemperature=23] - The local temperature value in degrees Celsius. Defaults to 23°.
2621
+ * @param {number} [occupiedHeatingSetpoint=21] - The occupied heating setpoint value in degrees Celsius. Defaults to 21°.
2622
+ * @param {number} [occupiedCoolingSetpoint=25] - The occupied cooling setpoint value in degrees Celsius. Defaults to 25°.
2623
+ * @param {number} [minSetpointDeadBand=1] - The minimum setpoint dead band value. Defaults to 1°.
2624
+ * @param {number} [minHeatSetpointLimit=0] - The minimum heat setpoint limit value. Defaults to 0°.
2625
+ * @param {number} [maxHeatSetpointLimit=50] - The maximum heat setpoint limit value. Defaults to 50°.
2626
+ * @param {number} [minCoolSetpointLimit=0] - The minimum cool setpoint limit value. Defaults to 0°.
2627
+ * @param {number} [maxCoolSetpointLimit=50] - The maximum cool setpoint limit value. Defaults to 50°.
2628
+ */
1657
2629
  createDefaultThermostatClusterServer(localTemperature = 23, occupiedHeatingSetpoint = 21, occupiedCoolingSetpoint = 25, minSetpointDeadBand = 1, minHeatSetpointLimit = 0, maxHeatSetpointLimit = 50, minCoolSetpointLimit = 0, maxCoolSetpointLimit = 50) {
1658
2630
  this.addClusterServer(this.getDefaultThermostatClusterServer(localTemperature, occupiedHeatingSetpoint, occupiedCoolingSetpoint, minSetpointDeadBand, minHeatSetpointLimit, maxHeatSetpointLimit, minCoolSetpointLimit, maxCoolSetpointLimit));
1659
2631
  }
2632
+ /**
2633
+ * Returns the default SmokeCOAlarm Cluster Server.
2634
+ *
2635
+ * @param smokeState - The state of the smoke alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
2636
+ * @param coState - The state of the CO alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
2637
+ * @returns The default SmokeCOAlarmClusterServer.
2638
+ */
1660
2639
  getDefaultSmokeCOAlarmClusterServer(smokeState = SmokeCoAlarm.AlarmState.Normal, coState = SmokeCoAlarm.AlarmState.Normal) {
1661
2640
  return ClusterServer(SmokeCoAlarmCluster.with(SmokeCoAlarm.Feature.SmokeAlarm, SmokeCoAlarm.Feature.CoAlarm), {
1662
2641
  smokeState,
@@ -1671,6 +2650,7 @@ export class MatterbridgeEndpoint extends Endpoint {
1671
2650
  interconnectCoAlarm: SmokeCoAlarm.AlarmState.Normal,
1672
2651
  }, {
1673
2652
  selfTestRequest: async (data) => {
2653
+ // Never called in edge
1674
2654
  },
1675
2655
  }, {
1676
2656
  smokeAlarm: true,
@@ -1686,9 +2666,24 @@ export class MatterbridgeEndpoint extends Endpoint {
1686
2666
  allClear: true,
1687
2667
  });
1688
2668
  }
2669
+ /**
2670
+ * Create the default SmokeCOAlarm Cluster Server.
2671
+ *
2672
+ * @param smokeState - The state of the smoke alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
2673
+ * @param coState - The state of the CO alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
2674
+ * @returns The default SmokeCOAlarmClusterServer.
2675
+ */
1689
2676
  createDefaultSmokeCOAlarmClusterServer(smokeState = SmokeCoAlarm.AlarmState.Normal, coState = SmokeCoAlarm.AlarmState.Normal) {
1690
2677
  this.addClusterServer(this.getDefaultSmokeCOAlarmClusterServer(smokeState, coState));
1691
2678
  }
2679
+ /**
2680
+ * Returns the default Carbon Monoxide Concentration Measurement Cluster Server.
2681
+ *
2682
+ * @param {number} measuredValue - The measured value of the concentration.
2683
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
2684
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
2685
+ * @returns {ClusterServer} - The default Carbon Monoxide Concentration Measurement Cluster Server.
2686
+ */
1692
2687
  getDefaultCarbonMonoxideConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1693
2688
  return ClusterServer(CarbonMonoxideConcentrationMeasurementCluster.with('NumericMeasurement'), {
1694
2689
  measuredValue,
@@ -1699,9 +2694,24 @@ export class MatterbridgeEndpoint extends Endpoint {
1699
2694
  measurementMedium,
1700
2695
  }, {}, {});
1701
2696
  }
2697
+ /**
2698
+ * Create the default Carbon Monoxide Concentration Measurement Cluster Server.
2699
+ *
2700
+ * @param {number} measuredValue - The measured value of the concentration.
2701
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
2702
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
2703
+ */
1702
2704
  createDefaultCarbonMonoxideConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1703
2705
  this.addClusterServer(this.getDefaultCarbonMonoxideConcentrationMeasurementClusterServer(measuredValue, measurementUnit, measurementMedium));
1704
2706
  }
2707
+ /**
2708
+ * Returns the default Carbon Dioxide Concentration Measurement Cluster Server.
2709
+ *
2710
+ * @param {number} measuredValue - The measured value of the concentration.
2711
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
2712
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
2713
+ * @returns {ClusterServer} - The default Carbon Monoxide Concentration Measurement Cluster Server.
2714
+ */
1705
2715
  getDefaultCarbonDioxideConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1706
2716
  return ClusterServer(CarbonDioxideConcentrationMeasurementCluster.with('NumericMeasurement'), {
1707
2717
  measuredValue,
@@ -1712,9 +2722,24 @@ export class MatterbridgeEndpoint extends Endpoint {
1712
2722
  measurementMedium,
1713
2723
  }, {}, {});
1714
2724
  }
2725
+ /**
2726
+ * Create the default Carbon Dioxide Concentration Measurement Cluster Server.
2727
+ *
2728
+ * @param {number} measuredValue - The measured value of the concentration.
2729
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
2730
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
2731
+ */
1715
2732
  createDefaultCarbonDioxideConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1716
2733
  this.addClusterServer(this.getDefaultCarbonDioxideConcentrationMeasurementClusterServer(measuredValue, measurementUnit, measurementMedium));
1717
2734
  }
2735
+ /**
2736
+ * Returns the default Formaldehyde Concentration Measurement Cluster Server.
2737
+ *
2738
+ * @param {number} measuredValue - The measured value of the concentration.
2739
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
2740
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
2741
+ * @returns {ClusterServer} - The default Carbon Monoxide Concentration Measurement Cluster Server.
2742
+ */
1718
2743
  getDefaultFormaldehydeConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1719
2744
  return ClusterServer(FormaldehydeConcentrationMeasurementCluster.with('NumericMeasurement'), {
1720
2745
  measuredValue,
@@ -1725,9 +2750,24 @@ export class MatterbridgeEndpoint extends Endpoint {
1725
2750
  measurementMedium,
1726
2751
  }, {}, {});
1727
2752
  }
2753
+ /**
2754
+ * Create the default Formaldehyde Concentration Measurement Cluster Server.
2755
+ *
2756
+ * @param {number} measuredValue - The measured value of the concentration.
2757
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
2758
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
2759
+ */
1728
2760
  createDefaultFormaldehydeConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1729
2761
  this.addClusterServer(this.getDefaultFormaldehydeConcentrationMeasurementClusterServer(measuredValue, measurementUnit, measurementMedium));
1730
2762
  }
2763
+ /**
2764
+ * Returns the default Pm1 Concentration Measurement Cluster Server.
2765
+ *
2766
+ * @param {number} measuredValue - The measured value of the concentration.
2767
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
2768
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
2769
+ * @returns {ClusterServer} - The default Carbon Monoxide Concentration Measurement Cluster Server.
2770
+ */
1731
2771
  getDefaultPm1ConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1732
2772
  return ClusterServer(Pm1ConcentrationMeasurementCluster.with('NumericMeasurement'), {
1733
2773
  measuredValue,
@@ -1738,9 +2778,24 @@ export class MatterbridgeEndpoint extends Endpoint {
1738
2778
  measurementMedium,
1739
2779
  }, {}, {});
1740
2780
  }
2781
+ /**
2782
+ * Create the default Pm1 Concentration Measurement Cluster Server.
2783
+ *
2784
+ * @param {number} measuredValue - The measured value of the concentration.
2785
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
2786
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
2787
+ */
1741
2788
  createDefaultPm1ConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1742
2789
  this.addClusterServer(this.getDefaultPm1ConcentrationMeasurementClusterServer(measuredValue, measurementUnit, measurementMedium));
1743
2790
  }
2791
+ /**
2792
+ * Returns the default Pm25 Concentration Measurement Cluster Server.
2793
+ *
2794
+ * @param {number} measuredValue - The measured value of the concentration.
2795
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
2796
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
2797
+ * @returns {ClusterServer} - The default Carbon Monoxide Concentration Measurement Cluster Server.
2798
+ */
1744
2799
  getDefaultPm25ConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1745
2800
  return ClusterServer(Pm25ConcentrationMeasurementCluster.with('NumericMeasurement'), {
1746
2801
  measuredValue,
@@ -1751,9 +2806,24 @@ export class MatterbridgeEndpoint extends Endpoint {
1751
2806
  measurementMedium,
1752
2807
  }, {}, {});
1753
2808
  }
2809
+ /**
2810
+ * Create the default Pm25 Concentration Measurement Cluster Server.
2811
+ *
2812
+ * @param {number} measuredValue - The measured value of the concentration.
2813
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
2814
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
2815
+ */
1754
2816
  createDefaultPm25ConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1755
2817
  this.addClusterServer(this.getDefaultPm25ConcentrationMeasurementClusterServer(measuredValue, measurementUnit, measurementMedium));
1756
2818
  }
2819
+ /**
2820
+ * Returns the default Pm10 Concentration Measurement Cluster Server.
2821
+ *
2822
+ * @param {number} measuredValue - The measured value of the concentration.
2823
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
2824
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
2825
+ * @returns {ClusterServer} - The default Carbon Monoxide Concentration Measurement Cluster Server.
2826
+ */
1757
2827
  getDefaultPm10ConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1758
2828
  return ClusterServer(Pm10ConcentrationMeasurementCluster.with('NumericMeasurement'), {
1759
2829
  measuredValue,
@@ -1764,9 +2834,24 @@ export class MatterbridgeEndpoint extends Endpoint {
1764
2834
  measurementMedium,
1765
2835
  }, {}, {});
1766
2836
  }
2837
+ /**
2838
+ * Create the default Pm10 Concentration Measurement Cluster Server.
2839
+ *
2840
+ * @param {number} measuredValue - The measured value of the concentration.
2841
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
2842
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
2843
+ */
1767
2844
  createDefaultPm10ConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1768
2845
  this.addClusterServer(this.getDefaultPm10ConcentrationMeasurementClusterServer(measuredValue, measurementUnit, measurementMedium));
1769
2846
  }
2847
+ /**
2848
+ * Returns the default Ozone Concentration Measurement Cluster Server.
2849
+ *
2850
+ * @param {number} measuredValue - The measured value of the concentration.
2851
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
2852
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
2853
+ * @returns {ClusterServer} - The default Carbon Monoxide Concentration Measurement Cluster Server.
2854
+ */
1770
2855
  getDefaultOzoneConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ugm3, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1771
2856
  return ClusterServer(OzoneConcentrationMeasurementCluster.with('NumericMeasurement'), {
1772
2857
  measuredValue,
@@ -1777,9 +2862,24 @@ export class MatterbridgeEndpoint extends Endpoint {
1777
2862
  measurementMedium,
1778
2863
  }, {}, {});
1779
2864
  }
2865
+ /**
2866
+ * Create the default Ozone Concentration Measurement Cluster Server.
2867
+ *
2868
+ * @param {number} measuredValue - The measured value of the concentration.
2869
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
2870
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
2871
+ */
1780
2872
  createDefaultOzoneConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ugm3, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1781
2873
  this.addClusterServer(this.getDefaultOzoneConcentrationMeasurementClusterServer(measuredValue, measurementUnit, measurementMedium));
1782
2874
  }
2875
+ /**
2876
+ * Returns the default Radon Concentration Measurement Cluster Server.
2877
+ *
2878
+ * @param {number} measuredValue - The measured value of the concentration.
2879
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
2880
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
2881
+ * @returns {ClusterServer} - The default Carbon Monoxide Concentration Measurement Cluster Server.
2882
+ */
1783
2883
  getDefaultRadonConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1784
2884
  return ClusterServer(RadonConcentrationMeasurementCluster.with('NumericMeasurement'), {
1785
2885
  measuredValue,
@@ -1790,9 +2890,24 @@ export class MatterbridgeEndpoint extends Endpoint {
1790
2890
  measurementMedium,
1791
2891
  }, {}, {});
1792
2892
  }
2893
+ /**
2894
+ * Create the default Radon Concentration Measurement Cluster Server.
2895
+ *
2896
+ * @param {number} measuredValue - The measured value of the concentration.
2897
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
2898
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
2899
+ */
1793
2900
  createDefaultRadonConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1794
2901
  this.addClusterServer(this.getDefaultRadonConcentrationMeasurementClusterServer(measuredValue, measurementUnit, measurementMedium));
1795
2902
  }
2903
+ /**
2904
+ * Returns the default Nitrogen Dioxide Concentration Measurement Cluster Server.
2905
+ *
2906
+ * @param {number} measuredValue - The measured value of the concentration.
2907
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
2908
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
2909
+ * @returns {ClusterServer} - The default Carbon Monoxide Concentration Measurement Cluster Server.
2910
+ */
1796
2911
  getDefaultNitrogenDioxideConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ugm3, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1797
2912
  return ClusterServer(NitrogenDioxideConcentrationMeasurementCluster.with('NumericMeasurement'), {
1798
2913
  measuredValue,
@@ -1803,9 +2918,22 @@ export class MatterbridgeEndpoint extends Endpoint {
1803
2918
  measurementMedium,
1804
2919
  }, {}, {});
1805
2920
  }
2921
+ /**
2922
+ * Create the default Nitrogen Dioxide Concentration Measurement Cluster Server.
2923
+ *
2924
+ * @param {number} measuredValue - The measured value of the concentration.
2925
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
2926
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
2927
+ */
1806
2928
  createDefaultNitrogenDioxideConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ugm3, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1807
2929
  this.addClusterServer(this.getDefaultNitrogenDioxideConcentrationMeasurementClusterServer(measuredValue, measurementUnit, measurementMedium));
1808
2930
  }
2931
+ /**
2932
+ * Returns the default fan control cluster server rev 2.
2933
+ *
2934
+ * @param fanMode The fan mode to set. Defaults to `FanControl.FanMode.Off`.
2935
+ * @returns The default fan control cluster server.
2936
+ */
1809
2937
  getDefaultFanControlClusterServer(fanMode = FanControl.FanMode.Off) {
1810
2938
  return ClusterServer(FanControlCluster.with(FanControl.Feature.MultiSpeed, FanControl.Feature.Auto, FanControl.Feature.Step), {
1811
2939
  fanMode,
@@ -1817,12 +2945,25 @@ export class MatterbridgeEndpoint extends Endpoint {
1817
2945
  speedCurrent: 0,
1818
2946
  }, {
1819
2947
  step: async (data) => {
2948
+ // Never called in edge
1820
2949
  },
1821
2950
  }, {});
1822
2951
  }
2952
+ /**
2953
+ * Create the default fan control cluster server rev 2.
2954
+ *
2955
+ * @param fanMode The fan mode to set. Defaults to `FanControl.FanMode.Off`.
2956
+ * @returns The default fan control cluster server.
2957
+ */
1823
2958
  createDefaultFanControlClusterServer(fanMode = FanControl.FanMode.Off) {
1824
2959
  this.addClusterServer(this.getDefaultFanControlClusterServer(fanMode));
1825
2960
  }
2961
+ /**
2962
+ * Returns the default Pump Configuration And Control cluster server.
2963
+ *
2964
+ * @param {PumpConfigurationAndControl.OperationMode} [pumpMode=PumpConfigurationAndControl.OperationMode.Normal] - The pump mode to set. Defaults to `PumpConfigurationAndControl.OperationMode.Normal`.
2965
+ * @returns {ClusterServer} - The default Pump Configuration And Control cluster server.
2966
+ */
1826
2967
  getDefaultPumpConfigurationAndControlClusterServer(pumpMode = PumpConfigurationAndControl.OperationMode.Normal) {
1827
2968
  return ClusterServer(PumpConfigurationAndControlCluster.with(PumpConfigurationAndControl.Feature.ConstantSpeed), {
1828
2969
  minConstSpeed: null,
@@ -1836,9 +2977,22 @@ export class MatterbridgeEndpoint extends Endpoint {
1836
2977
  operationMode: pumpMode,
1837
2978
  }, {}, {});
1838
2979
  }
2980
+ /**
2981
+ * Creates the default Pump Configuration And Control cluster server.
2982
+ *
2983
+ * @param {PumpConfigurationAndControl.OperationMode} [pumpMode=PumpConfigurationAndControl.OperationMode.Normal] - The pump mode to set. Defaults to `PumpConfigurationAndControl.OperationMode.Normal`.
2984
+ * @returns {void}
2985
+ */
1839
2986
  createDefaultPumpConfigurationAndControlClusterServer(pumpMode = PumpConfigurationAndControl.OperationMode.Normal) {
1840
2987
  this.addClusterServer(this.getDefaultPumpConfigurationAndControlClusterServer(pumpMode));
1841
2988
  }
2989
+ /**
2990
+ * Returns the default Valve Configuration And Control cluster server rev 2.
2991
+ *
2992
+ * @param {ValveConfigurationAndControl.ValveState} [valveState=ValveConfigurationAndControl.ValveState.Closed] - The valve state to set. Defaults to `ValveConfigurationAndControl.ValveState.Closed`.
2993
+ * @param {number} [valveLevel=0] - The valve level to set. Defaults to 0.
2994
+ * @returns {ClusterServer} - The default Valve Configuration And Control cluster server.
2995
+ */
1842
2996
  getDefaultValveConfigurationAndControlClusterServer(valveState = ValveConfigurationAndControl.ValveState.Closed, valveLevel = 0) {
1843
2997
  return ClusterServer(ValveConfigurationAndControlCluster.with(ValveConfigurationAndControl.Feature.Level), {
1844
2998
  currentState: valveState,
@@ -1850,12 +3004,22 @@ export class MatterbridgeEndpoint extends Endpoint {
1850
3004
  remainingDuration: null,
1851
3005
  }, {
1852
3006
  open: async (data) => {
3007
+ // Never called in edge
1853
3008
  },
1854
3009
  close: async (data) => {
3010
+ // Never called in edge
1855
3011
  },
1856
3012
  }, {});
1857
3013
  }
3014
+ /**
3015
+ * Create the default Valve Configuration And Control cluster server rev 2.
3016
+ *
3017
+ * @param {ValveConfigurationAndControl.ValveState} [valveState=ValveConfigurationAndControl.ValveState.Closed] - The valve state to set. Defaults to `ValveConfigurationAndControl.ValveState.Closed`.
3018
+ * @param {number} [valveLevel=0] - The valve level to set. Defaults to 0.
3019
+ * @returns {void}
3020
+ */
1858
3021
  createDefaultValveConfigurationAndControlClusterServer(valveState = ValveConfigurationAndControl.ValveState.Closed, valveLevel = 0) {
1859
3022
  this.addClusterServer(this.getDefaultValveConfigurationAndControlClusterServer(valveState, valveLevel));
1860
3023
  }
1861
3024
  }
3025
+ //# sourceMappingURL=matterbridgeEndpoint.js.map