matterbridge 3.1.5-dev-20250718-054cd80 → 3.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) hide show
  1. package/CHANGELOG.md +5 -6
  2. package/dist/cli.d.ts +26 -0
  3. package/dist/cli.d.ts.map +1 -0
  4. package/dist/cli.js +91 -2
  5. package/dist/cli.js.map +1 -0
  6. package/dist/cliEmitter.d.ts +34 -0
  7. package/dist/cliEmitter.d.ts.map +1 -0
  8. package/dist/cliEmitter.js +30 -0
  9. package/dist/cliEmitter.js.map +1 -0
  10. package/dist/clusters/export.d.ts +2 -0
  11. package/dist/clusters/export.d.ts.map +1 -0
  12. package/dist/clusters/export.js +2 -0
  13. package/dist/clusters/export.js.map +1 -0
  14. package/dist/defaultConfigSchema.d.ts +28 -0
  15. package/dist/defaultConfigSchema.d.ts.map +1 -0
  16. package/dist/defaultConfigSchema.js +24 -0
  17. package/dist/defaultConfigSchema.js.map +1 -0
  18. package/dist/deviceManager.d.ts +112 -0
  19. package/dist/deviceManager.d.ts.map +1 -0
  20. package/dist/deviceManager.js +94 -1
  21. package/dist/deviceManager.js.map +1 -0
  22. package/dist/devices/batteryStorage.d.ts +48 -0
  23. package/dist/devices/batteryStorage.d.ts.map +1 -0
  24. package/dist/devices/batteryStorage.js +48 -1
  25. package/dist/devices/batteryStorage.js.map +1 -0
  26. package/dist/devices/evse.d.ts +75 -0
  27. package/dist/devices/evse.d.ts.map +1 -0
  28. package/dist/devices/evse.js +74 -10
  29. package/dist/devices/evse.js.map +1 -0
  30. package/dist/devices/export.d.ts +9 -0
  31. package/dist/devices/export.d.ts.map +1 -0
  32. package/dist/devices/export.js +2 -0
  33. package/dist/devices/export.js.map +1 -0
  34. package/dist/devices/heatPump.d.ts +47 -0
  35. package/dist/devices/heatPump.d.ts.map +1 -0
  36. package/dist/devices/heatPump.js +50 -2
  37. package/dist/devices/heatPump.js.map +1 -0
  38. package/dist/devices/laundryDryer.d.ts +87 -0
  39. package/dist/devices/laundryDryer.d.ts.map +1 -0
  40. package/dist/devices/laundryDryer.js +83 -6
  41. package/dist/devices/laundryDryer.js.map +1 -0
  42. package/dist/devices/laundryWasher.d.ts +242 -0
  43. package/dist/devices/laundryWasher.d.ts.map +1 -0
  44. package/dist/devices/laundryWasher.js +91 -7
  45. package/dist/devices/laundryWasher.js.map +1 -0
  46. package/dist/devices/roboticVacuumCleaner.d.ts +112 -0
  47. package/dist/devices/roboticVacuumCleaner.d.ts.map +1 -0
  48. package/dist/devices/roboticVacuumCleaner.js +103 -14
  49. package/dist/devices/roboticVacuumCleaner.js.map +1 -0
  50. package/dist/devices/solarPower.d.ts +40 -0
  51. package/dist/devices/solarPower.d.ts.map +1 -0
  52. package/dist/devices/solarPower.js +38 -0
  53. package/dist/devices/solarPower.js.map +1 -0
  54. package/dist/devices/waterHeater.d.ts +111 -0
  55. package/dist/devices/waterHeater.d.ts.map +1 -0
  56. package/dist/devices/waterHeater.js +82 -2
  57. package/dist/devices/waterHeater.js.map +1 -0
  58. package/dist/frontend.d.ts +304 -0
  59. package/dist/frontend.d.ts.map +1 -0
  60. package/dist/frontend.js +430 -22
  61. package/dist/frontend.js.map +1 -0
  62. package/dist/globalMatterbridge.d.ts +59 -0
  63. package/dist/globalMatterbridge.d.ts.map +1 -0
  64. package/dist/globalMatterbridge.js +47 -0
  65. package/dist/globalMatterbridge.js.map +1 -0
  66. package/dist/helpers.d.ts +48 -0
  67. package/dist/helpers.d.ts.map +1 -0
  68. package/dist/helpers.js +53 -0
  69. package/dist/helpers.js.map +1 -0
  70. package/dist/index.d.ts +33 -0
  71. package/dist/index.d.ts.map +1 -0
  72. package/dist/index.js +30 -1
  73. package/dist/index.js.map +1 -0
  74. package/dist/logger/export.d.ts +2 -0
  75. package/dist/logger/export.d.ts.map +1 -0
  76. package/dist/logger/export.js +1 -0
  77. package/dist/logger/export.js.map +1 -0
  78. package/dist/matter/behaviors.d.ts +2 -0
  79. package/dist/matter/behaviors.d.ts.map +1 -0
  80. package/dist/matter/behaviors.js +2 -0
  81. package/dist/matter/behaviors.js.map +1 -0
  82. package/dist/matter/clusters.d.ts +2 -0
  83. package/dist/matter/clusters.d.ts.map +1 -0
  84. package/dist/matter/clusters.js +2 -0
  85. package/dist/matter/clusters.js.map +1 -0
  86. package/dist/matter/devices.d.ts +2 -0
  87. package/dist/matter/devices.d.ts.map +1 -0
  88. package/dist/matter/devices.js +2 -0
  89. package/dist/matter/devices.js.map +1 -0
  90. package/dist/matter/endpoints.d.ts +2 -0
  91. package/dist/matter/endpoints.d.ts.map +1 -0
  92. package/dist/matter/endpoints.js +2 -0
  93. package/dist/matter/endpoints.js.map +1 -0
  94. package/dist/matter/export.d.ts +5 -0
  95. package/dist/matter/export.d.ts.map +1 -0
  96. package/dist/matter/export.js +3 -0
  97. package/dist/matter/export.js.map +1 -0
  98. package/dist/matter/types.d.ts +3 -0
  99. package/dist/matter/types.d.ts.map +1 -0
  100. package/dist/matter/types.js +3 -0
  101. package/dist/matter/types.js.map +1 -0
  102. package/dist/matterbridge.d.ts +447 -0
  103. package/dist/matterbridge.d.ts.map +1 -0
  104. package/dist/matterbridge.js +791 -51
  105. package/dist/matterbridge.js.map +1 -0
  106. package/dist/matterbridgeAccessoryPlatform.d.ts +42 -0
  107. package/dist/matterbridgeAccessoryPlatform.d.ts.map +1 -0
  108. package/dist/matterbridgeAccessoryPlatform.js +36 -0
  109. package/dist/matterbridgeAccessoryPlatform.js.map +1 -0
  110. package/dist/matterbridgeBehaviors.d.ts +1340 -0
  111. package/dist/matterbridgeBehaviors.d.ts.map +1 -0
  112. package/dist/matterbridgeBehaviors.js +61 -1
  113. package/dist/matterbridgeBehaviors.js.map +1 -0
  114. package/dist/matterbridgeDeviceTypes.d.ts +709 -0
  115. package/dist/matterbridgeDeviceTypes.d.ts.map +1 -0
  116. package/dist/matterbridgeDeviceTypes.js +579 -15
  117. package/dist/matterbridgeDeviceTypes.js.map +1 -0
  118. package/dist/matterbridgeDynamicPlatform.d.ts +42 -0
  119. package/dist/matterbridgeDynamicPlatform.d.ts.map +1 -0
  120. package/dist/matterbridgeDynamicPlatform.js +36 -0
  121. package/dist/matterbridgeDynamicPlatform.js.map +1 -0
  122. package/dist/matterbridgeEndpoint.d.ts +1250 -0
  123. package/dist/matterbridgeEndpoint.d.ts.map +1 -0
  124. package/dist/matterbridgeEndpoint.js +1106 -42
  125. package/dist/matterbridgeEndpoint.js.map +1 -0
  126. package/dist/matterbridgeEndpointHelpers.d.ts +3198 -0
  127. package/dist/matterbridgeEndpointHelpers.d.ts.map +1 -0
  128. package/dist/matterbridgeEndpointHelpers.js +322 -12
  129. package/dist/matterbridgeEndpointHelpers.js.map +1 -0
  130. package/dist/matterbridgePlatform.d.ts +310 -0
  131. package/dist/matterbridgePlatform.d.ts.map +1 -0
  132. package/dist/matterbridgePlatform.js +233 -0
  133. package/dist/matterbridgePlatform.js.map +1 -0
  134. package/dist/matterbridgeTypes.d.ts +195 -0
  135. package/dist/matterbridgeTypes.d.ts.map +1 -0
  136. package/dist/matterbridgeTypes.js +25 -0
  137. package/dist/matterbridgeTypes.js.map +1 -0
  138. package/dist/pluginManager.d.ts +270 -0
  139. package/dist/pluginManager.d.ts.map +1 -0
  140. package/dist/pluginManager.js +249 -3
  141. package/dist/pluginManager.js.map +1 -0
  142. package/dist/shelly.d.ts +174 -0
  143. package/dist/shelly.d.ts.map +1 -0
  144. package/dist/shelly.js +168 -7
  145. package/dist/shelly.js.map +1 -0
  146. package/dist/storage/export.d.ts +2 -0
  147. package/dist/storage/export.d.ts.map +1 -0
  148. package/dist/storage/export.js +1 -0
  149. package/dist/storage/export.js.map +1 -0
  150. package/dist/update.d.ts +59 -0
  151. package/dist/update.d.ts.map +1 -0
  152. package/dist/update.js +54 -0
  153. package/dist/update.js.map +1 -0
  154. package/dist/utils/colorUtils.d.ts +117 -0
  155. package/dist/utils/colorUtils.d.ts.map +1 -0
  156. package/dist/utils/colorUtils.js +263 -2
  157. package/dist/utils/colorUtils.js.map +1 -0
  158. package/dist/utils/commandLine.d.ts +59 -0
  159. package/dist/utils/commandLine.d.ts.map +1 -0
  160. package/dist/utils/commandLine.js +54 -0
  161. package/dist/utils/commandLine.js.map +1 -0
  162. package/dist/utils/copyDirectory.d.ts +33 -0
  163. package/dist/utils/copyDirectory.d.ts.map +1 -0
  164. package/dist/utils/copyDirectory.js +38 -1
  165. package/dist/utils/copyDirectory.js.map +1 -0
  166. package/dist/utils/createDirectory.d.ts +34 -0
  167. package/dist/utils/createDirectory.d.ts.map +1 -0
  168. package/dist/utils/createDirectory.js +33 -0
  169. package/dist/utils/createDirectory.js.map +1 -0
  170. package/dist/utils/createZip.d.ts +39 -0
  171. package/dist/utils/createZip.d.ts.map +1 -0
  172. package/dist/utils/createZip.js +47 -2
  173. package/dist/utils/createZip.js.map +1 -0
  174. package/dist/utils/deepCopy.d.ts +32 -0
  175. package/dist/utils/deepCopy.d.ts.map +1 -0
  176. package/dist/utils/deepCopy.js +39 -0
  177. package/dist/utils/deepCopy.js.map +1 -0
  178. package/dist/utils/deepEqual.d.ts +54 -0
  179. package/dist/utils/deepEqual.d.ts.map +1 -0
  180. package/dist/utils/deepEqual.js +72 -1
  181. package/dist/utils/deepEqual.js.map +1 -0
  182. package/dist/utils/error.d.ts +44 -0
  183. package/dist/utils/error.d.ts.map +1 -0
  184. package/dist/utils/error.js +41 -0
  185. package/dist/utils/error.js.map +1 -0
  186. package/dist/utils/export.d.ts +12 -0
  187. package/dist/utils/export.d.ts.map +1 -0
  188. package/dist/utils/export.js +1 -0
  189. package/dist/utils/export.js.map +1 -0
  190. package/dist/utils/hex.d.ts +49 -0
  191. package/dist/utils/hex.d.ts.map +1 -0
  192. package/dist/utils/hex.js +58 -0
  193. package/dist/utils/hex.js.map +1 -0
  194. package/dist/utils/isvalid.d.ts +103 -0
  195. package/dist/utils/isvalid.d.ts.map +1 -0
  196. package/dist/utils/isvalid.js +101 -0
  197. package/dist/utils/isvalid.js.map +1 -0
  198. package/dist/utils/network.d.ts +74 -0
  199. package/dist/utils/network.d.ts.map +1 -0
  200. package/dist/utils/network.js +81 -5
  201. package/dist/utils/network.js.map +1 -0
  202. package/dist/utils/spawn.d.ts +33 -0
  203. package/dist/utils/spawn.d.ts.map +1 -0
  204. package/dist/utils/spawn.js +40 -0
  205. package/dist/utils/spawn.js.map +1 -0
  206. package/dist/utils/wait.d.ts +56 -0
  207. package/dist/utils/wait.d.ts.map +1 -0
  208. package/dist/utils/wait.js +62 -9
  209. package/dist/utils/wait.js.map +1 -0
  210. package/npm-shrinkwrap.json +2 -2
  211. package/package.json +2 -1
@@ -1,5 +1,30 @@
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
+ * @created 2024-10-01
7
+ * @version 2.1.1
8
+ * @license Apache-2.0
9
+ *
10
+ * Copyright 2024, 2025, 2026 Luca Liguori.
11
+ *
12
+ * Licensed under the Apache License, Version 2.0 (the "License");
13
+ * you may not use this file except in compliance with the License.
14
+ * You may obtain a copy of the License at
15
+ *
16
+ * http://www.apache.org/licenses/LICENSE-2.0
17
+ *
18
+ * Unless required by applicable law or agreed to in writing, software
19
+ * distributed under the License is distributed on an "AS IS" BASIS,
20
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
+ * See the License for the specific language governing permissions and
22
+ * limitations under the License.
23
+ */
24
+ // @matter
1
25
  import { Endpoint, Lifecycle, MutableEndpoint, NamedHandler, SupportedBehaviors, UINT16_MAX, UINT32_MAX, VendorId } from '@matter/main';
2
26
  import { getClusterNameById, MeasurementType } from '@matter/main/types';
27
+ // @matter clusters
3
28
  import { Descriptor } from '@matter/main/clusters/descriptor';
4
29
  import { PowerSource } from '@matter/main/clusters/power-source';
5
30
  import { BridgedDeviceBasicInformation } from '@matter/main/clusters/bridged-device-basic-information';
@@ -26,6 +51,7 @@ import { ThermostatUserInterfaceConfiguration } from '@matter/main/clusters/ther
26
51
  import { OperationalState } from '@matter/main/clusters/operational-state';
27
52
  import { DeviceEnergyManagement } from '@matter/main/clusters/device-energy-management';
28
53
  import { DeviceEnergyManagementMode } from '@matter/main/clusters/device-energy-management-mode';
54
+ // @matter behaviors
29
55
  import { DescriptorServer } from '@matter/main/behaviors/descriptor';
30
56
  import { PowerSourceServer } from '@matter/main/behaviors/power-source';
31
57
  import { BridgedDeviceBasicInformationServer } from '@matter/main/behaviors/bridged-device-basic-information';
@@ -59,18 +85,39 @@ import { ResourceMonitoring } from '@matter/main/clusters/resource-monitoring';
59
85
  import { HepaFilterMonitoringServer } from '@matter/main/behaviors/hepa-filter-monitoring';
60
86
  import { ActivatedCarbonFilterMonitoringServer } from '@matter/main/behaviors/activated-carbon-filter-monitoring';
61
87
  import { ThermostatUserInterfaceConfigurationServer } from '@matter/main/behaviors/thermostat-user-interface-configuration';
88
+ // AnsiLogger module
62
89
  import { AnsiLogger, CYAN, YELLOW, db, debugStringify, hk, or, zb } from './logger/export.js';
90
+ // Matterbridge
63
91
  import { bridgedNode } from './matterbridgeDeviceTypes.js';
