matterbridge 1.6.5-dev.3 → 1.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -1
- package/dist/cli.d.ts +25 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +26 -0
- package/dist/cli.js.map +1 -0
- package/dist/cluster/export.d.ts +2 -0
- package/dist/cluster/export.d.ts.map +1 -0
- package/dist/cluster/export.js +2 -0
- package/dist/cluster/export.js.map +1 -0
- package/dist/defaultConfigSchema.d.ts +27 -0
- package/dist/defaultConfigSchema.d.ts.map +1 -0
- package/dist/defaultConfigSchema.js +23 -0
- package/dist/defaultConfigSchema.js.map +1 -0
- package/dist/deviceManager.d.ts +46 -0
- package/dist/deviceManager.d.ts.map +1 -0
- package/dist/deviceManager.js +26 -1
- package/dist/deviceManager.js.map +1 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +30 -0
- package/dist/index.js.map +1 -0
- package/dist/logger/export.d.ts +2 -0
- package/dist/logger/export.d.ts.map +1 -0
- package/dist/logger/export.js +1 -0
- package/dist/logger/export.js.map +1 -0
- package/dist/matter/export.d.ts +5 -0
- package/dist/matter/export.d.ts.map +1 -0
- package/dist/matter/export.js +1 -0
- package/dist/matter/export.js.map +1 -0
- package/dist/matterbridge.d.ts +466 -0
- package/dist/matterbridge.d.ts.map +1 -0
- package/dist/matterbridge.js +702 -62
- package/dist/matterbridge.js.map +1 -0
- package/dist/matterbridgeAccessoryPlatform.d.ts +39 -0
- package/dist/matterbridgeAccessoryPlatform.d.ts.map +1 -0
- package/dist/matterbridgeAccessoryPlatform.js +33 -0
- package/dist/matterbridgeAccessoryPlatform.js.map +1 -0
- package/dist/matterbridgeBehaviors.d.ts +934 -0
- package/dist/matterbridgeBehaviors.d.ts.map +1 -0
- package/dist/matterbridgeBehaviors.js +29 -1
- package/dist/matterbridgeBehaviors.js.map +1 -0
- package/dist/matterbridgeDevice.d.ts +6504 -0
- package/dist/matterbridgeDevice.d.ts.map +1 -0
- package/dist/matterbridgeDevice.js +919 -9
- package/dist/matterbridgeDevice.js.map +1 -0
- package/dist/matterbridgeDeviceTypes.d.ts +65 -0
- package/dist/matterbridgeDeviceTypes.d.ts.map +1 -0
- package/dist/matterbridgeDeviceTypes.js +40 -12
- package/dist/matterbridgeDeviceTypes.js.map +1 -0
- package/dist/matterbridgeDynamicPlatform.d.ts +39 -0
- package/dist/matterbridgeDynamicPlatform.d.ts.map +1 -0
- package/dist/matterbridgeDynamicPlatform.js +33 -0
- package/dist/matterbridgeDynamicPlatform.js.map +1 -0
- package/dist/matterbridgeEdge.d.ts +89 -0
- package/dist/matterbridgeEdge.d.ts.map +1 -0
- package/dist/matterbridgeEdge.js +525 -0
- package/dist/matterbridgeEdge.js.map +1 -0
- package/dist/matterbridgeEndpoint.d.ts +8529 -0
- package/dist/matterbridgeEndpoint.d.ts.map +1 -0
- package/dist/matterbridgeEndpoint.js +997 -16
- package/dist/matterbridgeEndpoint.js.map +1 -0
- package/dist/matterbridgePlatform.d.ts +96 -0
- package/dist/matterbridgePlatform.d.ts.map +1 -0
- package/dist/matterbridgePlatform.js +74 -3
- package/dist/matterbridgePlatform.js.map +1 -0
- package/dist/matterbridgeTypes.d.ts +147 -0
- package/dist/matterbridgeTypes.d.ts.map +1 -0
- package/dist/matterbridgeTypes.js +24 -0
- package/dist/matterbridgeTypes.js.map +1 -0
- package/dist/matterbridgeWebsocket.d.ts +49 -0
- package/dist/matterbridgeWebsocket.d.ts.map +1 -0
- package/dist/matterbridgeWebsocket.js +45 -0
- package/dist/matterbridgeWebsocket.js.map +1 -0
- package/dist/pluginManager.d.ts +238 -0
- package/dist/pluginManager.d.ts.map +1 -0
- package/dist/pluginManager.js +231 -3
- package/dist/pluginManager.js.map +1 -0
- package/dist/storage/export.d.ts +2 -0
- package/dist/storage/export.d.ts.map +1 -0
- package/dist/storage/export.js +1 -0
- package/dist/storage/export.js.map +1 -0
- package/dist/utils/colorUtils.d.ts +61 -0
- package/dist/utils/colorUtils.d.ts.map +1 -0
- package/dist/utils/colorUtils.js +78 -2
- package/dist/utils/colorUtils.js.map +1 -0
- package/dist/utils/export.d.ts +3 -0
- package/dist/utils/export.d.ts.map +1 -0
- package/dist/utils/export.js +1 -0
- package/dist/utils/export.js.map +1 -0
- package/dist/utils/utils.d.ts +221 -0
- package/dist/utils/utils.d.ts.map +1 -0
- package/dist/utils/utils.js +252 -7
- package/dist/utils/utils.js.map +1 -0
- package/npm-shrinkwrap.json +8 -5
- package/package.json +1 -1
- package/tsconfig.production.json +3 -9
|
@@ -1,15 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file contains the class MatterbridgeDevice.
|
|
3
|
+
*
|
|
4
|
+
* @file matterbridgeDevice.ts
|
|
5
|
+
* @author Luca Liguori
|
|
6
|
+
* @date 2023-12-29
|
|
7
|
+
* @version 2.0.0
|
|
8
|
+
*
|
|
9
|
+
* Copyright 2023, 2024, 2025 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
|
+
// @matter
|
|
1
24
|
import { AirQuality, AirQualityCluster, BasicInformationCluster, BooleanState, BooleanStateCluster, BooleanStateConfiguration, BooleanStateConfigurationCluster, BridgedDeviceBasicInformationCluster, CarbonDioxideConcentrationMeasurement, CarbonDioxideConcentrationMeasurementCluster, CarbonMonoxideConcentrationMeasurement, CarbonMonoxideConcentrationMeasurementCluster, ColorControl, ColorControlCluster, ConcentrationMeasurement, Descriptor, DescriptorCluster, DeviceEnergyManagement, DeviceEnergyManagementCluster, DeviceEnergyManagementMode, DeviceEnergyManagementModeCluster, DoorLock, DoorLockCluster, ElectricalEnergyMeasurement, ElectricalEnergyMeasurementCluster, ElectricalPowerMeasurement, ElectricalPowerMeasurementCluster, FanControl, FanControlCluster, FlowMeasurement, FlowMeasurementCluster, FormaldehydeConcentrationMeasurement, FormaldehydeConcentrationMeasurementCluster, Groups, GroupsCluster, Identify, IdentifyCluster, IlluminanceMeasurement, IlluminanceMeasurementCluster, LevelControl, LevelControlCluster, ModeSelectCluster, NitrogenDioxideConcentrationMeasurement, NitrogenDioxideConcentrationMeasurementCluster, OccupancySensing, OccupancySensingCluster, OnOff, OnOffCluster, OzoneConcentrationMeasurement, OzoneConcentrationMeasurementCluster, Pm10ConcentrationMeasurement, Pm10ConcentrationMeasurementCluster, Pm1ConcentrationMeasurement, Pm1ConcentrationMeasurementCluster, Pm25ConcentrationMeasurement, Pm25ConcentrationMeasurementCluster, PowerSource, PowerSourceCluster, PowerSourceConfigurationCluster, PowerTopology, PowerTopologyCluster, PressureMeasurement, PressureMeasurementCluster, RadonConcentrationMeasurement, RadonConcentrationMeasurementCluster, RelativeHumidityMeasurement, RelativeHumidityMeasurementCluster, SmokeCoAlarm, SmokeCoAlarmCluster, Switch, SwitchCluster, TemperatureMeasurement, TemperatureMeasurementCluster, Thermostat, ThermostatCluster, ThreadNetworkDiagnostics, ThreadNetworkDiagnosticsCluster, TimeSynchronization, TimeSynchronizationCluster, TotalVolatileOrganicCompoundsConcentrationMeasurement, TotalVolatileOrganicCompoundsConcentrationMeasurementCluster, WindowCovering, WindowCoveringCluster, } from '@matter/main/clusters';
|
|
2
25
|
import { Specification } from '@matter/main/model';
|
|
3
26
|
import { EndpointNumber, extendPublicHandlerMethods, VendorId } from '@matter/main';
|
|
4
27
|
import { MeasurementType, getClusterNameById } from '@matter/main/types';
|
|
28
|
+
// @project-chip
|
|
5
29
|
import { Device } from '@project-chip/matter.js/device';
|
|
6
30
|
import { GroupsClusterHandler, ClusterServer } from '@project-chip/matter.js/cluster';
|
|
31
|
+
// AnsiLogger module
|
|
7
32
|
import { AnsiLogger, CYAN, YELLOW, db, hk, or, zb, debugStringify } from 'node-ansi-logger';
|
|
33
|
+
// Node.js modules
|
|
8
34
|
import { createHash } from 'crypto';
|
|
9
35
|
import { bridgedNode } from './matterbridgeDeviceTypes.js';
|
|
10
36
|
export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
11
37
|
static bridgeMode = '';
|
|
12
|
-
static logLevel = "info"
|
|
38
|
+
static logLevel = "info" /* LogLevel.INFO */;
|
|
13
39
|
log;
|
|
14
40
|
plugin = undefined;
|
|
15
41
|
serialNumber = undefined;
|
|
@@ -23,6 +49,13 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
23
49
|
softwareVersionString = undefined;
|
|
24
50
|
hardwareVersion = undefined;
|
|
25
51
|
hardwareVersionString = undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Create a Matterbridge device.
|
|
54
|
+
* @constructor
|
|
55
|
+
* @param {DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>} definition - The DeviceTypeDefinition of the device.
|
|
56
|
+
* @param {EndpointOptions} [options={}] - The options for the device.
|
|
57
|
+
* @param {boolean} [debug=false] - The debug level for the device.
|
|
58
|
+
*/
|
|
26
59
|
constructor(definition, options = {}, debug = false) {
|
|
27
60
|
let firstDefinition;
|
|
28
61
|
if (Array.isArray(definition))
|
|
@@ -30,7 +63,7 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
30
63
|
else
|
|
31
64
|
firstDefinition = definition;
|
|
32
65
|
super(firstDefinition, options);
|
|
33
|
-
this.log = new AnsiLogger({ logName: 'MatterbridgeDevice', logTimestampFormat: 4
|
|
66
|
+
this.log = new AnsiLogger({ logName: 'MatterbridgeDevice', logTimestampFormat: 4 /* TimestampFormat.TIME_MILLIS */, logLevel: debug === true ? "debug" /* LogLevel.DEBUG */ : MatterbridgeDevice.logLevel });
|
|
34
67
|
this.log.debug(`new MatterbridgeDevice with deviceType: ${zb}${firstDefinition.code}${db}-${zb}${firstDefinition.name}${db}`);
|
|
35
68
|
if (Array.isArray(definition)) {
|
|
36
69
|
definition.forEach((deviceType) => {
|
|
@@ -40,12 +73,28 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
40
73
|
else
|
|
41
74
|
this.addDeviceType(firstDefinition);
|
|
42
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Loads asyncronously an instance of the MatterbridgeDevice class.
|
|
78
|
+
*
|
|
79
|
+
* @param {DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>} definition - The DeviceTypeDefinition of the device.
|
|
80
|
+
* @param {EndpointOptions} [options={}] - The options for the device.
|
|
81
|
+
* @param {boolean} [debug=false] - The debug level for the device.
|
|
82
|
+
* @returns {Promise<MatterbridgeDevice>} A Promise of MatterbridgeDevice instance.
|
|
83
|
+
*/
|
|
43
84
|
static async loadInstance(definition, options = {}, debug = false) {
|
|
44
85
|
return new MatterbridgeDevice(definition, options, debug);
|
|
45
86
|
}
|
|
87
|
+
// Present in new API but not here
|
|
46
88
|
get maybeNumber() {
|
|
47
89
|
return this.number;
|
|
48
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* Adds a device type to the list of device types of the MatterbridgeDevice endpoint.
|
|
93
|
+
* If the device type is not already present in the list, it will be added.
|
|
94
|
+
*
|
|
95
|
+
* @param {DeviceTypeDefinition} deviceType - The device type to add.
|
|
96
|
+
* @returns {MatterbridgeDevice} The MatterbridgeDevice instance.
|
|
97
|
+
*/
|
|
49
98
|
addDeviceType(deviceType) {
|
|
50
99
|
const deviceTypes = this.getDeviceTypes();
|
|
51
100
|
if (!deviceTypes.includes(deviceType)) {
|
|
@@ -55,6 +104,13 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
55
104
|
}
|
|
56
105
|
return this;
|
|
57
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* Adds one or more device types with the required cluster servers and the specified cluster servers.
|
|
109
|
+
*
|
|
110
|
+
* @param {AtLeastOne<DeviceTypeDefinition>} deviceTypes - The device types to add.
|
|
111
|
+
* @param {ClusterId[]} includeServerList - The list of cluster IDs to include.
|
|
112
|
+
* @returns {MatterbridgeDevice} The MatterbridgeDevice instance.
|
|
113
|
+
*/
|
|
58
114
|
addDeviceTypeWithClusterServer(deviceTypes, includeServerList = []) {
|
|
59
115
|
this.log.debug('addDeviceTypeWithClusterServer:');
|
|
60
116
|
deviceTypes.forEach((deviceType) => {
|
|
@@ -76,6 +132,18 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
76
132
|
this.addClusterServerFromList(this, includeServerList);
|
|
77
133
|
return this;
|
|
78
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* Adds a child endpoint with the specified device types and options.
|
|
137
|
+
* If the child endpoint is not already present, it will be created and added.
|
|
138
|
+
* If the child endpoint is already present, the device types will be added to the existing child endpoint.
|
|
139
|
+
*
|
|
140
|
+
* @param {string} endpointName - The name of the new endpoint to add.
|
|
141
|
+
* @param {AtLeastOne<DeviceTypeDefinition>} deviceTypes - The device types to add.
|
|
142
|
+
* @param {MatterbridgeEndpointOptions} [options={}] - The options for the endpoint.
|
|
143
|
+
* @param {boolean} [debug=false] - Whether to enable debug logging.
|
|
144
|
+
* @returns {MatterbridgeDevice} - The child endpoint that was found or added.
|
|
145
|
+
*/
|
|
146
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
79
147
|
addChildDeviceType(endpointName, deviceTypes, options = {}, debug = false) {
|
|
80
148
|
this.log.debug(`addChildDeviceType: ${CYAN}${endpointName}${db}`);
|
|
81
149
|
let child = this.getChildEndpoints().find((endpoint) => endpoint.uniqueStorageKey === endpointName);
|
|
@@ -100,6 +168,19 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
100
168
|
child.setDeviceTypes(childDeviceTypes);
|
|
101
169
|
return child;
|
|
102
170
|
}
|
|
171
|
+
/**
|
|
172
|
+
* Adds a child endpoint with one or more device types with the required cluster servers and the specified cluster servers.
|
|
173
|
+
* If the child endpoint is not already present in the childEndpoints, it will be added.
|
|
174
|
+
* If the child endpoint is already present in the childEndpoints, the device types and cluster servers will be added to the existing child endpoint.
|
|
175
|
+
*
|
|
176
|
+
* @param {string} endpointName - The name of the new enpoint to add.
|
|
177
|
+
* @param {AtLeastOne<DeviceTypeDefinition>} deviceTypes - The device types to add.
|
|
178
|
+
* @param {ClusterId[]} [includeServerList=[]] - The list of cluster IDs to include.
|
|
179
|
+
* @param {EndpointOptions} [options={}] - The options for the device.
|
|
180
|
+
* @param {boolean} [debug=false] - Whether to enable debug logging.
|
|
181
|
+
* @returns {MatterbridgeDevice} - The child endpoint that was found or added.
|
|
182
|
+
*/
|
|
183
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
103
184
|
addChildDeviceTypeWithClusterServer(endpointName, deviceTypes, includeServerList = [], options = {}, debug = false) {
|
|
104
185
|
this.log.debug(`addChildDeviceTypeWithClusterServer: ${CYAN}${endpointName}${db}`);
|
|
105
186
|
let child = this.getChildEndpoints().find((endpoint) => endpoint.uniqueStorageKey === endpointName);
|
|
@@ -132,6 +213,12 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
132
213
|
this.addClusterServerFromList(child, includeServerList);
|
|
133
214
|
return child;
|
|
134
215
|
}
|
|
216
|
+
/**
|
|
217
|
+
* Adds the required cluster servers (only if they are not present) for the device types of the specified endpoint.
|
|
218
|
+
*
|
|
219
|
+
* @param {Endpoint} endpoint - The endpoint to add the required cluster servers to.
|
|
220
|
+
* @returns {Endpoint} The updated endpoint with the required cluster servers added.
|
|
221
|
+
*/
|
|
135
222
|
addRequiredClusterServers(endpoint) {
|
|
136
223
|
const requiredServerList = [];
|
|
137
224
|
this.log.debug(`addRequiredClusterServer for ${CYAN}${endpoint.name}${db}`);
|
|
@@ -148,6 +235,12 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
148
235
|
this.addClusterServerFromList(endpoint, requiredServerList);
|
|
149
236
|
return endpoint;
|
|
150
237
|
}
|
|
238
|
+
/**
|
|
239
|
+
* Adds the optional cluster servers (only if they are not present) for the device types of the specified endpoint.
|
|
240
|
+
*
|
|
241
|
+
* @param {Endpoint} endpoint - The endpoint to add the required cluster servers to.
|
|
242
|
+
* @returns {Endpoint} The updated endpoint with the required cluster servers added.
|
|
243
|
+
*/
|
|
151
244
|
addOptionalClusterServers(endpoint) {
|
|
152
245
|
const optionalServerList = [];
|
|
153
246
|
this.log.debug(`addRequiredClusterServer for ${CYAN}${endpoint.name}${db}`);
|
|
@@ -164,11 +257,19 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
164
257
|
this.addClusterServerFromList(endpoint, optionalServerList);
|
|
165
258
|
return endpoint;
|
|
166
259
|
}
|
|
260
|
+
/**
|
|
261
|
+
* Adds cluster servers to the specified endpoint based on the provided server list.
|
|
262
|
+
*
|
|
263
|
+
* @param {Endpoint} endpoint - The endpoint to add cluster servers to.
|
|
264
|
+
* @param {ClusterId[]} includeServerList - The list of cluster IDs to include.
|
|
265
|
+
* @returns {Endpoint} The updated endpoint with the cluster servers added.
|
|
266
|
+
*/
|
|
167
267
|
addClusterServerFromList(endpoint, includeServerList) {
|
|
168
268
|
if (includeServerList.includes(Identify.Cluster.id))
|
|
169
269
|
endpoint.addClusterServer(this.getDefaultIdentifyClusterServer());
|
|
170
270
|
if (includeServerList.includes(Groups.Cluster.id))
|
|
171
271
|
endpoint.addClusterServer(this.getDefaultGroupsClusterServer());
|
|
272
|
+
// if (includeServerList.includes(ScenesManagement.Cluster.id)) endpoint.addClusterServer(this.getDefaultScenesClusterServer());
|
|
172
273
|
if (includeServerList.includes(OnOff.Cluster.id))
|
|
173
274
|
endpoint.addClusterServer(this.getDefaultOnOffClusterServer());
|
|
174
275
|
if (includeServerList.includes(LevelControl.Cluster.id))
|
|
@@ -241,9 +342,25 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
241
342
|
endpoint.addClusterServer(this.getDefaultDeviceEnergyManagementModeClusterServer());
|
|
242
343
|
return endpoint;
|
|
243
344
|
}
|
|
345
|
+
/**
|
|
346
|
+
* Retrieves a child endpoint by its name.
|
|
347
|
+
*
|
|
348
|
+
* @param {string} endpointName - The name of the endpoint to retrieve.
|
|
349
|
+
* @returns {Endpoint | undefined} The child endpoint with the specified name, or undefined if not found.
|
|
350
|
+
*/
|
|
244
351
|
getChildEndpointByName(endpointName) {
|
|
245
352
|
return this.getChildEndpoints().find((endpoint) => endpoint.uniqueStorageKey === endpointName);
|
|
246
353
|
}
|
|
354
|
+
/**
|
|
355
|
+
* Retrieves the value of the specified attribute from the given endpoint and cluster.
|
|
356
|
+
*
|
|
357
|
+
* @param {ClusterId} clusterId - The ID of the cluster to retrieve the attribute from.
|
|
358
|
+
* @param {string} attribute - The name of the attribute to retrieve.
|
|
359
|
+
* @param {AnsiLogger} [log] - Optional logger for error and info messages.
|
|
360
|
+
* @param {Endpoint} [endpoint] - Optional the child endpoint to retrieve the attribute from.
|
|
361
|
+
* @returns {any} The value of the attribute, or undefined if the attribute is not found.
|
|
362
|
+
*/
|
|
363
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
247
364
|
getAttribute(clusterId, attribute, log, endpoint) {
|
|
248
365
|
if (!endpoint)
|
|
249
366
|
endpoint = this;
|
|
@@ -257,15 +374,28 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
257
374
|
this.log.error(`getAttribute error: Attribute ${attribute} not found on Cluster ${clusterServer.name} on endpoint ${endpoint.name}:${endpoint.number}`);
|
|
258
375
|
return undefined;
|
|
259
376
|
}
|
|
377
|
+
// Find the getter method
|
|
378
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
260
379
|
if (!clusterServer[`get${capitalizedAttributeName}Attribute`]) {
|
|
261
380
|
this.log.error(`getAttribute error: Getter get${capitalizedAttributeName}Attribute not found on Cluster ${clusterServer.name} on endpoint ${endpoint.name}:${endpoint.number}`);
|
|
262
381
|
return undefined;
|
|
263
382
|
}
|
|
383
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-empty-object-type
|
|
264
384
|
const getter = clusterServer[`get${capitalizedAttributeName}Attribute`];
|
|
265
385
|
const value = getter();
|
|
266
386
|
log?.info(`${db}Get endpoint ${or}${endpoint.name}:${endpoint.number}${db} attribute ${hk}${clusterServer.name}.${capitalizedAttributeName}${db} value ${YELLOW}${typeof value === 'object' ? debugStringify(value) : value}${db}`);
|
|
267
387
|
return value;
|
|
268
388
|
}
|
|
389
|
+
/**
|
|
390
|
+
* Sets the value of an attribute on a cluster server endpoint.
|
|
391
|
+
*
|
|
392
|
+
* @param {ClusterId} clusterId - The ID of the cluster.
|
|
393
|
+
* @param {string} attribute - The name of the attribute.
|
|
394
|
+
* @param {any} value - The value to set for the attribute.
|
|
395
|
+
* @param {AnsiLogger} [log] - (Optional) The logger to use for logging errors and information.
|
|
396
|
+
* @param {Endpoint} [endpoint] - (Optional) The endpoint to set the attribute on. If not provided, the attribute will be set on the current endpoint.
|
|
397
|
+
*/
|
|
398
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
269
399
|
setAttribute(clusterId, attribute, value, log, endpoint) {
|
|
270
400
|
if (!endpoint)
|
|
271
401
|
endpoint = this;
|
|
@@ -279,15 +409,21 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
279
409
|
this.log.error(`setAttribute error: Attribute ${attribute} not found on Cluster ${clusterId} on endpoint ${endpoint.name}:${endpoint.number}`);
|
|
280
410
|
return false;
|
|
281
411
|
}
|
|
412
|
+
// Find the getter method
|
|
413
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
282
414
|
if (!clusterServer[`get${capitalizedAttributeName}Attribute`]) {
|
|
283
415
|
this.log.error(`setAttribute error: Getter get${capitalizedAttributeName}Attribute not found on Cluster ${clusterServer.name} on endpoint ${endpoint.name}:${endpoint.number}`);
|
|
284
416
|
return false;
|
|
285
417
|
}
|
|
418
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-empty-object-type
|
|
286
419
|
const getter = clusterServer[`get${capitalizedAttributeName}Attribute`];
|
|
420
|
+
// Find the setter method
|
|
421
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
287
422
|
if (!clusterServer[`set${capitalizedAttributeName}Attribute`]) {
|
|
288
423
|
this.log.error(`setAttribute error: Setter set${capitalizedAttributeName}Attribute not found on Cluster ${clusterServer.name} on endpoint ${endpoint.name}:${endpoint.number}`);
|
|
289
424
|
return false;
|
|
290
425
|
}
|
|
426
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-empty-object-type
|
|
291
427
|
const setter = clusterServer[`set${capitalizedAttributeName}Attribute`];
|
|
292
428
|
const oldValue = getter();
|
|
293
429
|
setter(value);
|
|
@@ -296,6 +432,17 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
296
432
|
`to ${YELLOW}${typeof value === 'object' ? debugStringify(value) : value}${db}`);
|
|
297
433
|
return true;
|
|
298
434
|
}
|
|
435
|
+
/**
|
|
436
|
+
* Subscribes to an attribute on a cluster.
|
|
437
|
+
*
|
|
438
|
+
* @param {ClusterId} clusterId - The ID of the cluster.
|
|
439
|
+
* @param {string} attribute - The name of the attribute to subscribe to.
|
|
440
|
+
* @param {(newValue: any, oldValue: any) => void} listener - A callback function that will be called when the attribute value changes.
|
|
441
|
+
* @param {AnsiLogger} log - (Optional) An AnsiLogger instance for logging errors and information.
|
|
442
|
+
* @param {Endpoint} endpoint - (Optional) The endpoint to subscribe the attribute on. If not provided, the current endpoint will be used.
|
|
443
|
+
* @returns A boolean indicating whether the subscription was successful.
|
|
444
|
+
*/
|
|
445
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
299
446
|
subscribeAttribute(clusterId, attribute, listener, log, endpoint) {
|
|
300
447
|
if (!endpoint)
|
|
301
448
|
endpoint = this;
|
|
@@ -309,15 +456,28 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
309
456
|
this.log.error(`subscribeAttribute error: Attribute ${attribute} not found on Cluster ${clusterServer.name} on endpoint ${endpoint.name}:${endpoint.number}`);
|
|
310
457
|
return false;
|
|
311
458
|
}
|
|
459
|
+
// Find the subscribe method
|
|
460
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
312
461
|
if (!clusterServer[`subscribe${capitalizedAttributeName}Attribute`]) {
|
|
313
462
|
this.log.error(`subscribeAttribute error: subscribe${capitalizedAttributeName}Attribute not found on Cluster ${clusterServer.name} on endpoint ${endpoint.name}:${endpoint.number}`);
|
|
314
463
|
return false;
|
|
315
464
|
}
|
|
465
|
+
// Subscribe to the attribute
|
|
466
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-empty-object-type
|
|
316
467
|
const subscribe = clusterServer[`subscribe${capitalizedAttributeName}Attribute`];
|
|
317
468
|
subscribe(listener);
|
|
318
469
|
log?.info(`${db}Subscribe endpoint ${or}${endpoint.name}:${endpoint.number}${db} attribute ${hk}${clusterServer.name}.${capitalizedAttributeName}${db}`);
|
|
319
470
|
return true;
|
|
320
471
|
}
|
|
472
|
+
/**
|
|
473
|
+
* Triggers the specified event of the specified cluster from the given endpoint and cluster.
|
|
474
|
+
*
|
|
475
|
+
* @param {ClusterId} clusterId - The ID of the cluster to retrieve the event from.
|
|
476
|
+
* @param {string} event - The name of the event to trigger.
|
|
477
|
+
* @param {Record<string, any>} payload - The payload of the event to trigger.
|
|
478
|
+
* @param {AnsiLogger} [log] - Optional logger for error and info messages.
|
|
479
|
+
* @param {Endpoint} [endpoint] - Optional the child endpoint to retrieve the event from.
|
|
480
|
+
*/
|
|
321
481
|
triggerEvent(clusterId, event, payload, log, endpoint) {
|
|
322
482
|
if (!endpoint)
|
|
323
483
|
endpoint = this;
|
|
@@ -333,20 +493,43 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
333
493
|
this.log.error(`triggerEvent error: Event ${event} not found on Cluster ${clusterServer.name} on endpoint ${endpoint.name}:${endpoint.number}`);
|
|
334
494
|
return;
|
|
335
495
|
}
|
|
496
|
+
// Find the getter method
|
|
497
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
336
498
|
if (!clusterServer[`trigger${capitalizedEventName}Event`]) {
|
|
337
499
|
this.log.error(`triggerEvent error: Trigger trigger${capitalizedEventName}Event not found on Cluster ${clusterServer.name} on endpoint ${endpoint.name}:${endpoint.number}`);
|
|
338
500
|
return;
|
|
339
501
|
}
|
|
502
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-empty-object-type
|
|
340
503
|
const trigger = clusterServer[`trigger${capitalizedEventName}Event`];
|
|
341
504
|
trigger(payload);
|
|
342
505
|
log?.info(`${db}Trigger event ${hk}${clusterServer.name}.${capitalizedEventName}${db} on endpoint ${or}${endpoint.name}:${endpoint.number}${db}`);
|
|
343
506
|
}
|
|
507
|
+
/**
|
|
508
|
+
* Adds a tag to the tag list of the specified endpoint.
|
|
509
|
+
*
|
|
510
|
+
* @param {Endpoint} endpoint - The endpoint to add the tag to.
|
|
511
|
+
* @param {VendorId | null} mfgCode - The manufacturer code.
|
|
512
|
+
* @param {number} namespaceId - The namespace ID of the tag.
|
|
513
|
+
* @param {number} tag - The tag number.
|
|
514
|
+
* @param {string | null} [label=null] - The label for the tag.
|
|
515
|
+
*
|
|
516
|
+
* @remarks
|
|
517
|
+
* This method is used to add a tag to the tag list of a given endpoint.
|
|
518
|
+
* If the tag list already exists, the new tag is added to the existing list. Otherwise, a new tag list is created with the provided tag.
|
|
519
|
+
*
|
|
520
|
+
* Example usage:
|
|
521
|
+
* ```typescript
|
|
522
|
+
* this.addTagList(endpoint, null, NumberTag.One.namespaceId, NumberTag.One.tag, 'Label');
|
|
523
|
+
* this.addTagList(endpoint, null, SwitchesTag.Custom.namespaceId, SwitchesTag.Custom.tag, 'Label');
|
|
524
|
+
* ```
|
|
525
|
+
*/
|
|
344
526
|
addTagList(endpoint, mfgCode, namespaceId, tag, label) {
|
|
345
527
|
const descriptor = endpoint.getClusterServer(DescriptorCluster.with(Descriptor.Feature.TagList));
|
|
346
528
|
if (!descriptor) {
|
|
347
529
|
this.log.error(`addTagList: descriptor cluster not found on endpoint ${endpoint.name}:${endpoint.number}`);
|
|
348
530
|
return;
|
|
349
531
|
}
|
|
532
|
+
// tagList: { mfgCode: VendorId | null; namespaceId: number; tag: number; label?: string | null }[] = [];
|
|
350
533
|
if (descriptor.attributes.tagList) {
|
|
351
534
|
this.log.debug(`addTagList: adding ${CYAN}tagList${db} mfCode: ${mfgCode}, namespaceId: ${namespaceId}, tag: ${tag}, label: ${label} on endpoint ${endpoint.name}:${endpoint.number}`);
|
|
352
535
|
const tagList = descriptor.attributes.tagList.getLocal();
|
|
@@ -362,6 +545,12 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
362
545
|
partsList: [...descriptor.attributes.partsList.getLocal()],
|
|
363
546
|
}, {}, {}));
|
|
364
547
|
}
|
|
548
|
+
/**
|
|
549
|
+
* Serializes the Matterbridge device into a serialized object.
|
|
550
|
+
*
|
|
551
|
+
* @param pluginName - The name of the plugin.
|
|
552
|
+
* @returns The serialized Matterbridge device object.
|
|
553
|
+
*/
|
|
365
554
|
serialize() {
|
|
366
555
|
if (!this.serialNumber || !this.deviceName || !this.uniqueId)
|
|
367
556
|
return;
|
|
@@ -386,6 +575,11 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
386
575
|
});
|
|
387
576
|
return serialized;
|
|
388
577
|
}
|
|
578
|
+
/**
|
|
579
|
+
* Deserializes the device into a serialized object.
|
|
580
|
+
*
|
|
581
|
+
* @returns The deserialized MatterbridgeDevice.
|
|
582
|
+
*/
|
|
389
583
|
static deserialize(serializedDevice) {
|
|
390
584
|
const device = new MatterbridgeDevice(serializedDevice.deviceTypes);
|
|
391
585
|
device.serialNumber = serializedDevice.serialNumber;
|
|
@@ -401,6 +595,9 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
401
595
|
}
|
|
402
596
|
return device;
|
|
403
597
|
}
|
|
598
|
+
/**
|
|
599
|
+
* Get a default IdentifyCluster server.
|
|
600
|
+
*/
|
|
404
601
|
getDefaultIdentifyClusterServer(identifyTime = 0, identifyType = Identify.IdentifyType.None) {
|
|
405
602
|
return ClusterServer(IdentifyCluster, {
|
|
406
603
|
identifyTime,
|
|
@@ -416,28 +613,88 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
416
613
|
},
|
|
417
614
|
});
|
|
418
615
|
}
|
|
616
|
+
/**
|
|
617
|
+
* Creates a default IdentifyCluster server.
|
|
618
|
+
*/
|
|
419
619
|
createDefaultIdentifyClusterServer(identifyTime = 0, identifyType = Identify.IdentifyType.None) {
|
|
420
620
|
this.addClusterServer(this.getDefaultIdentifyClusterServer(identifyTime, identifyType));
|
|
421
621
|
}
|
|
622
|
+
/**
|
|
623
|
+
* Get a default IdentifyCluster server.
|
|
624
|
+
*/
|
|
422
625
|
getDefaultGroupsClusterServer() {
|
|
423
626
|
return ClusterServer(GroupsCluster, {
|
|
424
627
|
nameSupport: {
|
|
425
628
|
nameSupport: true,
|
|
426
629
|
},
|
|
427
630
|
}, GroupsClusterHandler());
|
|
631
|
+
// return createDefaultGroupsClusterServer();
|
|
428
632
|
}
|
|
633
|
+
/**
|
|
634
|
+
* Creates a default groups cluster server and adds it to the device.
|
|
635
|
+
*/
|
|
429
636
|
createDefaultGroupsClusterServer() {
|
|
430
637
|
this.addClusterServer(this.getDefaultGroupsClusterServer());
|
|
431
638
|
}
|
|
639
|
+
/**
|
|
640
|
+
* Get a default scenes cluster server and adds it to the current instance.
|
|
641
|
+
* @deprecated This method is deprecated.
|
|
642
|
+
*
|
|
643
|
+
*/
|
|
432
644
|
getDefaultScenesClusterServer() {
|
|
433
|
-
|
|
645
|
+
/*
|
|
646
|
+
return ClusterServer(
|
|
647
|
+
ScenesCluster,
|
|
648
|
+
{
|
|
649
|
+
sceneCount: 0,
|
|
650
|
+
currentScene: 0,
|
|
651
|
+
currentGroup: GroupId(0),
|
|
652
|
+
sceneValid: false,
|
|
653
|
+
nameSupport: {
|
|
654
|
+
nameSupport: true,
|
|
655
|
+
},
|
|
656
|
+
lastConfiguredBy: null,
|
|
657
|
+
},
|
|
658
|
+
{},
|
|
659
|
+
);
|
|
660
|
+
*/
|
|
661
|
+
}
|
|
662
|
+
/**
|
|
663
|
+
* Creates a default scenes cluster server and adds it to the current instance.
|
|
664
|
+
* @deprecated This method is deprecated.
|
|
665
|
+
*/
|
|
434
666
|
createDefaultScenesClusterServer() {
|
|
435
|
-
|
|
667
|
+
/*
|
|
668
|
+
this.addClusterServer(this.getDefaultScenesClusterServer());
|
|
669
|
+
*/
|
|
670
|
+
}
|
|
671
|
+
/**
|
|
672
|
+
* Creates a unique identifier based on the provided parameters.
|
|
673
|
+
* @param param1 - The first parameter.
|
|
674
|
+
* @param param2 - The second parameter.
|
|
675
|
+
* @param param3 - The third parameter.
|
|
676
|
+
* @param param4 - The fourth parameter.
|
|
677
|
+
* @returns A unique identifier generated using the MD5 hash algorithm.
|
|
678
|
+
*/
|
|
436
679
|
createUniqueId(param1, param2, param3, param4) {
|
|
437
680
|
const hash = createHash('md5');
|
|
438
681
|
hash.update(param1 + param2 + param3 + param4);
|
|
439
682
|
return hash.digest('hex');
|
|
440
683
|
}
|
|
684
|
+
/**
|
|
685
|
+
* Get a default Basic Information Cluster Server.
|
|
686
|
+
*
|
|
687
|
+
* @param deviceName - The name of the device.
|
|
688
|
+
* @param serialNumber - The serial number of the device.
|
|
689
|
+
* @param vendorId - The vendor ID of the device.
|
|
690
|
+
* @param vendorName - The vendor name of the device.
|
|
691
|
+
* @param productId - The product ID of the device.
|
|
692
|
+
* @param productName - The product name of the device.
|
|
693
|
+
* @param softwareVersion - The software version of the device. Default is 1.
|
|
694
|
+
* @param softwareVersionString - The software version string of the device. Default is 'v.1.0.0'.
|
|
695
|
+
* @param hardwareVersion - The hardware version of the device. Default is 1.
|
|
696
|
+
* @param hardwareVersionString - The hardware version string of the device. Default is 'v.1.0.0'.
|
|
697
|
+
*/
|
|
441
698
|
getDefaultBasicInformationClusterServer(deviceName, serialNumber, vendorId, vendorName, productId, productName, softwareVersion = 1, softwareVersionString = '1.0.0', hardwareVersion = 1, hardwareVersionString = '1.0.0') {
|
|
442
699
|
this.log.logName = deviceName;
|
|
443
700
|
this.deviceName = deviceName;
|
|
@@ -477,6 +734,20 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
477
734
|
reachableChanged: true,
|
|
478
735
|
});
|
|
479
736
|
}
|
|
737
|
+
/**
|
|
738
|
+
* Creates a default Basic Information Cluster Server.
|
|
739
|
+
*
|
|
740
|
+
* @param deviceName - The name of the device.
|
|
741
|
+
* @param serialNumber - The serial number of the device.
|
|
742
|
+
* @param vendorId - The vendor ID of the device.
|
|
743
|
+
* @param vendorName - The vendor name of the device.
|
|
744
|
+
* @param productId - The product ID of the device.
|
|
745
|
+
* @param productName - The product name of the device.
|
|
746
|
+
* @param softwareVersion - The software version of the device. Default is 1.
|
|
747
|
+
* @param softwareVersionString - The software version string of the device. Default is 'v.1.0.0'.
|
|
748
|
+
* @param hardwareVersion - The hardware version of the device. Default is 1.
|
|
749
|
+
* @param hardwareVersionString - The hardware version string of the device. Default is 'v.1.0.0'.
|
|
750
|
+
*/
|
|
480
751
|
createDefaultBasicInformationClusterServer(deviceName, serialNumber, vendorId, vendorName, productId, productName, softwareVersion = 1, softwareVersionString = '1.0.0', hardwareVersion = 1, hardwareVersionString = '1.0.0') {
|
|
481
752
|
if (MatterbridgeDevice.bridgeMode === 'bridge') {
|
|
482
753
|
this.addDeviceType(bridgedNode);
|
|
@@ -485,6 +756,19 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
485
756
|
}
|
|
486
757
|
this.addClusterServer(this.getDefaultBasicInformationClusterServer(deviceName, serialNumber, vendorId, vendorName, productId, productName, softwareVersion, softwareVersionString, hardwareVersion, hardwareVersionString));
|
|
487
758
|
}
|
|
759
|
+
/**
|
|
760
|
+
* Get a default BridgedDeviceBasicInformationClusterServer.
|
|
761
|
+
*
|
|
762
|
+
* @param deviceName - The name of the device.
|
|
763
|
+
* @param serialNumber - The serial number of the device.
|
|
764
|
+
* @param vendorId - The vendor ID of the device.
|
|
765
|
+
* @param vendorName - The name of the vendor.
|
|
766
|
+
* @param productName - The name of the product.
|
|
767
|
+
* @param softwareVersion - The software version of the device. Default is 1.
|
|
768
|
+
* @param softwareVersionString - The software version string of the device. Default is 'v.1.0.0'.
|
|
769
|
+
* @param hardwareVersion - The hardware version of the device. Default is 1.
|
|
770
|
+
* @param hardwareVersionString - The hardware version string of the device. Default is 'v.1.0.0'.
|
|
771
|
+
*/
|
|
488
772
|
getDefaultBridgedDeviceBasicInformationClusterServer(deviceName, serialNumber, vendorId, vendorName, productName, softwareVersion = 1, softwareVersionString = '1.0.0', hardwareVersion = 1, hardwareVersionString = '1.0.0') {
|
|
489
773
|
this.log.logName = deviceName;
|
|
490
774
|
this.deviceName = deviceName;
|
|
@@ -499,7 +783,7 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
499
783
|
this.hardwareVersion = hardwareVersion;
|
|
500
784
|
this.hardwareVersionString = hardwareVersionString;
|
|
501
785
|
return ClusterServer(BridgedDeviceBasicInformationCluster, {
|
|
502
|
-
vendorId: vendorId !== undefined ? VendorId(vendorId) : undefined,
|
|
786
|
+
vendorId: vendorId !== undefined ? VendorId(vendorId) : undefined, // 4874
|
|
503
787
|
vendorName: vendorName.slice(0, 32),
|
|
504
788
|
productName: productName.slice(0, 32),
|
|
505
789
|
productLabel: deviceName.slice(0, 64),
|
|
@@ -518,12 +802,36 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
518
802
|
reachableChanged: true,
|
|
519
803
|
});
|
|
520
804
|
}
|
|
805
|
+
/**
|
|
806
|
+
* Creates a default BridgedDeviceBasicInformationClusterServer.
|
|
807
|
+
*
|
|
808
|
+
* @param deviceName - The name of the device.
|
|
809
|
+
* @param serialNumber - The serial number of the device.
|
|
810
|
+
* @param vendorId - The vendor ID of the device.
|
|
811
|
+
* @param vendorName - The name of the vendor.
|
|
812
|
+
* @param productName - The name of the product.
|
|
813
|
+
* @param softwareVersion - The software version of the device. Default is 1.
|
|
814
|
+
* @param softwareVersionString - The software version string of the device. Default is 'v.1.0.0'.
|
|
815
|
+
* @param hardwareVersion - The hardware version of the device. Default is 1.
|
|
816
|
+
* @param hardwareVersionString - The hardware version string of the device. Default is 'v.1.0.0'.
|
|
817
|
+
*/
|
|
521
818
|
createDefaultBridgedDeviceBasicInformationClusterServer(deviceName, serialNumber, vendorId, vendorName, productName, softwareVersion = 1, softwareVersionString = '1.0.0', hardwareVersion = 1, hardwareVersionString = '1.0.0') {
|
|
522
819
|
this.addClusterServer(this.getDefaultBridgedDeviceBasicInformationClusterServer(deviceName, serialNumber, vendorId, vendorName, productName, softwareVersion, softwareVersionString, hardwareVersion, hardwareVersionString));
|
|
523
820
|
}
|
|
821
|
+
/**
|
|
822
|
+
* Get a default Power Topology Cluster Server.
|
|
823
|
+
*
|
|
824
|
+
* @returns {ClusterServer} - The configured Power Topology Cluster Server.
|
|
825
|
+
*/
|
|
524
826
|
getDefaultPowerTopologyClusterServer() {
|
|
525
827
|
return ClusterServer(PowerTopologyCluster.with(PowerTopology.Feature.TreeTopology), {}, {}, {});
|
|
526
828
|
}
|
|
829
|
+
/**
|
|
830
|
+
* Get a default Electrical Energy Measurement Cluster Server.
|
|
831
|
+
*
|
|
832
|
+
* @param {number} energy - The total consumption value in mW/h.
|
|
833
|
+
* @returns {ClusterServer} - The configured Electrical Energy Measurement Cluster Server.
|
|
834
|
+
*/
|
|
527
835
|
getDefaultElectricalEnergyMeasurementClusterServer(energy = null) {
|
|
528
836
|
return ClusterServer(ElectricalEnergyMeasurementCluster.with(ElectricalEnergyMeasurement.Feature.ImportedEnergy, ElectricalEnergyMeasurement.Feature.ExportedEnergy, ElectricalEnergyMeasurement.Feature.CumulativeEnergy), {
|
|
529
837
|
accuracy: {
|
|
@@ -540,6 +848,15 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
540
848
|
cumulativeEnergyMeasured: true,
|
|
541
849
|
});
|
|
542
850
|
}
|
|
851
|
+
/**
|
|
852
|
+
* Get a default Electrical Power Measurement Cluster Server.
|
|
853
|
+
*
|
|
854
|
+
* @param {number} voltage - The voltage value in millivolts.
|
|
855
|
+
* @param {number} current - The current value in milliamperes.
|
|
856
|
+
* @param {number} power - The power value in milliwatts.
|
|
857
|
+
* @param {number} frequency - The frequency value in millihertz.
|
|
858
|
+
* @returns {ClusterServer} - The configured Electrical Power Measurement Cluster Server.
|
|
859
|
+
*/
|
|
543
860
|
getDefaultElectricalPowerMeasurementClusterServer(voltage = null, current = null, power = null, frequency = null) {
|
|
544
861
|
return ClusterServer(ElectricalPowerMeasurementCluster.with(ElectricalPowerMeasurement.Feature.AlternatingCurrent), {
|
|
545
862
|
powerMode: ElectricalPowerMeasurement.PowerMode.Ac,
|
|
@@ -580,6 +897,15 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
580
897
|
frequency: frequency,
|
|
581
898
|
}, {}, {});
|
|
582
899
|
}
|
|
900
|
+
/**
|
|
901
|
+
* Creates a default Dummy Thread Network Diagnostics Cluster server.
|
|
902
|
+
* @deprecated This method is deprecated and is only used for testing.
|
|
903
|
+
*
|
|
904
|
+
* @remarks
|
|
905
|
+
* This method adds a cluster server used only to give the networkName to Eve app.
|
|
906
|
+
*
|
|
907
|
+
* @returns void
|
|
908
|
+
*/
|
|
583
909
|
createDefaultDummyThreadNetworkDiagnosticsClusterServer() {
|
|
584
910
|
this.addClusterServer(ClusterServer(ThreadNetworkDiagnosticsCluster.with(ThreadNetworkDiagnostics.Feature.PacketCounts, ThreadNetworkDiagnostics.Feature.ErrorCounts), {
|
|
585
911
|
channel: 1,
|
|
@@ -607,6 +933,11 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
607
933
|
},
|
|
608
934
|
}, {}));
|
|
609
935
|
}
|
|
936
|
+
/**
|
|
937
|
+
* Get a default OnOff cluster server.
|
|
938
|
+
*
|
|
939
|
+
* @param onOff - The initial state of the OnOff cluster (default: false).
|
|
940
|
+
*/
|
|
610
941
|
getDefaultOnOffClusterServer(onOff = false) {
|
|
611
942
|
return ClusterServer(OnOffCluster, {
|
|
612
943
|
onOff,
|
|
@@ -625,9 +956,22 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
625
956
|
},
|
|
626
957
|
}, {});
|
|
627
958
|
}
|
|
959
|
+
/**
|
|
960
|
+
* Creates a default OnOff cluster server.
|
|
961
|
+
*
|
|
962
|
+
* @param onOff - The initial state of the OnOff cluster (default: false).
|
|
963
|
+
*/
|
|
628
964
|
createDefaultOnOffClusterServer(onOff = false) {
|
|
629
965
|
this.addClusterServer(this.getDefaultOnOffClusterServer(onOff));
|
|
630
966
|
}
|
|
967
|
+
/**
|
|
968
|
+
* Get a default level control cluster server.
|
|
969
|
+
*
|
|
970
|
+
* @param currentLevel - The current level (default: 254).
|
|
971
|
+
* @param minLevel - The minimum level (default: 0).
|
|
972
|
+
* @param maxLevel - The maximum level (default: 254).
|
|
973
|
+
* @param onLevel - The on level (default: null).
|
|
974
|
+
*/
|
|
631
975
|
getDefaultLevelControlClusterServer(currentLevel = 254, minLevel = 0, maxLevel = 254, onLevel = null) {
|
|
632
976
|
return ClusterServer(LevelControlCluster.with(LevelControl.Feature.OnOff), {
|
|
633
977
|
currentLevel,
|
|
@@ -667,9 +1011,28 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
667
1011
|
},
|
|
668
1012
|
});
|
|
669
1013
|
}
|
|
1014
|
+
/**
|
|
1015
|
+
* Creates a default level control cluster server.
|
|
1016
|
+
*
|
|
1017
|
+
* @param currentLevel - The current level (default: 254).
|
|
1018
|
+
* @param minLevel - The minimum level (default: 0).
|
|
1019
|
+
* @param maxLevel - The maximum level (default: 254).
|
|
1020
|
+
* @param onLevel - The on level (default: null).
|
|
1021
|
+
*/
|
|
670
1022
|
createDefaultLevelControlClusterServer(currentLevel = 254, minLevel = 0, maxLevel = 254, onLevel = null) {
|
|
671
1023
|
this.addClusterServer(this.getDefaultLevelControlClusterServer(currentLevel, minLevel, maxLevel, onLevel));
|
|
672
1024
|
}
|
|
1025
|
+
/**
|
|
1026
|
+
* Get a default color control cluster server.
|
|
1027
|
+
*
|
|
1028
|
+
* @param currentX - The current X value.
|
|
1029
|
+
* @param currentY - The current Y value.
|
|
1030
|
+
* @param currentHue - The current hue value.
|
|
1031
|
+
* @param currentSaturation - The current saturation value.
|
|
1032
|
+
* @param colorTemperatureMireds - The color temperature in mireds.
|
|
1033
|
+
* @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds.
|
|
1034
|
+
* @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds.
|
|
1035
|
+
*/
|
|
673
1036
|
getDefaultColorControlClusterServer(currentX = 0, currentY = 0, currentHue = 0, currentSaturation = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
|
|
674
1037
|
return ClusterServer(ColorControlCluster.with(ColorControl.Feature.Xy, ColorControl.Feature.HueSaturation, ColorControl.Feature.ColorTemperature), {
|
|
675
1038
|
colorMode: ColorControl.ColorMode.CurrentHueAndCurrentSaturation,
|
|
@@ -736,9 +1099,26 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
736
1099
|
},
|
|
737
1100
|
}, {});
|
|
738
1101
|
}
|
|
1102
|
+
/**
|
|
1103
|
+
* Creates a default color control cluster server.
|
|
1104
|
+
*
|
|
1105
|
+
* @param currentX - The current X value.
|
|
1106
|
+
* @param currentY - The current Y value.
|
|
1107
|
+
* @param currentHue - The current hue value.
|
|
1108
|
+
* @param currentSaturation - The current saturation value.
|
|
1109
|
+
* @param colorTemperatureMireds - The color temperature in mireds.
|
|
1110
|
+
* @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds.
|
|
1111
|
+
* @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds.
|
|
1112
|
+
*/
|
|
739
1113
|
createDefaultColorControlClusterServer(currentX = 0, currentY = 0, currentHue = 0, currentSaturation = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
|
|
740
1114
|
this.addClusterServer(this.getDefaultColorControlClusterServer(currentX, currentY, currentHue, currentSaturation, colorTemperatureMireds, colorTempPhysicalMinMireds, colorTempPhysicalMaxMireds));
|
|
741
1115
|
}
|
|
1116
|
+
/**
|
|
1117
|
+
* Get a Xy color control cluster server.
|
|
1118
|
+
*
|
|
1119
|
+
* @param currentX - The current X value.
|
|
1120
|
+
* @param currentY - The current Y value.
|
|
1121
|
+
*/
|
|
742
1122
|
getXyColorControlClusterServer(currentX = 0, currentY = 0) {
|
|
743
1123
|
return ClusterServer(ColorControlCluster.with(ColorControl.Feature.Xy), {
|
|
744
1124
|
colorMode: ColorControl.ColorMode.CurrentXAndCurrentY,
|
|
@@ -766,9 +1146,21 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
766
1146
|
},
|
|
767
1147
|
}, {});
|
|
768
1148
|
}
|
|
1149
|
+
/**
|
|
1150
|
+
* Creates a Xy color control cluster server.
|
|
1151
|
+
*
|
|
1152
|
+
* @param currentX - The current X value.
|
|
1153
|
+
* @param currentY - The current Y value.
|
|
1154
|
+
*/
|
|
769
1155
|
createXyControlClusterServer(currentX = 0, currentY = 0) {
|
|
770
1156
|
this.addClusterServer(this.getXyColorControlClusterServer(currentX, currentY));
|
|
771
1157
|
}
|
|
1158
|
+
/**
|
|
1159
|
+
* Get a default hue and saturation control cluster server.
|
|
1160
|
+
*
|
|
1161
|
+
* @param currentHue - The current hue value.
|
|
1162
|
+
* @param currentSaturation - The current saturation value.
|
|
1163
|
+
*/
|
|
772
1164
|
getHsColorControlClusterServer(currentHue = 0, currentSaturation = 0) {
|
|
773
1165
|
return ClusterServer(ColorControlCluster.with(ColorControl.Feature.HueSaturation), {
|
|
774
1166
|
colorMode: ColorControl.ColorMode.CurrentHueAndCurrentSaturation,
|
|
@@ -810,9 +1202,22 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
810
1202
|
},
|
|
811
1203
|
}, {});
|
|
812
1204
|
}
|
|
1205
|
+
/**
|
|
1206
|
+
* Creates a hue and saturation color control cluster server.
|
|
1207
|
+
*
|
|
1208
|
+
* @param currentHue - The current hue value.
|
|
1209
|
+
* @param currentSaturation - The current saturation value.
|
|
1210
|
+
*/
|
|
813
1211
|
createHsColorControlClusterServer(currentHue = 0, currentSaturation = 0) {
|
|
814
1212
|
this.addClusterServer(this.getHsColorControlClusterServer(currentHue, currentSaturation));
|
|
815
1213
|
}
|
|
1214
|
+
/**
|
|
1215
|
+
* Get a color temperature color control cluster server.
|
|
1216
|
+
*
|
|
1217
|
+
* @param colorTemperatureMireds - The color temperature in mireds.
|
|
1218
|
+
* @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds.
|
|
1219
|
+
* @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds.
|
|
1220
|
+
*/
|
|
816
1221
|
getCtColorControlClusterServer(colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
|
|
817
1222
|
return ClusterServer(ColorControlCluster.with(ColorControl.Feature.ColorTemperature), {
|
|
818
1223
|
colorMode: ColorControl.ColorMode.ColorTemperatureMireds,
|
|
@@ -841,9 +1246,28 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
841
1246
|
},
|
|
842
1247
|
}, {});
|
|
843
1248
|
}
|
|
1249
|
+
/**
|
|
1250
|
+
* Creates a color temperature color control cluster server.
|
|
1251
|
+
*
|
|
1252
|
+
* @param colorTemperatureMireds - The color temperature in mireds.
|
|
1253
|
+
* @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds.
|
|
1254
|
+
* @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds.
|
|
1255
|
+
*/
|
|
844
1256
|
createCtColorControlClusterServer(colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
|
|
845
1257
|
this.addClusterServer(this.getCtColorControlClusterServer(colorTemperatureMireds, colorTempPhysicalMinMireds, colorTempPhysicalMaxMireds));
|
|
846
1258
|
}
|
|
1259
|
+
/**
|
|
1260
|
+
* Configures the color control cluster for a device.
|
|
1261
|
+
*
|
|
1262
|
+
* @remark This method must be called only after creating the cluster with getDefaultCompleteColorControlClusterServer or createDefaultCompleteColorControlClusterServer
|
|
1263
|
+
* and before starting the matter server.
|
|
1264
|
+
*
|
|
1265
|
+
* @param {boolean} hueSaturation - A boolean indicating whether the device supports hue and saturation control.
|
|
1266
|
+
* @param {boolean} xy - A boolean indicating whether the device supports XY control.
|
|
1267
|
+
* @param {boolean} colorTemperature - A boolean indicating whether the device supports color temperature control.
|
|
1268
|
+
* @param {ColorControl.ColorMode} colorMode - An optional parameter specifying the color mode of the device.
|
|
1269
|
+
* @param {Endpoint} endpoint - An optional parameter specifying the endpoint to configure. If not provided, the device endpoint will be used.
|
|
1270
|
+
*/
|
|
847
1271
|
configureColorControlCluster(hueSaturation, xy, colorTemperature, colorMode, endpoint) {
|
|
848
1272
|
if (!endpoint)
|
|
849
1273
|
endpoint = this;
|
|
@@ -854,6 +1278,12 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
854
1278
|
endpoint.getClusterServer(ColorControlCluster)?.setEnhancedColorModeAttribute(colorMode);
|
|
855
1279
|
}
|
|
856
1280
|
}
|
|
1281
|
+
/**
|
|
1282
|
+
* Configures the color control mode for the device.
|
|
1283
|
+
*
|
|
1284
|
+
* @param {ColorControl.ColorMode} colorMode - The color mode to set.
|
|
1285
|
+
* @param {Endpoint} endpoint - The optional endpoint to configure. If not provided, the method will configure the current endpoint.
|
|
1286
|
+
*/
|
|
857
1287
|
configureColorControlMode(colorMode, endpoint) {
|
|
858
1288
|
if (!endpoint)
|
|
859
1289
|
endpoint = this;
|
|
@@ -862,8 +1292,13 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
862
1292
|
endpoint.getClusterServer(ColorControlCluster)?.setEnhancedColorModeAttribute(colorMode);
|
|
863
1293
|
}
|
|
864
1294
|
}
|
|
1295
|
+
/**
|
|
1296
|
+
* Get a default window covering cluster server.
|
|
1297
|
+
*
|
|
1298
|
+
* @param positionPercent100ths - The position percentage in 100ths (0-10000). Defaults to 0.
|
|
1299
|
+
*/
|
|
865
1300
|
getDefaultWindowCoveringClusterServer(positionPercent100ths) {
|
|
866
|
-
return ClusterServer(WindowCoveringCluster.with(WindowCovering.Feature.Lift, WindowCovering.Feature.PositionAwareLift), {
|
|
1301
|
+
return ClusterServer(WindowCoveringCluster.with(WindowCovering.Feature.Lift, WindowCovering.Feature.PositionAwareLift /* , WindowCovering.Feature.AbsolutePosition*/), {
|
|
867
1302
|
type: WindowCovering.WindowCoveringType.Rollershade,
|
|
868
1303
|
configStatus: {
|
|
869
1304
|
operational: true,
|
|
@@ -877,8 +1312,10 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
877
1312
|
operationalStatus: { global: WindowCovering.MovementStatus.Stopped, lift: WindowCovering.MovementStatus.Stopped, tilt: WindowCovering.MovementStatus.Stopped },
|
|
878
1313
|
endProductType: WindowCovering.EndProductType.RollerShade,
|
|
879
1314
|
mode: { motorDirectionReversed: false, calibrationMode: false, maintenanceMode: false, ledFeedback: false },
|
|
880
|
-
targetPositionLiftPercent100ths: positionPercent100ths ?? 0,
|
|
881
|
-
currentPositionLiftPercent100ths: positionPercent100ths ?? 0,
|
|
1315
|
+
targetPositionLiftPercent100ths: positionPercent100ths ?? 0, // 0 Fully open 10000 fully closed
|
|
1316
|
+
currentPositionLiftPercent100ths: positionPercent100ths ?? 0, // 0 Fully open 10000 fully closed
|
|
1317
|
+
// installedClosedLimitLift: 10000,
|
|
1318
|
+
// installedOpenLimitLift: 0,
|
|
882
1319
|
}, {
|
|
883
1320
|
upOrOpen: async (data) => {
|
|
884
1321
|
this.log.debug('Matter command: upOrOpen');
|
|
@@ -899,9 +1336,18 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
899
1336
|
},
|
|
900
1337
|
}, {});
|
|
901
1338
|
}
|
|
1339
|
+
/**
|
|
1340
|
+
* Creates a default window covering cluster server.
|
|
1341
|
+
*
|
|
1342
|
+
* @param positionPercent100ths - The position percentage in 100ths (0-10000). Defaults to 0.
|
|
1343
|
+
*/
|
|
902
1344
|
createDefaultWindowCoveringClusterServer(positionPercent100ths) {
|
|
903
1345
|
this.addClusterServer(this.getDefaultWindowCoveringClusterServer(positionPercent100ths));
|
|
904
1346
|
}
|
|
1347
|
+
/**
|
|
1348
|
+
* Sets the window covering target position as the current position and stops the movement.
|
|
1349
|
+
* @param {Endpoint} endpoint - The endpoint on which to set the window covering (default the device endpoint).
|
|
1350
|
+
*/
|
|
905
1351
|
setWindowCoveringTargetAsCurrentAndStopped(endpoint) {
|
|
906
1352
|
if (!endpoint)
|
|
907
1353
|
endpoint = this;
|
|
@@ -919,6 +1365,13 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
919
1365
|
this.log.debug(`Set WindowCovering currentPositionLiftPercent100ths and targetPositionLiftPercent100ths to ${position} and operationalStatus to Stopped.`);
|
|
920
1366
|
}
|
|
921
1367
|
}
|
|
1368
|
+
/**
|
|
1369
|
+
* Sets the current and target status of a window covering.
|
|
1370
|
+
* @param {number} current - The current position of the window covering.
|
|
1371
|
+
* @param {number} target - The target position of the window covering.
|
|
1372
|
+
* @param {WindowCovering.MovementStatus} status - The movement status of the window covering.
|
|
1373
|
+
* @param {Endpoint} endpoint - The endpoint on which to set the window covering (default the device endpoint).
|
|
1374
|
+
*/
|
|
922
1375
|
setWindowCoveringCurrentTargetStatus(current, target, status, endpoint) {
|
|
923
1376
|
if (!endpoint)
|
|
924
1377
|
endpoint = this;
|
|
@@ -934,6 +1387,11 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
934
1387
|
}
|
|
935
1388
|
this.log.debug(`Set WindowCovering currentPositionLiftPercent100ths: ${current}, targetPositionLiftPercent100ths: ${target} and operationalStatus: ${status}.`);
|
|
936
1389
|
}
|
|
1390
|
+
/**
|
|
1391
|
+
* Sets the status of the window covering.
|
|
1392
|
+
* @param {WindowCovering.MovementStatus} status - The movement status to set.
|
|
1393
|
+
* @param {Endpoint} endpoint - The endpoint on which to set the window covering (default the device endpoint).
|
|
1394
|
+
*/
|
|
937
1395
|
setWindowCoveringStatus(status, endpoint) {
|
|
938
1396
|
if (!endpoint)
|
|
939
1397
|
endpoint = this;
|
|
@@ -943,6 +1401,12 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
943
1401
|
windowCovering.setOperationalStatusAttribute({ global: status, lift: status, tilt: status });
|
|
944
1402
|
this.log.debug(`Set WindowCovering operationalStatus: ${status}`);
|
|
945
1403
|
}
|
|
1404
|
+
/**
|
|
1405
|
+
* Retrieves the status of the window covering.
|
|
1406
|
+
* @param {Endpoint} endpoint - The endpoint on which to get the window covering (default the device endpoint).
|
|
1407
|
+
*
|
|
1408
|
+
* @returns The global operational status of the window covering.
|
|
1409
|
+
*/
|
|
946
1410
|
getWindowCoveringStatus(endpoint) {
|
|
947
1411
|
if (!endpoint)
|
|
948
1412
|
endpoint = this;
|
|
@@ -953,6 +1417,12 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
953
1417
|
this.log.debug(`Get WindowCovering operationalStatus: ${status.global}`);
|
|
954
1418
|
return status.global;
|
|
955
1419
|
}
|
|
1420
|
+
/**
|
|
1421
|
+
* Sets the target and current position of the window covering.
|
|
1422
|
+
*
|
|
1423
|
+
* @param position - The position to set, specified as a number.
|
|
1424
|
+
* @param {Endpoint} endpoint - The endpoint on which to set the window covering (default the device endpoint).
|
|
1425
|
+
*/
|
|
956
1426
|
setWindowCoveringTargetAndCurrentPosition(position, endpoint) {
|
|
957
1427
|
if (!endpoint)
|
|
958
1428
|
endpoint = this;
|
|
@@ -963,6 +1433,13 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
963
1433
|
windowCovering.setTargetPositionLiftPercent100thsAttribute(position);
|
|
964
1434
|
this.log.debug(`Set WindowCovering currentPositionLiftPercent100ths: ${position} and targetPositionLiftPercent100ths: ${position}.`);
|
|
965
1435
|
}
|
|
1436
|
+
/**
|
|
1437
|
+
* Get a default door lock cluster server.
|
|
1438
|
+
*
|
|
1439
|
+
* @remarks
|
|
1440
|
+
* This method adds a cluster server for a door lock cluster with default settings.
|
|
1441
|
+
*
|
|
1442
|
+
*/
|
|
966
1443
|
getDefaultDoorLockClusterServer(lockState = DoorLock.LockState.Locked, lockType = DoorLock.LockType.DeadBolt) {
|
|
967
1444
|
return ClusterServer(DoorLockCluster, {
|
|
968
1445
|
operatingMode: DoorLock.OperatingMode.Normal,
|
|
@@ -985,9 +1462,22 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
985
1462
|
lockOperationError: true,
|
|
986
1463
|
});
|
|
987
1464
|
}
|
|
1465
|
+
/**
|
|
1466
|
+
* Creates a default door lock cluster server.
|
|
1467
|
+
*
|
|
1468
|
+
* @remarks
|
|
1469
|
+
* This method adds a cluster server for a door lock cluster with default settings.
|
|
1470
|
+
*
|
|
1471
|
+
*/
|
|
988
1472
|
createDefaultDoorLockClusterServer(lockState = DoorLock.LockState.Locked, lockType = DoorLock.LockType.DeadBolt) {
|
|
989
1473
|
this.addClusterServer(this.getDefaultDoorLockClusterServer(lockState, lockType));
|
|
990
1474
|
}
|
|
1475
|
+
/**
|
|
1476
|
+
* Get a default momentary switch cluster server.
|
|
1477
|
+
*
|
|
1478
|
+
* @remarks
|
|
1479
|
+
* This method adds a cluster server with default momentary switch features and configurations suitable for (AppleHome) Single Double Long automations.
|
|
1480
|
+
*/
|
|
991
1481
|
getDefaultSwitchClusterServer() {
|
|
992
1482
|
return ClusterServer(SwitchCluster.with(Switch.Feature.MomentarySwitch, Switch.Feature.MomentarySwitchRelease, Switch.Feature.MomentarySwitchLongPress, Switch.Feature.MomentarySwitchMultiPress), {
|
|
993
1483
|
numberOfPositions: 2,
|
|
@@ -1002,9 +1492,21 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
1002
1492
|
multiPressComplete: true,
|
|
1003
1493
|
});
|
|
1004
1494
|
}
|
|
1495
|
+
/**
|
|
1496
|
+
* Creates a default momentary switch cluster server.
|
|
1497
|
+
*
|
|
1498
|
+
* @remarks
|
|
1499
|
+
* This method adds a cluster server with default momentary switch features and configurations.
|
|
1500
|
+
*/
|
|
1005
1501
|
createDefaultSwitchClusterServer() {
|
|
1006
1502
|
this.addClusterServer(this.getDefaultSwitchClusterServer());
|
|
1007
1503
|
}
|
|
1504
|
+
/**
|
|
1505
|
+
* Get a default latching switch cluster server.
|
|
1506
|
+
*
|
|
1507
|
+
* @remarks
|
|
1508
|
+
* This method adds a cluster server with default latching switch features and configuration.
|
|
1509
|
+
*/
|
|
1008
1510
|
getDefaultLatchingSwitchClusterServer() {
|
|
1009
1511
|
return ClusterServer(SwitchCluster.with(Switch.Feature.LatchingSwitch), {
|
|
1010
1512
|
numberOfPositions: 2,
|
|
@@ -1013,9 +1515,22 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
1013
1515
|
switchLatched: true,
|
|
1014
1516
|
});
|
|
1015
1517
|
}
|
|
1518
|
+
/**
|
|
1519
|
+
* Creates a default latching switch cluster server.
|
|
1520
|
+
*
|
|
1521
|
+
* @remarks
|
|
1522
|
+
* This method adds a cluster server with default latching switch features and configuration.
|
|
1523
|
+
*/
|
|
1016
1524
|
createDefaultLatchingSwitchClusterServer() {
|
|
1017
1525
|
this.addClusterServer(this.getDefaultLatchingSwitchClusterServer());
|
|
1018
1526
|
}
|
|
1527
|
+
/**
|
|
1528
|
+
* Triggers a switch event on the specified endpoint.
|
|
1529
|
+
*
|
|
1530
|
+
* @param {string} event - The type of event to trigger. Possible values are 'Single', 'Double', 'Long' for momentarySwitch and 'Press', 'Release' for latchingSwitch.
|
|
1531
|
+
* @param {Endpoint} endpoint - The endpoint on which to trigger the event (default the device endpoint).
|
|
1532
|
+
* @returns {void}
|
|
1533
|
+
*/
|
|
1019
1534
|
triggerSwitchEvent(event, log, endpoint) {
|
|
1020
1535
|
if (!endpoint)
|
|
1021
1536
|
endpoint = this;
|
|
@@ -1087,6 +1602,15 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
1087
1602
|
}
|
|
1088
1603
|
return true;
|
|
1089
1604
|
}
|
|
1605
|
+
/**
|
|
1606
|
+
* Retrieves the default mode select cluster server.
|
|
1607
|
+
*
|
|
1608
|
+
* @param description - The description of the cluster server.
|
|
1609
|
+
* @param supportedModes - The supported modes for the cluster server.
|
|
1610
|
+
* @param currentMode - The current mode of the cluster server. Defaults to 0.
|
|
1611
|
+
* @param startUpMode - The startup mode of the cluster server. Defaults to 0.
|
|
1612
|
+
* @returns The default mode select cluster server.
|
|
1613
|
+
*/
|
|
1090
1614
|
getDefaultModeSelectClusterServer(description, supportedModes, currentMode = 0, startUpMode = 0) {
|
|
1091
1615
|
return ClusterServer(ModeSelectCluster, {
|
|
1092
1616
|
description: description,
|
|
@@ -1101,11 +1625,24 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
1101
1625
|
},
|
|
1102
1626
|
});
|
|
1103
1627
|
}
|
|
1628
|
+
/**
|
|
1629
|
+
* Creates a default mode select cluster server.
|
|
1630
|
+
*
|
|
1631
|
+
* @remarks
|
|
1632
|
+
* This method adds a cluster server for a mode select cluster with default settings.
|
|
1633
|
+
*
|
|
1634
|
+
* @param endpoint - The endpoint to add the cluster server to. Defaults to `this` if not provided.
|
|
1635
|
+
*/
|
|
1104
1636
|
createDefaultModeSelectClusterServer(description, supportedModes, currentMode = 0, startUpMode = 0, endpoint) {
|
|
1105
1637
|
if (!endpoint)
|
|
1106
1638
|
endpoint = this;
|
|
1107
1639
|
endpoint.addClusterServer(this.getDefaultModeSelectClusterServer(description, supportedModes, currentMode, startUpMode));
|
|
1108
1640
|
}
|
|
1641
|
+
/**
|
|
1642
|
+
* Get a default occupancy sensing cluster server.
|
|
1643
|
+
*
|
|
1644
|
+
* @param occupied - A boolean indicating whether the occupancy is occupied or not. Default is false.
|
|
1645
|
+
*/
|
|
1109
1646
|
getDefaultOccupancySensingClusterServer(occupied = false) {
|
|
1110
1647
|
return ClusterServer(OccupancySensingCluster, {
|
|
1111
1648
|
occupancy: { occupied },
|
|
@@ -1114,9 +1651,19 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
1114
1651
|
pirOccupiedToUnoccupiedDelay: 30,
|
|
1115
1652
|
}, {});
|
|
1116
1653
|
}
|
|
1654
|
+
/**
|
|
1655
|
+
* Creates a default occupancy sensing cluster server.
|
|
1656
|
+
*
|
|
1657
|
+
* @param occupied - A boolean indicating whether the occupancy is occupied or not. Default is false.
|
|
1658
|
+
*/
|
|
1117
1659
|
createDefaultOccupancySensingClusterServer(occupied = false) {
|
|
1118
1660
|
this.addClusterServer(this.getDefaultOccupancySensingClusterServer(occupied));
|
|
1119
1661
|
}
|
|
1662
|
+
/**
|
|
1663
|
+
* Get a default Illuminance Measurement Cluster Server.
|
|
1664
|
+
*
|
|
1665
|
+
* @param measuredValue - The measured value of illuminance.
|
|
1666
|
+
*/
|
|
1120
1667
|
getDefaultIlluminanceMeasurementClusterServer(measuredValue = 0) {
|
|
1121
1668
|
return ClusterServer(IlluminanceMeasurementCluster, {
|
|
1122
1669
|
measuredValue,
|
|
@@ -1125,9 +1672,19 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
1125
1672
|
tolerance: 0,
|
|
1126
1673
|
}, {}, {});
|
|
1127
1674
|
}
|
|
1675
|
+
/**
|
|
1676
|
+
* Creates a default Illuminance Measurement Cluster Server.
|
|
1677
|
+
*
|
|
1678
|
+
* @param measuredValue - The measured value of illuminance.
|
|
1679
|
+
*/
|
|
1128
1680
|
createDefaultIlluminanceMeasurementClusterServer(measuredValue = 0) {
|
|
1129
1681
|
this.addClusterServer(this.getDefaultIlluminanceMeasurementClusterServer(measuredValue));
|
|
1130
1682
|
}
|
|
1683
|
+
/**
|
|
1684
|
+
* Get a default flow measurement cluster server.
|
|
1685
|
+
*
|
|
1686
|
+
* @param measuredValue - The measured value of the flow in 10 x m/h.
|
|
1687
|
+
*/
|
|
1131
1688
|
getDefaultFlowMeasurementClusterServer(measuredValue = 0) {
|
|
1132
1689
|
return ClusterServer(FlowMeasurementCluster, {
|
|
1133
1690
|
measuredValue,
|
|
@@ -1136,9 +1693,19 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
1136
1693
|
tolerance: 0,
|
|
1137
1694
|
}, {}, {});
|
|
1138
1695
|
}
|
|
1696
|
+
/**
|
|
1697
|
+
* Creates a default flow measurement cluster server.
|
|
1698
|
+
*
|
|
1699
|
+
* @param measuredValue - The measured value of the of the flow in 10 x m/h.
|
|
1700
|
+
*/
|
|
1139
1701
|
createDefaultFlowMeasurementClusterServer(measuredValue = 0) {
|
|
1140
1702
|
this.addClusterServer(this.getDefaultFlowMeasurementClusterServer(measuredValue));
|
|
1141
1703
|
}
|
|
1704
|
+
/**
|
|
1705
|
+
* Get a default temperature measurement cluster server.
|
|
1706
|
+
*
|
|
1707
|
+
* @param measuredValue - The measured value of the temperature x 100.
|
|
1708
|
+
*/
|
|
1142
1709
|
getDefaultTemperatureMeasurementClusterServer(measuredValue = 0) {
|
|
1143
1710
|
return ClusterServer(TemperatureMeasurementCluster, {
|
|
1144
1711
|
measuredValue,
|
|
@@ -1147,9 +1714,19 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
1147
1714
|
tolerance: 0,
|
|
1148
1715
|
}, {}, {});
|
|
1149
1716
|
}
|
|
1717
|
+
/**
|
|
1718
|
+
* Creates a default temperature measurement cluster server.
|
|
1719
|
+
*
|
|
1720
|
+
* @param measuredValue - The measured value of the temperature x 100.
|
|
1721
|
+
*/
|
|
1150
1722
|
createDefaultTemperatureMeasurementClusterServer(measuredValue = 0) {
|
|
1151
1723
|
this.addClusterServer(this.getDefaultTemperatureMeasurementClusterServer(measuredValue));
|
|
1152
1724
|
}
|
|
1725
|
+
/**
|
|
1726
|
+
* Get a default RelativeHumidityMeasurementCluster server.
|
|
1727
|
+
*
|
|
1728
|
+
* @param measuredValue - The measured value of the relative humidity x 100.
|
|
1729
|
+
*/
|
|
1153
1730
|
getDefaultRelativeHumidityMeasurementClusterServer(measuredValue = 0) {
|
|
1154
1731
|
return ClusterServer(RelativeHumidityMeasurementCluster, {
|
|
1155
1732
|
measuredValue,
|
|
@@ -1158,9 +1735,19 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
1158
1735
|
tolerance: 0,
|
|
1159
1736
|
}, {}, {});
|
|
1160
1737
|
}
|
|
1738
|
+
/**
|
|
1739
|
+
* Creates a default RelativeHumidityMeasurementCluster server.
|
|
1740
|
+
*
|
|
1741
|
+
* @param measuredValue - The measured value of the relative humidity x 100.
|
|
1742
|
+
*/
|
|
1161
1743
|
createDefaultRelativeHumidityMeasurementClusterServer(measuredValue = 0) {
|
|
1162
1744
|
this.addClusterServer(this.getDefaultRelativeHumidityMeasurementClusterServer(measuredValue));
|
|
1163
1745
|
}
|
|
1746
|
+
/**
|
|
1747
|
+
* Get a default Pressure Measurement Cluster Server.
|
|
1748
|
+
*
|
|
1749
|
+
* @param measuredValue - The measured value for the pressure.
|
|
1750
|
+
*/
|
|
1164
1751
|
getDefaultPressureMeasurementClusterServer(measuredValue = 1000) {
|
|
1165
1752
|
return ClusterServer(PressureMeasurementCluster, {
|
|
1166
1753
|
measuredValue,
|
|
@@ -1169,19 +1756,39 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
1169
1756
|
tolerance: 0,
|
|
1170
1757
|
}, {}, {});
|
|
1171
1758
|
}
|
|
1759
|
+
/**
|
|
1760
|
+
* Creates a default Pressure Measurement Cluster Server.
|
|
1761
|
+
*
|
|
1762
|
+
* @param measuredValue - The measured value for the pressure.
|
|
1763
|
+
*/
|
|
1172
1764
|
createDefaultPressureMeasurementClusterServer(measuredValue = 1000) {
|
|
1173
1765
|
this.addClusterServer(this.getDefaultPressureMeasurementClusterServer(measuredValue));
|
|
1174
1766
|
}
|
|
1767
|
+
/**
|
|
1768
|
+
* Get a default boolean state cluster server.
|
|
1769
|
+
*
|
|
1770
|
+
* @param contact - Optional boolean value indicating the contact state. Defaults to `true` if not provided.
|
|
1771
|
+
*/
|
|
1175
1772
|
getDefaultBooleanStateClusterServer(contact) {
|
|
1176
1773
|
return ClusterServer(BooleanStateCluster, {
|
|
1177
|
-
stateValue: contact ?? true,
|
|
1774
|
+
stateValue: contact ?? true, // true=contact false=no_contact
|
|
1178
1775
|
}, {}, {
|
|
1179
1776
|
stateChange: true,
|
|
1180
1777
|
});
|
|
1181
1778
|
}
|
|
1779
|
+
/**
|
|
1780
|
+
* Creates a default boolean state configuration cluster server.
|
|
1781
|
+
*
|
|
1782
|
+
* @param contact - Optional boolean value indicating the contact state. Defaults to `true` if not provided.
|
|
1783
|
+
*/
|
|
1182
1784
|
createDefaultBooleanStateClusterServer(contact) {
|
|
1183
1785
|
this.addClusterServer(this.getDefaultBooleanStateClusterServer(contact));
|
|
1184
1786
|
}
|
|
1787
|
+
/**
|
|
1788
|
+
* Get a default boolean state configuration cluster server.
|
|
1789
|
+
*
|
|
1790
|
+
* @param contact - Optional boolean value indicating the sensor fault state. Defaults to `false` if not provided.
|
|
1791
|
+
*/
|
|
1185
1792
|
getDefaultBooleanStateConfigurationClusterServer(sensorFault = false) {
|
|
1186
1793
|
return ClusterServer(BooleanStateConfigurationCluster.with(BooleanStateConfiguration.Feature.Visual, BooleanStateConfiguration.Feature.Audible, BooleanStateConfiguration.Feature.SensitivityLevel), {
|
|
1187
1794
|
currentSensitivityLevel: 0,
|
|
@@ -1190,6 +1797,7 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
1190
1797
|
alarmsActive: { visual: false, audible: false },
|
|
1191
1798
|
alarmsEnabled: { visual: false, audible: false },
|
|
1192
1799
|
alarmsSupported: { visual: true, audible: true },
|
|
1800
|
+
// alarmsSuppressed: { visual: false, audible: false },
|
|
1193
1801
|
sensorFault: { generalFault: sensorFault },
|
|
1194
1802
|
}, {
|
|
1195
1803
|
enableDisableAlarm: async ({ request, attributes }) => {
|
|
@@ -1201,9 +1809,23 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
1201
1809
|
sensorFault: true,
|
|
1202
1810
|
});
|
|
1203
1811
|
}
|
|
1812
|
+
/**
|
|
1813
|
+
* Creates a default boolean state configuration cluster server.
|
|
1814
|
+
*
|
|
1815
|
+
* @param contact - Optional boolean value indicating the sensor fault state. Defaults to `false` if not provided.
|
|
1816
|
+
*/
|
|
1204
1817
|
createDefaultBooleanStateConfigurationClusterServer(sensorFault = false) {
|
|
1205
1818
|
this.addClusterServer(this.getDefaultBooleanStateConfigurationClusterServer(sensorFault));
|
|
1206
1819
|
}
|
|
1820
|
+
/**
|
|
1821
|
+
* Get a default power source replaceable battery cluster server.
|
|
1822
|
+
*
|
|
1823
|
+
* @param batPercentRemaining - The remaining battery percentage (default: 100).
|
|
1824
|
+
* @param batChargeLevel - The battery charge level (default: PowerSource.BatChargeLevel.Ok).
|
|
1825
|
+
* @param batVoltage - The battery voltage (default: 1500).
|
|
1826
|
+
* @param batReplacementDescription - The battery replacement description (default: 'Battery type').
|
|
1827
|
+
* @param batQuantity - The battery quantity (default: 1).
|
|
1828
|
+
*/
|
|
1207
1829
|
getDefaultPowerSourceReplaceableBatteryClusterServer(batPercentRemaining = 100, batChargeLevel = PowerSource.BatChargeLevel.Ok, batVoltage = 1500, batReplacementDescription = 'Battery type', batQuantity = 1) {
|
|
1208
1830
|
return ClusterServer(PowerSourceCluster.with(PowerSource.Feature.Battery, PowerSource.Feature.Replaceable), {
|
|
1209
1831
|
status: PowerSource.PowerSourceStatus.Active,
|
|
@@ -1220,9 +1842,25 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
1220
1842
|
endpointList: [],
|
|
1221
1843
|
}, {}, {});
|
|
1222
1844
|
}
|
|
1845
|
+
/**
|
|
1846
|
+
* Creates a default power source replaceable battery cluster server.
|
|
1847
|
+
*
|
|
1848
|
+
* @param batPercentRemaining - The remaining battery percentage (default: 100).
|
|
1849
|
+
* @param batChargeLevel - The battery charge level (default: PowerSource.BatChargeLevel.Ok).
|
|
1850
|
+
* @param batVoltage - The battery voltage (default: 1500).
|
|
1851
|
+
* @param batReplacementDescription - The battery replacement description (default: 'Battery type').
|
|
1852
|
+
* @param batQuantity - The battery quantity (default: 1).
|
|
1853
|
+
*/
|
|
1223
1854
|
createDefaultPowerSourceReplaceableBatteryClusterServer(batPercentRemaining = 100, batChargeLevel = PowerSource.BatChargeLevel.Ok, batVoltage = 1500, batReplacementDescription = 'Battery type', batQuantity = 1) {
|
|
1224
1855
|
this.addClusterServer(this.getDefaultPowerSourceReplaceableBatteryClusterServer(batPercentRemaining, batChargeLevel, batVoltage, batReplacementDescription, batQuantity));
|
|
1225
1856
|
}
|
|
1857
|
+
/**
|
|
1858
|
+
* Get a default power source rechargeable battery cluster server.
|
|
1859
|
+
*
|
|
1860
|
+
* @param batPercentRemaining - The remaining battery percentage (default: 100).
|
|
1861
|
+
* @param batChargeLevel - The battery charge level (default: PowerSource.BatChargeLevel.Ok).
|
|
1862
|
+
* @param batVoltage - The battery voltage (default: 1500).
|
|
1863
|
+
*/
|
|
1226
1864
|
getDefaultPowerSourceRechargeableBatteryClusterServer(batPercentRemaining = 100, batChargeLevel = PowerSource.BatChargeLevel.Ok, batVoltage = 1500) {
|
|
1227
1865
|
return ClusterServer(PowerSourceCluster.with(PowerSource.Feature.Battery, PowerSource.Feature.Rechargeable), {
|
|
1228
1866
|
status: PowerSource.PowerSourceStatus.Active,
|
|
@@ -1240,9 +1878,21 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
1240
1878
|
endpointList: [],
|
|
1241
1879
|
}, {}, {});
|
|
1242
1880
|
}
|
|
1881
|
+
/**
|
|
1882
|
+
* Creates a default power source rechargeable battery cluster server.
|
|
1883
|
+
*
|
|
1884
|
+
* @param batPercentRemaining - The remaining battery percentage (default: 100).
|
|
1885
|
+
* @param batChargeLevel - The battery charge level (default: PowerSource.BatChargeLevel.Ok).
|
|
1886
|
+
* @param batVoltage - The battery voltage (default: 1500).
|
|
1887
|
+
*/
|
|
1243
1888
|
createDefaultPowerSourceRechargeableBatteryClusterServer(batPercentRemaining = 100, batChargeLevel = PowerSource.BatChargeLevel.Ok, batVoltage = 1500) {
|
|
1244
1889
|
this.addClusterServer(this.getDefaultPowerSourceRechargeableBatteryClusterServer(batPercentRemaining, batChargeLevel, batVoltage));
|
|
1245
1890
|
}
|
|
1891
|
+
/**
|
|
1892
|
+
* Get a default power source wired cluster server.
|
|
1893
|
+
*
|
|
1894
|
+
* @param wiredCurrentType - The type of wired current (default: PowerSource.WiredCurrentType.Ac)
|
|
1895
|
+
*/
|
|
1246
1896
|
getDefaultPowerSourceWiredClusterServer(wiredCurrentType = PowerSource.WiredCurrentType.Ac) {
|
|
1247
1897
|
return ClusterServer(PowerSourceCluster.with(PowerSource.Feature.Wired), {
|
|
1248
1898
|
wiredCurrentType,
|
|
@@ -1252,22 +1902,45 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
1252
1902
|
endpointList: [],
|
|
1253
1903
|
}, {}, {});
|
|
1254
1904
|
}
|
|
1905
|
+
/**
|
|
1906
|
+
* Creates a default power source wired cluster server.
|
|
1907
|
+
*
|
|
1908
|
+
* @param wiredCurrentType - The type of wired current (default: PowerSource.WiredCurrentType.Ac)
|
|
1909
|
+
*/
|
|
1255
1910
|
createDefaultPowerSourceWiredClusterServer(wiredCurrentType = PowerSource.WiredCurrentType.Ac) {
|
|
1256
1911
|
this.addClusterServer(this.getDefaultPowerSourceWiredClusterServer(wiredCurrentType));
|
|
1257
1912
|
}
|
|
1913
|
+
/**
|
|
1914
|
+
* @deprecated This function is deprecated by Matter 1.3 spec and will be removed in a future version.
|
|
1915
|
+
*/
|
|
1258
1916
|
createDefaultPowerSourceConfigurationClusterServer(endpointNumber) {
|
|
1259
1917
|
this.addClusterServer(ClusterServer(PowerSourceConfigurationCluster, {
|
|
1260
1918
|
sources: endpointNumber ? [EndpointNumber(endpointNumber)] : [],
|
|
1261
1919
|
}, {}, {}));
|
|
1262
1920
|
}
|
|
1921
|
+
/**
|
|
1922
|
+
* Get a default air quality cluster server.
|
|
1923
|
+
*
|
|
1924
|
+
* @param airQuality The air quality type. Defaults to `AirQuality.AirQualityType.Unknown`.
|
|
1925
|
+
*/
|
|
1263
1926
|
getDefaultAirQualityClusterServer(airQuality = AirQuality.AirQualityEnum.Unknown) {
|
|
1264
1927
|
return ClusterServer(AirQualityCluster.with(AirQuality.Feature.Fair, AirQuality.Feature.Moderate, AirQuality.Feature.VeryPoor, AirQuality.Feature.ExtremelyPoor), {
|
|
1265
1928
|
airQuality,
|
|
1266
1929
|
}, {}, {});
|
|
1267
1930
|
}
|
|
1931
|
+
/**
|
|
1932
|
+
* Creates a default air quality cluster server.
|
|
1933
|
+
*
|
|
1934
|
+
* @param airQuality The air quality type. Defaults to `AirQuality.AirQualityType.Unknown`.
|
|
1935
|
+
*/
|
|
1268
1936
|
createDefaultAirQualityClusterServer(airQuality = AirQuality.AirQualityEnum.Unknown) {
|
|
1269
1937
|
this.addClusterServer(this.getDefaultAirQualityClusterServer(airQuality));
|
|
1270
1938
|
}
|
|
1939
|
+
/**
|
|
1940
|
+
* Get a default TVOC measurement cluster server.
|
|
1941
|
+
*
|
|
1942
|
+
* @param measuredValue - The measured value for TVOC.
|
|
1943
|
+
*/
|
|
1271
1944
|
getDefaultTvocMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1272
1945
|
return ClusterServer(TotalVolatileOrganicCompoundsConcentrationMeasurementCluster.with('NumericMeasurement'), {
|
|
1273
1946
|
measuredValue,
|
|
@@ -1278,14 +1951,28 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
1278
1951
|
measurementMedium,
|
|
1279
1952
|
}, {}, {});
|
|
1280
1953
|
}
|
|
1954
|
+
/**
|
|
1955
|
+
* Creates a default TVOC measurement cluster server.
|
|
1956
|
+
*
|
|
1957
|
+
* @param measuredValue - The measured value for TVOC.
|
|
1958
|
+
*/
|
|
1281
1959
|
createDefaultTvocMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1282
1960
|
this.addClusterServer(this.getDefaultTvocMeasurementClusterServer(measuredValue, measurementUnit, measurementMedium));
|
|
1283
1961
|
}
|
|
1962
|
+
/**
|
|
1963
|
+
* Get a default heating thermostat cluster server with the specified parameters.
|
|
1964
|
+
* @param {number} [localTemperature] - The local temperature value in degrees Celsius. Defaults to 23°.
|
|
1965
|
+
* @param {number} [occupiedHeatingSetpoint] - The occupied heating setpoint value in degrees Celsius. Defaults to 21°.
|
|
1966
|
+
* @param {number} [minHeatSetpointLimit] - The minimum heat setpoint limit value. Defaults to 0°.
|
|
1967
|
+
* @param {number} [maxHeatSetpointLimit] - The maximum heat setpoint limit value. Defaults to 50°.
|
|
1968
|
+
* @returns {ThermostatClusterServer} A default thermostat cluster server configured with the specified parameters.
|
|
1969
|
+
*/
|
|
1284
1970
|
getDefaultHeatingThermostatClusterServer(localTemperature = 23, occupiedHeatingSetpoint = 21, minHeatSetpointLimit = 0, maxHeatSetpointLimit = 50) {
|
|
1285
1971
|
return ClusterServer(ThermostatCluster.with(Thermostat.Feature.Heating), {
|
|
1286
1972
|
localTemperature: localTemperature * 100,
|
|
1287
1973
|
systemMode: Thermostat.SystemMode.Heat,
|
|
1288
1974
|
controlSequenceOfOperation: Thermostat.ControlSequenceOfOperation.HeatingOnly,
|
|
1975
|
+
// Thermostat.Feature.Heating
|
|
1289
1976
|
occupiedHeatingSetpoint: occupiedHeatingSetpoint * 100,
|
|
1290
1977
|
minHeatSetpointLimit: minHeatSetpointLimit * 100,
|
|
1291
1978
|
maxHeatSetpointLimit: maxHeatSetpointLimit * 100,
|
|
@@ -1298,14 +1985,31 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
1298
1985
|
},
|
|
1299
1986
|
}, {});
|
|
1300
1987
|
}
|
|
1988
|
+
/**
|
|
1989
|
+
* Creates and adds a default heating thermostat cluster server to the device.
|
|
1990
|
+
*
|
|
1991
|
+
* @param {number} [localTemperature] - The local temperature value in degrees Celsius. Defaults to 23°.
|
|
1992
|
+
* @param {number} [occupiedHeatingSetpoint] - The occupied heating setpoint value in degrees Celsius. Defaults to 21°.
|
|
1993
|
+
* @param {number} [minHeatSetpointLimit] - The minimum heat setpoint limit value. Defaults to 0°.
|
|
1994
|
+
* @param {number} [maxHeatSetpointLimit] - The maximum heat setpoint limit value. Defaults to 50°.
|
|
1995
|
+
*/
|
|
1301
1996
|
createDefaultHeatingThermostatClusterServer(localTemperature = 23, occupiedHeatingSetpoint = 25, minHeatSetpointLimit = 0, maxHeatSetpointLimit = 50) {
|
|
1302
1997
|
this.addClusterServer(this.getDefaultHeatingThermostatClusterServer(localTemperature, occupiedHeatingSetpoint, minHeatSetpointLimit, maxHeatSetpointLimit));
|
|
1303
1998
|
}
|
|
1999
|
+
/**
|
|
2000
|
+
* Get a default cooling thermostat cluster server with the specified parameters.
|
|
2001
|
+
* @param {number} [localTemperature] - The local temperature value in degrees Celsius. Defaults to 23°.
|
|
2002
|
+
* @param {number} [occupiedCoolingSetpoint] - The occupied cooling setpoint value in degrees Celsius. Defaults to 25°.
|
|
2003
|
+
* @param {number} [minCoolSetpointLimit] - The minimum cool setpoint limit value. Defaults to 0°.
|
|
2004
|
+
* @param {number} [maxCoolSetpointLimit] - The maximum cool setpoint limit value. Defaults to 50°.
|
|
2005
|
+
* @returns {ThermostatClusterServer} A default thermostat cluster server configured with the specified parameters.
|
|
2006
|
+
*/
|
|
1304
2007
|
getDefaultCoolingThermostatClusterServer(localTemperature = 23, occupiedCoolingSetpoint = 25, minCoolSetpointLimit = 0, maxCoolSetpointLimit = 50) {
|
|
1305
2008
|
return ClusterServer(ThermostatCluster.with(Thermostat.Feature.Cooling), {
|
|
1306
2009
|
localTemperature: localTemperature * 100,
|
|
1307
2010
|
systemMode: Thermostat.SystemMode.Cool,
|
|
1308
2011
|
controlSequenceOfOperation: Thermostat.ControlSequenceOfOperation.CoolingOnly,
|
|
2012
|
+
// Thermostat.Feature.Cooling
|
|
1309
2013
|
occupiedCoolingSetpoint: occupiedCoolingSetpoint * 100,
|
|
1310
2014
|
minCoolSetpointLimit: minCoolSetpointLimit * 100,
|
|
1311
2015
|
maxCoolSetpointLimit: maxCoolSetpointLimit * 100,
|
|
@@ -1318,24 +2022,48 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
1318
2022
|
},
|
|
1319
2023
|
}, {});
|
|
1320
2024
|
}
|
|
2025
|
+
/**
|
|
2026
|
+
* Creates and adds a default cooling thermostat cluster server to the device.
|
|
2027
|
+
*
|
|
2028
|
+
* @param {number} [localTemperature] - The local temperature value in degrees Celsius. Defaults to 23°.
|
|
2029
|
+
* @param {number} [occupiedCoolingSetpoint] - The occupied cooling setpoint value in degrees Celsius. Defaults to 25°.
|
|
2030
|
+
* @param {number} [minCoolSetpointLimit] - The minimum cool setpoint limit value. Defaults to 0°.
|
|
2031
|
+
* @param {number} [maxCoolSetpointLimit] - The maximum cool setpoint limit value. Defaults to 50°.
|
|
2032
|
+
*/
|
|
1321
2033
|
createDefaultCoolingThermostatClusterServer(localTemperature = 23, occupiedCoolingSetpoint = 25, minCoolSetpointLimit = 0, maxCoolSetpointLimit = 50) {
|
|
1322
2034
|
this.addClusterServer(this.getDefaultCoolingThermostatClusterServer(localTemperature, occupiedCoolingSetpoint, minCoolSetpointLimit, maxCoolSetpointLimit));
|
|
1323
2035
|
}
|
|
2036
|
+
/**
|
|
2037
|
+
* Get a default thermostat cluster server with the specified parameters.
|
|
2038
|
+
*
|
|
2039
|
+
* @param {number} [localTemperature=23] - The local temperature value in degrees Celsius. Defaults to 23°.
|
|
2040
|
+
* @param {number} [occupiedHeatingSetpoint=21] - The occupied heating setpoint value in degrees Celsius. Defaults to 21°.
|
|
2041
|
+
* @param {number} [occupiedCoolingSetpoint=25] - The occupied cooling setpoint value in degrees Celsius. Defaults to 25°.
|
|
2042
|
+
* @param {number} [minSetpointDeadBand=1] - The minimum setpoint dead band value. Defaults to 1°.
|
|
2043
|
+
* @param {number} [minHeatSetpointLimit=0] - The minimum heat setpoint limit value. Defaults to 0°.
|
|
2044
|
+
* @param {number} [maxHeatSetpointLimit=50] - The maximum heat setpoint limit value. Defaults to 50°.
|
|
2045
|
+
* @param {number} [minCoolSetpointLimit=0] - The minimum cool setpoint limit value. Defaults to 0°.
|
|
2046
|
+
* @param {number} [maxCoolSetpointLimit=50] - The maximum cool setpoint limit value. Defaults to 50°.
|
|
2047
|
+
* @returns {ThermostatClusterServer} A default thermostat cluster server configured with the specified parameters.
|
|
2048
|
+
*/
|
|
1324
2049
|
getDefaultThermostatClusterServer(localTemperature = 23, occupiedHeatingSetpoint = 21, occupiedCoolingSetpoint = 25, minSetpointDeadBand = 1, minHeatSetpointLimit = 0, maxHeatSetpointLimit = 50, minCoolSetpointLimit = 0, maxCoolSetpointLimit = 50) {
|
|
1325
2050
|
return ClusterServer(ThermostatCluster.with(Thermostat.Feature.Heating, Thermostat.Feature.Cooling, Thermostat.Feature.AutoMode), {
|
|
1326
2051
|
localTemperature: localTemperature * 100,
|
|
1327
2052
|
systemMode: Thermostat.SystemMode.Auto,
|
|
1328
2053
|
controlSequenceOfOperation: Thermostat.ControlSequenceOfOperation.CoolingAndHeating,
|
|
2054
|
+
// Thermostat.Feature.Heating
|
|
1329
2055
|
occupiedHeatingSetpoint: occupiedHeatingSetpoint * 100,
|
|
1330
2056
|
minHeatSetpointLimit: minHeatSetpointLimit * 100,
|
|
1331
2057
|
maxHeatSetpointLimit: maxHeatSetpointLimit * 100,
|
|
1332
2058
|
absMinHeatSetpointLimit: minHeatSetpointLimit * 100,
|
|
1333
2059
|
absMaxHeatSetpointLimit: maxHeatSetpointLimit * 100,
|
|
2060
|
+
// Thermostat.Feature.Cooling
|
|
1334
2061
|
occupiedCoolingSetpoint: occupiedCoolingSetpoint * 100,
|
|
1335
2062
|
minCoolSetpointLimit: minCoolSetpointLimit * 100,
|
|
1336
2063
|
maxCoolSetpointLimit: maxCoolSetpointLimit * 100,
|
|
1337
2064
|
absMinCoolSetpointLimit: minCoolSetpointLimit * 100,
|
|
1338
2065
|
absMaxCoolSetpointLimit: maxCoolSetpointLimit * 100,
|
|
2066
|
+
// Thermostat.Feature.AutoMode
|
|
1339
2067
|
minSetpointDeadBand: minSetpointDeadBand * 100,
|
|
1340
2068
|
thermostatRunningMode: Thermostat.ThermostatRunningMode.Off,
|
|
1341
2069
|
}, {
|
|
@@ -1345,9 +2073,24 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
1345
2073
|
},
|
|
1346
2074
|
}, {});
|
|
1347
2075
|
}
|
|
2076
|
+
/**
|
|
2077
|
+
* Creates and adds a default thermostat cluster server to the device.
|
|
2078
|
+
*
|
|
2079
|
+
* @param {number} [localTemperature=23] - The local temperature value in degrees Celsius. Defaults to 23°.
|
|
2080
|
+
* @param {number} [occupiedHeatingSetpoint=21] - The occupied heating setpoint value in degrees Celsius. Defaults to 21°.
|
|
2081
|
+
* @param {number} [occupiedCoolingSetpoint=25] - The occupied cooling setpoint value in degrees Celsius. Defaults to 25°.
|
|
2082
|
+
* @param {number} [minSetpointDeadBand=1] - The minimum setpoint dead band value. Defaults to 1°.
|
|
2083
|
+
* @param {number} [minHeatSetpointLimit=0] - The minimum heat setpoint limit value. Defaults to 0°.
|
|
2084
|
+
* @param {number} [maxHeatSetpointLimit=50] - The maximum heat setpoint limit value. Defaults to 50°.
|
|
2085
|
+
* @param {number} [minCoolSetpointLimit=0] - The minimum cool setpoint limit value. Defaults to 0°.
|
|
2086
|
+
* @param {number} [maxCoolSetpointLimit=50] - The maximum cool setpoint limit value. Defaults to 50°.
|
|
2087
|
+
*/
|
|
1348
2088
|
createDefaultThermostatClusterServer(localTemperature = 23, occupiedHeatingSetpoint = 21, occupiedCoolingSetpoint = 25, minSetpointDeadBand = 1, minHeatSetpointLimit = 0, maxHeatSetpointLimit = 50, minCoolSetpointLimit = 0, maxCoolSetpointLimit = 50) {
|
|
1349
2089
|
this.addClusterServer(this.getDefaultThermostatClusterServer(localTemperature, occupiedHeatingSetpoint, occupiedCoolingSetpoint, minSetpointDeadBand, minHeatSetpointLimit, maxHeatSetpointLimit, minCoolSetpointLimit, maxCoolSetpointLimit));
|
|
1350
2090
|
}
|
|
2091
|
+
/**
|
|
2092
|
+
* Get a default dummy time sync cluster server. Only needed to create a thermostat.
|
|
2093
|
+
*/
|
|
1351
2094
|
getDefaultTimeSyncClusterServer() {
|
|
1352
2095
|
return ClusterServer(TimeSynchronizationCluster.with(TimeSynchronization.Feature.TimeZone), {
|
|
1353
2096
|
utcTime: null,
|
|
@@ -1379,9 +2122,19 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
1379
2122
|
timeFailure: true,
|
|
1380
2123
|
});
|
|
1381
2124
|
}
|
|
2125
|
+
/**
|
|
2126
|
+
* Creates a default dummy time sync cluster server. Only needed to create a thermostat.
|
|
2127
|
+
*/
|
|
1382
2128
|
createDefaultTimeSyncClusterServer() {
|
|
1383
2129
|
this.addClusterServer(this.getDefaultTimeSyncClusterServer());
|
|
1384
2130
|
}
|
|
2131
|
+
/**
|
|
2132
|
+
* Returns the default SmokeCOAlarm Cluster Server.
|
|
2133
|
+
*
|
|
2134
|
+
* @param smokeState - The state of the smoke alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
|
|
2135
|
+
* @param coState - The state of the CO alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
|
|
2136
|
+
* @returns The default SmokeCOAlarmClusterServer.
|
|
2137
|
+
*/
|
|
1385
2138
|
getDefaultSmokeCOAlarmClusterServer(smokeState = SmokeCoAlarm.AlarmState.Normal, coState = SmokeCoAlarm.AlarmState.Normal) {
|
|
1386
2139
|
return ClusterServer(SmokeCoAlarmCluster.with(SmokeCoAlarm.Feature.SmokeAlarm, SmokeCoAlarm.Feature.CoAlarm), {
|
|
1387
2140
|
smokeState,
|
|
@@ -1413,9 +2166,24 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
1413
2166
|
allClear: true,
|
|
1414
2167
|
});
|
|
1415
2168
|
}
|
|
2169
|
+
/**
|
|
2170
|
+
* Create the default SmokeCOAlarm Cluster Server.
|
|
2171
|
+
*
|
|
2172
|
+
* @param smokeState - The state of the smoke alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
|
|
2173
|
+
* @param coState - The state of the CO alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
|
|
2174
|
+
* @returns The default SmokeCOAlarmClusterServer.
|
|
2175
|
+
*/
|
|
1416
2176
|
createDefaultSmokeCOAlarmClusterServer(smokeState = SmokeCoAlarm.AlarmState.Normal, coState = SmokeCoAlarm.AlarmState.Normal) {
|
|
1417
2177
|
this.addClusterServer(this.getDefaultSmokeCOAlarmClusterServer(smokeState, coState));
|
|
1418
2178
|
}
|
|
2179
|
+
/**
|
|
2180
|
+
* Returns the default Carbon Monoxide Concentration Measurement Cluster Server.
|
|
2181
|
+
*
|
|
2182
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
2183
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
2184
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
2185
|
+
* @returns {ClusterServer} - The default Carbon Monoxide Concentration Measurement Cluster Server.
|
|
2186
|
+
*/
|
|
1419
2187
|
getDefaultCarbonMonoxideConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1420
2188
|
return ClusterServer(CarbonMonoxideConcentrationMeasurementCluster.with('NumericMeasurement'), {
|
|
1421
2189
|
measuredValue,
|
|
@@ -1426,9 +2194,24 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
1426
2194
|
measurementMedium,
|
|
1427
2195
|
}, {}, {});
|
|
1428
2196
|
}
|
|
2197
|
+
/**
|
|
2198
|
+
* Create the default Carbon Monoxide Concentration Measurement Cluster Server.
|
|
2199
|
+
*
|
|
2200
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
2201
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
2202
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
2203
|
+
*/
|
|
1429
2204
|
createDefaultCarbonMonoxideConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1430
2205
|
this.addClusterServer(this.getDefaultCarbonMonoxideConcentrationMeasurementClusterServer(measuredValue, measurementUnit, measurementMedium));
|
|
1431
2206
|
}
|
|
2207
|
+
/**
|
|
2208
|
+
* Returns the default Carbon Dioxide Concentration Measurement Cluster Server.
|
|
2209
|
+
*
|
|
2210
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
2211
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
2212
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
2213
|
+
* @returns {ClusterServer} - The default Carbon Monoxide Concentration Measurement Cluster Server.
|
|
2214
|
+
*/
|
|
1432
2215
|
getDefaultCarbonDioxideConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1433
2216
|
return ClusterServer(CarbonDioxideConcentrationMeasurementCluster.with('NumericMeasurement'), {
|
|
1434
2217
|
measuredValue,
|
|
@@ -1439,9 +2222,24 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
1439
2222
|
measurementMedium,
|
|
1440
2223
|
}, {}, {});
|
|
1441
2224
|
}
|
|
2225
|
+
/**
|
|
2226
|
+
* Create the default Carbon Dioxide Concentration Measurement Cluster Server.
|
|
2227
|
+
*
|
|
2228
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
2229
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
2230
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
2231
|
+
*/
|
|
1442
2232
|
createDefaultCarbonDioxideConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1443
2233
|
this.addClusterServer(this.getDefaultCarbonDioxideConcentrationMeasurementClusterServer(measuredValue, measurementUnit, measurementMedium));
|
|
1444
2234
|
}
|
|
2235
|
+
/**
|
|
2236
|
+
* Returns the default Formaldehyde Concentration Measurement Cluster Server.
|
|
2237
|
+
*
|
|
2238
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
2239
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
2240
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
2241
|
+
* @returns {ClusterServer} - The default Carbon Monoxide Concentration Measurement Cluster Server.
|
|
2242
|
+
*/
|
|
1445
2243
|
getDefaultFormaldehydeConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1446
2244
|
return ClusterServer(FormaldehydeConcentrationMeasurementCluster.with('NumericMeasurement'), {
|
|
1447
2245
|
measuredValue,
|
|
@@ -1452,9 +2250,24 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
1452
2250
|
measurementMedium,
|
|
1453
2251
|
}, {}, {});
|
|
1454
2252
|
}
|
|
2253
|
+
/**
|
|
2254
|
+
* Create the default Formaldehyde Concentration Measurement Cluster Server.
|
|
2255
|
+
*
|
|
2256
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
2257
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
2258
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
2259
|
+
*/
|
|
1455
2260
|
createDefaultFormaldehydeConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1456
2261
|
this.addClusterServer(this.getDefaultFormaldehydeConcentrationMeasurementClusterServer(measuredValue, measurementUnit, measurementMedium));
|
|
1457
2262
|
}
|
|
2263
|
+
/**
|
|
2264
|
+
* Returns the default Pm1 Concentration Measurement Cluster Server.
|
|
2265
|
+
*
|
|
2266
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
2267
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
2268
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
2269
|
+
* @returns {ClusterServer} - The default Carbon Monoxide Concentration Measurement Cluster Server.
|
|
2270
|
+
*/
|
|
1458
2271
|
getDefaultPm1ConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1459
2272
|
return ClusterServer(Pm1ConcentrationMeasurementCluster.with('NumericMeasurement'), {
|
|
1460
2273
|
measuredValue,
|
|
@@ -1465,9 +2278,24 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
1465
2278
|
measurementMedium,
|
|
1466
2279
|
}, {}, {});
|
|
1467
2280
|
}
|
|
2281
|
+
/**
|
|
2282
|
+
* Create the default Pm1 Concentration Measurement Cluster Server.
|
|
2283
|
+
*
|
|
2284
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
2285
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
2286
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
2287
|
+
*/
|
|
1468
2288
|
createDefaulPm1ConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1469
2289
|
this.addClusterServer(this.getDefaultPm1ConcentrationMeasurementClusterServer(measuredValue, measurementUnit, measurementMedium));
|
|
1470
2290
|
}
|
|
2291
|
+
/**
|
|
2292
|
+
* Returns the default Pm25 Concentration Measurement Cluster Server.
|
|
2293
|
+
*
|
|
2294
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
2295
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
2296
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
2297
|
+
* @returns {ClusterServer} - The default Carbon Monoxide Concentration Measurement Cluster Server.
|
|
2298
|
+
*/
|
|
1471
2299
|
getDefaultPm25ConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1472
2300
|
return ClusterServer(Pm25ConcentrationMeasurementCluster.with('NumericMeasurement'), {
|
|
1473
2301
|
measuredValue,
|
|
@@ -1478,9 +2306,24 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
1478
2306
|
measurementMedium,
|
|
1479
2307
|
}, {}, {});
|
|
1480
2308
|
}
|
|
2309
|
+
/**
|
|
2310
|
+
* Create the default Pm25 Concentration Measurement Cluster Server.
|
|
2311
|
+
*
|
|
2312
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
2313
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
2314
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
2315
|
+
*/
|
|
1481
2316
|
createDefaulPm25ConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1482
2317
|
this.addClusterServer(this.getDefaultPm25ConcentrationMeasurementClusterServer(measuredValue, measurementUnit, measurementMedium));
|
|
1483
2318
|
}
|
|
2319
|
+
/**
|
|
2320
|
+
* Returns the default Pm10 Concentration Measurement Cluster Server.
|
|
2321
|
+
*
|
|
2322
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
2323
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
2324
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
2325
|
+
* @returns {ClusterServer} - The default Carbon Monoxide Concentration Measurement Cluster Server.
|
|
2326
|
+
*/
|
|
1484
2327
|
getDefaultPm10ConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1485
2328
|
return ClusterServer(Pm10ConcentrationMeasurementCluster.with('NumericMeasurement'), {
|
|
1486
2329
|
measuredValue,
|
|
@@ -1491,9 +2334,24 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
1491
2334
|
measurementMedium,
|
|
1492
2335
|
}, {}, {});
|
|
1493
2336
|
}
|
|
2337
|
+
/**
|
|
2338
|
+
* Create the default Pm10 Concentration Measurement Cluster Server.
|
|
2339
|
+
*
|
|
2340
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
2341
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
2342
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
2343
|
+
*/
|
|
1494
2344
|
createDefaulPm10ConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1495
2345
|
this.addClusterServer(this.getDefaultPm10ConcentrationMeasurementClusterServer(measuredValue, measurementUnit, measurementMedium));
|
|
1496
2346
|
}
|
|
2347
|
+
/**
|
|
2348
|
+
* Returns the default Ozone Concentration Measurement Cluster Server.
|
|
2349
|
+
*
|
|
2350
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
2351
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
2352
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
2353
|
+
* @returns {ClusterServer} - The default Carbon Monoxide Concentration Measurement Cluster Server.
|
|
2354
|
+
*/
|
|
1497
2355
|
getDefaultOzoneConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ugm3, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1498
2356
|
return ClusterServer(OzoneConcentrationMeasurementCluster.with('NumericMeasurement'), {
|
|
1499
2357
|
measuredValue,
|
|
@@ -1504,9 +2362,24 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
1504
2362
|
measurementMedium,
|
|
1505
2363
|
}, {}, {});
|
|
1506
2364
|
}
|
|
2365
|
+
/**
|
|
2366
|
+
* Create the default Ozone Concentration Measurement Cluster Server.
|
|
2367
|
+
*
|
|
2368
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
2369
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
2370
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
2371
|
+
*/
|
|
1507
2372
|
createDefaulOzoneConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ugm3, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1508
2373
|
this.addClusterServer(this.getDefaultOzoneConcentrationMeasurementClusterServer(measuredValue, measurementUnit, measurementMedium));
|
|
1509
2374
|
}
|
|
2375
|
+
/**
|
|
2376
|
+
* Returns the default Radon Concentration Measurement Cluster Server.
|
|
2377
|
+
*
|
|
2378
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
2379
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
2380
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
2381
|
+
* @returns {ClusterServer} - The default Carbon Monoxide Concentration Measurement Cluster Server.
|
|
2382
|
+
*/
|
|
1510
2383
|
getDefaultRadonConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1511
2384
|
return ClusterServer(RadonConcentrationMeasurementCluster.with('NumericMeasurement'), {
|
|
1512
2385
|
measuredValue,
|
|
@@ -1517,9 +2390,24 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
1517
2390
|
measurementMedium,
|
|
1518
2391
|
}, {}, {});
|
|
1519
2392
|
}
|
|
2393
|
+
/**
|
|
2394
|
+
* Create the default Radon Concentration Measurement Cluster Server.
|
|
2395
|
+
*
|
|
2396
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
2397
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
2398
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
2399
|
+
*/
|
|
1520
2400
|
createDefaulRadonConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1521
2401
|
this.addClusterServer(this.getDefaultRadonConcentrationMeasurementClusterServer(measuredValue, measurementUnit, measurementMedium));
|
|
1522
2402
|
}
|
|
2403
|
+
/**
|
|
2404
|
+
* Returns the default Nitrogen Dioxide Concentration Measurement Cluster Server.
|
|
2405
|
+
*
|
|
2406
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
2407
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
2408
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
2409
|
+
* @returns {ClusterServer} - The default Carbon Monoxide Concentration Measurement Cluster Server.
|
|
2410
|
+
*/
|
|
1523
2411
|
getDefaultNitrogenDioxideConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ugm3, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1524
2412
|
return ClusterServer(NitrogenDioxideConcentrationMeasurementCluster.with('NumericMeasurement'), {
|
|
1525
2413
|
measuredValue,
|
|
@@ -1530,9 +2418,22 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
1530
2418
|
measurementMedium,
|
|
1531
2419
|
}, {}, {});
|
|
1532
2420
|
}
|
|
2421
|
+
/**
|
|
2422
|
+
* Create the default Nitrogen Dioxide Concentration Measurement Cluster Server.
|
|
2423
|
+
*
|
|
2424
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
2425
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
2426
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
2427
|
+
*/
|
|
1533
2428
|
createDefaulNitrogenDioxideConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ugm3, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1534
2429
|
this.addClusterServer(this.getDefaultNitrogenDioxideConcentrationMeasurementClusterServer(measuredValue, measurementUnit, measurementMedium));
|
|
1535
2430
|
}
|
|
2431
|
+
/**
|
|
2432
|
+
* Returns the default fan control cluster server rev 2.
|
|
2433
|
+
*
|
|
2434
|
+
* @param fanMode The fan mode to set. Defaults to `FanControl.FanMode.Off`.
|
|
2435
|
+
* @returns The default fan control cluster server.
|
|
2436
|
+
*/
|
|
1536
2437
|
getDefaultFanControlClusterServer(fanMode = FanControl.FanMode.Off) {
|
|
1537
2438
|
return ClusterServer(FanControlCluster.with(FanControl.Feature.MultiSpeed, FanControl.Feature.Auto, FanControl.Feature.Step), {
|
|
1538
2439
|
fanMode,
|
|
@@ -1549,9 +2450,16 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
1549
2450
|
},
|
|
1550
2451
|
}, {});
|
|
1551
2452
|
}
|
|
2453
|
+
/**
|
|
2454
|
+
* Create the default fan control cluster server rev 2.
|
|
2455
|
+
*
|
|
2456
|
+
* @param fanMode The fan mode to set. Defaults to `FanControl.FanMode.Off`.
|
|
2457
|
+
* @returns The default fan control cluster server.
|
|
2458
|
+
*/
|
|
1552
2459
|
createDefaultFanControlClusterServer(fanMode = FanControl.FanMode.Off) {
|
|
1553
2460
|
this.addClusterServer(this.getDefaultFanControlClusterServer(fanMode));
|
|
1554
2461
|
}
|
|
2462
|
+
// NOTE Support of Device Energy Management Cluster is provisional.
|
|
1555
2463
|
getDefaultDeviceEnergyManagementClusterServer() {
|
|
1556
2464
|
return ClusterServer(DeviceEnergyManagementCluster.with(DeviceEnergyManagement.Feature.Pausable, DeviceEnergyManagement.Feature.PowerForecastReporting, DeviceEnergyManagement.Feature.StateForecastReporting), {
|
|
1557
2465
|
esaType: DeviceEnergyManagement.EsaType.Other,
|
|
@@ -1575,6 +2483,7 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
1575
2483
|
resumed: true,
|
|
1576
2484
|
});
|
|
1577
2485
|
}
|
|
2486
|
+
// NOTE Support of Device Energy Management Mode Cluster is provisional.
|
|
1578
2487
|
getDefaultDeviceEnergyManagementModeClusterServer() {
|
|
1579
2488
|
return ClusterServer(DeviceEnergyManagementModeCluster, {
|
|
1580
2489
|
supportedModes: [
|
|
@@ -1591,3 +2500,4 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
1591
2500
|
}, {});
|
|
1592
2501
|
}
|
|
1593
2502
|
}
|
|
2503
|
+
//# sourceMappingURL=matterbridgeDevice.js.map
|