matterbridge 3.0.4 → 3.0.5-dev-20250526-422f029

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 (164) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cli.js +16 -43
  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 +16 -363
  7. package/dist/helpers.js +0 -51
  8. package/dist/index.js +1 -27
  9. package/dist/laundryWasher.js +122 -0
  10. package/dist/logger/export.js +0 -1
  11. package/dist/matter/behaviors.js +0 -2
  12. package/dist/matter/clusters.js +0 -2
  13. package/dist/matter/devices.js +0 -2
  14. package/dist/matter/endpoints.js +0 -2
  15. package/dist/matter/export.js +0 -2
  16. package/dist/matter/types.js +0 -2
  17. package/dist/matterbridge.js +47 -747
  18. package/dist/matterbridgeAccessoryPlatform.js +0 -34
  19. package/dist/matterbridgeBehaviors.js +4 -63
  20. package/dist/matterbridgeDeviceTypes.js +15 -563
  21. package/dist/matterbridgeDynamicPlatform.js +0 -34
  22. package/dist/matterbridgeEndpoint.js +23 -903
  23. package/dist/matterbridgeEndpointHelpers.js +11 -173
  24. package/dist/matterbridgePlatform.js +7 -225
  25. package/dist/matterbridgeTypes.js +0 -24
  26. package/dist/pluginManager.js +3 -264
  27. package/dist/roboticVacuumCleaner.js +3 -78
  28. package/dist/shelly.js +7 -155
  29. package/dist/storage/export.js +0 -1
  30. package/dist/update.js +0 -53
  31. package/dist/utils/colorUtils.js +2 -205
  32. package/dist/utils/commandLine.js +0 -53
  33. package/dist/utils/copyDirectory.js +1 -37
  34. package/dist/utils/createZip.js +2 -42
  35. package/dist/utils/deepCopy.js +0 -38
  36. package/dist/utils/deepEqual.js +1 -71
  37. package/dist/utils/export.js +0 -1
  38. package/dist/utils/hex.js +0 -57
  39. package/dist/utils/isvalid.js +0 -100
  40. package/dist/utils/network.js +5 -76
  41. package/dist/utils/wait.js +9 -58
  42. package/dist/waterHeater.js +0 -52
  43. package/npm-shrinkwrap.json +2 -2
  44. package/package.json +1 -2
  45. package/dist/cli.d.ts +0 -29
  46. package/dist/cli.d.ts.map +0 -1
  47. package/dist/cli.js.map +0 -1
  48. package/dist/cluster/export.d.ts +0 -2
  49. package/dist/cluster/export.d.ts.map +0 -1
  50. package/dist/cluster/export.js.map +0 -1
  51. package/dist/defaultConfigSchema.d.ts +0 -27
  52. package/dist/defaultConfigSchema.d.ts.map +0 -1
  53. package/dist/defaultConfigSchema.js.map +0 -1
  54. package/dist/deviceManager.d.ts +0 -114
  55. package/dist/deviceManager.d.ts.map +0 -1
  56. package/dist/deviceManager.js.map +0 -1
  57. package/dist/frontend.d.ts +0 -256
  58. package/dist/frontend.d.ts.map +0 -1
  59. package/dist/frontend.js.map +0 -1
  60. package/dist/helpers.d.ts +0 -47
  61. package/dist/helpers.d.ts.map +0 -1
  62. package/dist/helpers.js.map +0 -1
  63. package/dist/index.d.ts +0 -35
  64. package/dist/index.d.ts.map +0 -1
  65. package/dist/index.js.map +0 -1
  66. package/dist/logger/export.d.ts +0 -2
  67. package/dist/logger/export.d.ts.map +0 -1
  68. package/dist/logger/export.js.map +0 -1
  69. package/dist/matter/behaviors.d.ts +0 -2
  70. package/dist/matter/behaviors.d.ts.map +0 -1
  71. package/dist/matter/behaviors.js.map +0 -1
  72. package/dist/matter/clusters.d.ts +0 -2
  73. package/dist/matter/clusters.d.ts.map +0 -1
  74. package/dist/matter/clusters.js.map +0 -1
  75. package/dist/matter/devices.d.ts +0 -2
  76. package/dist/matter/devices.d.ts.map +0 -1
  77. package/dist/matter/devices.js.map +0 -1
  78. package/dist/matter/endpoints.d.ts +0 -2
  79. package/dist/matter/endpoints.d.ts.map +0 -1
  80. package/dist/matter/endpoints.js.map +0 -1
  81. package/dist/matter/export.d.ts +0 -5
  82. package/dist/matter/export.d.ts.map +0 -1
  83. package/dist/matter/export.js.map +0 -1
  84. package/dist/matter/types.d.ts +0 -3
  85. package/dist/matter/types.d.ts.map +0 -1
  86. package/dist/matter/types.js.map +0 -1
  87. package/dist/matterbridge.d.ts +0 -445
  88. package/dist/matterbridge.d.ts.map +0 -1
  89. package/dist/matterbridge.js.map +0 -1
  90. package/dist/matterbridgeAccessoryPlatform.d.ts +0 -40
  91. package/dist/matterbridgeAccessoryPlatform.d.ts.map +0 -1
  92. package/dist/matterbridgeAccessoryPlatform.js.map +0 -1
  93. package/dist/matterbridgeBehaviors.d.ts +0 -1398
  94. package/dist/matterbridgeBehaviors.d.ts.map +0 -1
  95. package/dist/matterbridgeBehaviors.js.map +0 -1
  96. package/dist/matterbridgeDeviceTypes.d.ts +0 -629
  97. package/dist/matterbridgeDeviceTypes.d.ts.map +0 -1
  98. package/dist/matterbridgeDeviceTypes.js.map +0 -1
  99. package/dist/matterbridgeDynamicPlatform.d.ts +0 -40
  100. package/dist/matterbridgeDynamicPlatform.d.ts.map +0 -1
  101. package/dist/matterbridgeDynamicPlatform.js.map +0 -1
  102. package/dist/matterbridgeEndpoint.d.ts +0 -1053
  103. package/dist/matterbridgeEndpoint.d.ts.map +0 -1
  104. package/dist/matterbridgeEndpoint.js.map +0 -1
  105. package/dist/matterbridgeEndpointHelpers.d.ts +0 -2749
  106. package/dist/matterbridgeEndpointHelpers.d.ts.map +0 -1
  107. package/dist/matterbridgeEndpointHelpers.js.map +0 -1
  108. package/dist/matterbridgePlatform.d.ts +0 -294
  109. package/dist/matterbridgePlatform.d.ts.map +0 -1
  110. package/dist/matterbridgePlatform.js.map +0 -1
  111. package/dist/matterbridgeTypes.d.ts +0 -196
  112. package/dist/matterbridgeTypes.d.ts.map +0 -1
  113. package/dist/matterbridgeTypes.js.map +0 -1
  114. package/dist/pluginManager.d.ts +0 -273
  115. package/dist/pluginManager.d.ts.map +0 -1
  116. package/dist/pluginManager.js.map +0 -1
  117. package/dist/roboticVacuumCleaner.d.ts +0 -82
  118. package/dist/roboticVacuumCleaner.d.ts.map +0 -1
  119. package/dist/roboticVacuumCleaner.js.map +0 -1
  120. package/dist/shelly.d.ts +0 -153
  121. package/dist/shelly.d.ts.map +0 -1
  122. package/dist/shelly.js.map +0 -1
  123. package/dist/storage/export.d.ts +0 -2
  124. package/dist/storage/export.d.ts.map +0 -1
  125. package/dist/storage/export.js.map +0 -1
  126. package/dist/update.d.ts +0 -58
  127. package/dist/update.d.ts.map +0 -1
  128. package/dist/update.js.map +0 -1
  129. package/dist/utils/colorUtils.d.ts +0 -61
  130. package/dist/utils/colorUtils.d.ts.map +0 -1
  131. package/dist/utils/colorUtils.js.map +0 -1
  132. package/dist/utils/commandLine.d.ts +0 -58
  133. package/dist/utils/commandLine.d.ts.map +0 -1
  134. package/dist/utils/commandLine.js.map +0 -1
  135. package/dist/utils/copyDirectory.d.ts +0 -32
  136. package/dist/utils/copyDirectory.d.ts.map +0 -1
  137. package/dist/utils/copyDirectory.js.map +0 -1
  138. package/dist/utils/createZip.d.ts +0 -38
  139. package/dist/utils/createZip.d.ts.map +0 -1
  140. package/dist/utils/createZip.js.map +0 -1
  141. package/dist/utils/deepCopy.d.ts +0 -31
  142. package/dist/utils/deepCopy.d.ts.map +0 -1
  143. package/dist/utils/deepCopy.js.map +0 -1
  144. package/dist/utils/deepEqual.d.ts +0 -53
  145. package/dist/utils/deepEqual.d.ts.map +0 -1
  146. package/dist/utils/deepEqual.js.map +0 -1
  147. package/dist/utils/export.d.ts +0 -11
  148. package/dist/utils/export.d.ts.map +0 -1
  149. package/dist/utils/export.js.map +0 -1
  150. package/dist/utils/hex.d.ts +0 -48
  151. package/dist/utils/hex.d.ts.map +0 -1
  152. package/dist/utils/hex.js.map +0 -1
  153. package/dist/utils/isvalid.d.ts +0 -102
  154. package/dist/utils/isvalid.d.ts.map +0 -1
  155. package/dist/utils/isvalid.js.map +0 -1
  156. package/dist/utils/network.d.ts +0 -69
  157. package/dist/utils/network.d.ts.map +0 -1
  158. package/dist/utils/network.js.map +0 -1
  159. package/dist/utils/wait.d.ts +0 -52
  160. package/dist/utils/wait.d.ts.map +0 -1
  161. package/dist/utils/wait.js.map +0 -1
  162. package/dist/waterHeater.d.ts +0 -75
  163. package/dist/waterHeater.d.ts.map +0 -1
  164. package/dist/waterHeater.js.map +0 -1
