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