matterbridge 3.0.3-dev-20250520-e6e7257 → 3.0.3
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 +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 -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 +241 -0
- package/dist/frontend.d.ts.map +1 -0
- package/dist/frontend.js +333 -15
- package/dist/frontend.js.map +1 -0
- package/dist/helpers.d.ts +47 -0
- package/dist/helpers.d.ts.map +1 -0
- package/dist/helpers.js +50 -0
- package/dist/helpers.js.map +1 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -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 +445 -0
- package/dist/matterbridge.d.ts.map +1 -0
- package/dist/matterbridge.js +747 -47
- package/dist/matterbridge.js.map +1 -0
- package/dist/matterbridgeAccessoryPlatform.d.ts +40 -0
- package/dist/matterbridgeAccessoryPlatform.d.ts.map +1 -0
- package/dist/matterbridgeAccessoryPlatform.js +34 -0
- package/dist/matterbridgeAccessoryPlatform.js.map +1 -0
- package/dist/matterbridgeBehaviors.d.ts +1201 -0
- package/dist/matterbridgeBehaviors.d.ts.map +1 -0
- package/dist/matterbridgeBehaviors.js +60 -4
- package/dist/matterbridgeBehaviors.js.map +1 -0
- package/dist/matterbridgeDeviceTypes.d.ts +629 -0
- package/dist/matterbridgeDeviceTypes.d.ts.map +1 -0
- package/dist/matterbridgeDeviceTypes.js +563 -15
- package/dist/matterbridgeDeviceTypes.js.map +1 -0
- package/dist/matterbridgeDynamicPlatform.d.ts +40 -0
- package/dist/matterbridgeDynamicPlatform.d.ts.map +1 -0
- package/dist/matterbridgeDynamicPlatform.js +34 -0
- package/dist/matterbridgeDynamicPlatform.js.map +1 -0
- package/dist/matterbridgeEndpoint.d.ts +967 -0
- package/dist/matterbridgeEndpoint.d.ts.map +1 -0
- package/dist/matterbridgeEndpoint.js +807 -11
- package/dist/matterbridgeEndpoint.js.map +1 -0
- package/dist/matterbridgeEndpointHelpers.d.ts +2728 -0
- package/dist/matterbridgeEndpointHelpers.d.ts.map +1 -0
- package/dist/matterbridgeEndpointHelpers.js +149 -10
- package/dist/matterbridgeEndpointHelpers.js.map +1 -0
- package/dist/matterbridgePlatform.d.ts +294 -0
- package/dist/matterbridgePlatform.d.ts.map +1 -0
- package/dist/matterbridgePlatform.js +225 -7
- package/dist/matterbridgePlatform.js.map +1 -0
- package/dist/matterbridgeTypes.d.ts +188 -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 +273 -0
- package/dist/pluginManager.d.ts.map +1 -0
- package/dist/pluginManager.js +264 -3
- package/dist/pluginManager.js.map +1 -0
- package/dist/roboticVacuumCleaner.d.ts +82 -0
- package/dist/roboticVacuumCleaner.d.ts.map +1 -0
- package/dist/roboticVacuumCleaner.js +78 -3
- package/dist/roboticVacuumCleaner.js.map +1 -0
- package/dist/shelly.d.ts +153 -0
- package/dist/shelly.d.ts.map +1 -0
- package/dist/shelly.js +155 -7
- 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 +58 -0
- package/dist/update.d.ts.map +1 -0
- package/dist/update.js +53 -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/commandLine.d.ts +58 -0
- package/dist/utils/commandLine.d.ts.map +1 -0
- package/dist/utils/commandLine.js +53 -0
- package/dist/utils/commandLine.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 +38 -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 +71 -1
- package/dist/utils/deepEqual.js.map +1 -0
- package/dist/utils/export.d.ts +11 -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/hex.d.ts +48 -0
- package/dist/utils/hex.d.ts.map +1 -0
- package/dist/utils/hex.js +57 -0
- package/dist/utils/hex.js.map +1 -0
- package/dist/utils/isvalid.d.ts +102 -0
- package/dist/utils/isvalid.d.ts.map +1 -0
- package/dist/utils/isvalid.js +100 -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 +76 -5
- package/dist/utils/network.js.map +1 -0
- package/dist/utils/wait.d.ts +52 -0
- package/dist/utils/wait.d.ts.map +1 -0
- package/dist/utils/wait.js +58 -9
- package/dist/utils/wait.js.map +1 -0
- package/dist/waterHeater.d.ts +75 -0
- package/dist/waterHeater.d.ts.map +1 -0
- package/dist/waterHeater.js +52 -0
- package/dist/waterHeater.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, isValidString } from './utils/export.js';
|
|
4
28
|
import { MatterbridgeServer, MatterbridgeServerDevice, MatterbridgeIdentifyServer, MatterbridgeOnOffServer, MatterbridgeLevelControlServer, MatterbridgeColorControlServer, MatterbridgeWindowCoveringServer, MatterbridgeThermostatServer, MatterbridgeFanControlServer, MatterbridgeDoorLockServer, MatterbridgeModeSelectServer, MatterbridgeValveConfigurationAndControlServer, MatterbridgeSmokeCoAlarmServer, MatterbridgeBooleanStateConfigurationServer, MatterbridgeSwitchServer, MatterbridgeOperationalStateServer, } from './matterbridgeBehaviors.js';
|
|
5
29
|
import { addClusterServers, addFixedLabel, addOptionalClusterServers, addRequiredClusterServers, addUserLabel, capitalizeFirstLetter, createUniqueId, getBehavior, getBehaviourTypesFromClusterClientIds, getBehaviourTypesFromClusterServerIds, getDefaultOperationalStateClusterServer, getDefaultFlowMeasurementClusterServer, getDefaultIlluminanceMeasurementClusterServer, getDefaultPressureMeasurementClusterServer, getDefaultRelativeHumidityMeasurementClusterServer, getDefaultTemperatureMeasurementClusterServer, getDefaultOccupancySensingClusterServer, lowercaseFirstLetter, updateAttribute, getClusterId, getAttributeId, setAttribute, getAttribute, checkNotLatinCharacters, generateUniqueId, subscribeAttribute, invokeBehaviorCommand, } from './matterbridgeEndpointHelpers.js';
|
|
30
|
+
// @matter
|
|
6
31
|
import { Endpoint, Lifecycle, MutableEndpoint, NamedHandler, SupportedBehaviors, UINT16_MAX, UINT32_MAX, 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';
|
|
@@ -29,6 +55,7 @@ import { ConcentrationMeasurement } from '@matter/main/clusters/concentration-me
|
|
|
29
55
|
import { OccupancySensing } from '@matter/main/clusters/occupancy-sensing';
|
|
30
56
|
import { ThermostatUserInterfaceConfiguration } from '@matter/main/clusters/thermostat-user-interface-configuration';
|
|
31
57
|
import { OperationalState } from '@matter/main/clusters/operational-state';
|
|
58
|
+
// @matter behaviors
|
|
32
59
|
import { DescriptorServer } from '@matter/main/behaviors/descriptor';
|
|
33
60
|
import { PowerSourceServer } from '@matter/main/behaviors/power-source';
|
|
34
61
|
import { BridgedDeviceBasicInformationServer } from '@matter/main/behaviors/bridged-device-basic-information';
|
|
@@ -64,7 +91,7 @@ import { ActivatedCarbonFilterMonitoringServer } from '@matter/main/behaviors/ac
|
|
|
64
91
|
import { ThermostatUserInterfaceConfigurationServer } from '@matter/main/behaviors/thermostat-user-interface-configuration';
|
|
65
92
|
export class MatterbridgeEndpoint extends Endpoint {
|
|
66
93
|
static bridgeMode = '';
|
|
67
|
-
static logLevel = "info"
|
|
94
|
+
static logLevel = "info" /* LogLevel.INFO */;
|
|
68
95
|
log;
|
|
69
96
|
plugin = undefined;
|
|
70
97
|
configUrl = undefined;
|
|
@@ -80,14 +107,25 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
80
107
|
hardwareVersion = undefined;
|
|
81
108
|
hardwareVersionString = undefined;
|
|
82
109
|
productUrl = 'https://www.npmjs.com/package/matterbridge';
|
|
110
|
+
// The first device type of the endpoint
|
|
83
111
|
name = undefined;
|
|
84
112
|
deviceType;
|
|
85
113
|
uniqueStorageKey = undefined;
|
|
86
114
|
tagList = undefined;
|
|
115
|
+
// Maps matter deviceTypes
|
|
87
116
|
deviceTypes = new Map();
|
|
117
|
+
// Command handler
|
|
88
118
|
commandHandler = new NamedHandler();
|
|
119
|
+
/**
|
|
120
|
+
* Represents a MatterbridgeEndpoint.
|
|
121
|
+
* @constructor
|
|
122
|
+
* @param {DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>} definition - The DeviceTypeDefinition(s) of the endpoint.
|
|
123
|
+
* @param {MatterbridgeEndpointOptions} [options={}] - The options for the device.
|
|
124
|
+
* @param {boolean} [debug=false] - Debug flag.
|
|
125
|
+
*/
|
|
89
126
|
constructor(definition, options = {}, debug = false) {
|
|
90
127
|
let deviceTypeList = [];
|
|
128
|
+
// Get the first DeviceTypeDefinition
|
|
91
129
|
let firstDefinition;
|
|
92
130
|
if (Array.isArray(definition)) {
|
|
93
131
|
firstDefinition = definition[0];
|
|
@@ -100,6 +138,7 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
100
138
|
firstDefinition = definition;
|
|
101
139
|
deviceTypeList = [{ deviceType: firstDefinition.code, revision: firstDefinition.revision }];
|
|
102
140
|
}
|
|
141
|
+
// Convert the first DeviceTypeDefinition to an EndpointType.Options
|
|
103
142
|
const deviceTypeDefinitionV8 = {
|
|
104
143
|
name: firstDefinition.name.replace('-', '_'),
|
|
105
144
|
deviceType: firstDefinition.code,
|
|
@@ -118,9 +157,11 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
118
157
|
behaviors: options.tagList ? SupportedBehaviors(DescriptorServer.with(Descriptor.Feature.TagList)) : {},
|
|
119
158
|
};
|
|
120
159
|
const endpointV8 = MutableEndpoint(deviceTypeDefinitionV8);
|
|
160
|
+
// Check if the uniqueStorageKey is valid
|
|
121
161
|
if (options.uniqueStorageKey && checkNotLatinCharacters(options.uniqueStorageKey)) {
|
|
122
162
|
options.uniqueStorageKey = generateUniqueId(options.uniqueStorageKey);
|
|
123
163
|
}
|
|
164
|
+
// Convert the options to an Endpoint.Options
|
|
124
165
|
const optionsV8 = {
|
|
125
166
|
id: options.uniqueStorageKey?.replace(/[ .]/g, ''),
|
|
126
167
|
number: options.endpointId,
|
|
@@ -138,17 +179,41 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
138
179
|
}
|
|
139
180
|
else
|
|
140
181
|
this.deviceTypes.set(firstDefinition.code, firstDefinition);
|
|
141
|
-
|
|
182
|
+
// console.log('MatterbridgeEndpoint.option', options);
|
|
183
|
+
// console.log('MatterbridgeEndpoint.endpointV8', endpointV8);
|
|
184
|
+
// console.log('MatterbridgeEndpoint.optionsV8', optionsV8);
|
|
185
|
+
// Create the logger
|
|
186
|
+
this.log = new AnsiLogger({ logName: options.uniqueStorageKey ?? 'MatterbridgeEndpoint', logTimestampFormat: 4 /* TimestampFormat.TIME_MILLIS */, logLevel: debug === true ? "debug" /* LogLevel.DEBUG */ : MatterbridgeEndpoint.logLevel });
|
|
142
187
|
this.log.debug(`${YELLOW}new${db} MatterbridgeEndpoint: ${zb}${'0x' + firstDefinition.code.toString(16).padStart(4, '0')}${db}-${zb}${firstDefinition.name}${db} ` +
|
|
143
188
|
`id: ${CYAN}${options.uniqueStorageKey}${db} number: ${CYAN}${options.endpointId}${db} taglist: ${CYAN}${options.tagList ? debugStringify(options.tagList) : 'undefined'}${db}`);
|
|
189
|
+
// Add MatterbridgeBehavior with MatterbridgeBehaviorDevice
|
|
144
190
|
this.behaviors.require(MatterbridgeServer, { deviceCommand: new MatterbridgeServerDevice(this.log, this.commandHandler, undefined) });
|
|
145
191
|
}
|
|
192
|
+
/**
|
|
193
|
+
* Loads an instance of the MatterbridgeEndpoint class.
|
|
194
|
+
*
|
|
195
|
+
* @param {DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>} definition - The DeviceTypeDefinition(s) of the device.
|
|
196
|
+
* @param {MatterbridgeEndpointOptions} [options={}] - The options for the device.
|
|
197
|
+
* @param {boolean} [debug=false] - Debug flag.
|
|
198
|
+
* @returns {Promise<MatterbridgeEndpoint>} MatterbridgeEndpoint instance.
|
|
199
|
+
*/
|
|
146
200
|
static async loadInstance(definition, options = {}, debug = false) {
|
|
147
201
|
return new MatterbridgeEndpoint(definition, options, debug);
|
|
148
202
|
}
|
|
203
|
+
/**
|
|
204
|
+
* Get all the device types of this endpoint.
|
|
205
|
+
*
|
|
206
|
+
* @returns {DeviceTypeDefinition[]} The device types of this endpoint.
|
|
207
|
+
*/
|
|
149
208
|
getDeviceTypes() {
|
|
150
209
|
return Array.from(this.deviceTypes.values());
|
|
151
210
|
}
|
|
211
|
+
/**
|
|
212
|
+
* Checks if the provided cluster server is supported by this endpoint.
|
|
213
|
+
*
|
|
214
|
+
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to check.
|
|
215
|
+
* @returns {boolean} True if the cluster server is supported, false otherwise.
|
|
216
|
+
*/
|
|
152
217
|
hasClusterServer(cluster) {
|
|
153
218
|
const behavior = getBehavior(this, cluster);
|
|
154
219
|
if (behavior)
|
|
@@ -156,6 +221,13 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
156
221
|
else
|
|
157
222
|
return false;
|
|
158
223
|
}
|
|
224
|
+
/**
|
|
225
|
+
* Checks if the provided attribute server is supported for a given cluster of this endpoint.
|
|
226
|
+
*
|
|
227
|
+
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to check.
|
|
228
|
+
* @param {string} attribute - The attribute name to check.
|
|
229
|
+
* @returns {boolean} True if the attribute server is supported, false otherwise.
|
|
230
|
+
*/
|
|
159
231
|
hasAttributeServer(cluster, attribute) {
|
|
160
232
|
const behavior = getBehavior(this, cluster);
|
|
161
233
|
if (!behavior || !this.behaviors.supported[behavior.id])
|
|
@@ -164,75 +236,195 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
164
236
|
const defaults = this.behaviors.defaultsFor(behavior);
|
|
165
237
|
return lowercaseFirstLetter(attribute) in options || lowercaseFirstLetter(attribute) in defaults;
|
|
166
238
|
}
|
|
239
|
+
/**
|
|
240
|
+
* Retrieves the initial options for the provided cluster server.
|
|
241
|
+
*
|
|
242
|
+
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to get options for.
|
|
243
|
+
* @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.
|
|
244
|
+
*/
|
|
167
245
|
getClusterServerOptions(cluster) {
|
|
168
246
|
const behavior = getBehavior(this, cluster);
|
|
169
247
|
if (!behavior)
|
|
170
248
|
return undefined;
|
|
171
249
|
return this.behaviors.optionsFor(behavior);
|
|
172
250
|
}
|
|
251
|
+
/**
|
|
252
|
+
* Retrieves the value of the provided attribute from the given cluster.
|
|
253
|
+
*
|
|
254
|
+
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to retrieve the attribute from.
|
|
255
|
+
* @param {string} attribute - The name of the attribute to retrieve.
|
|
256
|
+
* @param {AnsiLogger} [log] - Optional logger for error and info messages.
|
|
257
|
+
* @returns {any} The value of the attribute, or undefined if the attribute is not found.
|
|
258
|
+
*/
|
|
259
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
173
260
|
getAttribute(cluster, attribute, log) {
|
|
174
261
|
return getAttribute(this, cluster, attribute, log);
|
|
175
262
|
}
|
|
263
|
+
/**
|
|
264
|
+
* Sets the value of an attribute on a cluster server.
|
|
265
|
+
*
|
|
266
|
+
* @param {Behavior.Type | ClusterType | ClusterId | string} clusterId - The ID of the cluster.
|
|
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 errors and information.
|
|
270
|
+
* @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the attribute was successfully set.
|
|
271
|
+
*/
|
|
176
272
|
async setAttribute(clusterId, attribute, value, log) {
|
|
177
273
|
return await setAttribute(this, clusterId, attribute, value, log);
|
|
178
274
|
}
|
|
275
|
+
/**
|
|
276
|
+
* Update the value of an attribute on a cluster server only if the value is different.
|
|
277
|
+
*
|
|
278
|
+
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to set the attribute on.
|
|
279
|
+
* @param {string} attribute - The name of the attribute.
|
|
280
|
+
* @param {boolean | number | bigint | string | object | null} value - The value to set for the attribute.
|
|
281
|
+
* @param {AnsiLogger} [log] - (Optional) The logger to use for logging the update. Errors are logged to the endpoint logger.
|
|
282
|
+
* @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the attribute was successfully set.
|
|
283
|
+
*/
|
|
179
284
|
async updateAttribute(cluster, attribute, value, log) {
|
|
180
285
|
return await updateAttribute(this, cluster, attribute, value, log);
|
|
181
286
|
}
|
|
287
|
+
/**
|
|
288
|
+
* Subscribes to the provided attribute on a cluster.
|
|
289
|
+
*
|
|
290
|
+
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to subscribe the attribute to.
|
|
291
|
+
* @param {string} attribute - The name of the attribute to subscribe to.
|
|
292
|
+
* @param {(newValue: any, oldValue: any, context?: any) => void} listener - A callback function that will be called when the attribute value changes.
|
|
293
|
+
* @param {AnsiLogger} [log] - Optional logger for logging errors and information.
|
|
294
|
+
* @returns {Promise<boolean>} - A boolean indicating whether the subscription was successful.
|
|
295
|
+
*/
|
|
296
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
182
297
|
async subscribeAttribute(cluster, attribute, listener, log) {
|
|
183
298
|
return await subscribeAttribute(this, cluster, attribute, listener, log);
|
|
184
299
|
}
|
|
300
|
+
/**
|
|
301
|
+
* Triggers an event on the specified cluster.
|
|
302
|
+
*
|
|
303
|
+
* @param {ClusterId} clusterId - The ID of the cluster.
|
|
304
|
+
* @param {string} event - The name of the event to trigger.
|
|
305
|
+
* @param {Record<string, boolean | number | bigint | string | object | undefined | null>} payload - The payload to pass to the event.
|
|
306
|
+
* @param {AnsiLogger} [log] - Optional logger for logging information.
|
|
307
|
+
* @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the event was successfully triggered.
|
|
308
|
+
*/
|
|
185
309
|
async triggerEvent(clusterId, event, payload, log) {
|
|
186
310
|
const clusterName = lowercaseFirstLetter(getClusterNameById(clusterId));
|
|
187
311
|
if (this.construction.status !== Lifecycle.Status.Active) {
|
|
188
312
|
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`);
|
|
189
313
|
return false;
|
|
190
314
|
}
|
|
315
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
191
316
|
const events = this.events;
|
|
192
317
|
if (!(clusterName in events) || !(event in events[clusterName])) {
|
|
193
318
|
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}`);
|
|
194
319
|
return false;
|
|
195
320
|
}
|
|
321
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
322
|
+
// @ts-ignore
|
|
196
323
|
await this.act((agent) => agent[clusterName].events[event].emit(payload, agent.context));
|
|
197
324
|
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} `);
|
|
198
325
|
return true;
|
|
199
326
|
}
|
|
327
|
+
/**
|
|
328
|
+
* Adds cluster servers from the provided server list.
|
|
329
|
+
*
|
|
330
|
+
* @param {ClusterId[]} serverList - The list of cluster IDs to add.
|
|
331
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
332
|
+
*/
|
|
200
333
|
addClusterServers(serverList) {
|
|
201
334
|
addClusterServers(this, serverList);
|
|
202
335
|
return this;
|
|
203
336
|
}
|
|
337
|
+
/**
|
|
338
|
+
* Adds a fixed label to the FixedLabel cluster. If the cluster server is not present, it will be added.
|
|
339
|
+
*
|
|
340
|
+
* @param {string} label - The label to add.
|
|
341
|
+
* @param {string} value - The value of the label.
|
|
342
|
+
* @returns {Promise<this>} The current MatterbridgeEndpoint instance for chaining.
|
|
343
|
+
*/
|
|
204
344
|
async addFixedLabel(label, value) {
|
|
205
345
|
await addFixedLabel(this, label, value);
|
|
206
346
|
return this;
|
|
207
347
|
}
|
|
348
|
+
/**
|
|
349
|
+
* Adds a user label to the UserLabel cluster. If the cluster server is not present, it will be added.
|
|
350
|
+
*
|
|
351
|
+
* @param {string} label - The label to add.
|
|
352
|
+
* @param {string} value - The value of the label.
|
|
353
|
+
* @returns {Promise<this>} The current MatterbridgeEndpoint instance for chaining.
|
|
354
|
+
*/
|
|
208
355
|
async addUserLabel(label, value) {
|
|
209
356
|
await addUserLabel(this, label, value);
|
|
210
357
|
return this;
|
|
211
358
|
}
|
|
359
|
+
/**
|
|
360
|
+
* Adds a command handler for the specified command.
|
|
361
|
+
*
|
|
362
|
+
* @param {keyof MatterbridgeEndpointCommands} command - The command to add the handler for.
|
|
363
|
+
* @param {HandlerFunction} handler - The handler function to execute when the command is received.
|
|
364
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
365
|
+
*/
|
|
212
366
|
addCommandHandler(command, handler) {
|
|
213
367
|
this.commandHandler.addHandler(command, handler);
|
|
214
368
|
return this;
|
|
215
369
|
}
|
|
370
|
+
/**
|
|
371
|
+
* Execute the command handler for the specified command. Mainly used in Jest tests.
|
|
372
|
+
*
|
|
373
|
+
* @param {keyof MatterbridgeEndpointCommands} command - The command to execute.
|
|
374
|
+
* @param {Record<string, boolean | number | bigint | string | object | null>} [request] - The optional request to pass to the handler function.
|
|
375
|
+
*/
|
|
216
376
|
async executeCommandHandler(command, request) {
|
|
217
377
|
await this.commandHandler.executeHandler(command, { request });
|
|
218
378
|
}
|
|
379
|
+
/**
|
|
380
|
+
* Invokes a behavior command on the specified cluster. Mainly used in Jest tests.
|
|
381
|
+
*
|
|
382
|
+
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to invoke the command on.
|
|
383
|
+
* @param {string} command - The command to invoke.
|
|
384
|
+
* @param {Record<string, boolean | number | bigint | string | object | null>} [params] - The optional parameters to pass to the command.
|
|
385
|
+
*/
|
|
219
386
|
async invokeBehaviorCommand(cluster, command, params) {
|
|
220
387
|
await invokeBehaviorCommand(this, cluster, command, params);
|
|
221
388
|
}
|
|
389
|
+
/**
|
|
390
|
+
* Adds the required cluster servers (only if they are not present) for the device types of the specified endpoint.
|
|
391
|
+
*
|
|
392
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
393
|
+
*/
|
|
222
394
|
addRequiredClusterServers() {
|
|
223
395
|
addRequiredClusterServers(this);
|
|
224
396
|
return this;
|
|
225
397
|
}
|
|
398
|
+
/**
|
|
399
|
+
* Adds the optional cluster servers (only if they are not present) for the device types of the specified endpoint.
|
|
400
|
+
*
|
|
401
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
402
|
+
*/
|
|
226
403
|
addOptionalClusterServers() {
|
|
227
404
|
addOptionalClusterServers(this);
|
|
228
405
|
return this;
|
|
229
406
|
}
|
|
407
|
+
/**
|
|
408
|
+
* Retrieves all cluster servers.
|
|
409
|
+
*
|
|
410
|
+
* @returns {Behavior.Type[]} An array of all cluster servers.
|
|
411
|
+
*/
|
|
230
412
|
getAllClusterServers() {
|
|
231
413
|
return Object.values(this.behaviors.supported);
|
|
232
414
|
}
|
|
415
|
+
/**
|
|
416
|
+
* Retrieves the names of all cluster servers.
|
|
417
|
+
*
|
|
418
|
+
* @returns {string[]} An array of all cluster server names.
|
|
419
|
+
*/
|
|
233
420
|
getAllClusterServerNames() {
|
|
234
421
|
return Object.keys(this.behaviors.supported);
|
|
235
422
|
}
|
|
423
|
+
/**
|
|
424
|
+
* Iterates over each attribute of each cluster server of the device state and calls the provided callback function.
|
|
425
|
+
*
|
|
426
|
+
* @param {Function} callback - The callback function to call with the cluster name, cluster id, attribute name, attribute id and attribute value.
|
|
427
|
+
*/
|
|
236
428
|
forEachAttribute(callback) {
|
|
237
429
|
if (!this.lifecycle.isReady || this.construction.status !== Lifecycle.Status.Active)
|
|
238
430
|
return;
|
|
@@ -240,16 +432,34 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
240
432
|
for (const [attributeName, attributeValue] of Object.entries(clusterAttributes)) {
|
|
241
433
|
const clusterId = getClusterId(this, clusterName);
|
|
242
434
|
if (clusterId === undefined) {
|
|
435
|
+
// this.log.error(`forEachAttribute error: cluster ${clusterName} not found`);
|
|
243
436
|
continue;
|
|
244
437
|
}
|
|
245
438
|
const attributeId = getAttributeId(this, clusterName, attributeName);
|
|
246
439
|
if (attributeId === undefined) {
|
|
440
|
+
// this.log.error(`forEachAttribute error: attribute ${clusterName}.${attributeName} not found`);
|
|
247
441
|
continue;
|
|
248
442
|
}
|
|
249
443
|
callback(clusterName, clusterId, attributeName, attributeId, attributeValue);
|
|
250
444
|
}
|
|
251
445
|
}
|
|
252
446
|
}
|
|
447
|
+
/**
|
|
448
|
+
* Adds a child endpoint with the specified device types and options.
|
|
449
|
+
* If the child endpoint is not already present, it will be created and added.
|
|
450
|
+
* If the child endpoint is already present, the existing child endpoint will be returned.
|
|
451
|
+
*
|
|
452
|
+
* @param {string} endpointName - The name of the new endpoint to add.
|
|
453
|
+
* @param {DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>} definition - The device types to add.
|
|
454
|
+
* @param {MatterbridgeEndpointOptions} [options={}] - The options for the endpoint.
|
|
455
|
+
* @param {boolean} [debug=false] - Whether to enable debug logging.
|
|
456
|
+
* @returns {MatterbridgeEndpoint} - The child endpoint that was found or added.
|
|
457
|
+
*
|
|
458
|
+
* @example
|
|
459
|
+
* ```typescript
|
|
460
|
+
* const endpoint = device.addChildDeviceType('Temperature', [temperatureSensor], { tagList: [{ mfgCode: null, namespaceId: LocationTag.Indoor.namespaceId, tag: LocationTag.Indoor.tag, label: null }] }, true);
|
|
461
|
+
* ```
|
|
462
|
+
*/
|
|
253
463
|
addChildDeviceType(endpointName, definition, options = {}, debug = false) {
|
|
254
464
|
this.log.debug(`addChildDeviceType: ${CYAN}${endpointName}${db}`);
|
|
255
465
|
let alreadyAdded = false;
|
|
@@ -289,6 +499,23 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
289
499
|
}
|
|
290
500
|
return child;
|
|
291
501
|
}
|
|
502
|
+
/**
|
|
503
|
+
* Adds a child endpoint with one or more device types with the required cluster servers and the specified cluster servers.
|
|
504
|
+
* If the child endpoint is not already present in the childEndpoints, it will be added.
|
|
505
|
+
* If the child endpoint is already present in the childEndpoints, the device types and cluster servers will be added to the existing child endpoint.
|
|
506
|
+
*
|
|
507
|
+
* @param {string} endpointName - The name of the new enpoint to add.
|
|
508
|
+
* @param {DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>} definition - The device types to add.
|
|
509
|
+
* @param {ClusterId[]} [serverList=[]] - The list of cluster IDs to include.
|
|
510
|
+
* @param {MatterbridgeEndpointOptions} [options={}] - The options for the device.
|
|
511
|
+
* @param {boolean} [debug=false] - Whether to enable debug logging.
|
|
512
|
+
* @returns {MatterbridgeEndpoint} - The child endpoint that was found or added.
|
|
513
|
+
*
|
|
514
|
+
* @example
|
|
515
|
+
* ```typescript
|
|
516
|
+
* const endpoint = device.addChildDeviceTypeWithClusterServer('Temperature', [temperatureSensor], [], { tagList: [{ mfgCode: null, namespaceId: LocationTag.Indoor.namespaceId, tag: LocationTag.Indoor.tag, label: null }] }, true);
|
|
517
|
+
* ```
|
|
518
|
+
*/
|
|
292
519
|
addChildDeviceTypeWithClusterServer(endpointName, definition, serverList = [], options = {}, debug = false) {
|
|
293
520
|
this.log.debug(`addChildDeviceTypeWithClusterServer: ${CYAN}${endpointName}${db}`);
|
|
294
521
|
let alreadyAdded = false;
|
|
@@ -351,15 +578,38 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
351
578
|
}
|
|
352
579
|
return child;
|
|
353
580
|
}
|
|
581
|
+
/**
|
|
582
|
+
* Retrieves a child endpoint by its name.
|
|
583
|
+
*
|
|
584
|
+
* @param {string} endpointName - The name of the endpoint to retrieve.
|
|
585
|
+
* @returns {Endpoint | undefined} The child endpoint with the specified name, or undefined if not found.
|
|
586
|
+
*/
|
|
354
587
|
getChildEndpointByName(endpointName) {
|
|
355
588
|
return this.parts.find((part) => part.id === endpointName);
|
|
356
589
|
}
|
|
590
|
+
/**
|
|
591
|
+
* Retrieves a child endpoint by its EndpointNumber.
|
|
592
|
+
*
|
|
593
|
+
* @param {EndpointNumber} endpointNumber - The EndpointNumber of the endpoint to retrieve.
|
|
594
|
+
* @returns {MatterbridgeEndpoint | undefined} The child endpoint with the specified EndpointNumber, or undefined if not found.
|
|
595
|
+
*/
|
|
357
596
|
getChildEndpoint(endpointNumber) {
|
|
358
597
|
return this.parts.find((part) => part.number === endpointNumber);
|
|
359
598
|
}
|
|
599
|
+
/**
|
|
600
|
+
* Get all the child endpoints of this endpoint.
|
|
601
|
+
*
|
|
602
|
+
* @returns {MatterbridgeEndpoint[]} The child endpoints.
|
|
603
|
+
*/
|
|
360
604
|
getChildEndpoints() {
|
|
361
605
|
return Array.from(this.parts);
|
|
362
606
|
}
|
|
607
|
+
/**
|
|
608
|
+
* Serializes the Matterbridge device into a serialized object.
|
|
609
|
+
*
|
|
610
|
+
* @param pluginName - The name of the plugin.
|
|
611
|
+
* @returns The serialized Matterbridge device object.
|
|
612
|
+
*/
|
|
363
613
|
static serialize(device) {
|
|
364
614
|
if (!device.serialNumber || !device.deviceName || !device.uniqueId)
|
|
365
615
|
return;
|
|
@@ -382,9 +632,15 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
382
632
|
serialized.clusterServersId.push(BridgedDeviceBasicInformation.Cluster.id);
|
|
383
633
|
if (behaviorName === 'powerSource')
|
|
384
634
|
serialized.clusterServersId.push(PowerSource.Cluster.id);
|
|
635
|
+
// serialized.clusterServersId.push(this.behaviors.supported[behaviorName]cluster.id);
|
|
385
636
|
});
|
|
386
637
|
return serialized;
|
|
387
638
|
}
|
|
639
|
+
/**
|
|
640
|
+
* Deserializes the device into a serialized object.
|
|
641
|
+
*
|
|
642
|
+
* @returns The deserialized MatterbridgeDevice.
|
|
643
|
+
*/
|
|
388
644
|
static deserialize(serializedDevice) {
|
|
389
645
|
const device = new MatterbridgeEndpoint(serializedDevice.deviceTypes, { uniqueStorageKey: serializedDevice.endpointName, endpointId: serializedDevice.endpoint }, false);
|
|
390
646
|
device.plugin = serializedDevice.pluginName;
|
|
@@ -400,9 +656,16 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
400
656
|
device.createDefaultBridgedDeviceBasicInformationClusterServer(serializedDevice.deviceName, serializedDevice.serialNumber, serializedDevice.vendorId ?? 0xfff1, serializedDevice.vendorName ?? 'Matterbridge', serializedDevice.productName ?? 'Matterbridge device');
|
|
401
657
|
else if (clusterId === PowerSource.Cluster.id)
|
|
402
658
|
device.createDefaultPowerSourceWiredClusterServer();
|
|
659
|
+
// else addClusterServerFromList(device, [clusterId]);
|
|
403
660
|
}
|
|
404
661
|
return device;
|
|
405
662
|
}
|
|
663
|
+
/**
|
|
664
|
+
* Creates a default power source wired cluster server.
|
|
665
|
+
*
|
|
666
|
+
* @param wiredCurrentType - The type of wired current (default: PowerSource.WiredCurrentType.Ac)
|
|
667
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
668
|
+
*/
|
|
406
669
|
createDefaultPowerSourceWiredClusterServer(wiredCurrentType = PowerSource.WiredCurrentType.Ac) {
|
|
407
670
|
this.behaviors.require(PowerSourceServer.with(PowerSource.Feature.Wired), {
|
|
408
671
|
wiredCurrentType,
|
|
@@ -413,6 +676,16 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
413
676
|
});
|
|
414
677
|
return this;
|
|
415
678
|
}
|
|
679
|
+
/**
|
|
680
|
+
* Creates a default power source replaceable battery cluster server.
|
|
681
|
+
*
|
|
682
|
+
* @param batPercentRemaining - The remaining battery percentage (default: 100).
|
|
683
|
+
* @param batChargeLevel - The battery charge level (default: PowerSource.BatChargeLevel.Ok).
|
|
684
|
+
* @param batVoltage - The battery voltage (default: 1500).
|
|
685
|
+
* @param batReplacementDescription - The battery replacement description (default: 'Battery type').
|
|
686
|
+
* @param batQuantity - The battery quantity (default: 1).
|
|
687
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
688
|
+
*/
|
|
416
689
|
createDefaultPowerSourceReplaceableBatteryClusterServer(batPercentRemaining = 100, batChargeLevel = PowerSource.BatChargeLevel.Ok, batVoltage = 1500, batReplacementDescription = 'Battery type', batQuantity = 1) {
|
|
417
690
|
this.behaviors.require(PowerSourceServer.with(PowerSource.Feature.Battery, PowerSource.Feature.Replaceable), {
|
|
418
691
|
status: PowerSource.PowerSourceStatus.Active,
|
|
@@ -430,6 +703,14 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
430
703
|
});
|
|
431
704
|
return this;
|
|
432
705
|
}
|
|
706
|
+
/**
|
|
707
|
+
* Creates a default power source rechargeable battery cluster server.
|
|
708
|
+
*
|
|
709
|
+
* @param batPercentRemaining - The remaining battery percentage (default: 100).
|
|
710
|
+
* @param batChargeLevel - The battery charge level (default: PowerSource.BatChargeLevel.Ok).
|
|
711
|
+
* @param batVoltage - The battery voltage (default: 1500).
|
|
712
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
713
|
+
*/
|
|
433
714
|
createDefaultPowerSourceRechargeableBatteryClusterServer(batPercentRemaining = 100, batChargeLevel = PowerSource.BatChargeLevel.Ok, batVoltage = 1500) {
|
|
434
715
|
this.behaviors.require(PowerSourceServer.with(PowerSource.Feature.Battery, PowerSource.Feature.Rechargeable), {
|
|
435
716
|
status: PowerSource.PowerSourceStatus.Active,
|
|
@@ -448,6 +729,21 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
448
729
|
});
|
|
449
730
|
return this;
|
|
450
731
|
}
|
|
732
|
+
/**
|
|
733
|
+
* Creates a default Basic Information Cluster Server for the server node.
|
|
734
|
+
*
|
|
735
|
+
* @param deviceName - The name of the device.
|
|
736
|
+
* @param serialNumber - The serial number of the device.
|
|
737
|
+
* @param vendorId - The vendor ID of the device.
|
|
738
|
+
* @param vendorName - The vendor name of the device.
|
|
739
|
+
* @param productId - The product ID of the device.
|
|
740
|
+
* @param productName - The product name of the device.
|
|
741
|
+
* @param softwareVersion - The software version of the device. Default is 1.
|
|
742
|
+
* @param softwareVersionString - The software version string of the device. Default is 'v.1.0.0'.
|
|
743
|
+
* @param hardwareVersion - The hardware version of the device. Default is 1.
|
|
744
|
+
* @param hardwareVersionString - The hardware version string of the device. Default is 'v.1.0.0'.
|
|
745
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
746
|
+
*/
|
|
451
747
|
createDefaultBasicInformationClusterServer(deviceName, serialNumber, vendorId, vendorName, productId, productName, softwareVersion = 1, softwareVersionString = '1.0.0', hardwareVersion = 1, hardwareVersionString = '1.0.0') {
|
|
452
748
|
this.log.logName = deviceName;
|
|
453
749
|
this.deviceName = deviceName;
|
|
@@ -471,6 +767,20 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
471
767
|
}
|
|
472
768
|
return this;
|
|
473
769
|
}
|
|
770
|
+
/**
|
|
771
|
+
* Creates a default BridgedDeviceBasicInformationClusterServer for the aggregator endpoints.
|
|
772
|
+
*
|
|
773
|
+
* @param deviceName - The name of the device.
|
|
774
|
+
* @param serialNumber - The serial number of the device.
|
|
775
|
+
* @param vendorId - The vendor ID of the device.
|
|
776
|
+
* @param vendorName - The name of the vendor.
|
|
777
|
+
* @param productName - The name of the product.
|
|
778
|
+
* @param softwareVersion - The software version of the device. Default is 1.
|
|
779
|
+
* @param softwareVersionString - The software version string of the device. Default is 'v.1.0.0'.
|
|
780
|
+
* @param hardwareVersion - The hardware version of the device. Default is 1.
|
|
781
|
+
* @param hardwareVersionString - The hardware version string of the device. Default is 'v.1.0.0'.
|
|
782
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
783
|
+
*/
|
|
474
784
|
createDefaultBridgedDeviceBasicInformationClusterServer(deviceName, serialNumber, vendorId, vendorName, productName, softwareVersion = 1, softwareVersionString = '1.0.0', hardwareVersion = 1, hardwareVersionString = '1.0.0') {
|
|
475
785
|
this.log.logName = deviceName;
|
|
476
786
|
this.deviceName = deviceName;
|
|
@@ -487,7 +797,7 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
487
797
|
this.behaviors.require(BridgedDeviceBasicInformationServer.enable({
|
|
488
798
|
events: { leave: true, reachableChanged: true },
|
|
489
799
|
}), {
|
|
490
|
-
vendorId: vendorId !== undefined ? VendorId(vendorId) : undefined,
|
|
800
|
+
vendorId: vendorId !== undefined ? VendorId(vendorId) : undefined, // 4874
|
|
491
801
|
vendorName: vendorName.slice(0, 32),
|
|
492
802
|
productName: productName.slice(0, 32),
|
|
493
803
|
productUrl: this.productUrl.slice(0, 256),
|
|
@@ -503,6 +813,13 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
503
813
|
});
|
|
504
814
|
return this;
|
|
505
815
|
}
|
|
816
|
+
/**
|
|
817
|
+
* Creates a default identify cluster server with the specified identify time and type.
|
|
818
|
+
*
|
|
819
|
+
* @param {number} [identifyTime=0] - The time to identify the server. Defaults to 0.
|
|
820
|
+
* @param {Identify.IdentifyType} [identifyType=Identify.IdentifyType.None] - The type of identification. Defaults to Identify.IdentifyType.None.
|
|
821
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
822
|
+
*/
|
|
506
823
|
createDefaultIdentifyClusterServer(identifyTime = 0, identifyType = Identify.IdentifyType.None) {
|
|
507
824
|
this.behaviors.require(MatterbridgeIdentifyServer, {
|
|
508
825
|
identifyTime,
|
|
@@ -510,14 +827,32 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
510
827
|
});
|
|
511
828
|
return this;
|
|
512
829
|
}
|
|
830
|
+
/**
|
|
831
|
+
* Creates a default groups cluster server.
|
|
832
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
833
|
+
*/
|
|
513
834
|
createDefaultGroupsClusterServer() {
|
|
514
835
|
this.behaviors.require(GroupsServer);
|
|
515
836
|
return this;
|
|
516
837
|
}
|
|
838
|
+
/**
|
|
839
|
+
* Creates a default scenes management cluster server.
|
|
840
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
841
|
+
*/
|
|
517
842
|
createDefaultScenesClusterServer() {
|
|
518
843
|
this.behaviors.require(ScenesManagementServer);
|
|
519
844
|
return this;
|
|
520
845
|
}
|
|
846
|
+
/**
|
|
847
|
+
* Creates a default OnOff cluster server for light devices.
|
|
848
|
+
*
|
|
849
|
+
* @param {boolean} [onOff=false] - The initial state of the OnOff cluster.
|
|
850
|
+
* @param {boolean} [globalSceneControl=false] - The global scene control state.
|
|
851
|
+
* @param {number} [onTime=0] - The on time value.
|
|
852
|
+
* @param {number} [offWaitTime=0] - The off wait time value.
|
|
853
|
+
* @param {OnOff.StartUpOnOff | null} [startUpOnOff=null] - The start-up OnOff state. Null means previous state.
|
|
854
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
855
|
+
*/
|
|
521
856
|
createDefaultOnOffClusterServer(onOff = false, globalSceneControl = false, onTime = 0, offWaitTime = 0, startUpOnOff = null) {
|
|
522
857
|
this.behaviors.require(MatterbridgeOnOffServer.with(OnOff.Feature.Lighting), {
|
|
523
858
|
onOff,
|
|
@@ -528,24 +863,52 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
528
863
|
});
|
|
529
864
|
return this;
|
|
530
865
|
}
|
|
866
|
+
/**
|
|
867
|
+
* Creates an OnOff cluster server without features.
|
|
868
|
+
*
|
|
869
|
+
* @param {boolean} [onOff=false] - The initial state of the OnOff cluster.
|
|
870
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
871
|
+
*/
|
|
531
872
|
createOnOffClusterServer(onOff = false) {
|
|
532
873
|
this.behaviors.require(MatterbridgeOnOffServer, {
|
|
533
874
|
onOff,
|
|
534
875
|
});
|
|
535
876
|
return this;
|
|
536
877
|
}
|
|
878
|
+
/**
|
|
879
|
+
* Creates a DeadFront OnOff cluster server.
|
|
880
|
+
*
|
|
881
|
+
* @param {boolean} [onOff=false] - The initial state of the OnOff cluster.
|
|
882
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
883
|
+
*/
|
|
537
884
|
createDeadFrontOnOffClusterServer(onOff = false) {
|
|
538
885
|
this.behaviors.require(MatterbridgeOnOffServer.with(OnOff.Feature.DeadFrontBehavior), {
|
|
539
886
|
onOff,
|
|
540
887
|
});
|
|
541
888
|
return this;
|
|
542
889
|
}
|
|
890
|
+
/**
|
|
891
|
+
* Creates an OffOnly OnOff cluster server.
|
|
892
|
+
*
|
|
893
|
+
* @param {boolean} [onOff=false] - The initial state of the OnOff cluster.
|
|
894
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
895
|
+
*/
|
|
543
896
|
createOffOnlyOnOffClusterServer(onOff = false) {
|
|
544
897
|
this.behaviors.require(MatterbridgeOnOffServer.with(OnOff.Feature.OffOnly), {
|
|
545
898
|
onOff,
|
|
546
899
|
});
|
|
547
900
|
return this;
|
|
548
901
|
}
|
|
902
|
+
/**
|
|
903
|
+
* Creates a default level control cluster server for light devices.
|
|
904
|
+
*
|
|
905
|
+
* @param {number} [currentLevel=254] - The current level (default: 254).
|
|
906
|
+
* @param {number} [minLevel=1] - The minimum level (default: 1).
|
|
907
|
+
* @param {number} [maxLevel=254] - The maximum level (default: 254).
|
|
908
|
+
* @param {number | null} [onLevel=null] - The on level (default: null).
|
|
909
|
+
* @param {number | null} [startUpCurrentLevel=null] - The startUp on level (default: null).
|
|
910
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
911
|
+
*/
|
|
549
912
|
createDefaultLevelControlClusterServer(currentLevel = 254, minLevel = 1, maxLevel = 254, onLevel = null, startUpCurrentLevel = null) {
|
|
550
913
|
this.behaviors.require(MatterbridgeLevelControlServer.with(LevelControl.Feature.OnOff, LevelControl.Feature.Lighting), {
|
|
551
914
|
currentLevel,
|
|
@@ -561,6 +924,13 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
561
924
|
});
|
|
562
925
|
return this;
|
|
563
926
|
}
|
|
927
|
+
/**
|
|
928
|
+
* Creates a level control cluster server without features.
|
|
929
|
+
*
|
|
930
|
+
* @param {number} [currentLevel=254] - The current level (default: 254).
|
|
931
|
+
* @param {number | null} [onLevel=null] - The on level (default: null).
|
|
932
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
933
|
+
*/
|
|
564
934
|
createLevelControlClusterServer(currentLevel = 254, onLevel = null) {
|
|
565
935
|
this.behaviors.require(MatterbridgeLevelControlServer, {
|
|
566
936
|
currentLevel,
|
|
@@ -572,6 +942,18 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
572
942
|
});
|
|
573
943
|
return this;
|
|
574
944
|
}
|
|
945
|
+
/**
|
|
946
|
+
* Creates a default color control cluster server with Xy, HueSaturation and ColorTemperature.
|
|
947
|
+
*
|
|
948
|
+
* @param currentX - The current X value (range 0-65279).
|
|
949
|
+
* @param currentY - The current Y value (range 0-65279).
|
|
950
|
+
* @param currentHue - The current hue value (range: 0-254).
|
|
951
|
+
* @param currentSaturation - The current saturation value (range: 0-254).
|
|
952
|
+
* @param colorTemperatureMireds - The color temperature in mireds (default range 147-500).
|
|
953
|
+
* @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds (default range 147).
|
|
954
|
+
* @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds (default range 500).
|
|
955
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
956
|
+
*/
|
|
575
957
|
createDefaultColorControlClusterServer(currentX = 0, currentY = 0, currentHue = 0, currentSaturation = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
|
|
576
958
|
this.behaviors.require(MatterbridgeColorControlServer.with(ColorControl.Feature.Xy, ColorControl.Feature.HueSaturation, ColorControl.Feature.ColorTemperature), {
|
|
577
959
|
colorMode: ColorControl.ColorMode.CurrentHueAndCurrentSaturation,
|
|
@@ -594,6 +976,19 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
594
976
|
});
|
|
595
977
|
return this;
|
|
596
978
|
}
|
|
979
|
+
/**
|
|
980
|
+
* Creates a Xy color control cluster server with Xy and ColorTemperature.
|
|
981
|
+
*
|
|
982
|
+
* @param currentX - The current X value.
|
|
983
|
+
* @param currentY - The current Y value.
|
|
984
|
+
* @param colorTemperatureMireds - The color temperature in mireds.
|
|
985
|
+
* @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds.
|
|
986
|
+
* @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds.
|
|
987
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
988
|
+
*
|
|
989
|
+
* @remarks
|
|
990
|
+
* From zigbee to matter = Math.max(Math.min(Math.round(x * 65536), 65279), 0)
|
|
991
|
+
*/
|
|
597
992
|
createXyColorControlClusterServer(currentX = 0, currentY = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
|
|
598
993
|
this.behaviors.require(MatterbridgeColorControlServer.with(ColorControl.Feature.Xy, ColorControl.Feature.ColorTemperature), {
|
|
599
994
|
colorMode: ColorControl.ColorMode.CurrentXAndCurrentY,
|
|
@@ -614,6 +1009,16 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
614
1009
|
});
|
|
615
1010
|
return this;
|
|
616
1011
|
}
|
|
1012
|
+
/**
|
|
1013
|
+
* Creates a default hue and saturation control cluster server with HueSaturation and ColorTemperature.
|
|
1014
|
+
*
|
|
1015
|
+
* @param currentHue - The current hue value.
|
|
1016
|
+
* @param currentSaturation - The current saturation value.
|
|
1017
|
+
* @param colorTemperatureMireds - The color temperature in mireds.
|
|
1018
|
+
* @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds.
|
|
1019
|
+
* @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds.
|
|
1020
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1021
|
+
*/
|
|
617
1022
|
createHsColorControlClusterServer(currentHue = 0, currentSaturation = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
|
|
618
1023
|
this.behaviors.require(MatterbridgeColorControlServer.with(ColorControl.Feature.HueSaturation, ColorControl.Feature.ColorTemperature), {
|
|
619
1024
|
colorMode: ColorControl.ColorMode.CurrentHueAndCurrentSaturation,
|
|
@@ -634,6 +1039,14 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
634
1039
|
});
|
|
635
1040
|
return this;
|
|
636
1041
|
}
|
|
1042
|
+
/**
|
|
1043
|
+
* Creates a color temperature color control cluster server.
|
|
1044
|
+
*
|
|
1045
|
+
* @param colorTemperatureMireds - The color temperature in mireds.
|
|
1046
|
+
* @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds.
|
|
1047
|
+
* @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds.
|
|
1048
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1049
|
+
*/
|
|
637
1050
|
createCtColorControlClusterServer(colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
|
|
638
1051
|
this.behaviors.require(MatterbridgeColorControlServer.with(ColorControl.Feature.ColorTemperature), {
|
|
639
1052
|
colorMode: ColorControl.ColorMode.ColorTemperatureMireds,
|
|
@@ -652,12 +1065,23 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
652
1065
|
});
|
|
653
1066
|
return this;
|
|
654
1067
|
}
|
|
1068
|
+
/**
|
|
1069
|
+
* Configures the color control mode for the device.
|
|
1070
|
+
*
|
|
1071
|
+
* @param {ColorControl.ColorMode} colorMode - The color mode to set.
|
|
1072
|
+
*/
|
|
655
1073
|
async configureColorControlMode(colorMode) {
|
|
656
1074
|
if (isValidNumber(colorMode, ColorControl.ColorMode.CurrentHueAndCurrentSaturation, ColorControl.ColorMode.ColorTemperatureMireds)) {
|
|
657
1075
|
await this.setAttribute(ColorControl.Cluster.id, 'colorMode', colorMode, this.log);
|
|
658
1076
|
await this.setAttribute(ColorControl.Cluster.id, 'enhancedColorMode', colorMode, this.log);
|
|
659
1077
|
}
|
|
660
1078
|
}
|
|
1079
|
+
/**
|
|
1080
|
+
* Creates a default window covering cluster server (Lift and PositionAwareLift).
|
|
1081
|
+
*
|
|
1082
|
+
* @param positionPercent100ths - The position percentage in 100ths (0-10000). Defaults to 0. Matter uses 10000 = fully closed 0 = fully opened.
|
|
1083
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1084
|
+
*/
|
|
661
1085
|
createDefaultWindowCoveringClusterServer(positionPercent100ths) {
|
|
662
1086
|
this.behaviors.require(MatterbridgeWindowCoveringServer.with(WindowCovering.Feature.Lift, WindowCovering.Feature.PositionAwareLift), {
|
|
663
1087
|
type: WindowCovering.WindowCoveringType.Rollershade,
|
|
@@ -673,11 +1097,15 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
673
1097
|
operationalStatus: { global: WindowCovering.MovementStatus.Stopped, lift: WindowCovering.MovementStatus.Stopped, tilt: WindowCovering.MovementStatus.Stopped },
|
|
674
1098
|
endProductType: WindowCovering.EndProductType.RollerShade,
|
|
675
1099
|
mode: { motorDirectionReversed: false, calibrationMode: false, maintenanceMode: false, ledFeedback: false },
|
|
676
|
-
targetPositionLiftPercent100ths: positionPercent100ths ?? 0,
|
|
677
|
-
currentPositionLiftPercent100ths: positionPercent100ths ?? 0,
|
|
1100
|
+
targetPositionLiftPercent100ths: positionPercent100ths ?? 0, // 0 Fully open 10000 fully closed
|
|
1101
|
+
currentPositionLiftPercent100ths: positionPercent100ths ?? 0, // 0 Fully open 10000 fully closed
|
|
678
1102
|
});
|
|
679
1103
|
return this;
|
|
680
1104
|
}
|
|
1105
|
+
/**
|
|
1106
|
+
* Sets the window covering target position as the current position and stops the movement.
|
|
1107
|
+
*
|
|
1108
|
+
*/
|
|
681
1109
|
async setWindowCoveringTargetAsCurrentAndStopped() {
|
|
682
1110
|
const position = this.getAttribute(WindowCovering.Cluster.id, 'currentPositionLiftPercent100ths', this.log);
|
|
683
1111
|
if (isValidNumber(position, 0, 10000)) {
|
|
@@ -690,6 +1118,12 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
690
1118
|
}
|
|
691
1119
|
this.log.debug(`Set WindowCovering currentPositionLiftPercent100ths and targetPositionLiftPercent100ths to ${position} and operationalStatus to Stopped.`);
|
|
692
1120
|
}
|
|
1121
|
+
/**
|
|
1122
|
+
* Sets the current and target status of a window covering.
|
|
1123
|
+
* @param {number} current - The current position of the window covering.
|
|
1124
|
+
* @param {number} target - The target position of the window covering.
|
|
1125
|
+
* @param {WindowCovering.MovementStatus} status - The movement status of the window covering.
|
|
1126
|
+
*/
|
|
693
1127
|
async setWindowCoveringCurrentTargetStatus(current, target, status) {
|
|
694
1128
|
await this.setAttribute(WindowCovering.Cluster.id, 'currentPositionLiftPercent100ths', current, this.log);
|
|
695
1129
|
await this.setAttribute(WindowCovering.Cluster.id, 'targetPositionLiftPercent100ths', target, this.log);
|
|
@@ -700,6 +1134,10 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
700
1134
|
}, this.log);
|
|
701
1135
|
this.log.debug(`Set WindowCovering currentPositionLiftPercent100ths: ${current}, targetPositionLiftPercent100ths: ${target} and operationalStatus: ${status}.`);
|
|
702
1136
|
}
|
|
1137
|
+
/**
|
|
1138
|
+
* Sets the status of the window covering.
|
|
1139
|
+
* @param {WindowCovering.MovementStatus} status - The movement status to set.
|
|
1140
|
+
*/
|
|
703
1141
|
async setWindowCoveringStatus(status) {
|
|
704
1142
|
await this.setAttribute(WindowCovering.Cluster.id, 'operationalStatus', {
|
|
705
1143
|
global: status,
|
|
@@ -708,6 +1146,11 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
708
1146
|
}, this.log);
|
|
709
1147
|
this.log.debug(`Set WindowCovering operationalStatus: ${status}`);
|
|
710
1148
|
}
|
|
1149
|
+
/**
|
|
1150
|
+
* Retrieves the status of the window covering.
|
|
1151
|
+
*
|
|
1152
|
+
* @returns The global operational status of the window covering or undefined.
|
|
1153
|
+
*/
|
|
711
1154
|
getWindowCoveringStatus() {
|
|
712
1155
|
const status = this.getAttribute(WindowCovering.Cluster.id, 'operationalStatus', this.log);
|
|
713
1156
|
if (isValidObject(status, 3) && 'global' in status && typeof status.global === 'number') {
|
|
@@ -715,36 +1158,66 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
715
1158
|
return status.global;
|
|
716
1159
|
}
|
|
717
1160
|
}
|
|
1161
|
+
/**
|
|
1162
|
+
* Sets the target and current position of the window covering.
|
|
1163
|
+
*
|
|
1164
|
+
* @param position - The position to set, specified as a number.
|
|
1165
|
+
*/
|
|
718
1166
|
async setWindowCoveringTargetAndCurrentPosition(position) {
|
|
719
1167
|
await this.setAttribute(WindowCovering.Cluster.id, 'currentPositionLiftPercent100ths', position, this.log);
|
|
720
1168
|
await this.setAttribute(WindowCovering.Cluster.id, 'targetPositionLiftPercent100ths', position, this.log);
|
|
721
1169
|
this.log.debug(`Set WindowCovering currentPositionLiftPercent100ths: ${position} and targetPositionLiftPercent100ths: ${position}.`);
|
|
722
1170
|
}
|
|
1171
|
+
/**
|
|
1172
|
+
* Creates a default thermostat cluster server with Thermostat.Feature.Heating, Thermostat.Feature.Cooling, Thermostat.Feature.AutoMode.
|
|
1173
|
+
*
|
|
1174
|
+
* @param {number} [localTemperature=23] - The local temperature value in degrees Celsius. Defaults to 23°.
|
|
1175
|
+
* @param {number} [occupiedHeatingSetpoint=21] - The occupied heating setpoint value in degrees Celsius. Defaults to 21°.
|
|
1176
|
+
* @param {number} [occupiedCoolingSetpoint=25] - The occupied cooling setpoint value in degrees Celsius. Defaults to 25°.
|
|
1177
|
+
* @param {number} [minSetpointDeadBand=1] - The minimum setpoint dead band value. Defaults to 1°.
|
|
1178
|
+
* @param {number} [minHeatSetpointLimit=0] - The minimum heat setpoint limit value. Defaults to 0°.
|
|
1179
|
+
* @param {number} [maxHeatSetpointLimit=50] - The maximum heat setpoint limit value. Defaults to 50°.
|
|
1180
|
+
* @param {number} [minCoolSetpointLimit=0] - The minimum cool setpoint limit value. Defaults to 0°.
|
|
1181
|
+
* @param {number} [maxCoolSetpointLimit=50] - The maximum cool setpoint limit value. Defaults to 50°.
|
|
1182
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1183
|
+
*/
|
|
723
1184
|
createDefaultThermostatClusterServer(localTemperature = 23, occupiedHeatingSetpoint = 21, occupiedCoolingSetpoint = 25, minSetpointDeadBand = 1, minHeatSetpointLimit = 0, maxHeatSetpointLimit = 50, minCoolSetpointLimit = 0, maxCoolSetpointLimit = 50) {
|
|
724
1185
|
this.behaviors.require(MatterbridgeThermostatServer.with(Thermostat.Feature.Heating, Thermostat.Feature.Cooling, Thermostat.Feature.AutoMode), {
|
|
725
1186
|
localTemperature: localTemperature * 100,
|
|
726
1187
|
systemMode: Thermostat.SystemMode.Auto,
|
|
727
1188
|
controlSequenceOfOperation: Thermostat.ControlSequenceOfOperation.CoolingAndHeating,
|
|
1189
|
+
// Thermostat.Feature.Heating
|
|
728
1190
|
occupiedHeatingSetpoint: occupiedHeatingSetpoint * 100,
|
|
729
1191
|
minHeatSetpointLimit: minHeatSetpointLimit * 100,
|
|
730
1192
|
maxHeatSetpointLimit: maxHeatSetpointLimit * 100,
|
|
731
1193
|
absMinHeatSetpointLimit: minHeatSetpointLimit * 100,
|
|
732
1194
|
absMaxHeatSetpointLimit: maxHeatSetpointLimit * 100,
|
|
1195
|
+
// Thermostat.Feature.Cooling
|
|
733
1196
|
occupiedCoolingSetpoint: occupiedCoolingSetpoint * 100,
|
|
734
1197
|
minCoolSetpointLimit: minCoolSetpointLimit * 100,
|
|
735
1198
|
maxCoolSetpointLimit: maxCoolSetpointLimit * 100,
|
|
736
1199
|
absMinCoolSetpointLimit: minCoolSetpointLimit * 100,
|
|
737
1200
|
absMaxCoolSetpointLimit: maxCoolSetpointLimit * 100,
|
|
1201
|
+
// Thermostat.Feature.AutoMode
|
|
738
1202
|
minSetpointDeadBand: minSetpointDeadBand * 100,
|
|
739
1203
|
thermostatRunningMode: Thermostat.ThermostatRunningMode.Off,
|
|
740
1204
|
});
|
|
741
1205
|
return this;
|
|
742
1206
|
}
|
|
1207
|
+
/**
|
|
1208
|
+
* Creates a default heating thermostat cluster server with Thermostat.Feature.Heating.
|
|
1209
|
+
* @param {number} [localTemperature] - The local temperature value in degrees Celsius. Defaults to 23°.
|
|
1210
|
+
* @param {number} [occupiedHeatingSetpoint] - The occupied heating setpoint value in degrees Celsius. Defaults to 21°.
|
|
1211
|
+
* @param {number} [minHeatSetpointLimit] - The minimum heat setpoint limit value. Defaults to 0°.
|
|
1212
|
+
* @param {number} [maxHeatSetpointLimit] - The maximum heat setpoint limit value. Defaults to 50°.
|
|
1213
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1214
|
+
*/
|
|
743
1215
|
createDefaultHeatingThermostatClusterServer(localTemperature = 23, occupiedHeatingSetpoint = 21, minHeatSetpointLimit = 0, maxHeatSetpointLimit = 50) {
|
|
744
1216
|
this.behaviors.require(MatterbridgeThermostatServer.with(Thermostat.Feature.Heating), {
|
|
745
1217
|
localTemperature: localTemperature * 100,
|
|
746
1218
|
systemMode: Thermostat.SystemMode.Heat,
|
|
747
1219
|
controlSequenceOfOperation: Thermostat.ControlSequenceOfOperation.HeatingOnly,
|
|
1220
|
+
// Thermostat.Feature.Heating
|
|
748
1221
|
occupiedHeatingSetpoint: occupiedHeatingSetpoint * 100,
|
|
749
1222
|
minHeatSetpointLimit: minHeatSetpointLimit * 100,
|
|
750
1223
|
maxHeatSetpointLimit: maxHeatSetpointLimit * 100,
|
|
@@ -753,11 +1226,20 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
753
1226
|
});
|
|
754
1227
|
return this;
|
|
755
1228
|
}
|
|
1229
|
+
/**
|
|
1230
|
+
* Creates a default cooling thermostat cluster server with Thermostat.Feature.Cooling.
|
|
1231
|
+
* @param {number} [localTemperature] - The local temperature value in degrees Celsius. Defaults to 23°.
|
|
1232
|
+
* @param {number} [occupiedCoolingSetpoint] - The occupied cooling setpoint value in degrees Celsius. Defaults to 25°.
|
|
1233
|
+
* @param {number} [minCoolSetpointLimit] - The minimum cool setpoint limit value. Defaults to 0°.
|
|
1234
|
+
* @param {number} [maxCoolSetpointLimit] - The maximum cool setpoint limit value. Defaults to 50°.
|
|
1235
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1236
|
+
*/
|
|
756
1237
|
createDefaultCoolingThermostatClusterServer(localTemperature = 23, occupiedCoolingSetpoint = 25, minCoolSetpointLimit = 0, maxCoolSetpointLimit = 50) {
|
|
757
1238
|
this.behaviors.require(MatterbridgeThermostatServer.with(Thermostat.Feature.Cooling), {
|
|
758
1239
|
localTemperature: localTemperature * 100,
|
|
759
1240
|
systemMode: Thermostat.SystemMode.Cool,
|
|
760
1241
|
controlSequenceOfOperation: Thermostat.ControlSequenceOfOperation.CoolingOnly,
|
|
1242
|
+
// Thermostat.Feature.Cooling
|
|
761
1243
|
occupiedCoolingSetpoint: occupiedCoolingSetpoint * 100,
|
|
762
1244
|
minCoolSetpointLimit: minCoolSetpointLimit * 100,
|
|
763
1245
|
maxCoolSetpointLimit: maxCoolSetpointLimit * 100,
|
|
@@ -766,6 +1248,15 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
766
1248
|
});
|
|
767
1249
|
return this;
|
|
768
1250
|
}
|
|
1251
|
+
/**
|
|
1252
|
+
* Creates a default thermostat user interface configuration cluster server.
|
|
1253
|
+
*
|
|
1254
|
+
* @remarks
|
|
1255
|
+
* The default values are:
|
|
1256
|
+
* - temperatureDisplayMode: ThermostatUserInterfaceConfiguration.TemperatureDisplayMode.Celsius (writeble).
|
|
1257
|
+
* - keypadLockout: ThermostatUserInterfaceConfiguration.KeypadLockout.NoLockout (writeble).
|
|
1258
|
+
* - scheduleProgrammingVisibility: ThermostatUserInterfaceConfiguration.ScheduleProgrammingVisibility.ScheduleProgrammingPermitted (writeble).
|
|
1259
|
+
*/
|
|
769
1260
|
createDefaultThermostatUserInterfaceConfigurationClusterServer() {
|
|
770
1261
|
this.behaviors.require(ThermostatUserInterfaceConfigurationServer, {
|
|
771
1262
|
temperatureDisplayMode: ThermostatUserInterfaceConfiguration.TemperatureDisplayMode.Celsius,
|
|
@@ -774,6 +1265,12 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
774
1265
|
});
|
|
775
1266
|
return this;
|
|
776
1267
|
}
|
|
1268
|
+
/**
|
|
1269
|
+
* Creates a default fan control cluster server.
|
|
1270
|
+
*
|
|
1271
|
+
* @param fanMode The fan mode to set. Defaults to `FanControl.FanMode.Off`.
|
|
1272
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1273
|
+
*/
|
|
777
1274
|
createDefaultFanControlClusterServer(fanMode = FanControl.FanMode.Off) {
|
|
778
1275
|
this.behaviors.require(MatterbridgeFanControlServer.with(FanControl.Feature.MultiSpeed, FanControl.Feature.Auto, FanControl.Feature.Step), {
|
|
779
1276
|
fanMode,
|
|
@@ -786,6 +1283,12 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
786
1283
|
});
|
|
787
1284
|
return this;
|
|
788
1285
|
}
|
|
1286
|
+
/**
|
|
1287
|
+
* Creates a base fan control cluster server.
|
|
1288
|
+
*
|
|
1289
|
+
* @param fanMode The fan mode to set. Defaults to `FanControl.FanMode.Off`.
|
|
1290
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1291
|
+
*/
|
|
789
1292
|
createBaseFanControlClusterServer(fanMode = FanControl.FanMode.Off) {
|
|
790
1293
|
this.behaviors.require(FanControlServer, {
|
|
791
1294
|
fanMode,
|
|
@@ -795,39 +1298,82 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
795
1298
|
});
|
|
796
1299
|
return this;
|
|
797
1300
|
}
|
|
1301
|
+
/**
|
|
1302
|
+
* Creates a default HEPA Filter Monitoring Cluster Server.
|
|
1303
|
+
* It supports ResourceMonitoring.Feature.Condition and ResourceMonitoring.Feature.ReplacementProductList.
|
|
1304
|
+
*
|
|
1305
|
+
* @param {ResourceMonitoring.ChangeIndication} changeIndication - The initial change indication. Default is ResourceMonitoring.ChangeIndication.Ok.
|
|
1306
|
+
* @param {boolean | undefined} inPlaceIndicator - The in-place indicator. Default is undefined.
|
|
1307
|
+
* @param {number | undefined} lastChangedTime - The last changed time (EpochS). Default is undefined.
|
|
1308
|
+
*
|
|
1309
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1310
|
+
*/
|
|
798
1311
|
createDefaultHepaFilterMonitoringClusterServer(changeIndication = ResourceMonitoring.ChangeIndication.Ok, inPlaceIndicator = undefined, lastChangedTime = undefined) {
|
|
799
1312
|
this.behaviors.require(HepaFilterMonitoringServer.with(ResourceMonitoring.Feature.Condition, ResourceMonitoring.Feature.ReplacementProductList), {
|
|
800
|
-
condition: 100,
|
|
801
|
-
degradationDirection: ResourceMonitoring.DegradationDirection.Down,
|
|
1313
|
+
condition: 100, // Feature.Condition
|
|
1314
|
+
degradationDirection: ResourceMonitoring.DegradationDirection.Down, // Feature.Condition
|
|
802
1315
|
changeIndication,
|
|
803
1316
|
inPlaceIndicator,
|
|
804
1317
|
lastChangedTime,
|
|
805
|
-
replacementProductList: [],
|
|
1318
|
+
replacementProductList: [], // Feature.ReplacementProductList
|
|
806
1319
|
});
|
|
807
1320
|
return this;
|
|
808
1321
|
}
|
|
1322
|
+
/**
|
|
1323
|
+
* Creates a default Activated Carbon Filter Monitoring Cluster Server.
|
|
1324
|
+
* It supports ResourceMonitoring.Feature.Condition and ResourceMonitoring.Feature.ReplacementProductList.
|
|
1325
|
+
*
|
|
1326
|
+
* @param {ResourceMonitoring.ChangeIndication} changeIndication - The initial change indication. Default is ResourceMonitoring.ChangeIndication.Ok.
|
|
1327
|
+
* @param {boolean | undefined} inPlaceIndicator - The in-place indicator. Default is undefined.
|
|
1328
|
+
* @param {number | undefined} lastChangedTime - The last changed time (EpochS). Default is undefined.
|
|
1329
|
+
*
|
|
1330
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1331
|
+
*/
|
|
809
1332
|
createDefaultActivatedCarbonFilterMonitoringClusterServer(changeIndication = ResourceMonitoring.ChangeIndication.Ok, inPlaceIndicator = undefined, lastChangedTime = undefined) {
|
|
810
1333
|
this.behaviors.require(ActivatedCarbonFilterMonitoringServer.with(ResourceMonitoring.Feature.Condition, ResourceMonitoring.Feature.ReplacementProductList), {
|
|
811
|
-
condition: 100,
|
|
812
|
-
degradationDirection: ResourceMonitoring.DegradationDirection.Down,
|
|
1334
|
+
condition: 100, // Feature.Condition
|
|
1335
|
+
degradationDirection: ResourceMonitoring.DegradationDirection.Down, // Feature.Condition
|
|
813
1336
|
changeIndication,
|
|
814
1337
|
inPlaceIndicator,
|
|
815
1338
|
lastChangedTime,
|
|
816
|
-
replacementProductList: [],
|
|
1339
|
+
replacementProductList: [], // Feature.ReplacementProductList
|
|
817
1340
|
});
|
|
818
1341
|
return this;
|
|
819
1342
|
}
|
|
1343
|
+
/**
|
|
1344
|
+
* Creates a default door lock cluster server.
|
|
1345
|
+
*
|
|
1346
|
+
* @param {DoorLock.LockState} [lockState=DoorLock.LockState.Locked] - The initial state of the lock (default: Locked).
|
|
1347
|
+
* @param {DoorLock.LockType} [lockType=DoorLock.LockType.DeadBolt] - The type of the lock (default: DeadBolt).
|
|
1348
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1349
|
+
*
|
|
1350
|
+
* @remarks
|
|
1351
|
+
* All operating modes NOT supported by a lock SHALL be set to one. The value of the OperatingMode enumeration defines the related bit to be set.
|
|
1352
|
+
*/
|
|
820
1353
|
createDefaultDoorLockClusterServer(lockState = DoorLock.LockState.Locked, lockType = DoorLock.LockType.DeadBolt) {
|
|
821
1354
|
this.behaviors.require(MatterbridgeDoorLockServer.enable({ events: { doorLockAlarm: true, lockOperation: true, lockOperationError: true } }), {
|
|
822
1355
|
lockState,
|
|
823
1356
|
lockType,
|
|
824
1357
|
actuatorEnabled: false,
|
|
825
1358
|
operatingMode: DoorLock.OperatingMode.Normal,
|
|
1359
|
+
// Special case of inverted bitmap: add also alwaysSet = 2047
|
|
826
1360
|
supportedOperatingModes: { normal: false, vacation: true, privacy: true, noRemoteLockUnlock: true, passage: true, alwaysSet: 2047 },
|
|
827
1361
|
alarmMask: { lockJammed: false, lockFactoryReset: false, lockRadioPowerCycled: false, wrongCodeEntryLimit: false, frontEscutcheonRemoved: false, doorForcedOpen: false },
|
|
828
1362
|
});
|
|
829
1363
|
return this;
|
|
830
1364
|
}
|
|
1365
|
+
/**
|
|
1366
|
+
* Creates a default Mode Select cluster server.
|
|
1367
|
+
*
|
|
1368
|
+
* @param {string} description - The description of the mode select cluster.
|
|
1369
|
+
* @param {ModeSelect.ModeOption[]} supportedModes - The list of supported modes.
|
|
1370
|
+
* @param {number} [currentMode=0] - The current mode (default: 0).
|
|
1371
|
+
* @param {number} [startUpMode=0] - The startup mode (default: 0).
|
|
1372
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1373
|
+
*
|
|
1374
|
+
* @remarks
|
|
1375
|
+
* endpoint.createDefaultModeSelectClusterServer('Night mode', [{ label: 'Led ON', mode: 0, semanticTags: [] }, { label: 'Led OFF', mode: 1, semanticTags: [] }], 0, 0);
|
|
1376
|
+
*/
|
|
831
1377
|
createDefaultModeSelectClusterServer(description, supportedModes, currentMode = 0, startUpMode = 0) {
|
|
832
1378
|
this.behaviors.require(MatterbridgeModeSelectServer, {
|
|
833
1379
|
description: description,
|
|
@@ -838,6 +1384,13 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
838
1384
|
});
|
|
839
1385
|
return this;
|
|
840
1386
|
}
|
|
1387
|
+
/**
|
|
1388
|
+
* Creates the default Valve Configuration And Control cluster server.
|
|
1389
|
+
*
|
|
1390
|
+
* @param {ValveConfigurationAndControl.ValveState} [valveState=ValveConfigurationAndControl.ValveState.Closed] - The valve state to set. Defaults to `ValveConfigurationAndControl.ValveState.Closed`.
|
|
1391
|
+
* @param {number} [valveLevel=0] - The valve level to set. Defaults to 0.
|
|
1392
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1393
|
+
*/
|
|
841
1394
|
createDefaultValveConfigurationAndControlClusterServer(valveState = ValveConfigurationAndControl.ValveState.Closed, valveLevel = 0) {
|
|
842
1395
|
this.behaviors.require(MatterbridgeValveConfigurationAndControlServer.with(ValveConfigurationAndControl.Feature.Level), {
|
|
843
1396
|
currentState: valveState,
|
|
@@ -853,6 +1406,12 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
853
1406
|
});
|
|
854
1407
|
return this;
|
|
855
1408
|
}
|
|
1409
|
+
/**
|
|
1410
|
+
* Creates the default PumpConfigurationAndControl cluster server.
|
|
1411
|
+
*
|
|
1412
|
+
* @param {PumpConfigurationAndControl.OperationMode} [pumpMode=PumpConfigurationAndControl.OperationMode.Normal] - The pump mode to set. Defaults to `PumpConfigurationAndControl.OperationMode.Normal`.
|
|
1413
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1414
|
+
*/
|
|
856
1415
|
createDefaultPumpConfigurationAndControlClusterServer(pumpMode = PumpConfigurationAndControl.OperationMode.Normal) {
|
|
857
1416
|
this.behaviors.require(PumpConfigurationAndControlServer.with(PumpConfigurationAndControl.Feature.ConstantSpeed), {
|
|
858
1417
|
minConstSpeed: null,
|
|
@@ -867,6 +1426,13 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
867
1426
|
});
|
|
868
1427
|
return this;
|
|
869
1428
|
}
|
|
1429
|
+
/**
|
|
1430
|
+
* Creates the default SmokeCOAlarm Cluster Server.
|
|
1431
|
+
*
|
|
1432
|
+
* @param {SmokeCoAlarm.AlarmState} smokeState - The state of the smoke alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
|
|
1433
|
+
* @param {SmokeCoAlarm.AlarmState} coState - The state of the CO alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
|
|
1434
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1435
|
+
*/
|
|
870
1436
|
createDefaultSmokeCOAlarmClusterServer(smokeState = SmokeCoAlarm.AlarmState.Normal, coState = SmokeCoAlarm.AlarmState.Normal) {
|
|
871
1437
|
this.behaviors.require(MatterbridgeSmokeCoAlarmServer.with(SmokeCoAlarm.Feature.SmokeAlarm, SmokeCoAlarm.Feature.CoAlarm).enable({
|
|
872
1438
|
events: { smokeAlarm: true, interconnectSmokeAlarm: false, coAlarm: true, interconnectCoAlarm: false, lowBattery: true, hardwareFault: true, endOfService: true, selfTestComplete: true, alarmMuted: true, muteEnded: true, allClear: true },
|
|
@@ -882,6 +1448,12 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
882
1448
|
});
|
|
883
1449
|
return this;
|
|
884
1450
|
}
|
|
1451
|
+
/**
|
|
1452
|
+
* Creates a smoke only SmokeCOAlarm Cluster Server.
|
|
1453
|
+
*
|
|
1454
|
+
* @param {SmokeCoAlarm.AlarmState} smokeState - The state of the smoke alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
|
|
1455
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1456
|
+
*/
|
|
885
1457
|
createSmokeOnlySmokeCOAlarmClusterServer(smokeState = SmokeCoAlarm.AlarmState.Normal) {
|
|
886
1458
|
this.behaviors.require(MatterbridgeSmokeCoAlarmServer.with(SmokeCoAlarm.Feature.SmokeAlarm).enable({
|
|
887
1459
|
events: { smokeAlarm: true, interconnectSmokeAlarm: false, coAlarm: false, interconnectCoAlarm: false, lowBattery: true, hardwareFault: true, endOfService: true, selfTestComplete: true, alarmMuted: true, muteEnded: true, allClear: true },
|
|
@@ -896,6 +1468,12 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
896
1468
|
});
|
|
897
1469
|
return this;
|
|
898
1470
|
}
|
|
1471
|
+
/**
|
|
1472
|
+
* Creates a co only SmokeCOAlarm Cluster Server.
|
|
1473
|
+
*
|
|
1474
|
+
* @param {SmokeCoAlarm.AlarmState} coState - The state of the CO alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
|
|
1475
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1476
|
+
*/
|
|
899
1477
|
createCoOnlySmokeCOAlarmClusterServer(coState = SmokeCoAlarm.AlarmState.Normal) {
|
|
900
1478
|
this.behaviors.require(MatterbridgeSmokeCoAlarmServer.with(SmokeCoAlarm.Feature.CoAlarm).enable({
|
|
901
1479
|
events: { smokeAlarm: false, interconnectSmokeAlarm: false, coAlarm: true, interconnectCoAlarm: false, lowBattery: true, hardwareFault: true, endOfService: true, selfTestComplete: true, alarmMuted: true, muteEnded: true, allClear: true },
|
|
@@ -910,6 +1488,13 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
910
1488
|
});
|
|
911
1489
|
return this;
|
|
912
1490
|
}
|
|
1491
|
+
/**
|
|
1492
|
+
* Creates a default momentary switch cluster server.
|
|
1493
|
+
*
|
|
1494
|
+
* @remarks
|
|
1495
|
+
* This method adds a cluster server with default momentary switch features and configuration suitable for (AppleHome) Single Double Long automations.
|
|
1496
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1497
|
+
*/
|
|
913
1498
|
createDefaultSwitchClusterServer() {
|
|
914
1499
|
this.behaviors.require(MatterbridgeSwitchServer.with(Switch.Feature.MomentarySwitch, Switch.Feature.MomentarySwitchRelease, Switch.Feature.MomentarySwitchLongPress, Switch.Feature.MomentarySwitchMultiPress).enable({
|
|
915
1500
|
events: { initialPress: true, longPress: true, shortRelease: true, longRelease: true, multiPressOngoing: true, multiPressComplete: true },
|
|
@@ -920,6 +1505,13 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
920
1505
|
});
|
|
921
1506
|
return this;
|
|
922
1507
|
}
|
|
1508
|
+
/**
|
|
1509
|
+
* Creates a default latching switch cluster server.
|
|
1510
|
+
*
|
|
1511
|
+
* @remarks
|
|
1512
|
+
* This method adds a cluster server with default latching switch features and configuration suitable for a latching switch with 2 positions.
|
|
1513
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1514
|
+
*/
|
|
923
1515
|
createDefaultLatchingSwitchClusterServer() {
|
|
924
1516
|
this.behaviors.require(SwitchServer.with(Switch.Feature.LatchingSwitch).enable({
|
|
925
1517
|
events: { switchLatched: true },
|
|
@@ -929,6 +1521,13 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
929
1521
|
});
|
|
930
1522
|
return this;
|
|
931
1523
|
}
|
|
1524
|
+
/**
|
|
1525
|
+
* Triggers a switch event on the specified endpoint.
|
|
1526
|
+
*
|
|
1527
|
+
* @param {string} event - The type of event to trigger. Possible values are 'Single', 'Double', 'Long' for momentarySwitch and 'Press', 'Release' for latchingSwitch.
|
|
1528
|
+
* @param {Endpoint} endpoint - The endpoint on which to trigger the event (default the device endpoint).
|
|
1529
|
+
* @returns {boolean} - A boolean indicating whether the event was successfully triggered.
|
|
1530
|
+
*/
|
|
932
1531
|
async triggerSwitchEvent(event, log) {
|
|
933
1532
|
if (this.maybeNumber === undefined) {
|
|
934
1533
|
this.log.error(`triggerSwitchEvent ${event} error: Endpoint number not assigned on endpoint ${this.maybeId}:${this.maybeNumber}`);
|
|
@@ -988,10 +1587,29 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
988
1587
|
}
|
|
989
1588
|
return true;
|
|
990
1589
|
}
|
|
1590
|
+
/**
|
|
1591
|
+
* Creates a default OperationalState Cluster Server.
|
|
1592
|
+
*
|
|
1593
|
+
* @param {OperationalState.OperationalStateEnum} operationalState - The initial operational state.
|
|
1594
|
+
*
|
|
1595
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1596
|
+
*/
|
|
991
1597
|
createDefaultOperationalStateClusterServer(operationalState = OperationalState.OperationalStateEnum.Stopped) {
|
|
992
1598
|
this.behaviors.require(MatterbridgeOperationalStateServer, getDefaultOperationalStateClusterServer(operationalState));
|
|
993
1599
|
return this;
|
|
994
1600
|
}
|
|
1601
|
+
/**
|
|
1602
|
+
* Creates a default boolean state cluster server.
|
|
1603
|
+
*
|
|
1604
|
+
* @param {boolean} contact - The state of the cluster. Defaults to true (true = contact).
|
|
1605
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1606
|
+
*
|
|
1607
|
+
* @remarks
|
|
1608
|
+
* Water Leak Detector: true = leak, false = no leak
|
|
1609
|
+
* Water Freeze Detector: true = freeze, false = no freeze
|
|
1610
|
+
* Rain Sensor: true = rain, false = no rain
|
|
1611
|
+
* Contact Sensor: true = closed or contact, false = open or no contact
|
|
1612
|
+
*/
|
|
995
1613
|
createDefaultBooleanStateClusterServer(contact) {
|
|
996
1614
|
this.behaviors.require(BooleanStateServer.enable({
|
|
997
1615
|
events: { stateChange: true },
|
|
@@ -1000,6 +1618,18 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1000
1618
|
});
|
|
1001
1619
|
return this;
|
|
1002
1620
|
}
|
|
1621
|
+
/**
|
|
1622
|
+
* Creates a default boolean state configuration cluster server to be used with the waterFreezeDetector, waterLeakDetector, and rainSensor device types.
|
|
1623
|
+
*
|
|
1624
|
+
* @remarks Supports the enableDisableAlarm command.
|
|
1625
|
+
*
|
|
1626
|
+
* @param {boolean} [sensorFault=false] - Optional boolean value indicating the sensor fault state. Defaults to `false` if not provided.
|
|
1627
|
+
* @param {number} [currentSensitivityLevel=0] - The current sensitivity level. Defaults to `0` if not provided.
|
|
1628
|
+
* @param {number} [supportedSensitivityLevels=2] - The number of supported sensitivity levels. Defaults to `2` if not provided (min 2, max 10).
|
|
1629
|
+
* @param {number} [defaultSensitivityLevel=0] - The default sensitivity level. Defaults to `0` if not provided.
|
|
1630
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1631
|
+
*
|
|
1632
|
+
*/
|
|
1003
1633
|
createDefaultBooleanStateConfigurationClusterServer(sensorFault = false, currentSensitivityLevel = 0, supportedSensitivityLevels = 2, defaultSensitivityLevel = 0) {
|
|
1004
1634
|
this.behaviors.require(MatterbridgeBooleanStateConfigurationServer.with(BooleanStateConfiguration.Feature.Visual, BooleanStateConfiguration.Feature.Audible, BooleanStateConfiguration.Feature.SensitivityLevel).enable({
|
|
1005
1635
|
events: { alarmsStateChanged: true, sensorFault: true },
|
|
@@ -1014,10 +1644,21 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1014
1644
|
});
|
|
1015
1645
|
return this;
|
|
1016
1646
|
}
|
|
1647
|
+
/**
|
|
1648
|
+
* Creates a default Power Topology Cluster Server with feature TreeTopology. Only needed for an electricalSensor device type.
|
|
1649
|
+
*
|
|
1650
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1651
|
+
*/
|
|
1017
1652
|
createDefaultPowerTopologyClusterServer() {
|
|
1018
1653
|
this.behaviors.require(PowerTopologyServer.with(PowerTopology.Feature.TreeTopology));
|
|
1019
1654
|
return this;
|
|
1020
1655
|
}
|
|
1656
|
+
/**
|
|
1657
|
+
* Creates a default Electrical Energy Measurement Cluster Server.
|
|
1658
|
+
*
|
|
1659
|
+
* @param {number} energy - The total consumption value in mW/h.
|
|
1660
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1661
|
+
*/
|
|
1021
1662
|
createDefaultElectricalEnergyMeasurementClusterServer(energy = null) {
|
|
1022
1663
|
this.behaviors.require(ElectricalEnergyMeasurementServer.with(ElectricalEnergyMeasurement.Feature.ImportedEnergy, ElectricalEnergyMeasurement.Feature.ExportedEnergy, ElectricalEnergyMeasurement.Feature.CumulativeEnergy), {
|
|
1023
1664
|
accuracy: {
|
|
@@ -1033,6 +1674,15 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1033
1674
|
});
|
|
1034
1675
|
return this;
|
|
1035
1676
|
}
|
|
1677
|
+
/**
|
|
1678
|
+
* Creates a default Electrical Power Measurement Cluster Server.
|
|
1679
|
+
*
|
|
1680
|
+
* @param {number} voltage - The voltage value in millivolts.
|
|
1681
|
+
* @param {number} current - The current value in milliamperes.
|
|
1682
|
+
* @param {number} power - The power value in milliwatts.
|
|
1683
|
+
* @param {number} frequency - The frequency value in millihertz.
|
|
1684
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1685
|
+
*/
|
|
1036
1686
|
createDefaultElectricalPowerMeasurementClusterServer(voltage = null, current = null, power = null, frequency = null) {
|
|
1037
1687
|
this.behaviors.require(ElectricalPowerMeasurementServer.with(ElectricalPowerMeasurement.Feature.AlternatingCurrent), {
|
|
1038
1688
|
powerMode: ElectricalPowerMeasurement.PowerMode.Ac,
|
|
@@ -1074,36 +1724,113 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1074
1724
|
});
|
|
1075
1725
|
return this;
|
|
1076
1726
|
}
|
|
1727
|
+
/**
|
|
1728
|
+
* Creates a default TemperatureMeasurement cluster server.
|
|
1729
|
+
*
|
|
1730
|
+
* @param {number | null} measuredValue - The measured value of the temperature x 100.
|
|
1731
|
+
* @param {number | null} minMeasuredValue - The minimum measured value of the temperature x 100.
|
|
1732
|
+
* @param {number | null} maxMeasuredValue - The maximum measured value of the temperature x 100.
|
|
1733
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1734
|
+
*/
|
|
1077
1735
|
createDefaultTemperatureMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
1078
1736
|
this.behaviors.require(TemperatureMeasurementServer, getDefaultTemperatureMeasurementClusterServer(measuredValue, minMeasuredValue, maxMeasuredValue));
|
|
1079
1737
|
return this;
|
|
1080
1738
|
}
|
|
1739
|
+
/**
|
|
1740
|
+
* Creates a default RelativeHumidityMeasurement cluster server.
|
|
1741
|
+
*
|
|
1742
|
+
* @param {number | null} measuredValue - The measured value of the relative humidity x 100.
|
|
1743
|
+
* @param {number | null} minMeasuredValue - The minimum measured value of the relative humidity x 100.
|
|
1744
|
+
* @param {number | null} maxMeasuredValue - The maximum measured value of the relative humidity x 100.
|
|
1745
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1746
|
+
*/
|
|
1081
1747
|
createDefaultRelativeHumidityMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
1082
1748
|
this.behaviors.require(RelativeHumidityMeasurementServer, getDefaultRelativeHumidityMeasurementClusterServer(measuredValue, minMeasuredValue, maxMeasuredValue));
|
|
1083
1749
|
return this;
|
|
1084
1750
|
}
|
|
1751
|
+
/**
|
|
1752
|
+
* Creates a default PressureMeasurement cluster server.
|
|
1753
|
+
*
|
|
1754
|
+
* @param {number | null} measuredValue - The measured value for the pressure.
|
|
1755
|
+
* @param {number | null} minMeasuredValue - The minimum measured value for the pressure.
|
|
1756
|
+
* @param {number | null} maxMeasuredValue - The maximum measured value for the pressure.
|
|
1757
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1758
|
+
*/
|
|
1085
1759
|
createDefaultPressureMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
1086
1760
|
this.behaviors.require(PressureMeasurementServer, getDefaultPressureMeasurementClusterServer(measuredValue, minMeasuredValue, maxMeasuredValue));
|
|
1087
1761
|
return this;
|
|
1088
1762
|
}
|
|
1763
|
+
/**
|
|
1764
|
+
* Creates a default IlluminanceMeasurement cluster server.
|
|
1765
|
+
*
|
|
1766
|
+
* @param {number | null} measuredValue - The measured value of illuminance.
|
|
1767
|
+
* @param {number | null} minMeasuredValue - The minimum measured value of illuminance.
|
|
1768
|
+
* @param {number | null} maxMeasuredValue - The maximum measured value of illuminance.
|
|
1769
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1770
|
+
*
|
|
1771
|
+
* @remark The default value for the illuminance measurement is null.
|
|
1772
|
+
* This attribute SHALL indicate the illuminance in Lux (symbol lx) as follows:
|
|
1773
|
+
* • MeasuredValue = 10,000 x log10(illuminance) + 1,
|
|
1774
|
+
* where 1 lx <= illuminance <= 3.576 Mlx, corresponding to a MeasuredValue in the range 1 to 0xFFFE.
|
|
1775
|
+
* • 0 indicates a value of illuminance that is too low to be measured
|
|
1776
|
+
* • null indicates that the illuminance measurement is invalid.
|
|
1777
|
+
*
|
|
1778
|
+
* @remarks
|
|
1779
|
+
* Lux to matter = Math.round(Math.max(Math.min(10000 * Math.log10(lux), 0xfffe), 0))
|
|
1780
|
+
* Matter to Lux = Math.round(Math.max(Math.pow(10, value / 10000), 0))
|
|
1781
|
+
*/
|
|
1089
1782
|
createDefaultIlluminanceMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
1090
1783
|
this.behaviors.require(IlluminanceMeasurementServer, getDefaultIlluminanceMeasurementClusterServer(measuredValue, minMeasuredValue, maxMeasuredValue));
|
|
1091
1784
|
return this;
|
|
1092
1785
|
}
|
|
1786
|
+
/**
|
|
1787
|
+
* Creates a default FlowMeasurement cluster server.
|
|
1788
|
+
*
|
|
1789
|
+
* @param {number | null} measuredValue - The measured value of the flow in 10 x m3/h.
|
|
1790
|
+
* @param {number | null} minMeasuredValue - The minimum measured value of the flow in 10 x m3/h.
|
|
1791
|
+
* @param {number | null} maxMeasuredValue - The maximum measured value of the flow in 10 x m3/h.
|
|
1792
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1793
|
+
*/
|
|
1093
1794
|
createDefaultFlowMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
1094
1795
|
this.behaviors.require(FlowMeasurementServer, getDefaultFlowMeasurementClusterServer(measuredValue, minMeasuredValue, maxMeasuredValue));
|
|
1095
1796
|
return this;
|
|
1096
1797
|
}
|
|
1798
|
+
/**
|
|
1799
|
+
* Creates a default OccupancySensing cluster server.
|
|
1800
|
+
*
|
|
1801
|
+
* @param {boolean} occupied - A boolean indicating whether the occupancy is occupied or not. Default is false.
|
|
1802
|
+
* @param {number} holdTime - The hold time in seconds. Default is 30.
|
|
1803
|
+
* @param {number} holdTimeMin - The minimum hold time in seconds. Default is 1.
|
|
1804
|
+
* @param {number} holdTimeMax - The maximum hold time in seconds. Default is 300.
|
|
1805
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1806
|
+
*
|
|
1807
|
+
* @remark The default value for the occupancy sensor type is PIR.
|
|
1808
|
+
*/
|
|
1097
1809
|
createDefaultOccupancySensingClusterServer(occupied = false, holdTime = 30, holdTimeMin = 1, holdTimeMax = 300) {
|
|
1098
1810
|
this.behaviors.require(OccupancySensingServer.with(OccupancySensing.Feature.PassiveInfrared), getDefaultOccupancySensingClusterServer(occupied, holdTime, holdTimeMin, holdTimeMax));
|
|
1099
1811
|
return this;
|
|
1100
1812
|
}
|
|
1813
|
+
/**
|
|
1814
|
+
* Creates a default AirQuality cluster server.
|
|
1815
|
+
*
|
|
1816
|
+
* @param {AirQuality.AirQualityEnum} airQuality The air quality level. Defaults to `AirQuality.AirQualityType.Unknown`.
|
|
1817
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1818
|
+
*/
|
|
1101
1819
|
createDefaultAirQualityClusterServer(airQuality = AirQuality.AirQualityEnum.Unknown) {
|
|
1102
1820
|
this.behaviors.require(AirQualityServer.with(AirQuality.Feature.Fair, AirQuality.Feature.Moderate, AirQuality.Feature.VeryPoor, AirQuality.Feature.ExtremelyPoor), {
|
|
1103
1821
|
airQuality,
|
|
1104
1822
|
});
|
|
1105
1823
|
return this;
|
|
1106
1824
|
}
|
|
1825
|
+
/**
|
|
1826
|
+
* Creates a default TotalVolatileOrganicCompoundsConcentrationMeasurement cluster server.
|
|
1827
|
+
*
|
|
1828
|
+
* @param {number | null} measuredValue - The measured value of the concentration.
|
|
1829
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
|
|
1830
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
|
|
1831
|
+
* @param {number} [uncertainty] - The uncertainty value (optional).
|
|
1832
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1833
|
+
*/
|
|
1107
1834
|
createDefaultTvocMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air, uncertainty) {
|
|
1108
1835
|
this.behaviors.require(TotalVolatileOrganicCompoundsConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
|
|
1109
1836
|
measuredValue,
|
|
@@ -1115,6 +1842,11 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1115
1842
|
});
|
|
1116
1843
|
return this;
|
|
1117
1844
|
}
|
|
1845
|
+
/**
|
|
1846
|
+
* @param {ConcentrationMeasurement.LevelValue} levelValue - The level value of the measurement (default to ConcentrationMeasurement.LevelValue.Unknown).
|
|
1847
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The measurement medium (default to ConcentrationMeasurement.MeasurementMedium.Air).
|
|
1848
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1849
|
+
*/
|
|
1118
1850
|
createLevelTvocMeasurementClusterServer(levelValue = ConcentrationMeasurement.LevelValue.Unknown, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1119
1851
|
this.behaviors.require(TotalVolatileOrganicCompoundsConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.LevelIndication, ConcentrationMeasurement.Feature.MediumLevel, ConcentrationMeasurement.Feature.CriticalLevel), {
|
|
1120
1852
|
levelValue,
|
|
@@ -1122,6 +1854,13 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1122
1854
|
});
|
|
1123
1855
|
return this;
|
|
1124
1856
|
}
|
|
1857
|
+
/**
|
|
1858
|
+
* Create a default CarbonMonoxideConcentrationMeasurement cluster server.
|
|
1859
|
+
*
|
|
1860
|
+
* @param {number | null} measuredValue - The measured value of the concentration.
|
|
1861
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
|
|
1862
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
|
|
1863
|
+
*/
|
|
1125
1864
|
createDefaultCarbonMonoxideConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1126
1865
|
this.behaviors.require(CarbonMonoxideConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
|
|
1127
1866
|
measuredValue,
|
|
@@ -1133,6 +1872,13 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1133
1872
|
});
|
|
1134
1873
|
return this;
|
|
1135
1874
|
}
|
|
1875
|
+
/**
|
|
1876
|
+
* Create a default CarbonDioxideConcentrationMeasurement cluster server.
|
|
1877
|
+
*
|
|
1878
|
+
* @param {number | null} measuredValue - The measured value of the concentration.
|
|
1879
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
|
|
1880
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
|
|
1881
|
+
*/
|
|
1136
1882
|
createDefaultCarbonDioxideConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1137
1883
|
this.behaviors.require(CarbonDioxideConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
|
|
1138
1884
|
measuredValue,
|
|
@@ -1144,6 +1890,13 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1144
1890
|
});
|
|
1145
1891
|
return this;
|
|
1146
1892
|
}
|
|
1893
|
+
/**
|
|
1894
|
+
* Create a default FormaldehydeConcentrationMeasurement cluster server.
|
|
1895
|
+
*
|
|
1896
|
+
* @param {number | null} measuredValue - The measured value of the concentration.
|
|
1897
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
|
|
1898
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
|
|
1899
|
+
*/
|
|
1147
1900
|
createDefaultFormaldehydeConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1148
1901
|
this.behaviors.require(FormaldehydeConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
|
|
1149
1902
|
measuredValue,
|
|
@@ -1155,6 +1908,13 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1155
1908
|
});
|
|
1156
1909
|
return this;
|
|
1157
1910
|
}
|
|
1911
|
+
/**
|
|
1912
|
+
* Create a default Pm1ConcentrationMeasurement cluster server.
|
|
1913
|
+
*
|
|
1914
|
+
* @param {number | null} measuredValue - The measured value of the concentration.
|
|
1915
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
|
|
1916
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
|
|
1917
|
+
*/
|
|
1158
1918
|
createDefaultPm1ConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1159
1919
|
this.behaviors.require(Pm1ConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
|
|
1160
1920
|
measuredValue,
|
|
@@ -1166,6 +1926,13 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1166
1926
|
});
|
|
1167
1927
|
return this;
|
|
1168
1928
|
}
|
|
1929
|
+
/**
|
|
1930
|
+
* Create a default Pm25ConcentrationMeasurement cluster server.
|
|
1931
|
+
*
|
|
1932
|
+
* @param {number | null} measuredValue - The measured value of the concentration.
|
|
1933
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
|
|
1934
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
|
|
1935
|
+
*/
|
|
1169
1936
|
createDefaultPm25ConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1170
1937
|
this.behaviors.require(Pm25ConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
|
|
1171
1938
|
measuredValue,
|
|
@@ -1177,6 +1944,13 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1177
1944
|
});
|
|
1178
1945
|
return this;
|
|
1179
1946
|
}
|
|
1947
|
+
/**
|
|
1948
|
+
* Create a default Pm10ConcentrationMeasurement cluster server.
|
|
1949
|
+
*
|
|
1950
|
+
* @param {number | null} measuredValue - The measured value of the concentration.
|
|
1951
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
|
|
1952
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
|
|
1953
|
+
*/
|
|
1180
1954
|
createDefaultPm10ConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1181
1955
|
this.behaviors.require(Pm10ConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
|
|
1182
1956
|
measuredValue,
|
|
@@ -1188,6 +1962,13 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1188
1962
|
});
|
|
1189
1963
|
return this;
|
|
1190
1964
|
}
|
|
1965
|
+
/**
|
|
1966
|
+
* Create a default OzoneConcentrationMeasurement cluster server.
|
|
1967
|
+
*
|
|
1968
|
+
* @param {number | null} measuredValue - The measured value of the concentration.
|
|
1969
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ugm3).
|
|
1970
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
|
|
1971
|
+
*/
|
|
1191
1972
|
createDefaultOzoneConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ugm3, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1192
1973
|
this.behaviors.require(OzoneConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
|
|
1193
1974
|
measuredValue,
|
|
@@ -1199,6 +1980,13 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1199
1980
|
});
|
|
1200
1981
|
return this;
|
|
1201
1982
|
}
|
|
1983
|
+
/**
|
|
1984
|
+
* Create a default RadonConcentrationMeasurement cluster server.
|
|
1985
|
+
*
|
|
1986
|
+
* @param {number | null} measuredValue - The measured value of the concentration.
|
|
1987
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
|
|
1988
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
|
|
1989
|
+
*/
|
|
1202
1990
|
createDefaultRadonConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1203
1991
|
this.behaviors.require(RadonConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
|
|
1204
1992
|
measuredValue,
|
|
@@ -1210,6 +1998,13 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1210
1998
|
});
|
|
1211
1999
|
return this;
|
|
1212
2000
|
}
|
|
2001
|
+
/**
|
|
2002
|
+
* Create a default NitrogenDioxideConcentrationMeasurement cluster server.
|
|
2003
|
+
*
|
|
2004
|
+
* @param {number | null} measuredValue - The measured value of the concentration.
|
|
2005
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ugm3).
|
|
2006
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
|
|
2007
|
+
*/
|
|
1213
2008
|
createDefaultNitrogenDioxideConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ugm3, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1214
2009
|
this.behaviors.require(NitrogenDioxideConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
|
|
1215
2010
|
measuredValue,
|
|
@@ -1222,3 +2017,4 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1222
2017
|
return this;
|
|
1223
2018
|
}
|
|
1224
2019
|
}
|
|
2020
|
+
//# sourceMappingURL=matterbridgeEndpoint.js.map
|