matterbridge 3.0.6 → 3.0.7-dev-20250614-0d145a8

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 (183) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cli.js +2 -62
  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/evse.js +9 -65
  7. package/dist/frontend.js +16 -374
  8. package/dist/globalMatterbridge.js +0 -20
  9. package/dist/helpers.js +0 -51
  10. package/dist/index.js +1 -28
  11. package/dist/laundryWasher.js +7 -92
  12. package/dist/logger/export.js +0 -1
  13. package/dist/matter/behaviors.js +0 -2
  14. package/dist/matter/clusters.js +0 -2
  15. package/dist/matter/devices.js +0 -2
  16. package/dist/matter/endpoints.js +0 -2
  17. package/dist/matter/export.js +0 -2
  18. package/dist/matter/types.js +0 -2
  19. package/dist/matterbridge.js +46 -748
  20. package/dist/matterbridgeAccessoryPlatform.js +0 -34
  21. package/dist/matterbridgeBehaviors.js +1 -54
  22. package/dist/matterbridgeDeviceTypes.js +15 -578
  23. package/dist/matterbridgeDynamicPlatform.js +0 -34
  24. package/dist/matterbridgeEndpoint.js +43 -997
  25. package/dist/matterbridgeEndpointHelpers.js +10 -204
  26. package/dist/matterbridgePlatform.js +7 -225
  27. package/dist/matterbridgeTypes.js +0 -24
  28. package/dist/pluginManager.js +3 -269
  29. package/dist/roboticVacuumCleaner.js +6 -81
  30. package/dist/shelly.js +7 -155
  31. package/dist/storage/export.js +0 -1
  32. package/dist/update.js +0 -53
  33. package/dist/utils/colorUtils.js +2 -205
  34. package/dist/utils/commandLine.js +0 -53
  35. package/dist/utils/copyDirectory.js +1 -37
  36. package/dist/utils/createDirectory.js +0 -31
  37. package/dist/utils/createZip.js +2 -42
  38. package/dist/utils/deepCopy.js +0 -38
  39. package/dist/utils/deepEqual.js +1 -71
  40. package/dist/utils/export.js +0 -1
  41. package/dist/utils/hex.js +0 -57
  42. package/dist/utils/isvalid.js +0 -100
  43. package/dist/utils/network.js +5 -76
  44. package/dist/utils/spawn.js +0 -16
  45. package/dist/utils/wait.js +9 -58
  46. package/dist/waterHeater.js +2 -62
  47. package/npm-shrinkwrap.json +40 -28
  48. package/package.json +2 -3
  49. package/dist/cli.d.ts +0 -29
  50. package/dist/cli.d.ts.map +0 -1
  51. package/dist/cli.js.map +0 -1
  52. package/dist/cluster/export.d.ts +0 -2
  53. package/dist/cluster/export.d.ts.map +0 -1
  54. package/dist/cluster/export.js.map +0 -1
  55. package/dist/defaultConfigSchema.d.ts +0 -27
  56. package/dist/defaultConfigSchema.d.ts.map +0 -1
  57. package/dist/defaultConfigSchema.js.map +0 -1
  58. package/dist/deviceManager.d.ts +0 -114
  59. package/dist/deviceManager.d.ts.map +0 -1
  60. package/dist/deviceManager.js.map +0 -1
  61. package/dist/evse.d.ts +0 -67
  62. package/dist/evse.d.ts.map +0 -1
  63. package/dist/evse.js.map +0 -1
  64. package/dist/frontend.d.ts +0 -256
  65. package/dist/frontend.d.ts.map +0 -1
  66. package/dist/frontend.js.map +0 -1
  67. package/dist/globalMatterbridge.d.ts +0 -32
  68. package/dist/globalMatterbridge.d.ts.map +0 -1
  69. package/dist/globalMatterbridge.js.map +0 -1
  70. package/dist/helpers.d.ts +0 -47
  71. package/dist/helpers.d.ts.map +0 -1
  72. package/dist/helpers.js.map +0 -1
  73. package/dist/index.d.ts +0 -37
  74. package/dist/index.d.ts.map +0 -1
  75. package/dist/index.js.map +0 -1
  76. package/dist/laundryWasher.d.ts +0 -243
  77. package/dist/laundryWasher.d.ts.map +0 -1
  78. package/dist/laundryWasher.js.map +0 -1
  79. package/dist/logger/export.d.ts +0 -2
  80. package/dist/logger/export.d.ts.map +0 -1
  81. package/dist/logger/export.js.map +0 -1
  82. package/dist/matter/behaviors.d.ts +0 -2
  83. package/dist/matter/behaviors.d.ts.map +0 -1
  84. package/dist/matter/behaviors.js.map +0 -1
  85. package/dist/matter/clusters.d.ts +0 -2
  86. package/dist/matter/clusters.d.ts.map +0 -1
  87. package/dist/matter/clusters.js.map +0 -1
  88. package/dist/matter/devices.d.ts +0 -2
  89. package/dist/matter/devices.d.ts.map +0 -1
  90. package/dist/matter/devices.js.map +0 -1
  91. package/dist/matter/endpoints.d.ts +0 -2
  92. package/dist/matter/endpoints.d.ts.map +0 -1
  93. package/dist/matter/endpoints.js.map +0 -1
  94. package/dist/matter/export.d.ts +0 -5
  95. package/dist/matter/export.d.ts.map +0 -1
  96. package/dist/matter/export.js.map +0 -1
  97. package/dist/matter/types.d.ts +0 -3
  98. package/dist/matter/types.d.ts.map +0 -1
  99. package/dist/matter/types.js.map +0 -1
  100. package/dist/matterbridge.d.ts +0 -445
  101. package/dist/matterbridge.d.ts.map +0 -1
  102. package/dist/matterbridge.js.map +0 -1
  103. package/dist/matterbridgeAccessoryPlatform.d.ts +0 -40
  104. package/dist/matterbridgeAccessoryPlatform.d.ts.map +0 -1
  105. package/dist/matterbridgeAccessoryPlatform.js.map +0 -1
  106. package/dist/matterbridgeBehaviors.d.ts +0 -1333
  107. package/dist/matterbridgeBehaviors.d.ts.map +0 -1
  108. package/dist/matterbridgeBehaviors.js.map +0 -1
  109. package/dist/matterbridgeDeviceTypes.d.ts +0 -644
  110. package/dist/matterbridgeDeviceTypes.d.ts.map +0 -1
  111. package/dist/matterbridgeDeviceTypes.js.map +0 -1
  112. package/dist/matterbridgeDynamicPlatform.d.ts +0 -40
  113. package/dist/matterbridgeDynamicPlatform.d.ts.map +0 -1
  114. package/dist/matterbridgeDynamicPlatform.js.map +0 -1
  115. package/dist/matterbridgeEndpoint.d.ts +0 -1144
  116. package/dist/matterbridgeEndpoint.d.ts.map +0 -1
  117. package/dist/matterbridgeEndpoint.js.map +0 -1
  118. package/dist/matterbridgeEndpointHelpers.d.ts +0 -3083
  119. package/dist/matterbridgeEndpointHelpers.d.ts.map +0 -1
  120. package/dist/matterbridgeEndpointHelpers.js.map +0 -1
  121. package/dist/matterbridgePlatform.d.ts +0 -294
  122. package/dist/matterbridgePlatform.d.ts.map +0 -1
  123. package/dist/matterbridgePlatform.js.map +0 -1
  124. package/dist/matterbridgeTypes.d.ts +0 -196
  125. package/dist/matterbridgeTypes.d.ts.map +0 -1
  126. package/dist/matterbridgeTypes.js.map +0 -1
  127. package/dist/pluginManager.d.ts +0 -273
  128. package/dist/pluginManager.d.ts.map +0 -1
  129. package/dist/pluginManager.js.map +0 -1
  130. package/dist/roboticVacuumCleaner.d.ts +0 -102
  131. package/dist/roboticVacuumCleaner.d.ts.map +0 -1
  132. package/dist/roboticVacuumCleaner.js.map +0 -1
  133. package/dist/shelly.d.ts +0 -161
  134. package/dist/shelly.d.ts.map +0 -1
  135. package/dist/shelly.js.map +0 -1
  136. package/dist/storage/export.d.ts +0 -2
  137. package/dist/storage/export.d.ts.map +0 -1
  138. package/dist/storage/export.js.map +0 -1
  139. package/dist/update.d.ts +0 -58
  140. package/dist/update.d.ts.map +0 -1
  141. package/dist/update.js.map +0 -1
  142. package/dist/utils/colorUtils.d.ts +0 -61
  143. package/dist/utils/colorUtils.d.ts.map +0 -1
  144. package/dist/utils/colorUtils.js.map +0 -1
  145. package/dist/utils/commandLine.d.ts +0 -58
  146. package/dist/utils/commandLine.d.ts.map +0 -1
  147. package/dist/utils/commandLine.js.map +0 -1
  148. package/dist/utils/copyDirectory.d.ts +0 -32
  149. package/dist/utils/copyDirectory.d.ts.map +0 -1
  150. package/dist/utils/copyDirectory.js.map +0 -1
  151. package/dist/utils/createDirectory.d.ts +0 -32
  152. package/dist/utils/createDirectory.d.ts.map +0 -1
  153. package/dist/utils/createDirectory.js.map +0 -1
  154. package/dist/utils/createZip.d.ts +0 -38
  155. package/dist/utils/createZip.d.ts.map +0 -1
  156. package/dist/utils/createZip.js.map +0 -1
  157. package/dist/utils/deepCopy.d.ts +0 -31
  158. package/dist/utils/deepCopy.d.ts.map +0 -1
  159. package/dist/utils/deepCopy.js.map +0 -1
  160. package/dist/utils/deepEqual.d.ts +0 -53
  161. package/dist/utils/deepEqual.d.ts.map +0 -1
  162. package/dist/utils/deepEqual.js.map +0 -1
  163. package/dist/utils/export.d.ts +0 -12
  164. package/dist/utils/export.d.ts.map +0 -1
  165. package/dist/utils/export.js.map +0 -1
  166. package/dist/utils/hex.d.ts +0 -48
  167. package/dist/utils/hex.d.ts.map +0 -1
  168. package/dist/utils/hex.js.map +0 -1
  169. package/dist/utils/isvalid.d.ts +0 -102
  170. package/dist/utils/isvalid.d.ts.map +0 -1
  171. package/dist/utils/isvalid.js.map +0 -1
  172. package/dist/utils/network.d.ts +0 -69
  173. package/dist/utils/network.d.ts.map +0 -1
  174. package/dist/utils/network.js.map +0 -1
  175. package/dist/utils/spawn.d.ts +0 -12
  176. package/dist/utils/spawn.d.ts.map +0 -1
  177. package/dist/utils/spawn.js.map +0 -1
  178. package/dist/utils/wait.d.ts +0 -52
  179. package/dist/utils/wait.d.ts.map +0 -1
  180. package/dist/utils/wait.js.map +0 -1
  181. package/dist/waterHeater.d.ts +0 -90
  182. package/dist/waterHeater.d.ts.map +0 -1
  183. package/dist/waterHeater.js.map +0 -1
