matterbridge 2.1.4 → 2.1.5-dev.2

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