@@ -1,8 +1,5 @@
1
- // src\matterbridgeEndpointHelpers.ts
2
- // @matter
3
1
  import { Lifecycle } from '@matter/main';
4
2
  import { getClusterNameById } from '@matter/main/types';
5
- // @matter clusters
6
3
  import { PowerSource } from '@matter/main/clusters/power-source';
7
4
  import { UserLabel } from '@matter/main/clusters/user-label';
8
5
  import { FixedLabel } from '@matter/main/clusters/fixed-label';
@@ -45,7 +42,6 @@ import { Pm10ConcentrationMeasurement } from '@matter/main/clusters/pm10-concent
45
42
  import { RadonConcentrationMeasurement } from '@matter/main/clusters/radon-concentration-measurement';
46
43
  import { TotalVolatileOrganicCompoundsConcentrationMeasurement } from '@matter/main/clusters/total-volatile-organic-compounds-concentration-measurement';
47
44
  import { OperationalState } from '@matter/main/clusters/operational-state';
48
- // @matter behaviors
49
45
  import { PowerSourceServer } from '@matter/main/behaviors/power-source';
50
46
  import { UserLabelServer } from '@matter/main/behaviors/user-label';
51
47
  import { FixedLabelServer } from '@matter/main/behaviors/fixed-label';