@@ -1,29 +1,5 @@
1
- /**
2
- * This file contains the helpers for the class MatterbridgeEndpoint.
3
- *
4
- * @file matterbridgeEndpointHelpers.ts
5
- * @author Luca Liguori
6
- * @date 2024-10-01
7
- * @version 2.1.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
- // @matter
24
1
  import { Lifecycle } from '@matter/main';
25
2
  import { getClusterNameById } from '@matter/main/types';
26
- // @matter clusters
27
3
  import { PowerSource } from '@matter/main/clusters/power-source';
28
4
  import { UserLabel } from '@matter/main/clusters/user-label';
29
5
  import { FixedLabel } from '@matter/main/clusters/fixed-label';
@@ -68,7 +44,6 @@ import { TotalVolatileOrganicCompoundsConcentrationMeasurement } from '@matter/m
68
44
  import { OperationalState } from '@matter/main/clusters/operational-state';
69
45
  import { DeviceEnergyManagement } from '@matter/main/clusters/device-energy-management';
70
46
  import { DeviceEnergyManagementMode } from '@matter/main/clusters/device-energy-management-mode';
71
- // @matter behaviors
72
47
  import { PowerSourceServer } from '@matter/main/behaviors/power-source';
73
48
  import { UserLabelServer } from '@matter/main/behaviors/user-label';
74
49
  import { FixedLabelServer } from '@matter/main/behaviors/fixed-label';
@@ -99,10 +74,8 @@ import { Pm10ConcentrationMeasurementServer } from '@matter/main/behaviors/pm10-
99
74
  import { RadonConcentrationMeasurementServer } from '@matter/main/behaviors/radon-concentration-measurement';
100
75
  import { TotalVolatileOrganicCompoundsConcentrationMeasurementServer } from '@matter/main/behaviors/total-volatile-organic-compounds-concentration-measurement';
101
76
  import { DeviceEnergyManagementServer } from '@matter/node/behaviors/device-energy-management';
102
- // Other modules
103
77
  import { createHash } from 'node:crypto';
104
78
  import { BLUE, CYAN, db, debugStringify, er, hk, or, YELLOW, zb } from 'node-ansi-logger';
105
- // Matterbridge
106
79
  import { deepCopy, deepEqual, isValidArray } from './utils/export.js';
107
80
  import { MatterbridgeIdentifyServer, MatterbridgeOnOffServer, MatterbridgeLevelControlServer, MatterbridgeColorControlServer, MatterbridgeLiftWindowCoveringServer, MatterbridgeThermostatServer, MatterbridgeFanControlServer, MatterbridgeDoorLockServer, MatterbridgeModeSelectServer, MatterbridgeValveConfigurationAndControlServer, MatterbridgeSmokeCoAlarmServer, MatterbridgeBooleanStateConfigurationServer, MatterbridgeOperationalStateServer, MatterbridgeDeviceEnergyManagementModeServer, } from './matterbridgeBehaviors.js';
108
81
  export function capitalizeFirstLetter(name) {
@@ -117,19 +90,19 @@ export function lowercaseFirstLetter(name) {
117
90
  }
118
91
  export function checkNotLatinCharacters(deviceName) {
119
92
  const nonLatinRegexList = [
120
- /[\u0400-\u04FF\u0500-\u052F]/, // Cyrillic
121
- /[\u2E80-\u9FFF]/, // CJK (Chinese, Japanese, Korean)
122
- /[\uAC00-\uD7AF]/, // Korean Hangul
123
- /[\u0600-\u06FF\u0750-\u077F]/, // Arabic, Persian
124
- /[\u0590-\u05FF]/, // Hebrew
125
- /[\u0900-\u097F]/, // Devanagari (Hindi, Sanskrit)
126
- /[\u0E00-\u0E7F]/, // Thai
127
- /[\u1200-\u137F]/, // Ethiopic (Amharic, Tigrinya)
93
+ /[\u0400-\u04FF\u0500-\u052F]/,
94
+ /[\u2E80-\u9FFF]/,
95
+ /[\uAC00-\uD7AF]/,
96
+ /[\u0600-\u06FF\u0750-\u077F]/,
97
+ /[\u0590-\u05FF]/,
98
+ /[\u0900-\u097F]/,
99
+ /[\u0E00-\u0E7F]/,
100
+ /[\u1200-\u137F]/,
128
101
  ];
129
102
  return nonLatinRegexList.some((regex) => regex.test(deviceName));
130
103
  }
131
104
  export function generateUniqueId(deviceName) {
132
- return createHash('md5').update(deviceName).digest('hex'); // MD5 hash of the device name
105
+ return createHash('md5').update(deviceName).digest('hex');
133
106
  }
134
107
  export function createUniqueId(param1, param2, param3, param4) {
135
108
  const hash = createHash('md5');
@@ -137,7 +110,6 @@ export function createUniqueId(param1, param2, param3, param4) {
137
110
  return hash.digest('hex');
138
111
  }
139
112
  export function getBehaviourTypesFromClusterServerIds(clusterServerList) {
140
- // Map Server ClusterId to Behavior.Type
141
113
  const behaviorTypes = [];
142
114
  clusterServerList.forEach((clusterId) => {
143
115
  behaviorTypes.push(getBehaviourTypeFromClusterServerId(clusterId));
@@ -145,15 +117,12 @@ export function getBehaviourTypesFromClusterServerIds(clusterServerList) {
145
117
  return behaviorTypes;
146
118
  }
147
119
  export function getBehaviourTypesFromClusterClientIds(clusterClientList) {
148
- // Map Client ClusterId to Behavior.Type
149
120
  const behaviorTypes = [];
150
121
  clusterClientList.forEach((_clusterId) => {
151
- // behaviorTypes.push(getBehaviourTypeFromClusterClientId(clusterId));
152
122
  });
153
123
  return behaviorTypes;
154
124
  }
155
125
  export function getBehaviourTypeFromClusterServerId(clusterId) {
156
- // Map ClusterId to Server Behavior.Type
157
126
  if (clusterId === PowerSource.Cluster.id)
158
127
  return PowerSourceServer.with(PowerSource.Feature.Wired);
159
128
  if (clusterId === UserLabel.Cluster.id)
@@ -245,8 +214,6 @@ export function getBehaviourTypeFromClusterServerId(clusterId) {
245
214
  return MatterbridgeIdentifyServer;
246
215
  }
247
216
  export function getBehaviourTypeFromClusterClientId(_clusterId) {
248
- // Map ClusterId to Client Behavior.Type
249
- // return IdentifyClient;
250
217
  }
251
218
  export function getBehavior(endpoint, cluster) {
252
219
  let behavior;
@@ -264,11 +231,6 @@ export function getBehavior(endpoint, cluster) {
264
231
  }
265
232
  return behavior;
266
233
  }
267
- /**
268
- * Invokes a command on the specified behavior of the endpoint. Used ONLY in Jest tests.
269
- *
270
- * @deprecated Used ONLY in Jest tests.
271
- */
272
234
  export async function invokeBehaviorCommand(endpoint, cluster, command, params) {
273
235
  const behaviorId = getBehavior(endpoint, cluster)?.id;
274
236
  if (!behaviorId) {
@@ -276,7 +238,6 @@ export async function invokeBehaviorCommand(endpoint, cluster, command, params)
276
238
  return false;
277
239
  }
278
240
  await endpoint.act((agent) => {
279
- // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
280
241
  const behavior = agent[behaviorId];
281
242
  if (!(command in behavior) || typeof behavior[command] !== 'function') {
282
243
  endpoint.log?.error(`invokeBehaviorCommand error: command ${hk}${command}${er} not found on agent for endpoint ${or}${endpoint.maybeId}${er}:${or}${endpoint.maybeNumber}${er}`);
@@ -286,17 +247,6 @@ export async function invokeBehaviorCommand(endpoint, cluster, command, params)
286
247
  });
287
248
  return true;
288
249
  }
289
- /**
290
- * Invokes the subscription handler on the specified cluster and attribute of the endpoint. Used ONLY in Jest tests.
291
- *
292
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to invoke the subscription handler on.
293
- * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to invoke the subscription handler on.
294
- * @param {string} attribute - The attribute to invoke the subscription handler on.
295
- * @param {unknown} newValue - The new value of the attribute.
296
- * @param {unknown} oldValue - The old value of the attribute.
297
- *
298
- * @deprecated Used ONLY in Jest tests.
299
- */
300
250
  export async function invokeSubscribeHandler(endpoint, cluster, attribute, newValue, oldValue) {
301
251
  const event = attribute + '$Changed';
302
252
  const clusterName = getBehavior(endpoint, cluster)?.id;
@@ -313,8 +263,6 @@ export async function invokeSubscribeHandler(endpoint, cluster, attribute, newVa
313
263
  endpoint.log.error(`invokeSubscribeHandler ${hk}${event}${er} error: cluster ${clusterName} not found on endpoint ${or}${endpoint.id}${er}:${or}${endpoint.number}${er}`);
314
264
  return false;
315
265
  }
316
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
317
- // @ts-ignore
318
266
  await endpoint.act((agent) => agent[clusterName].events[event].emit(newValue, oldValue, { ...agent.context, offline: false }));
319
267
  return true;
320
268
  }
@@ -346,13 +294,6 @@ export function addOptionalClusterServers(endpoint) {
346
294
  });