64
92
  import { isValidNumber, isValidObject, isValidString } from './utils/export.js';
65
93
  import { MatterbridgeServer, MatterbridgeIdentifyServer, MatterbridgeOnOffServer, MatterbridgeLevelControlServer, MatterbridgeColorControlServer, MatterbridgeLiftWindowCoveringServer, MatterbridgeLiftTiltWindowCoveringServer, MatterbridgeThermostatServer, MatterbridgeFanControlServer, MatterbridgeDoorLockServer, MatterbridgeModeSelectServer, MatterbridgeValveConfigurationAndControlServer, MatterbridgeSmokeCoAlarmServer, MatterbridgeBooleanStateConfigurationServer, MatterbridgeSwitchServer, MatterbridgeOperationalStateServer, MatterbridgeDeviceEnergyManagementModeServer, MatterbridgeDeviceEnergyManagementServer, } from './matterbridgeBehaviors.js';
66
94
  import { addClusterServers, addFixedLabel, addOptionalClusterServers, addRequiredClusterServers, addUserLabel, createUniqueId, getBehavior, getBehaviourTypesFromClusterClientIds, getBehaviourTypesFromClusterServerIds, getDefaultOperationalStateClusterServer, getDefaultFlowMeasurementClusterServer, getDefaultIlluminanceMeasurementClusterServer, getDefaultPressureMeasurementClusterServer, getDefaultRelativeHumidityMeasurementClusterServer, getDefaultTemperatureMeasurementClusterServer, getDefaultOccupancySensingClusterServer, lowercaseFirstLetter, updateAttribute, getClusterId, getAttributeId, setAttribute, getAttribute, checkNotLatinCharacters, generateUniqueId, subscribeAttribute, invokeBehaviorCommand, triggerEvent, } from './matterbridgeEndpointHelpers.js';