@@ -75,10 +71,8 @@ import { Pm25ConcentrationMeasurementServer } from '@matter/main/behaviors/pm25-
75
71
  import { Pm10ConcentrationMeasurementServer } from '@matter/main/behaviors/pm10-concentration-measurement';
76
72
  import { RadonConcentrationMeasurementServer } from '@matter/main/behaviors/radon-concentration-measurement';
77
73
  import { TotalVolatileOrganicCompoundsConcentrationMeasurementServer } from '@matter/main/behaviors/total-volatile-organic-compounds-concentration-measurement';
78
- // Other modules
79
74
  import { createHash } from 'node:crypto';
80
75
  import { BLUE, CYAN, db, debugStringify, er, hk, or, YELLOW, zb } from 'node-ansi-logger';
81
- // Matterbridge
82
76
  import { deepCopy, deepEqual, isValidArray } from './utils/export.js';
83
77
  import { MatterbridgeIdentifyServer, MatterbridgeOnOffServer, MatterbridgeLevelControlServer, MatterbridgeColorControlServer, MatterbridgeLiftWindowCoveringServer, MatterbridgeThermostatServer, MatterbridgeFanControlServer, MatterbridgeDoorLockServer, MatterbridgeModeSelectServer, MatterbridgeValveConfigurationAndControlServer, MatterbridgeSmokeCoAlarmServer, MatterbridgeBooleanStateConfigurationServer, MatterbridgeOperationalStateServer, } from './matterbridgeBehaviors.js';