347
295
  addClusterServers(endpoint, optionalServerList);
348
296
  }
349
- /**
350
- * Adds cluster servers to the specified endpoint based on the provided server list.
351
- *
352
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to add the cluster servers to.
353
- * @param {ClusterId[]} serverList - The list of cluster IDs to add.
354
- * @returns void
355
- */
356
297
  export function addClusterServers(endpoint, serverList) {
357
298
  if (serverList.includes(PowerSource.Cluster.id))
358
299
  endpoint.createDefaultPowerSourceWiredClusterServer();
@@ -433,13 +374,6 @@ export function addClusterServers(endpoint, serverList) {
433
374
  if (serverList.includes(DeviceEnergyManagementMode.Cluster.id))
434
375
  endpoint.createDefaultDeviceEnergyManagementModeClusterServer();
435
376
  }
436
- /**
437
- * Adds a fixed label to the FixedLabel cluster. The FixedLabel cluster is created if it does not exist.
438
- *
439
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to add the cluster servers to.
440
- * @param {string} label - The label to add.
441
- * @param {string} value - The value of the label.
442
- */
443
377
  export async function addFixedLabel(endpoint, label, value) {
444
378
  if (!endpoint.hasClusterServer(FixedLabel.Cluster.id)) {
445
379
  endpoint.log.debug(`addFixedLabel: add cluster ${hk}FixedLabel${db}:${hk}fixedLabel${db} with label ${CYAN}${label}${db} value ${CYAN}${value}${db}`);
@@ -456,13 +390,6 @@ export async function addFixedLabel(endpoint, label, value) {
456
390
  await endpoint.setAttribute(FixedLabel.Cluster.id, 'labelList', labelList, endpoint.log);
457
391
  }
458
392
  }
459
- /**
460
- * Adds a user label to the UserLabel cluster. The UserLabel cluster is created if it does not exist.
461
- *
462
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to add the cluster servers to.
463
- * @param {string} label - The label to add.
464
- * @param {string} value - The value of the label.
465
- */
466
393
  export async function addUserLabel(endpoint, label, value) {
467
394
  if (!endpoint.hasClusterServer(UserLabel.Cluster.id)) {
468
395
  endpoint.log.debug(`addUserLabel: add cluster ${hk}UserLabel${db}:${hk}userLabel${db} with label ${CYAN}${label}${db} value ${CYAN}${value}${db}`);
@@ -489,16 +416,6 @@ export function getAttributeId(endpoint, cluster, attribute) {
489
416
  const clusterBehavior = endpoint.behaviors.supported[lowercaseFirstLetter(cluster)];
490
417
  return clusterBehavior?.cluster?.attributes[lowercaseFirstLetter(attribute)]?.id;
491
418
  }
492
- /**
493
- * Retrieves the value of the provided attribute from the given cluster.
494
- *
495
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to retrieve the attribute from.
496
- * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to retrieve the attribute from.
497
- * @param {string} attribute - The name of the attribute to retrieve.
498
- * @param {AnsiLogger} [log] - (Optional) The logger to use for logging the retrieve. Errors are logged to the endpoint logger.
499
- * @returns {any} The value of the attribute, or undefined if the attribute is not found.
500
- */
501
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
502
419
  export function getAttribute(endpoint, cluster, attribute, log) {
503
420
  const clusterName = getBehavior(endpoint, cluster)?.id;
504
421
  if (!clusterName) {
@@ -521,16 +438,6 @@ export function getAttribute(endpoint, cluster, attribute, log) {
521
438
  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}`);
522
439
  return value;
523
440
  }
524
- /**
525
- * Sets the value of an attribute on a cluster server.
526
- *
527
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to set the attribute on.
528
- * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to set the attribute on.
529
- * @param {string} attribute - The name of the attribute.
530
- * @param {boolean | number | bigint | string | object | null} value - The value to set for the attribute.
531
- * @param {AnsiLogger} [log] - (Optional) The logger to use for logging the set. Errors are logged to the endpoint logger.
532
- * @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the attribute was successfully set.
533
- */
534
441
  export async function setAttribute(endpoint, cluster, attribute, value, log) {
535
442
  const clusterName = getBehavior(endpoint, cluster)?.id;
536
443
  if (!clusterName) {
@@ -556,16 +463,6 @@ export async function setAttribute(endpoint, cluster, attribute, value, log) {
556
463
  `to ${YELLOW}${value !== null && typeof value === 'object' ? debugStringify(value) : value}${db}`);
557
464
  return true;
558
465
  }
559
- /**
560
- * Sets the value of an attribute on a cluster server.
561
- *
562
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to update the attribute on.
563
- * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to update the attribute on.
564
- * @param {string} attribute - The name of the attribute.
565
- * @param {boolean | number | bigint | string | object | null} value - The value to set for the attribute.
566
- * @param {AnsiLogger} [log] - (Optional) The logger to use for logging the update. Errors are logged to the endpoint logger.
567
- * @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the attribute was successfully set.
568
- */
569
466
  export async function updateAttribute(endpoint, cluster, attribute, value, log) {
570
467
  const clusterName = getBehavior(endpoint, cluster)?.id;
571
468
  if (!clusterName) {
@@ -596,24 +493,7 @@ export async function updateAttribute(endpoint, cluster, attribute, value, log)
596
493
  `to ${YELLOW}${value !== null && typeof value === 'object' ? debugStringify(value) : value}${db}`);
597
494
  return true;
598
495
  }
599
- /**
600
- * Subscribes to the provided attribute on a cluster.
601
- *
602
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to subscribe the attribute to.
603
- * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to subscribe the attribute to.
604
- * @param {string} attribute - The name of the attribute to subscribe to.
605
- * @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.
606
- * @param {AnsiLogger} [log] - Optional logger for logging errors and information.
607
- * @returns {boolean} - A boolean indicating whether the subscription was successful.
608
- *
609
- * @remarks The listener function (cannot be async) will receive three parameters:
610
- * - `newValue`: The new value of the attribute.
611
- * - `oldValue`: The old value of the attribute.
612
- * - `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.
613
- */
614
- export async function subscribeAttribute(endpoint, cluster, attribute,
615
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
616
- listener, log) {
496
+ export async function subscribeAttribute(endpoint, cluster, attribute, listener, log) {
617
497
  const clusterName = getBehavior(endpoint, cluster)?.id;
618
498
  if (!clusterName) {
619
499
  endpoint.log.error(`subscribeAttribute ${hk}${attribute}${er} error: cluster not found on endpoint ${or}${endpoint.maybeId}${er}:${or}${endpoint.maybeNumber}${er}`);
@@ -623,7 +503,6 @@ listener, log) {
623
503
  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`);
624
504
  await endpoint.construction.ready;
625
505
  }
626
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
627
506
  const events = endpoint.events;
628
507
  attribute = lowercaseFirstLetter(attribute) + '$Changed';
629
508
  if (!(clusterName in events) || !(attribute in events[clusterName])) {
@@ -634,16 +513,6 @@ listener, log) {
634
513
  log?.info(`${db}Subscribed endpoint ${or}${endpoint.id}${db}:${or}${endpoint.number}${db} attribute ${hk}${capitalizeFirstLetter(clusterName)}${db}.${hk}${attribute}${db}`);
635
514
  return true;
636
515
  }
637
- /**
638
- * Triggers an event on the specified cluster.
639
- *
640
- * @param {MatterbridgeEndpoint} endpoint - The endpoint to trigger the event on.
641
- * @param {ClusterId} clusterId - The ID of the cluster.
642
- * @param {string} event - The name of the event to trigger.
643
- * @param {Record<string, boolean | number | bigint | string | object | undefined | null>} payload - The payload to pass to the event.
644
- * @param {AnsiLogger} [log] - Optional logger for logging information.
645
- * @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the event was successfully triggered.
646
- */
647
516
  export async function triggerEvent(endpoint, cluster, event, payload, log) {
648
517
  const clusterName = getBehavior(endpoint, cluster)?.id;
649
518
  if (!clusterName) {
@@ -654,23 +523,15 @@ export async function triggerEvent(endpoint, cluster, event, payload, log) {
654
523
  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`);
655
524
  return false;
656
525
  }
657
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
658
526
  const events = endpoint.events;
659
527
  if (!(clusterName in events) || !(event in events[clusterName])) {
660
528
  endpoint.log.error(`triggerEvent ${hk}${event}${er} error: cluster ${clusterName} not found on endpoint ${or}${endpoint.id}${er}:${or}${endpoint.number}${er}`);
661
529
  return false;
662
530
  }
663
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
664
- // @ts-ignore
665
531
  await endpoint.act((agent) => agent[clusterName].events[event].emit(payload, agent.context));
666
532
  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} `);
667
533
  return true;
668
534
  }
669
- /**
670
- * Get the default OperationalState Cluster Server.
671
- *
672
- * @param {OperationalState.OperationalStateEnum} operationalState - The initial operational state.
673
- */
674
535
  export function getDefaultOperationalStateClusterServer(operationalState = OperationalState.OperationalStateEnum.Stopped) {
675
536
  return optionsFor(MatterbridgeOperationalStateServer, {
676
537
  phaseList: [],
@@ -685,13 +546,6 @@ export function getDefaultOperationalStateClusterServer(operationalState = Opera
685
546
  operationalError: { errorStateId: OperationalState.ErrorState.NoError, errorStateLabel: 'No error', errorStateDetails: 'Fully operational' },
686
547
  });
687
548
  }
688
- /**
689
- * Get the default TemperatureMeasurement cluster server options.
690
- *
691
- * @param {number | null} measuredValue - The measured value of the temperature x 100.
692
- * @param {number | null} minMeasuredValue - The minimum measured value of the temperature x 100.
693
- * @param {number | null} maxMeasuredValue - The maximum measured value of the temperature x 100.
694
- */
695
549
  export function getDefaultTemperatureMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
696
550
  return optionsFor(TemperatureMeasurementServer, {
697
551
  measuredValue,
@@ -700,13 +554,6 @@ export function getDefaultTemperatureMeasurementClusterServer(measuredValue = nu
700
554
  tolerance: 0,
701
555
  });
702
556
  }
703
- /**
704
- * Get the default RelativeHumidityMeasurement cluster server options.
705
- *
706
- * @param {number | null} measuredValue - The measured value of the relative humidity x 100.
707
- * @param {number | null} minMeasuredValue - The minimum measured value of the relative humidity x 100.
708
- * @param {number | null} maxMeasuredValue - The maximum measured value of the relative humidity x 100.
709
- */
710
557
  export function getDefaultRelativeHumidityMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
711
558
  return optionsFor(RelativeHumidityMeasurementServer, {
712
559
  measuredValue,
@@ -715,13 +562,6 @@ export function getDefaultRelativeHumidityMeasurementClusterServer(measuredValue
715
562
  tolerance: 0,
716
563
  });
717
564
  }
718
- /**
719
- * Get the default PressureMeasurement cluster server options.
720
- *
721
- * @param {number | null} measuredValue - The measured value for the pressure.
722
- * @param {number | null} minMeasuredValue - The minimum measured value for the pressure.
723
- * @param {number | null} maxMeasuredValue - The maximum measured value for the pressure.
724
- */
725
565
  export function getDefaultPressureMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
726
566
  return optionsFor(PressureMeasurementServer, {
727
567
  measuredValue,
@@ -730,19 +570,6 @@ export function getDefaultPressureMeasurementClusterServer(measuredValue = null,
730
570
  tolerance: 0,
731
571
  });
732
572
  }
733
- /**
734
- * Get the default IlluminanceMeasurement cluster server options.
735
- *
736
- * @param {number | null} measuredValue - The measured value of illuminance.
737
- * @param {number | null} minMeasuredValue - The minimum measured value of illuminance.
738
- * @param {number | null} maxMeasuredValue - The maximum measured value of illuminance.
739
- * @remark The default value for the illuminance measurement is null.
740
- * This attribute SHALL indicate the illuminance in Lux (symbol lx) as follows:
741
- * • MeasuredValue = 10,000 x log10(illuminance) + 1,
742
- * where 1 lx <= illuminance <= 3.576 Mlx, corresponding to a MeasuredValue in the range 1 to 0xFFFE.
743
- * • 0 indicates a value of illuminance that is too low to be measured
744
- * • null indicates that the illuminance measurement is invalid.
745
- */
746
573
  export function getDefaultIlluminanceMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
747
574
  return optionsFor(IlluminanceMeasurementServer, {
748
575
  measuredValue,
@@ -751,13 +578,6 @@ export function getDefaultIlluminanceMeasurementClusterServer(measuredValue = nu
751
578
  tolerance: 0,
752
579
  });
753
580
  }
754
- /**
755
- * Get the default FlowMeasurement cluster server options.
756
- *
757
- * @param {number | null} measuredValue - The measured value of the flow in 10 x m3/h.
758
- * @param {number | null} minMeasuredValue - The minimum measured value of the flow in 10 x m3/h.
759
- * @param {number | null} maxMeasuredValue - The maximum measured value of the flow in 10 x m3/h.
760
- */
761
581
  export function getDefaultFlowMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
762
582
  return optionsFor(FlowMeasurementServer, {
763
583
  measuredValue,
@@ -766,19 +586,6 @@ export function getDefaultFlowMeasurementClusterServer(measuredValue = null, min
766
586
  tolerance: 0,
767
587
  });
768
588
  }
769
- /**
770
- * Get the default OccupancySensing cluster server options.
771
- *
772
- * @param {boolean} occupied - A boolean indicating whether the occupancy is occupied or not. Default is false.
773
- * @param {number} holdTime - The hold time in seconds. Default is 30.
774
- * @param {number} holdTimeMin - The minimum hold time in seconds. Default is 1.
775
- * @param {number} holdTimeMax - The maximum hold time in seconds. Default is 300.
776
- *
777
- * @remark The default value for the occupancy sensor type is PIR.
778
- * Servers SHALL set these attributes for backward compatibility with clients implementing a cluster revision <= 4 as
779
- * described in OccupancySensorType and OccupancySensorTypeBitmap Attributes.
780
- * This replaces the 9 legacy attributes PIROccupiedToUnoccupiedDelay through PhysicalContactUnoccupiedToOccupiedThreshold.
781
- */
782
589
  export function getDefaultOccupancySensingClusterServer(occupied = false, holdTime = 30, holdTimeMin = 1, holdTimeMax = 300) {
783
590
  return optionsFor(OccupancySensingServer.with(OccupancySensing.Feature.PassiveInfrared), {
784
591
  occupancy: { occupied },
@@ -790,4 +597,3 @@ export function getDefaultOccupancySensingClusterServer(occupied = false, holdTi
790
597
  holdTimeLimits: { holdTimeMin, holdTimeMax, holdTimeDefault: holdTime },
791
598
  });
792
599
  }
793
- //# sourceMappingURL=matterbridgeEndpointHelpers.js.map