67
95
  export class MatterbridgeEndpoint extends Endpoint {
96
+ /** The bridge mode of Matterbridge */
68
97
  static bridgeMode = '';
69
- static logLevel = "info";
98
+ /** The default log level of the new MatterbridgeEndpoints */
99
+ static logLevel = "info" /* LogLevel.INFO */;
100
+ /**
101
+ * Activates a special mode for this endpoint.
102
+ * - 'server': it creates the device server node and add the device as Matter device that needs to be paired individually.
103
+ * In this case the bridge mode is not relevant. The device is autonomous. The main use case is a workaround for the Apple Home rvc issue.
104
+ *
105
+ * - 'matter': it adds the device directly to the bridge server node as Matter device. In this case the implementation must respect
106
+ * the 9.2.3. Disambiguation rule (i.e. use taglist if needed cause the device doesn't have nodeLabel).
107
+ * Furthermore the device will be a part of the bridge (i.e. will have the same name and will be in the same room).
108
+ * See 9.12.2.2. Native Matter functionality in Bridge.
109
+ *
110
+ * @remarks
111
+ * Always use createDefaultBasicInformationClusterServer() to create the BasicInformation cluster server.
112
+ */
70
113
  mode = undefined;
114
+ /** The server node of the endpoint, if it is a single not bridged endpoint */
71
115
  serverNode;
116
+ /** The logger instance for the MatterbridgeEndpoint */
72
117
  log;
118
+ /** The plugin name this MatterbridgeEndpoint belongs to */
73
119
  plugin = undefined;
120
+ /** The configuration URL of the device, if available */
74
121
  configUrl = undefined;
75
122
  deviceName = undefined;
76
123
  serialNumber = undefined;
@@ -84,14 +131,28 @@ export class MatterbridgeEndpoint extends Endpoint {
84
131
  hardwareVersion = undefined;
85
132
  hardwareVersionString = undefined;
86
133
  productUrl = 'https://www.npmjs.com/package/matterbridge';
134
+ /** The name of the first device type of the endpoint (old api compatibility) */
87
135
  name = undefined;
136
+ /** The code of the first device type of the endpoint (old api compatibility) */
88
137
  deviceType = undefined;
138
+ /** The original id (with spaces and .) of the endpoint (old api compatibility) */
89
139
  uniqueStorageKey = undefined;
90
140
  tagList = undefined;
141
+ /** Maps the DeviceTypeDefinitions with their code */
91
142
  deviceTypes = new Map();
143
+ /** Command handler for the MatterbridgeEndpoint commands */
92
144
  commandHandler = new NamedHandler();
145
+ /**
146
+ * Represents a MatterbridgeEndpoint.
147
+ *
148
+ * @class MatterbridgeEndpoint
149
+ * @param {DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>} definition - The DeviceTypeDefinition(s) of the endpoint.
150
+ * @param {MatterbridgeEndpointOptions} [options] - The options for the device.
151
+ * @param {boolean} [debug] - Debug flag.
152
+ */
93
153
  constructor(definition, options = {}, debug = false) {
94
154
  let deviceTypeList = [];
155
+ // Get the first DeviceTypeDefinition
95
156
  let firstDefinition;
96
157
  if (Array.isArray(definition)) {
97
158
  firstDefinition = definition[0];
@@ -104,6 +165,7 @@ export class MatterbridgeEndpoint extends Endpoint {
104
165
  firstDefinition = definition;
105
166
  deviceTypeList = [{ deviceType: firstDefinition.code, revision: firstDefinition.revision }];
106
167
  }
168
+ // Convert the first DeviceTypeDefinition to an EndpointType.Options
107
169
  const deviceTypeDefinitionV8 = {
108
170
  name: firstDefinition.name.replace('-', '_'),
109
171
  deviceType: firstDefinition.code,
@@ -122,17 +184,20 @@ export class MatterbridgeEndpoint extends Endpoint {
122
184
  behaviors: options.tagList ? SupportedBehaviors(DescriptorServer.with(Descriptor.Feature.TagList)) : {},
123
185
  };
124
186
  const endpointV8 = MutableEndpoint(deviceTypeDefinitionV8);
187
+ // Check if the uniqueStorageKey is valid
125
188
  if (options.uniqueStorageKey && checkNotLatinCharacters(options.uniqueStorageKey)) {
126
189
  options.uniqueStorageKey = generateUniqueId(options.uniqueStorageKey);
127
190
  }
128
191
  if (options.id && checkNotLatinCharacters(options.id)) {
129
192
  options.id = generateUniqueId(options.id);
130
193
  }
194
+ // Convert the options to an Endpoint.Options
131
195
  const optionsV8 = {
132
196
  id: options.uniqueStorageKey?.replace(/[ .]/g, ''),
133
197
  number: options.endpointId,
134
198
  descriptor: options.tagList ? { tagList: options.tagList, deviceTypeList } : { deviceTypeList },
135
199
  };
200
+ // Override the deprecated uniqueStorageKey && endpointId with id and number if provided
136
201
  if (options.id !== undefined) {
137
202
  optionsV8.id = options.id.replace(/[ .]/g, '');
138
203
  }
@@ -152,16 +217,40 @@ export class MatterbridgeEndpoint extends Endpoint {
152
217
  }
153
218
  else
154
219
  this.deviceTypes.set(firstDefinition.code, firstDefinition);
155
- this.log = new AnsiLogger({ logName: options.uniqueStorageKey ?? 'MatterbridgeEndpoint', logTimestampFormat: 4, logLevel: debug === true ? "debug" : MatterbridgeEndpoint.logLevel });
220
+ // console.log('MatterbridgeEndpoint.option', options);
221
+ // console.log('MatterbridgeEndpoint.endpointV8', endpointV8);
222
+ // console.log('MatterbridgeEndpoint.optionsV8', optionsV8);
223
+ // Create the logger
224
+ this.log = new AnsiLogger({ logName: options.uniqueStorageKey ?? 'MatterbridgeEndpoint', logTimestampFormat: 4 /* TimestampFormat.TIME_MILLIS */, logLevel: debug === true ? "debug" /* LogLevel.DEBUG */ : MatterbridgeEndpoint.logLevel });
156
225
  this.log.debug(`${YELLOW}new${db} MatterbridgeEndpoint: ${zb}${'0x' + firstDefinition.code.toString(16).padStart(4, '0')}${db}-${zb}${firstDefinition.name}${db} mode: ${CYAN}${this.mode}${db} id: ${CYAN}${optionsV8.id}${db} number: ${CYAN}${optionsV8.number}${db} taglist: ${CYAN}${options.tagList ? debugStringify(options.tagList) : 'undefined'}${db}`);
226
+ // Add MatterbridgeServer
157
227
  this.behaviors.require(MatterbridgeServer, { log: this.log, commandHandler: this.commandHandler });
158
228
  }
229
+ /**
230
+ * Loads an instance of the MatterbridgeEndpoint class.
231
+ *
232
+ * @param {DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>} definition - The DeviceTypeDefinition(s) of the device.
233
+ * @param {MatterbridgeEndpointOptions} [options] - The options for the device.
234
+ * @param {boolean} [debug] - Debug flag.
235
+ * @returns {Promise<MatterbridgeEndpoint>} MatterbridgeEndpoint instance.
236
+ */
159
237
  static async loadInstance(definition, options = {}, debug = false) {
160
238
  return new MatterbridgeEndpoint(definition, options, debug);
161
239
  }
240
+ /**
241
+ * Get all the device types of this endpoint.
242
+ *
243
+ * @returns {DeviceTypeDefinition[]} The device types of this endpoint.
244
+ */
162
245
  getDeviceTypes() {
163
246
  return Array.from(this.deviceTypes.values());
164
247
  }
248
+ /**
249
+ * Checks if the provided cluster server is supported by this endpoint.
250
+ *
251
+ * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to check.
252
+ * @returns {boolean} True if the cluster server is supported, false otherwise.
253
+ */
165
254
  hasClusterServer(cluster) {
166
255
  const behavior = getBehavior(this, cluster);
167
256
  if (behavior)
@@ -169,6 +258,13 @@ export class MatterbridgeEndpoint extends Endpoint {
169
258
  else
170
259
  return false;
171
260
  }
261
+ /**
262
+ * Checks if the provided attribute server is supported for a given cluster of this endpoint.
263
+ *
264
+ * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to check.
265
+ * @param {string} attribute - The attribute name to check.
266
+ * @returns {boolean} True if the attribute server is supported, false otherwise.
267
+ */
172
268
  hasAttributeServer(cluster, attribute) {
173
269
  const behavior = getBehavior(this, cluster);
174
270
  if (!behavior || !this.behaviors.supported[behavior.id])
@@ -177,82 +273,239 @@ export class MatterbridgeEndpoint extends Endpoint {
177
273
  const defaults = this.behaviors.defaultsFor(behavior);
178
274
  return lowercaseFirstLetter(attribute) in options || lowercaseFirstLetter(attribute) in defaults;
179
275
  }
276
+ /**
277
+ * Retrieves the initial options for the provided cluster server.
278
+ *
279
+ * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to get options for.
280
+ * @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.
281
+ */
180
282
  getClusterServerOptions(cluster) {
181
283
  const behavior = getBehavior(this, cluster);
182
284
  if (!behavior)
183
285
  return undefined;
184
286
  return this.behaviors.optionsFor(behavior);
185
287
  }
288
+ /**
289
+ * Retrieves the value of the provided attribute from the given cluster.
290
+ *
291
+ * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to retrieve the attribute from.
292
+ * @param {string} attribute - The name of the attribute to retrieve.
293
+ * @param {AnsiLogger} [log] - Optional logger for error and info messages.
294
+ * @returns {any} The value of the attribute, or undefined if the attribute is not found.
295
+ */
296
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
186
297
  getAttribute(cluster, attribute, log) {
187
298
  return getAttribute(this, cluster, attribute, log);
188
299
  }
300
+ /**
301
+ * Sets the value of an attribute on a cluster server.
302
+ *
303
+ * @param {Behavior.Type | ClusterType | ClusterId | string} clusterId - The ID of the cluster.
304
+ * @param {string} attribute - The name of the attribute.
305
+ * @param {boolean | number | bigint | string | object | null} value - The value to set for the attribute.
306
+ * @param {AnsiLogger} [log] - (Optional) The logger to use for logging errors and information.
307
+ * @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the attribute was successfully set.
308
+ */
189
309
  async setAttribute(clusterId, attribute, value, log) {
190
310
  return await setAttribute(this, clusterId, attribute, value, log);
191
311
  }
312
+ /**
313
+ * Update the value of an attribute on a cluster server only if the value is different.
314
+ *
315
+ * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to set the attribute on.
316
+ * @param {string} attribute - The name of the attribute.
317
+ * @param {boolean | number | bigint | string | object | null} value - The value to set for the attribute.
318
+ * @param {AnsiLogger} [log] - (Optional) The logger to use for logging the update. Errors are logged to the endpoint logger.
319
+ * @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the attribute was successfully set.
320
+ */
192
321
  async updateAttribute(cluster, attribute, value, log) {
193
322
  return await updateAttribute(this, cluster, attribute, value, log);
194
323
  }
324
+ /**
325
+ * Subscribes to the provided attribute on a cluster.
326
+ *
327
+ * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to subscribe the attribute to.
328
+ * @param {string} attribute - The name of the attribute to subscribe to.
329
+ * @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.
330
+ * @param {AnsiLogger} [log] - Optional logger for logging errors and information.
331
+ * @returns {Promise<boolean>} - A boolean indicating whether the subscription was successful.
332
+ *
333
+ * @remarks The listener function (cannot be async) will receive three parameters:
334
+ * - `newValue`: The new value of the attribute.
335
+ * - `oldValue`: The old value of the attribute.
336
+ * - `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.
337
+ */
338
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
195
339
  async subscribeAttribute(cluster, attribute, listener, log) {
196
340
  return await subscribeAttribute(this, cluster, attribute, listener, log);
197
341
  }
342
+ /**
343
+ * Triggers an event on the specified cluster.
344
+ *
345
+ * @param {ClusterId} cluster - The ID of the cluster.
346
+ * @param {string} event - The name of the event to trigger.
347
+ * @param {Record<string, boolean | number | bigint | string | object | undefined | null>} payload - The payload to pass to the event.
348
+ * @param {AnsiLogger} [log] - Optional logger for logging information.
349
+ * @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the event was successfully triggered.
350
+ */
198
351
  async triggerEvent(cluster, event, payload, log) {
199
352
  return await triggerEvent(this, cluster, event, payload, log);
200
353
  }
354
+ /**
355
+ * Adds cluster servers from the provided server list.
356
+ *
357
+ * @param {ClusterId[]} serverList - The list of cluster IDs to add.
358
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
359
+ */
201
360
  addClusterServers(serverList) {
202
361
  addClusterServers(this, serverList);
203
362
  return this;
204
363
  }
364
+ /**
365
+ * Adds a fixed label to the FixedLabel cluster. If the cluster server is not present, it will be added.
366
+ *
367
+ * @param {string} label - The label to add.
368
+ * @param {string} value - The value of the label.
369
+ * @returns {Promise<this>} The current MatterbridgeEndpoint instance for chaining.
370
+ */
205
371
  async addFixedLabel(label, value) {
206
372
  await addFixedLabel(this, label, value);
207
373
  return this;
208
374
  }
375
+ /**
376
+ * Adds a user label to the UserLabel cluster. If the cluster server is not present, it will be added.
377
+ *
378
+ * @param {string} label - The label to add.
379
+ * @param {string} value - The value of the label.
380
+ * @returns {Promise<this>} The current MatterbridgeEndpoint instance for chaining.
381
+ */
209
382
  async addUserLabel(label, value) {
210
383
  await addUserLabel(this, label, value);
211
384
  return this;
212
385
  }
386
+ /**
387
+ * Adds a command handler for the specified command.
388
+ *
389
+ * @param {keyof MatterbridgeEndpointCommands} command - The command to add the handler for.
390
+ * @param {CommandHandlerFunction} handler - The handler function to execute when the command is received.
391
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
392
+ *
393
+ * @remarks
394
+ * The handler function will receive an object with the following properties:
395
+ * - `request`: The request object sent with the command.
396
+ * - `cluster`: The id of the cluster that received the command (i.e. "onOff").
397
+ * - `attributes`: The current attributes of the cluster that received the command (i.e. { onOff: true}).
398
+ * - `endpoint`: The MatterbridgeEndpoint instance that received the command.
399
+ */
213
400
  addCommandHandler(command, handler) {
214
401
  this.commandHandler.addHandler(command, handler);
215
402
  return this;
216
403
  }
404
+ /**
405
+ * Execute the command handler for the specified command. Used ONLY in Jest tests.
406
+ *
407
+ * @param {keyof MatterbridgeEndpointCommands} command - The command to execute.
408
+ * @param {Record<string, boolean | number | bigint | string | object | null>} [request] - The optional request to pass to the handler function.
409
+ * @param {string} [cluster] - The optional cluster to pass to the handler function.
410
+ * @param {Record<string, boolean | number | bigint | string | object | null>} [attributes] - The optional attributes to pass to the handler function.
411
+ * @param {MatterbridgeEndpoint} [endpoint] - The optional MatterbridgeEndpoint instance to pass to the handler function
412
+ *
413
+ * @deprecated Used ONLY in Jest tests.
414
+ */
217
415
  async executeCommandHandler(command, request, cluster, attributes, endpoint) {
218
416
  await this.commandHandler.executeHandler(command, { request, cluster, attributes, endpoint });
219
417
  }
418
+ /**
419
+ * Invokes a behavior command on the specified cluster. Used ONLY in Jest tests.
420
+ *
421
+ * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to invoke the command on.
422
+ * @param {string} command - The command to invoke.
423
+ * @param {Record<string, boolean | number | bigint | string | object | null>} [params] - The optional parameters to pass to the command.
424
+ *
425
+ * @deprecated Used ONLY in Jest tests.
426
+ */
220
427
  async invokeBehaviorCommand(cluster, command, params) {
221
428
  await invokeBehaviorCommand(this, cluster, command, params);
222
429
  }
430
+ /**
431
+ * Adds the required cluster servers (only if they are not present) for the device types of the specified endpoint.
432
+ *
433
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
434
+ */
223
435
  addRequiredClusterServers() {
224
436
  addRequiredClusterServers(this);
225
437
  return this;
226
438
  }
439
+ /**
440
+ * Adds the optional cluster servers (only if they are not present) for the device types of the specified endpoint.
441
+ *
442
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
443
+ */
227
444
  addOptionalClusterServers() {
228
445
  addOptionalClusterServers(this);
229
446
  return this;
230
447
  }
448
+ /**
449
+ * Retrieves all cluster servers.
450
+ *
451
+ * @returns {Behavior.Type[]} An array of all cluster servers.
452
+ */
231
453
  getAllClusterServers() {
232
454
  return Object.values(this.behaviors.supported);
233
455
  }
456
+ /**
457
+ * Retrieves the names of all cluster servers.
458
+ *
459
+ * @returns {string[]} An array of all cluster server names.
460
+ */
234
461
  getAllClusterServerNames() {
235
462
  return Object.keys(this.behaviors.supported);
236
463
  }
464
+ /**
465
+ * Iterates over each attribute of each cluster server of the device state and calls the provided callback function.
466
+ *
467
+ * @param {Function} callback - The callback function to call with the cluster name, cluster id, attribute name, attribute id and attribute value.
468
+ */
237
469
  forEachAttribute(callback) {
238
470
  if (!this.lifecycle.isReady || this.construction.status !== Lifecycle.Status.Active)
239
471
  return;
240
472
  for (const [clusterName, clusterAttributes] of Object.entries(this.state)) {
473
+ // Skip if the key / cluster name is a number, cause they are double indexed.
241
474
  if (!isNaN(Number(clusterName)))
242
475
  continue;
243
476
  for (const [attributeName, attributeValue] of Object.entries(clusterAttributes)) {
477
+ // Skip if the behavior has no associated cluster (i.e. matterbridge server)
244
478
  const clusterId = getClusterId(this, clusterName);
245
479
  if (clusterId === undefined) {
480
+ // this.log.debug(`***forEachAttribute: cluster ${clusterName} not found`);
246
481
  continue;
247
482
  }
483
+ // Skip if the attribute is not present in the ClusterBehavior.Type. Also skip if the attribute it is an internal state.
248
484
  const attributeId = getAttributeId(this, clusterName, attributeName);
249
485
  if (attributeId === undefined) {
486
+ // this.log.debug(`***forEachAttribute: attribute ${clusterName}.${attributeName} not found`);
250
487
  continue;
251
488
  }
252
489
  callback(clusterName, clusterId, attributeName, attributeId, attributeValue);
253
490
  }
254
491
  }
255
492
  }
493
+ /**
494
+ * Adds a child endpoint with the specified device types and options.
495
+ * If the child endpoint is not already present, it will be created and added.
496
+ * If the child endpoint is already present, the existing child endpoint will be returned.
497
+ *
498
+ * @param {string} endpointName - The name of the new endpoint to add.
499
+ * @param {DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>} definition - The device types to add.
500
+ * @param {MatterbridgeEndpointOptions} [options] - The options for the endpoint.
501
+ * @param {boolean} [debug] - Whether to enable debug logging.
502
+ * @returns {MatterbridgeEndpoint} - The child endpoint that was found or added.
503
+ *
504
+ * @example
505
+ * ```typescript
506
+ * const endpoint = device.addChildDeviceType('Temperature', [temperatureSensor], { tagList: [{ mfgCode: null, namespaceId: LocationTag.Indoor.namespaceId, tag: LocationTag.Indoor.tag, label: null }] }, true);
507
+ * ```
508
+ */
256
509
  addChildDeviceType(endpointName, definition, options = {}, debug = false) {
257
510
  this.log.debug(`addChildDeviceType: ${CYAN}${endpointName}${db}`);
258
511
  let alreadyAdded = false;
@@ -292,6 +545,23 @@ export class MatterbridgeEndpoint extends Endpoint {
292
545
  }
293
546
  return child;
294
547
  }
548
+ /**
549
+ * Adds a child endpoint with one or more device types with the required cluster servers and the specified cluster servers.
550
+ * If the child endpoint is not already present in the childEndpoints, it will be added.
551
+ * If the child endpoint is already present in the childEndpoints, the device types and cluster servers will be added to the existing child endpoint.
552
+ *
553
+ * @param {string} endpointName - The name of the new enpoint to add.
554
+ * @param {DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>} definition - The device types to add.
555
+ * @param {ClusterId[]} [serverList] - The list of cluster IDs to include.
556
+ * @param {MatterbridgeEndpointOptions} [options] - The options for the device.
557
+ * @param {boolean} [debug] - Whether to enable debug logging.
558
+ * @returns {MatterbridgeEndpoint} - The child endpoint that was found or added.
559
+ *
560
+ * @example
561
+ * ```typescript
562
+ * const endpoint = device.addChildDeviceTypeWithClusterServer('Temperature', [temperatureSensor], [], { tagList: [{ mfgCode: null, namespaceId: LocationTag.Indoor.namespaceId, tag: LocationTag.Indoor.tag, label: null }] }, true);
563
+ * ```
564
+ */
295
565
  addChildDeviceTypeWithClusterServer(endpointName, definition, serverList = [], options = {}, debug = false) {
296
566
  this.log.debug(`addChildDeviceTypeWithClusterServer: ${CYAN}${endpointName}${db}`);
297
567
  let alreadyAdded = false;
@@ -354,15 +624,39 @@ export class MatterbridgeEndpoint extends Endpoint {
354
624
  }
355
625
  return child;
356
626
  }
627
+ /**
628
+ * Retrieves a child endpoint by its name.
629
+ *
630
+ * @param {string} endpointName - The name of the endpoint to retrieve.
631
+ * @returns {Endpoint | undefined} The child endpoint with the specified name, or undefined if not found.
632
+ */
357
633
  getChildEndpointByName(endpointName) {
358
634
  return this.parts.find((part) => part.id === endpointName);
359
635
  }
636
+ /**
637
+ * Retrieves a child endpoint by its EndpointNumber.
638
+ *
639
+ * @param {EndpointNumber} endpointNumber - The EndpointNumber of the endpoint to retrieve.
640
+ * @returns {MatterbridgeEndpoint | undefined} The child endpoint with the specified EndpointNumber, or undefined if not found.
641
+ */
360
642
  getChildEndpoint(endpointNumber) {
361
643
  return this.parts.find((part) => part.number === endpointNumber);
362
644
  }
645
+ /**
646
+ * Get all the child endpoints of this endpoint.
647
+ *
648
+ * @returns {MatterbridgeEndpoint[]} The child endpoints.
649
+ */
363
650
  getChildEndpoints() {
364
651
  return Array.from(this.parts);
365
652
  }
653
+ /**
654
+ * Serializes the Matterbridge device into a serialized object.
655
+ *
656
+ * @param {MatterbridgeEndpoint} device - The Matterbridge device to serialize.
657
+ *
658
+ * @returns {SerializedMatterbridgeEndpoint | undefined} The serialized Matterbridge device object.
659
+ */
366
660
  static serialize(device) {
367
661
  if (!device.serialNumber || !device.deviceName || !device.uniqueId)
368
662
  return;
@@ -385,9 +679,16 @@ export class MatterbridgeEndpoint extends Endpoint {
385
679
  serialized.clusterServersId.push(BridgedDeviceBasicInformation.Cluster.id);
386
680
  if (behaviorName === 'powerSource')
387
681
  serialized.clusterServersId.push(PowerSource.Cluster.id);
682
+ // serialized.clusterServersId.push(this.behaviors.supported[behaviorName]cluster.id);
388
683
  });
389
684
  return serialized;
390
685
  }
686
+ /**
687
+ * Deserializes the device into a serialized object.
688
+ *
689
+ * @param {SerializedMatterbridgeEndpoint} serializedDevice - The serialized Matterbridge device object.
690
+ * @returns {MatterbridgeEndpoint | undefined} The deserialized Matterbridge device.
691
+ */
391
692
  static deserialize(serializedDevice) {
392
693
  const device = new MatterbridgeEndpoint(serializedDevice.deviceTypes, { uniqueStorageKey: serializedDevice.endpointName, endpointId: serializedDevice.endpoint }, false);
393
694
  device.plugin = serializedDevice.pluginName;
@@ -403,55 +704,122 @@ export class MatterbridgeEndpoint extends Endpoint {
403
704
  device.createDefaultBridgedDeviceBasicInformationClusterServer(serializedDevice.deviceName, serializedDevice.serialNumber, serializedDevice.vendorId ?? 0xfff1, serializedDevice.vendorName ?? 'Matterbridge', serializedDevice.productName ?? 'Matterbridge device');
404
705
  else if (clusterId === PowerSource.Cluster.id)
405
706
  device.createDefaultPowerSourceWiredClusterServer();
707
+ // else addClusterServerFromList(device, [clusterId]);
406
708
  }
407
709
  return device;
408
710
  }
711
+ /**
712
+ * Creates a default power source wired cluster server.
713
+ *
714
+ * @param {PowerSource.WiredCurrentType} wiredCurrentType - The type of wired current (default: PowerSource.WiredCurrentType.Ac)
715
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
716
+ *
717
+ * @remarks
718
+ * - order: The order of the power source is a persisted attribute that indicates the order in which the power sources are used.
719
+ * - description: The description of the power source is a fixed attribute that describes the power source type.
720
+ * - wiredCurrentType: The type of wired current is a fixed attribute that indicates the type of wired current used by the power source (AC or DC).
721
+ */
409
722
  createDefaultPowerSourceWiredClusterServer(wiredCurrentType = PowerSource.WiredCurrentType.Ac) {
410
723
  this.behaviors.require(PowerSourceServer.with(PowerSource.Feature.Wired), {
724
+ // Base attributes
411
725
  status: PowerSource.PowerSourceStatus.Active,
412
726
  order: 0,
413
727
  description: wiredCurrentType === PowerSource.WiredCurrentType.Ac ? 'AC Power' : 'DC Power',
414
728
  endpointList: [],
729
+ // Wired feature attributes
415
730
  wiredCurrentType,
416
731
  });
417
732
  return this;
418
733
  }
734
+ /**
735
+ * Creates a default power source replaceable battery cluster server.
736
+ *
737
+ * @param {number} batPercentRemaining - The remaining battery percentage (default: 100).
738
+ * @param {PowerSource.BatChargeLevel} batChargeLevel - The battery charge level (default: PowerSource.BatChargeLevel.Ok).
739
+ * @param {number} batVoltage - The battery voltage (default: 1500).
740
+ * @param {string} batReplacementDescription - The description of the battery replacement (default: 'Battery type').
741
+ * @param {number} batQuantity - The quantity of the battery (default: 1).
742
+ * @param {PowerSource.BatReplaceability} batReplaceability - The replaceability of the battery (default: PowerSource.BatReplaceability.Unspecified).
743
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
744
+ *
745
+ * @remarks
746
+ * - order: The order of the power source is a persisted attribute that indicates the order in which the power sources are used.
747
+ * - description: The description of the power source is a fixed attribute that describes the power source type.
748
+ * - batReplaceability: The replaceability of the battery is a fixed attribute that indicates whether the battery is user-replaceable or not.
749
+ * - batReplacementDescription: The description of the battery replacement is a fixed attribute that describes the battery type.
750
+ * - batQuantity: The quantity of the battery is a fixed attribute that indicates how many batteries are present in the device.
751
+ */
419
752
  createDefaultPowerSourceReplaceableBatteryClusterServer(batPercentRemaining = 100, batChargeLevel = PowerSource.BatChargeLevel.Ok, batVoltage = 1500, batReplacementDescription = 'Battery type', batQuantity = 1, batReplaceability = PowerSource.BatReplaceability.UserReplaceable) {
420
753
  this.behaviors.require(PowerSourceServer.with(PowerSource.Feature.Battery, PowerSource.Feature.Replaceable), {
754
+ // Base attributes
421
755
  status: PowerSource.PowerSourceStatus.Active,
422
756
  order: 0,
423
757
  description: 'Primary battery',
424
758
  endpointList: [],
759
+ // Battery feature attributes
425
760
  batVoltage,
426
761
  batPercentRemaining: Math.min(Math.max(batPercentRemaining * 2, 0), 200),
427
762
  batChargeLevel,
428
763
  batReplacementNeeded: false,
429
764
  batReplaceability,
430
765
  activeBatFaults: undefined,
766
+ // Replaceable feature attributes
431
767
  batReplacementDescription,
432
768
  batQuantity,
433
769
  });
434
770
  return this;
435
771
  }
772
+ /**
773
+ * Creates a default power source rechargeable battery cluster server.
774
+ *
775
+ * @param {number} [batPercentRemaining] - The remaining battery percentage (default: 100).
776
+ * @param {PowerSource.BatChargeLevel} [batChargeLevel] - The battery charge level (default: PowerSource.BatChargeLevel.Ok).
777
+ * @param {number} [batVoltage] - The battery voltage in mV (default: 1500).
778
+ * @param {PowerSource.BatReplaceability} [batReplaceability] - The replaceability of the battery (default: PowerSource.BatReplaceability.Unspecified).
779
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
780
+ *
781
+ * @remarks
782
+ * - order: The order of the power source is a persisted attribute that indicates the order in which the power sources are used.
783
+ * - description: The description of the power source is a fixed attribute that describes the power source type.
784
+ * - batReplaceability: The replaceability of the battery is a fixed attribute that indicates whether the battery is user-replaceable or not.
785
+ */
436
786
  createDefaultPowerSourceRechargeableBatteryClusterServer(batPercentRemaining = 100, batChargeLevel = PowerSource.BatChargeLevel.Ok, batVoltage = 1500, batReplaceability = PowerSource.BatReplaceability.Unspecified) {
437
787
  this.behaviors.require(PowerSourceServer.with(PowerSource.Feature.Battery, PowerSource.Feature.Rechargeable), {
788
+ // Base attributes
438
789
  status: PowerSource.PowerSourceStatus.Active,
439
790
  order: 0,
440
791
  description: 'Primary battery',
441
792
  endpointList: [],
793
+ // Battery feature attributes
442
794
  batVoltage,
443
795
  batPercentRemaining: Math.min(Math.max(batPercentRemaining * 2, 0), 200),
444
- batTimeRemaining: null,
796
+ batTimeRemaining: null, // Indicates the estimated time in seconds before the battery will no longer be able to provide power to the Node
445
797
  batChargeLevel,
446
798
  batReplacementNeeded: false,
447
799
  batReplaceability,
448
800
  batPresent: true,
449
801
  activeBatFaults: [],
802
+ // Rechargeable feature attributes
450
803
  batChargeState: PowerSource.BatChargeState.IsNotCharging,
451
804
  batFunctionalWhileCharging: true,
452
805
  });
453
806
  return this;
454
807
  }
808
+ /**
809
+ * Setup the default Basic Information Cluster Server attributes for the server node.
810
+ *
811
+ * @param {string} deviceName - The name of the device.
812
+ * @param {string} serialNumber - The serial number of the device.
813
+ * @param {number} [vendorId] - The vendor ID of the device. Default is 0xfff1 (Matter Test VendorId).
814
+ * @param {string} [vendorName] - The name of the vendor. Default is 'Matterbridge'.
815
+ * @param {number} [productId] - The product ID of the device. Default is 0x8000 (Matter Test ProductId).
816
+ * @param {string} [productName] - The name of the product. Default is 'Matterbridge device'.
817
+ * @param {number} [softwareVersion] - The software version of the device. Default is 1.
818
+ * @param {string} [softwareVersionString] - The software version string of the device. Default is '1.0.0'.
819
+ * @param {number} [hardwareVersion] - The hardware version of the device. Default is 1.
820
+ * @param {string} [hardwareVersionString] - The hardware version string of the device. Default is '1.0.0'.
821
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
822
+ */
455
823
  createDefaultBasicInformationClusterServer(deviceName, serialNumber, vendorId = 0xfff1, vendorName = 'Matterbridge', productId = 0x8000, productName = 'Matterbridge device', softwareVersion = 1, softwareVersionString = '1.0.0', hardwareVersion = 1, hardwareVersionString = '1.0.0') {
456
824
  this.log.logName = deviceName;
457
825
  this.deviceName = deviceName;
@@ -475,6 +843,22 @@ export class MatterbridgeEndpoint extends Endpoint {
475
843
  }
476
844
  return this;
477
845
  }
846
+ /**
847
+ * Creates a default BridgedDeviceBasicInformationClusterServer for the aggregator endpoints.
848
+ *
849
+ * @param {string} deviceName - The name of the device.
850
+ * @param {string} serialNumber - The serial number of the device.
851
+ * @param {number} [vendorId] - The vendor ID of the device. Default is 0xfff1 (Matter Test VendorId).
852
+ * @param {string} [vendorName] - The name of the vendor. Default is 'Matterbridge'.
853
+ * @param {string} [productName] - The name of the product. Default is 'Matterbridge device'.
854
+ * @param {number} [softwareVersion] - The software version of the device. Default is 1.
855
+ * @param {string} [softwareVersionString] - The software version string of the device. Default is '1.0.0'.
856
+ * @param {number} [hardwareVersion] - The hardware version of the device. Default is 1.
857
+ * @param {string} [hardwareVersionString] - The hardware version string of the device. Default is '1.0.0'.
858
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
859
+ *
860
+ * @remarks The bridgedNode device type must be added to the deviceTypeList of the Descriptor cluster.
861
+ */
478
862
  createDefaultBridgedDeviceBasicInformationClusterServer(deviceName, serialNumber, vendorId = 0xfff1, vendorName = 'Matterbridge', productName = 'Matterbridge device', softwareVersion = 1, softwareVersionString = '1.0.0', hardwareVersion = 1, hardwareVersionString = '1.0.0') {
479
863
  this.log.logName = deviceName;
480
864
  this.deviceName = deviceName;
@@ -507,6 +891,13 @@ export class MatterbridgeEndpoint extends Endpoint {
507
891
  });
508
892
  return this;
509
893
  }
894
+ /**
895
+ * Creates a default identify cluster server with the specified identify time and type.
896
+ *
897
+ * @param {number} [identifyTime] - The time to identify the server. Defaults to 0.
898
+ * @param {Identify.IdentifyType} [identifyType] - The type of identification. Defaults to Identify.IdentifyType.None.
899
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
900
+ */
510
901
  createDefaultIdentifyClusterServer(identifyTime = 0, identifyType = Identify.IdentifyType.None) {
511
902
  this.behaviors.require(MatterbridgeIdentifyServer, {
512
903
  identifyTime,
@@ -514,14 +905,36 @@ export class MatterbridgeEndpoint extends Endpoint {
514
905
  });
515
906
  return this;
516
907
  }
908
+ /**
909
+ * Creates a default groups cluster server.
910
+ *
911
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
912
+ */
517
913
  createDefaultGroupsClusterServer() {
518
914
  this.behaviors.require(GroupsServer);
519
915
  return this;
520
916
  }
917
+ /**
918
+ * Creates a default scenes management cluster server.
919
+ *
920
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
921
+ *
922
+ * @remarks The scenes management cluster server is still provisional and so not yet implemented.
923
+ */
521
924
  createDefaultScenesClusterServer() {
522
925
  this.behaviors.require(ScenesManagementServer);
523
926
  return this;
524
927
  }
928
+ /**
929
+ * Creates a default OnOff cluster server for light devices with feature Lighting.
930
+ *
931
+ * @param {boolean} [onOff] - The initial state of the OnOff cluster.
932
+ * @param {boolean} [globalSceneControl] - The global scene control state.
933
+ * @param {number} [onTime] - The on time value.
934
+ * @param {number} [offWaitTime] - The off wait time value.
935
+ * @param {OnOff.StartUpOnOff | null} [startUpOnOff] - The start-up OnOff state. Null means previous state.
936
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
937
+ */
525
938
  createDefaultOnOffClusterServer(onOff = false, globalSceneControl = false, onTime = 0, offWaitTime = 0, startUpOnOff = null) {
526
939
  this.behaviors.require(MatterbridgeOnOffServer.with(OnOff.Feature.Lighting), {
527
940
  onOff,
@@ -532,24 +945,52 @@ export class MatterbridgeEndpoint extends Endpoint {
532
945
  });
533
946
  return this;
534
947
  }
948
+ /**
949
+ * Creates an OnOff cluster server without features.
950
+ *
951
+ * @param {boolean} [onOff] - The initial state of the OnOff cluster.
952
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
953
+ */
535
954
  createOnOffClusterServer(onOff = false) {
536
955
  this.behaviors.require(MatterbridgeOnOffServer, {
537
956
  onOff,
538
957
  });
539
958
  return this;
540
959
  }
960
+ /**
961
+ * Creates a DeadFront OnOff cluster server with feature DeadFrontBehavior.
962
+ *
963
+ * @param {boolean} [onOff] - The initial state of the OnOff cluster.
964
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
965
+ */
541
966
  createDeadFrontOnOffClusterServer(onOff = false) {
542
967
  this.behaviors.require(MatterbridgeOnOffServer.with(OnOff.Feature.DeadFrontBehavior), {
543
968
  onOff,
544
969
  });
545
970
  return this;
546
971
  }
972
+ /**
973
+ * Creates an OffOnly OnOff cluster server with feature OffOnly.
974
+ *
975
+ * @param {boolean} [onOff] - The initial state of the OnOff cluster.
976
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
977
+ */
547
978
  createOffOnlyOnOffClusterServer(onOff = false) {
548
979
  this.behaviors.require(MatterbridgeOnOffServer.with(OnOff.Feature.OffOnly), {
549
980
  onOff,
550
981
  });
551
982
  return this;
552
983
  }
984
+ /**
985
+ * Creates a default level control cluster server for light devices with feature OnOff and Lighting.
986
+ *
987
+ * @param {number} [currentLevel] - The current level (default: 254).
988
+ * @param {number} [minLevel] - The minimum level (default: 1).
989
+ * @param {number} [maxLevel] - The maximum level (default: 254).
990
+ * @param {number | null} [onLevel] - The on level (default: null).
991
+ * @param {number | null} [startUpCurrentLevel] - The startUp on level (default: null).
992
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
993
+ */
553
994
  createDefaultLevelControlClusterServer(currentLevel = 254, minLevel = 1, maxLevel = 254, onLevel = null, startUpCurrentLevel = null) {
554
995
  this.behaviors.require(MatterbridgeLevelControlServer.with(LevelControl.Feature.OnOff, LevelControl.Feature.Lighting), {
555
996
  currentLevel,
@@ -565,6 +1006,13 @@ export class MatterbridgeEndpoint extends Endpoint {
565
1006
  });
566
1007
  return this;
567
1008
  }
1009
+ /**
1010
+ * Creates a level control cluster server without features.
1011
+ *
1012
+ * @param {number} [currentLevel] - The current level (default: 254).
1013
+ * @param {number | null} [onLevel] - The on level (default: null).
1014
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1015
+ */
568
1016
  createLevelControlClusterServer(currentLevel = 254, onLevel = null) {
569
1017
  this.behaviors.require(MatterbridgeLevelControlServer, {
570
1018
  currentLevel,
@@ -576,6 +1024,25 @@ export class MatterbridgeEndpoint extends Endpoint {
576
1024
  });
577
1025
  return this;
578
1026
  }
1027
+ /**
1028
+ * Creates a default color control cluster server with features Xy, HueSaturation and ColorTemperature.
1029
+ *
1030
+ * @param {number} currentX - The current X value (range 0-65279).
1031
+ * @param {number} currentY - The current Y value (range 0-65279).
1032
+ * @param {number} currentHue - The current hue value (range: 0-254).
1033
+ * @param {number} currentSaturation - The current saturation value (range: 0-254).
1034
+ * @param {number} colorTemperatureMireds - The color temperature in mireds (default range 147-500).
1035
+ * @param {number} colorTempPhysicalMinMireds - The physical minimum color temperature in mireds (default range 147).
1036
+ * @param {number} colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds (default range 500).
1037
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1038
+ *
1039
+ * @remarks colorMode and enhancedColorMode persist across restarts.
1040
+ * @remarks currentHue and currentSaturation persist across restarts.
1041
+ * @remarks currentX and currentY persist across restarts.
1042
+ * @remarks colorTemperatureMireds persists across restarts.
1043
+ * @remarks startUpColorTemperatureMireds persists across restarts.
1044
+ * @remarks coupleColorTempToLevelMinMireds persists across restarts.
1045
+ */
579
1046
  createDefaultColorControlClusterServer(currentX = 0, currentY = 0, currentHue = 0, currentSaturation = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
580
1047
  this.behaviors.require(MatterbridgeColorControlServer.with(ColorControl.Feature.Xy, ColorControl.Feature.HueSaturation, ColorControl.Feature.ColorTemperature), {
581
1048
  colorMode: ColorControl.ColorMode.CurrentHueAndCurrentSaturation,
@@ -598,6 +1065,25 @@ export class MatterbridgeEndpoint extends Endpoint {
598
1065
  });
599
1066
  return this;
600
1067
  }
1068
+ /**
1069
+ * Creates a Xy color control cluster server with feature Xy and ColorTemperature.
1070
+ *
1071
+ * @param {number} currentX - The current X value (range 0-65279).
1072
+ * @param {number} currentY - The current Y value (range 0-65279).
1073
+ * @param {number} colorTemperatureMireds - The color temperature in mireds (default range 147-500).
1074
+ * @param {number} colorTempPhysicalMinMireds - The physical minimum color temperature in mireds (default range 147).
1075
+ * @param {number} colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds (default range 500).
1076
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1077
+ *
1078
+ * @remarks
1079
+ * From zigbee to matter = Math.max(Math.min(Math.round(x * 65536), 65279), 0)
1080
+ *
1081
+ * @remarks colorMode and enhancedColorMode persist across restarts.
1082
+ * @remarks currentX and currentY persist across restarts.
1083
+ * @remarks colorTemperatureMireds persists across restarts.
1084
+ * @remarks startUpColorTemperatureMireds persists across restarts.
1085
+ * @remarks coupleColorTempToLevelMinMireds persists across restarts.
1086
+ */
601
1087
  createXyColorControlClusterServer(currentX = 0, currentY = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
602
1088
  this.behaviors.require(MatterbridgeColorControlServer.with(ColorControl.Feature.Xy, ColorControl.Feature.ColorTemperature), {
603
1089
  colorMode: ColorControl.ColorMode.CurrentXAndCurrentY,
@@ -618,6 +1104,22 @@ export class MatterbridgeEndpoint extends Endpoint {
618
1104
  });
619
1105
  return this;
620
1106
  }
1107
+ /**
1108
+ * Creates a default hue and saturation control cluster server with feature HueSaturation and ColorTemperature.
1109
+ *
1110
+ * @param {number} currentHue - The current hue value (range: 0-254).
1111
+ * @param {number} currentSaturation - The current saturation value (range: 0-254).
1112
+ * @param {number} colorTemperatureMireds - The color temperature in mireds (default range 147-500).
1113
+ * @param {number} colorTempPhysicalMinMireds - The physical minimum color temperature in mireds (default range 147).
1114
+ * @param {number} colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds (default range 500).
1115
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1116
+ *
1117
+ * @remarks colorMode and enhancedColorMode persist across restarts.
1118
+ * @remarks currentHue and currentSaturation persist across restarts.
1119
+ * @remarks colorTemperatureMireds persists across restarts.
1120
+ * @remarks startUpColorTemperatureMireds persists across restarts.
1121
+ * @remarks coupleColorTempToLevelMinMireds persists across restarts.
1122
+ */
621
1123
  createHsColorControlClusterServer(currentHue = 0, currentSaturation = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
622
1124
  this.behaviors.require(MatterbridgeColorControlServer.with(ColorControl.Feature.HueSaturation, ColorControl.Feature.ColorTemperature), {
623
1125
  colorMode: ColorControl.ColorMode.CurrentHueAndCurrentSaturation,
@@ -638,6 +1140,20 @@ export class MatterbridgeEndpoint extends Endpoint {
638
1140
  });
639
1141
  return this;
640
1142
  }
1143
+ /**
1144
+ * Creates a color temperature color control cluster server with feature ColorTemperature.
1145
+ * This cluster server is used for devices that only support color temperature control.
1146
+ *
1147
+ * @param {number} colorTemperatureMireds - The color temperature in mireds (default range 147-500).
1148
+ * @param {number} colorTempPhysicalMinMireds - The physical minimum color temperature in mireds (default range 147).
1149
+ * @param {number} colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds (default range 500).
1150
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1151
+ *
1152
+ * @remarks colorMode and enhancedColorMode persist across restarts.
1153
+ * @remarks colorTemperatureMireds persists across restarts.
1154
+ * @remarks startUpColorTemperatureMireds persists across restarts.
1155
+ * @remarks coupleColorTempToLevelMinMireds persists across restarts.
1156
+ */
641
1157
  createCtColorControlClusterServer(colorTemperatureMireds = 250, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
642
1158
  this.behaviors.require(MatterbridgeColorControlServer.with(ColorControl.Feature.ColorTemperature), {
643
1159
  colorMode: ColorControl.ColorMode.ColorTemperatureMireds,
@@ -656,15 +1172,34 @@ export class MatterbridgeEndpoint extends Endpoint {
656
1172
  });
657
1173
  return this;
658
1174
  }
1175
+ /**
1176
+ * Configures the color control mode for the device.
1177
+ *
1178
+ * @param {ColorControl.ColorMode} colorMode - The color mode to set.
1179
+ *
1180
+ * @remarks colorMode and enhancedColorMode persist across restarts.
1181
+ */
659
1182
  async configureColorControlMode(colorMode) {
660
1183
  if (isValidNumber(colorMode, ColorControl.ColorMode.CurrentHueAndCurrentSaturation, ColorControl.ColorMode.ColorTemperatureMireds)) {
661
1184
  await this.setAttribute(ColorControl.Cluster.id, 'colorMode', colorMode, this.log);
662
1185
  await this.setAttribute(ColorControl.Cluster.id, 'enhancedColorMode', colorMode, this.log);
663
1186
  }
664
1187
  }
1188
+ /**
1189
+ * Creates a default window covering cluster server with feature Lift and PositionAwareLift.
1190
+ *
1191
+ * @param {number} positionPercent100ths - The position percentage in 100ths (0-10000). Defaults to 0. Matter uses 10000 = fully closed 0 = fully opened.
1192
+ * @param {WindowCovering.WindowCoveringType} type - The type of window covering (default: WindowCovering.WindowCoveringType.Rollershade). Must support feature Lift.
1193
+ * @param {WindowCovering.EndProductType} endProductType - The end product type (default: WindowCovering.EndProductType.RollerShade). Must support feature Lift.
1194
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1195
+ *
1196
+ * @remarks mode attributes is writable and persists across restarts.
1197
+ * currentPositionLiftPercent100ths persists across restarts.
1198
+ * configStatus attributes persists across restarts.
1199
+ */
665
1200
  createDefaultWindowCoveringClusterServer(positionPercent100ths, type = WindowCovering.WindowCoveringType.Rollershade, endProductType = WindowCovering.EndProductType.RollerShade) {
666
1201
  this.behaviors.require(MatterbridgeLiftWindowCoveringServer.with(WindowCovering.Feature.Lift, WindowCovering.Feature.PositionAwareLift), {
667
- type,
1202
+ type, // Must support feature Lift
668
1203
  numberOfActuationsLift: 0,
669
1204
  configStatus: {
670
1205
  operational: true,
@@ -672,20 +1207,33 @@ export class MatterbridgeEndpoint extends Endpoint {
672
1207
  liftMovementReversed: false,
673
1208
  liftPositionAware: true,
674
1209
  tiltPositionAware: false,
675
- liftEncoderControlled: false,
676
- tiltEncoderControlled: false,
1210
+ liftEncoderControlled: false, // 0 = Timer Controlled 1 = Encoder Controlled
1211
+ tiltEncoderControlled: false, // 0 = Timer Controlled 1 = Encoder Controlled
677
1212
  },
678
1213
  operationalStatus: { global: WindowCovering.MovementStatus.Stopped, lift: WindowCovering.MovementStatus.Stopped, tilt: WindowCovering.MovementStatus.Stopped },
679
- endProductType,
1214
+ endProductType, // Must support feature Lift
680
1215
  mode: { motorDirectionReversed: false, calibrationMode: false, maintenanceMode: false, ledFeedback: false },
681
- targetPositionLiftPercent100ths: positionPercent100ths ?? 0,
682
- currentPositionLiftPercent100ths: positionPercent100ths ?? 0,
1216
+ targetPositionLiftPercent100ths: positionPercent100ths ?? 0, // 0 Fully open 10000 fully closed
1217
+ currentPositionLiftPercent100ths: positionPercent100ths ?? 0, // 0 Fully open 10000 fully closed
683
1218
  });
684
1219
  return this;
685
1220
  }
1221
+ /**
1222
+ * Creates a default window covering cluster server with features Lift, PositionAwareLift, Tilt, PositionAwareTilt.
1223
+ *
1224
+ * @param {number} positionLiftPercent100ths - The lift position percentage in 100ths (0-10000). Defaults to 0. Matter uses 10000 = fully closed 0 = fully opened.
1225
+ * @param {number} positionTiltPercent100ths - The tilt position percentage in 100ths (0-10000). Defaults to 0. Matter uses 10000 = fully closed 0 = fully opened.
1226
+ * @param {WindowCovering.WindowCoveringType} type - The type of window covering (default: WindowCovering.WindowCoveringType.TiltBlindLift). Must support features Lift and Tilt.
1227
+ * @param {WindowCovering.EndProductType} endProductType - The end product type (default: WindowCovering.EndProductType.InteriorBlind). Must support features Lift and Tilt.
1228
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1229
+ *
1230
+ * @remarks mode attributes is writable and persists across restarts.
1231
+ * currentPositionTiltPercent100ths persists across restarts.
1232
+ * configStatus attributes persists across restarts.
1233
+ */
686
1234
  createDefaultLiftTiltWindowCoveringClusterServer(positionLiftPercent100ths, positionTiltPercent100ths, type = WindowCovering.WindowCoveringType.TiltBlindLift, endProductType = WindowCovering.EndProductType.InteriorBlind) {
687
1235
  this.behaviors.require(MatterbridgeLiftTiltWindowCoveringServer.with(WindowCovering.Feature.Lift, WindowCovering.Feature.PositionAwareLift, WindowCovering.Feature.Tilt, WindowCovering.Feature.PositionAwareTilt), {
688
- type,
1236
+ type, // Must support features Lift and Tilt
689
1237
  numberOfActuationsLift: 0,
690
1238
  numberOfActuationsTilt: 0,
691
1239
  configStatus: {
@@ -694,19 +1242,23 @@ export class MatterbridgeEndpoint extends Endpoint {
694
1242
  liftMovementReversed: false,
695
1243
  liftPositionAware: true,
696
1244
  tiltPositionAware: true,
697
- liftEncoderControlled: false,
698
- tiltEncoderControlled: false,
1245
+ liftEncoderControlled: false, // 0 = Timer Controlled 1 = Encoder Controlled
1246
+ tiltEncoderControlled: false, // 0 = Timer Controlled 1 = Encoder Controlled
699
1247
  },
700
1248
  operationalStatus: { global: WindowCovering.MovementStatus.Stopped, lift: WindowCovering.MovementStatus.Stopped, tilt: WindowCovering.MovementStatus.Stopped },
701
- endProductType,
1249
+ endProductType, // Must support features Lift and Tilt
702
1250
  mode: { motorDirectionReversed: false, calibrationMode: false, maintenanceMode: false, ledFeedback: false },
703
- targetPositionLiftPercent100ths: positionLiftPercent100ths ?? 0,
704
- currentPositionLiftPercent100ths: positionLiftPercent100ths ?? 0,
705
- targetPositionTiltPercent100ths: positionTiltPercent100ths ?? 0,
706
- currentPositionTiltPercent100ths: positionTiltPercent100ths ?? 0,
1251
+ targetPositionLiftPercent100ths: positionLiftPercent100ths ?? 0, // 0 Fully open 10000 fully closed
1252
+ currentPositionLiftPercent100ths: positionLiftPercent100ths ?? 0, // 0 Fully open 10000 fully closed
1253
+ targetPositionTiltPercent100ths: positionTiltPercent100ths ?? 0, // 0 Fully open 10000 fully closed
1254
+ currentPositionTiltPercent100ths: positionTiltPercent100ths ?? 0, // 0 Fully open 10000 fully closed
707
1255
  });
708
1256
  return this;
709
1257
  }
1258
+ /**
1259
+ * Sets the window covering lift target position as the current position and stops the movement.
1260
+ *
1261
+ */
710
1262
  async setWindowCoveringTargetAsCurrentAndStopped() {
711
1263
  const position = this.getAttribute(WindowCovering.Cluster.id, 'currentPositionLiftPercent100ths', this.log);
712
1264
  if (isValidNumber(position, 0, 10000)) {
@@ -726,6 +1278,13 @@ export class MatterbridgeEndpoint extends Endpoint {
726
1278
  this.log.debug(`Set WindowCovering currentPositionTiltPercent100ths and targetPositionTiltPercent100ths to ${position} and operationalStatus to Stopped.`);
727
1279
  }
728
1280
  }
1281
+ /**
1282
+ * Sets the lift current and target position and the status of a window covering.
1283
+ *
1284
+ * @param {number} current - The current position of the window covering.
1285
+ * @param {number} target - The target position of the window covering.
1286
+ * @param {WindowCovering.MovementStatus} status - The movement status of the window covering.
1287
+ */
729
1288
  async setWindowCoveringCurrentTargetStatus(current, target, status) {
730
1289
  await this.setAttribute(WindowCovering.Cluster.id, 'currentPositionLiftPercent100ths', current, this.log);
731
1290
  await this.setAttribute(WindowCovering.Cluster.id, 'targetPositionLiftPercent100ths', target, this.log);
@@ -736,6 +1295,11 @@ export class MatterbridgeEndpoint extends Endpoint {
736
1295
  }, this.log);
737
1296
  this.log.debug(`Set WindowCovering currentPositionLiftPercent100ths: ${current}, targetPositionLiftPercent100ths: ${target} and operationalStatus: ${status}.`);
738
1297
  }
1298
+ /**
1299
+ * Sets the status of the window covering.
1300
+ *
1301
+ * @param {WindowCovering.MovementStatus} status - The movement status to set.
1302
+ */
739
1303
  async setWindowCoveringStatus(status) {
740
1304
  await this.setAttribute(WindowCovering.Cluster.id, 'operationalStatus', {
741
1305
  global: status,
@@ -744,6 +1308,11 @@ export class MatterbridgeEndpoint extends Endpoint {
744
1308
  }, this.log);
745
1309
  this.log.debug(`Set WindowCovering operationalStatus: ${status}`);
746
1310
  }
1311
+ /**
1312
+ * Retrieves the status of the window covering.
1313
+ *
1314
+ * @returns {WindowCovering.MovementStatus | undefined} The movement status of the window covering, or undefined if not available.
1315
+ */
747
1316
  getWindowCoveringStatus() {
748
1317
  const status = this.getAttribute(WindowCovering.Cluster.id, 'operationalStatus', this.log);
749
1318
  if (isValidObject(status, 3) && 'global' in status && typeof status.global === 'number') {
@@ -751,6 +1320,12 @@ export class MatterbridgeEndpoint extends Endpoint {
751
1320
  return status.global;
752
1321
  }
753
1322
  }
1323
+ /**
1324
+ * Sets the lift target and current position of the window covering.
1325
+ *
1326
+ * @param {number} liftPosition - The position to set, specified as a number.
1327
+ * @param {number} [tiltPosition] - The tilt position to set, specified as a number.
1328
+ */
754
1329
  async setWindowCoveringTargetAndCurrentPosition(liftPosition, tiltPosition) {
755
1330
  await this.setAttribute(WindowCovering.Cluster.id, 'currentPositionLiftPercent100ths', liftPosition, this.log);
756
1331
  await this.setAttribute(WindowCovering.Cluster.id, 'targetPositionLiftPercent100ths', liftPosition, this.log);
@@ -761,31 +1336,57 @@ export class MatterbridgeEndpoint extends Endpoint {
761
1336
  this.log.debug(`Set WindowCovering currentPositionTiltPercent100ths: ${tiltPosition} and targetPositionTiltPercent100ths: ${tiltPosition}.`);
762
1337
  }
763
1338
  }
1339
+ /**
1340
+ * Creates a default thermostat cluster server with features Heating, Cooling and AutoMode.
1341
+ *
1342
+ * @param {number} [localTemperature] - The local temperature value in degrees Celsius. Defaults to 23°.
1343
+ * @param {number} [occupiedHeatingSetpoint] - The occupied heating setpoint value in degrees Celsius. Defaults to 21°.
1344
+ * @param {number} [occupiedCoolingSetpoint] - The occupied cooling setpoint value in degrees Celsius. Defaults to 25°.
1345
+ * @param {number} [minSetpointDeadBand] - The minimum setpoint dead band value. Defaults to 1°.
1346
+ * @param {number} [minHeatSetpointLimit] - The minimum heat setpoint limit value. Defaults to 0°.
1347
+ * @param {number} [maxHeatSetpointLimit] - The maximum heat setpoint limit value. Defaults to 50°.
1348
+ * @param {number} [minCoolSetpointLimit] - The minimum cool setpoint limit value. Defaults to 0°.
1349
+ * @param {number} [maxCoolSetpointLimit] - The maximum cool setpoint limit value. Defaults to 50°.
1350
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1351
+ */
764
1352
  createDefaultThermostatClusterServer(localTemperature = 23, occupiedHeatingSetpoint = 21, occupiedCoolingSetpoint = 25, minSetpointDeadBand = 1, minHeatSetpointLimit = 0, maxHeatSetpointLimit = 50, minCoolSetpointLimit = 0, maxCoolSetpointLimit = 50) {
765
1353
  this.behaviors.require(MatterbridgeThermostatServer.with(Thermostat.Feature.Heating, Thermostat.Feature.Cooling, Thermostat.Feature.AutoMode), {
766
1354
  localTemperature: localTemperature * 100,
767
1355
  systemMode: Thermostat.SystemMode.Auto,
768
1356
  controlSequenceOfOperation: Thermostat.ControlSequenceOfOperation.CoolingAndHeating,
1357
+ // Thermostat.Feature.Heating
769
1358
  occupiedHeatingSetpoint: occupiedHeatingSetpoint * 100,
770
1359
  minHeatSetpointLimit: minHeatSetpointLimit * 100,
771
1360
  maxHeatSetpointLimit: maxHeatSetpointLimit * 100,
772
1361
  absMinHeatSetpointLimit: minHeatSetpointLimit * 100,
773
1362
  absMaxHeatSetpointLimit: maxHeatSetpointLimit * 100,
1363
+ // Thermostat.Feature.Cooling
774
1364
  occupiedCoolingSetpoint: occupiedCoolingSetpoint * 100,
775
1365
  minCoolSetpointLimit: minCoolSetpointLimit * 100,
776
1366
  maxCoolSetpointLimit: maxCoolSetpointLimit * 100,
777
1367
  absMinCoolSetpointLimit: minCoolSetpointLimit * 100,
778
1368
  absMaxCoolSetpointLimit: maxCoolSetpointLimit * 100,
1369
+ // Thermostat.Feature.AutoMode
779
1370
  minSetpointDeadBand: minSetpointDeadBand * 100,
780
1371
  thermostatRunningMode: Thermostat.ThermostatRunningMode.Off,
781
1372
  });
782
1373
  return this;
783
1374
  }
1375
+ /**
1376
+ * Creates a default heating thermostat cluster server with feature Heating.
1377
+ *
1378
+ * @param {number} [localTemperature] - The local temperature value in degrees Celsius. Defaults to 23°.
1379
+ * @param {number} [occupiedHeatingSetpoint] - The occupied heating setpoint value in degrees Celsius. Defaults to 21°.
1380
+ * @param {number} [minHeatSetpointLimit] - The minimum heat setpoint limit value. Defaults to 0°.
1381
+ * @param {number} [maxHeatSetpointLimit] - The maximum heat setpoint limit value. Defaults to 50°.
1382
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1383
+ */
784
1384
  createDefaultHeatingThermostatClusterServer(localTemperature = 23, occupiedHeatingSetpoint = 21, minHeatSetpointLimit = 0, maxHeatSetpointLimit = 50) {
785
1385
  this.behaviors.require(MatterbridgeThermostatServer.with(Thermostat.Feature.Heating), {
786
1386
  localTemperature: localTemperature * 100,
787
1387
  systemMode: Thermostat.SystemMode.Heat,
788
1388
  controlSequenceOfOperation: Thermostat.ControlSequenceOfOperation.HeatingOnly,
1389
+ // Thermostat.Feature.Heating
789
1390
  occupiedHeatingSetpoint: occupiedHeatingSetpoint * 100,
790
1391
  minHeatSetpointLimit: minHeatSetpointLimit * 100,
791
1392
  maxHeatSetpointLimit: maxHeatSetpointLimit * 100,
@@ -794,11 +1395,21 @@ export class MatterbridgeEndpoint extends Endpoint {
794
1395
  });
795
1396
  return this;
796
1397
  }
1398
+ /**
1399
+ * Creates a default cooling thermostat cluster server with feature Cooling.
1400
+ *
1401
+ * @param {number} [localTemperature] - The local temperature value in degrees Celsius. Defaults to 23°.
1402
+ * @param {number} [occupiedCoolingSetpoint] - The occupied cooling setpoint value in degrees Celsius. Defaults to 25°.
1403
+ * @param {number} [minCoolSetpointLimit] - The minimum cool setpoint limit value. Defaults to 0°.
1404
+ * @param {number} [maxCoolSetpointLimit] - The maximum cool setpoint limit value. Defaults to 50°.
1405
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1406
+ */
797
1407
  createDefaultCoolingThermostatClusterServer(localTemperature = 23, occupiedCoolingSetpoint = 25, minCoolSetpointLimit = 0, maxCoolSetpointLimit = 50) {
798
1408
  this.behaviors.require(MatterbridgeThermostatServer.with(Thermostat.Feature.Cooling), {
799
1409
  localTemperature: localTemperature * 100,
800
1410
  systemMode: Thermostat.SystemMode.Cool,
801
1411
  controlSequenceOfOperation: Thermostat.ControlSequenceOfOperation.CoolingOnly,
1412
+ // Thermostat.Feature.Cooling
802
1413
  occupiedCoolingSetpoint: occupiedCoolingSetpoint * 100,
803
1414
  minCoolSetpointLimit: minCoolSetpointLimit * 100,
804
1415
  maxCoolSetpointLimit: maxCoolSetpointLimit * 100,
@@ -807,6 +1418,16 @@ export class MatterbridgeEndpoint extends Endpoint {
807
1418
  });
808
1419
  return this;
809
1420
  }
1421
+ /**
1422
+ * Creates a default thermostat user interface configuration cluster server.
1423
+ *
1424
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1425
+ * @remarks
1426
+ * The default values are:
1427
+ * - temperatureDisplayMode: ThermostatUserInterfaceConfiguration.TemperatureDisplayMode.Celsius (writeble).
1428
+ * - keypadLockout: ThermostatUserInterfaceConfiguration.KeypadLockout.NoLockout (writeble).
1429
+ * - scheduleProgrammingVisibility: ThermostatUserInterfaceConfiguration.ScheduleProgrammingVisibility.ScheduleProgrammingPermitted (writeble).
1430
+ */
810
1431
  createDefaultThermostatUserInterfaceConfigurationClusterServer() {
811
1432
  this.behaviors.require(ThermostatUserInterfaceConfigurationServer, {
812
1433
  temperatureDisplayMode: ThermostatUserInterfaceConfiguration.TemperatureDisplayMode.Celsius,
@@ -815,69 +1436,159 @@ export class MatterbridgeEndpoint extends Endpoint {
815
1436
  });
816
1437
  return this;
817
1438
  }
1439
+ /**
1440
+ * Creates a default fan control cluster server with features Auto, and Step.
1441
+ *
1442
+ * @param {FanControl.FanMode} [fanMode] - The fan mode to set. Defaults to `FanControl.FanMode.Off`.
1443
+ * @param {FanControl.FanModeSequence} [fanModeSequence] - The fan mode sequence to set. Defaults to `FanControl.FanModeSequence.OffLowMedHighAuto`.
1444
+ * @param {number} [percentSetting] - The initial percent setting. Defaults to 0.
1445
+ * @param {number} [percentCurrent] - The initial percent current. Defaults to 0.
1446
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1447
+ *
1448
+ * @remarks
1449
+ * - fanmode is writable and persists across reboots.
1450
+ * - fanModeSequence is fixed.
1451
+ * - percentSetting is writable.
1452
+ */
818
1453
  createDefaultFanControlClusterServer(fanMode = FanControl.FanMode.Off, fanModeSequence = FanControl.FanModeSequence.OffLowMedHighAuto, percentSetting = 0, percentCurrent = 0) {
819
1454
  this.behaviors.require(MatterbridgeFanControlServer.with(FanControl.Feature.Auto, FanControl.Feature.Step), {
820
- fanMode,
821
- fanModeSequence,
822
- percentSetting,
1455
+ fanMode, // Writable and persistent attribute
1456
+ fanModeSequence, // Fixed attribute
1457
+ percentSetting, // Writable attribute
823
1458
  percentCurrent,
824
1459
  });
825
1460
  return this;
826
1461
  }
1462
+ /**
1463
+ * Creates a fan control cluster server with features MultiSpeed, Auto, and Step.
1464
+ *
1465
+ * @param {FanControl.FanMode} [fanMode] - The fan mode to set. Defaults to `FanControl.FanMode.Off`.
1466
+ * @param {FanControl.FanModeSequence} [fanModeSequence] - The fan mode sequence to set. Defaults to `FanControl.FanModeSequence.OffLowMedHighAuto`.
1467
+ * @param {number} [percentSetting] - The initial percent setting. Defaults to 0.
1468
+ * @param {number} [percentCurrent] - The initial percent current. Defaults to 0.
1469
+ * @param {number} [speedMax] - The maximum speed setting. Defaults to 10.
1470
+ * @param {number} [speedSetting] - The initial speed setting. Defaults to 0.
1471
+ * @param {number} [speedCurrent] - The initial speed current. Defaults to 0.
1472
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1473
+ *
1474
+ * @remarks
1475
+ * - fanmode is writable and persists across reboots.
1476
+ * - fanModeSequence is fixed.
1477
+ * - percentSetting is writable.
1478
+ * - speedMax is fixed.
1479
+ * - speedSetting is writable.
1480
+ */
827
1481
  createMultiSpeedFanControlClusterServer(fanMode = FanControl.FanMode.Off, fanModeSequence = FanControl.FanModeSequence.OffLowMedHighAuto, percentSetting = 0, percentCurrent = 0, speedMax = 10, speedSetting = 0, speedCurrent = 0) {
828
1482
  this.behaviors.require(MatterbridgeFanControlServer.with(FanControl.Feature.MultiSpeed, FanControl.Feature.Auto, FanControl.Feature.Step), {
829
- fanMode,
830
- fanModeSequence,
831
- percentSetting,
1483
+ fanMode, // Writable and persistent attribute
1484
+ fanModeSequence, // Fixed attribute
1485
+ percentSetting, // Writable attribute
832
1486
  percentCurrent,
833
- speedMax,
834
- speedSetting,
1487
+ // MultiSpeed feature
1488
+ speedMax, // Fixed attribute
1489
+ speedSetting, // Writable attribute
835
1490
  speedCurrent,
836
1491
  });
837
1492
  return this;
838
1493
  }
1494
+ /**
1495
+ * Creates a base fan control cluster server without features.
1496
+ *
1497
+ * @param {FanControl.FanMode} [fanMode] - The fan mode to set. Defaults to `FanControl.FanMode.Off`.
1498
+ * @param {FanControl.FanModeSequence} [fanModeSequence] - The fan mode sequence to set. Defaults to `FanControl.FanModeSequence.OffLowMedHigh`.
1499
+ * @param {number} [percentSetting] - The initial percent setting. Defaults to 0.
1500
+ * @param {number} [percentCurrent] - The initial percent current. Defaults to 0.
1501
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1502
+ *
1503
+ * @remarks
1504
+ * fanmode is writable and persists across reboots.
1505
+ * fanModeSequence is fixed.
1506
+ * percentSetting is writable.
1507
+ */
839
1508
  createBaseFanControlClusterServer(fanMode = FanControl.FanMode.Off, fanModeSequence = FanControl.FanModeSequence.OffLowMedHigh, percentSetting = 0, percentCurrent = 0) {
840
1509
  this.behaviors.require(FanControlServer, {
841
- fanMode,
842
- fanModeSequence,
843
- percentSetting,
1510
+ fanMode, // Writable and persistent attribute
1511
+ fanModeSequence, // Fixed attribute
1512
+ percentSetting, // Writable attribute
844
1513
  percentCurrent,
845
1514
  });
846
1515
  return this;
847
1516
  }
1517
+ /**
1518
+ * Creates a default HEPA Filter Monitoring Cluster Server with features Condition and ReplacementProductList.
1519
+ * It supports ResourceMonitoring.Feature.Condition and ResourceMonitoring.Feature.ReplacementProductList.
1520
+ *
1521
+ * @param {ResourceMonitoring.ChangeIndication} changeIndication - The initial change indication. Default is ResourceMonitoring.ChangeIndication.Ok.
1522
+ * @param {boolean | undefined} inPlaceIndicator - The in-place indicator. Default is undefined.
1523
+ * @param {number | undefined} lastChangedTime - The last changed time (EpochS). Default is undefined.
1524
+ *
1525
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1526
+ */
848
1527
  createDefaultHepaFilterMonitoringClusterServer(changeIndication = ResourceMonitoring.ChangeIndication.Ok, inPlaceIndicator = undefined, lastChangedTime = undefined) {
849
1528
  this.behaviors.require(HepaFilterMonitoringServer.with(ResourceMonitoring.Feature.Condition, ResourceMonitoring.Feature.ReplacementProductList), {
850
- condition: 100,
851
- degradationDirection: ResourceMonitoring.DegradationDirection.Down,
1529
+ condition: 100, // Feature.Condition
1530
+ degradationDirection: ResourceMonitoring.DegradationDirection.Down, // Feature.Condition
852
1531
  changeIndication,
853
1532
  inPlaceIndicator,
854
1533
  lastChangedTime,
855
- replacementProductList: [],
1534
+ replacementProductList: [], // Feature.ReplacementProductList
856
1535
  });
857
1536
  return this;
858
1537
  }
1538
+ /**
1539
+ * Creates a default Activated Carbon Filter Monitoring Cluster Server with features Condition and ReplacementProductList.
1540
+ *
1541
+ * @param {ResourceMonitoring.ChangeIndication} changeIndication - The initial change indication. Default is ResourceMonitoring.ChangeIndication.Ok.
1542
+ * @param {boolean | undefined} inPlaceIndicator - The in-place indicator. Default is undefined.
1543
+ * @param {number | undefined} lastChangedTime - The last changed time (EpochS). Default is undefined.
1544
+ *
1545
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1546
+ */
859
1547
  createDefaultActivatedCarbonFilterMonitoringClusterServer(changeIndication = ResourceMonitoring.ChangeIndication.Ok, inPlaceIndicator = undefined, lastChangedTime = undefined) {
860
1548
  this.behaviors.require(ActivatedCarbonFilterMonitoringServer.with(ResourceMonitoring.Feature.Condition, ResourceMonitoring.Feature.ReplacementProductList), {
861
- condition: 100,
862
- degradationDirection: ResourceMonitoring.DegradationDirection.Down,
1549
+ condition: 100, // Feature.Condition
1550
+ degradationDirection: ResourceMonitoring.DegradationDirection.Down, // Feature.Condition
863
1551
  changeIndication,
864
1552
  inPlaceIndicator,
865
1553
  lastChangedTime,
866
- replacementProductList: [],
1554
+ replacementProductList: [], // Feature.ReplacementProductList
867
1555
  });
868
1556
  return this;
869
1557
  }
1558
+ /**
1559
+ * Creates a default door lock cluster server.
1560
+ *
1561
+ * @param {DoorLock.LockState} [lockState] - The initial state of the lock (default: Locked).
1562
+ * @param {DoorLock.LockType} [lockType] - The type of the lock (default: DeadBolt).
1563
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1564
+ *
1565
+ * @remarks
1566
+ * All operating modes NOT supported by a lock SHALL be set to one. The value of the OperatingMode enumeration defines the related bit to be set.
1567
+ */
870
1568
  createDefaultDoorLockClusterServer(lockState = DoorLock.LockState.Locked, lockType = DoorLock.LockType.DeadBolt) {
871
1569
  this.behaviors.require(MatterbridgeDoorLockServer.enable({ events: { doorLockAlarm: true, lockOperation: true, lockOperationError: true } }), {
872
1570
  lockState,
873
1571
  lockType,
874
1572
  actuatorEnabled: false,
875
1573
  operatingMode: DoorLock.OperatingMode.Normal,
1574
+ // Special case of inverted bitmap: add also alwaysSet = 2047
876
1575
  supportedOperatingModes: { normal: false, vacation: true, privacy: true, noRemoteLockUnlock: true, passage: true, alwaysSet: 2047 },
877
1576
  alarmMask: { lockJammed: false, lockFactoryReset: false, lockRadioPowerCycled: false, wrongCodeEntryLimit: false, frontEscutcheonRemoved: false, doorForcedOpen: false },
878
1577
  });
879
1578
  return this;
880
1579
  }
1580
+ /**
1581
+ * Creates a default Mode Select cluster server.
1582
+ *
1583
+ * @param {string} description - The description of the mode select cluster.
1584
+ * @param {ModeSelect.ModeOption[]} supportedModes - The list of supported modes.
1585
+ * @param {number} [currentMode] - The current mode (default: 0).
1586
+ * @param {number} [startUpMode] - The startup mode (default: 0).
1587
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1588
+ *
1589
+ * @remarks
1590
+ * endpoint.createDefaultModeSelectClusterServer('Night mode', [{ label: 'Led ON', mode: 0, semanticTags: [] }, { label: 'Led OFF', mode: 1, semanticTags: [] }], 0, 0);
1591
+ */
881
1592
  createDefaultModeSelectClusterServer(description, supportedModes, currentMode = 0, startUpMode = 0) {
882
1593
  this.behaviors.require(MatterbridgeModeSelectServer, {
883
1594
  description: description,
@@ -888,21 +1599,35 @@ export class MatterbridgeEndpoint extends Endpoint {
888
1599
  });
889
1600
  return this;
890
1601
  }
1602
+ /**
1603
+ * Creates the default Valve Configuration And Control cluster server with features Level.
1604
+ *
1605
+ * @param {ValveConfigurationAndControl.ValveState} [valveState] - The valve state to set. Defaults to `ValveConfigurationAndControl.ValveState.Closed`.
1606
+ * @param {number} [valveLevel] - The valve level to set. Defaults to 0.
1607
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1608
+ */
891
1609
  createDefaultValveConfigurationAndControlClusterServer(valveState = ValveConfigurationAndControl.ValveState.Closed, valveLevel = 0) {
892
1610
  this.behaviors.require(MatterbridgeValveConfigurationAndControlServer.with(ValveConfigurationAndControl.Feature.Level), {
893
1611
  currentState: valveState,
894
1612
  targetState: valveState,
895
1613
  openDuration: null,
896
- defaultOpenDuration: null,
1614
+ defaultOpenDuration: null, // Writable and persistent across restarts
897
1615
  remainingDuration: null,
898
1616
  valveFault: { generalFault: false, blocked: false, leaking: false, notConnected: false, shortCircuit: false, currentExceeded: false },
1617
+ // Feature.Level
899
1618
  currentLevel: valveLevel,
900
1619
  targetLevel: valveLevel,
901
- defaultOpenLevel: 100,
902
- levelStep: 1,
1620
+ defaultOpenLevel: 100, // Writable and persistent across restarts
1621
+ levelStep: 1, // Fixed
903
1622
  });
904
1623
  return this;
905
1624
  }
1625
+ /**
1626
+ * Creates the default PumpConfigurationAndControl cluster server with features ConstantSpeed.
1627
+ *
1628
+ * @param {PumpConfigurationAndControl.OperationMode} [pumpMode] - The pump mode to set. Defaults to `PumpConfigurationAndControl.OperationMode.Normal`.
1629
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1630
+ */
906
1631
  createDefaultPumpConfigurationAndControlClusterServer(pumpMode = PumpConfigurationAndControl.OperationMode.Normal) {
907
1632
  this.behaviors.require(PumpConfigurationAndControlServer.with(PumpConfigurationAndControl.Feature.ConstantSpeed), {
908
1633
  minConstSpeed: null,
@@ -917,6 +1642,13 @@ export class MatterbridgeEndpoint extends Endpoint {
917
1642
  });
918
1643
  return this;
919
1644
  }
1645
+ /**
1646
+ * Creates the default SmokeCOAlarm Cluster Server with features SmokeAlarm and CoAlarm.
1647
+ *
1648
+ * @param {SmokeCoAlarm.AlarmState} smokeState - The state of the smoke alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
1649
+ * @param {SmokeCoAlarm.AlarmState} coState - The state of the CO alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
1650
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1651
+ */
920
1652
  createDefaultSmokeCOAlarmClusterServer(smokeState = SmokeCoAlarm.AlarmState.Normal, coState = SmokeCoAlarm.AlarmState.Normal) {
921
1653
  this.behaviors.require(MatterbridgeSmokeCoAlarmServer.with(SmokeCoAlarm.Feature.SmokeAlarm, SmokeCoAlarm.Feature.CoAlarm).enable({
922
1654
  events: { smokeAlarm: true, interconnectSmokeAlarm: false, coAlarm: true, interconnectCoAlarm: false, lowBattery: true, hardwareFault: true, endOfService: true, selfTestComplete: true, alarmMuted: true, muteEnded: true, allClear: true },
@@ -932,6 +1664,12 @@ export class MatterbridgeEndpoint extends Endpoint {
932
1664
  });
933
1665
  return this;
934
1666
  }
1667
+ /**
1668
+ * Creates a smoke only SmokeCOAlarm Cluster Server with features SmokeAlarm.
1669
+ *
1670
+ * @param {SmokeCoAlarm.AlarmState} smokeState - The state of the smoke alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
1671
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1672
+ */
935
1673
  createSmokeOnlySmokeCOAlarmClusterServer(smokeState = SmokeCoAlarm.AlarmState.Normal) {
936
1674
  this.behaviors.require(MatterbridgeSmokeCoAlarmServer.with(SmokeCoAlarm.Feature.SmokeAlarm).enable({
937
1675
  events: { smokeAlarm: true, interconnectSmokeAlarm: false, coAlarm: false, interconnectCoAlarm: false, lowBattery: true, hardwareFault: true, endOfService: true, selfTestComplete: true, alarmMuted: true, muteEnded: true, allClear: true },
@@ -946,6 +1684,12 @@ export class MatterbridgeEndpoint extends Endpoint {
946
1684
  });
947
1685
  return this;
948
1686
  }
1687
+ /**
1688
+ * Creates a co only SmokeCOAlarm Cluster Server with features CoAlarm.
1689
+ *
1690
+ * @param {SmokeCoAlarm.AlarmState} coState - The state of the CO alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
1691
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1692
+ */
949
1693
  createCoOnlySmokeCOAlarmClusterServer(coState = SmokeCoAlarm.AlarmState.Normal) {
950
1694
  this.behaviors.require(MatterbridgeSmokeCoAlarmServer.with(SmokeCoAlarm.Feature.CoAlarm).enable({
951
1695
  events: { smokeAlarm: false, interconnectSmokeAlarm: false, coAlarm: true, interconnectCoAlarm: false, lowBattery: true, hardwareFault: true, endOfService: true, selfTestComplete: true, alarmMuted: true, muteEnded: true, allClear: true },
@@ -960,6 +1704,15 @@ export class MatterbridgeEndpoint extends Endpoint {
960
1704
  });
961
1705
  return this;
962
1706
  }
1707
+ /**
1708
+ * Creates a default momentary switch cluster server with features MomentarySwitch, MomentarySwitchRelease, MomentarySwitchLongPress and MomentarySwitchMultiPress
1709
+ * and events initialPress, longPress, shortRelease, longRelease, multiPressOngoing, multiPressComplete.
1710
+ *
1711
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1712
+ *
1713
+ * @remarks
1714
+ * This method adds a cluster server with default momentary switch features and configuration suitable for (AppleHome) Single Double Long automations.
1715
+ */
963
1716
  createDefaultSwitchClusterServer() {
964
1717
  this.behaviors.require(MatterbridgeSwitchServer.with(Switch.Feature.MomentarySwitch, Switch.Feature.MomentarySwitchRelease, Switch.Feature.MomentarySwitchLongPress, Switch.Feature.MomentarySwitchMultiPress).enable({
965
1718
  events: { initialPress: true, longPress: true, shortRelease: true, longRelease: true, multiPressOngoing: true, multiPressComplete: true },
@@ -970,6 +1723,14 @@ export class MatterbridgeEndpoint extends Endpoint {
970
1723
  });
971
1724
  return this;
972
1725
  }
1726
+ /**
1727
+ * Creates a default momentary switch cluster server with feature MomentarySwitch and event initialPress.
1728
+ *
1729
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1730
+ *
1731
+ * @remarks
1732
+ * This method adds a cluster server with default momentary switch features and configuration suitable for Single press automations.
1733
+ */
973
1734
  createDefaultMomentarySwitchClusterServer() {
974
1735
  this.behaviors.require(MatterbridgeSwitchServer.with(Switch.Feature.MomentarySwitch).enable({
975
1736
  events: { initialPress: true },
@@ -979,6 +1740,14 @@ export class MatterbridgeEndpoint extends Endpoint {
979
1740
  });
980
1741
  return this;
981
1742
  }
1743
+ /**
1744
+ * Creates a default latching switch cluster server with features LatchingSwitch.
1745
+ *
1746
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1747
+ *
1748
+ * @remarks
1749
+ * This method adds a cluster server with default latching switch features and configuration suitable for a latching switch with 2 positions.
1750
+ */
982
1751
  createDefaultLatchingSwitchClusterServer() {
983
1752
  this.behaviors.require(SwitchServer.with(Switch.Feature.LatchingSwitch).enable({
984
1753
  events: { switchLatched: true },
@@ -988,6 +1757,13 @@ export class MatterbridgeEndpoint extends Endpoint {
988
1757
  });
989
1758
  return this;
990
1759
  }
1760
+ /**
1761
+ * Triggers a switch event on the specified endpoint.
1762
+ *
1763
+ * @param {string} event - The type of event to trigger. Possible values are 'Single', 'Double', 'Long' for momentarySwitch and 'Press', 'Release' for latchingSwitch.
1764
+ * @param {AnsiLogger} log - Optional logger to log the event.
1765
+ * @returns {boolean} - A boolean indicating whether the event was successfully triggered.
1766
+ */
991
1767
  async triggerSwitchEvent(event, log) {
992
1768
  if (this.maybeNumber === undefined) {
993
1769
  this.log.error(`triggerSwitchEvent ${event} error: Endpoint number not assigned on endpoint ${this.maybeId}:${this.maybeNumber}`);
@@ -1047,10 +1823,30 @@ export class MatterbridgeEndpoint extends Endpoint {
1047
1823
  }
1048
1824
  return true;
1049
1825
  }
1826
+ /**
1827
+ * Creates a default OperationalState Cluster Server.
1828
+ *
1829
+ * @param {OperationalState.OperationalStateEnum} operationalState - The initial operational state.
1830
+ *
1831
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1832
+ */
1050
1833
  createDefaultOperationalStateClusterServer(operationalState = OperationalState.OperationalStateEnum.Stopped) {
1051
1834
  this.behaviors.require(MatterbridgeOperationalStateServer, getDefaultOperationalStateClusterServer(operationalState));
1052
1835
  return this;
1053
1836
  }
1837
+ /**
1838
+ * Creates a default boolean state cluster server.
1839
+ * The stateChange event is enabled.
1840
+ *
1841
+ * @param {boolean} contact - The state of the cluster. Defaults to true (true = contact).
1842
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1843
+ *
1844
+ * @remarks
1845
+ * Water Leak Detector: true = leak, false = no leak
1846
+ * Water Freeze Detector: true = freeze, false = no freeze
1847
+ * Rain Sensor: true = rain, false = no rain
1848
+ * Contact Sensor: true = closed or contact, false = open or no contact
1849
+ */
1054
1850
  createDefaultBooleanStateClusterServer(contact) {
1055
1851
  this.behaviors.require(BooleanStateServer.enable({
1056
1852
  events: { stateChange: true },
@@ -1059,6 +1855,22 @@ export class MatterbridgeEndpoint extends Endpoint {
1059
1855
  });
1060
1856
  return this;
1061
1857
  }
1858
+ /**
1859
+ * Creates a default boolean state configuration cluster server to be used with the waterFreezeDetector, waterLeakDetector, and rainSensor device types.
1860
+ *
1861
+ * Features:
1862
+ * - Visual
1863
+ * - Audible
1864
+ * - SensitivityLevel
1865
+ *
1866
+ * @remarks Supports the enableDisableAlarm command.
1867
+ *
1868
+ * @param {boolean} [sensorFault] - Optional boolean value indicating the sensor fault state. Defaults to `false` if not provided.
1869
+ * @param {number} [currentSensitivityLevel] - The current sensitivity level. Defaults to `0` if not provided.
1870
+ * @param {number} [supportedSensitivityLevels] - The number of supported sensitivity levels. Defaults to `2` if not provided (min 2, max 10).
1871
+ * @param {number} [defaultSensitivityLevel] - The default sensitivity level. Defaults to `0` if not provided.
1872
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1873
+ */
1062
1874
  createDefaultBooleanStateConfigurationClusterServer(sensorFault = false, currentSensitivityLevel = 0, supportedSensitivityLevels = 2, defaultSensitivityLevel = 0) {
1063
1875
  this.behaviors.require(MatterbridgeBooleanStateConfigurationServer.with(BooleanStateConfiguration.Feature.Visual, BooleanStateConfiguration.Feature.Audible, BooleanStateConfiguration.Feature.SensitivityLevel).enable({
1064
1876
  events: { alarmsStateChanged: true, sensorFault: true },
@@ -1073,18 +1885,51 @@ export class MatterbridgeEndpoint extends Endpoint {
1073
1885
  });
1074
1886
  return this;
1075
1887
  }
1888
+ /**
1889
+ * Creates a default Device Energy Management Cluster Server with feature PowerForecastReporting and with the specified ESA type, ESA canGenerate, ESA state, and power limits.
1890
+ *
1891
+ * @param {DeviceEnergyManagement.EsaType} [esaType] - The ESA type. Defaults to `DeviceEnergyManagement.EsaType.Other`.
1892
+ * @param {boolean} [esaCanGenerate] - Indicates if the ESA can generate energy. Defaults to `false`.
1893
+ * @param {DeviceEnergyManagement.EsaState} [esaState] - The ESA state. Defaults to `DeviceEnergyManagement.EsaState.Online`.
1894
+ * @param {number} [absMinPower] - Indicate the minimum electrical power in mw that the ESA can consume when switched on. Defaults to `0` if not provided.
1895
+ * @param {number} [absMaxPower] - Indicate the maximum electrical power in mw that the ESA can consume when switched on. Defaults to `0` if not provided.
1896
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1897
+ *
1898
+ * @remarks
1899
+ * - The forecast attribute is set to null, indicating that there is no forecast currently available.
1900
+ * - The ESA type and canGenerate attributes are fixed and cannot be changed after creation.
1901
+ * - The ESA state is set to Online by default.
1902
+ * - The absolute minimum and maximum power attributes are set to 0 by default.
1903
+ * - For example, a battery storage inverter that can charge its battery at a maximum power of 2000W and can
1904
+ * discharge the battery at a maximum power of 3000W, would have a absMinPower: -3000W, absMaxPower: 2000W.
1905
+ */
1076
1906
  createDefaultDeviceEnergyManagementClusterServer(esaType = DeviceEnergyManagement.EsaType.Other, esaCanGenerate = false, esaState = DeviceEnergyManagement.EsaState.Online, absMinPower = 0, absMaxPower = 0) {
1077
1907
  this.behaviors.require(MatterbridgeDeviceEnergyManagementServer.with(DeviceEnergyManagement.Feature.PowerForecastReporting, DeviceEnergyManagement.Feature.PowerAdjustment), {
1078
- forecast: null,
1079
- powerAdjustmentCapability: null,
1080
- esaType,
1081
- esaCanGenerate,
1908
+ forecast: null, // A null value indicates that there is no forecast currently available
1909
+ powerAdjustmentCapability: null, // A null value indicates that no power adjustment is currently possible, and nor is any adjustment currently active
1910
+ esaType, // Fixed attribute
1911
+ esaCanGenerate, // Fixed attribute
1082
1912
  esaState,
1083
1913
  absMinPower,
1084
1914
  absMaxPower,
1085
1915
  });
1086
1916
  return this;
1087
1917
  }
1918
+ /**
1919
+ * Creates a default EnergyManagementMode Cluster Server.
1920
+ *
1921
+ * @param {number} [currentMode] - The current mode of the EnergyManagementMode cluster. Defaults to mode 1 (DeviceEnergyManagementMode.ModeTag.NoOptimization).
1922
+ * @param {EnergyManagementMode.ModeOption[]} [supportedModes] - The supported modes for the DeviceEnergyManagementMode cluster. The attribute is fixed and defaults to a predefined set of cluster modes.
1923
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1924
+ *
1925
+ * @remarks
1926
+ * A few examples of Device Energy Management modes and their mode tags are provided below.
1927
+ * - For the "No Energy Management (Forecast reporting only)" mode, tags: 0x4000 (NoOptimization).
1928
+ * - For the "Device Energy Management" mode, tags: 0x4001 (DeviceOptimization).
1929
+ * - For the "Home Energy Management" mode, tags: 0x4001 (DeviceOptimization), 0x4002 (LocalOptimization).
1930
+ * - For the "Grid Energy Management" mode, tags: 0x4003 (GridOptimization).
1931
+ * - For the "Full Energy Management" mode, tags: 0x4001 (DeviceOptimization), 0x4002 (LocalOptimization), 0x4003 (GridOptimization).
1932
+ */
1088
1933
  createDefaultDeviceEnergyManagementModeClusterServer(currentMode, supportedModes) {
1089
1934
  this.behaviors.require(MatterbridgeDeviceEnergyManagementModeServer, {
1090
1935
  supportedModes: supportedModes ?? [
@@ -1105,15 +1950,27 @@ export class MatterbridgeEndpoint extends Endpoint {
1105
1950
  mode: 5,
1106
1951
  modeTags: [{ value: DeviceEnergyManagementMode.ModeTag.DeviceOptimization }, { value: DeviceEnergyManagementMode.ModeTag.LocalOptimization }, { value: DeviceEnergyManagementMode.ModeTag.GridOptimization }],
1107
1952
  },
1108
- ],
1953
+ ], // Fixed attribute
1109
1954
  currentMode: currentMode ?? 1,
1110
1955
  });
1111
1956
  return this;
1112
1957
  }
1958
+ /**
1959
+ * Creates a default Power Topology Cluster Server with feature TreeTopology (the endpoint provides or consumes power to/from itself and its child endpoints). Only needed for an electricalSensor device type.
1960
+ *
1961
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1962
+ */
1113
1963
  createDefaultPowerTopologyClusterServer() {
1114
1964
  this.behaviors.require(PowerTopologyServer.with(PowerTopology.Feature.TreeTopology));
1115
1965
  return this;
1116
1966
  }
1967
+ /**
1968
+ * Creates a default Electrical Energy Measurement Cluster Server with features ImportedEnergy, ExportedEnergy, and CumulativeEnergy.
1969
+ *
1970
+ * @param {number} energyImported - The total consumption value in mW/h.
1971
+ * @param {number} energyExported - The total production value in mW/h.
1972
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1973
+ */
1117
1974
  createDefaultElectricalEnergyMeasurementClusterServer(energyImported = null, energyExported = null) {
1118
1975
  this.behaviors.require(ElectricalEnergyMeasurementServer.with(ElectricalEnergyMeasurement.Feature.ImportedEnergy, ElectricalEnergyMeasurement.Feature.ExportedEnergy, ElectricalEnergyMeasurement.Feature.CumulativeEnergy), {
1119
1976
  accuracy: {
@@ -1129,6 +1986,15 @@ export class MatterbridgeEndpoint extends Endpoint {
1129
1986
  });
1130
1987
  return this;
1131
1988
  }
1989
+ /**
1990
+ * Creates a default Electrical Power Measurement Cluster Server with features AlternatingCurrent.
1991
+ *
1992
+ * @param {number} voltage - The voltage value in millivolts.
1993
+ * @param {number} current - The current value in milliamperes.
1994
+ * @param {number} power - The power value in milliwatts.
1995
+ * @param {number} frequency - The frequency value in millihertz.
1996
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
1997
+ */
1132
1998
  createDefaultElectricalPowerMeasurementClusterServer(voltage = null, current = null, power = null, frequency = null) {
1133
1999
  this.behaviors.require(ElectricalPowerMeasurementServer.with(ElectricalPowerMeasurement.Feature.AlternatingCurrent), {
1134
2000
  powerMode: ElectricalPowerMeasurement.PowerMode.Ac,
@@ -1170,36 +2036,124 @@ export class MatterbridgeEndpoint extends Endpoint {
1170
2036
  });
1171
2037
  return this;
1172
2038
  }
2039
+ /**
2040
+ * Creates a default TemperatureMeasurement cluster server.
2041
+ *
2042
+ * @param {number | null} measuredValue - The measured value of the temperature x 100.
2043
+ * @param {number | null} minMeasuredValue - The minimum measured value of the temperature x 100.
2044
+ * @param {number | null} maxMeasuredValue - The maximum measured value of the temperature x 100.
2045
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2046
+ */
1173
2047
  createDefaultTemperatureMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
1174
2048
  this.behaviors.require(TemperatureMeasurementServer, getDefaultTemperatureMeasurementClusterServer(measuredValue, minMeasuredValue, maxMeasuredValue));
1175
2049
  return this;
1176
2050
  }
2051
+ /**
2052
+ * Creates a default RelativeHumidityMeasurement cluster server.
2053
+ *
2054
+ * @param {number | null} measuredValue - The measured value of the relative humidity x 100.
2055
+ * @param {number | null} minMeasuredValue - The minimum measured value of the relative humidity x 100.
2056
+ * @param {number | null} maxMeasuredValue - The maximum measured value of the relative humidity x 100.
2057
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2058
+ */
1177
2059
  createDefaultRelativeHumidityMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
1178
2060
  this.behaviors.require(RelativeHumidityMeasurementServer, getDefaultRelativeHumidityMeasurementClusterServer(measuredValue, minMeasuredValue, maxMeasuredValue));
1179
2061
  return this;
1180
2062
  }
2063
+ /**
2064
+ * Creates a default PressureMeasurement cluster server.
2065
+ *
2066
+ * @param {number | null} measuredValue - The measured value for the pressure in kPa x 10.
2067
+ * @param {number | null} minMeasuredValue - The minimum measured value for the pressure in kPa x 10.
2068
+ * @param {number | null} maxMeasuredValue - The maximum measured value for the pressure in kPa x 10.
2069
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2070
+ *
2071
+ * @remarks
2072
+ * - MeasuredValue = 10 x Pressure in kPa
2073
+ * - MeasuredValue = 1 x Pressure in hPa
2074
+ * - MeasuredValue = 33.8639 x Pressure in inHg
2075
+ *
2076
+ * Conversion:
2077
+ * - 1 kPa = 10 hPa
2078
+ * - 1 inHg = 33.8639 hPa
2079
+ */
1181
2080
  createDefaultPressureMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
1182
2081
  this.behaviors.require(PressureMeasurementServer, getDefaultPressureMeasurementClusterServer(measuredValue, minMeasuredValue, maxMeasuredValue));
1183
2082
  return this;
1184
2083
  }
2084
+ /**
2085
+ * Creates a default IlluminanceMeasurement cluster server.
2086
+ *
2087
+ * @param {number | null} measuredValue - The measured value of illuminance.
2088
+ * @param {number | null} minMeasuredValue - The minimum measured value of illuminance.
2089
+ * @param {number | null} maxMeasuredValue - The maximum measured value of illuminance.
2090
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2091
+ *
2092
+ * @remarks The default value for the illuminance measurement is null.
2093
+ * This attribute SHALL indicate the illuminance in Lux (symbol lx) as follows:
2094
+ * • MeasuredValue = 10,000 x log10(illuminance) + 1,
2095
+ * where 1 lx <= illuminance <= 3.576 Mlx, corresponding to a MeasuredValue in the range 1 to 0xFFFE.
2096
+ * • 0 indicates a value of illuminance that is too low to be measured
2097
+ * • null indicates that the illuminance measurement is invalid.
2098
+ *
2099
+ * - Lux to matter = Math.round(Math.max(Math.min(10000 * Math.log10(lux), 0xfffe), 0))
2100
+ * - Matter to Lux = Math.round(Math.max(Math.pow(10, value / 10000), 0))
2101
+ */
1185
2102
  createDefaultIlluminanceMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
1186
2103
  this.behaviors.require(IlluminanceMeasurementServer, getDefaultIlluminanceMeasurementClusterServer(measuredValue, minMeasuredValue, maxMeasuredValue));
1187
2104
  return this;
1188
2105
  }
2106
+ /**
2107
+ * Creates a default FlowMeasurement cluster server.
2108
+ *
2109
+ * @param {number | null} measuredValue - The measured value of the flow in 10 x m3/h.
2110
+ * @param {number | null} minMeasuredValue - The minimum measured value of the flow in 10 x m3/h.
2111
+ * @param {number | null} maxMeasuredValue - The maximum measured value of the flow in 10 x m3/h.
2112
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2113
+ */
1189
2114
  createDefaultFlowMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
1190
2115
  this.behaviors.require(FlowMeasurementServer, getDefaultFlowMeasurementClusterServer(measuredValue, minMeasuredValue, maxMeasuredValue));
1191
2116
  return this;
1192
2117
  }
2118
+ /**
2119
+ * Creates a default OccupancySensing cluster server with feature PassiveInfrared.
2120
+ *
2121
+ * @param {boolean} occupied - A boolean indicating whether the occupancy is occupied or not. Default is false.
2122
+ * @param {number} holdTime - The hold time in seconds. Default is 30.
2123
+ * @param {number} holdTimeMin - The minimum hold time in seconds. Default is 1.
2124
+ * @param {number} holdTimeMax - The maximum hold time in seconds. Default is 300.
2125
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2126
+ *
2127
+ * @remarks The default value for the occupancy sensor type is PIR.
2128
+ */
1193
2129
  createDefaultOccupancySensingClusterServer(occupied = false, holdTime = 30, holdTimeMin = 1, holdTimeMax = 300) {
1194
2130
  this.behaviors.require(OccupancySensingServer.with(OccupancySensing.Feature.PassiveInfrared), getDefaultOccupancySensingClusterServer(occupied, holdTime, holdTimeMin, holdTimeMax));
1195
2131
  return this;
1196
2132
  }
2133
+ /**
2134
+ * Creates a default AirQuality cluster server.
2135
+ *
2136
+ * @param {AirQuality.AirQualityEnum} airQuality The air quality level. Defaults to `AirQuality.AirQualityType.Unknown`.
2137
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2138
+ */
1197
2139
  createDefaultAirQualityClusterServer(airQuality = AirQuality.AirQualityEnum.Unknown) {
1198
2140
  this.behaviors.require(AirQualityServer.with(AirQuality.Feature.Fair, AirQuality.Feature.Moderate, AirQuality.Feature.VeryPoor, AirQuality.Feature.ExtremelyPoor), {
1199
2141
  airQuality,
1200
2142
  });
1201
2143
  return this;
1202
2144
  }
2145
+ /**
2146
+ * Creates a default TotalVolatileOrganicCompoundsConcentrationMeasurement cluster server with feature NumericMeasurement.
2147
+ *
2148
+ * @param {number | null} measuredValue - The measured value of the concentration.
2149
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
2150
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2151
+ * @param {number} [uncertainty] - The uncertainty value (optional).
2152
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2153
+ *
2154
+ * @remarks
2155
+ * The measurementUnit and the measurementMedium attributes are fixed and cannot be changed after creation.
2156
+ */
1203
2157
  createDefaultTvocMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air, uncertainty) {
1204
2158
  this.behaviors.require(TotalVolatileOrganicCompoundsConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1205
2159
  measuredValue,
@@ -1211,6 +2165,16 @@ export class MatterbridgeEndpoint extends Endpoint {
1211
2165
  });
1212
2166
  return this;
1213
2167
  }
2168
+ /**
2169
+ * Creates a default TotalVolatileOrganicCompoundsConcentrationMeasurement cluster server with feature LevelIndication.
2170
+
2171
+ * @param {ConcentrationMeasurement.LevelValue} levelValue - The level value of the measurement (default to ConcentrationMeasurement.LevelValue.Unknown).
2172
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The measurement medium (default to ConcentrationMeasurement.MeasurementMedium.Air).
2173
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2174
+ *
2175
+ * @remarks
2176
+ * The measurementMedium attribute is fixed and cannot be changed after creation.
2177
+ */
1214
2178
  createLevelTvocMeasurementClusterServer(levelValue = ConcentrationMeasurement.LevelValue.Unknown, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1215
2179
  this.behaviors.require(TotalVolatileOrganicCompoundsConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.LevelIndication, ConcentrationMeasurement.Feature.MediumLevel, ConcentrationMeasurement.Feature.CriticalLevel), {
1216
2180
  levelValue,
@@ -1218,6 +2182,17 @@ export class MatterbridgeEndpoint extends Endpoint {
1218
2182
  });
1219
2183
  return this;
1220
2184
  }
2185
+ /**
2186
+ * Create a default CarbonMonoxideConcentrationMeasurement cluster server with feature NumericMeasurement.
2187
+ *
2188
+ * @param {number | null} measuredValue - The measured value of the concentration.
2189
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
2190
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2191
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2192
+ *
2193
+ * @remarks
2194
+ * The measurementUnit and the measurementMedium attributes are fixed and cannot be changed after creation.
2195
+ */
1221
2196
  createDefaultCarbonMonoxideConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1222
2197
  this.behaviors.require(CarbonMonoxideConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1223
2198
  measuredValue,
@@ -1229,6 +2204,17 @@ export class MatterbridgeEndpoint extends Endpoint {
1229
2204
  });
1230
2205
  return this;
1231
2206
  }
2207
+ /**
2208
+ * Create a default CarbonDioxideConcentrationMeasurement cluster server with feature NumericMeasurement.
2209
+ *
2210
+ * @param {number | null} measuredValue - The measured value of the concentration.
2211
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
2212
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2213
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2214
+ *
2215
+ * @remarks
2216
+ * The measurementUnit and the measurementMedium attributes are fixed and cannot be changed after creation.
2217
+ */
1232
2218
  createDefaultCarbonDioxideConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1233
2219
  this.behaviors.require(CarbonDioxideConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1234
2220
  measuredValue,
@@ -1240,6 +2226,17 @@ export class MatterbridgeEndpoint extends Endpoint {
1240
2226
  });
1241
2227
  return this;
1242
2228
  }
2229
+ /**
2230
+ * Create a default FormaldehydeConcentrationMeasurement cluster server with feature NumericMeasurement.
2231
+ *
2232
+ * @param {number | null} measuredValue - The measured value of the concentration.
2233
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
2234
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2235
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2236
+ *
2237
+ * @remarks
2238
+ * The measurementUnit and the measurementMedium attributes are fixed and cannot be changed after creation.
2239
+ */
1243
2240
  createDefaultFormaldehydeConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1244
2241
  this.behaviors.require(FormaldehydeConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1245
2242
  measuredValue,
@@ -1251,6 +2248,17 @@ export class MatterbridgeEndpoint extends Endpoint {
1251
2248
  });
1252
2249
  return this;
1253
2250
  }
2251
+ /**
2252
+ * Create a default Pm1ConcentrationMeasurement cluster server with feature NumericMeasurement.
2253
+ *
2254
+ * @param {number | null} measuredValue - The measured value of the concentration.
2255
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
2256
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2257
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2258
+ *
2259
+ * @remarks
2260
+ * The measurementUnit and the measurementMedium attributes are fixed and cannot be changed after creation.
2261
+ */
1254
2262
  createDefaultPm1ConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1255
2263
  this.behaviors.require(Pm1ConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1256
2264
  measuredValue,
@@ -1262,6 +2270,17 @@ export class MatterbridgeEndpoint extends Endpoint {
1262
2270
  });
1263
2271
  return this;
1264
2272
  }
2273
+ /**
2274
+ * Create a default Pm25ConcentrationMeasurement cluster server with feature NumericMeasurement.
2275
+ *
2276
+ * @param {number | null} measuredValue - The measured value of the concentration.
2277
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
2278
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2279
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2280
+ *
2281
+ * @remarks
2282
+ * The measurementUnit and the measurementMedium attributes are fixed and cannot be changed after creation.
2283
+ */
1265
2284
  createDefaultPm25ConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1266
2285
  this.behaviors.require(Pm25ConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1267
2286
  measuredValue,
@@ -1273,6 +2292,17 @@ export class MatterbridgeEndpoint extends Endpoint {
1273
2292
  });
1274
2293
  return this;
1275
2294
  }
2295
+ /**
2296
+ * Create a default Pm10ConcentrationMeasurement cluster server with feature NumericMeasurement.
2297
+ *
2298
+ * @param {number | null} measuredValue - The measured value of the concentration.
2299
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
2300
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2301
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2302
+ *
2303
+ * @remarks
2304
+ * The measurementUnit and the measurementMedium attributes are fixed and cannot be changed after creation.
2305
+ */
1276
2306
  createDefaultPm10ConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1277
2307
  this.behaviors.require(Pm10ConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1278
2308
  measuredValue,
@@ -1284,6 +2314,17 @@ export class MatterbridgeEndpoint extends Endpoint {
1284
2314
  });
1285
2315
  return this;
1286
2316
  }
2317
+ /**
2318
+ * Create a default OzoneConcentrationMeasurement cluster server with feature NumericMeasurement.
2319
+ *
2320
+ * @param {number | null} measuredValue - The measured value of the concentration.
2321
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ugm3).
2322
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2323
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2324
+ *
2325
+ * @remarks
2326
+ * The measurementUnit and the measurementMedium attributes are fixed and cannot be changed after creation.
2327
+ */
1287
2328
  createDefaultOzoneConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ugm3, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1288
2329
  this.behaviors.require(OzoneConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1289
2330
  measuredValue,
@@ -1295,6 +2336,17 @@ export class MatterbridgeEndpoint extends Endpoint {
1295
2336
  });
1296
2337
  return this;
1297
2338
  }
2339
+ /**
2340
+ * Create a default RadonConcentrationMeasurement cluster server with feature NumericMeasurement.
2341
+ *
2342
+ * @param {number | null} measuredValue - The measured value of the concentration.
2343
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
2344
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2345
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2346
+ *
2347
+ * @remarks
2348
+ * The measurementUnit and the measurementMedium attributes are fixed and cannot be changed after creation.
2349
+ */
1298
2350
  createDefaultRadonConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1299
2351
  this.behaviors.require(RadonConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1300
2352
  measuredValue,
@@ -1306,6 +2358,17 @@ export class MatterbridgeEndpoint extends Endpoint {
1306
2358
  });
1307
2359
  return this;
1308
2360
  }
2361
+ /**
2362
+ * Create a default NitrogenDioxideConcentrationMeasurement cluster server with feature NumericMeasurement.
2363
+ *
2364
+ * @param {number | null} measuredValue - The measured value of the concentration.
2365
+ * @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ugm3).
2366
+ * @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
2367
+ * @returns {this} The current MatterbridgeEndpoint instance for chaining.
2368
+ *
2369
+ * @remarks
2370
+ * The measurementUnit and the measurementMedium attributes are fixed and cannot be changed after creation.
2371
+ */
1309
2372
  createDefaultNitrogenDioxideConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ugm3, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
1310
2373
  this.behaviors.require(NitrogenDioxideConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
1311
2374
  measuredValue,
@@ -1318,3 +2381,4 @@ export class MatterbridgeEndpoint extends Endpoint {
1318
2381
  return this;
1319
2382
  }
1320
2383
  }
2384
+ //# sourceMappingURL=matterbridgeEndpoint.js.map