matterbridge 2.2.6-dev.5 → 2.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -1
- package/dist/cli.d.ts +29 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +37 -2
- 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 -2
- 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 +221 -0
- package/dist/frontend.d.ts.map +1 -0
- package/dist/frontend.js +325 -19
- 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 -1
- 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 +425 -0
- package/dist/matterbridge.d.ts.map +1 -0
- package/dist/matterbridge.js +753 -47
- 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 +835 -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 +2275 -0
- package/dist/matterbridgeEndpointHelpers.d.ts.map +1 -0
- package/dist/matterbridgeEndpointHelpers.js +118 -9
- package/dist/matterbridgeEndpointHelpers.js.map +1 -0
- package/dist/matterbridgePlatform.d.ts +285 -0
- package/dist/matterbridgePlatform.d.ts.map +1 -0
- package/dist/matterbridgePlatform.js +216 -7
- package/dist/matterbridgePlatform.js.map +1 -0
- package/dist/matterbridgeTypes.d.ts +179 -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 +229 -3
- package/dist/pluginManager.js.map +1 -0
- package/dist/shelly.d.ts +92 -0
- package/dist/shelly.d.ts.map +1 -0
- package/dist/shelly.js +146 -6
- package/dist/shelly.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/update.d.ts +32 -0
- package/dist/update.d.ts.map +1 -0
- package/dist/update.js +45 -0
- package/dist/update.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/copyDirectory.d.ts +32 -0
- package/dist/utils/copyDirectory.d.ts.map +1 -0
- package/dist/utils/copyDirectory.js +37 -1
- package/dist/utils/copyDirectory.js.map +1 -0
- package/dist/utils/createZip.d.ts +38 -0
- package/dist/utils/createZip.d.ts.map +1 -0
- package/dist/utils/createZip.js +42 -2
- package/dist/utils/createZip.js.map +1 -0
- package/dist/utils/deepCopy.d.ts +31 -0
- package/dist/utils/deepCopy.d.ts.map +1 -0
- package/dist/utils/deepCopy.js +40 -0
- package/dist/utils/deepCopy.js.map +1 -0
- package/dist/utils/deepEqual.d.ts +53 -0
- package/dist/utils/deepEqual.d.ts.map +1 -0
- package/dist/utils/deepEqual.js +65 -1
- package/dist/utils/deepEqual.js.map +1 -0
- package/dist/utils/export.d.ts +10 -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/isvalid.d.ts +87 -0
- package/dist/utils/isvalid.d.ts.map +1 -0
- package/dist/utils/isvalid.js +86 -0
- package/dist/utils/isvalid.js.map +1 -0
- package/dist/utils/network.d.ts +69 -0
- package/dist/utils/network.d.ts.map +1 -0
- package/dist/utils/network.js +77 -8
- package/dist/utils/network.js.map +1 -0
- package/dist/utils/parameter.d.ts +44 -0
- package/dist/utils/parameter.d.ts.map +1 -0
- package/dist/utils/parameter.js +41 -0
- package/dist/utils/parameter.js.map +1 -0
- package/dist/utils/wait.d.ts +43 -0
- package/dist/utils/wait.d.ts.map +1 -0
- package/dist/utils/wait.js +48 -5
- package/dist/utils/wait.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/export.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, subscribeAttribute, } from './matterbridgeEndpointHelpers.js';
|
|
30
|
+
// @matter
|
|
6
31
|
import { Endpoint, Lifecycle, MutableEndpoint, NamedHandler, SupportedBehaviors, VendorId } from '@matter/main';
|
|
7
32
|
import { ClusterType, 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: options.uniqueStorageKey ?? '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,72 +228,186 @@ 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 {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to subscribe the attribute to.
|
|
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 {Promise<boolean>} - A boolean indicating whether the subscription was successful.
|
|
287
|
+
*/
|
|
288
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
174
289
|
async subscribeAttribute(cluster, attribute, listener, log) {
|
|
175
290
|
return await subscribeAttribute(this, cluster, attribute, listener, log);
|
|
176
291
|
}
|
|
292
|
+
/**
|
|
293
|
+
* Triggers an event on the specified cluster.
|
|
294
|
+
*
|
|
295
|
+
* @param {ClusterId} clusterId - The ID of the cluster.
|
|
296
|
+
* @param {string} event - The name of the event to trigger.
|
|
297
|
+
* @param {Record<string, boolean | number | bigint | string | object | undefined | null>} payload - The payload to pass to the event.
|
|
298
|
+
* @param {AnsiLogger} [log] - Optional logger for logging information.
|
|
299
|
+
* @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the event was successfully triggered.
|
|
300
|
+
*/
|
|
177
301
|
async triggerEvent(clusterId, event, payload, log) {
|
|
178
302
|
const clusterName = lowercaseFirstLetter(getClusterNameById(clusterId));
|
|
179
303
|
if (this.construction.status !== Lifecycle.Status.Active) {
|
|
180
304
|
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`);
|
|
181
305
|
return false;
|
|
182
306
|
}
|
|
307
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
183
308
|
const events = this.events;
|
|
184
309
|
if (!(clusterName in events) || !(event in events[clusterName])) {
|
|
185
310
|
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}`);
|
|
186
311
|
return false;
|
|
187
312
|
}
|
|
313
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
314
|
+
// @ts-ignore
|
|
188
315
|
await this.act((agent) => agent[clusterName].events[event].emit(payload, agent.context));
|
|
189
316
|
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} `);
|
|
190
317
|
return true;
|
|
191
318
|
}
|
|
319
|
+
/**
|
|
320
|
+
* Adds cluster servers from the provided server list.
|
|
321
|
+
*
|
|
322
|
+
* @param {ClusterId[]} serverList - The list of cluster IDs to add.
|
|
323
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
324
|
+
*/
|
|
192
325
|
addClusterServers(serverList) {
|
|
193
326
|
addClusterServers(this, serverList);
|
|
194
327
|
return this;
|
|
195
328
|
}
|
|
329
|
+
/**
|
|
330
|
+
* Adds a fixed label to the FixedLabel cluster. If the cluster server is not present, it will be added.
|
|
331
|
+
*
|
|
332
|
+
* @param {string} label - The label to add.
|
|
333
|
+
* @param {string} value - The value of the label.
|
|
334
|
+
* @returns {Promise<this>} The current MatterbridgeEndpoint instance for chaining.
|
|
335
|
+
*/
|
|
196
336
|
async addFixedLabel(label, value) {
|
|
197
337
|
await addFixedLabel(this, label, value);
|
|
198
338
|
return this;
|
|
199
339
|
}
|
|
340
|
+
/**
|
|
341
|
+
* Adds a user label to the UserLabel cluster. If the cluster server is not present, it will be added.
|
|
342
|
+
*
|
|
343
|
+
* @param {string} label - The label to add.
|
|
344
|
+
* @param {string} value - The value of the label.
|
|
345
|
+
* @returns {Promise<this>} The current MatterbridgeEndpoint instance for chaining.
|
|
346
|
+
*/
|
|
200
347
|
async addUserLabel(label, value) {
|
|
201
348
|
await addUserLabel(this, label, value);
|
|
202
349
|
return this;
|
|
203
350
|
}
|
|
351
|
+
/**
|
|
352
|
+
* Adds a command handler for the specified command.
|
|
353
|
+
*
|
|
354
|
+
* @param {keyof MatterbridgeEndpointCommands} command - The command to add the handler for.
|
|
355
|
+
* @param {HandlerFunction} handler - The handler function to execute when the command is received.
|
|
356
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
357
|
+
*/
|
|
204
358
|
addCommandHandler(command, handler) {
|
|
205
359
|
this.commandHandler.addHandler(command, handler);
|
|
206
360
|
return this;
|
|
207
361
|
}
|
|
362
|
+
/**
|
|
363
|
+
* Execute the command handler for the specified command. Mainly used in Jest tests.
|
|
364
|
+
*
|
|
365
|
+
* @param {keyof MatterbridgeEndpointCommands} command - The command to execute.
|
|
366
|
+
* @param {Record<string, boolean | number | bigint | string | object | null>} request - The optional request to pass to the handler function.
|
|
367
|
+
* @returns {Promise<void>} A promise that resolves when the command handler has been executed
|
|
368
|
+
*/
|
|
208
369
|
async executeCommandHandler(command, request) {
|
|
209
370
|
await this.commandHandler.executeHandler(command, { request });
|
|
210
371
|
}
|
|
372
|
+
/**
|
|
373
|
+
* Adds the required cluster servers (only if they are not present) for the device types of the specified endpoint.
|
|
374
|
+
*
|
|
375
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
376
|
+
*/
|
|
211
377
|
addRequiredClusterServers() {
|
|
212
378
|
addRequiredClusterServers(this);
|
|
213
379
|
return this;
|
|
214
380
|
}
|
|
381
|
+
/**
|
|
382
|
+
* Adds the optional cluster servers (only if they are not present) for the device types of the specified endpoint.
|
|
383
|
+
*
|
|
384
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
385
|
+
*/
|
|
215
386
|
addOptionalClusterServers() {
|
|
216
387
|
addOptionalClusterServers(this);
|
|
217
388
|
return this;
|
|
218
389
|
}
|
|
390
|
+
/**
|
|
391
|
+
* Retrieves all cluster servers.
|
|
392
|
+
*
|
|
393
|
+
* @returns {Behavior.Type[]} An array of all cluster servers.
|
|
394
|
+
*/
|
|
219
395
|
getAllClusterServers() {
|
|
220
396
|
return Object.values(this.behaviors.supported);
|
|
221
397
|
}
|
|
398
|
+
/**
|
|
399
|
+
* Retrieves the names of all cluster servers.
|
|
400
|
+
*
|
|
401
|
+
* @returns {string[]} An array of all cluster server names.
|
|
402
|
+
*/
|
|
222
403
|
getAllClusterServerNames() {
|
|
223
404
|
return Object.keys(this.behaviors.supported);
|
|
224
405
|
}
|
|
406
|
+
/**
|
|
407
|
+
* Iterates over each attribute of each cluster server of the device state and calls the provided callback function.
|
|
408
|
+
*
|
|
409
|
+
* @param {Function} callback - The callback function to call with the cluster name, cluster id, attribute name, attribute id and attribute value.
|
|
410
|
+
*/
|
|
225
411
|
forEachAttribute(callback) {
|
|
226
412
|
if (!this.lifecycle.isReady || this.construction.status !== Lifecycle.Status.Active)
|
|
227
413
|
return;
|
|
@@ -229,16 +415,34 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
229
415
|
for (const [attributeName, attributeValue] of Object.entries(clusterAttributes)) {
|
|
230
416
|
const clusterId = getClusterId(this, clusterName);
|
|
231
417
|
if (clusterId === undefined) {
|
|
418
|
+
// this.log.error(`forEachAttribute error: cluster ${clusterName} not found`);
|
|
232
419
|
continue;
|
|
233
420
|
}
|
|
234
421
|
const attributeId = getAttributeId(this, clusterName, attributeName);
|
|
235
422
|
if (attributeId === undefined) {
|
|
423
|
+
// this.log.error(`forEachAttribute error: attribute ${clusterName}.${attributeName} not found`);
|
|
236
424
|
continue;
|
|
237
425
|
}
|
|
238
426
|
callback(clusterName, clusterId, attributeName, attributeId, attributeValue);
|
|
239
427
|
}
|
|
240
428
|
}
|
|
241
429
|
}
|
|
430
|
+
/**
|
|
431
|
+
* Adds a child endpoint with the specified device types and options.
|
|
432
|
+
* If the child endpoint is not already present, it will be created and added.
|
|
433
|
+
* If the child endpoint is already present, the existing child endpoint will be returned.
|
|
434
|
+
*
|
|
435
|
+
* @param {string} endpointName - The name of the new endpoint to add.
|
|
436
|
+
* @param {DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>} definition - The device types to add.
|
|
437
|
+
* @param {MatterbridgeEndpointOptions} [options={}] - The options for the endpoint.
|
|
438
|
+
* @param {boolean} [debug=false] - Whether to enable debug logging.
|
|
439
|
+
* @returns {MatterbridgeEndpoint} - The child endpoint that was found or added.
|
|
440
|
+
*
|
|
441
|
+
* @example
|
|
442
|
+
* ```typescript
|
|
443
|
+
* const endpoint = device.addChildDeviceType('Temperature', [temperatureSensor], { tagList: [{ mfgCode: null, namespaceId: LocationTag.Indoor.namespaceId, tag: LocationTag.Indoor.tag, label: null }] }, true);
|
|
444
|
+
* ```
|
|
445
|
+
*/
|
|
242
446
|
addChildDeviceType(endpointName, definition, options = {}, debug = false) {
|
|
243
447
|
this.log.debug(`addChildDeviceType: ${CYAN}${endpointName}${db}`);
|
|
244
448
|
let alreadyAdded = false;
|
|
@@ -278,6 +482,23 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
278
482
|
}
|
|
279
483
|
return child;
|
|
280
484
|
}
|
|
485
|
+
/**
|
|
486
|
+
* Adds a child endpoint with one or more device types with the required cluster servers and the specified cluster servers.
|
|
487
|
+
* If the child endpoint is not already present in the childEndpoints, it will be added.
|
|
488
|
+
* If the child endpoint is already present in the childEndpoints, the device types and cluster servers will be added to the existing child endpoint.
|
|
489
|
+
*
|
|
490
|
+
* @param {string} endpointName - The name of the new enpoint to add.
|
|
491
|
+
* @param {DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>} definition - The device types to add.
|
|
492
|
+
* @param {ClusterId[]} [serverList=[]] - The list of cluster IDs to include.
|
|
493
|
+
* @param {MatterbridgeEndpointOptions} [options={}] - The options for the device.
|
|
494
|
+
* @param {boolean} [debug=false] - Whether to enable debug logging.
|
|
495
|
+
* @returns {MatterbridgeEndpoint} - The child endpoint that was found or added.
|
|
496
|
+
*
|
|
497
|
+
* @example
|
|
498
|
+
* ```typescript
|
|
499
|
+
* const endpoint = device.addChildDeviceTypeWithClusterServer('Temperature', [temperatureSensor], [], { tagList: [{ mfgCode: null, namespaceId: LocationTag.Indoor.namespaceId, tag: LocationTag.Indoor.tag, label: null }] }, true);
|
|
500
|
+
* ```
|
|
501
|
+
*/
|
|
281
502
|
addChildDeviceTypeWithClusterServer(endpointName, definition, serverList = [], options = {}, debug = false) {
|
|
282
503
|
this.log.debug(`addChildDeviceTypeWithClusterServer: ${CYAN}${endpointName}${db}`);
|
|
283
504
|
let alreadyAdded = false;
|
|
@@ -340,15 +561,38 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
340
561
|
}
|
|
341
562
|
return child;
|
|
342
563
|
}
|
|
564
|
+
/**
|
|
565
|
+
* Retrieves a child endpoint by its name.
|
|
566
|
+
*
|
|
567
|
+
* @param {string} endpointName - The name of the endpoint to retrieve.
|
|
568
|
+
* @returns {Endpoint | undefined} The child endpoint with the specified name, or undefined if not found.
|
|
569
|
+
*/
|
|
343
570
|
getChildEndpointByName(endpointName) {
|
|
344
571
|
return this.parts.find((part) => part.id === endpointName);
|
|
345
572
|
}
|
|
573
|
+
/**
|
|
574
|
+
* Retrieves a child endpoint by its EndpointNumber.
|
|
575
|
+
*
|
|
576
|
+
* @param {EndpointNumber} endpointNumber - The EndpointNumber of the endpoint to retrieve.
|
|
577
|
+
* @returns {MatterbridgeEndpoint | undefined} The child endpoint with the specified EndpointNumber, or undefined if not found.
|
|
578
|
+
*/
|
|
346
579
|
getChildEndpoint(endpointNumber) {
|
|
347
580
|
return this.parts.find((part) => part.number === endpointNumber);
|
|
348
581
|
}
|
|
582
|
+
/**
|
|
583
|
+
* Get all the child endpoints of this endpoint.
|
|
584
|
+
*
|
|
585
|
+
* @returns {MatterbridgeEndpoint[]} The child endpoints.
|
|
586
|
+
*/
|
|
349
587
|
getChildEndpoints() {
|
|
350
588
|
return Array.from(this.parts);
|
|
351
589
|
}
|
|
590
|
+
/**
|
|
591
|
+
* Serializes the Matterbridge device into a serialized object.
|
|
592
|
+
*
|
|
593
|
+
* @param pluginName - The name of the plugin.
|
|
594
|
+
* @returns The serialized Matterbridge device object.
|
|
595
|
+
*/
|
|
352
596
|
static serialize(device) {
|
|
353
597
|
if (!device.serialNumber || !device.deviceName || !device.uniqueId)
|
|
354
598
|
return;
|
|
@@ -371,9 +615,15 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
371
615
|
serialized.clusterServersId.push(BridgedDeviceBasicInformation.Cluster.id);
|
|
372
616
|
if (behaviorName === 'powerSource')
|
|
373
617
|
serialized.clusterServersId.push(PowerSource.Cluster.id);
|
|
618
|
+
// serialized.clusterServersId.push(this.behaviors.supported[behaviorName]cluster.id);
|
|
374
619
|
});
|
|
375
620
|
return serialized;
|
|
376
621
|
}
|
|
622
|
+
/**
|
|
623
|
+
* Deserializes the device into a serialized object.
|
|
624
|
+
*
|
|
625
|
+
* @returns The deserialized MatterbridgeDevice.
|
|
626
|
+
*/
|
|
377
627
|
static deserialize(serializedDevice) {
|
|
378
628
|
const device = new MatterbridgeEndpoint(serializedDevice.deviceTypes, { uniqueStorageKey: serializedDevice.endpointName, endpointId: serializedDevice.endpoint }, false);
|
|
379
629
|
device.plugin = serializedDevice.pluginName;
|
|
@@ -389,9 +639,16 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
389
639
|
device.createDefaultBridgedDeviceBasicInformationClusterServer(serializedDevice.deviceName, serializedDevice.serialNumber, serializedDevice.vendorId ?? 0xfff1, serializedDevice.vendorName ?? 'Matterbridge', serializedDevice.productName ?? 'Matterbridge device');
|
|
390
640
|
else if (clusterId === PowerSource.Cluster.id)
|
|
391
641
|
device.createDefaultPowerSourceWiredClusterServer();
|
|
642
|
+
// else addClusterServerFromList(device, [clusterId]);
|
|
392
643
|
}
|
|
393
644
|
return device;
|
|
394
645
|
}
|
|
646
|
+
/**
|
|
647
|
+
* Creates a default power source wired cluster server.
|
|
648
|
+
*
|
|
649
|
+
* @param wiredCurrentType - The type of wired current (default: PowerSource.WiredCurrentType.Ac)
|
|
650
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
651
|
+
*/
|
|
395
652
|
createDefaultPowerSourceWiredClusterServer(wiredCurrentType = PowerSource.WiredCurrentType.Ac) {
|
|
396
653
|
this.behaviors.require(PowerSourceServer.with(PowerSource.Feature.Wired), {
|
|
397
654
|
wiredCurrentType,
|
|
@@ -402,6 +659,16 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
402
659
|
});
|
|
403
660
|
return this;
|
|
404
661
|
}
|
|
662
|
+
/**
|
|
663
|
+
* Creates a default power source replaceable battery cluster server.
|
|
664
|
+
*
|
|
665
|
+
* @param batPercentRemaining - The remaining battery percentage (default: 100).
|
|
666
|
+
* @param batChargeLevel - The battery charge level (default: PowerSource.BatChargeLevel.Ok).
|
|
667
|
+
* @param batVoltage - The battery voltage (default: 1500).
|
|
668
|
+
* @param batReplacementDescription - The battery replacement description (default: 'Battery type').
|
|
669
|
+
* @param batQuantity - The battery quantity (default: 1).
|
|
670
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
671
|
+
*/
|
|
405
672
|
createDefaultPowerSourceReplaceableBatteryClusterServer(batPercentRemaining = 100, batChargeLevel = PowerSource.BatChargeLevel.Ok, batVoltage = 1500, batReplacementDescription = 'Battery type', batQuantity = 1) {
|
|
406
673
|
this.behaviors.require(PowerSourceServer.with(PowerSource.Feature.Battery, PowerSource.Feature.Replaceable), {
|
|
407
674
|
status: PowerSource.PowerSourceStatus.Active,
|
|
@@ -419,6 +686,14 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
419
686
|
});
|
|
420
687
|
return this;
|
|
421
688
|
}
|
|
689
|
+
/**
|
|
690
|
+
* Creates a default power source rechargeable battery cluster server.
|
|
691
|
+
*
|
|
692
|
+
* @param batPercentRemaining - The remaining battery percentage (default: 100).
|
|
693
|
+
* @param batChargeLevel - The battery charge level (default: PowerSource.BatChargeLevel.Ok).
|
|
694
|
+
* @param batVoltage - The battery voltage (default: 1500).
|
|
695
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
696
|
+
*/
|
|
422
697
|
createDefaultPowerSourceRechargeableBatteryClusterServer(batPercentRemaining = 100, batChargeLevel = PowerSource.BatChargeLevel.Ok, batVoltage = 1500) {
|
|
423
698
|
this.behaviors.require(PowerSourceServer.with(PowerSource.Feature.Battery, PowerSource.Feature.Rechargeable), {
|
|
424
699
|
status: PowerSource.PowerSourceStatus.Active,
|
|
@@ -437,6 +712,21 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
437
712
|
});
|
|
438
713
|
return this;
|
|
439
714
|
}
|
|
715
|
+
/**
|
|
716
|
+
* Creates a default Basic Information Cluster Server for the server node.
|
|
717
|
+
*
|
|
718
|
+
* @param deviceName - The name of the device.
|
|
719
|
+
* @param serialNumber - The serial number of the device.
|
|
720
|
+
* @param vendorId - The vendor ID of the device.
|
|
721
|
+
* @param vendorName - The vendor name of the device.
|
|
722
|
+
* @param productId - The product ID of the device.
|
|
723
|
+
* @param productName - The product name of the device.
|
|
724
|
+
* @param softwareVersion - The software version of the device. Default is 1.
|
|
725
|
+
* @param softwareVersionString - The software version string of the device. Default is 'v.1.0.0'.
|
|
726
|
+
* @param hardwareVersion - The hardware version of the device. Default is 1.
|
|
727
|
+
* @param hardwareVersionString - The hardware version string of the device. Default is 'v.1.0.0'.
|
|
728
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
729
|
+
*/
|
|
440
730
|
createDefaultBasicInformationClusterServer(deviceName, serialNumber, vendorId, vendorName, productId, productName, softwareVersion = 1, softwareVersionString = '1.0.0', hardwareVersion = 1, hardwareVersionString = '1.0.0') {
|
|
441
731
|
this.log.logName = deviceName;
|
|
442
732
|
this.deviceName = deviceName;
|
|
@@ -460,6 +750,20 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
460
750
|
}
|
|
461
751
|
return this;
|
|
462
752
|
}
|
|
753
|
+
/**
|
|
754
|
+
* Creates a default BridgedDeviceBasicInformationClusterServer for the aggregator endpoints.
|
|
755
|
+
*
|
|
756
|
+
* @param deviceName - The name of the device.
|
|
757
|
+
* @param serialNumber - The serial number of the device.
|
|
758
|
+
* @param vendorId - The vendor ID of the device.
|
|
759
|
+
* @param vendorName - The name of the vendor.
|
|
760
|
+
* @param productName - The name of the product.
|
|
761
|
+
* @param softwareVersion - The software version of the device. Default is 1.
|
|
762
|
+
* @param softwareVersionString - The software version string of the device. Default is 'v.1.0.0'.
|
|
763
|
+
* @param hardwareVersion - The hardware version of the device. Default is 1.
|
|
764
|
+
* @param hardwareVersionString - The hardware version string of the device. Default is 'v.1.0.0'.
|
|
765
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
766
|
+
*/
|
|
463
767
|
createDefaultBridgedDeviceBasicInformationClusterServer(deviceName, serialNumber, vendorId, vendorName, productName, softwareVersion = 1, softwareVersionString = '1.0.0', hardwareVersion = 1, hardwareVersionString = '1.0.0') {
|
|
464
768
|
this.log.logName = deviceName;
|
|
465
769
|
this.deviceName = deviceName;
|
|
@@ -476,7 +780,7 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
476
780
|
this.behaviors.require(BridgedDeviceBasicInformationServer.enable({
|
|
477
781
|
events: { leave: true, reachableChanged: true },
|
|
478
782
|
}), {
|
|
479
|
-
vendorId: vendorId !== undefined ? VendorId(vendorId) : undefined,
|
|
783
|
+
vendorId: vendorId !== undefined ? VendorId(vendorId) : undefined, // 4874
|
|
480
784
|
vendorName: vendorName.slice(0, 32),
|
|
481
785
|
productName: productName.slice(0, 32),
|
|
482
786
|
productUrl: this.productUrl,
|
|
@@ -492,6 +796,13 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
492
796
|
});
|
|
493
797
|
return this;
|
|
494
798
|
}
|
|
799
|
+
/**
|
|
800
|
+
* Creates a default identify cluster server with the specified identify time and type.
|
|
801
|
+
*
|
|
802
|
+
* @param {number} [identifyTime=0] - The time to identify the server. Defaults to 0.
|
|
803
|
+
* @param {Identify.IdentifyType} [identifyType=Identify.IdentifyType.None] - The type of identification. Defaults to Identify.IdentifyType.None.
|
|
804
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
805
|
+
*/
|
|
495
806
|
createDefaultIdentifyClusterServer(identifyTime = 0, identifyType = Identify.IdentifyType.None) {
|
|
496
807
|
this.behaviors.require(MatterbridgeIdentifyServer, {
|
|
497
808
|
identifyTime,
|
|
@@ -499,14 +810,32 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
499
810
|
});
|
|
500
811
|
return this;
|
|
501
812
|
}
|
|
813
|
+
/**
|
|
814
|
+
* Creates a default groups cluster server.
|
|
815
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
816
|
+
*/
|
|
502
817
|
createDefaultGroupsClusterServer() {
|
|
503
818
|
this.behaviors.require(GroupsServer);
|
|
504
819
|
return this;
|
|
505
820
|
}
|
|
821
|
+
/**
|
|
822
|
+
* Creates a default scenes management cluster server.
|
|
823
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
824
|
+
*/
|
|
506
825
|
createDefaultScenesClusterServer() {
|
|
507
826
|
this.behaviors.require(ScenesManagementServer);
|
|
508
827
|
return this;
|
|
509
828
|
}
|
|
829
|
+
/**
|
|
830
|
+
* Creates a default OnOff cluster server for light devices.
|
|
831
|
+
*
|
|
832
|
+
* @param {boolean} [onOff=false] - The initial state of the OnOff cluster.
|
|
833
|
+
* @param {boolean} [globalSceneControl=false] - The global scene control state.
|
|
834
|
+
* @param {number} [onTime=0] - The on time value.
|
|
835
|
+
* @param {number} [offWaitTime=0] - The off wait time value.
|
|
836
|
+
* @param {OnOff.StartUpOnOff | null} [startUpOnOff=null] - The start-up OnOff state. Null means previous state.
|
|
837
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
838
|
+
*/
|
|
510
839
|
createDefaultOnOffClusterServer(onOff = false, globalSceneControl = false, onTime = 0, offWaitTime = 0, startUpOnOff = null) {
|
|
511
840
|
this.behaviors.require(MatterbridgeOnOffServer.with(OnOff.Feature.Lighting), {
|
|
512
841
|
onOff,
|
|
@@ -517,18 +846,40 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
517
846
|
});
|
|
518
847
|
return this;
|
|
519
848
|
}
|
|
849
|
+
/**
|
|
850
|
+
* Creates an OnOff cluster server without features.
|
|
851
|
+
*
|
|
852
|
+
* @param {boolean} [onOff=false] - The initial state of the OnOff cluster.
|
|
853
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
854
|
+
*/
|
|
520
855
|
createOnOffClusterServer(onOff = false) {
|
|
521
856
|
this.behaviors.require(MatterbridgeOnOffServer.for(ClusterType(OnOff.Base)), {
|
|
522
857
|
onOff,
|
|
523
858
|
});
|
|
524
859
|
return this;
|
|
525
860
|
}
|
|
861
|
+
/**
|
|
862
|
+
* Creates a DeadFront OnOff cluster server.
|
|
863
|
+
*
|
|
864
|
+
* @param {boolean} [onOff=false] - The initial state of the OnOff cluster.
|
|
865
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
866
|
+
*/
|
|
526
867
|
createDeadFrontOnOffClusterServer(onOff = false) {
|
|
527
868
|
this.behaviors.require(MatterbridgeOnOffServer.with(OnOff.Feature.DeadFrontBehavior), {
|
|
528
869
|
onOff,
|
|
529
870
|
});
|
|
530
871
|
return this;
|
|
531
872
|
}
|
|
873
|
+
/**
|
|
874
|
+
* Creates a default level control cluster server for light devices.
|
|
875
|
+
*
|
|
876
|
+
* @param {number} [currentLevel=254] - The current level (default: 254).
|
|
877
|
+
* @param {number} [minLevel=1] - The minimum level (default: 1).
|
|
878
|
+
* @param {number} [maxLevel=254] - The maximum level (default: 254).
|
|
879
|
+
* @param {number | null} [onLevel=null] - The on level (default: null).
|
|
880
|
+
* @param {number | null} [startUpCurrentLevel=null] - The startUp on level (default: null).
|
|
881
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
882
|
+
*/
|
|
532
883
|
createDefaultLevelControlClusterServer(currentLevel = 254, minLevel = 1, maxLevel = 254, onLevel = null, startUpCurrentLevel = null) {
|
|
533
884
|
this.behaviors.require(MatterbridgeLevelControlServer.with(LevelControl.Feature.OnOff, LevelControl.Feature.Lighting), {
|
|
534
885
|
currentLevel,
|
|
@@ -544,6 +895,18 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
544
895
|
});
|
|
545
896
|
return this;
|
|
546
897
|
}
|
|
898
|
+
/**
|
|
899
|
+
* Creates a default color control cluster server with Xy, HueSaturation and ColorTemperature.
|
|
900
|
+
*
|
|
901
|
+
* @param currentX - The current X value.
|
|
902
|
+
* @param currentY - The current Y value.
|
|
903
|
+
* @param currentHue - The current hue value.
|
|
904
|
+
* @param currentSaturation - The current saturation value.
|
|
905
|
+
* @param colorTemperatureMireds - The color temperature in mireds.
|
|
906
|
+
* @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds.
|
|
907
|
+
* @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds.
|
|
908
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
909
|
+
*/
|
|
547
910
|
createDefaultColorControlClusterServer(currentX = 0, currentY = 0, currentHue = 0, currentSaturation = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
|
|
548
911
|
this.behaviors.require(MatterbridgeColorControlServer.with(ColorControl.Feature.Xy, ColorControl.Feature.HueSaturation, ColorControl.Feature.ColorTemperature), {
|
|
549
912
|
colorMode: ColorControl.ColorMode.CurrentHueAndCurrentSaturation,
|
|
@@ -566,6 +929,19 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
566
929
|
});
|
|
567
930
|
return this;
|
|
568
931
|
}
|
|
932
|
+
/**
|
|
933
|
+
* Creates a Xy color control cluster server with Xy and ColorTemperature.
|
|
934
|
+
*
|
|
935
|
+
* @param currentX - The current X value.
|
|
936
|
+
* @param currentY - The current Y value.
|
|
937
|
+
* @param colorTemperatureMireds - The color temperature in mireds.
|
|
938
|
+
* @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds.
|
|
939
|
+
* @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds.
|
|
940
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
941
|
+
*
|
|
942
|
+
* @remarks
|
|
943
|
+
* From zigbee to matter = Math.max(Math.min(Math.round(x * 65536), 65279), 0)
|
|
944
|
+
*/
|
|
569
945
|
createXyColorControlClusterServer(currentX = 0, currentY = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
|
|
570
946
|
this.behaviors.require(MatterbridgeColorControlServer.with(ColorControl.Feature.Xy, ColorControl.Feature.ColorTemperature), {
|
|
571
947
|
colorMode: ColorControl.ColorMode.CurrentXAndCurrentY,
|
|
@@ -586,6 +962,16 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
586
962
|
});
|
|
587
963
|
return this;
|
|
588
964
|
}
|
|
965
|
+
/**
|
|
966
|
+
* Creates a default hue and saturation control cluster server with HueSaturation and ColorTemperature.
|
|
967
|
+
*
|
|
968
|
+
* @param currentHue - The current hue value.
|
|
969
|
+
* @param currentSaturation - The current saturation value.
|
|
970
|
+
* @param colorTemperatureMireds - The color temperature in mireds.
|
|
971
|
+
* @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds.
|
|
972
|
+
* @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds.
|
|
973
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
974
|
+
*/
|
|
589
975
|
createHsColorControlClusterServer(currentHue = 0, currentSaturation = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
|
|
590
976
|
this.behaviors.require(MatterbridgeColorControlServer.with(ColorControl.Feature.HueSaturation, ColorControl.Feature.ColorTemperature), {
|
|
591
977
|
colorMode: ColorControl.ColorMode.CurrentHueAndCurrentSaturation,
|
|
@@ -606,6 +992,14 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
606
992
|
});
|
|
607
993
|
return this;
|
|
608
994
|
}
|
|
995
|
+
/**
|
|
996
|
+
* Creates a color temperature color control cluster server.
|
|
997
|
+
*
|
|
998
|
+
* @param colorTemperatureMireds - The color temperature in mireds.
|
|
999
|
+
* @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds.
|
|
1000
|
+
* @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds.
|
|
1001
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1002
|
+
*/
|
|
609
1003
|
createCtColorControlClusterServer(colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
|
|
610
1004
|
this.behaviors.require(MatterbridgeColorControlServer.with(ColorControl.Feature.ColorTemperature), {
|
|
611
1005
|
colorMode: ColorControl.ColorMode.ColorTemperatureMireds,
|
|
@@ -624,12 +1018,23 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
624
1018
|
});
|
|
625
1019
|
return this;
|
|
626
1020
|
}
|
|
1021
|
+
/**
|
|
1022
|
+
* Configures the color control mode for the device.
|
|
1023
|
+
*
|
|
1024
|
+
* @param {ColorControl.ColorMode} colorMode - The color mode to set.
|
|
1025
|
+
*/
|
|
627
1026
|
async configureColorControlMode(colorMode) {
|
|
628
1027
|
if (isValidNumber(colorMode, ColorControl.ColorMode.CurrentHueAndCurrentSaturation, ColorControl.ColorMode.ColorTemperatureMireds)) {
|
|
629
1028
|
await this.setAttribute(ColorControl.Cluster.id, 'colorMode', colorMode, this.log);
|
|
630
1029
|
await this.setAttribute(ColorControl.Cluster.id, 'enhancedColorMode', colorMode, this.log);
|
|
631
1030
|
}
|
|
632
1031
|
}
|
|
1032
|
+
/**
|
|
1033
|
+
* Creates a default window covering cluster server (Lift and PositionAwareLift).
|
|
1034
|
+
*
|
|
1035
|
+
* @param positionPercent100ths - The position percentage in 100ths (0-10000). Defaults to 0. Matter uses 10000 = fully closed 0 = fully opened.
|
|
1036
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1037
|
+
*/
|
|
633
1038
|
createDefaultWindowCoveringClusterServer(positionPercent100ths) {
|
|
634
1039
|
this.behaviors.require(MatterbridgeWindowCoveringServer.with(WindowCovering.Feature.Lift, WindowCovering.Feature.PositionAwareLift), {
|
|
635
1040
|
type: WindowCovering.WindowCoveringType.Rollershade,
|
|
@@ -645,11 +1050,15 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
645
1050
|
operationalStatus: { global: WindowCovering.MovementStatus.Stopped, lift: WindowCovering.MovementStatus.Stopped, tilt: WindowCovering.MovementStatus.Stopped },
|
|
646
1051
|
endProductType: WindowCovering.EndProductType.RollerShade,
|
|
647
1052
|
mode: { motorDirectionReversed: false, calibrationMode: false, maintenanceMode: false, ledFeedback: false },
|
|
648
|
-
targetPositionLiftPercent100ths: positionPercent100ths ?? 0,
|
|
649
|
-
currentPositionLiftPercent100ths: positionPercent100ths ?? 0,
|
|
1053
|
+
targetPositionLiftPercent100ths: positionPercent100ths ?? 0, // 0 Fully open 10000 fully closed
|
|
1054
|
+
currentPositionLiftPercent100ths: positionPercent100ths ?? 0, // 0 Fully open 10000 fully closed
|
|
650
1055
|
});
|
|
651
1056
|
return this;
|
|
652
1057
|
}
|
|
1058
|
+
/**
|
|
1059
|
+
* Sets the window covering target position as the current position and stops the movement.
|
|
1060
|
+
*
|
|
1061
|
+
*/
|
|
653
1062
|
async setWindowCoveringTargetAsCurrentAndStopped() {
|
|
654
1063
|
const position = this.getAttribute(WindowCovering.Cluster.id, 'currentPositionLiftPercent100ths', this.log);
|
|
655
1064
|
if (isValidNumber(position, 0, 10000)) {
|
|
@@ -662,6 +1071,12 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
662
1071
|
}
|
|
663
1072
|
this.log.debug(`Set WindowCovering currentPositionLiftPercent100ths and targetPositionLiftPercent100ths to ${position} and operationalStatus to Stopped.`);
|
|
664
1073
|
}
|
|
1074
|
+
/**
|
|
1075
|
+
* Sets the current and target status of a window covering.
|
|
1076
|
+
* @param {number} current - The current position of the window covering.
|
|
1077
|
+
* @param {number} target - The target position of the window covering.
|
|
1078
|
+
* @param {WindowCovering.MovementStatus} status - The movement status of the window covering.
|
|
1079
|
+
*/
|
|
665
1080
|
async setWindowCoveringCurrentTargetStatus(current, target, status) {
|
|
666
1081
|
await this.setAttribute(WindowCovering.Cluster.id, 'currentPositionLiftPercent100ths', current, this.log);
|
|
667
1082
|
await this.setAttribute(WindowCovering.Cluster.id, 'targetPositionLiftPercent100ths', target, this.log);
|
|
@@ -672,6 +1087,10 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
672
1087
|
}, this.log);
|
|
673
1088
|
this.log.debug(`Set WindowCovering currentPositionLiftPercent100ths: ${current}, targetPositionLiftPercent100ths: ${target} and operationalStatus: ${status}.`);
|
|
674
1089
|
}
|
|
1090
|
+
/**
|
|
1091
|
+
* Sets the status of the window covering.
|
|
1092
|
+
* @param {WindowCovering.MovementStatus} status - The movement status to set.
|
|
1093
|
+
*/
|
|
675
1094
|
async setWindowCoveringStatus(status) {
|
|
676
1095
|
await this.setAttribute(WindowCovering.Cluster.id, 'operationalStatus', {
|
|
677
1096
|
global: status,
|
|
@@ -680,6 +1099,11 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
680
1099
|
}, this.log);
|
|
681
1100
|
this.log.debug(`Set WindowCovering operationalStatus: ${status}`);
|
|
682
1101
|
}
|
|
1102
|
+
/**
|
|
1103
|
+
* Retrieves the status of the window covering.
|
|
1104
|
+
*
|
|
1105
|
+
* @returns The global operational status of the window covering or undefined.
|
|
1106
|
+
*/
|
|
683
1107
|
getWindowCoveringStatus() {
|
|
684
1108
|
const status = this.getAttribute(WindowCovering.Cluster.id, 'operationalStatus', this.log);
|
|
685
1109
|
if (isValidObject(status, 3) && 'global' in status && typeof status.global === 'number') {
|
|
@@ -687,36 +1111,66 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
687
1111
|
return status.global;
|
|
688
1112
|
}
|
|
689
1113
|
}
|
|
1114
|
+
/**
|
|
1115
|
+
* Sets the target and current position of the window covering.
|
|
1116
|
+
*
|
|
1117
|
+
* @param position - The position to set, specified as a number.
|
|
1118
|
+
*/
|
|
690
1119
|
async setWindowCoveringTargetAndCurrentPosition(position) {
|
|
691
1120
|
await this.setAttribute(WindowCovering.Cluster.id, 'currentPositionLiftPercent100ths', position, this.log);
|
|
692
1121
|
await this.setAttribute(WindowCovering.Cluster.id, 'targetPositionLiftPercent100ths', position, this.log);
|
|
693
1122
|
this.log.debug(`Set WindowCovering currentPositionLiftPercent100ths: ${position} and targetPositionLiftPercent100ths: ${position}.`);
|
|
694
1123
|
}
|
|
1124
|
+
/**
|
|
1125
|
+
* Creates a default thermostat cluster server with Thermostat.Feature.Heating, Thermostat.Feature.Cooling, Thermostat.Feature.AutoMode.
|
|
1126
|
+
*
|
|
1127
|
+
* @param {number} [localTemperature=23] - The local temperature value in degrees Celsius. Defaults to 23°.
|
|
1128
|
+
* @param {number} [occupiedHeatingSetpoint=21] - The occupied heating setpoint value in degrees Celsius. Defaults to 21°.
|
|
1129
|
+
* @param {number} [occupiedCoolingSetpoint=25] - The occupied cooling setpoint value in degrees Celsius. Defaults to 25°.
|
|
1130
|
+
* @param {number} [minSetpointDeadBand=1] - The minimum setpoint dead band value. Defaults to 1°.
|
|
1131
|
+
* @param {number} [minHeatSetpointLimit=0] - The minimum heat setpoint limit value. Defaults to 0°.
|
|
1132
|
+
* @param {number} [maxHeatSetpointLimit=50] - The maximum heat setpoint limit value. Defaults to 50°.
|
|
1133
|
+
* @param {number} [minCoolSetpointLimit=0] - The minimum cool setpoint limit value. Defaults to 0°.
|
|
1134
|
+
* @param {number} [maxCoolSetpointLimit=50] - The maximum cool setpoint limit value. Defaults to 50°.
|
|
1135
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1136
|
+
*/
|
|
695
1137
|
createDefaultThermostatClusterServer(localTemperature = 23, occupiedHeatingSetpoint = 21, occupiedCoolingSetpoint = 25, minSetpointDeadBand = 1, minHeatSetpointLimit = 0, maxHeatSetpointLimit = 50, minCoolSetpointLimit = 0, maxCoolSetpointLimit = 50) {
|
|
696
1138
|
this.behaviors.require(MatterbridgeThermostatServer.with(Thermostat.Feature.Heating, Thermostat.Feature.Cooling, Thermostat.Feature.AutoMode), {
|
|
697
1139
|
localTemperature: localTemperature * 100,
|
|
698
1140
|
systemMode: Thermostat.SystemMode.Auto,
|
|
699
1141
|
controlSequenceOfOperation: Thermostat.ControlSequenceOfOperation.CoolingAndHeating,
|
|
1142
|
+
// Thermostat.Feature.Heating
|
|
700
1143
|
occupiedHeatingSetpoint: occupiedHeatingSetpoint * 100,
|
|
701
1144
|
minHeatSetpointLimit: minHeatSetpointLimit * 100,
|
|
702
1145
|
maxHeatSetpointLimit: maxHeatSetpointLimit * 100,
|
|
703
1146
|
absMinHeatSetpointLimit: minHeatSetpointLimit * 100,
|
|
704
1147
|
absMaxHeatSetpointLimit: maxHeatSetpointLimit * 100,
|
|
1148
|
+
// Thermostat.Feature.Cooling
|
|
705
1149
|
occupiedCoolingSetpoint: occupiedCoolingSetpoint * 100,
|
|
706
1150
|
minCoolSetpointLimit: minCoolSetpointLimit * 100,
|
|
707
1151
|
maxCoolSetpointLimit: maxCoolSetpointLimit * 100,
|
|
708
1152
|
absMinCoolSetpointLimit: minCoolSetpointLimit * 100,
|
|
709
1153
|
absMaxCoolSetpointLimit: maxCoolSetpointLimit * 100,
|
|
1154
|
+
// Thermostat.Feature.AutoMode
|
|
710
1155
|
minSetpointDeadBand: minSetpointDeadBand * 100,
|
|
711
1156
|
thermostatRunningMode: Thermostat.ThermostatRunningMode.Off,
|
|
712
1157
|
});
|
|
713
1158
|
return this;
|
|
714
1159
|
}
|
|
1160
|
+
/**
|
|
1161
|
+
* Creates a default heating thermostat cluster server with Thermostat.Feature.Heating.
|
|
1162
|
+
* @param {number} [localTemperature] - The local temperature value in degrees Celsius. Defaults to 23°.
|
|
1163
|
+
* @param {number} [occupiedHeatingSetpoint] - The occupied heating setpoint value in degrees Celsius. Defaults to 21°.
|
|
1164
|
+
* @param {number} [minHeatSetpointLimit] - The minimum heat setpoint limit value. Defaults to 0°.
|
|
1165
|
+
* @param {number} [maxHeatSetpointLimit] - The maximum heat setpoint limit value. Defaults to 50°.
|
|
1166
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1167
|
+
*/
|
|
715
1168
|
createDefaultHeatingThermostatClusterServer(localTemperature = 23, occupiedHeatingSetpoint = 21, minHeatSetpointLimit = 0, maxHeatSetpointLimit = 50) {
|
|
716
1169
|
this.behaviors.require(MatterbridgeThermostatServer.with(Thermostat.Feature.Heating), {
|
|
717
1170
|
localTemperature: localTemperature * 100,
|
|
718
1171
|
systemMode: Thermostat.SystemMode.Heat,
|
|
719
1172
|
controlSequenceOfOperation: Thermostat.ControlSequenceOfOperation.HeatingOnly,
|
|
1173
|
+
// Thermostat.Feature.Heating
|
|
720
1174
|
occupiedHeatingSetpoint: occupiedHeatingSetpoint * 100,
|
|
721
1175
|
minHeatSetpointLimit: minHeatSetpointLimit * 100,
|
|
722
1176
|
maxHeatSetpointLimit: maxHeatSetpointLimit * 100,
|
|
@@ -725,11 +1179,20 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
725
1179
|
});
|
|
726
1180
|
return this;
|
|
727
1181
|
}
|
|
1182
|
+
/**
|
|
1183
|
+
* Creates a default cooling thermostat cluster server with Thermostat.Feature.Cooling.
|
|
1184
|
+
* @param {number} [localTemperature] - The local temperature value in degrees Celsius. Defaults to 23°.
|
|
1185
|
+
* @param {number} [occupiedCoolingSetpoint] - The occupied cooling setpoint value in degrees Celsius. Defaults to 25°.
|
|
1186
|
+
* @param {number} [minCoolSetpointLimit] - The minimum cool setpoint limit value. Defaults to 0°.
|
|
1187
|
+
* @param {number} [maxCoolSetpointLimit] - The maximum cool setpoint limit value. Defaults to 50°.
|
|
1188
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1189
|
+
*/
|
|
728
1190
|
createDefaultCoolingThermostatClusterServer(localTemperature = 23, occupiedCoolingSetpoint = 25, minCoolSetpointLimit = 0, maxCoolSetpointLimit = 50) {
|
|
729
1191
|
this.behaviors.require(MatterbridgeThermostatServer.with(Thermostat.Feature.Cooling), {
|
|
730
1192
|
localTemperature: localTemperature * 100,
|
|
731
1193
|
systemMode: Thermostat.SystemMode.Cool,
|
|
732
1194
|
controlSequenceOfOperation: Thermostat.ControlSequenceOfOperation.CoolingOnly,
|
|
1195
|
+
// Thermostat.Feature.Cooling
|
|
733
1196
|
occupiedCoolingSetpoint: occupiedCoolingSetpoint * 100,
|
|
734
1197
|
minCoolSetpointLimit: minCoolSetpointLimit * 100,
|
|
735
1198
|
maxCoolSetpointLimit: maxCoolSetpointLimit * 100,
|
|
@@ -738,6 +1201,12 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
738
1201
|
});
|
|
739
1202
|
return this;
|
|
740
1203
|
}
|
|
1204
|
+
/**
|
|
1205
|
+
* Creates a default fan control cluster server.
|
|
1206
|
+
*
|
|
1207
|
+
* @param fanMode The fan mode to set. Defaults to `FanControl.FanMode.Off`.
|
|
1208
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1209
|
+
*/
|
|
741
1210
|
createDefaultFanControlClusterServer(fanMode = FanControl.FanMode.Off) {
|
|
742
1211
|
this.behaviors.require(MatterbridgeFanControlServer.with(FanControl.Feature.MultiSpeed, FanControl.Feature.Auto, FanControl.Feature.Step), {
|
|
743
1212
|
fanMode,
|
|
@@ -750,6 +1219,13 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
750
1219
|
});
|
|
751
1220
|
return this;
|
|
752
1221
|
}
|
|
1222
|
+
/**
|
|
1223
|
+
* Creates a default door lock cluster server.
|
|
1224
|
+
*
|
|
1225
|
+
* @param {DoorLock.LockState} [lockState=DoorLock.LockState.Locked] - The initial state of the lock (default: Locked).
|
|
1226
|
+
* @param {DoorLock.LockType} [lockType=DoorLock.LockType.DeadBolt] - The type of the lock (default: DeadBolt).
|
|
1227
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1228
|
+
*/
|
|
753
1229
|
createDefaultDoorLockClusterServer(lockState = DoorLock.LockState.Locked, lockType = DoorLock.LockType.DeadBolt) {
|
|
754
1230
|
this.behaviors.require(MatterbridgeDoorLockServer.enable({ events: { doorLockAlarm: true, lockOperation: true, lockOperationError: true } }), {
|
|
755
1231
|
operatingMode: DoorLock.OperatingMode.Normal,
|
|
@@ -760,6 +1236,18 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
760
1236
|
});
|
|
761
1237
|
return this;
|
|
762
1238
|
}
|
|
1239
|
+
/**
|
|
1240
|
+
* Creates a default Mode Select cluster server.
|
|
1241
|
+
*
|
|
1242
|
+
* @param {string} description - The description of the mode select cluster.
|
|
1243
|
+
* @param {ModeSelect.ModeOption[]} supportedModes - The list of supported modes.
|
|
1244
|
+
* @param {number} [currentMode=0] - The current mode (default: 0).
|
|
1245
|
+
* @param {number} [startUpMode=0] - The startup mode (default: 0).
|
|
1246
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1247
|
+
*
|
|
1248
|
+
* @remarks
|
|
1249
|
+
* endpoint.createDefaultModeSelectClusterServer('Night mode', [{ label: 'Led ON', mode: 0, semanticTags: [] }, { label: 'Led OFF', mode: 1, semanticTags: [] }], 0, 0);
|
|
1250
|
+
*/
|
|
763
1251
|
createDefaultModeSelectClusterServer(description, supportedModes, currentMode = 0, startUpMode = 0) {
|
|
764
1252
|
this.behaviors.require(MatterbridgeModeSelectServer, {
|
|
765
1253
|
description: description,
|
|
@@ -770,6 +1258,13 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
770
1258
|
});
|
|
771
1259
|
return this;
|
|
772
1260
|
}
|
|
1261
|
+
/**
|
|
1262
|
+
* Creates the default Valve Configuration And Control cluster server.
|
|
1263
|
+
*
|
|
1264
|
+
* @param {ValveConfigurationAndControl.ValveState} [valveState=ValveConfigurationAndControl.ValveState.Closed] - The valve state to set. Defaults to `ValveConfigurationAndControl.ValveState.Closed`.
|
|
1265
|
+
* @param {number} [valveLevel=0] - The valve level to set. Defaults to 0.
|
|
1266
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1267
|
+
*/
|
|
773
1268
|
createDefaultValveConfigurationAndControlClusterServer(valveState = ValveConfigurationAndControl.ValveState.Closed, valveLevel = 0) {
|
|
774
1269
|
this.behaviors.require(MatterbridgeValveConfigurationAndControlServer.with(ValveConfigurationAndControl.Feature.Level), {
|
|
775
1270
|
currentState: valveState,
|
|
@@ -782,6 +1277,12 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
782
1277
|
});
|
|
783
1278
|
return this;
|
|
784
1279
|
}
|
|
1280
|
+
/**
|
|
1281
|
+
* Creates the default PumpConfigurationAndControl cluster server.
|
|
1282
|
+
*
|
|
1283
|
+
* @param {PumpConfigurationAndControl.OperationMode} [pumpMode=PumpConfigurationAndControl.OperationMode.Normal] - The pump mode to set. Defaults to `PumpConfigurationAndControl.OperationMode.Normal`.
|
|
1284
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1285
|
+
*/
|
|
785
1286
|
createDefaultPumpConfigurationAndControlClusterServer(pumpMode = PumpConfigurationAndControl.OperationMode.Normal) {
|
|
786
1287
|
this.behaviors.require(PumpConfigurationAndControlServer.with(PumpConfigurationAndControl.Feature.ConstantSpeed), {
|
|
787
1288
|
minConstSpeed: null,
|
|
@@ -796,6 +1297,13 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
796
1297
|
});
|
|
797
1298
|
return this;
|
|
798
1299
|
}
|
|
1300
|
+
/**
|
|
1301
|
+
* Creates the default SmokeCOAlarm Cluster Server.
|
|
1302
|
+
*
|
|
1303
|
+
* @param {SmokeCoAlarm.AlarmState} smokeState - The state of the smoke alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
|
|
1304
|
+
* @param {SmokeCoAlarm.AlarmState} coState - The state of the CO alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
|
|
1305
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1306
|
+
*/
|
|
799
1307
|
createDefaultSmokeCOAlarmClusterServer(smokeState = SmokeCoAlarm.AlarmState.Normal, coState = SmokeCoAlarm.AlarmState.Normal) {
|
|
800
1308
|
this.behaviors.require(MatterbridgeSmokeCoAlarmServer.with(SmokeCoAlarm.Feature.SmokeAlarm, SmokeCoAlarm.Feature.CoAlarm).enable({
|
|
801
1309
|
events: { smokeAlarm: true, interconnectSmokeAlarm: true, coAlarm: true, interconnectCoAlarm: true, lowBattery: true, hardwareFault: true, endOfService: true, selfTestComplete: true, alarmMuted: true, muteEnded: true, allClear: true },
|
|
@@ -813,6 +1321,13 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
813
1321
|
});
|
|
814
1322
|
return this;
|
|
815
1323
|
}
|
|
1324
|
+
/**
|
|
1325
|
+
* Creates a default momentary switch cluster server.
|
|
1326
|
+
*
|
|
1327
|
+
* @remarks
|
|
1328
|
+
* This method adds a cluster server with default momentary switch features and configuration suitable for (AppleHome) Single Double Long automations.
|
|
1329
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1330
|
+
*/
|
|
816
1331
|
createDefaultSwitchClusterServer() {
|
|
817
1332
|
this.behaviors.require(MatterbridgeSwitchServer.with(Switch.Feature.MomentarySwitch, Switch.Feature.MomentarySwitchRelease, Switch.Feature.MomentarySwitchLongPress, Switch.Feature.MomentarySwitchMultiPress).enable({
|
|
818
1333
|
events: { initialPress: true, longPress: true, shortRelease: true, longRelease: true, multiPressOngoing: true, multiPressComplete: true },
|
|
@@ -823,6 +1338,13 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
823
1338
|
});
|
|
824
1339
|
return this;
|
|
825
1340
|
}
|
|
1341
|
+
/**
|
|
1342
|
+
* Creates a default latching switch cluster server.
|
|
1343
|
+
*
|
|
1344
|
+
* @remarks
|
|
1345
|
+
* This method adds a cluster server with default latching switch features and configuration suitable for a latching switch with 2 positions.
|
|
1346
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1347
|
+
*/
|
|
826
1348
|
createDefaultLatchingSwitchClusterServer() {
|
|
827
1349
|
this.behaviors.require(SwitchServer.with(Switch.Feature.LatchingSwitch).enable({
|
|
828
1350
|
events: { switchLatched: true },
|
|
@@ -832,6 +1354,13 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
832
1354
|
});
|
|
833
1355
|
return this;
|
|
834
1356
|
}
|
|
1357
|
+
/**
|
|
1358
|
+
* Triggers a switch event on the specified endpoint.
|
|
1359
|
+
*
|
|
1360
|
+
* @param {string} event - The type of event to trigger. Possible values are 'Single', 'Double', 'Long' for momentarySwitch and 'Press', 'Release' for latchingSwitch.
|
|
1361
|
+
* @param {Endpoint} endpoint - The endpoint on which to trigger the event (default the device endpoint).
|
|
1362
|
+
* @returns {boolean} - A boolean indicating whether the event was successfully triggered.
|
|
1363
|
+
*/
|
|
835
1364
|
async triggerSwitchEvent(event, log) {
|
|
836
1365
|
if (this.maybeNumber === undefined) {
|
|
837
1366
|
this.log.error(`triggerSwitchEvent ${event} error: Endpoint number not assigned on endpoint ${this.maybeId}:${this.maybeNumber}`);
|
|
@@ -891,14 +1420,31 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
891
1420
|
}
|
|
892
1421
|
return true;
|
|
893
1422
|
}
|
|
1423
|
+
/**
|
|
1424
|
+
* Creates a default boolean state cluster server.
|
|
1425
|
+
*
|
|
1426
|
+
* @param {boolean} contact - The state of the cluster. Defaults to true (true = contact).
|
|
1427
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1428
|
+
*/
|
|
894
1429
|
createDefaultBooleanStateClusterServer(contact) {
|
|
895
1430
|
this.behaviors.require(BooleanStateServer.enable({
|
|
896
1431
|
events: { stateChange: true },
|
|
897
1432
|
}), {
|
|
898
|
-
stateValue: contact ?? true,
|
|
1433
|
+
stateValue: contact ?? true, // true=contact false=no_contact
|
|
899
1434
|
});
|
|
900
1435
|
return this;
|
|
901
1436
|
}
|
|
1437
|
+
/**
|
|
1438
|
+
* Creates a default boolean state configuration cluster server to be used with the waterFreezeDetector, waterLeakDetector, and rainSensor device types.
|
|
1439
|
+
*
|
|
1440
|
+
* @remarks Supports the enableDisableAlarm command.
|
|
1441
|
+
*
|
|
1442
|
+
* @param {boolean} [sensorFault=false] - Optional boolean value indicating the sensor fault state. Defaults to `false` if not provided.
|
|
1443
|
+
* @param {number} [currentSensitivityLevel=0] - The current sensitivity level. Defaults to `0` if not provided.
|
|
1444
|
+
* @param {number} [supportedSensitivityLevels=2] - The number of supported sensitivity levels. Defaults to `2` if not provided (min 2, max 10).
|
|
1445
|
+
* @param {number} [defaultSensitivityLevel=0] - The default sensitivity level. Defaults to `0` if not provided.
|
|
1446
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1447
|
+
*/
|
|
902
1448
|
createDefaultBooleanStateConfigurationClusterServer(sensorFault = false, currentSensitivityLevel = 0, supportedSensitivityLevels = 2, defaultSensitivityLevel = 0) {
|
|
903
1449
|
this.behaviors.require(MatterbridgeBooleanStateConfigurationServer.with(BooleanStateConfiguration.Feature.Visual, BooleanStateConfiguration.Feature.Audible, BooleanStateConfiguration.Feature.SensitivityLevel).enable({
|
|
904
1450
|
events: { alarmsStateChanged: true, sensorFault: true },
|
|
@@ -913,10 +1459,21 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
913
1459
|
});
|
|
914
1460
|
return this;
|
|
915
1461
|
}
|
|
1462
|
+
/**
|
|
1463
|
+
* Creates a default Power Topology Cluster Server with feature TreeTopology. Only needed for an electricalSensor device type.
|
|
1464
|
+
*
|
|
1465
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1466
|
+
*/
|
|
916
1467
|
createDefaultPowerTopologyClusterServer() {
|
|
917
1468
|
this.behaviors.require(PowerTopologyServer.with(PowerTopology.Feature.TreeTopology));
|
|
918
1469
|
return this;
|
|
919
1470
|
}
|
|
1471
|
+
/**
|
|
1472
|
+
* Creates a default Electrical Energy Measurement Cluster Server.
|
|
1473
|
+
*
|
|
1474
|
+
* @param {number} energy - The total consumption value in mW/h.
|
|
1475
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1476
|
+
*/
|
|
920
1477
|
createDefaultElectricalEnergyMeasurementClusterServer(energy = null) {
|
|
921
1478
|
this.behaviors.require(ElectricalEnergyMeasurementServer.with(ElectricalEnergyMeasurement.Feature.ImportedEnergy, ElectricalEnergyMeasurement.Feature.ExportedEnergy, ElectricalEnergyMeasurement.Feature.CumulativeEnergy), {
|
|
922
1479
|
accuracy: {
|
|
@@ -932,6 +1489,15 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
932
1489
|
});
|
|
933
1490
|
return this;
|
|
934
1491
|
}
|
|
1492
|
+
/**
|
|
1493
|
+
* Creates a default Electrical Power Measurement Cluster Server.
|
|
1494
|
+
*
|
|
1495
|
+
* @param {number} voltage - The voltage value in millivolts.
|
|
1496
|
+
* @param {number} current - The current value in milliamperes.
|
|
1497
|
+
* @param {number} power - The power value in milliwatts.
|
|
1498
|
+
* @param {number} frequency - The frequency value in millihertz.
|
|
1499
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1500
|
+
*/
|
|
935
1501
|
createDefaultElectricalPowerMeasurementClusterServer(voltage = null, current = null, power = null, frequency = null) {
|
|
936
1502
|
this.behaviors.require(ElectricalPowerMeasurementServer.with(ElectricalPowerMeasurement.Feature.AlternatingCurrent), {
|
|
937
1503
|
powerMode: ElectricalPowerMeasurement.PowerMode.Ac,
|
|
@@ -973,36 +1539,90 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
973
1539
|
});
|
|
974
1540
|
return this;
|
|
975
1541
|
}
|
|
1542
|
+
/**
|
|
1543
|
+
* Creates a default TemperatureMeasurement cluster server.
|
|
1544
|
+
*
|
|
1545
|
+
* @param {number} measuredValue - The measured value of the temperature x 100.
|
|
1546
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1547
|
+
*/
|
|
976
1548
|
createDefaultTemperatureMeasurementClusterServer(measuredValue = 0) {
|
|
977
1549
|
this.behaviors.require(TemperatureMeasurementServer, getDefaultTemperatureMeasurementClusterServer(measuredValue));
|
|
978
1550
|
return this;
|
|
979
1551
|
}
|
|
1552
|
+
/**
|
|
1553
|
+
* Creates a default RelativeHumidityMeasurement cluster server.
|
|
1554
|
+
*
|
|
1555
|
+
* @param {number} measuredValue - The measured value of the relative humidity x 100.
|
|
1556
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1557
|
+
*/
|
|
980
1558
|
createDefaultRelativeHumidityMeasurementClusterServer(measuredValue = 0) {
|
|
981
1559
|
this.behaviors.require(RelativeHumidityMeasurementServer, getDefaultRelativeHumidityMeasurementClusterServer(measuredValue));
|
|
982
1560
|
return this;
|
|
983
1561
|
}
|
|
1562
|
+
/**
|
|
1563
|
+
* Creates a default PressureMeasurement cluster server.
|
|
1564
|
+
*
|
|
1565
|
+
* @param {number} measuredValue - The measured value for the pressure.
|
|
1566
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1567
|
+
*/
|
|
984
1568
|
createDefaultPressureMeasurementClusterServer(measuredValue = 1000) {
|
|
985
1569
|
this.behaviors.require(PressureMeasurementServer, getDefaultPressureMeasurementClusterServer(measuredValue));
|
|
986
1570
|
return this;
|
|
987
1571
|
}
|
|
1572
|
+
/**
|
|
1573
|
+
* Creates a default IlluminanceMeasurement cluster server.
|
|
1574
|
+
*
|
|
1575
|
+
* @param {number} measuredValue - The measured value of illuminance.
|
|
1576
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1577
|
+
*
|
|
1578
|
+
* @remarks
|
|
1579
|
+
* Lux to matter = Math.round(Math.max(Math.min(10000 * Math.log10(lux), 0xfffe), 0))
|
|
1580
|
+
* Matter to Lux = Math.round(Math.max(Math.pow(10, value / 10000), 0))
|
|
1581
|
+
*/
|
|
988
1582
|
createDefaultIlluminanceMeasurementClusterServer(measuredValue = 0) {
|
|
989
1583
|
this.behaviors.require(IlluminanceMeasurementServer, getDefaultIlluminanceMeasurementClusterServer(measuredValue));
|
|
990
1584
|
return this;
|
|
991
1585
|
}
|
|
1586
|
+
/**
|
|
1587
|
+
* Creates a default FlowMeasurement cluster server.
|
|
1588
|
+
*
|
|
1589
|
+
* @param {number} measuredValue - The measured value of the flow in 10 x m/h.
|
|
1590
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1591
|
+
*/
|
|
992
1592
|
createDefaultFlowMeasurementClusterServer(measuredValue = 0) {
|
|
993
1593
|
this.behaviors.require(FlowMeasurementServer, getDefaultFlowMeasurementClusterServer(measuredValue));
|
|
994
1594
|
return this;
|
|
995
1595
|
}
|
|
1596
|
+
/**
|
|
1597
|
+
* Creates a default OccupancySensing cluster server.
|
|
1598
|
+
*
|
|
1599
|
+
* @param {boolean} occupied - A boolean indicating whether the occupancy is occupied or not. Default is false.
|
|
1600
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1601
|
+
*/
|
|
996
1602
|
createDefaultOccupancySensingClusterServer(occupied = false) {
|
|
997
1603
|
this.behaviors.require(OccupancySensingServer, getDefaultOccupancySensingClusterServer(occupied));
|
|
998
1604
|
return this;
|
|
999
1605
|
}
|
|
1606
|
+
/**
|
|
1607
|
+
* Creates a default AirQuality cluster server.
|
|
1608
|
+
*
|
|
1609
|
+
* @param {AirQuality.AirQualityEnum} airQuality The air quality level. Defaults to `AirQuality.AirQualityType.Unknown`.
|
|
1610
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1611
|
+
*/
|
|
1000
1612
|
createDefaultAirQualityClusterServer(airQuality = AirQuality.AirQualityEnum.Unknown) {
|
|
1001
1613
|
this.behaviors.require(AirQualityServer.with(AirQuality.Feature.Fair, AirQuality.Feature.Moderate, AirQuality.Feature.VeryPoor, AirQuality.Feature.ExtremelyPoor), {
|
|
1002
1614
|
airQuality,
|
|
1003
1615
|
});
|
|
1004
1616
|
return this;
|
|
1005
1617
|
}
|
|
1618
|
+
/**
|
|
1619
|
+
* Creates a default TotalVolatileOrganicCompoundsConcentrationMeasurement cluster server.
|
|
1620
|
+
*
|
|
1621
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
1622
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
|
|
1623
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
|
|
1624
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1625
|
+
*/
|
|
1006
1626
|
createDefaultTvocMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1007
1627
|
this.behaviors.require(TotalVolatileOrganicCompoundsConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
|
|
1008
1628
|
measuredValue,
|
|
@@ -1014,6 +1634,13 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1014
1634
|
});
|
|
1015
1635
|
return this;
|
|
1016
1636
|
}
|
|
1637
|
+
/**
|
|
1638
|
+
* Create a default CarbonMonoxideConcentrationMeasurement cluster server.
|
|
1639
|
+
*
|
|
1640
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
1641
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
|
|
1642
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
|
|
1643
|
+
*/
|
|
1017
1644
|
createDefaultCarbonMonoxideConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1018
1645
|
this.behaviors.require(CarbonMonoxideConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
|
|
1019
1646
|
measuredValue,
|
|
@@ -1025,6 +1652,13 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1025
1652
|
});
|
|
1026
1653
|
return this;
|
|
1027
1654
|
}
|
|
1655
|
+
/**
|
|
1656
|
+
* Create a default CarbonDioxideConcentrationMeasurement cluster server.
|
|
1657
|
+
*
|
|
1658
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
1659
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
|
|
1660
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
|
|
1661
|
+
*/
|
|
1028
1662
|
createDefaultCarbonDioxideConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1029
1663
|
this.behaviors.require(CarbonDioxideConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
|
|
1030
1664
|
measuredValue,
|
|
@@ -1036,6 +1670,13 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1036
1670
|
});
|
|
1037
1671
|
return this;
|
|
1038
1672
|
}
|
|
1673
|
+
/**
|
|
1674
|
+
* Create a default FormaldehydeConcentrationMeasurement cluster server.
|
|
1675
|
+
*
|
|
1676
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
1677
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
|
|
1678
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
|
|
1679
|
+
*/
|
|
1039
1680
|
createDefaultFormaldehydeConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1040
1681
|
this.behaviors.require(FormaldehydeConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
|
|
1041
1682
|
measuredValue,
|
|
@@ -1047,6 +1688,13 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1047
1688
|
});
|
|
1048
1689
|
return this;
|
|
1049
1690
|
}
|
|
1691
|
+
/**
|
|
1692
|
+
* Create a default Pm1ConcentrationMeasurement cluster server.
|
|
1693
|
+
*
|
|
1694
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
1695
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
|
|
1696
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
|
|
1697
|
+
*/
|
|
1050
1698
|
createDefaultPm1ConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1051
1699
|
this.behaviors.require(Pm1ConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
|
|
1052
1700
|
measuredValue,
|
|
@@ -1058,6 +1706,13 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1058
1706
|
});
|
|
1059
1707
|
return this;
|
|
1060
1708
|
}
|
|
1709
|
+
/**
|
|
1710
|
+
* Create a default Pm25ConcentrationMeasurement cluster server.
|
|
1711
|
+
*
|
|
1712
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
1713
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
|
|
1714
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
|
|
1715
|
+
*/
|
|
1061
1716
|
createDefaultPm25ConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1062
1717
|
this.behaviors.require(Pm25ConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
|
|
1063
1718
|
measuredValue,
|
|
@@ -1069,6 +1724,13 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1069
1724
|
});
|
|
1070
1725
|
return this;
|
|
1071
1726
|
}
|
|
1727
|
+
/**
|
|
1728
|
+
* Create a default Pm10ConcentrationMeasurement cluster server.
|
|
1729
|
+
*
|
|
1730
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
1731
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
|
|
1732
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
|
|
1733
|
+
*/
|
|
1072
1734
|
createDefaultPm10ConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1073
1735
|
this.behaviors.require(Pm10ConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
|
|
1074
1736
|
measuredValue,
|
|
@@ -1080,6 +1742,13 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1080
1742
|
});
|
|
1081
1743
|
return this;
|
|
1082
1744
|
}
|
|
1745
|
+
/**
|
|
1746
|
+
* Create a default OzoneConcentrationMeasurement cluster server.
|
|
1747
|
+
*
|
|
1748
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
1749
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ugm3).
|
|
1750
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
|
|
1751
|
+
*/
|
|
1083
1752
|
createDefaultOzoneConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ugm3, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1084
1753
|
this.behaviors.require(OzoneConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
|
|
1085
1754
|
measuredValue,
|
|
@@ -1091,6 +1760,13 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1091
1760
|
});
|
|
1092
1761
|
return this;
|
|
1093
1762
|
}
|
|
1763
|
+
/**
|
|
1764
|
+
* Create a default RadonConcentrationMeasurement cluster server.
|
|
1765
|
+
*
|
|
1766
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
1767
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
|
|
1768
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
|
|
1769
|
+
*/
|
|
1094
1770
|
createDefaultRadonConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1095
1771
|
this.behaviors.require(RadonConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
|
|
1096
1772
|
measuredValue,
|
|
@@ -1102,6 +1778,13 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1102
1778
|
});
|
|
1103
1779
|
return this;
|
|
1104
1780
|
}
|
|
1781
|
+
/**
|
|
1782
|
+
* Create a default NitrogenDioxideConcentrationMeasurement cluster server.
|
|
1783
|
+
*
|
|
1784
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
1785
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ugm3).
|
|
1786
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
|
|
1787
|
+
*/
|
|
1105
1788
|
createDefaultNitrogenDioxideConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ugm3, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1106
1789
|
this.behaviors.require(NitrogenDioxideConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
|
|
1107
1790
|
measuredValue,
|
|
@@ -1114,3 +1797,4 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1114
1797
|
return this;
|
|
1115
1798
|
}
|
|
1116
1799
|
}
|
|
1800
|
+
//# sourceMappingURL=matterbridgeEndpoint.js.map
|