matterbridge 3.1.6-dev-20250720-88d6141 → 3.1.6

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