84
78
  export function capitalizeFirstLetter(name) {
@@ -93,19 +87,19 @@ export function lowercaseFirstLetter(name) {
93
87
  }
94
88
  export function checkNotLatinCharacters(deviceName) {
95
89
  const nonLatinRegexList = [
96
- /[\u0400-\u04FF\u0500-\u052F]/, // Cyrillic
97
- /[\u2E80-\u9FFF]/, // CJK (Chinese, Japanese, Korean)
98
- /[\uAC00-\uD7AF]/, // Korean Hangul
99
- /[\u0600-\u06FF\u0750-\u077F]/, // Arabic, Persian
100
- /[\u0590-\u05FF]/, // Hebrew
101
- /[\u0900-\u097F]/, // Devanagari (Hindi, Sanskrit)
102
- /[\u0E00-\u0E7F]/, // Thai
103
- /[\u1200-\u137F]/, // Ethiopic (Amharic, Tigrinya)
90
+ /[\u0400-\u04FF\u0500-\u052F]/,
91
+ /[\u2E80-\u9FFF]/,
92
+ /[\uAC00-\uD7AF]/,
93
+ /[\u0600-\u06FF\u0750-\u077F]/,
94
+ /[\u0590-\u05FF]/,
95
+ /[\u0900-\u097F]/,
96
+ /[\u0E00-\u0E7F]/,
97
+ /[\u1200-\u137F]/,
104
98
  ];
105
99
  return nonLatinRegexList.some((regex) => regex.test(deviceName));
106
100
  }
107
101
  export function generateUniqueId(deviceName) {
108
- return createHash('md5').update(deviceName).digest('hex'); // MD5 hash of the device name
102
+ return createHash('md5').update(deviceName).digest('hex');
109
103
  }
110
104
  export function createUniqueId(param1, param2, param3, param4) {
111
105
  const hash = createHash('md5');
@@ -113,7 +107,6 @@ export function createUniqueId(param1, param2, param3, param4) {
113
107
  return hash.digest('hex');
114
108
  }
115
109
  export function getBehaviourTypesFromClusterServerIds(clusterServerList) {
116
- // Map Server ClusterId to Behavior.Type
117
110
  const behaviorTypes = [];
118
111
  clusterServerList.forEach((clusterId) => {
119
112
  behaviorTypes.push(getBehaviourTypeFromClusterServerId(clusterId));
@@ -121,15 +114,12 @@ export function getBehaviourTypesFromClusterServerIds(clusterServerList) {
121
114
  return behaviorTypes;
122
115
  }
123
116
  export function getBehaviourTypesFromClusterClientIds(clusterClientList) {
124
- // Map Client ClusterId to Behavior.Type
125
117
  const behaviorTypes = [];
126
118
  clusterClientList.forEach((_clusterId) => {
127
- // behaviorTypes.push(getBehaviourTypeFromClusterClientId(clusterId));
128
119
  });
129
120
  return behaviorTypes;
130
121
  }
131
122
  export function getBehaviourTypeFromClusterServerId(clusterId) {
132
- // Map ClusterId to Server Behavior.Type
133
123
  if (clusterId === PowerSource.Cluster.id)
134
124
  return PowerSourceServer.with(PowerSource.Feature.Wired);
135
125
  if (clusterId === UserLabel.Cluster.id)
@@ -217,8 +207,6 @@ export function getBehaviourTypeFromClusterServerId(clusterId) {
217
207
  return MatterbridgeIdentifyServer;
218
208
  }
219
209
  export function getBehaviourTypeFromClusterClientId(_clusterId) {
220
- // Map ClusterId to Client Behavior.Type
221
- // return IdentifyClient;
222
210
  }
223
211
  export function getBehavior(endpoint, cluster) {
224
212
  let behavior;
@@ -236,11 +224,6 @@ export function getBehavior(endpoint, cluster) {
236
224
  }
237
225
  return behavior;
238
226
  }
239
- /**
240
- * Invokes a command on the specified behavior of the endpoint. Used ONLY in Jest tests.
241
- *
242
- * @deprecated Used ONLY in Jest tests.
243
- */
244
227
  export async function invokeBehaviorCommand(endpoint, cluster, command, params) {
245
228
  const behaviorId = getBehavior(endpoint, cluster)?.id;
246
229
  if (!behaviorId) {
@@ -248,7 +231,6 @@ export async function invokeBehaviorCommand(endpoint, cluster, command, params)
248
231
  return false;
249
232
  }
250
233
  await endpoint.act((agent) => {
251
- // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
252
234
  const behavior = agent[behaviorId];
253
235
  if (!(command in behavior) || typeof behavior[command] !== 'function') {
254
236
  endpoint.log?.error(`invokeBehaviorCommand error: command ${hk}${command}${er} not found on agent for endpoint ${or}${endpoint.maybeId}${er}:${or}${endpoint.maybeNumber}${er}`);
@@ -286,13 +268,6 @@ export function addOptionalClusterServers(endpoint) {
286
268
  });
287
269
  addClusterServers(endpoint, optionalServerList);
288
270
  }
289
- /**
290
- * Adds cluster servers to the specified endpoint based on the provided server list.
291
- *
292
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to add the cluster servers to.
293
- * @param {ClusterId[]} serverList - The list of cluster IDs to add.
294
- * @returns void
295
- */
296
271
  export function addClusterServers(endpoint, serverList) {
297
272
  if (serverList.includes(PowerSource.Cluster.id))
298
273
  endpoint.createDefaultPowerSourceWiredClusterServer();
@@ -368,16 +343,7 @@ export function addClusterServers(endpoint, serverList) {
368
343
  endpoint.createDefaultRadonConcentrationMeasurementClusterServer();
369
344
  if (serverList.includes(TotalVolatileOrganicCompoundsConcentrationMeasurement.Cluster.id))
370
345
  endpoint.createDefaultTvocMeasurementClusterServer();
371
- // if (serverList.includes(DeviceEnergyManagement.Cluster.id)) endpoint.createDefaultDeviceEnergyManagementClusterServer();
372
- // if (serverList.includes(DeviceEnergyManagementMode.Cluster.id)) endpoint.createDefaultDeviceEnergyManagementModeClusterServer();
373
346
  }
374
- /**
375
- * Adds a fixed label to the FixedLabel cluster. The FixedLabel cluster is created if it does not exist.
376
- *
377
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to add the cluster servers to.
378
- * @param {string} label - The label to add.
379
- * @param {string} value - The value of the label.
380
- */
381
347
  export async function addFixedLabel(endpoint, label, value) {
382
348
  if (!endpoint.hasClusterServer(FixedLabel.Cluster.id)) {
383
349
  endpoint.log.debug(`addFixedLabel: add cluster ${hk}FixedLabel${db}:${hk}fixedLabel${db} with label ${CYAN}${label}${db} value ${CYAN}${value}${db}`);
@@ -394,13 +360,6 @@ export async function addFixedLabel(endpoint, label, value) {
394
360
  await endpoint.setAttribute(FixedLabel.Cluster.id, 'labelList', labelList, endpoint.log);
395
361
  }
396
362
  }
397
- /**
398
- * Adds a user label to the UserLabel cluster. The UserLabel cluster is created if it does not exist.
399
- *
400
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to add the cluster servers to.
401
- * @param {string} label - The label to add.
402
- * @param {string} value - The value of the label.
403
- */
404
363
  export async function addUserLabel(endpoint, label, value) {
405
364
  if (!endpoint.hasClusterServer(UserLabel.Cluster.id)) {
406
365
  endpoint.log.debug(`addUserLabel: add cluster ${hk}UserLabel${db}:${hk}userLabel${db} with label ${CYAN}${label}${db} value ${CYAN}${value}${db}`);
@@ -425,18 +384,8 @@ export function getClusterId(endpoint, cluster) {
425
384
  }
426
385
  export function getAttributeId(endpoint, cluster, attribute) {
427
386
  const clusterBehavior = endpoint.behaviors.supported[lowercaseFirstLetter(cluster)];
428
- return clusterBehavior?.cluster.attributes[lowercaseFirstLetter(attribute)]?.id;
387
+ return clusterBehavior?.cluster?.attributes[lowercaseFirstLetter(attribute)]?.id;
429
388
  }
430
- /**
431
- * Retrieves the value of the provided attribute from the given cluster.
432
- *
433
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to retrieve the attribute from.
434
- * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to retrieve the attribute from.
435
- * @param {string} attribute - The name of the attribute to retrieve.
436
- * @param {AnsiLogger} [log] - (Optional) The logger to use for logging the retrieve. Errors are logged to the endpoint logger.
437
- * @returns {any} The value of the attribute, or undefined if the attribute is not found.
438
- */
439
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
440
389
  export function getAttribute(endpoint, cluster, attribute, log) {
441
390
  const clusterName = getBehavior(endpoint, cluster)?.id;
442
391
  if (!clusterName) {
@@ -459,16 +408,6 @@ export function getAttribute(endpoint, cluster, attribute, log) {
459
408
  log?.info(`${db}Get endpoint ${or}${endpoint.id}${db}:${or}${endpoint.number}${db} attribute ${hk}${capitalizeFirstLetter(clusterName)}${db}.${hk}${attribute}${db} value ${YELLOW}${value !== null && typeof value === 'object' ? debugStringify(value) : value}${db}`);
460
409
  return value;
461
410
  }
462
- /**
463
- * Sets the value of an attribute on a cluster server.
464
- *
465
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to set the attribute on.
466
- * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to set the attribute on.
467
- * @param {string} attribute - The name of the attribute.
468
- * @param {boolean | number | bigint | string | object | null} value - The value to set for the attribute.
469
- * @param {AnsiLogger} [log] - (Optional) The logger to use for logging the set. Errors are logged to the endpoint logger.
470
- * @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the attribute was successfully set.
471
- */
472
411
  export async function setAttribute(endpoint, cluster, attribute, value, log) {
473
412
  const clusterName = getBehavior(endpoint, cluster)?.id;
474
413
  if (!clusterName) {
@@ -494,16 +433,6 @@ export async function setAttribute(endpoint, cluster, attribute, value, log) {
494
433
  `to ${YELLOW}${value !== null && typeof value === 'object' ? debugStringify(value) : value}${db}`);
495
434
  return true;
496
435
  }
497
- /**
498
- * Sets the value of an attribute on a cluster server.
499
- *
500
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to update the attribute on.
501
- * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to update the attribute on.
502
- * @param {string} attribute - The name of the attribute.
503
- * @param {boolean | number | bigint | string | object | null} value - The value to set for the attribute.
504
- * @param {AnsiLogger} [log] - (Optional) The logger to use for logging the update. Errors are logged to the endpoint logger.
505
- * @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the attribute was successfully set.
506
- */
507
436
  export async function updateAttribute(endpoint, cluster, attribute, value, log) {
508
437
  const clusterName = getBehavior(endpoint, cluster)?.id;
509
438
  if (!clusterName) {
@@ -534,24 +463,7 @@ export async function updateAttribute(endpoint, cluster, attribute, value, log)
534
463
  `to ${YELLOW}${value !== null && typeof value === 'object' ? debugStringify(value) : value}${db}`);
535
464
  return true;
536
465
  }
537
- /**
538
- * Subscribes to the provided attribute on a cluster.
539
- *
540
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to subscribe the attribute to.
541
- * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to subscribe the attribute to.
542
- * @param {string} attribute - The name of the attribute to subscribe to.
543
- * @param {(newValue: any, oldValue: any, context: ActionContext) => void} listener - A callback function that will be called when the attribute value changes. When context.offline === true then the change is locally generated and not from the controller.
544
- * @param {AnsiLogger} [log] - Optional logger for logging errors and information.
545
- * @returns {boolean} - A boolean indicating whether the subscription was successful.
546
- *
547
- * @remarks The listener function (cannot be async) will receive three parameters:
548
- * - `newValue`: The new value of the attribute.
549
- * - `oldValue`: The old value of the attribute.
550
- * - `context`: The action context, which includes information about the action that triggered the change. When context.offline === true then the change is locally generated and not from the controller.
551
- */
552
- export async function subscribeAttribute(endpoint, cluster, attribute,
553
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
554
- listener, log) {
466
+ export async function subscribeAttribute(endpoint, cluster, attribute, listener, log) {
555
467
  const clusterName = getBehavior(endpoint, cluster)?.id;
556
468
  if (!clusterName) {
557
469
  endpoint.log.error(`subscribeAttribute ${hk}${attribute}${er} error: cluster not found on endpoint ${or}${endpoint.maybeId}${er}:${or}${endpoint.maybeNumber}${er}`);
@@ -561,7 +473,6 @@ listener, log) {
561
473
  endpoint.log.debug(`subscribeAttribute ${hk}${clusterName}.${attribute}${db}: Endpoint ${or}${endpoint.maybeId}${db}:${or}${endpoint.maybeNumber}${db} is in the ${BLUE}${endpoint.construction.status}${db} state`);
562
474
  await endpoint.construction.ready;
563
475
  }
564
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
565
476
  const events = endpoint.events;
566
477
  attribute = lowercaseFirstLetter(attribute) + '$Changed';
567
478
  if (!(clusterName in events) || !(attribute in events[clusterName])) {
@@ -572,16 +483,6 @@ listener, log) {
572
483
  log?.info(`${db}Subscribed endpoint ${or}${endpoint.id}${db}:${or}${endpoint.number}${db} attribute ${hk}${capitalizeFirstLetter(clusterName)}${db}.${hk}${attribute}${db}`);
573
484
  return true;
574
485
  }
575
- /**
576
- * Triggers an event on the specified cluster.
577
- *
578
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to trigger the event on.
579
- * @param {ClusterId} clusterId - The ID of the cluster.
580
- * @param {string} event - The name of the event to trigger.
581
- * @param {Record<string, boolean | number | bigint | string | object | undefined | null>} payload - The payload to pass to the event.
582
- * @param {AnsiLogger} [log] - Optional logger for logging information.
583
- * @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the event was successfully triggered.
584
- */
585
486
  export async function triggerEvent(endpoint, cluster, event, payload, log) {
586
487
  const clusterName = getBehavior(endpoint, cluster)?.id;
587
488
  if (!clusterName) {
@@ -592,23 +493,15 @@ export async function triggerEvent(endpoint, cluster, event, payload, log) {
592
493
  endpoint.log.error(`triggerEvent ${hk}${clusterName}.${event}${er} error: Endpoint ${or}${endpoint.maybeId}${er}:${or}${endpoint.maybeNumber}${er} is in the ${BLUE}${endpoint.construction.status}${er} state`);
593
494
  return false;
594
495
  }
595
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
596
496
  const events = endpoint.events;
597
497
  if (!(clusterName in events) || !(event in events[clusterName])) {
598
498
  endpoint.log.error(`triggerEvent ${hk}${event}${er} error: cluster ${clusterName} not found on endpoint ${or}${endpoint.id}${er}:${or}${endpoint.number}${er}`);
599
499
  return false;
600
500
  }
601
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
602
- // @ts-ignore
603
501
  await endpoint.act((agent) => agent[clusterName].events[event].emit(payload, agent.context));
604
502
  log?.info(`${db}Trigger event ${hk}${capitalizeFirstLetter(clusterName)}${db}.${hk}${event}${db} with ${debugStringify(payload)}${db} on endpoint ${or}${endpoint.id}${db}:${or}${endpoint.number}${db} `);
605
503
  return true;
606
504
  }
607
- /**
608
- * Get the default OperationalState Cluster Server.
609
- *
610
- * @param {OperationalState.OperationalStateEnum} operationalState - The initial operational state.
611
- */
612
505
  export function getDefaultOperationalStateClusterServer(operationalState = OperationalState.OperationalStateEnum.Stopped) {
613
506
  return optionsFor(MatterbridgeOperationalStateServer, {
614
507
  phaseList: [],
@@ -623,13 +516,6 @@ export function getDefaultOperationalStateClusterServer(operationalState = Opera
623
516
  operationalError: { errorStateId: OperationalState.ErrorState.NoError, errorStateLabel: 'No error', errorStateDetails: 'Fully operational' },
624
517
  });
625
518
  }
626
- /**
627
- * Get the default TemperatureMeasurement cluster server options.
628
- *
629
- * @param {number | null} measuredValue - The measured value of the temperature x 100.
630
- * @param {number | null} minMeasuredValue - The minimum measured value of the temperature x 100.
631
- * @param {number | null} maxMeasuredValue - The maximum measured value of the temperature x 100.
632
- */
633
519
  export function getDefaultTemperatureMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
634
520
  return optionsFor(TemperatureMeasurementServer, {
635
521
  measuredValue,
@@ -638,13 +524,6 @@ export function getDefaultTemperatureMeasurementClusterServer(measuredValue = nu
638
524
  tolerance: 0,
639
525
  });
640
526
  }
641
- /**
642
- * Get the default RelativeHumidityMeasurement cluster server options.
643
- *
644
- * @param {number | null} measuredValue - The measured value of the relative humidity x 100.
645
- * @param {number | null} minMeasuredValue - The minimum measured value of the relative humidity x 100.
646
- * @param {number | null} maxMeasuredValue - The maximum measured value of the relative humidity x 100.
647
- */
648
527
  export function getDefaultRelativeHumidityMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
649
528
  return optionsFor(RelativeHumidityMeasurementServer, {
650
529
  measuredValue,
@@ -653,13 +532,6 @@ export function getDefaultRelativeHumidityMeasurementClusterServer(measuredValue
653
532
  tolerance: 0,
654
533
  });
655
534
  }
656
- /**
657
- * Get the default PressureMeasurement cluster server options.
658
- *
659
- * @param {number | null} measuredValue - The measured value for the pressure.
660
- * @param {number | null} minMeasuredValue - The minimum measured value for the pressure.
661
- * @param {number | null} maxMeasuredValue - The maximum measured value for the pressure.
662
- */
663
535
  export function getDefaultPressureMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
664
536
  return optionsFor(PressureMeasurementServer, {
665
537
  measuredValue,
@@ -668,19 +540,6 @@ export function getDefaultPressureMeasurementClusterServer(measuredValue = null,
668
540
  tolerance: 0,
669
541
  });
670
542
  }
671
- /**
672
- * Get the default IlluminanceMeasurement cluster server options.
673
- *
674
- * @param {number | null} measuredValue - The measured value of illuminance.
675
- * @param {number | null} minMeasuredValue - The minimum measured value of illuminance.
676
- * @param {number | null} maxMeasuredValue - The maximum measured value of illuminance.
677
- * @remark The default value for the illuminance measurement is null.
678
- * This attribute SHALL indicate the illuminance in Lux (symbol lx) as follows:
679
- * • MeasuredValue = 10,000 x log10(illuminance) + 1,
680
- * where 1 lx <= illuminance <= 3.576 Mlx, corresponding to a MeasuredValue in the range 1 to 0xFFFE.
681
- * • 0 indicates a value of illuminance that is too low to be measured
682
- * • null indicates that the illuminance measurement is invalid.
683
- */
684
543
  export function getDefaultIlluminanceMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
685
544
  return optionsFor(IlluminanceMeasurementServer, {
686
545
  measuredValue,
@@ -689,13 +548,6 @@ export function getDefaultIlluminanceMeasurementClusterServer(measuredValue = nu
689
548
  tolerance: 0,
690
549
  });
691
550
  }
692
- /**
693
- * Get the default FlowMeasurement cluster server options.
694
- *
695
- * @param {number | null} measuredValue - The measured value of the flow in 10 x m3/h.
696
- * @param {number | null} minMeasuredValue - The minimum measured value of the flow in 10 x m3/h.
697
- * @param {number | null} maxMeasuredValue - The maximum measured value of the flow in 10 x m3/h.
698
- */
699
551
  export function getDefaultFlowMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
700
552
  return optionsFor(FlowMeasurementServer, {
701
553
  measuredValue,
@@ -704,19 +556,6 @@ export function getDefaultFlowMeasurementClusterServer(measuredValue = null, min
704
556
  tolerance: 0,
705
557
  });
706
558
  }
707
- /**
708
- * Get the default OccupancySensing cluster server options.
709
- *
710
- * @param {boolean} occupied - A boolean indicating whether the occupancy is occupied or not. Default is false.
711
- * @param {number} holdTime - The hold time in seconds. Default is 30.
712
- * @param {number} holdTimeMin - The minimum hold time in seconds. Default is 1.
713
- * @param {number} holdTimeMax - The maximum hold time in seconds. Default is 300.
714
- *
715
- * @remark The default value for the occupancy sensor type is PIR.
716
- * Servers SHALL set these attributes for backward compatibility with clients implementing a cluster revision <= 4 as
717
- * described in OccupancySensorType and OccupancySensorTypeBitmap Attributes.
718
- * This replaces the 9 legacy attributes PIROccupiedToUnoccupiedDelay through PhysicalContactUnoccupiedToOccupiedThreshold.
719
- */
720
559
  export function getDefaultOccupancySensingClusterServer(occupied = false, holdTime = 30, holdTimeMin = 1, holdTimeMax = 300) {
721
560
  return optionsFor(OccupancySensingServer.with(OccupancySensing.Feature.PassiveInfrared), {
722
561
  occupancy: { occupied },
@@ -728,4 +567,3 @@ export function getDefaultOccupancySensingClusterServer(occupied = false, holdTi
728
567
  holdTimeLimits: { holdTimeMin, holdTimeMax, holdTimeDefault: holdTime },
729
568
  });
730
569
  }
731
- //# sourceMappingURL=matterbridgeEndpointHelpers.js.map