matterbridge 2.1.2-dev.3 → 2.1.2
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/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 +231 -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 +743 -37
- 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 +690 -6
- package/dist/matterbridgeEndpoint.js.map +1 -0
- package/dist/matterbridgeEndpointHelpers.d.ts +2262 -0
- package/dist/matterbridgeEndpointHelpers.d.ts.map +1 -0
- package/dist/matterbridgeEndpointHelpers.js +96 -0
- package/dist/matterbridgeEndpointHelpers.js.map +1 -0
- package/dist/matterbridgePlatform.d.ts +152 -0
- package/dist/matterbridgePlatform.d.ts.map +1 -0
- package/dist/matterbridgePlatform.js +111 -3
- 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 +221 -0
- package/dist/utils/utils.d.ts.map +1 -0
- package/dist/utils/utils.js +251 -7
- 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, } 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,6 +149,7 @@ 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
|
+
// Convert the options to an Endpoint.Options
|
|
113
153
|
const optionsV8 = {
|
|
114
154
|
id: options.uniqueStorageKey?.replace(/[ .]/g, ''),
|
|
115
155
|
number: options.endpointId,
|
|
@@ -127,17 +167,41 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
127
167
|
}
|
|
128
168
|
else
|
|
129
169
|
this.deviceTypes.set(firstDefinition.code, firstDefinition);
|
|
130
|
-
|
|
170
|
+
// console.log('MatterbridgeEndpoint.option', options);
|
|
171
|
+
// console.log('MatterbridgeEndpoint.endpointV8', endpointV8);
|
|
172
|
+
// console.log('MatterbridgeEndpoint.optionsV8', optionsV8);
|
|
173
|
+
// Create the logger
|
|
174
|
+
this.log = new AnsiLogger({ logName: 'MatterbridgeEndpoint', logTimestampFormat: 4 /* TimestampFormat.TIME_MILLIS */, logLevel: debug === true ? "debug" /* LogLevel.DEBUG */ : MatterbridgeEndpoint.logLevel });
|
|
131
175
|
this.log.debug(`${YELLOW}new${db} MatterbridgeEndpoint: ${zb}${'0x' + firstDefinition.code.toString(16).padStart(4, '0')}${db}-${zb}${firstDefinition.name}${db} ` +
|
|
132
176
|
`id: ${CYAN}${options.uniqueStorageKey}${db} number: ${CYAN}${options.endpointId}${db} taglist: ${CYAN}${options.tagList ? debugStringify(options.tagList) : 'undefined'}${db}`);
|
|
177
|
+
// Add MatterbridgeBehavior with MatterbridgeBehaviorDevice
|
|
133
178
|
this.behaviors.require(MatterbridgeBehavior, { deviceCommand: new MatterbridgeBehaviorDevice(this.log, this.commandHandler, undefined) });
|
|
134
179
|
}
|
|
180
|
+
/**
|
|
181
|
+
* Loads an instance of the MatterbridgeEndpoint class.
|
|
182
|
+
*
|
|
183
|
+
* @param {DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>} definition - The DeviceTypeDefinition(s) of the device.
|
|
184
|
+
* @param {MatterbridgeEndpointOptions} [options={}] - The options for the device.
|
|
185
|
+
* @param {boolean} [debug=false] - Debug flag.
|
|
186
|
+
* @returns {Promise<MatterbridgeEndpoint>} MatterbridgeEndpoint instance.
|
|
187
|
+
*/
|
|
135
188
|
static async loadInstance(definition, options = {}, debug = false) {
|
|
136
189
|
return new MatterbridgeEndpoint(definition, options, debug);
|
|
137
190
|
}
|
|
191
|
+
/**
|
|
192
|
+
* Get all the device types of this endpoint.
|
|
193
|
+
*
|
|
194
|
+
* @returns {DeviceTypeDefinition[]} The device types of this endpoint.
|
|
195
|
+
*/
|
|
138
196
|
getDeviceTypes() {
|
|
139
197
|
return Array.from(this.deviceTypes.values());
|
|
140
198
|
}
|
|
199
|
+
/**
|
|
200
|
+
* Checks if the provided cluster server is supported by this endpoint.
|
|
201
|
+
*
|
|
202
|
+
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to check.
|
|
203
|
+
* @returns {boolean} True if the cluster server is supported, false otherwise.
|
|
204
|
+
*/
|
|
141
205
|
hasClusterServer(cluster) {
|
|
142
206
|
const behavior = getBehavior(this, cluster);
|
|
143
207
|
if (behavior)
|
|
@@ -145,6 +209,13 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
145
209
|
else
|
|
146
210
|
return false;
|
|
147
211
|
}
|
|
212
|
+
/**
|
|
213
|
+
* Checks if the provided attribute server is supported for a given cluster of this endpoint.
|
|
214
|
+
*
|
|
215
|
+
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to check.
|
|
216
|
+
* @param {string} attribute - The attribute name to check.
|
|
217
|
+
* @returns {boolean} True if the attribute server is supported, false otherwise.
|
|
218
|
+
*/
|
|
148
219
|
hasAttributeServer(cluster, attribute) {
|
|
149
220
|
const behavior = getBehavior(this, cluster);
|
|
150
221
|
if (!behavior || !this.behaviors.supported[behavior.id])
|
|
@@ -153,26 +224,71 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
153
224
|
const defaults = this.behaviors.defaultsFor(behavior);
|
|
154
225
|
return lowercaseFirstLetter(attribute) in options || lowercaseFirstLetter(attribute) in defaults;
|
|
155
226
|
}
|
|
227
|
+
/**
|
|
228
|
+
* Retrieves the initial options for the provided cluster server.
|
|
229
|
+
*
|
|
230
|
+
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to get options for.
|
|
231
|
+
* @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.
|
|
232
|
+
*/
|
|
156
233
|
getClusterServerOptions(cluster) {
|
|
157
234
|
const behavior = getBehavior(this, cluster);
|
|
158
235
|
if (!behavior)
|
|
159
236
|
return undefined;
|
|
160
237
|
return this.behaviors.optionsFor(behavior);
|
|
161
238
|
}
|
|
239
|
+
/**
|
|
240
|
+
* Retrieves the value of the provided attribute from the given cluster.
|
|
241
|
+
*
|
|
242
|
+
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to retrieve the attribute from.
|
|
243
|
+
* @param {string} attribute - The name of the attribute to retrieve.
|
|
244
|
+
* @param {AnsiLogger} [log] - Optional logger for error and info messages.
|
|
245
|
+
* @returns {any} The value of the attribute, or undefined if the attribute is not found.
|
|
246
|
+
*/
|
|
247
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
162
248
|
getAttribute(cluster, attribute, log) {
|
|
163
249
|
return getAttribute(this, cluster, attribute, log);
|
|
164
250
|
}
|
|
251
|
+
/**
|
|
252
|
+
* Sets the value of an attribute on a cluster server.
|
|
253
|
+
*
|
|
254
|
+
* @param {Behavior.Type | ClusterType | ClusterId | string} clusterId - The ID of the cluster.
|
|
255
|
+
* @param {string} attribute - The name of the attribute.
|
|
256
|
+
* @param {boolean | number | bigint | string | object | null} value - The value to set for the attribute.
|
|
257
|
+
* @param {AnsiLogger} [log] - (Optional) The logger to use for logging errors and information.
|
|
258
|
+
* @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the attribute was successfully set.
|
|
259
|
+
*/
|
|
165
260
|
async setAttribute(clusterId, attribute, value, log) {
|
|
166
261
|
return await setAttribute(this, clusterId, attribute, value, log);
|
|
167
262
|
}
|
|
263
|
+
/**
|
|
264
|
+
* Update the value of an attribute on a cluster server only if the value is different.
|
|
265
|
+
*
|
|
266
|
+
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to set the attribute on.
|
|
267
|
+
* @param {string} attribute - The name of the attribute.
|
|
268
|
+
* @param {boolean | number | bigint | string | object | null} value - The value to set for the attribute.
|
|
269
|
+
* @param {AnsiLogger} [log] - (Optional) The logger to use for logging the update. Errors are logged to the endpoint logger.
|
|
270
|
+
* @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the attribute was successfully set.
|
|
271
|
+
*/
|
|
168
272
|
async updateAttribute(cluster, attribute, value, log) {
|
|
169
273
|
return await updateAttribute(this, cluster, attribute, value, log);
|
|
170
274
|
}
|
|
275
|
+
/**
|
|
276
|
+
* Subscribes to the provided attribute on a cluster.
|
|
277
|
+
*
|
|
278
|
+
* @param {ClusterId} clusterId - The ID of the cluster.
|
|
279
|
+
* @param {string} attribute - The name of the attribute to subscribe to.
|
|
280
|
+
* @param {(newValue: any, oldValue: any) => void} listener - A callback function that will be called when the attribute value changes.
|
|
281
|
+
* @param {AnsiLogger} [log] - Optional logger for logging errors and information.
|
|
282
|
+
* @returns {boolean} - A boolean indicating whether the subscription was successful.
|
|
283
|
+
*/
|
|
284
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
171
285
|
async subscribeAttribute(clusterId, attribute, listener, log) {
|
|
172
286
|
const clusterName = lowercaseFirstLetter(getClusterNameById(clusterId));
|
|
173
287
|
if (this.construction.status !== Lifecycle.Status.Active) {
|
|
288
|
+
// 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`);
|
|
174
289
|
await this.construction.ready;
|
|
175
290
|
}
|
|
291
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
176
292
|
const events = this.events;
|
|
177
293
|
if (!(clusterName in events)) {
|
|
178
294
|
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}`);
|
|
@@ -187,68 +303,157 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
187
303
|
log?.info(`${db}Subscribed endpoint ${or}${this.id}${db}:${or}${this.number}${db} attribute ${hk}${capitalizeFirstLetter(clusterName)}${db}.${hk}${attribute}${db}`);
|
|
188
304
|
return true;
|
|
189
305
|
}
|
|
306
|
+
/**
|
|
307
|
+
* Triggers an event on the specified cluster.
|
|
308
|
+
*
|
|
309
|
+
* @param {ClusterId} clusterId - The ID of the cluster.
|
|
310
|
+
* @param {string} event - The name of the event to trigger.
|
|
311
|
+
* @param {Record<string, boolean | number | bigint | string | object | undefined | null>} payload - The payload to pass to the event.
|
|
312
|
+
* @param {AnsiLogger} [log] - Optional logger for logging information.
|
|
313
|
+
* @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the event was successfully triggered.
|
|
314
|
+
*/
|
|
190
315
|
async triggerEvent(clusterId, event, payload, log) {
|
|
191
316
|
const clusterName = lowercaseFirstLetter(getClusterNameById(clusterId));
|
|
192
317
|
if (this.construction.status !== Lifecycle.Status.Active) {
|
|
193
318
|
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`);
|
|
194
319
|
return false;
|
|
195
320
|
}
|
|
321
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
196
322
|
const events = this.events;
|
|
197
323
|
if (!(clusterName in events) || !(event in events[clusterName])) {
|
|
198
324
|
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}`);
|
|
199
325
|
return false;
|
|
200
326
|
}
|
|
327
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
328
|
+
// @ts-ignore
|
|
201
329
|
await this.act((agent) => agent[clusterName].events[event].emit(payload, agent.context));
|
|
202
330
|
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} `);
|
|
203
331
|
return true;
|
|
204
332
|
}
|
|
333
|
+
/**
|
|
334
|
+
* Adds cluster servers from the provided server list.
|
|
335
|
+
*
|
|
336
|
+
* @param {ClusterId[]} serverList - The list of cluster IDs to add.
|
|
337
|
+
* @returns {Promise<this>} The current MatterbridgeEndpoint instance for chaining.
|
|
338
|
+
*/
|
|
205
339
|
addClusterServers(serverList) {
|
|
206
340
|
addClusterServers(this, serverList);
|
|
207
341
|
}
|
|
342
|
+
/**
|
|
343
|
+
* Adds a fixed label to the FixedLabel cluster. If the cluster server is not present, it will be added.
|
|
344
|
+
*
|
|
345
|
+
* @param {string} label - The label to add.
|
|
346
|
+
* @param {string} value - The value of the label.
|
|
347
|
+
* @returns {Promise<this>} The current MatterbridgeEndpoint instance for chaining.
|
|
348
|
+
*/
|
|
208
349
|
async addFixedLabel(label, value) {
|
|
209
350
|
await addFixedLabel(this, label, value);
|
|
210
351
|
return this;
|
|
211
352
|
}
|
|
353
|
+
/**
|
|
354
|
+
* Adds a user label to the UserLabel cluster. If the cluster server is not present, it will be added.
|
|
355
|
+
*
|
|
356
|
+
* @param {string} label - The label to add.
|
|
357
|
+
* @param {string} value - The value of the label.
|
|
358
|
+
* @returns {Promise<this>} The current MatterbridgeEndpoint instance for chaining.
|
|
359
|
+
*/
|
|
212
360
|
async addUserLabel(label, value) {
|
|
213
361
|
await addUserLabel(this, label, value);
|
|
214
362
|
return this;
|
|
215
363
|
}
|
|
364
|
+
/**
|
|
365
|
+
* Adds a command handler for the specified command.
|
|
366
|
+
*
|
|
367
|
+
* @param {keyof MatterbridgeEndpointCommands} command - The command to add the handler for.
|
|
368
|
+
* @param {HandlerFunction} handler - The handler function to execute when the command is received.
|
|
369
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
370
|
+
*/
|
|
216
371
|
addCommandHandler(command, handler) {
|
|
217
372
|
this.commandHandler.addHandler(command, handler);
|
|
218
373
|
return this;
|
|
219
374
|
}
|
|
375
|
+
/**
|
|
376
|
+
* Execute the command handler for the specified command. Mainly used in Jest tests.
|
|
377
|
+
*
|
|
378
|
+
* @param {keyof MatterbridgeEndpointCommands} command - The command to execute.
|
|
379
|
+
* @param {Record<string, boolean | number | bigint | string | object | null>} request - The optional request to pass to the handler function.
|
|
380
|
+
* @returns {Promise<void>} A promise that resolves when the command handler has been executed
|
|
381
|
+
*/
|
|
220
382
|
async executeCommandHandler(command, request) {
|
|
221
383
|
await this.commandHandler.executeHandler(command, { request });
|
|
222
384
|
}
|
|
385
|
+
/**
|
|
386
|
+
* Adds the required cluster servers (only if they are not present) for the device types of the specified endpoint.
|
|
387
|
+
*
|
|
388
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
389
|
+
*/
|
|
223
390
|
addRequiredClusterServers() {
|
|
224
391
|
addRequiredClusterServers(this);
|
|
225
392
|
return this;
|
|
226
393
|
}
|
|
394
|
+
/**
|
|
395
|
+
* Adds the optional cluster servers (only if they are not present) for the device types of the specified endpoint.
|
|
396
|
+
*
|
|
397
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
398
|
+
*/
|
|
227
399
|
addOptionalClusterServers() {
|
|
228
400
|
addOptionalClusterServers(this);
|
|
229
401
|
return this;
|
|
230
402
|
}
|
|
403
|
+
/**
|
|
404
|
+
* Retrieves all cluster servers.
|
|
405
|
+
*
|
|
406
|
+
* @returns {Behavior.Type[]} An array of all cluster servers.
|
|
407
|
+
*/
|
|
231
408
|
getAllClusterServers() {
|
|
232
409
|
return Object.values(this.behaviors.supported);
|
|
233
410
|
}
|
|
411
|
+
/**
|
|
412
|
+
* Retrieves the names of all cluster servers.
|
|
413
|
+
*
|
|
414
|
+
* @returns {string[]} An array of all cluster server names.
|
|
415
|
+
*/
|
|
234
416
|
getAllClusterServerNames() {
|
|
235
417
|
return Object.keys(this.behaviors.supported);
|
|
236
418
|
}
|
|
419
|
+
/**
|
|
420
|
+
* Iterates over each attribute of each cluster server of the device state and calls the provided callback function.
|
|
421
|
+
*
|
|
422
|
+
* @param {Function} callback - The callback function to call with the cluster name, cluster id, attribute name, attribute id and attribute value.
|
|
423
|
+
*/
|
|
237
424
|
forEachAttribute(callback) {
|
|
238
425
|
for (const [clusterName, clusterAttributes] of Object.entries(this.state)) {
|
|
239
426
|
for (const [attributeName, attributeValue] of Object.entries(clusterAttributes)) {
|
|
240
427
|
const clusterId = getClusterId(this, clusterName);
|
|
241
428
|
if (clusterId === undefined) {
|
|
429
|
+
// this.log.error(`forEachAttribute error: cluster ${clusterName} not found`);
|
|
242
430
|
continue;
|
|
243
431
|
}
|
|
244
432
|
const attributeId = getAttributeId(this, clusterName, attributeName);
|
|
245
433
|
if (attributeId === undefined) {
|
|
434
|
+
// this.log.error(`forEachAttribute error: attribute ${clusterName}.${attributeName} not found`);
|
|
246
435
|
continue;
|
|
247
436
|
}
|
|
248
437
|
callback(clusterName, clusterId, attributeName, attributeId, attributeValue);
|
|
249
438
|
}
|
|
250
439
|
}
|
|
251
440
|
}
|
|
441
|
+
/**
|
|
442
|
+
* Adds a child endpoint with the specified device types and options.
|
|
443
|
+
* If the child endpoint is not already present, it will be created and added.
|
|
444
|
+
* If the child endpoint is already present, the device types will be added to the existing child endpoint.
|
|
445
|
+
*
|
|
446
|
+
* @param {string} endpointName - The name of the new endpoint to add.
|
|
447
|
+
* @param {DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>} definition - The device types to add.
|
|
448
|
+
* @param {MatterbridgeEndpointOptions} [options={}] - The options for the endpoint.
|
|
449
|
+
* @param {boolean} [debug=false] - Whether to enable debug logging.
|
|
450
|
+
* @returns {MatterbridgeEndpoint} - The child endpoint that was found or added.
|
|
451
|
+
*
|
|
452
|
+
* @example
|
|
453
|
+
* ```typescript
|
|
454
|
+
* const endpoint = device.addChildDeviceType('Temperature', [temperatureSensor], { tagList: [{ mfgCode: null, namespaceId: LocationTag.Indoor.namespaceId, tag: LocationTag.Indoor.tag, label: null }] }, true);
|
|
455
|
+
* ```
|
|
456
|
+
*/
|
|
252
457
|
addChildDeviceType(endpointName, definition, options = {}, debug = false) {
|
|
253
458
|
this.log.debug(`addChildDeviceType: ${CYAN}${endpointName}${db}`);
|
|
254
459
|
let alreadyAdded = false;
|
|
@@ -288,6 +493,23 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
288
493
|
}
|
|
289
494
|
return child;
|
|
290
495
|
}
|
|
496
|
+
/**
|
|
497
|
+
* Adds a child endpoint with one or more device types with the required cluster servers and the specified cluster servers.
|
|
498
|
+
* If the child endpoint is not already present in the childEndpoints, it will be added.
|
|
499
|
+
* If the child endpoint is already present in the childEndpoints, the device types and cluster servers will be added to the existing child endpoint.
|
|
500
|
+
*
|
|
501
|
+
* @param {string} endpointName - The name of the new enpoint to add.
|
|
502
|
+
* @param {DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>} definition - The device types to add.
|
|
503
|
+
* @param {ClusterId[]} [serverList=[]] - The list of cluster IDs to include.
|
|
504
|
+
* @param {MatterbridgeEndpointOptions} [options={}] - The options for the device.
|
|
505
|
+
* @param {boolean} [debug=false] - Whether to enable debug logging.
|
|
506
|
+
* @returns {MatterbridgeEndpoint} - The child endpoint that was found or added.
|
|
507
|
+
*
|
|
508
|
+
* @example
|
|
509
|
+
* ```typescript
|
|
510
|
+
* const endpoint = device.addChildDeviceTypeWithClusterServer('Temperature', [temperatureSensor], [], { tagList: [{ mfgCode: null, namespaceId: LocationTag.Indoor.namespaceId, tag: LocationTag.Indoor.tag, label: null }] }, true);
|
|
511
|
+
* ```
|
|
512
|
+
*/
|
|
291
513
|
addChildDeviceTypeWithClusterServer(endpointName, definition, serverList = [], options = {}, debug = false) {
|
|
292
514
|
this.log.debug(`addChildDeviceTypeWithClusterServer: ${CYAN}${endpointName}${db}`);
|
|
293
515
|
let alreadyAdded = false;
|
|
@@ -350,15 +572,38 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
350
572
|
}
|
|
351
573
|
return child;
|
|
352
574
|
}
|
|
575
|
+
/**
|
|
576
|
+
* Retrieves a child endpoint by its name.
|
|
577
|
+
*
|
|
578
|
+
* @param {string} endpointName - The name of the endpoint to retrieve.
|
|
579
|
+
* @returns {Endpoint | undefined} The child endpoint with the specified name, or undefined if not found.
|
|
580
|
+
*/
|
|
353
581
|
getChildEndpointByName(endpointName) {
|
|
354
582
|
return this.parts.find((part) => part.id === endpointName);
|
|
355
583
|
}
|
|
584
|
+
/**
|
|
585
|
+
* Retrieves a child endpoint by its EndpointNumber.
|
|
586
|
+
*
|
|
587
|
+
* @param {EndpointNumber} endpointNumber - The EndpointNumber of the endpoint to retrieve.
|
|
588
|
+
* @returns {MatterbridgeEndpoint | undefined} The child endpoint with the specified EndpointNumber, or undefined if not found.
|
|
589
|
+
*/
|
|
356
590
|
getChildEndpoint(endpointNumber) {
|
|
357
591
|
return this.parts.find((part) => part.number === endpointNumber);
|
|
358
592
|
}
|
|
593
|
+
/**
|
|
594
|
+
* Get all the child endpoints of this endpoint.
|
|
595
|
+
*
|
|
596
|
+
* @returns {MatterbridgeEndpoint[]} The child endpoints.
|
|
597
|
+
*/
|
|
359
598
|
getChildEndpoints() {
|
|
360
599
|
return Array.from(this.parts);
|
|
361
600
|
}
|
|
601
|
+
/**
|
|
602
|
+
* Serializes the Matterbridge device into a serialized object.
|
|
603
|
+
*
|
|
604
|
+
* @param pluginName - The name of the plugin.
|
|
605
|
+
* @returns The serialized Matterbridge device object.
|
|
606
|
+
*/
|
|
362
607
|
static serialize(device) {
|
|
363
608
|
if (!device.serialNumber || !device.deviceName || !device.uniqueId)
|
|
364
609
|
return;
|
|
@@ -381,9 +626,15 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
381
626
|
serialized.clusterServersId.push(BridgedDeviceBasicInformation.Cluster.id);
|
|
382
627
|
if (behaviorName === 'powerSource')
|
|
383
628
|
serialized.clusterServersId.push(PowerSource.Cluster.id);
|
|
629
|
+
// serialized.clusterServersId.push(this.behaviors.supported[behaviorName]cluster.id);
|
|
384
630
|
});
|
|
385
631
|
return serialized;
|
|
386
632
|
}
|
|
633
|
+
/**
|
|
634
|
+
* Deserializes the device into a serialized object.
|
|
635
|
+
*
|
|
636
|
+
* @returns The deserialized MatterbridgeDevice.
|
|
637
|
+
*/
|
|
387
638
|
static deserialize(serializedDevice) {
|
|
388
639
|
const device = new MatterbridgeEndpoint(serializedDevice.deviceTypes, { uniqueStorageKey: serializedDevice.endpointName, endpointId: serializedDevice.endpoint }, false);
|
|
389
640
|
device.plugin = serializedDevice.pluginName;
|
|
@@ -399,9 +650,16 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
399
650
|
device.createDefaultBridgedDeviceBasicInformationClusterServer(serializedDevice.deviceName, serializedDevice.serialNumber, serializedDevice.vendorId ?? 0xfff1, serializedDevice.vendorName ?? 'Matterbridge', serializedDevice.productName ?? 'Matterbridge device');
|
|
400
651
|
else if (clusterId === PowerSource.Cluster.id)
|
|
401
652
|
device.createDefaultPowerSourceWiredClusterServer();
|
|
653
|
+
// else addClusterServerFromList(device, [clusterId]);
|
|
402
654
|
}
|
|
403
655
|
return device;
|
|
404
656
|
}
|
|
657
|
+
/**
|
|
658
|
+
* Creates a default power source wired cluster server.
|
|
659
|
+
*
|
|
660
|
+
* @param wiredCurrentType - The type of wired current (default: PowerSource.WiredCurrentType.Ac)
|
|
661
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
662
|
+
*/
|
|
405
663
|
createDefaultPowerSourceWiredClusterServer(wiredCurrentType = PowerSource.WiredCurrentType.Ac) {
|
|
406
664
|
this.behaviors.require(PowerSourceServer.with(PowerSource.Feature.Wired), {
|
|
407
665
|
wiredCurrentType,
|
|
@@ -412,6 +670,16 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
412
670
|
});
|
|
413
671
|
return this;
|
|
414
672
|
}
|
|
673
|
+
/**
|
|
674
|
+
* Creates a default power source replaceable battery cluster server.
|
|
675
|
+
*
|
|
676
|
+
* @param batPercentRemaining - The remaining battery percentage (default: 100).
|
|
677
|
+
* @param batChargeLevel - The battery charge level (default: PowerSource.BatChargeLevel.Ok).
|
|
678
|
+
* @param batVoltage - The battery voltage (default: 1500).
|
|
679
|
+
* @param batReplacementDescription - The battery replacement description (default: 'Battery type').
|
|
680
|
+
* @param batQuantity - The battery quantity (default: 1).
|
|
681
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
682
|
+
*/
|
|
415
683
|
createDefaultPowerSourceReplaceableBatteryClusterServer(batPercentRemaining = 100, batChargeLevel = PowerSource.BatChargeLevel.Ok, batVoltage = 1500, batReplacementDescription = 'Battery type', batQuantity = 1) {
|
|
416
684
|
this.behaviors.require(PowerSourceServer.with(PowerSource.Feature.Battery, PowerSource.Feature.Replaceable), {
|
|
417
685
|
status: PowerSource.PowerSourceStatus.Active,
|
|
@@ -429,6 +697,14 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
429
697
|
});
|
|
430
698
|
return this;
|
|
431
699
|
}
|
|
700
|
+
/**
|
|
701
|
+
* Creates a default power source rechargeable battery cluster server.
|
|
702
|
+
*
|
|
703
|
+
* @param batPercentRemaining - The remaining battery percentage (default: 100).
|
|
704
|
+
* @param batChargeLevel - The battery charge level (default: PowerSource.BatChargeLevel.Ok).
|
|
705
|
+
* @param batVoltage - The battery voltage (default: 1500).
|
|
706
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
707
|
+
*/
|
|
432
708
|
createDefaultPowerSourceRechargeableBatteryClusterServer(batPercentRemaining = 100, batChargeLevel = PowerSource.BatChargeLevel.Ok, batVoltage = 1500) {
|
|
433
709
|
this.behaviors.require(PowerSourceServer.with(PowerSource.Feature.Battery, PowerSource.Feature.Rechargeable), {
|
|
434
710
|
status: PowerSource.PowerSourceStatus.Active,
|
|
@@ -447,6 +723,21 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
447
723
|
});
|
|
448
724
|
return this;
|
|
449
725
|
}
|
|
726
|
+
/**
|
|
727
|
+
* Creates a default Basic Information Cluster Server for the server node.
|
|
728
|
+
*
|
|
729
|
+
* @param deviceName - The name of the device.
|
|
730
|
+
* @param serialNumber - The serial number of the device.
|
|
731
|
+
* @param vendorId - The vendor ID of the device.
|
|
732
|
+
* @param vendorName - The vendor name of the device.
|
|
733
|
+
* @param productId - The product ID of the device.
|
|
734
|
+
* @param productName - The product name of the device.
|
|
735
|
+
* @param softwareVersion - The software version of the device. Default is 1.
|
|
736
|
+
* @param softwareVersionString - The software version string of the device. Default is 'v.1.0.0'.
|
|
737
|
+
* @param hardwareVersion - The hardware version of the device. Default is 1.
|
|
738
|
+
* @param hardwareVersionString - The hardware version string of the device. Default is 'v.1.0.0'.
|
|
739
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
740
|
+
*/
|
|
450
741
|
createDefaultBasicInformationClusterServer(deviceName, serialNumber, vendorId, vendorName, productId, productName, softwareVersion = 1, softwareVersionString = '1.0.0', hardwareVersion = 1, hardwareVersionString = '1.0.0') {
|
|
451
742
|
this.log.logName = deviceName;
|
|
452
743
|
this.deviceName = deviceName;
|
|
@@ -470,6 +761,20 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
470
761
|
}
|
|
471
762
|
return this;
|
|
472
763
|
}
|
|
764
|
+
/**
|
|
765
|
+
* Creates a default BridgedDeviceBasicInformationClusterServer for the aggregator endpoints.
|
|
766
|
+
*
|
|
767
|
+
* @param deviceName - The name of the device.
|
|
768
|
+
* @param serialNumber - The serial number of the device.
|
|
769
|
+
* @param vendorId - The vendor ID of the device.
|
|
770
|
+
* @param vendorName - The name of the vendor.
|
|
771
|
+
* @param productName - The name of the product.
|
|
772
|
+
* @param softwareVersion - The software version of the device. Default is 1.
|
|
773
|
+
* @param softwareVersionString - The software version string of the device. Default is 'v.1.0.0'.
|
|
774
|
+
* @param hardwareVersion - The hardware version of the device. Default is 1.
|
|
775
|
+
* @param hardwareVersionString - The hardware version string of the device. Default is 'v.1.0.0'.
|
|
776
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
777
|
+
*/
|
|
473
778
|
createDefaultBridgedDeviceBasicInformationClusterServer(deviceName, serialNumber, vendorId, vendorName, productName, softwareVersion = 1, softwareVersionString = '1.0.0', hardwareVersion = 1, hardwareVersionString = '1.0.0') {
|
|
474
779
|
this.log.logName = deviceName;
|
|
475
780
|
this.deviceName = deviceName;
|
|
@@ -486,7 +791,7 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
486
791
|
this.behaviors.require(BridgedDeviceBasicInformationServer.enable({
|
|
487
792
|
events: { leave: true, reachableChanged: true },
|
|
488
793
|
}), {
|
|
489
|
-
vendorId: vendorId !== undefined ? VendorId(vendorId) : undefined,
|
|
794
|
+
vendorId: vendorId !== undefined ? VendorId(vendorId) : undefined, // 4874
|
|
490
795
|
vendorName: vendorName.slice(0, 32),
|
|
491
796
|
productName: productName.slice(0, 32),
|
|
492
797
|
productUrl: this.productUrl,
|
|
@@ -502,6 +807,13 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
502
807
|
});
|
|
503
808
|
return this;
|
|
504
809
|
}
|
|
810
|
+
/**
|
|
811
|
+
* Creates a default identify cluster server with the specified identify time and type.
|
|
812
|
+
*
|
|
813
|
+
* @param {number} [identifyTime=0] - The time to identify the server. Defaults to 0.
|
|
814
|
+
* @param {Identify.IdentifyType} [identifyType=Identify.IdentifyType.None] - The type of identification. Defaults to Identify.IdentifyType.None.
|
|
815
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
816
|
+
*/
|
|
505
817
|
createDefaultIdentifyClusterServer(identifyTime = 0, identifyType = Identify.IdentifyType.None) {
|
|
506
818
|
this.behaviors.require(MatterbridgeIdentifyServer, {
|
|
507
819
|
identifyTime,
|
|
@@ -509,14 +821,32 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
509
821
|
});
|
|
510
822
|
return this;
|
|
511
823
|
}
|
|
824
|
+
/**
|
|
825
|
+
* Creates a default groups cluster server.
|
|
826
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
827
|
+
*/
|
|
512
828
|
createDefaultGroupsClusterServer() {
|
|
513
829
|
this.behaviors.require(GroupsServer);
|
|
514
830
|
return this;
|
|
515
831
|
}
|
|
832
|
+
/**
|
|
833
|
+
* Creates a default scenes management cluster server.
|
|
834
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
835
|
+
*/
|
|
516
836
|
createDefaultScenesClusterServer() {
|
|
517
837
|
this.behaviors.require(ScenesManagementServer);
|
|
518
838
|
return this;
|
|
519
839
|
}
|
|
840
|
+
/**
|
|
841
|
+
* Creates a default OnOff cluster server for light devices.
|
|
842
|
+
*
|
|
843
|
+
* @param {boolean} [onOff=false] - The initial state of the OnOff cluster.
|
|
844
|
+
* @param {boolean} [globalSceneControl=false] - The global scene control state.
|
|
845
|
+
* @param {number} [onTime=0] - The on time value.
|
|
846
|
+
* @param {number} [offWaitTime=0] - The off wait time value.
|
|
847
|
+
* @param {OnOff.StartUpOnOff | null} [startUpOnOff=null] - The start-up OnOff state. Null means previous state.
|
|
848
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
849
|
+
*/
|
|
520
850
|
createDefaultOnOffClusterServer(onOff = false, globalSceneControl = false, onTime = 0, offWaitTime = 0, startUpOnOff = null) {
|
|
521
851
|
this.behaviors.require(MatterbridgeOnOffServer.with(OnOff.Feature.Lighting), {
|
|
522
852
|
onOff,
|
|
@@ -527,18 +857,40 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
527
857
|
});
|
|
528
858
|
return this;
|
|
529
859
|
}
|
|
860
|
+
/**
|
|
861
|
+
* Creates an OnOff cluster server without features.
|
|
862
|
+
*
|
|
863
|
+
* @param {boolean} [onOff=false] - The initial state of the OnOff cluster.
|
|
864
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
865
|
+
*/
|
|
530
866
|
createOnOffClusterServer(onOff = false) {
|
|
531
867
|
this.behaviors.require(MatterbridgeOnOffServer, {
|
|
532
868
|
onOff,
|
|
533
869
|
});
|
|
534
870
|
return this;
|
|
535
871
|
}
|
|
872
|
+
/**
|
|
873
|
+
* Creates a DeadFront OnOff cluster server.
|
|
874
|
+
*
|
|
875
|
+
* @param {boolean} [onOff=false] - The initial state of the OnOff cluster.
|
|
876
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
877
|
+
*/
|
|
536
878
|
createDeadFrontOnOffClusterServer(onOff = false) {
|
|
537
879
|
this.behaviors.require(MatterbridgeOnOffServer.with(OnOff.Feature.DeadFrontBehavior), {
|
|
538
880
|
onOff,
|
|
539
881
|
});
|
|
540
882
|
return this;
|
|
541
883
|
}
|
|
884
|
+
/**
|
|
885
|
+
* Creates a default level control cluster server for light devices.
|
|
886
|
+
*
|
|
887
|
+
* @param {number} [currentLevel=254] - The current level (default: 254).
|
|
888
|
+
* @param {number} [minLevel=1] - The minimum level (default: 1).
|
|
889
|
+
* @param {number} [maxLevel=254] - The maximum level (default: 254).
|
|
890
|
+
* @param {number | null} [onLevel=null] - The on level (default: null).
|
|
891
|
+
* @param {number | null} [startUpCurrentLevel=null] - The startUp on level (default: null).
|
|
892
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
893
|
+
*/
|
|
542
894
|
createDefaultLevelControlClusterServer(currentLevel = 254, minLevel = 1, maxLevel = 254, onLevel = null, startUpCurrentLevel = null) {
|
|
543
895
|
this.behaviors.require(MatterbridgeLevelControlServer.with(LevelControl.Feature.OnOff, LevelControl.Feature.Lighting), {
|
|
544
896
|
currentLevel,
|
|
@@ -554,6 +906,18 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
554
906
|
});
|
|
555
907
|
return this;
|
|
556
908
|
}
|
|
909
|
+
/**
|
|
910
|
+
* Creates a default color control cluster server with Xy, HueSaturation and ColorTemperature.
|
|
911
|
+
*
|
|
912
|
+
* @param currentX - The current X value.
|
|
913
|
+
* @param currentY - The current Y value.
|
|
914
|
+
* @param currentHue - The current hue value.
|
|
915
|
+
* @param currentSaturation - The current saturation value.
|
|
916
|
+
* @param colorTemperatureMireds - The color temperature in mireds.
|
|
917
|
+
* @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds.
|
|
918
|
+
* @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds.
|
|
919
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
920
|
+
*/
|
|
557
921
|
createDefaultColorControlClusterServer(currentX = 0, currentY = 0, currentHue = 0, currentSaturation = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
|
|
558
922
|
this.behaviors.require(MatterbridgeColorControlServer.with(ColorControl.Feature.Xy, ColorControl.Feature.HueSaturation, ColorControl.Feature.ColorTemperature), {
|
|
559
923
|
colorMode: ColorControl.ColorMode.CurrentHueAndCurrentSaturation,
|
|
@@ -576,6 +940,19 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
576
940
|
});
|
|
577
941
|
return this;
|
|
578
942
|
}
|
|
943
|
+
/**
|
|
944
|
+
* Creates a Xy color control cluster server with Xy and ColorTemperature.
|
|
945
|
+
*
|
|
946
|
+
* @param currentX - The current X value.
|
|
947
|
+
* @param currentY - The current Y value.
|
|
948
|
+
* @param colorTemperatureMireds - The color temperature in mireds.
|
|
949
|
+
* @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds.
|
|
950
|
+
* @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds.
|
|
951
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
952
|
+
*
|
|
953
|
+
* @remarks
|
|
954
|
+
* From zigbee to matter = Math.max(Math.min(Math.round(x * 65536), 65279), 0)
|
|
955
|
+
*/
|
|
579
956
|
createXyColorControlClusterServer(currentX = 0, currentY = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
|
|
580
957
|
this.behaviors.require(MatterbridgeColorControlServer.with(ColorControl.Feature.Xy, ColorControl.Feature.ColorTemperature), {
|
|
581
958
|
colorMode: ColorControl.ColorMode.CurrentXAndCurrentY,
|
|
@@ -596,6 +973,16 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
596
973
|
});
|
|
597
974
|
return this;
|
|
598
975
|
}
|
|
976
|
+
/**
|
|
977
|
+
* Creates a default hue and saturation control cluster server with HueSaturation and ColorTemperature.
|
|
978
|
+
*
|
|
979
|
+
* @param currentHue - The current hue value.
|
|
980
|
+
* @param currentSaturation - The current saturation value.
|
|
981
|
+
* @param colorTemperatureMireds - The color temperature in mireds.
|
|
982
|
+
* @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds.
|
|
983
|
+
* @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds.
|
|
984
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
985
|
+
*/
|
|
599
986
|
createHsColorControlClusterServer(currentHue = 0, currentSaturation = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
|
|
600
987
|
this.behaviors.require(MatterbridgeColorControlServer.with(ColorControl.Feature.HueSaturation, ColorControl.Feature.ColorTemperature), {
|
|
601
988
|
colorMode: ColorControl.ColorMode.CurrentHueAndCurrentSaturation,
|
|
@@ -616,6 +1003,14 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
616
1003
|
});
|
|
617
1004
|
return this;
|
|
618
1005
|
}
|
|
1006
|
+
/**
|
|
1007
|
+
* Creates a color temperature color control cluster server.
|
|
1008
|
+
*
|
|
1009
|
+
* @param colorTemperatureMireds - The color temperature in mireds.
|
|
1010
|
+
* @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds.
|
|
1011
|
+
* @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds.
|
|
1012
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1013
|
+
*/
|
|
619
1014
|
createCtColorControlClusterServer(colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
|
|
620
1015
|
this.behaviors.require(MatterbridgeColorControlServer.with(ColorControl.Feature.ColorTemperature), {
|
|
621
1016
|
colorMode: ColorControl.ColorMode.ColorTemperatureMireds,
|
|
@@ -634,12 +1029,23 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
634
1029
|
});
|
|
635
1030
|
return this;
|
|
636
1031
|
}
|
|
1032
|
+
/**
|
|
1033
|
+
* Configures the color control mode for the device.
|
|
1034
|
+
*
|
|
1035
|
+
* @param {ColorControl.ColorMode} colorMode - The color mode to set.
|
|
1036
|
+
*/
|
|
637
1037
|
async configureColorControlMode(colorMode) {
|
|
638
1038
|
if (isValidNumber(colorMode, ColorControl.ColorMode.CurrentHueAndCurrentSaturation, ColorControl.ColorMode.ColorTemperatureMireds)) {
|
|
639
1039
|
await this.setAttribute(ColorControl.Cluster.id, 'colorMode', colorMode, this.log);
|
|
640
1040
|
await this.setAttribute(ColorControl.Cluster.id, 'enhancedColorMode', colorMode, this.log);
|
|
641
1041
|
}
|
|
642
1042
|
}
|
|
1043
|
+
/**
|
|
1044
|
+
* Creates a default window covering cluster server (Lift and PositionAwareLift).
|
|
1045
|
+
*
|
|
1046
|
+
* @param positionPercent100ths - The position percentage in 100ths (0-10000). Defaults to 0. Matter uses 10000 = fully closed 0 = fully opened.
|
|
1047
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1048
|
+
*/
|
|
643
1049
|
createDefaultWindowCoveringClusterServer(positionPercent100ths) {
|
|
644
1050
|
this.behaviors.require(MatterbridgeWindowCoveringServer.with(WindowCovering.Feature.Lift, WindowCovering.Feature.PositionAwareLift), {
|
|
645
1051
|
type: WindowCovering.WindowCoveringType.Rollershade,
|
|
@@ -655,11 +1061,15 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
655
1061
|
operationalStatus: { global: WindowCovering.MovementStatus.Stopped, lift: WindowCovering.MovementStatus.Stopped, tilt: WindowCovering.MovementStatus.Stopped },
|
|
656
1062
|
endProductType: WindowCovering.EndProductType.RollerShade,
|
|
657
1063
|
mode: { motorDirectionReversed: false, calibrationMode: false, maintenanceMode: false, ledFeedback: false },
|
|
658
|
-
targetPositionLiftPercent100ths: positionPercent100ths ?? 0,
|
|
659
|
-
currentPositionLiftPercent100ths: positionPercent100ths ?? 0,
|
|
1064
|
+
targetPositionLiftPercent100ths: positionPercent100ths ?? 0, // 0 Fully open 10000 fully closed
|
|
1065
|
+
currentPositionLiftPercent100ths: positionPercent100ths ?? 0, // 0 Fully open 10000 fully closed
|
|
660
1066
|
});
|
|
661
1067
|
return this;
|
|
662
1068
|
}
|
|
1069
|
+
/**
|
|
1070
|
+
* Sets the window covering target position as the current position and stops the movement.
|
|
1071
|
+
*
|
|
1072
|
+
*/
|
|
663
1073
|
async setWindowCoveringTargetAsCurrentAndStopped() {
|
|
664
1074
|
const position = this.getAttribute(WindowCovering.Cluster.id, 'currentPositionLiftPercent100ths', this.log);
|
|
665
1075
|
if (isValidNumber(position, 0, 10000)) {
|
|
@@ -672,6 +1082,12 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
672
1082
|
}
|
|
673
1083
|
this.log.debug(`Set WindowCovering currentPositionLiftPercent100ths and targetPositionLiftPercent100ths to ${position} and operationalStatus to Stopped.`);
|
|
674
1084
|
}
|
|
1085
|
+
/**
|
|
1086
|
+
* Sets the current and target status of a window covering.
|
|
1087
|
+
* @param {number} current - The current position of the window covering.
|
|
1088
|
+
* @param {number} target - The target position of the window covering.
|
|
1089
|
+
* @param {WindowCovering.MovementStatus} status - The movement status of the window covering.
|
|
1090
|
+
*/
|
|
675
1091
|
async setWindowCoveringCurrentTargetStatus(current, target, status) {
|
|
676
1092
|
await this.setAttribute(WindowCovering.Cluster.id, 'currentPositionLiftPercent100ths', current, this.log);
|
|
677
1093
|
await this.setAttribute(WindowCovering.Cluster.id, 'targetPositionLiftPercent100ths', target, this.log);
|
|
@@ -682,6 +1098,10 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
682
1098
|
}, this.log);
|
|
683
1099
|
this.log.debug(`Set WindowCovering currentPositionLiftPercent100ths: ${current}, targetPositionLiftPercent100ths: ${target} and operationalStatus: ${status}.`);
|
|
684
1100
|
}
|
|
1101
|
+
/**
|
|
1102
|
+
* Sets the status of the window covering.
|
|
1103
|
+
* @param {WindowCovering.MovementStatus} status - The movement status to set.
|
|
1104
|
+
*/
|
|
685
1105
|
async setWindowCoveringStatus(status) {
|
|
686
1106
|
await this.setAttribute(WindowCovering.Cluster.id, 'operationalStatus', {
|
|
687
1107
|
global: status,
|
|
@@ -690,6 +1110,11 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
690
1110
|
}, this.log);
|
|
691
1111
|
this.log.debug(`Set WindowCovering operationalStatus: ${status}`);
|
|
692
1112
|
}
|
|
1113
|
+
/**
|
|
1114
|
+
* Retrieves the status of the window covering.
|
|
1115
|
+
*
|
|
1116
|
+
* @returns The global operational status of the window covering or undefined.
|
|
1117
|
+
*/
|
|
693
1118
|
getWindowCoveringStatus() {
|
|
694
1119
|
const status = this.getAttribute(WindowCovering.Cluster.id, 'operationalStatus', this.log);
|
|
695
1120
|
if (isValidObject(status, 3) && 'global' in status && typeof status.global === 'number') {
|
|
@@ -697,36 +1122,66 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
697
1122
|
return status.global;
|
|
698
1123
|
}
|
|
699
1124
|
}
|
|
1125
|
+
/**
|
|
1126
|
+
* Sets the target and current position of the window covering.
|
|
1127
|
+
*
|
|
1128
|
+
* @param position - The position to set, specified as a number.
|
|
1129
|
+
*/
|
|
700
1130
|
async setWindowCoveringTargetAndCurrentPosition(position) {
|
|
701
1131
|
await this.setAttribute(WindowCovering.Cluster.id, 'currentPositionLiftPercent100ths', position, this.log);
|
|
702
1132
|
await this.setAttribute(WindowCovering.Cluster.id, 'targetPositionLiftPercent100ths', position, this.log);
|
|
703
1133
|
this.log.debug(`Set WindowCovering currentPositionLiftPercent100ths: ${position} and targetPositionLiftPercent100ths: ${position}.`);
|
|
704
1134
|
}
|
|
1135
|
+
/**
|
|
1136
|
+
* Creates a default thermostat cluster server with Thermostat.Feature.Heating, Thermostat.Feature.Cooling, Thermostat.Feature.AutoMode.
|
|
1137
|
+
*
|
|
1138
|
+
* @param {number} [localTemperature=23] - The local temperature value in degrees Celsius. Defaults to 23°.
|
|
1139
|
+
* @param {number} [occupiedHeatingSetpoint=21] - The occupied heating setpoint value in degrees Celsius. Defaults to 21°.
|
|
1140
|
+
* @param {number} [occupiedCoolingSetpoint=25] - The occupied cooling setpoint value in degrees Celsius. Defaults to 25°.
|
|
1141
|
+
* @param {number} [minSetpointDeadBand=1] - The minimum setpoint dead band value. Defaults to 1°.
|
|
1142
|
+
* @param {number} [minHeatSetpointLimit=0] - The minimum heat setpoint limit value. Defaults to 0°.
|
|
1143
|
+
* @param {number} [maxHeatSetpointLimit=50] - The maximum heat setpoint limit value. Defaults to 50°.
|
|
1144
|
+
* @param {number} [minCoolSetpointLimit=0] - The minimum cool setpoint limit value. Defaults to 0°.
|
|
1145
|
+
* @param {number} [maxCoolSetpointLimit=50] - The maximum cool setpoint limit value. Defaults to 50°.
|
|
1146
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1147
|
+
*/
|
|
705
1148
|
createDefaultThermostatClusterServer(localTemperature = 23, occupiedHeatingSetpoint = 21, occupiedCoolingSetpoint = 25, minSetpointDeadBand = 1, minHeatSetpointLimit = 0, maxHeatSetpointLimit = 50, minCoolSetpointLimit = 0, maxCoolSetpointLimit = 50) {
|
|
706
1149
|
this.behaviors.require(MatterbridgeThermostatServer.with(Thermostat.Feature.Heating, Thermostat.Feature.Cooling, Thermostat.Feature.AutoMode), {
|
|
707
1150
|
localTemperature: localTemperature * 100,
|
|
708
1151
|
systemMode: Thermostat.SystemMode.Auto,
|
|
709
1152
|
controlSequenceOfOperation: Thermostat.ControlSequenceOfOperation.CoolingAndHeating,
|
|
1153
|
+
// Thermostat.Feature.Heating
|
|
710
1154
|
occupiedHeatingSetpoint: occupiedHeatingSetpoint * 100,
|
|
711
1155
|
minHeatSetpointLimit: minHeatSetpointLimit * 100,
|
|
712
1156
|
maxHeatSetpointLimit: maxHeatSetpointLimit * 100,
|
|
713
1157
|
absMinHeatSetpointLimit: minHeatSetpointLimit * 100,
|
|
714
1158
|
absMaxHeatSetpointLimit: maxHeatSetpointLimit * 100,
|
|
1159
|
+
// Thermostat.Feature.Cooling
|
|
715
1160
|
occupiedCoolingSetpoint: occupiedCoolingSetpoint * 100,
|
|
716
1161
|
minCoolSetpointLimit: minCoolSetpointLimit * 100,
|
|
717
1162
|
maxCoolSetpointLimit: maxCoolSetpointLimit * 100,
|
|
718
1163
|
absMinCoolSetpointLimit: minCoolSetpointLimit * 100,
|
|
719
1164
|
absMaxCoolSetpointLimit: maxCoolSetpointLimit * 100,
|
|
1165
|
+
// Thermostat.Feature.AutoMode
|
|
720
1166
|
minSetpointDeadBand: minSetpointDeadBand * 100,
|
|
721
1167
|
thermostatRunningMode: Thermostat.ThermostatRunningMode.Off,
|
|
722
1168
|
});
|
|
723
1169
|
return this;
|
|
724
1170
|
}
|
|
1171
|
+
/**
|
|
1172
|
+
* Creates a default heating thermostat cluster server with Thermostat.Feature.Heating.
|
|
1173
|
+
* @param {number} [localTemperature] - The local temperature value in degrees Celsius. Defaults to 23°.
|
|
1174
|
+
* @param {number} [occupiedHeatingSetpoint] - The occupied heating setpoint value in degrees Celsius. Defaults to 21°.
|
|
1175
|
+
* @param {number} [minHeatSetpointLimit] - The minimum heat setpoint limit value. Defaults to 0°.
|
|
1176
|
+
* @param {number} [maxHeatSetpointLimit] - The maximum heat setpoint limit value. Defaults to 50°.
|
|
1177
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1178
|
+
*/
|
|
725
1179
|
createDefaultHeatingThermostatClusterServer(localTemperature = 23, occupiedHeatingSetpoint = 21, minHeatSetpointLimit = 0, maxHeatSetpointLimit = 50) {
|
|
726
1180
|
this.behaviors.require(MatterbridgeThermostatServer.with(Thermostat.Feature.Heating), {
|
|
727
1181
|
localTemperature: localTemperature * 100,
|
|
728
1182
|
systemMode: Thermostat.SystemMode.Heat,
|
|
729
1183
|
controlSequenceOfOperation: Thermostat.ControlSequenceOfOperation.HeatingOnly,
|
|
1184
|
+
// Thermostat.Feature.Heating
|
|
730
1185
|
occupiedHeatingSetpoint: occupiedHeatingSetpoint * 100,
|
|
731
1186
|
minHeatSetpointLimit: minHeatSetpointLimit * 100,
|
|
732
1187
|
maxHeatSetpointLimit: maxHeatSetpointLimit * 100,
|
|
@@ -735,11 +1190,20 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
735
1190
|
});
|
|
736
1191
|
return this;
|
|
737
1192
|
}
|
|
1193
|
+
/**
|
|
1194
|
+
* Creates a default cooling thermostat cluster server with Thermostat.Feature.Cooling.
|
|
1195
|
+
* @param {number} [localTemperature] - The local temperature value in degrees Celsius. Defaults to 23°.
|
|
1196
|
+
* @param {number} [occupiedCoolingSetpoint] - The occupied cooling setpoint value in degrees Celsius. Defaults to 25°.
|
|
1197
|
+
* @param {number} [minCoolSetpointLimit] - The minimum cool setpoint limit value. Defaults to 0°.
|
|
1198
|
+
* @param {number} [maxCoolSetpointLimit] - The maximum cool setpoint limit value. Defaults to 50°.
|
|
1199
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1200
|
+
*/
|
|
738
1201
|
createDefaultCoolingThermostatClusterServer(localTemperature = 23, occupiedCoolingSetpoint = 25, minCoolSetpointLimit = 0, maxCoolSetpointLimit = 50) {
|
|
739
1202
|
this.behaviors.require(MatterbridgeThermostatServer.with(Thermostat.Feature.Cooling), {
|
|
740
1203
|
localTemperature: localTemperature * 100,
|
|
741
1204
|
systemMode: Thermostat.SystemMode.Cool,
|
|
742
1205
|
controlSequenceOfOperation: Thermostat.ControlSequenceOfOperation.CoolingOnly,
|
|
1206
|
+
// Thermostat.Feature.Cooling
|
|
743
1207
|
occupiedCoolingSetpoint: occupiedCoolingSetpoint * 100,
|
|
744
1208
|
minCoolSetpointLimit: minCoolSetpointLimit * 100,
|
|
745
1209
|
maxCoolSetpointLimit: maxCoolSetpointLimit * 100,
|
|
@@ -748,6 +1212,12 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
748
1212
|
});
|
|
749
1213
|
return this;
|
|
750
1214
|
}
|
|
1215
|
+
/**
|
|
1216
|
+
* Creates a default fan control cluster server.
|
|
1217
|
+
*
|
|
1218
|
+
* @param fanMode The fan mode to set. Defaults to `FanControl.FanMode.Off`.
|
|
1219
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1220
|
+
*/
|
|
751
1221
|
createDefaultFanControlClusterServer(fanMode = FanControl.FanMode.Off) {
|
|
752
1222
|
this.behaviors.require(MatterbridgeFanControlServer.with(FanControl.Feature.MultiSpeed, FanControl.Feature.Auto, FanControl.Feature.Step), {
|
|
753
1223
|
fanMode,
|
|
@@ -760,6 +1230,13 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
760
1230
|
});
|
|
761
1231
|
return this;
|
|
762
1232
|
}
|
|
1233
|
+
/**
|
|
1234
|
+
* Creates a default door lock cluster server.
|
|
1235
|
+
*
|
|
1236
|
+
* @param {DoorLock.LockState} [lockState=DoorLock.LockState.Locked] - The initial state of the lock (default: Locked).
|
|
1237
|
+
* @param {DoorLock.LockType} [lockType=DoorLock.LockType.DeadBolt] - The type of the lock (default: DeadBolt).
|
|
1238
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1239
|
+
*/
|
|
763
1240
|
createDefaultDoorLockClusterServer(lockState = DoorLock.LockState.Locked, lockType = DoorLock.LockType.DeadBolt) {
|
|
764
1241
|
this.behaviors.require(MatterbridgeDoorLockServer.enable({ events: { doorLockAlarm: true, lockOperation: true, lockOperationError: true } }), {
|
|
765
1242
|
operatingMode: DoorLock.OperatingMode.Normal,
|
|
@@ -770,6 +1247,18 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
770
1247
|
});
|
|
771
1248
|
return this;
|
|
772
1249
|
}
|
|
1250
|
+
/**
|
|
1251
|
+
* Creates a default Mode Select cluster server.
|
|
1252
|
+
*
|
|
1253
|
+
* @param {string} description - The description of the mode select cluster.
|
|
1254
|
+
* @param {ModeSelect.ModeOption[]} supportedModes - The list of supported modes.
|
|
1255
|
+
* @param {number} [currentMode=0] - The current mode (default: 0).
|
|
1256
|
+
* @param {number} [startUpMode=0] - The startup mode (default: 0).
|
|
1257
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1258
|
+
*
|
|
1259
|
+
* @remarks
|
|
1260
|
+
* endpoint.createDefaultModeSelectClusterServer('Night mode', [{ label: 'Led ON', mode: 0, semanticTags: [] }, { label: 'Led OFF', mode: 1, semanticTags: [] }], 0, 0);
|
|
1261
|
+
*/
|
|
773
1262
|
createDefaultModeSelectClusterServer(description, supportedModes, currentMode = 0, startUpMode = 0) {
|
|
774
1263
|
this.behaviors.require(MatterbridgeModeSelectServer, {
|
|
775
1264
|
description: description,
|
|
@@ -780,6 +1269,13 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
780
1269
|
});
|
|
781
1270
|
return this;
|
|
782
1271
|
}
|
|
1272
|
+
/**
|
|
1273
|
+
* Creates the default Valve Configuration And Control cluster server.
|
|
1274
|
+
*
|
|
1275
|
+
* @param {ValveConfigurationAndControl.ValveState} [valveState=ValveConfigurationAndControl.ValveState.Closed] - The valve state to set. Defaults to `ValveConfigurationAndControl.ValveState.Closed`.
|
|
1276
|
+
* @param {number} [valveLevel=0] - The valve level to set. Defaults to 0.
|
|
1277
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1278
|
+
*/
|
|
783
1279
|
createDefaultValveConfigurationAndControlClusterServer(valveState = ValveConfigurationAndControl.ValveState.Closed, valveLevel = 0) {
|
|
784
1280
|
this.behaviors.require(MatterbridgeValveConfigurationAndControlServer.with(ValveConfigurationAndControl.Feature.Level), {
|
|
785
1281
|
currentState: valveState,
|
|
@@ -792,6 +1288,12 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
792
1288
|
});
|
|
793
1289
|
return this;
|
|
794
1290
|
}
|
|
1291
|
+
/**
|
|
1292
|
+
* Creates the default PumpConfigurationAndControl cluster server.
|
|
1293
|
+
*
|
|
1294
|
+
* @param {PumpConfigurationAndControl.OperationMode} [pumpMode=PumpConfigurationAndControl.OperationMode.Normal] - The pump mode to set. Defaults to `PumpConfigurationAndControl.OperationMode.Normal`.
|
|
1295
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1296
|
+
*/
|
|
795
1297
|
createDefaultPumpConfigurationAndControlClusterServer(pumpMode = PumpConfigurationAndControl.OperationMode.Normal) {
|
|
796
1298
|
this.behaviors.require(PumpConfigurationAndControlServer.with(PumpConfigurationAndControl.Feature.ConstantSpeed), {
|
|
797
1299
|
minConstSpeed: null,
|
|
@@ -806,6 +1308,13 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
806
1308
|
});
|
|
807
1309
|
return this;
|
|
808
1310
|
}
|
|
1311
|
+
/**
|
|
1312
|
+
* Creates the default SmokeCOAlarm Cluster Server.
|
|
1313
|
+
*
|
|
1314
|
+
* @param {SmokeCoAlarm.AlarmState} smokeState - The state of the smoke alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
|
|
1315
|
+
* @param {SmokeCoAlarm.AlarmState} coState - The state of the CO alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
|
|
1316
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1317
|
+
*/
|
|
809
1318
|
createDefaultSmokeCOAlarmClusterServer(smokeState = SmokeCoAlarm.AlarmState.Normal, coState = SmokeCoAlarm.AlarmState.Normal) {
|
|
810
1319
|
this.behaviors.require(MatterbridgeSmokeCoAlarmServer.with(SmokeCoAlarm.Feature.SmokeAlarm, SmokeCoAlarm.Feature.CoAlarm).enable({
|
|
811
1320
|
events: { smokeAlarm: true, interconnectSmokeAlarm: true, coAlarm: true, interconnectCoAlarm: true, lowBattery: true, hardwareFault: true, endOfService: true, selfTestComplete: true, alarmMuted: true, muteEnded: true, allClear: true },
|
|
@@ -823,6 +1332,13 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
823
1332
|
});
|
|
824
1333
|
return this;
|
|
825
1334
|
}
|
|
1335
|
+
/**
|
|
1336
|
+
* Creates a default momentary switch cluster server.
|
|
1337
|
+
*
|
|
1338
|
+
* @remarks
|
|
1339
|
+
* This method adds a cluster server with default momentary switch features and configurations suitable for (AppleHome) Single Double Long automations.
|
|
1340
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1341
|
+
*/
|
|
826
1342
|
createDefaultSwitchClusterServer() {
|
|
827
1343
|
this.behaviors.require(MatterbridgeSwitchServer.with(Switch.Feature.MomentarySwitch, Switch.Feature.MomentarySwitchRelease, Switch.Feature.MomentarySwitchLongPress, Switch.Feature.MomentarySwitchMultiPress).enable({
|
|
828
1344
|
events: { initialPress: true, longPress: true, shortRelease: true, longRelease: true, multiPressOngoing: true, multiPressComplete: true },
|
|
@@ -833,6 +1349,12 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
833
1349
|
});
|
|
834
1350
|
return this;
|
|
835
1351
|
}
|
|
1352
|
+
/**
|
|
1353
|
+
* Creates a default latching switch cluster server.
|
|
1354
|
+
*
|
|
1355
|
+
* @remarks
|
|
1356
|
+
* This method adds a cluster server with default latching switch features and configuration suitable for a latching switch with 2 positions.
|
|
1357
|
+
*/
|
|
836
1358
|
createDefaultLatchingSwitchClusterServer() {
|
|
837
1359
|
this.behaviors.require(SwitchServer.with(Switch.Feature.LatchingSwitch).enable({
|
|
838
1360
|
events: { switchLatched: true },
|
|
@@ -842,6 +1364,13 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
842
1364
|
});
|
|
843
1365
|
return this;
|
|
844
1366
|
}
|
|
1367
|
+
/**
|
|
1368
|
+
* Triggers a switch event on the specified endpoint.
|
|
1369
|
+
*
|
|
1370
|
+
* @param {string} event - The type of event to trigger. Possible values are 'Single', 'Double', 'Long' for momentarySwitch and 'Press', 'Release' for latchingSwitch.
|
|
1371
|
+
* @param {Endpoint} endpoint - The endpoint on which to trigger the event (default the device endpoint).
|
|
1372
|
+
* @returns {boolean} - A boolean indicating whether the event was successfully triggered.
|
|
1373
|
+
*/
|
|
845
1374
|
async triggerSwitchEvent(event, log) {
|
|
846
1375
|
if (this.maybeNumber === undefined) {
|
|
847
1376
|
this.log.error(`triggerSwitchEvent ${event} error: Endpoint number not assigned on endpoint ${this.maybeId}:${this.maybeNumber}`);
|
|
@@ -901,14 +1430,31 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
901
1430
|
}
|
|
902
1431
|
return true;
|
|
903
1432
|
}
|
|
1433
|
+
/**
|
|
1434
|
+
* Creates a default boolean state cluster server.
|
|
1435
|
+
*
|
|
1436
|
+
* @param {boolean} contact - The state of the cluster. Defaults to true (true = contact).
|
|
1437
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1438
|
+
*/
|
|
904
1439
|
createDefaultBooleanStateClusterServer(contact) {
|
|
905
1440
|
this.behaviors.require(BooleanStateServer.enable({
|
|
906
1441
|
events: { stateChange: true },
|
|
907
1442
|
}), {
|
|
908
|
-
stateValue: contact ?? true,
|
|
1443
|
+
stateValue: contact ?? true, // true=contact false=no_contact
|
|
909
1444
|
});
|
|
910
1445
|
return this;
|
|
911
1446
|
}
|
|
1447
|
+
/**
|
|
1448
|
+
* Creates a default boolean state configuration cluster server to be used with the waterFreezeDetector, waterLeakDetector, and rainSensor device types.
|
|
1449
|
+
*
|
|
1450
|
+
* @remarks Supports the enableDisableAlarm command.
|
|
1451
|
+
*
|
|
1452
|
+
* @param {boolean} [sensorFault=false] - Optional boolean value indicating the sensor fault state. Defaults to `false` if not provided.
|
|
1453
|
+
* @param {number} [currentSensitivityLevel=0] - The current sensitivity level. Defaults to `0` if not provided.
|
|
1454
|
+
* @param {number} [supportedSensitivityLevels=2] - The number of supported sensitivity levels. Defaults to `2` if not provided (min 2, max 10).
|
|
1455
|
+
* @param {number} [defaultSensitivityLevel=0] - The default sensitivity level. Defaults to `0` if not provided.
|
|
1456
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1457
|
+
*/
|
|
912
1458
|
createDefaultBooleanStateConfigurationClusterServer(sensorFault = false, currentSensitivityLevel = 0, supportedSensitivityLevels = 2, defaultSensitivityLevel = 0) {
|
|
913
1459
|
this.behaviors.require(MatterbridgeBooleanStateConfigurationServer.with(BooleanStateConfiguration.Feature.Visual, BooleanStateConfiguration.Feature.Audible, BooleanStateConfiguration.Feature.SensitivityLevel).enable({
|
|
914
1460
|
events: { alarmsStateChanged: true, sensorFault: true },
|
|
@@ -923,10 +1469,21 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
923
1469
|
});
|
|
924
1470
|
return this;
|
|
925
1471
|
}
|
|
1472
|
+
/**
|
|
1473
|
+
* Creates a default Power Topology Cluster Server with feature TreeTopology. Only needed for an electricalSensor device type.
|
|
1474
|
+
*
|
|
1475
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1476
|
+
*/
|
|
926
1477
|
createDefaultPowerTopologyClusterServer() {
|
|
927
1478
|
this.behaviors.require(PowerTopologyServer.with(PowerTopology.Feature.TreeTopology));
|
|
928
1479
|
return this;
|
|
929
1480
|
}
|
|
1481
|
+
/**
|
|
1482
|
+
* Creates a default Electrical Energy Measurement Cluster Server.
|
|
1483
|
+
*
|
|
1484
|
+
* @param {number} energy - The total consumption value in mW/h.
|
|
1485
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1486
|
+
*/
|
|
930
1487
|
createDefaultElectricalEnergyMeasurementClusterServer(energy = null) {
|
|
931
1488
|
this.behaviors.require(ElectricalEnergyMeasurementServer.with(ElectricalEnergyMeasurement.Feature.ImportedEnergy, ElectricalEnergyMeasurement.Feature.ExportedEnergy, ElectricalEnergyMeasurement.Feature.CumulativeEnergy), {
|
|
932
1489
|
accuracy: {
|
|
@@ -942,6 +1499,15 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
942
1499
|
});
|
|
943
1500
|
return this;
|
|
944
1501
|
}
|
|
1502
|
+
/**
|
|
1503
|
+
* Creates a default Electrical Power Measurement Cluster Server.
|
|
1504
|
+
*
|
|
1505
|
+
* @param {number} voltage - The voltage value in millivolts.
|
|
1506
|
+
* @param {number} current - The current value in milliamperes.
|
|
1507
|
+
* @param {number} power - The power value in milliwatts.
|
|
1508
|
+
* @param {number} frequency - The frequency value in millihertz.
|
|
1509
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1510
|
+
*/
|
|
945
1511
|
createDefaultElectricalPowerMeasurementClusterServer(voltage = null, current = null, power = null, frequency = null) {
|
|
946
1512
|
this.behaviors.require(ElectricalPowerMeasurementServer.with(ElectricalPowerMeasurement.Feature.AlternatingCurrent), {
|
|
947
1513
|
powerMode: ElectricalPowerMeasurement.PowerMode.Ac,
|
|
@@ -983,36 +1549,90 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
983
1549
|
});
|
|
984
1550
|
return this;
|
|
985
1551
|
}
|
|
1552
|
+
/**
|
|
1553
|
+
* Creates a default TemperatureMeasurement cluster server.
|
|
1554
|
+
*
|
|
1555
|
+
* @param {number} measuredValue - The measured value of the temperature x 100.
|
|
1556
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1557
|
+
*/
|
|
986
1558
|
createDefaultTemperatureMeasurementClusterServer(measuredValue = 0) {
|
|
987
1559
|
this.behaviors.require(TemperatureMeasurementServer, getDefaultTemperatureMeasurementClusterServer(measuredValue));
|
|
988
1560
|
return this;
|
|
989
1561
|
}
|
|
1562
|
+
/**
|
|
1563
|
+
* Creates a default RelativeHumidityMeasurement cluster server.
|
|
1564
|
+
*
|
|
1565
|
+
* @param {number} measuredValue - The measured value of the relative humidity x 100.
|
|
1566
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1567
|
+
*/
|
|
990
1568
|
createDefaultRelativeHumidityMeasurementClusterServer(measuredValue = 0) {
|
|
991
1569
|
this.behaviors.require(RelativeHumidityMeasurementServer, getDefaultRelativeHumidityMeasurementClusterServer(measuredValue));
|
|
992
1570
|
return this;
|
|
993
1571
|
}
|
|
1572
|
+
/**
|
|
1573
|
+
* Creates a default PressureMeasurement cluster server.
|
|
1574
|
+
*
|
|
1575
|
+
* @param {number} measuredValue - The measured value for the pressure.
|
|
1576
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1577
|
+
*/
|
|
994
1578
|
createDefaultPressureMeasurementClusterServer(measuredValue = 1000) {
|
|
995
1579
|
this.behaviors.require(PressureMeasurementServer, getDefaultPressureMeasurementClusterServer(measuredValue));
|
|
996
1580
|
return this;
|
|
997
1581
|
}
|
|
1582
|
+
/**
|
|
1583
|
+
* Creates a default IlluminanceMeasurement cluster server.
|
|
1584
|
+
*
|
|
1585
|
+
* @param {number} measuredValue - The measured value of illuminance.
|
|
1586
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1587
|
+
*
|
|
1588
|
+
* @remarks
|
|
1589
|
+
* Lux to matter = Math.round(Math.max(Math.min(10000 * Math.log10(lux), 0xfffe), 0))
|
|
1590
|
+
* Matter to Lux = Math.round(Math.max(Math.pow(10, value / 10000), 0))
|
|
1591
|
+
*/
|
|
998
1592
|
createDefaultIlluminanceMeasurementClusterServer(measuredValue = 0) {
|
|
999
1593
|
this.behaviors.require(IlluminanceMeasurementServer, getDefaultIlluminanceMeasurementClusterServer(measuredValue));
|
|
1000
1594
|
return this;
|
|
1001
1595
|
}
|
|
1596
|
+
/**
|
|
1597
|
+
* Creates a default FlowMeasurement cluster server.
|
|
1598
|
+
*
|
|
1599
|
+
* @param {number} measuredValue - The measured value of the flow in 10 x m/h.
|
|
1600
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1601
|
+
*/
|
|
1002
1602
|
createDefaultFlowMeasurementClusterServer(measuredValue = 0) {
|
|
1003
1603
|
this.behaviors.require(FlowMeasurementServer, getDefaultFlowMeasurementClusterServer(measuredValue));
|
|
1004
1604
|
return this;
|
|
1005
1605
|
}
|
|
1606
|
+
/**
|
|
1607
|
+
* Creates a default OccupancySensing cluster server.
|
|
1608
|
+
*
|
|
1609
|
+
* @param {boolean} occupied - A boolean indicating whether the occupancy is occupied or not. Default is false.
|
|
1610
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1611
|
+
*/
|
|
1006
1612
|
createDefaultOccupancySensingClusterServer(occupied = false) {
|
|
1007
1613
|
this.behaviors.require(OccupancySensingServer, getDefaultOccupancySensingClusterServer(occupied));
|
|
1008
1614
|
return this;
|
|
1009
1615
|
}
|
|
1616
|
+
/**
|
|
1617
|
+
* Creates a default AirQuality cluster server.
|
|
1618
|
+
*
|
|
1619
|
+
* @param {AirQuality.AirQualityEnum} airQuality The air quality level. Defaults to `AirQuality.AirQualityType.Unknown`.
|
|
1620
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1621
|
+
*/
|
|
1010
1622
|
createDefaultAirQualityClusterServer(airQuality = AirQuality.AirQualityEnum.Unknown) {
|
|
1011
1623
|
this.behaviors.require(AirQualityServer.with(AirQuality.Feature.Fair, AirQuality.Feature.Moderate, AirQuality.Feature.VeryPoor, AirQuality.Feature.ExtremelyPoor), {
|
|
1012
1624
|
airQuality,
|
|
1013
1625
|
});
|
|
1014
1626
|
return this;
|
|
1015
1627
|
}
|
|
1628
|
+
/**
|
|
1629
|
+
* Creates a default TotalVolatileOrganicCompoundsConcentrationMeasurement cluster server.
|
|
1630
|
+
*
|
|
1631
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
1632
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
|
|
1633
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
|
|
1634
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1635
|
+
*/
|
|
1016
1636
|
createDefaultTvocMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1017
1637
|
this.behaviors.require(TotalVolatileOrganicCompoundsConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
|
|
1018
1638
|
measuredValue,
|
|
@@ -1024,6 +1644,13 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1024
1644
|
});
|
|
1025
1645
|
return this;
|
|
1026
1646
|
}
|
|
1647
|
+
/**
|
|
1648
|
+
* Create a default CarbonMonoxideConcentrationMeasurement cluster server.
|
|
1649
|
+
*
|
|
1650
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
1651
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
|
|
1652
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
|
|
1653
|
+
*/
|
|
1027
1654
|
createDefaultCarbonMonoxideConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1028
1655
|
this.behaviors.require(CarbonMonoxideConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
|
|
1029
1656
|
measuredValue,
|
|
@@ -1035,6 +1662,13 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1035
1662
|
});
|
|
1036
1663
|
return this;
|
|
1037
1664
|
}
|
|
1665
|
+
/**
|
|
1666
|
+
* Create a default CarbonDioxideConcentrationMeasurement cluster server.
|
|
1667
|
+
*
|
|
1668
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
1669
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
|
|
1670
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
|
|
1671
|
+
*/
|
|
1038
1672
|
createDefaultCarbonDioxideConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1039
1673
|
this.behaviors.require(CarbonDioxideConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
|
|
1040
1674
|
measuredValue,
|
|
@@ -1046,6 +1680,13 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1046
1680
|
});
|
|
1047
1681
|
return this;
|
|
1048
1682
|
}
|
|
1683
|
+
/**
|
|
1684
|
+
* Create a default FormaldehydeConcentrationMeasurement cluster server.
|
|
1685
|
+
*
|
|
1686
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
1687
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
|
|
1688
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
|
|
1689
|
+
*/
|
|
1049
1690
|
createDefaultFormaldehydeConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1050
1691
|
this.behaviors.require(FormaldehydeConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
|
|
1051
1692
|
measuredValue,
|
|
@@ -1057,6 +1698,13 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1057
1698
|
});
|
|
1058
1699
|
return this;
|
|
1059
1700
|
}
|
|
1701
|
+
/**
|
|
1702
|
+
* Create a default Pm1ConcentrationMeasurement cluster server.
|
|
1703
|
+
*
|
|
1704
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
1705
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
|
|
1706
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
|
|
1707
|
+
*/
|
|
1060
1708
|
createDefaultPm1ConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1061
1709
|
this.behaviors.require(Pm1ConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
|
|
1062
1710
|
measuredValue,
|
|
@@ -1068,6 +1716,13 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1068
1716
|
});
|
|
1069
1717
|
return this;
|
|
1070
1718
|
}
|
|
1719
|
+
/**
|
|
1720
|
+
* Create a default Pm25ConcentrationMeasurement cluster server.
|
|
1721
|
+
*
|
|
1722
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
1723
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
|
|
1724
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
|
|
1725
|
+
*/
|
|
1071
1726
|
createDefaultPm25ConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1072
1727
|
this.behaviors.require(Pm25ConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
|
|
1073
1728
|
measuredValue,
|
|
@@ -1079,6 +1734,13 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1079
1734
|
});
|
|
1080
1735
|
return this;
|
|
1081
1736
|
}
|
|
1737
|
+
/**
|
|
1738
|
+
* Create a default Pm10ConcentrationMeasurement cluster server.
|
|
1739
|
+
*
|
|
1740
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
1741
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
|
|
1742
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
|
|
1743
|
+
*/
|
|
1082
1744
|
createDefaultPm10ConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1083
1745
|
this.behaviors.require(Pm10ConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
|
|
1084
1746
|
measuredValue,
|
|
@@ -1090,6 +1752,13 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1090
1752
|
});
|
|
1091
1753
|
return this;
|
|
1092
1754
|
}
|
|
1755
|
+
/**
|
|
1756
|
+
* Create a default OzoneConcentrationMeasurement cluster server.
|
|
1757
|
+
*
|
|
1758
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
1759
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ugm3).
|
|
1760
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
|
|
1761
|
+
*/
|
|
1093
1762
|
createDefaultOzoneConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ugm3, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1094
1763
|
this.behaviors.require(OzoneConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
|
|
1095
1764
|
measuredValue,
|
|
@@ -1101,6 +1770,13 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1101
1770
|
});
|
|
1102
1771
|
return this;
|
|
1103
1772
|
}
|
|
1773
|
+
/**
|
|
1774
|
+
* Create a default RadonConcentrationMeasurement cluster server.
|
|
1775
|
+
*
|
|
1776
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
1777
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
|
|
1778
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
|
|
1779
|
+
*/
|
|
1104
1780
|
createDefaultRadonConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1105
1781
|
this.behaviors.require(RadonConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
|
|
1106
1782
|
measuredValue,
|
|
@@ -1112,6 +1788,13 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1112
1788
|
});
|
|
1113
1789
|
return this;
|
|
1114
1790
|
}
|
|
1791
|
+
/**
|
|
1792
|
+
* Create a default NitrogenDioxideConcentrationMeasurement cluster server.
|
|
1793
|
+
*
|
|
1794
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
1795
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ugm3).
|
|
1796
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
|
|
1797
|
+
*/
|
|
1115
1798
|
createDefaultNitrogenDioxideConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ugm3, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1116
1799
|
this.behaviors.require(NitrogenDioxideConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
|
|
1117
1800
|
measuredValue,
|
|
@@ -1124,3 +1807,4 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1124
1807
|
return this;
|
|
1125
1808
|
}
|
|
1126
1809
|
}
|
|
1810
|
+
//# sourceMappingURL=matterbridgeEndpoint.js.map
|