matterbridge 1.7.2 → 2.0.0-edge.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +40 -1
- package/dist/cli.js +3 -39
- package/dist/cluster/export.js +0 -2
- package/dist/defaultConfigSchema.js +0 -23
- package/dist/deviceManager.js +1 -26
- package/dist/frontend.js +1203 -0
- package/dist/index.js +1 -36
- package/dist/logger/export.js +0 -1
- package/dist/matter/export.js +0 -5
- package/dist/matterbridge.js +516 -2678
- package/dist/matterbridgeAccessoryPlatform.js +0 -33
- package/dist/matterbridgeBehaviors.js +23 -31
- package/dist/matterbridgeDeviceTypes.js +11 -82
- package/dist/matterbridgeDynamicPlatform.js +0 -33
- package/dist/matterbridgeEndpoint.js +45 -1145
- package/dist/matterbridgePlatform.js +14 -145
- package/dist/matterbridgeTypes.js +3 -24
- package/dist/pluginManager.js +5 -246
- package/dist/storage/export.js +0 -1
- package/dist/utils/colorUtils.js +2 -205
- package/dist/utils/export.js +0 -1
- package/dist/utils/utils.js +7 -252
- package/frontend/build/asset-manifest.json +3 -3
- package/frontend/build/index.html +1 -1
- package/frontend/build/static/js/{main.08241820.js → main.6204ae54.js} +3 -3
- package/frontend/build/static/js/main.6204ae54.js.map +1 -0
- package/npm-shrinkwrap.json +9 -9
- package/package.json +2 -3
- package/dist/cli.d.ts +0 -25
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/cluster/export.d.ts +0 -2
- package/dist/cluster/export.d.ts.map +0 -1
- package/dist/cluster/export.js.map +0 -1
- package/dist/defaultConfigSchema.d.ts +0 -27
- package/dist/defaultConfigSchema.d.ts.map +0 -1
- package/dist/defaultConfigSchema.js.map +0 -1
- package/dist/deviceManager.d.ts +0 -46
- package/dist/deviceManager.d.ts.map +0 -1
- package/dist/deviceManager.js.map +0 -1
- package/dist/index.d.ts +0 -40
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/logger/export.d.ts +0 -2
- package/dist/logger/export.d.ts.map +0 -1
- package/dist/logger/export.js.map +0 -1
- package/dist/matter/export.d.ts +0 -11
- package/dist/matter/export.d.ts.map +0 -1
- package/dist/matter/export.js.map +0 -1
- package/dist/matterbridge.d.ts +0 -483
- package/dist/matterbridge.d.ts.map +0 -1
- package/dist/matterbridge.js.map +0 -1
- package/dist/matterbridgeAccessoryPlatform.d.ts +0 -39
- package/dist/matterbridgeAccessoryPlatform.d.ts.map +0 -1
- package/dist/matterbridgeAccessoryPlatform.js.map +0 -1
- package/dist/matterbridgeBehaviors.d.ts +0 -942
- package/dist/matterbridgeBehaviors.d.ts.map +0 -1
- package/dist/matterbridgeBehaviors.js.map +0 -1
- package/dist/matterbridgeDevice.d.ts +0 -7077
- package/dist/matterbridgeDevice.d.ts.map +0 -1
- package/dist/matterbridgeDevice.js +0 -2736
- package/dist/matterbridgeDevice.js.map +0 -1
- package/dist/matterbridgeDeviceTypes.d.ts +0 -109
- package/dist/matterbridgeDeviceTypes.d.ts.map +0 -1
- package/dist/matterbridgeDeviceTypes.js.map +0 -1
- package/dist/matterbridgeDynamicPlatform.d.ts +0 -39
- package/dist/matterbridgeDynamicPlatform.d.ts.map +0 -1
- package/dist/matterbridgeDynamicPlatform.js.map +0 -1
- package/dist/matterbridgeEdge.d.ts +0 -91
- package/dist/matterbridgeEdge.d.ts.map +0 -1
- package/dist/matterbridgeEdge.js +0 -1077
- package/dist/matterbridgeEdge.js.map +0 -1
- package/dist/matterbridgeEndpoint.d.ts +0 -10156
- package/dist/matterbridgeEndpoint.d.ts.map +0 -1
- package/dist/matterbridgeEndpoint.js.map +0 -1
- package/dist/matterbridgePlatform.d.ts +0 -168
- package/dist/matterbridgePlatform.d.ts.map +0 -1
- package/dist/matterbridgePlatform.js.map +0 -1
- package/dist/matterbridgeTypes.d.ts +0 -172
- package/dist/matterbridgeTypes.d.ts.map +0 -1
- package/dist/matterbridgeTypes.js.map +0 -1
- package/dist/matterbridgeWebsocket.d.ts +0 -49
- package/dist/matterbridgeWebsocket.d.ts.map +0 -1
- package/dist/matterbridgeWebsocket.js +0 -325
- package/dist/matterbridgeWebsocket.js.map +0 -1
- package/dist/pluginManager.d.ts +0 -238
- package/dist/pluginManager.d.ts.map +0 -1
- package/dist/pluginManager.js.map +0 -1
- package/dist/storage/export.d.ts +0 -2
- package/dist/storage/export.d.ts.map +0 -1
- package/dist/storage/export.js.map +0 -1
- package/dist/utils/colorUtils.d.ts +0 -61
- package/dist/utils/colorUtils.d.ts.map +0 -1
- package/dist/utils/colorUtils.js.map +0 -1
- package/dist/utils/export.d.ts +0 -3
- package/dist/utils/export.d.ts.map +0 -1
- package/dist/utils/export.js.map +0 -1
- package/dist/utils/utils.d.ts +0 -221
- package/dist/utils/utils.d.ts.map +0 -1
- package/dist/utils/utils.js.map +0 -1
- package/frontend/build/static/js/main.08241820.js.map +0 -1
- /package/frontend/build/static/js/{main.08241820.js.LICENSE.txt → main.6204ae54.js.LICENSE.txt} +0 -0
|
@@ -1,2736 +0,0 @@
|
|
|
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
|
|
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, PumpConfigurationAndControl, PumpConfigurationAndControlCluster, RadonConcentrationMeasurement, RadonConcentrationMeasurementCluster, RelativeHumidityMeasurement, RelativeHumidityMeasurementCluster, SmokeCoAlarm, SmokeCoAlarmCluster, Switch, SwitchCluster, TemperatureMeasurement, TemperatureMeasurementCluster, Thermostat, ThermostatCluster, ThreadNetworkDiagnostics, ThreadNetworkDiagnosticsCluster, TimeSynchronization, TimeSynchronizationCluster, TotalVolatileOrganicCompoundsConcentrationMeasurement, TotalVolatileOrganicCompoundsConcentrationMeasurementCluster, ValveConfigurationAndControl, ValveConfigurationAndControlCluster, WindowCovering, WindowCoveringCluster, } from '@matter/main/clusters';
|
|
25
|
-
import { Specification } from '@matter/main/model';
|
|
26
|
-
import { EndpointNumber, extendPublicHandlerMethods, VendorId } from '@matter/main';
|
|
27
|
-
import { MeasurementType, getClusterNameById } from '@matter/main/types';
|
|
28
|
-
// @project-chip
|
|
29
|
-
import { Device } from '@project-chip/matter.js/device';
|
|
30
|
-
import { GroupsClusterHandler, ClusterServer } from '@project-chip/matter.js/cluster';
|
|
31
|
-
// AnsiLogger module
|
|
32
|
-
import { AnsiLogger, CYAN, YELLOW, db, hk, or, zb, debugStringify } from 'node-ansi-logger';
|
|
33
|
-
// Node.js modules
|
|
34
|
-
import { createHash } from 'crypto';
|
|
35
|
-
import { bridgedNode } from './matterbridgeDeviceTypes.js';
|
|
36
|
-
export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
37
|
-
static bridgeMode = '';
|
|
38
|
-
static logLevel = "info" /* LogLevel.INFO */;
|
|
39
|
-
log;
|
|
40
|
-
plugin = undefined;
|
|
41
|
-
configUrl = undefined;
|
|
42
|
-
serialNumber = undefined;
|
|
43
|
-
deviceName = undefined;
|
|
44
|
-
uniqueId = undefined;
|
|
45
|
-
vendorId = undefined;
|
|
46
|
-
vendorName = undefined;
|
|
47
|
-
productId = undefined;
|
|
48
|
-
productName = undefined;
|
|
49
|
-
softwareVersion = undefined;
|
|
50
|
-
softwareVersionString = undefined;
|
|
51
|
-
hardwareVersion = undefined;
|
|
52
|
-
hardwareVersionString = undefined;
|
|
53
|
-
/**
|
|
54
|
-
* Create a Matterbridge device.
|
|
55
|
-
* @constructor
|
|
56
|
-
* @param {DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>} definition - The DeviceTypeDefinition of the device.
|
|
57
|
-
* @param {EndpointOptions} [options={}] - The options for the device.
|
|
58
|
-
* @param {boolean} [debug=false] - The debug level for the device.
|
|
59
|
-
*/
|
|
60
|
-
constructor(definition, options = {}, debug = false) {
|
|
61
|
-
let firstDefinition;
|
|
62
|
-
if (Array.isArray(definition))
|
|
63
|
-
firstDefinition = definition[0];
|
|
64
|
-
else
|
|
65
|
-
firstDefinition = definition;
|
|
66
|
-
options.uniqueStorageKey?.replace(/[ .]/g, ''); // Remove spaces and dots from the uniqueStorageKey to avoid issues with storage converter
|
|
67
|
-
super(firstDefinition, options);
|
|
68
|
-
this.log = new AnsiLogger({ logName: 'MatterbridgeDevice', logTimestampFormat: 4 /* TimestampFormat.TIME_MILLIS */, logLevel: debug === true ? "debug" /* LogLevel.DEBUG */ : MatterbridgeDevice.logLevel });
|
|
69
|
-
this.log.debug(`new MatterbridgeDevice with deviceType: ${zb}${firstDefinition.code}${db}-${zb}${firstDefinition.name}${db}`);
|
|
70
|
-
if (Array.isArray(definition)) {
|
|
71
|
-
definition.forEach((deviceType) => {
|
|
72
|
-
this.addDeviceType(deviceType);
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
else
|
|
76
|
-
this.addDeviceType(firstDefinition);
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Loads asyncronously an instance of the MatterbridgeDevice class.
|
|
80
|
-
*
|
|
81
|
-
* @param {DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>} definition - The DeviceTypeDefinition of the device.
|
|
82
|
-
* @param {EndpointOptions} [options={}] - The options for the device.
|
|
83
|
-
* @param {boolean} [debug=false] - The debug level for the device.
|
|
84
|
-
* @returns {Promise<MatterbridgeDevice>} A Promise of MatterbridgeDevice instance.
|
|
85
|
-
*/
|
|
86
|
-
static async loadInstance(definition, options = {}, debug = false) {
|
|
87
|
-
return new MatterbridgeDevice(definition, options, debug);
|
|
88
|
-
}
|
|
89
|
-
// Present in new API but not here
|
|
90
|
-
get maybeNumber() {
|
|
91
|
-
return this.number;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Adds a device type to the list of device types of the MatterbridgeDevice endpoint.
|
|
95
|
-
* If the device type is not already present in the list, it will be added.
|
|
96
|
-
*
|
|
97
|
-
* @param {DeviceTypeDefinition} deviceType - The device type to add.
|
|
98
|
-
* @returns {MatterbridgeDevice} The MatterbridgeDevice instance.
|
|
99
|
-
*/
|
|
100
|
-
addDeviceType(deviceType) {
|
|
101
|
-
const deviceTypes = this.getDeviceTypes();
|
|
102
|
-
if (!deviceTypes.includes(deviceType)) {
|
|
103
|
-
this.log.debug(`addDeviceType: ${zb}${deviceType.code}${db}-${zb}${deviceType.name}${db}`);
|
|
104
|
-
deviceTypes.push(deviceType);
|
|
105
|
-
this.setDeviceTypes(deviceTypes);
|
|
106
|
-
}
|
|
107
|
-
return this;
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Adds one or more device types with the required cluster servers and the specified cluster servers.
|
|
111
|
-
*
|
|
112
|
-
* @param {AtLeastOne<DeviceTypeDefinition>} deviceTypes - The device types to add.
|
|
113
|
-
* @param {ClusterId[]} includeServerList - The list of cluster IDs to include.
|
|
114
|
-
* @returns {MatterbridgeDevice} The MatterbridgeDevice instance.
|
|
115
|
-
*/
|
|
116
|
-
addDeviceTypeWithClusterServer(deviceTypes, includeServerList = []) {
|
|
117
|
-
this.log.debug('addDeviceTypeWithClusterServer:');
|
|
118
|
-
deviceTypes.forEach((deviceType) => {
|
|
119
|
-
this.log.debug(`- with deviceType: ${zb}${deviceType.code}${db}-${zb}${deviceType.name}${db}`);
|
|
120
|
-
deviceType.requiredServerClusters.forEach((clusterId) => {
|
|
121
|
-
if (!includeServerList.includes(clusterId))
|
|
122
|
-
includeServerList.push(clusterId);
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
includeServerList.forEach((clusterId) => {
|
|
126
|
-
this.log.debug(`- with cluster: ${hk}${clusterId}${db}-${hk}${getClusterNameById(clusterId)}${db}`);
|
|
127
|
-
});
|
|
128
|
-
const endpointDeviceTypes = this.getDeviceTypes();
|
|
129
|
-
deviceTypes.forEach((deviceType) => {
|
|
130
|
-
if (!endpointDeviceTypes.includes(deviceType))
|
|
131
|
-
endpointDeviceTypes.push(deviceType);
|
|
132
|
-
});
|
|
133
|
-
this.setDeviceTypes(endpointDeviceTypes);
|
|
134
|
-
this.addClusterServerFromList(this, includeServerList);
|
|
135
|
-
return this;
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Adds a child endpoint with the specified device types and options.
|
|
139
|
-
* If the child endpoint is not already present, it will be created and added.
|
|
140
|
-
* If the child endpoint is already present, the device types will be added to the existing child endpoint.
|
|
141
|
-
*
|
|
142
|
-
* @param {string} endpointName - The name of the new endpoint to add.
|
|
143
|
-
* @param {AtLeastOne<DeviceTypeDefinition>} deviceTypes - The device types to add.
|
|
144
|
-
* @param {MatterbridgeEndpointOptions} [options={}] - The options for the endpoint.
|
|
145
|
-
* @param {boolean} [debug=false] - Whether to enable debug logging.
|
|
146
|
-
* @returns {MatterbridgeDevice} - The child endpoint that was found or added.
|
|
147
|
-
*
|
|
148
|
-
* @example
|
|
149
|
-
* ```typescript
|
|
150
|
-
* const endpoint = device.addChildDeviceType('Temperature', [temperatureSensor], { tagList: [{ mfgCode: null, namespaceId: LocationTag.Indoor.namespaceId, tag: LocationTag.Indoor.tag, label: null }] }, true);
|
|
151
|
-
* ```
|
|
152
|
-
*/
|
|
153
|
-
addChildDeviceType(endpointName, deviceTypes, options = {}, debug = false) {
|
|
154
|
-
this.log.debug(`addChildDeviceType: ${CYAN}${endpointName}${db}`);
|
|
155
|
-
let child = this.getChildEndpoints().find((endpoint) => endpoint.uniqueStorageKey === endpointName);
|
|
156
|
-
if (!child) {
|
|
157
|
-
child = new MatterbridgeDevice(deviceTypes, { uniqueStorageKey: endpointName }, debug);
|
|
158
|
-
if ('tagList' in options) {
|
|
159
|
-
for (const tag of options.tagList) {
|
|
160
|
-
this.log.debug(`- with tagList: mfgCode ${CYAN}${tag.mfgCode}${db} namespaceId ${CYAN}${tag.namespaceId}${db} tag ${CYAN}${tag.tag}${db} label ${CYAN}${tag.label}${db}`);
|
|
161
|
-
this.addTagList(child, tag.mfgCode, tag.namespaceId, tag.tag, tag.label);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
this.addChildEndpoint(child);
|
|
165
|
-
}
|
|
166
|
-
deviceTypes.forEach((deviceType) => {
|
|
167
|
-
this.log.debug(`- with deviceType: ${zb}${deviceType.code}${db}-${zb}${deviceType.name}${db}`);
|
|
168
|
-
});
|
|
169
|
-
const childDeviceTypes = child.getDeviceTypes();
|
|
170
|
-
deviceTypes.forEach((deviceType) => {
|
|
171
|
-
if (!childDeviceTypes.includes(deviceType))
|
|
172
|
-
childDeviceTypes.push(deviceType);
|
|
173
|
-
});
|
|
174
|
-
child.setDeviceTypes(childDeviceTypes);
|
|
175
|
-
return child;
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Adds a child endpoint with one or more device types with the required cluster servers and the specified cluster servers.
|
|
179
|
-
* If the child endpoint is not already present in the childEndpoints, it will be added.
|
|
180
|
-
* If the child endpoint is already present in the childEndpoints, the device types and cluster servers will be added to the existing child endpoint.
|
|
181
|
-
*
|
|
182
|
-
* @param {string} endpointName - The name of the new enpoint to add.
|
|
183
|
-
* @param {AtLeastOne<DeviceTypeDefinition>} deviceTypes - The device types to add.
|
|
184
|
-
* @param {ClusterId[]} [includeServerList=[]] - The list of cluster IDs to include.
|
|
185
|
-
* @param {EndpointOptions} [options={}] - The options for the device.
|
|
186
|
-
* @param {boolean} [debug=false] - Whether to enable debug logging.
|
|
187
|
-
* @returns {MatterbridgeDevice} - The child endpoint that was found or added.
|
|
188
|
-
*
|
|
189
|
-
* @example
|
|
190
|
-
* ```typescript
|
|
191
|
-
* const endpoint = device.addChildDeviceTypeWithClusterServer('Temperature', [temperatureSensor], [], { tagList: [{ mfgCode: null, namespaceId: LocationTag.Indoor.namespaceId, tag: LocationTag.Indoor.tag, label: null }] }, true);
|
|
192
|
-
* ```
|
|
193
|
-
*/
|
|
194
|
-
addChildDeviceTypeWithClusterServer(endpointName, deviceTypes, includeServerList = [], options = {}, debug = false) {
|
|
195
|
-
this.log.debug(`addChildDeviceTypeWithClusterServer: ${CYAN}${endpointName}${db}`);
|
|
196
|
-
let child = this.getChildEndpoints().find((endpoint) => endpoint.uniqueStorageKey === endpointName);
|
|
197
|
-
if (!child) {
|
|
198
|
-
child = new MatterbridgeDevice(deviceTypes, { uniqueStorageKey: endpointName }, debug);
|
|
199
|
-
if ('tagList' in options) {
|
|
200
|
-
for (const tag of options.tagList) {
|
|
201
|
-
this.log.debug(`- with tagList: mfgCode ${CYAN}${tag.mfgCode}${db} namespaceId ${CYAN}${tag.namespaceId}${db} tag ${CYAN}${tag.tag}${db} label ${CYAN}${tag.label}${db}`);
|
|
202
|
-
this.addTagList(child, tag.mfgCode, tag.namespaceId, tag.tag, tag.label);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
this.addChildEndpoint(child);
|
|
206
|
-
}
|
|
207
|
-
deviceTypes.forEach((deviceType) => {
|
|
208
|
-
this.log.debug(`- with deviceType: ${zb}${deviceType.code}${db}-${zb}${deviceType.name}${db}`);
|
|
209
|
-
deviceType.requiredServerClusters.forEach((clusterId) => {
|
|
210
|
-
if (!includeServerList.includes(clusterId))
|
|
211
|
-
includeServerList.push(clusterId);
|
|
212
|
-
});
|
|
213
|
-
});
|
|
214
|
-
includeServerList.forEach((clusterId) => {
|
|
215
|
-
this.log.debug(`- with cluster: ${hk}${clusterId}${db}-${hk}${getClusterNameById(clusterId)}${db}`);
|
|
216
|
-
});
|
|
217
|
-
const childDeviceTypes = child.getDeviceTypes();
|
|
218
|
-
deviceTypes.forEach((deviceType) => {
|
|
219
|
-
if (!childDeviceTypes.includes(deviceType))
|
|
220
|
-
childDeviceTypes.push(deviceType);
|
|
221
|
-
});
|
|
222
|
-
child.setDeviceTypes(childDeviceTypes);
|
|
223
|
-
this.addClusterServerFromList(child, includeServerList);
|
|
224
|
-
return child;
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* Adds the required cluster servers (only if they are not present) for the device types of the specified endpoint.
|
|
228
|
-
*
|
|
229
|
-
* @param {Endpoint} endpoint - The endpoint to add the required cluster servers to.
|
|
230
|
-
* @returns {Endpoint} The updated endpoint with the required cluster servers added.
|
|
231
|
-
*/
|
|
232
|
-
addRequiredClusterServers(endpoint) {
|
|
233
|
-
const requiredServerList = [];
|
|
234
|
-
this.log.debug(`addRequiredClusterServer for ${CYAN}${endpoint.name}${db}`);
|
|
235
|
-
endpoint.getDeviceTypes().forEach((deviceType) => {
|
|
236
|
-
this.log.debug(`- for deviceType: ${zb}${deviceType.code}${db}-${zb}${deviceType.name}${db}`);
|
|
237
|
-
deviceType.requiredServerClusters.forEach((clusterId) => {
|
|
238
|
-
if (!requiredServerList.includes(clusterId) && !endpoint.getClusterServerById(clusterId))
|
|
239
|
-
requiredServerList.push(clusterId);
|
|
240
|
-
});
|
|
241
|
-
});
|
|
242
|
-
requiredServerList.forEach((clusterId) => {
|
|
243
|
-
this.log.debug(`- with cluster: ${hk}${clusterId}${db}-${hk}${getClusterNameById(clusterId)}${db}`);
|
|
244
|
-
});
|
|
245
|
-
this.addClusterServerFromList(endpoint, requiredServerList);
|
|
246
|
-
return endpoint;
|
|
247
|
-
}
|
|
248
|
-
/**
|
|
249
|
-
* Adds the optional cluster servers (only if they are not present) for the device types of the specified endpoint.
|
|
250
|
-
*
|
|
251
|
-
* @param {Endpoint} endpoint - The endpoint to add the required cluster servers to.
|
|
252
|
-
* @returns {Endpoint} The updated endpoint with the required cluster servers added.
|
|
253
|
-
*/
|
|
254
|
-
addOptionalClusterServers(endpoint) {
|
|
255
|
-
const optionalServerList = [];
|
|
256
|
-
this.log.debug(`addRequiredClusterServer for ${CYAN}${endpoint.name}${db}`);
|
|
257
|
-
endpoint.getDeviceTypes().forEach((deviceType) => {
|
|
258
|
-
this.log.debug(`- for deviceType: ${zb}${deviceType.code}${db}-${zb}${deviceType.name}${db}`);
|
|
259
|
-
deviceType.optionalServerClusters.forEach((clusterId) => {
|
|
260
|
-
if (!optionalServerList.includes(clusterId) && !endpoint.getClusterServerById(clusterId))
|
|
261
|
-
optionalServerList.push(clusterId);
|
|
262
|
-
});
|
|
263
|
-
});
|
|
264
|
-
optionalServerList.forEach((clusterId) => {
|
|
265
|
-
this.log.debug(`- with cluster: ${hk}${clusterId}${db}-${hk}${getClusterNameById(clusterId)}${db}`);
|
|
266
|
-
});
|
|
267
|
-
this.addClusterServerFromList(endpoint, optionalServerList);
|
|
268
|
-
return endpoint;
|
|
269
|
-
}
|
|
270
|
-
/**
|
|
271
|
-
* Adds cluster servers to the specified endpoint based on the provided server list.
|
|
272
|
-
*
|
|
273
|
-
* @param {Endpoint} endpoint - The endpoint to add cluster servers to.
|
|
274
|
-
* @param {ClusterId[]} includeServerList - The list of cluster IDs to include.
|
|
275
|
-
* @returns {Endpoint} The updated endpoint with the cluster servers added.
|
|
276
|
-
*/
|
|
277
|
-
addClusterServerFromList(endpoint, includeServerList) {
|
|
278
|
-
if (includeServerList.includes(Identify.Cluster.id))
|
|
279
|
-
endpoint.addClusterServer(this.getDefaultIdentifyClusterServer());
|
|
280
|
-
if (includeServerList.includes(Groups.Cluster.id))
|
|
281
|
-
endpoint.addClusterServer(this.getDefaultGroupsClusterServer());
|
|
282
|
-
// if (includeServerList.includes(ScenesManagement.Cluster.id)) endpoint.addClusterServer(this.getDefaultScenesClusterServer());
|
|
283
|
-
if (includeServerList.includes(OnOff.Cluster.id))
|
|
284
|
-
endpoint.addClusterServer(this.getDefaultOnOffClusterServer());
|
|
285
|
-
if (includeServerList.includes(LevelControl.Cluster.id))
|
|
286
|
-
endpoint.addClusterServer(this.getDefaultLevelControlClusterServer());
|
|
287
|
-
if (includeServerList.includes(ColorControl.Cluster.id))
|
|
288
|
-
endpoint.addClusterServer(this.getDefaultColorControlClusterServer());
|
|
289
|
-
if (includeServerList.includes(Switch.Cluster.id))
|
|
290
|
-
endpoint.addClusterServer(this.getDefaultSwitchClusterServer());
|
|
291
|
-
if (includeServerList.includes(DoorLock.Cluster.id))
|
|
292
|
-
endpoint.addClusterServer(this.getDefaultDoorLockClusterServer());
|
|
293
|
-
if (includeServerList.includes(Thermostat.Cluster.id))
|
|
294
|
-
endpoint.addClusterServer(this.getDefaultThermostatClusterServer());
|
|
295
|
-
if (includeServerList.includes(TimeSynchronization.Cluster.id))
|
|
296
|
-
endpoint.addClusterServer(this.getDefaultTimeSyncClusterServer());
|
|
297
|
-
if (includeServerList.includes(WindowCovering.Cluster.id))
|
|
298
|
-
endpoint.addClusterServer(this.getDefaultWindowCoveringClusterServer());
|
|
299
|
-
if (includeServerList.includes(FanControl.Cluster.id))
|
|
300
|
-
endpoint.addClusterServer(this.getDefaultFanControlClusterServer());
|
|
301
|
-
if (includeServerList.includes(TemperatureMeasurement.Cluster.id))
|
|
302
|
-
endpoint.addClusterServer(this.getDefaultTemperatureMeasurementClusterServer());
|
|
303
|
-
if (includeServerList.includes(RelativeHumidityMeasurement.Cluster.id))
|
|
304
|
-
endpoint.addClusterServer(this.getDefaultRelativeHumidityMeasurementClusterServer());
|
|
305
|
-
if (includeServerList.includes(PressureMeasurement.Cluster.id))
|
|
306
|
-
endpoint.addClusterServer(this.getDefaultPressureMeasurementClusterServer());
|
|
307
|
-
if (includeServerList.includes(FlowMeasurement.Cluster.id))
|
|
308
|
-
endpoint.addClusterServer(this.getDefaultFlowMeasurementClusterServer());
|
|
309
|
-
if (includeServerList.includes(BooleanState.Cluster.id))
|
|
310
|
-
endpoint.addClusterServer(this.getDefaultBooleanStateClusterServer());
|
|
311
|
-
if (includeServerList.includes(BooleanStateConfiguration.Cluster.id))
|
|
312
|
-
endpoint.addClusterServer(this.getDefaultBooleanStateConfigurationClusterServer());
|
|
313
|
-
if (includeServerList.includes(OccupancySensing.Cluster.id))
|
|
314
|
-
endpoint.addClusterServer(this.getDefaultOccupancySensingClusterServer());
|
|
315
|
-
if (includeServerList.includes(IlluminanceMeasurement.Cluster.id))
|
|
316
|
-
endpoint.addClusterServer(this.getDefaultIlluminanceMeasurementClusterServer());
|
|
317
|
-
if (includeServerList.includes(PowerSource.Cluster.id))
|
|
318
|
-
endpoint.addClusterServer(this.getDefaultPowerSourceWiredClusterServer());
|
|
319
|
-
if (includeServerList.includes(PowerTopology.Cluster.id))
|
|
320
|
-
endpoint.addClusterServer(this.getDefaultPowerTopologyClusterServer());
|
|
321
|
-
if (includeServerList.includes(ElectricalPowerMeasurement.Cluster.id))
|
|
322
|
-
endpoint.addClusterServer(this.getDefaultElectricalPowerMeasurementClusterServer());
|
|
323
|
-
if (includeServerList.includes(ElectricalEnergyMeasurement.Cluster.id))
|
|
324
|
-
endpoint.addClusterServer(this.getDefaultElectricalEnergyMeasurementClusterServer());
|
|
325
|
-
if (includeServerList.includes(SmokeCoAlarm.Cluster.id))
|
|
326
|
-
endpoint.addClusterServer(this.getDefaultSmokeCOAlarmClusterServer());
|
|
327
|
-
if (includeServerList.includes(AirQuality.Cluster.id))
|
|
328
|
-
endpoint.addClusterServer(this.getDefaultAirQualityClusterServer());
|
|
329
|
-
if (includeServerList.includes(CarbonMonoxideConcentrationMeasurement.Cluster.id))
|
|
330
|
-
endpoint.addClusterServer(this.getDefaultCarbonMonoxideConcentrationMeasurementClusterServer());
|
|
331
|
-
if (includeServerList.includes(CarbonDioxideConcentrationMeasurement.Cluster.id))
|
|
332
|
-
endpoint.addClusterServer(this.getDefaultCarbonDioxideConcentrationMeasurementClusterServer());
|
|
333
|
-
if (includeServerList.includes(NitrogenDioxideConcentrationMeasurement.Cluster.id))
|
|
334
|
-
endpoint.addClusterServer(this.getDefaultNitrogenDioxideConcentrationMeasurementClusterServer());
|
|
335
|
-
if (includeServerList.includes(OzoneConcentrationMeasurement.Cluster.id))
|
|
336
|
-
endpoint.addClusterServer(this.getDefaultOzoneConcentrationMeasurementClusterServer());
|
|
337
|
-
if (includeServerList.includes(FormaldehydeConcentrationMeasurement.Cluster.id))
|
|
338
|
-
endpoint.addClusterServer(this.getDefaultFormaldehydeConcentrationMeasurementClusterServer());
|
|
339
|
-
if (includeServerList.includes(Pm1ConcentrationMeasurement.Cluster.id))
|
|
340
|
-
endpoint.addClusterServer(this.getDefaultPm1ConcentrationMeasurementClusterServer());
|
|
341
|
-
if (includeServerList.includes(Pm25ConcentrationMeasurement.Cluster.id))
|
|
342
|
-
endpoint.addClusterServer(this.getDefaultPm25ConcentrationMeasurementClusterServer());
|
|
343
|
-
if (includeServerList.includes(Pm10ConcentrationMeasurement.Cluster.id))
|
|
344
|
-
endpoint.addClusterServer(this.getDefaultPm10ConcentrationMeasurementClusterServer());
|
|
345
|
-
if (includeServerList.includes(RadonConcentrationMeasurement.Cluster.id))
|
|
346
|
-
endpoint.addClusterServer(this.getDefaultRadonConcentrationMeasurementClusterServer());
|
|
347
|
-
if (includeServerList.includes(TotalVolatileOrganicCompoundsConcentrationMeasurement.Cluster.id))
|
|
348
|
-
endpoint.addClusterServer(this.getDefaultTvocMeasurementClusterServer());
|
|
349
|
-
if (includeServerList.includes(DeviceEnergyManagement.Cluster.id))
|
|
350
|
-
endpoint.addClusterServer(this.getDefaultDeviceEnergyManagementClusterServer());
|
|
351
|
-
if (includeServerList.includes(DeviceEnergyManagementMode.Cluster.id))
|
|
352
|
-
endpoint.addClusterServer(this.getDefaultDeviceEnergyManagementModeClusterServer());
|
|
353
|
-
return endpoint;
|
|
354
|
-
}
|
|
355
|
-
/**
|
|
356
|
-
* Retrieves a child endpoint by its name.
|
|
357
|
-
*
|
|
358
|
-
* @param {string} endpointName - The name of the endpoint to retrieve.
|
|
359
|
-
* @returns {Endpoint | undefined} The child endpoint with the specified name, or undefined if not found.
|
|
360
|
-
*/
|
|
361
|
-
getChildEndpointByName(endpointName) {
|
|
362
|
-
return this.getChildEndpoints().find((endpoint) => endpoint.uniqueStorageKey === endpointName);
|
|
363
|
-
}
|
|
364
|
-
/**
|
|
365
|
-
* Retrieves the value of the specified attribute from the given endpoint and cluster.
|
|
366
|
-
*
|
|
367
|
-
* @param {ClusterId} clusterId - The ID of the cluster to retrieve the attribute from.
|
|
368
|
-
* @param {string} attribute - The name of the attribute to retrieve.
|
|
369
|
-
* @param {AnsiLogger} [log] - Optional logger for error and info messages.
|
|
370
|
-
* @param {Endpoint} [endpoint] - Optional the child endpoint to retrieve the attribute from.
|
|
371
|
-
* @returns {any} The value of the attribute, or undefined if the attribute is not found.
|
|
372
|
-
*/
|
|
373
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
374
|
-
getAttribute(clusterId, attribute, log, endpoint) {
|
|
375
|
-
if (!endpoint)
|
|
376
|
-
endpoint = this;
|
|
377
|
-
const clusterServer = endpoint.getClusterServerById(clusterId);
|
|
378
|
-
if (!clusterServer) {
|
|
379
|
-
this.log.error(`getAttribute error: Cluster ${clusterId} not found on endpoint ${endpoint.name}:${endpoint.number}`);
|
|
380
|
-
return undefined;
|
|
381
|
-
}
|
|
382
|
-
const capitalizedAttributeName = attribute.charAt(0).toUpperCase() + attribute.slice(1);
|
|
383
|
-
if (!clusterServer.isAttributeSupportedByName(attribute) && !clusterServer.isAttributeSupportedByName(capitalizedAttributeName)) {
|
|
384
|
-
this.log.error(`getAttribute error: Attribute ${attribute} not found on Cluster ${clusterServer.name} on endpoint ${endpoint.name}:${endpoint.number}`);
|
|
385
|
-
return undefined;
|
|
386
|
-
}
|
|
387
|
-
// Find the getter method
|
|
388
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
389
|
-
if (!clusterServer[`get${capitalizedAttributeName}Attribute`]) {
|
|
390
|
-
this.log.error(`getAttribute error: Getter get${capitalizedAttributeName}Attribute not found on Cluster ${clusterServer.name} on endpoint ${endpoint.name}:${endpoint.number}`);
|
|
391
|
-
return undefined;
|
|
392
|
-
}
|
|
393
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-empty-object-type
|
|
394
|
-
const getter = clusterServer[`get${capitalizedAttributeName}Attribute`];
|
|
395
|
-
const value = getter();
|
|
396
|
-
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}`);
|
|
397
|
-
return value;
|
|
398
|
-
}
|
|
399
|
-
/**
|
|
400
|
-
* Sets the value of an attribute on a cluster server endpoint.
|
|
401
|
-
*
|
|
402
|
-
* @param {ClusterId} clusterId - The ID of the cluster.
|
|
403
|
-
* @param {string} attribute - The name of the attribute.
|
|
404
|
-
* @param {any} value - The value to set for the attribute.
|
|
405
|
-
* @param {AnsiLogger} [log] - (Optional) The logger to use for logging errors and information.
|
|
406
|
-
* @param {Endpoint} [endpoint] - (Optional) The endpoint to set the attribute on. If not provided, the attribute will be set on the current endpoint.
|
|
407
|
-
*/
|
|
408
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
409
|
-
setAttribute(clusterId, attribute, value, log, endpoint) {
|
|
410
|
-
if (!endpoint)
|
|
411
|
-
endpoint = this;
|
|
412
|
-
const clusterServer = endpoint.getClusterServerById(clusterId);
|
|
413
|
-
if (!clusterServer) {
|
|
414
|
-
this.log.error(`setAttribute error: Cluster ${clusterId} not found on endpoint ${endpoint.name}:${endpoint.number}`);
|
|
415
|
-
return false;
|
|
416
|
-
}
|
|
417
|
-
const capitalizedAttributeName = attribute.charAt(0).toUpperCase() + attribute.slice(1);
|
|
418
|
-
if (!clusterServer.isAttributeSupportedByName(attribute) && !clusterServer.isAttributeSupportedByName(capitalizedAttributeName)) {
|
|
419
|
-
this.log.error(`setAttribute error: Attribute ${attribute} not found on Cluster ${clusterId} on endpoint ${endpoint.name}:${endpoint.number}`);
|
|
420
|
-
return false;
|
|
421
|
-
}
|
|
422
|
-
// Find the getter method
|
|
423
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
424
|
-
if (!clusterServer[`get${capitalizedAttributeName}Attribute`]) {
|
|
425
|
-
this.log.error(`setAttribute error: Getter get${capitalizedAttributeName}Attribute not found on Cluster ${clusterServer.name} on endpoint ${endpoint.name}:${endpoint.number}`);
|
|
426
|
-
return false;
|
|
427
|
-
}
|
|
428
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-empty-object-type
|
|
429
|
-
const getter = clusterServer[`get${capitalizedAttributeName}Attribute`];
|
|
430
|
-
// Find the setter method
|
|
431
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
432
|
-
if (!clusterServer[`set${capitalizedAttributeName}Attribute`]) {
|
|
433
|
-
this.log.error(`setAttribute error: Setter set${capitalizedAttributeName}Attribute not found on Cluster ${clusterServer.name} on endpoint ${endpoint.name}:${endpoint.number}`);
|
|
434
|
-
return false;
|
|
435
|
-
}
|
|
436
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-empty-object-type
|
|
437
|
-
const setter = clusterServer[`set${capitalizedAttributeName}Attribute`];
|
|
438
|
-
const oldValue = getter();
|
|
439
|
-
setter(value);
|
|
440
|
-
log?.info(`${db}Set endpoint ${or}${endpoint.name}:${endpoint.number}${db} attribute ${hk}${clusterServer.name}.${capitalizedAttributeName}${db} ` +
|
|
441
|
-
`from ${YELLOW}${typeof oldValue === 'object' ? debugStringify(oldValue) : oldValue}${db} ` +
|
|
442
|
-
`to ${YELLOW}${typeof value === 'object' ? debugStringify(value) : value}${db}`);
|
|
443
|
-
return true;
|
|
444
|
-
}
|
|
445
|
-
/**
|
|
446
|
-
* Subscribes to an attribute on a cluster.
|
|
447
|
-
*
|
|
448
|
-
* @param {ClusterId} clusterId - The ID of the cluster.
|
|
449
|
-
* @param {string} attribute - The name of the attribute to subscribe to.
|
|
450
|
-
* @param {(newValue: any, oldValue: any) => void} listener - A callback function that will be called when the attribute value changes.
|
|
451
|
-
* @param {AnsiLogger} log - (Optional) An AnsiLogger instance for logging errors and information.
|
|
452
|
-
* @param {Endpoint} endpoint - (Optional) The endpoint to subscribe the attribute on. If not provided, the current endpoint will be used.
|
|
453
|
-
* @returns A boolean indicating whether the subscription was successful.
|
|
454
|
-
*/
|
|
455
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
456
|
-
subscribeAttribute(clusterId, attribute, listener, log, endpoint) {
|
|
457
|
-
if (!endpoint)
|
|
458
|
-
endpoint = this;
|
|
459
|
-
const clusterServer = endpoint.getClusterServerById(clusterId);
|
|
460
|
-
if (!clusterServer) {
|
|
461
|
-
this.log.error(`subscribeAttribute error: Cluster ${clusterId} not found on endpoint ${endpoint.name}:${endpoint.number}`);
|
|
462
|
-
return false;
|
|
463
|
-
}
|
|
464
|
-
const capitalizedAttributeName = attribute.charAt(0).toUpperCase() + attribute.slice(1);
|
|
465
|
-
if (!clusterServer.isAttributeSupportedByName(attribute) && !clusterServer.isAttributeSupportedByName(capitalizedAttributeName)) {
|
|
466
|
-
this.log.error(`subscribeAttribute error: Attribute ${attribute} not found on Cluster ${clusterServer.name} on endpoint ${endpoint.name}:${endpoint.number}`);
|
|
467
|
-
return false;
|
|
468
|
-
}
|
|
469
|
-
// Find the subscribe method
|
|
470
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
471
|
-
if (!clusterServer[`subscribe${capitalizedAttributeName}Attribute`]) {
|
|
472
|
-
this.log.error(`subscribeAttribute error: subscribe${capitalizedAttributeName}Attribute not found on Cluster ${clusterServer.name} on endpoint ${endpoint.name}:${endpoint.number}`);
|
|
473
|
-
return false;
|
|
474
|
-
}
|
|
475
|
-
// Subscribe to the attribute
|
|
476
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-empty-object-type
|
|
477
|
-
const subscribe = clusterServer[`subscribe${capitalizedAttributeName}Attribute`];
|
|
478
|
-
subscribe(listener);
|
|
479
|
-
log?.info(`${db}Subscribe endpoint ${or}${endpoint.name}:${endpoint.number}${db} attribute ${hk}${clusterServer.name}.${capitalizedAttributeName}${db}`);
|
|
480
|
-
return true;
|
|
481
|
-
}
|
|
482
|
-
/**
|
|
483
|
-
* Triggers the specified event of the specified cluster from the given endpoint and cluster.
|
|
484
|
-
*
|
|
485
|
-
* @param {ClusterId} clusterId - The ID of the cluster to retrieve the event from.
|
|
486
|
-
* @param {string} event - The name of the event to trigger.
|
|
487
|
-
* @param {Record<string, any>} payload - The payload of the event to trigger.
|
|
488
|
-
* @param {AnsiLogger} [log] - Optional logger for error and info messages.
|
|
489
|
-
* @param {Endpoint} [endpoint] - Optional the child endpoint to retrieve the event from.
|
|
490
|
-
*/
|
|
491
|
-
triggerEvent(clusterId, event, payload, log, endpoint) {
|
|
492
|
-
if (!endpoint)
|
|
493
|
-
endpoint = this;
|
|
494
|
-
if (!endpoint.number)
|
|
495
|
-
return;
|
|
496
|
-
const clusterServer = endpoint.getClusterServerById(clusterId);
|
|
497
|
-
if (!clusterServer) {
|
|
498
|
-
this.log.error(`triggerEvent error: Cluster ${clusterId} not found on endpoint ${endpoint.name}:${endpoint.number}`);
|
|
499
|
-
return;
|
|
500
|
-
}
|
|
501
|
-
const capitalizedEventName = event.charAt(0).toUpperCase() + event.slice(1);
|
|
502
|
-
if (!clusterServer.isEventSupportedByName(event) && !clusterServer.isEventSupportedByName(capitalizedEventName)) {
|
|
503
|
-
this.log.error(`triggerEvent error: Event ${event} not found on Cluster ${clusterServer.name} on endpoint ${endpoint.name}:${endpoint.number}`);
|
|
504
|
-
return;
|
|
505
|
-
}
|
|
506
|
-
// Find the getter method
|
|
507
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
508
|
-
if (!clusterServer[`trigger${capitalizedEventName}Event`]) {
|
|
509
|
-
this.log.error(`triggerEvent error: Trigger trigger${capitalizedEventName}Event not found on Cluster ${clusterServer.name} on endpoint ${endpoint.name}:${endpoint.number}`);
|
|
510
|
-
return;
|
|
511
|
-
}
|
|
512
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-empty-object-type
|
|
513
|
-
const trigger = clusterServer[`trigger${capitalizedEventName}Event`];
|
|
514
|
-
trigger(payload);
|
|
515
|
-
log?.info(`${db}Trigger event ${hk}${clusterServer.name}.${capitalizedEventName}${db} on endpoint ${or}${endpoint.name}:${endpoint.number}${db}`);
|
|
516
|
-
}
|
|
517
|
-
/**
|
|
518
|
-
* Adds a tag to the tag list of the specified endpoint.
|
|
519
|
-
*
|
|
520
|
-
* @param {Endpoint} endpoint - The endpoint to add the tag to.
|
|
521
|
-
* @param {VendorId | null} mfgCode - The manufacturer code.
|
|
522
|
-
* @param {number} namespaceId - The namespace ID of the tag.
|
|
523
|
-
* @param {number} tag - The tag number.
|
|
524
|
-
* @param {string | null} [label=null] - The label for the tag.
|
|
525
|
-
*
|
|
526
|
-
* @remarks
|
|
527
|
-
* This method is used to add a tag to the tag list of a given endpoint.
|
|
528
|
-
* 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.
|
|
529
|
-
*
|
|
530
|
-
* Example usage:
|
|
531
|
-
* ```typescript
|
|
532
|
-
* this.addTagList(endpoint, null, NumberTag.One.namespaceId, NumberTag.One.tag, 'Label');
|
|
533
|
-
* this.addTagList(endpoint, null, SwitchesTag.Custom.namespaceId, SwitchesTag.Custom.tag, 'Label');
|
|
534
|
-
* ```
|
|
535
|
-
*/
|
|
536
|
-
addTagList(endpoint, mfgCode, namespaceId, tag, label) {
|
|
537
|
-
const descriptor = endpoint.getClusterServer(DescriptorCluster.with(Descriptor.Feature.TagList));
|
|
538
|
-
if (!descriptor) {
|
|
539
|
-
this.log.error(`addTagList: descriptor cluster not found on endpoint ${endpoint.name}:${endpoint.number}`);
|
|
540
|
-
return;
|
|
541
|
-
}
|
|
542
|
-
// tagList: { mfgCode: VendorId | null; namespaceId: number; tag: number; label?: string | null }[] = [];
|
|
543
|
-
if (descriptor.attributes.tagList) {
|
|
544
|
-
this.log.debug(`addTagList: adding ${CYAN}tagList${db} mfCode: ${mfgCode}, namespaceId: ${namespaceId}, tag: ${tag}, label: ${label} on endpoint ${endpoint.name}:${endpoint.number}`);
|
|
545
|
-
const tagList = descriptor.attributes.tagList.getLocal();
|
|
546
|
-
tagList.push({ mfgCode, namespaceId, tag, label });
|
|
547
|
-
return;
|
|
548
|
-
}
|
|
549
|
-
this.log.debug(`addTagList: creating ${CYAN}tagList${db} mfCode: ${mfgCode}, namespaceId: ${namespaceId}, tag: ${tag}, label: ${label} on endpoint ${endpoint.name}:${endpoint.number}`);
|
|
550
|
-
endpoint.addClusterServer(ClusterServer(DescriptorCluster.with(Descriptor.Feature.TagList), {
|
|
551
|
-
tagList: [{ mfgCode, namespaceId, tag, label }],
|
|
552
|
-
deviceTypeList: [...descriptor.attributes.deviceTypeList.getLocal()],
|
|
553
|
-
serverList: [...descriptor.attributes.serverList.getLocal()],
|
|
554
|
-
clientList: [...descriptor.attributes.clientList.getLocal()],
|
|
555
|
-
partsList: [...descriptor.attributes.partsList.getLocal()],
|
|
556
|
-
}, {}, {}));
|
|
557
|
-
}
|
|
558
|
-
/**
|
|
559
|
-
* Serializes the Matterbridge device into a serialized object.
|
|
560
|
-
*
|
|
561
|
-
* @param pluginName - The name of the plugin.
|
|
562
|
-
* @returns The serialized Matterbridge device object.
|
|
563
|
-
*/
|
|
564
|
-
serialize() {
|
|
565
|
-
if (!this.serialNumber || !this.deviceName || !this.uniqueId)
|
|
566
|
-
return;
|
|
567
|
-
const cluster = this.getClusterServer(BasicInformationCluster) ?? this.getClusterServer(BridgedDeviceBasicInformationCluster);
|
|
568
|
-
if (!cluster)
|
|
569
|
-
return;
|
|
570
|
-
const serialized = {
|
|
571
|
-
pluginName: this.plugin ?? 'Unknown',
|
|
572
|
-
serialNumber: this.serialNumber,
|
|
573
|
-
deviceName: this.deviceName,
|
|
574
|
-
uniqueId: this.uniqueId,
|
|
575
|
-
productName: cluster.attributes.productName?.getLocal(),
|
|
576
|
-
vendorId: cluster.attributes.vendorId?.getLocal(),
|
|
577
|
-
vendorName: cluster.attributes.vendorName?.getLocal(),
|
|
578
|
-
deviceTypes: this.getDeviceTypes(),
|
|
579
|
-
endpoint: this.number,
|
|
580
|
-
endpointName: this.name,
|
|
581
|
-
clusterServersId: [],
|
|
582
|
-
};
|
|
583
|
-
this.getAllClusterServers().forEach((clusterServer) => {
|
|
584
|
-
serialized.clusterServersId.push(clusterServer.id);
|
|
585
|
-
});
|
|
586
|
-
return serialized;
|
|
587
|
-
}
|
|
588
|
-
/**
|
|
589
|
-
* Deserializes the device into a serialized object.
|
|
590
|
-
*
|
|
591
|
-
* @returns The deserialized MatterbridgeDevice.
|
|
592
|
-
*/
|
|
593
|
-
static deserialize(serializedDevice) {
|
|
594
|
-
const device = new MatterbridgeDevice(serializedDevice.deviceTypes);
|
|
595
|
-
device.serialNumber = serializedDevice.serialNumber;
|
|
596
|
-
device.deviceName = serializedDevice.deviceName;
|
|
597
|
-
device.uniqueId = serializedDevice.uniqueId;
|
|
598
|
-
for (const clusterId of serializedDevice.clusterServersId) {
|
|
599
|
-
if (clusterId === BasicInformationCluster.id)
|
|
600
|
-
device.createDefaultBasicInformationClusterServer(serializedDevice.deviceName, serializedDevice.serialNumber, serializedDevice.vendorId ?? 0xfff1, serializedDevice.vendorName ?? 'Matterbridge', serializedDevice.productId ?? 0x8000, serializedDevice.productName ?? 'Matterbridge device');
|
|
601
|
-
else if (clusterId === BridgedDeviceBasicInformationCluster.id)
|
|
602
|
-
device.createDefaultBridgedDeviceBasicInformationClusterServer(serializedDevice.deviceName, serializedDevice.serialNumber, serializedDevice.vendorId ?? 0xfff1, serializedDevice.vendorName ?? 'Matterbridge', serializedDevice.productName ?? 'Matterbridge device');
|
|
603
|
-
else
|
|
604
|
-
device.addClusterServerFromList(device, [clusterId]);
|
|
605
|
-
}
|
|
606
|
-
return device;
|
|
607
|
-
}
|
|
608
|
-
/**
|
|
609
|
-
* Get a default IdentifyCluster server.
|
|
610
|
-
*/
|
|
611
|
-
getDefaultIdentifyClusterServer(identifyTime = 0, identifyType = Identify.IdentifyType.None) {
|
|
612
|
-
return ClusterServer(IdentifyCluster, {
|
|
613
|
-
identifyTime,
|
|
614
|
-
identifyType,
|
|
615
|
-
}, {
|
|
616
|
-
identify: async (data) => {
|
|
617
|
-
this.log.debug('Matter command: Identify');
|
|
618
|
-
await this.commandHandler.executeHandler('identify', data);
|
|
619
|
-
},
|
|
620
|
-
triggerEffect: async (data) => {
|
|
621
|
-
this.log.debug('Matter command: TriggerEffect');
|
|
622
|
-
await this.commandHandler.executeHandler('triggerEffect', data);
|
|
623
|
-
},
|
|
624
|
-
});
|
|
625
|
-
}
|
|
626
|
-
/**
|
|
627
|
-
* Creates a default IdentifyCluster server.
|
|
628
|
-
*/
|
|
629
|
-
createDefaultIdentifyClusterServer(identifyTime = 0, identifyType = Identify.IdentifyType.None) {
|
|
630
|
-
this.addClusterServer(this.getDefaultIdentifyClusterServer(identifyTime, identifyType));
|
|
631
|
-
return this;
|
|
632
|
-
}
|
|
633
|
-
/**
|
|
634
|
-
* Get a default IdentifyCluster server.
|
|
635
|
-
*/
|
|
636
|
-
getDefaultGroupsClusterServer() {
|
|
637
|
-
return ClusterServer(GroupsCluster, {
|
|
638
|
-
nameSupport: {
|
|
639
|
-
nameSupport: true,
|
|
640
|
-
},
|
|
641
|
-
}, GroupsClusterHandler());
|
|
642
|
-
// return createDefaultGroupsClusterServer();
|
|
643
|
-
}
|
|
644
|
-
/**
|
|
645
|
-
* Creates a default groups cluster server and adds it to the device.
|
|
646
|
-
*/
|
|
647
|
-
createDefaultGroupsClusterServer() {
|
|
648
|
-
this.addClusterServer(this.getDefaultGroupsClusterServer());
|
|
649
|
-
return this;
|
|
650
|
-
}
|
|
651
|
-
/**
|
|
652
|
-
* Get a default scenes cluster server and adds it to the current instance.
|
|
653
|
-
* @deprecated This method is deprecated.
|
|
654
|
-
*
|
|
655
|
-
*/
|
|
656
|
-
getDefaultScenesClusterServer() {
|
|
657
|
-
/*
|
|
658
|
-
return ClusterServer(
|
|
659
|
-
ScenesCluster,
|
|
660
|
-
{
|
|
661
|
-
sceneCount: 0,
|
|
662
|
-
currentScene: 0,
|
|
663
|
-
currentGroup: GroupId(0),
|
|
664
|
-
sceneValid: false,
|
|
665
|
-
nameSupport: {
|
|
666
|
-
nameSupport: true,
|
|
667
|
-
},
|
|
668
|
-
lastConfiguredBy: null,
|
|
669
|
-
},
|
|
670
|
-
{},
|
|
671
|
-
);
|
|
672
|
-
*/
|
|
673
|
-
}
|
|
674
|
-
/**
|
|
675
|
-
* Creates a default scenes cluster server and adds it to the current instance.
|
|
676
|
-
* @deprecated This method is deprecated.
|
|
677
|
-
*/
|
|
678
|
-
createDefaultScenesClusterServer() {
|
|
679
|
-
/*
|
|
680
|
-
this.addClusterServer(this.getDefaultScenesClusterServer());
|
|
681
|
-
*/
|
|
682
|
-
return this;
|
|
683
|
-
}
|
|
684
|
-
/**
|
|
685
|
-
* Creates a unique identifier based on the provided parameters.
|
|
686
|
-
* @param param1 - The first parameter.
|
|
687
|
-
* @param param2 - The second parameter.
|
|
688
|
-
* @param param3 - The third parameter.
|
|
689
|
-
* @param param4 - The fourth parameter.
|
|
690
|
-
* @returns A unique identifier generated using the MD5 hash algorithm.
|
|
691
|
-
*/
|
|
692
|
-
createUniqueId(param1, param2, param3, param4) {
|
|
693
|
-
const hash = createHash('md5');
|
|
694
|
-
hash.update(param1 + param2 + param3 + param4);
|
|
695
|
-
return hash.digest('hex');
|
|
696
|
-
}
|
|
697
|
-
/**
|
|
698
|
-
* Get a default Basic Information Cluster Server.
|
|
699
|
-
*
|
|
700
|
-
* @param deviceName - The name of the device.
|
|
701
|
-
* @param serialNumber - The serial number of the device.
|
|
702
|
-
* @param vendorId - The vendor ID of the device.
|
|
703
|
-
* @param vendorName - The vendor name of the device.
|
|
704
|
-
* @param productId - The product ID of the device.
|
|
705
|
-
* @param productName - The product name of the device.
|
|
706
|
-
* @param softwareVersion - The software version of the device. Default is 1.
|
|
707
|
-
* @param softwareVersionString - The software version string of the device. Default is 'v.1.0.0'.
|
|
708
|
-
* @param hardwareVersion - The hardware version of the device. Default is 1.
|
|
709
|
-
* @param hardwareVersionString - The hardware version string of the device. Default is 'v.1.0.0'.
|
|
710
|
-
*/
|
|
711
|
-
getDefaultBasicInformationClusterServer(deviceName, serialNumber, vendorId, vendorName, productId, productName, softwareVersion = 1, softwareVersionString = '1.0.0', hardwareVersion = 1, hardwareVersionString = '1.0.0') {
|
|
712
|
-
this.log.logName = deviceName;
|
|
713
|
-
this.deviceName = deviceName;
|
|
714
|
-
this.serialNumber = serialNumber;
|
|
715
|
-
this.uniqueId = this.createUniqueId(deviceName, serialNumber, vendorName, productName);
|
|
716
|
-
this.productId = productId;
|
|
717
|
-
this.productName = productName;
|
|
718
|
-
this.vendorId = vendorId;
|
|
719
|
-
this.vendorName = vendorName;
|
|
720
|
-
this.softwareVersion = softwareVersion;
|
|
721
|
-
this.softwareVersionString = softwareVersionString;
|
|
722
|
-
this.hardwareVersion = hardwareVersion;
|
|
723
|
-
this.hardwareVersionString = hardwareVersionString;
|
|
724
|
-
return ClusterServer(BasicInformationCluster, {
|
|
725
|
-
dataModelRevision: 1,
|
|
726
|
-
location: 'XX',
|
|
727
|
-
vendorId: VendorId(vendorId),
|
|
728
|
-
vendorName: vendorName.slice(0, 32),
|
|
729
|
-
productId: productId,
|
|
730
|
-
productName: productName.slice(0, 32),
|
|
731
|
-
productUrl: 'https://www.npmjs.com/package/matterbridge',
|
|
732
|
-
productLabel: deviceName.slice(0, 64),
|
|
733
|
-
nodeLabel: deviceName.slice(0, 32),
|
|
734
|
-
serialNumber: serialNumber.slice(0, 32),
|
|
735
|
-
uniqueId: this.createUniqueId(deviceName, serialNumber, vendorName, productName),
|
|
736
|
-
softwareVersion,
|
|
737
|
-
softwareVersionString: softwareVersionString.slice(0, 64),
|
|
738
|
-
hardwareVersion,
|
|
739
|
-
hardwareVersionString: hardwareVersionString.slice(0, 64),
|
|
740
|
-
reachable: true,
|
|
741
|
-
capabilityMinima: { caseSessionsPerFabric: 3, subscriptionsPerFabric: 3 },
|
|
742
|
-
specificationVersion: Specification.SPECIFICATION_VERSION,
|
|
743
|
-
maxPathsPerInvoke: 1,
|
|
744
|
-
}, {}, {
|
|
745
|
-
startUp: true,
|
|
746
|
-
shutDown: true,
|
|
747
|
-
leave: true,
|
|
748
|
-
reachableChanged: true,
|
|
749
|
-
});
|
|
750
|
-
}
|
|
751
|
-
/**
|
|
752
|
-
* Creates a default Basic Information Cluster Server.
|
|
753
|
-
*
|
|
754
|
-
* @param deviceName - The name of the device.
|
|
755
|
-
* @param serialNumber - The serial number of the device.
|
|
756
|
-
* @param vendorId - The vendor ID of the device.
|
|
757
|
-
* @param vendorName - The vendor name of the device.
|
|
758
|
-
* @param productId - The product ID of the device.
|
|
759
|
-
* @param productName - The product name of the device.
|
|
760
|
-
* @param softwareVersion - The software version of the device. Default is 1.
|
|
761
|
-
* @param softwareVersionString - The software version string of the device. Default is 'v.1.0.0'.
|
|
762
|
-
* @param hardwareVersion - The hardware version of the device. Default is 1.
|
|
763
|
-
* @param hardwareVersionString - The hardware version string of the device. Default is 'v.1.0.0'.
|
|
764
|
-
*/
|
|
765
|
-
createDefaultBasicInformationClusterServer(deviceName, serialNumber, vendorId, vendorName, productId, productName, softwareVersion = 1, softwareVersionString = '1.0.0', hardwareVersion = 1, hardwareVersionString = '1.0.0') {
|
|
766
|
-
if (MatterbridgeDevice.bridgeMode === 'bridge') {
|
|
767
|
-
this.addDeviceType(bridgedNode);
|
|
768
|
-
this.createDefaultBridgedDeviceBasicInformationClusterServer(deviceName, serialNumber, vendorId, vendorName, productName, softwareVersion, softwareVersionString, hardwareVersion, hardwareVersionString);
|
|
769
|
-
return;
|
|
770
|
-
}
|
|
771
|
-
this.addClusterServer(this.getDefaultBasicInformationClusterServer(deviceName, serialNumber, vendorId, vendorName, productId, productName, softwareVersion, softwareVersionString, hardwareVersion, hardwareVersionString));
|
|
772
|
-
return this;
|
|
773
|
-
}
|
|
774
|
-
/**
|
|
775
|
-
* Get a default BridgedDeviceBasicInformationClusterServer.
|
|
776
|
-
*
|
|
777
|
-
* @param deviceName - The name of the device.
|
|
778
|
-
* @param serialNumber - The serial number of the device.
|
|
779
|
-
* @param vendorId - The vendor ID of the device.
|
|
780
|
-
* @param vendorName - The name of the vendor.
|
|
781
|
-
* @param productName - The name of the product.
|
|
782
|
-
* @param softwareVersion - The software version of the device. Default is 1.
|
|
783
|
-
* @param softwareVersionString - The software version string of the device. Default is 'v.1.0.0'.
|
|
784
|
-
* @param hardwareVersion - The hardware version of the device. Default is 1.
|
|
785
|
-
* @param hardwareVersionString - The hardware version string of the device. Default is 'v.1.0.0'.
|
|
786
|
-
*/
|
|
787
|
-
getDefaultBridgedDeviceBasicInformationClusterServer(deviceName, serialNumber, vendorId, vendorName, productName, softwareVersion = 1, softwareVersionString = '1.0.0', hardwareVersion = 1, hardwareVersionString = '1.0.0') {
|
|
788
|
-
this.log.logName = deviceName;
|
|
789
|
-
this.deviceName = deviceName;
|
|
790
|
-
this.serialNumber = serialNumber;
|
|
791
|
-
this.uniqueId = this.createUniqueId(deviceName, serialNumber, vendorName, productName);
|
|
792
|
-
this.productId = undefined;
|
|
793
|
-
this.productName = productName;
|
|
794
|
-
this.vendorId = vendorId;
|
|
795
|
-
this.vendorName = vendorName;
|
|
796
|
-
this.softwareVersion = softwareVersion;
|
|
797
|
-
this.softwareVersionString = softwareVersionString;
|
|
798
|
-
this.hardwareVersion = hardwareVersion;
|
|
799
|
-
this.hardwareVersionString = hardwareVersionString;
|
|
800
|
-
return ClusterServer(BridgedDeviceBasicInformationCluster, {
|
|
801
|
-
vendorId: vendorId !== undefined ? VendorId(vendorId) : undefined, // 4874
|
|
802
|
-
vendorName: vendorName.slice(0, 32),
|
|
803
|
-
productName: productName.slice(0, 32),
|
|
804
|
-
productUrl: 'https://www.npmjs.com/package/matterbridge',
|
|
805
|
-
productLabel: deviceName.slice(0, 64),
|
|
806
|
-
nodeLabel: deviceName.slice(0, 32),
|
|
807
|
-
serialNumber: serialNumber.slice(0, 32),
|
|
808
|
-
uniqueId: this.createUniqueId(deviceName, serialNumber, vendorName, productName),
|
|
809
|
-
softwareVersion,
|
|
810
|
-
softwareVersionString: softwareVersionString.slice(0, 64),
|
|
811
|
-
hardwareVersion,
|
|
812
|
-
hardwareVersionString: hardwareVersionString.slice(0, 64),
|
|
813
|
-
reachable: true,
|
|
814
|
-
}, {}, {
|
|
815
|
-
startUp: true,
|
|
816
|
-
shutDown: true,
|
|
817
|
-
leave: true,
|
|
818
|
-
reachableChanged: true,
|
|
819
|
-
});
|
|
820
|
-
}
|
|
821
|
-
/**
|
|
822
|
-
* Creates a default BridgedDeviceBasicInformationClusterServer.
|
|
823
|
-
*
|
|
824
|
-
* @param deviceName - The name of the device.
|
|
825
|
-
* @param serialNumber - The serial number of the device.
|
|
826
|
-
* @param vendorId - The vendor ID of the device.
|
|
827
|
-
* @param vendorName - The name of the vendor.
|
|
828
|
-
* @param productName - The name of the product.
|
|
829
|
-
* @param softwareVersion - The software version of the device. Default is 1.
|
|
830
|
-
* @param softwareVersionString - The software version string of the device. Default is 'v.1.0.0'.
|
|
831
|
-
* @param hardwareVersion - The hardware version of the device. Default is 1.
|
|
832
|
-
* @param hardwareVersionString - The hardware version string of the device. Default is 'v.1.0.0'.
|
|
833
|
-
*/
|
|
834
|
-
createDefaultBridgedDeviceBasicInformationClusterServer(deviceName, serialNumber, vendorId, vendorName, productName, softwareVersion = 1, softwareVersionString = '1.0.0', hardwareVersion = 1, hardwareVersionString = '1.0.0') {
|
|
835
|
-
this.addClusterServer(this.getDefaultBridgedDeviceBasicInformationClusterServer(deviceName, serialNumber, vendorId, vendorName, productName, softwareVersion, softwareVersionString, hardwareVersion, hardwareVersionString));
|
|
836
|
-
return this;
|
|
837
|
-
}
|
|
838
|
-
/**
|
|
839
|
-
* Get a default Power Topology Cluster Server.
|
|
840
|
-
*
|
|
841
|
-
* @returns {ClusterServer} - The configured Power Topology Cluster Server.
|
|
842
|
-
*/
|
|
843
|
-
getDefaultPowerTopologyClusterServer() {
|
|
844
|
-
return ClusterServer(PowerTopologyCluster.with(PowerTopology.Feature.TreeTopology), {}, {}, {});
|
|
845
|
-
}
|
|
846
|
-
/**
|
|
847
|
-
* Get a default Electrical Energy Measurement Cluster Server.
|
|
848
|
-
*
|
|
849
|
-
* @param {number} energy - The total consumption value in mW/h.
|
|
850
|
-
* @returns {ClusterServer} - The configured Electrical Energy Measurement Cluster Server.
|
|
851
|
-
*/
|
|
852
|
-
getDefaultElectricalEnergyMeasurementClusterServer(energy = null) {
|
|
853
|
-
return ClusterServer(ElectricalEnergyMeasurementCluster.with(ElectricalEnergyMeasurement.Feature.ImportedEnergy, ElectricalEnergyMeasurement.Feature.ExportedEnergy, ElectricalEnergyMeasurement.Feature.CumulativeEnergy), {
|
|
854
|
-
accuracy: {
|
|
855
|
-
measurementType: MeasurementType.ElectricalEnergy,
|
|
856
|
-
measured: true,
|
|
857
|
-
minMeasuredValue: Number.MIN_SAFE_INTEGER,
|
|
858
|
-
maxMeasuredValue: Number.MAX_SAFE_INTEGER,
|
|
859
|
-
accuracyRanges: [{ rangeMin: Number.MIN_SAFE_INTEGER, rangeMax: Number.MAX_SAFE_INTEGER, fixedMax: 1 }],
|
|
860
|
-
},
|
|
861
|
-
cumulativeEnergyReset: null,
|
|
862
|
-
cumulativeEnergyImported: energy ? { energy } : null,
|
|
863
|
-
cumulativeEnergyExported: null,
|
|
864
|
-
}, {}, {
|
|
865
|
-
cumulativeEnergyMeasured: true,
|
|
866
|
-
});
|
|
867
|
-
}
|
|
868
|
-
/**
|
|
869
|
-
* Get a default Electrical Power Measurement Cluster Server.
|
|
870
|
-
*
|
|
871
|
-
* @param {number} voltage - The voltage value in millivolts.
|
|
872
|
-
* @param {number} current - The current value in milliamperes.
|
|
873
|
-
* @param {number} power - The power value in milliwatts.
|
|
874
|
-
* @param {number} frequency - The frequency value in millihertz.
|
|
875
|
-
* @returns {ClusterServer} - The configured Electrical Power Measurement Cluster Server.
|
|
876
|
-
*/
|
|
877
|
-
getDefaultElectricalPowerMeasurementClusterServer(voltage = null, current = null, power = null, frequency = null) {
|
|
878
|
-
return ClusterServer(ElectricalPowerMeasurementCluster.with(ElectricalPowerMeasurement.Feature.AlternatingCurrent), {
|
|
879
|
-
powerMode: ElectricalPowerMeasurement.PowerMode.Ac,
|
|
880
|
-
numberOfMeasurementTypes: 4,
|
|
881
|
-
accuracy: [
|
|
882
|
-
{
|
|
883
|
-
measurementType: MeasurementType.Voltage,
|
|
884
|
-
measured: true,
|
|
885
|
-
minMeasuredValue: Number.MIN_SAFE_INTEGER,
|
|
886
|
-
maxMeasuredValue: Number.MAX_SAFE_INTEGER,
|
|
887
|
-
accuracyRanges: [{ rangeMin: Number.MIN_SAFE_INTEGER, rangeMax: Number.MAX_SAFE_INTEGER, fixedMax: 1 }],
|
|
888
|
-
},
|
|
889
|
-
{
|
|
890
|
-
measurementType: MeasurementType.ActiveCurrent,
|
|
891
|
-
measured: true,
|
|
892
|
-
minMeasuredValue: Number.MIN_SAFE_INTEGER,
|
|
893
|
-
maxMeasuredValue: Number.MAX_SAFE_INTEGER,
|
|
894
|
-
accuracyRanges: [{ rangeMin: Number.MIN_SAFE_INTEGER, rangeMax: Number.MAX_SAFE_INTEGER, fixedMax: 1 }],
|
|
895
|
-
},
|
|
896
|
-
{
|
|
897
|
-
measurementType: MeasurementType.ActivePower,
|
|
898
|
-
measured: true,
|
|
899
|
-
minMeasuredValue: Number.MIN_SAFE_INTEGER,
|
|
900
|
-
maxMeasuredValue: Number.MAX_SAFE_INTEGER,
|
|
901
|
-
accuracyRanges: [{ rangeMin: Number.MIN_SAFE_INTEGER, rangeMax: Number.MAX_SAFE_INTEGER, fixedMax: 1 }],
|
|
902
|
-
},
|
|
903
|
-
{
|
|
904
|
-
measurementType: MeasurementType.Frequency,
|
|
905
|
-
measured: true,
|
|
906
|
-
minMeasuredValue: Number.MIN_SAFE_INTEGER,
|
|
907
|
-
maxMeasuredValue: Number.MAX_SAFE_INTEGER,
|
|
908
|
-
accuracyRanges: [{ rangeMin: Number.MIN_SAFE_INTEGER, rangeMax: Number.MAX_SAFE_INTEGER, fixedMax: 1 }],
|
|
909
|
-
},
|
|
910
|
-
],
|
|
911
|
-
voltage: voltage,
|
|
912
|
-
activeCurrent: current,
|
|
913
|
-
activePower: power,
|
|
914
|
-
frequency: frequency,
|
|
915
|
-
}, {}, {});
|
|
916
|
-
}
|
|
917
|
-
/**
|
|
918
|
-
* Creates a default Dummy Thread Network Diagnostics Cluster server.
|
|
919
|
-
* @deprecated This method is deprecated and is only used for testing.
|
|
920
|
-
*
|
|
921
|
-
* @remarks
|
|
922
|
-
* This method adds a cluster server used only to give the networkName to Eve app.
|
|
923
|
-
*
|
|
924
|
-
* @returns void
|
|
925
|
-
*/
|
|
926
|
-
createDefaultDummyThreadNetworkDiagnosticsClusterServer() {
|
|
927
|
-
this.addClusterServer(ClusterServer(ThreadNetworkDiagnosticsCluster.with(ThreadNetworkDiagnostics.Feature.PacketCounts, ThreadNetworkDiagnostics.Feature.ErrorCounts), {
|
|
928
|
-
channel: 1,
|
|
929
|
-
routingRole: ThreadNetworkDiagnostics.RoutingRole.Router,
|
|
930
|
-
networkName: 'MyMatterThread',
|
|
931
|
-
panId: 0,
|
|
932
|
-
extendedPanId: 0,
|
|
933
|
-
meshLocalPrefix: null,
|
|
934
|
-
neighborTable: [],
|
|
935
|
-
routeTable: [],
|
|
936
|
-
partitionId: null,
|
|
937
|
-
weighting: null,
|
|
938
|
-
dataVersion: null,
|
|
939
|
-
stableDataVersion: null,
|
|
940
|
-
leaderRouterId: null,
|
|
941
|
-
securityPolicy: null,
|
|
942
|
-
channelPage0Mask: null,
|
|
943
|
-
operationalDatasetComponents: null,
|
|
944
|
-
overrunCount: 0,
|
|
945
|
-
activeNetworkFaultsList: [],
|
|
946
|
-
}, {
|
|
947
|
-
resetCounts: async (data) => {
|
|
948
|
-
this.log.debug('Matter command: resetCounts');
|
|
949
|
-
await this.commandHandler.executeHandler('resetCounts', data);
|
|
950
|
-
},
|
|
951
|
-
}, {}));
|
|
952
|
-
}
|
|
953
|
-
/**
|
|
954
|
-
* Get a default OnOff cluster server for light devices.
|
|
955
|
-
*
|
|
956
|
-
* @param {boolean} [onOff=false] - The initial state of the OnOff cluster.
|
|
957
|
-
* @param {boolean} [globalSceneControl=false] - The global scene control state.
|
|
958
|
-
* @param {number} [onTime=0] - The on time value.
|
|
959
|
-
* @param {number} [offWaitTime=0] - The off wait time value.
|
|
960
|
-
* @param {OnOff.StartUpOnOff | null} [startUpOnOff=null] - The start-up OnOff state. Null means previous state.
|
|
961
|
-
*
|
|
962
|
-
* @returns {ClusterServer} - The configured OnOff cluster server.
|
|
963
|
-
*/
|
|
964
|
-
getDefaultOnOffClusterServer(onOff = false, globalSceneControl = false, onTime = 0, offWaitTime = 0, startUpOnOff = null) {
|
|
965
|
-
return ClusterServer(OnOffCluster.with(OnOff.Feature.Lighting), {
|
|
966
|
-
onOff,
|
|
967
|
-
globalSceneControl,
|
|
968
|
-
onTime,
|
|
969
|
-
offWaitTime,
|
|
970
|
-
startUpOnOff,
|
|
971
|
-
}, {
|
|
972
|
-
on: async (data) => {
|
|
973
|
-
this.log.debug('Matter command: on');
|
|
974
|
-
await this.commandHandler.executeHandler('on', data);
|
|
975
|
-
},
|
|
976
|
-
off: async (data) => {
|
|
977
|
-
this.log.debug('Matter command: off');
|
|
978
|
-
await this.commandHandler.executeHandler('off', data);
|
|
979
|
-
},
|
|
980
|
-
toggle: async (data) => {
|
|
981
|
-
this.log.debug('Matter command: toggle');
|
|
982
|
-
await this.commandHandler.executeHandler('toggle', data);
|
|
983
|
-
},
|
|
984
|
-
offWithEffect: async (data) => {
|
|
985
|
-
this.log.debug('Matter command: offWithEffect', data.request);
|
|
986
|
-
await this.commandHandler.executeHandler('offWithEffect', data);
|
|
987
|
-
},
|
|
988
|
-
onWithRecallGlobalScene: async (data) => {
|
|
989
|
-
this.log.debug('Matter command: onWithRecallGlobalScene', data.request);
|
|
990
|
-
await this.commandHandler.executeHandler('onWithRecallGlobalScene', data);
|
|
991
|
-
},
|
|
992
|
-
onWithTimedOff: async (data) => {
|
|
993
|
-
this.log.debug('Matter command: onWithTimedOff', data.request);
|
|
994
|
-
await this.commandHandler.executeHandler('onWithTimedOff', data);
|
|
995
|
-
},
|
|
996
|
-
}, {});
|
|
997
|
-
}
|
|
998
|
-
/**
|
|
999
|
-
* Creates a default OnOff cluster server for light devices.
|
|
1000
|
-
*
|
|
1001
|
-
* @param {boolean} [onOff=false] - The initial state of the OnOff cluster.
|
|
1002
|
-
* @param {boolean} [globalSceneControl=false] - The global scene control state.
|
|
1003
|
-
* @param {number} [onTime=0] - The on time value.
|
|
1004
|
-
* @param {number} [offWaitTime=0] - The off wait time value.
|
|
1005
|
-
* @param {OnOff.StartUpOnOff | null} [startUpOnOff=null] - The start-up OnOff state. Null means previous state.
|
|
1006
|
-
*/
|
|
1007
|
-
createDefaultOnOffClusterServer(onOff = false, globalSceneControl = false, onTime = 0, offWaitTime = 0, startUpOnOff = null) {
|
|
1008
|
-
this.addClusterServer(this.getDefaultOnOffClusterServer(onOff, globalSceneControl, onTime, offWaitTime, startUpOnOff));
|
|
1009
|
-
return this;
|
|
1010
|
-
}
|
|
1011
|
-
/**
|
|
1012
|
-
* Get a DeadFront OnOff cluster server.
|
|
1013
|
-
*
|
|
1014
|
-
* @param {boolean} [onOff=false] - The initial state of the OnOff cluster.
|
|
1015
|
-
*
|
|
1016
|
-
* @returns {ClusterServer} - The configured OnOff cluster server.
|
|
1017
|
-
*/
|
|
1018
|
-
getDeadFrontOnOffClusterServer(onOff = false) {
|
|
1019
|
-
return ClusterServer(OnOffCluster.with(OnOff.Feature.DeadFrontBehavior), {
|
|
1020
|
-
onOff,
|
|
1021
|
-
}, {
|
|
1022
|
-
on: async (data) => {
|
|
1023
|
-
this.log.debug('Matter command: on');
|
|
1024
|
-
await this.commandHandler.executeHandler('on', data);
|
|
1025
|
-
},
|
|
1026
|
-
off: async (data) => {
|
|
1027
|
-
this.log.debug('Matter command: off');
|
|
1028
|
-
await this.commandHandler.executeHandler('off', data);
|
|
1029
|
-
},
|
|
1030
|
-
toggle: async (data) => {
|
|
1031
|
-
this.log.debug('Matter command: toggle');
|
|
1032
|
-
await this.commandHandler.executeHandler('toggle', data);
|
|
1033
|
-
},
|
|
1034
|
-
}, {});
|
|
1035
|
-
}
|
|
1036
|
-
/**
|
|
1037
|
-
* Creates a DeadFront OnOff cluster server.
|
|
1038
|
-
*
|
|
1039
|
-
* @param {boolean} [onOff=false] - The initial state of the OnOff cluster.
|
|
1040
|
-
*/
|
|
1041
|
-
createDeadFrontOnOffClusterServer(onOff = false) {
|
|
1042
|
-
this.addClusterServer(this.getDeadFrontOnOffClusterServer(onOff));
|
|
1043
|
-
return this;
|
|
1044
|
-
}
|
|
1045
|
-
/**
|
|
1046
|
-
* Get an OnOff cluster server without features.
|
|
1047
|
-
*
|
|
1048
|
-
* @param {boolean} [onOff=false] - The initial state of the OnOff cluster.
|
|
1049
|
-
*
|
|
1050
|
-
* @returns {ClusterServer} - The configured OnOff cluster server.
|
|
1051
|
-
*/
|
|
1052
|
-
getOnOffClusterServer(onOff = false) {
|
|
1053
|
-
return ClusterServer(OnOffCluster, {
|
|
1054
|
-
onOff,
|
|
1055
|
-
}, {
|
|
1056
|
-
on: async (data) => {
|
|
1057
|
-
this.log.debug('Matter command: on');
|
|
1058
|
-
await this.commandHandler.executeHandler('on', data);
|
|
1059
|
-
},
|
|
1060
|
-
off: async (data) => {
|
|
1061
|
-
this.log.debug('Matter command: off');
|
|
1062
|
-
await this.commandHandler.executeHandler('off', data);
|
|
1063
|
-
},
|
|
1064
|
-
toggle: async (data) => {
|
|
1065
|
-
this.log.debug('Matter command: toggle');
|
|
1066
|
-
await this.commandHandler.executeHandler('toggle', data);
|
|
1067
|
-
},
|
|
1068
|
-
}, {});
|
|
1069
|
-
}
|
|
1070
|
-
/**
|
|
1071
|
-
* Creates an OnOff cluster server without features.
|
|
1072
|
-
*
|
|
1073
|
-
* @param {boolean} [onOff=false] - The initial state of the OnOff cluster.
|
|
1074
|
-
*/
|
|
1075
|
-
createOnOffClusterServer(onOff = false) {
|
|
1076
|
-
this.addClusterServer(this.getOnOffClusterServer(onOff));
|
|
1077
|
-
return this;
|
|
1078
|
-
}
|
|
1079
|
-
/**
|
|
1080
|
-
* Get a default level control cluster server.
|
|
1081
|
-
*
|
|
1082
|
-
* @param currentLevel - The current level (default: 254).
|
|
1083
|
-
* @param minLevel - The minimum level (default: 1).
|
|
1084
|
-
* @param maxLevel - The maximum level (default: 254).
|
|
1085
|
-
* @param onLevel - The on level (default: null).
|
|
1086
|
-
* @param startUpCurrentLevel - The startUp on level (default: null).
|
|
1087
|
-
*/
|
|
1088
|
-
getDefaultLevelControlClusterServer(currentLevel = 254, minLevel = 1, maxLevel = 254, onLevel = null, startUpCurrentLevel = null) {
|
|
1089
|
-
return ClusterServer(LevelControlCluster.with(LevelControl.Feature.OnOff, LevelControl.Feature.Lighting), {
|
|
1090
|
-
currentLevel,
|
|
1091
|
-
minLevel,
|
|
1092
|
-
maxLevel,
|
|
1093
|
-
onLevel,
|
|
1094
|
-
remainingTime: 0,
|
|
1095
|
-
startUpCurrentLevel,
|
|
1096
|
-
options: {
|
|
1097
|
-
executeIfOff: false,
|
|
1098
|
-
coupleColorTempToLevel: false,
|
|
1099
|
-
},
|
|
1100
|
-
}, {
|
|
1101
|
-
moveToLevel: async ({ request, attributes, endpoint }) => {
|
|
1102
|
-
this.log.debug('Matter command: moveToLevel request:', request, 'attributes.currentLevel:', attributes.currentLevel.getLocal());
|
|
1103
|
-
await this.commandHandler.executeHandler('moveToLevel', { request, attributes, endpoint });
|
|
1104
|
-
},
|
|
1105
|
-
move: async () => {
|
|
1106
|
-
this.log.error('Matter command: move not implemented');
|
|
1107
|
-
},
|
|
1108
|
-
step: async () => {
|
|
1109
|
-
this.log.error('Matter command: step not implemented');
|
|
1110
|
-
},
|
|
1111
|
-
stop: async () => {
|
|
1112
|
-
this.log.error('Matter command: stop not implemented');
|
|
1113
|
-
},
|
|
1114
|
-
moveToLevelWithOnOff: async ({ request, attributes, endpoint }) => {
|
|
1115
|
-
this.log.debug('Matter command: moveToLevelWithOnOff request:', request, 'attributes.currentLevel:', attributes.currentLevel.getLocal());
|
|
1116
|
-
await this.commandHandler.executeHandler('moveToLevelWithOnOff', { request, attributes, endpoint });
|
|
1117
|
-
},
|
|
1118
|
-
moveWithOnOff: async () => {
|
|
1119
|
-
this.log.error('Matter command: moveWithOnOff not implemented');
|
|
1120
|
-
},
|
|
1121
|
-
stepWithOnOff: async () => {
|
|
1122
|
-
this.log.error('Matter command: stepWithOnOff not implemented');
|
|
1123
|
-
},
|
|
1124
|
-
stopWithOnOff: async () => {
|
|
1125
|
-
this.log.error('Matter command: stopWithOnOff not implemented');
|
|
1126
|
-
},
|
|
1127
|
-
});
|
|
1128
|
-
}
|
|
1129
|
-
/**
|
|
1130
|
-
* Creates a default level control cluster server.
|
|
1131
|
-
*
|
|
1132
|
-
* @param currentLevel - The current level (default: 254).
|
|
1133
|
-
* @param minLevel - The minimum level (default: 1).
|
|
1134
|
-
* @param maxLevel - The maximum level (default: 254).
|
|
1135
|
-
* @param onLevel - The on level (default: null).
|
|
1136
|
-
* @param startUpCurrentLevel - The startUp on level (default: null).
|
|
1137
|
-
*/
|
|
1138
|
-
createDefaultLevelControlClusterServer(currentLevel = 254, minLevel = 1, maxLevel = 254, onLevel = null, startUpCurrentLevel = null) {
|
|
1139
|
-
this.addClusterServer(this.getDefaultLevelControlClusterServer(currentLevel, minLevel, maxLevel, onLevel, startUpCurrentLevel));
|
|
1140
|
-
return this;
|
|
1141
|
-
}
|
|
1142
|
-
/**
|
|
1143
|
-
* Get a default color control cluster server with Xy, HueSaturation and ColorTemperature.
|
|
1144
|
-
*
|
|
1145
|
-
* @param currentX - The current X value.
|
|
1146
|
-
* @param currentY - The current Y value.
|
|
1147
|
-
* @param currentHue - The current hue value.
|
|
1148
|
-
* @param currentSaturation - The current saturation value.
|
|
1149
|
-
* @param colorTemperatureMireds - The color temperature in mireds.
|
|
1150
|
-
* @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds.
|
|
1151
|
-
* @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds.
|
|
1152
|
-
*/
|
|
1153
|
-
getDefaultColorControlClusterServer(currentX = 0, currentY = 0, currentHue = 0, currentSaturation = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
|
|
1154
|
-
return ClusterServer(ColorControlCluster.with(ColorControl.Feature.Xy, ColorControl.Feature.HueSaturation, ColorControl.Feature.ColorTemperature), {
|
|
1155
|
-
colorMode: ColorControl.ColorMode.CurrentHueAndCurrentSaturation,
|
|
1156
|
-
enhancedColorMode: ColorControl.EnhancedColorMode.CurrentHueAndCurrentSaturation,
|
|
1157
|
-
colorCapabilities: { xy: true, hueSaturation: true, colorLoop: false, enhancedHue: false, colorTemperature: true },
|
|
1158
|
-
options: {
|
|
1159
|
-
executeIfOff: false,
|
|
1160
|
-
},
|
|
1161
|
-
numberOfPrimaries: null,
|
|
1162
|
-
currentX,
|
|
1163
|
-
currentY,
|
|
1164
|
-
currentHue,
|
|
1165
|
-
currentSaturation,
|
|
1166
|
-
colorTemperatureMireds,
|
|
1167
|
-
colorTempPhysicalMinMireds,
|
|
1168
|
-
colorTempPhysicalMaxMireds,
|
|
1169
|
-
coupleColorTempToLevelMinMireds: colorTempPhysicalMinMireds,
|
|
1170
|
-
remainingTime: 0,
|
|
1171
|
-
startUpColorTemperatureMireds: null,
|
|
1172
|
-
}, {
|
|
1173
|
-
moveToColor: async (data) => {
|
|
1174
|
-
this.log.debug('Matter command: moveToColor request:', data.request, 'attributes.currentX:', data.attributes.currentX.getLocal(), 'attributes.currentY:', data.attributes.currentY.getLocal());
|
|
1175
|
-
this.commandHandler.executeHandler('moveToColor', data);
|
|
1176
|
-
},
|
|
1177
|
-
moveColor: async () => {
|
|
1178
|
-
this.log.error('Matter command: moveColor not implemented');
|
|
1179
|
-
},
|
|
1180
|
-
stepColor: async () => {
|
|
1181
|
-
this.log.error('Matter command: stepColor not implemented');
|
|
1182
|
-
},
|
|
1183
|
-
moveToHue: async ({ request, attributes, endpoint }) => {
|
|
1184
|
-
this.log.debug('Matter command: moveToHue request:', request, 'attributes.currentHue:', attributes.currentHue.getLocal());
|
|
1185
|
-
this.commandHandler.executeHandler('moveToHue', { request, attributes, endpoint });
|
|
1186
|
-
},
|
|
1187
|
-
moveHue: async () => {
|
|
1188
|
-
this.log.error('Matter command: moveHue not implemented');
|
|
1189
|
-
},
|
|
1190
|
-
stepHue: async () => {
|
|
1191
|
-
this.log.error('Matter command: stepHue not implemented');
|
|
1192
|
-
},
|
|
1193
|
-
moveToSaturation: async ({ request, attributes, endpoint }) => {
|
|
1194
|
-
this.log.debug('Matter command: moveToSaturation request:', request, 'attributes.currentSaturation:', attributes.currentSaturation.getLocal());
|
|
1195
|
-
this.commandHandler.executeHandler('moveToSaturation', { request, attributes, endpoint });
|
|
1196
|
-
},
|
|
1197
|
-
moveSaturation: async () => {
|
|
1198
|
-
this.log.error('Matter command: moveSaturation not implemented');
|
|
1199
|
-
},
|
|
1200
|
-
stepSaturation: async () => {
|
|
1201
|
-
this.log.error('Matter command: stepSaturation not implemented');
|
|
1202
|
-
},
|
|
1203
|
-
moveToHueAndSaturation: async ({ request, attributes, endpoint }) => {
|
|
1204
|
-
this.log.debug('Matter command: moveToHueAndSaturation request:', request, 'attributes.currentHue:', attributes.currentHue.getLocal(), 'attributes.currentSaturation:', attributes.currentSaturation.getLocal());
|
|
1205
|
-
this.commandHandler.executeHandler('moveToHueAndSaturation', { request, attributes, endpoint });
|
|
1206
|
-
},
|
|
1207
|
-
stopMoveStep: async () => {
|
|
1208
|
-
this.log.error('Matter command: stopMoveStep not implemented');
|
|
1209
|
-
},
|
|
1210
|
-
moveToColorTemperature: async ({ request, attributes, endpoint }) => {
|
|
1211
|
-
this.log.debug('Matter command: moveToColorTemperature request:', request, 'attributes.colorTemperatureMireds:', attributes.colorTemperatureMireds.getLocal());
|
|
1212
|
-
this.commandHandler.executeHandler('moveToColorTemperature', { request, attributes, endpoint });
|
|
1213
|
-
},
|
|
1214
|
-
moveColorTemperature: async () => {
|
|
1215
|
-
this.log.error('Matter command: moveColorTemperature not implemented');
|
|
1216
|
-
},
|
|
1217
|
-
stepColorTemperature: async () => {
|
|
1218
|
-
this.log.error('Matter command: stepColorTemperature not implemented');
|
|
1219
|
-
},
|
|
1220
|
-
}, {});
|
|
1221
|
-
}
|
|
1222
|
-
/**
|
|
1223
|
-
* Creates a default color control cluster server with Xy, HueSaturation and ColorTemperature.
|
|
1224
|
-
*
|
|
1225
|
-
* @param currentX - The current X value.
|
|
1226
|
-
* @param currentY - The current Y value.
|
|
1227
|
-
* @param currentHue - The current hue value.
|
|
1228
|
-
* @param currentSaturation - The current saturation value.
|
|
1229
|
-
* @param colorTemperatureMireds - The color temperature in mireds.
|
|
1230
|
-
* @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds.
|
|
1231
|
-
* @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds.
|
|
1232
|
-
*/
|
|
1233
|
-
createDefaultColorControlClusterServer(currentX = 0, currentY = 0, currentHue = 0, currentSaturation = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
|
|
1234
|
-
this.addClusterServer(this.getDefaultColorControlClusterServer(currentX, currentY, currentHue, currentSaturation, colorTemperatureMireds, colorTempPhysicalMinMireds, colorTempPhysicalMaxMireds));
|
|
1235
|
-
return this;
|
|
1236
|
-
}
|
|
1237
|
-
/**
|
|
1238
|
-
* Get a Xy color control cluster server with Xy and ColorTemperature.
|
|
1239
|
-
*
|
|
1240
|
-
* @param currentX - The current X value.
|
|
1241
|
-
* @param currentY - The current Y value.
|
|
1242
|
-
* @param colorTemperatureMireds - The color temperature in mireds.
|
|
1243
|
-
* @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds.
|
|
1244
|
-
* @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds.
|
|
1245
|
-
*/
|
|
1246
|
-
getXyColorControlClusterServer(currentX = 0, currentY = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
|
|
1247
|
-
return ClusterServer(ColorControlCluster.with(ColorControl.Feature.Xy, ColorControl.Feature.ColorTemperature), {
|
|
1248
|
-
colorMode: ColorControl.ColorMode.CurrentXAndCurrentY,
|
|
1249
|
-
enhancedColorMode: ColorControl.EnhancedColorMode.CurrentXAndCurrentY,
|
|
1250
|
-
colorCapabilities: { xy: true, hueSaturation: false, colorLoop: false, enhancedHue: false, colorTemperature: true },
|
|
1251
|
-
options: {
|
|
1252
|
-
executeIfOff: false,
|
|
1253
|
-
},
|
|
1254
|
-
numberOfPrimaries: null,
|
|
1255
|
-
currentX,
|
|
1256
|
-
currentY,
|
|
1257
|
-
colorTemperatureMireds,
|
|
1258
|
-
colorTempPhysicalMinMireds,
|
|
1259
|
-
colorTempPhysicalMaxMireds,
|
|
1260
|
-
coupleColorTempToLevelMinMireds: colorTempPhysicalMinMireds,
|
|
1261
|
-
startUpColorTemperatureMireds: null,
|
|
1262
|
-
remainingTime: 0,
|
|
1263
|
-
}, {
|
|
1264
|
-
moveToColor: async (data) => {
|
|
1265
|
-
this.log.debug('Matter command: moveToColor request:', data.request, 'attributes.currentX:', data.attributes.currentX.getLocal(), 'attributes.currentY:', data.attributes.currentY.getLocal());
|
|
1266
|
-
this.commandHandler.executeHandler('moveToColor', data);
|
|
1267
|
-
},
|
|
1268
|
-
moveColor: async () => {
|
|
1269
|
-
this.log.error('Matter command: moveColor not implemented');
|
|
1270
|
-
},
|
|
1271
|
-
stepColor: async () => {
|
|
1272
|
-
this.log.error('Matter command: stepColor not implemented');
|
|
1273
|
-
},
|
|
1274
|
-
stopMoveStep: async () => {
|
|
1275
|
-
this.log.error('Matter command: stopMoveStep not implemented');
|
|
1276
|
-
},
|
|
1277
|
-
moveToColorTemperature: async ({ request, attributes, endpoint }) => {
|
|
1278
|
-
this.log.debug('Matter command: moveToColorTemperature request:', request, 'attributes.colorTemperatureMireds:', attributes.colorTemperatureMireds.getLocal());
|
|
1279
|
-
this.commandHandler.executeHandler('moveToColorTemperature', { request, attributes, endpoint });
|
|
1280
|
-
},
|
|
1281
|
-
moveColorTemperature: async () => {
|
|
1282
|
-
this.log.error('Matter command: moveColorTemperature not implemented');
|
|
1283
|
-
},
|
|
1284
|
-
stepColorTemperature: async () => {
|
|
1285
|
-
this.log.error('Matter command: stepColorTemperature not implemented');
|
|
1286
|
-
},
|
|
1287
|
-
}, {});
|
|
1288
|
-
}
|
|
1289
|
-
/**
|
|
1290
|
-
* Creates a Xy color control cluster server with Xy and ColorTemperature.
|
|
1291
|
-
*
|
|
1292
|
-
* @param currentX - The current X value.
|
|
1293
|
-
* @param currentY - The current Y value.
|
|
1294
|
-
* @param colorTemperatureMireds - The color temperature in mireds.
|
|
1295
|
-
* @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds.
|
|
1296
|
-
* @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds.
|
|
1297
|
-
*/
|
|
1298
|
-
createXyColorControlClusterServer(currentX = 0, currentY = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
|
|
1299
|
-
this.addClusterServer(this.getXyColorControlClusterServer(currentX, currentY, colorTemperatureMireds, colorTempPhysicalMinMireds, colorTempPhysicalMaxMireds));
|
|
1300
|
-
return this;
|
|
1301
|
-
}
|
|
1302
|
-
/**
|
|
1303
|
-
* Get a default hue and saturation control cluster server with HueSaturation and ColorTemperature.
|
|
1304
|
-
*
|
|
1305
|
-
* @param currentHue - The current hue value.
|
|
1306
|
-
* @param currentSaturation - The current saturation value.
|
|
1307
|
-
* @param colorTemperatureMireds - The color temperature in mireds.
|
|
1308
|
-
* @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds.
|
|
1309
|
-
* @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds.
|
|
1310
|
-
*/
|
|
1311
|
-
getHsColorControlClusterServer(currentHue = 0, currentSaturation = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
|
|
1312
|
-
return ClusterServer(ColorControlCluster.with(ColorControl.Feature.HueSaturation, ColorControl.Feature.ColorTemperature), {
|
|
1313
|
-
colorMode: ColorControl.ColorMode.CurrentHueAndCurrentSaturation,
|
|
1314
|
-
enhancedColorMode: ColorControl.EnhancedColorMode.CurrentHueAndCurrentSaturation,
|
|
1315
|
-
colorCapabilities: { xy: false, hueSaturation: true, colorLoop: false, enhancedHue: false, colorTemperature: true },
|
|
1316
|
-
options: {
|
|
1317
|
-
executeIfOff: false,
|
|
1318
|
-
},
|
|
1319
|
-
numberOfPrimaries: null,
|
|
1320
|
-
currentHue,
|
|
1321
|
-
currentSaturation,
|
|
1322
|
-
colorTemperatureMireds,
|
|
1323
|
-
colorTempPhysicalMinMireds,
|
|
1324
|
-
colorTempPhysicalMaxMireds,
|
|
1325
|
-
coupleColorTempToLevelMinMireds: colorTempPhysicalMinMireds,
|
|
1326
|
-
startUpColorTemperatureMireds: null,
|
|
1327
|
-
remainingTime: 0,
|
|
1328
|
-
}, {
|
|
1329
|
-
moveToHue: async ({ request, attributes, endpoint }) => {
|
|
1330
|
-
this.log.debug('Matter command: moveToHue request:', request, 'attributes.currentHue:', attributes.currentHue.getLocal());
|
|
1331
|
-
this.commandHandler.executeHandler('moveToHue', { request, attributes, endpoint });
|
|
1332
|
-
},
|
|
1333
|
-
moveHue: async () => {
|
|
1334
|
-
this.log.error('Matter command: moveHue not implemented');
|
|
1335
|
-
},
|
|
1336
|
-
stepHue: async () => {
|
|
1337
|
-
this.log.error('Matter command: stepHue not implemented');
|
|
1338
|
-
},
|
|
1339
|
-
moveToSaturation: async ({ request, attributes, endpoint }) => {
|
|
1340
|
-
this.log.debug('Matter command: moveToSaturation request:', request, 'attributes.currentSaturation:', attributes.currentSaturation.getLocal());
|
|
1341
|
-
this.commandHandler.executeHandler('moveToSaturation', { request, attributes, endpoint });
|
|
1342
|
-
},
|
|
1343
|
-
moveSaturation: async () => {
|
|
1344
|
-
this.log.error('Matter command: moveSaturation not implemented');
|
|
1345
|
-
},
|
|
1346
|
-
stepSaturation: async () => {
|
|
1347
|
-
this.log.error('Matter command: stepSaturation not implemented');
|
|
1348
|
-
},
|
|
1349
|
-
moveToHueAndSaturation: async ({ request, attributes, endpoint }) => {
|
|
1350
|
-
this.log.debug('Matter command: moveToHueAndSaturation request:', request, 'attributes.currentHue:', attributes.currentHue.getLocal(), 'attributes.currentSaturation:', attributes.currentSaturation.getLocal());
|
|
1351
|
-
this.commandHandler.executeHandler('moveToHueAndSaturation', { request, attributes, endpoint });
|
|
1352
|
-
},
|
|
1353
|
-
stopMoveStep: async () => {
|
|
1354
|
-
this.log.error('Matter command: stopMoveStep not implemented');
|
|
1355
|
-
},
|
|
1356
|
-
moveToColorTemperature: async ({ request, attributes, endpoint }) => {
|
|
1357
|
-
this.log.debug('Matter command: moveToColorTemperature request:', request, 'attributes.colorTemperatureMireds:', attributes.colorTemperatureMireds.getLocal());
|
|
1358
|
-
this.commandHandler.executeHandler('moveToColorTemperature', { request, attributes, endpoint });
|
|
1359
|
-
},
|
|
1360
|
-
moveColorTemperature: async () => {
|
|
1361
|
-
this.log.error('Matter command: moveColorTemperature not implemented');
|
|
1362
|
-
},
|
|
1363
|
-
stepColorTemperature: async () => {
|
|
1364
|
-
this.log.error('Matter command: stepColorTemperature not implemented');
|
|
1365
|
-
},
|
|
1366
|
-
}, {});
|
|
1367
|
-
}
|
|
1368
|
-
/**
|
|
1369
|
-
* Creates a hue and saturation color control cluster server with HueSaturation and ColorTemperature.
|
|
1370
|
-
*
|
|
1371
|
-
* @param currentHue - The current hue value.
|
|
1372
|
-
* @param currentSaturation - The current saturation value.
|
|
1373
|
-
* @param colorTemperatureMireds - The color temperature in mireds.
|
|
1374
|
-
* @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds.
|
|
1375
|
-
* @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds.
|
|
1376
|
-
*/
|
|
1377
|
-
createHsColorControlClusterServer(currentHue = 0, currentSaturation = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
|
|
1378
|
-
this.addClusterServer(this.getHsColorControlClusterServer(currentHue, currentSaturation, colorTemperatureMireds, colorTempPhysicalMinMireds, colorTempPhysicalMaxMireds));
|
|
1379
|
-
return this;
|
|
1380
|
-
}
|
|
1381
|
-
/**
|
|
1382
|
-
* Get a color temperature color control cluster server.
|
|
1383
|
-
*
|
|
1384
|
-
* @param colorTemperatureMireds - The color temperature in mireds.
|
|
1385
|
-
* @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds.
|
|
1386
|
-
* @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds.
|
|
1387
|
-
*/
|
|
1388
|
-
getCtColorControlClusterServer(colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
|
|
1389
|
-
return ClusterServer(ColorControlCluster.with(ColorControl.Feature.ColorTemperature), {
|
|
1390
|
-
colorMode: ColorControl.ColorMode.ColorTemperatureMireds,
|
|
1391
|
-
enhancedColorMode: ColorControl.EnhancedColorMode.ColorTemperatureMireds,
|
|
1392
|
-
colorCapabilities: { xy: false, hueSaturation: false, colorLoop: false, enhancedHue: false, colorTemperature: true },
|
|
1393
|
-
options: {
|
|
1394
|
-
executeIfOff: false,
|
|
1395
|
-
},
|
|
1396
|
-
numberOfPrimaries: null,
|
|
1397
|
-
colorTemperatureMireds,
|
|
1398
|
-
colorTempPhysicalMinMireds,
|
|
1399
|
-
colorTempPhysicalMaxMireds,
|
|
1400
|
-
coupleColorTempToLevelMinMireds: colorTempPhysicalMinMireds,
|
|
1401
|
-
remainingTime: 0,
|
|
1402
|
-
startUpColorTemperatureMireds: null,
|
|
1403
|
-
}, {
|
|
1404
|
-
stopMoveStep: async () => {
|
|
1405
|
-
this.log.error('Matter command: stopMoveStep not implemented');
|
|
1406
|
-
},
|
|
1407
|
-
moveToColorTemperature: async ({ request, attributes, endpoint }) => {
|
|
1408
|
-
this.log.debug('Matter command: moveToColorTemperature request:', request, 'attributes.colorTemperatureMireds:', attributes.colorTemperatureMireds.getLocal());
|
|
1409
|
-
this.commandHandler.executeHandler('moveToColorTemperature', { request, attributes, endpoint });
|
|
1410
|
-
},
|
|
1411
|
-
moveColorTemperature: async () => {
|
|
1412
|
-
this.log.error('Matter command: moveColorTemperature not implemented');
|
|
1413
|
-
},
|
|
1414
|
-
stepColorTemperature: async () => {
|
|
1415
|
-
this.log.error('Matter command: stepColorTemperature not implemented');
|
|
1416
|
-
},
|
|
1417
|
-
}, {});
|
|
1418
|
-
}
|
|
1419
|
-
/**
|
|
1420
|
-
* Creates a color temperature color control cluster server.
|
|
1421
|
-
*
|
|
1422
|
-
* @param colorTemperatureMireds - The color temperature in mireds.
|
|
1423
|
-
* @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds.
|
|
1424
|
-
* @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds.
|
|
1425
|
-
*/
|
|
1426
|
-
createCtColorControlClusterServer(colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
|
|
1427
|
-
this.addClusterServer(this.getCtColorControlClusterServer(colorTemperatureMireds, colorTempPhysicalMinMireds, colorTempPhysicalMaxMireds));
|
|
1428
|
-
return this;
|
|
1429
|
-
}
|
|
1430
|
-
/**
|
|
1431
|
-
* Configures the color control cluster for a device.
|
|
1432
|
-
*
|
|
1433
|
-
* @remark This method must be called only after creating the cluster with getDefaultCompleteColorControlClusterServer or createDefaultCompleteColorControlClusterServer
|
|
1434
|
-
* and before starting the matter server.
|
|
1435
|
-
*
|
|
1436
|
-
* @deprecated Use configureColorControlMode instead.
|
|
1437
|
-
*
|
|
1438
|
-
* @param {boolean} hueSaturation - A boolean indicating whether the device supports hue and saturation control.
|
|
1439
|
-
* @param {boolean} xy - A boolean indicating whether the device supports XY control.
|
|
1440
|
-
* @param {boolean} colorTemperature - A boolean indicating whether the device supports color temperature control.
|
|
1441
|
-
* @param {ColorControl.ColorMode} colorMode - An optional parameter specifying the color mode of the device.
|
|
1442
|
-
* @param {Endpoint} endpoint - An optional parameter specifying the endpoint to configure. If not provided, the device endpoint will be used.
|
|
1443
|
-
*/
|
|
1444
|
-
configureColorControlCluster(hueSaturation, xy, colorTemperature, colorMode, endpoint) {
|
|
1445
|
-
if (!endpoint)
|
|
1446
|
-
endpoint = this;
|
|
1447
|
-
endpoint.getClusterServer(ColorControlCluster)?.setFeatureMapAttribute({ hueSaturation, enhancedHue: false, colorLoop: false, xy, colorTemperature });
|
|
1448
|
-
endpoint.getClusterServer(ColorControlCluster)?.setColorCapabilitiesAttribute({ hueSaturation, enhancedHue: false, colorLoop: false, xy, colorTemperature });
|
|
1449
|
-
if (colorMode !== undefined && colorMode >= ColorControl.ColorMode.CurrentHueAndCurrentSaturation && colorMode <= ColorControl.ColorMode.ColorTemperatureMireds) {
|
|
1450
|
-
endpoint.getClusterServer(ColorControlCluster)?.setColorModeAttribute(colorMode);
|
|
1451
|
-
endpoint.getClusterServer(ColorControlCluster)?.setEnhancedColorModeAttribute(colorMode);
|
|
1452
|
-
}
|
|
1453
|
-
return this;
|
|
1454
|
-
}
|
|
1455
|
-
/**
|
|
1456
|
-
* Configures the color control mode for the device.
|
|
1457
|
-
*
|
|
1458
|
-
* @param {ColorControl.ColorMode} colorMode - The color mode to set.
|
|
1459
|
-
* @param {Endpoint} endpoint - The optional endpoint to configure. If not provided, the method will configure the current endpoint.
|
|
1460
|
-
*/
|
|
1461
|
-
configureColorControlMode(colorMode, endpoint) {
|
|
1462
|
-
if (!endpoint)
|
|
1463
|
-
endpoint = this;
|
|
1464
|
-
if (colorMode !== undefined && colorMode >= ColorControl.ColorMode.CurrentHueAndCurrentSaturation && colorMode <= ColorControl.ColorMode.ColorTemperatureMireds) {
|
|
1465
|
-
endpoint.getClusterServer(ColorControlCluster)?.setColorModeAttribute(colorMode);
|
|
1466
|
-
endpoint.getClusterServer(ColorControlCluster)?.setEnhancedColorModeAttribute(colorMode);
|
|
1467
|
-
}
|
|
1468
|
-
return this;
|
|
1469
|
-
}
|
|
1470
|
-
/**
|
|
1471
|
-
* Get a default window covering cluster server.
|
|
1472
|
-
*
|
|
1473
|
-
* @param positionPercent100ths - The position percentage in 100ths (0-10000). Defaults to 0.
|
|
1474
|
-
*/
|
|
1475
|
-
getDefaultWindowCoveringClusterServer(positionPercent100ths) {
|
|
1476
|
-
return ClusterServer(WindowCoveringCluster.with(WindowCovering.Feature.Lift, WindowCovering.Feature.PositionAwareLift /* , WindowCovering.Feature.AbsolutePosition*/), {
|
|
1477
|
-
type: WindowCovering.WindowCoveringType.Rollershade,
|
|
1478
|
-
configStatus: {
|
|
1479
|
-
operational: true,
|
|
1480
|
-
onlineReserved: true,
|
|
1481
|
-
liftMovementReversed: false,
|
|
1482
|
-
liftPositionAware: true,
|
|
1483
|
-
tiltPositionAware: false,
|
|
1484
|
-
liftEncoderControlled: false,
|
|
1485
|
-
tiltEncoderControlled: false,
|
|
1486
|
-
},
|
|
1487
|
-
operationalStatus: { global: WindowCovering.MovementStatus.Stopped, lift: WindowCovering.MovementStatus.Stopped, tilt: WindowCovering.MovementStatus.Stopped },
|
|
1488
|
-
endProductType: WindowCovering.EndProductType.RollerShade,
|
|
1489
|
-
mode: { motorDirectionReversed: false, calibrationMode: false, maintenanceMode: false, ledFeedback: false },
|
|
1490
|
-
targetPositionLiftPercent100ths: positionPercent100ths ?? 0, // 0 Fully open 10000 fully closed
|
|
1491
|
-
currentPositionLiftPercent100ths: positionPercent100ths ?? 0, // 0 Fully open 10000 fully closed
|
|
1492
|
-
// installedClosedLimitLift: 10000,
|
|
1493
|
-
// installedOpenLimitLift: 0,
|
|
1494
|
-
}, {
|
|
1495
|
-
upOrOpen: async (data) => {
|
|
1496
|
-
this.log.debug('Matter command: upOrOpen');
|
|
1497
|
-
await this.commandHandler.executeHandler('upOrOpen', data);
|
|
1498
|
-
},
|
|
1499
|
-
downOrClose: async (data) => {
|
|
1500
|
-
this.log.debug('Matter command: downOrClose');
|
|
1501
|
-
await this.commandHandler.executeHandler('downOrClose', data);
|
|
1502
|
-
},
|
|
1503
|
-
stopMotion: async (data) => {
|
|
1504
|
-
this.log.debug('Matter command: stopMotion');
|
|
1505
|
-
await this.commandHandler.executeHandler('stopMotion', data);
|
|
1506
|
-
},
|
|
1507
|
-
goToLiftPercentage: async (data) => {
|
|
1508
|
-
this.log.debug(`Matter command: goToLiftPercentage: ${data.request.liftPercent100thsValue} current: ${data.attributes.currentPositionLiftPercent100ths?.getLocal()} ` +
|
|
1509
|
-
`target: ${data.attributes.targetPositionLiftPercent100ths?.getLocal()} status: ${data.attributes.operationalStatus.getLocal().lift}`);
|
|
1510
|
-
await this.commandHandler.executeHandler('goToLiftPercentage', data);
|
|
1511
|
-
},
|
|
1512
|
-
}, {});
|
|
1513
|
-
}
|
|
1514
|
-
/**
|
|
1515
|
-
* Creates a default window covering cluster server.
|
|
1516
|
-
*
|
|
1517
|
-
* @param positionPercent100ths - The position percentage in 100ths (0-10000). Defaults to 0.
|
|
1518
|
-
*/
|
|
1519
|
-
createDefaultWindowCoveringClusterServer(positionPercent100ths) {
|
|
1520
|
-
this.addClusterServer(this.getDefaultWindowCoveringClusterServer(positionPercent100ths));
|
|
1521
|
-
}
|
|
1522
|
-
/**
|
|
1523
|
-
* Sets the window covering target position as the current position and stops the movement.
|
|
1524
|
-
* @param {Endpoint} endpoint - The endpoint on which to set the window covering (default the device endpoint).
|
|
1525
|
-
*/
|
|
1526
|
-
setWindowCoveringTargetAsCurrentAndStopped(endpoint) {
|
|
1527
|
-
if (!endpoint)
|
|
1528
|
-
endpoint = this;
|
|
1529
|
-
const windowCoveringCluster = endpoint.getClusterServer(WindowCoveringCluster.with(WindowCovering.Feature.Lift, WindowCovering.Feature.PositionAwareLift));
|
|
1530
|
-
if (windowCoveringCluster) {
|
|
1531
|
-
const position = windowCoveringCluster.getCurrentPositionLiftPercent100thsAttribute();
|
|
1532
|
-
if (position !== null) {
|
|
1533
|
-
windowCoveringCluster.setTargetPositionLiftPercent100thsAttribute(position);
|
|
1534
|
-
windowCoveringCluster.setOperationalStatusAttribute({
|
|
1535
|
-
global: WindowCovering.MovementStatus.Stopped,
|
|
1536
|
-
lift: WindowCovering.MovementStatus.Stopped,
|
|
1537
|
-
tilt: WindowCovering.MovementStatus.Stopped,
|
|
1538
|
-
});
|
|
1539
|
-
}
|
|
1540
|
-
this.log.debug(`Set WindowCovering currentPositionLiftPercent100ths and targetPositionLiftPercent100ths to ${position} and operationalStatus to Stopped.`);
|
|
1541
|
-
}
|
|
1542
|
-
}
|
|
1543
|
-
/**
|
|
1544
|
-
* Sets the current and target status of a window covering.
|
|
1545
|
-
* @param {number} current - The current position of the window covering.
|
|
1546
|
-
* @param {number} target - The target position of the window covering.
|
|
1547
|
-
* @param {WindowCovering.MovementStatus} status - The movement status of the window covering.
|
|
1548
|
-
* @param {Endpoint} endpoint - The endpoint on which to set the window covering (default the device endpoint).
|
|
1549
|
-
*/
|
|
1550
|
-
setWindowCoveringCurrentTargetStatus(current, target, status, endpoint) {
|
|
1551
|
-
if (!endpoint)
|
|
1552
|
-
endpoint = this;
|
|
1553
|
-
const windowCoveringCluster = endpoint.getClusterServer(WindowCoveringCluster.with(WindowCovering.Feature.Lift, WindowCovering.Feature.PositionAwareLift));
|
|
1554
|
-
if (windowCoveringCluster) {
|
|
1555
|
-
windowCoveringCluster.setCurrentPositionLiftPercent100thsAttribute(current);
|
|
1556
|
-
windowCoveringCluster.setTargetPositionLiftPercent100thsAttribute(target);
|
|
1557
|
-
windowCoveringCluster.setOperationalStatusAttribute({
|
|
1558
|
-
global: status,
|
|
1559
|
-
lift: status,
|
|
1560
|
-
tilt: status,
|
|
1561
|
-
});
|
|
1562
|
-
}
|
|
1563
|
-
this.log.debug(`Set WindowCovering currentPositionLiftPercent100ths: ${current}, targetPositionLiftPercent100ths: ${target} and operationalStatus: ${status}.`);
|
|
1564
|
-
}
|
|
1565
|
-
/**
|
|
1566
|
-
* Sets the status of the window covering.
|
|
1567
|
-
* @param {WindowCovering.MovementStatus} status - The movement status to set.
|
|
1568
|
-
* @param {Endpoint} endpoint - The endpoint on which to set the window covering (default the device endpoint).
|
|
1569
|
-
*/
|
|
1570
|
-
setWindowCoveringStatus(status, endpoint) {
|
|
1571
|
-
if (!endpoint)
|
|
1572
|
-
endpoint = this;
|
|
1573
|
-
const windowCovering = endpoint.getClusterServer(WindowCoveringCluster.with(WindowCovering.Feature.Lift, WindowCovering.Feature.PositionAwareLift));
|
|
1574
|
-
if (!windowCovering)
|
|
1575
|
-
return;
|
|
1576
|
-
windowCovering.setOperationalStatusAttribute({ global: status, lift: status, tilt: status });
|
|
1577
|
-
this.log.debug(`Set WindowCovering operationalStatus: ${status}`);
|
|
1578
|
-
}
|
|
1579
|
-
/**
|
|
1580
|
-
* Retrieves the status of the window covering.
|
|
1581
|
-
* @param {Endpoint} endpoint - The endpoint on which to get the window covering (default the device endpoint).
|
|
1582
|
-
*
|
|
1583
|
-
* @returns The global operational status of the window covering.
|
|
1584
|
-
*/
|
|
1585
|
-
getWindowCoveringStatus(endpoint) {
|
|
1586
|
-
if (!endpoint)
|
|
1587
|
-
endpoint = this;
|
|
1588
|
-
const windowCovering = endpoint.getClusterServer(WindowCoveringCluster.with(WindowCovering.Feature.Lift, WindowCovering.Feature.PositionAwareLift));
|
|
1589
|
-
if (!windowCovering)
|
|
1590
|
-
return undefined;
|
|
1591
|
-
const status = windowCovering.getOperationalStatusAttribute();
|
|
1592
|
-
this.log.debug(`Get WindowCovering operationalStatus: ${status.global}`);
|
|
1593
|
-
return status.global;
|
|
1594
|
-
}
|
|
1595
|
-
/**
|
|
1596
|
-
* Sets the target and current position of the window covering.
|
|
1597
|
-
*
|
|
1598
|
-
* @param position - The position to set, specified as a number.
|
|
1599
|
-
* @param {Endpoint} endpoint - The endpoint on which to set the window covering (default the device endpoint).
|
|
1600
|
-
*/
|
|
1601
|
-
setWindowCoveringTargetAndCurrentPosition(position, endpoint) {
|
|
1602
|
-
if (!endpoint)
|
|
1603
|
-
endpoint = this;
|
|
1604
|
-
const windowCovering = endpoint.getClusterServer(WindowCoveringCluster.with(WindowCovering.Feature.Lift, WindowCovering.Feature.PositionAwareLift));
|
|
1605
|
-
if (!windowCovering)
|
|
1606
|
-
return;
|
|
1607
|
-
windowCovering.setCurrentPositionLiftPercent100thsAttribute(position);
|
|
1608
|
-
windowCovering.setTargetPositionLiftPercent100thsAttribute(position);
|
|
1609
|
-
this.log.debug(`Set WindowCovering currentPositionLiftPercent100ths: ${position} and targetPositionLiftPercent100ths: ${position}.`);
|
|
1610
|
-
}
|
|
1611
|
-
/**
|
|
1612
|
-
* Get a default door lock cluster server.
|
|
1613
|
-
*
|
|
1614
|
-
* @remarks
|
|
1615
|
-
* This method adds a cluster server for a door lock cluster with default settings.
|
|
1616
|
-
*
|
|
1617
|
-
*/
|
|
1618
|
-
getDefaultDoorLockClusterServer(lockState = DoorLock.LockState.Locked, lockType = DoorLock.LockType.DeadBolt) {
|
|
1619
|
-
return ClusterServer(DoorLockCluster, {
|
|
1620
|
-
operatingMode: DoorLock.OperatingMode.Normal,
|
|
1621
|
-
lockState,
|
|
1622
|
-
lockType,
|
|
1623
|
-
actuatorEnabled: false,
|
|
1624
|
-
supportedOperatingModes: { normal: true, vacation: false, privacy: false, noRemoteLockUnlock: false, passage: false },
|
|
1625
|
-
}, {
|
|
1626
|
-
lockDoor: async (data) => {
|
|
1627
|
-
this.log.debug('Matter command: lockDoor', data.request);
|
|
1628
|
-
await this.commandHandler.executeHandler('lockDoor', data);
|
|
1629
|
-
},
|
|
1630
|
-
unlockDoor: async (data) => {
|
|
1631
|
-
this.log.debug('Matter command: unlockDoor', data.request);
|
|
1632
|
-
await this.commandHandler.executeHandler('unlockDoor', data);
|
|
1633
|
-
},
|
|
1634
|
-
}, {
|
|
1635
|
-
doorLockAlarm: true,
|
|
1636
|
-
lockOperation: true,
|
|
1637
|
-
lockOperationError: true,
|
|
1638
|
-
});
|
|
1639
|
-
}
|
|
1640
|
-
/**
|
|
1641
|
-
* Creates a default door lock cluster server.
|
|
1642
|
-
*
|
|
1643
|
-
* @remarks
|
|
1644
|
-
* This method adds a cluster server for a door lock cluster with default settings.
|
|
1645
|
-
*
|
|
1646
|
-
*/
|
|
1647
|
-
createDefaultDoorLockClusterServer(lockState = DoorLock.LockState.Locked, lockType = DoorLock.LockType.DeadBolt) {
|
|
1648
|
-
this.addClusterServer(this.getDefaultDoorLockClusterServer(lockState, lockType));
|
|
1649
|
-
}
|
|
1650
|
-
/**
|
|
1651
|
-
* Get a default momentary switch cluster server.
|
|
1652
|
-
*
|
|
1653
|
-
* @remarks
|
|
1654
|
-
* This method adds a cluster server with default momentary switch features and configurations suitable for (AppleHome) Single Double Long automations.
|
|
1655
|
-
*/
|
|
1656
|
-
getDefaultSwitchClusterServer() {
|
|
1657
|
-
return ClusterServer(SwitchCluster.with(Switch.Feature.MomentarySwitch, Switch.Feature.MomentarySwitchRelease, Switch.Feature.MomentarySwitchLongPress, Switch.Feature.MomentarySwitchMultiPress), {
|
|
1658
|
-
numberOfPositions: 2,
|
|
1659
|
-
currentPosition: 0,
|
|
1660
|
-
multiPressMax: 2,
|
|
1661
|
-
}, {}, {
|
|
1662
|
-
initialPress: true,
|
|
1663
|
-
longPress: true,
|
|
1664
|
-
shortRelease: true,
|
|
1665
|
-
longRelease: true,
|
|
1666
|
-
multiPressOngoing: true,
|
|
1667
|
-
multiPressComplete: true,
|
|
1668
|
-
});
|
|
1669
|
-
}
|
|
1670
|
-
/**
|
|
1671
|
-
* Creates a default momentary switch cluster server.
|
|
1672
|
-
*
|
|
1673
|
-
* @remarks
|
|
1674
|
-
* This method adds a cluster server with default momentary switch features and configurations.
|
|
1675
|
-
*/
|
|
1676
|
-
createDefaultSwitchClusterServer() {
|
|
1677
|
-
this.addClusterServer(this.getDefaultSwitchClusterServer());
|
|
1678
|
-
}
|
|
1679
|
-
/**
|
|
1680
|
-
* Get a default latching switch cluster server.
|
|
1681
|
-
*
|
|
1682
|
-
* @remarks
|
|
1683
|
-
* This method adds a cluster server with default latching switch features and configuration.
|
|
1684
|
-
*/
|
|
1685
|
-
getDefaultLatchingSwitchClusterServer() {
|
|
1686
|
-
return ClusterServer(SwitchCluster.with(Switch.Feature.LatchingSwitch), {
|
|
1687
|
-
numberOfPositions: 2,
|
|
1688
|
-
currentPosition: 0,
|
|
1689
|
-
}, {}, {
|
|
1690
|
-
switchLatched: true,
|
|
1691
|
-
});
|
|
1692
|
-
}
|
|
1693
|
-
/**
|
|
1694
|
-
* Creates a default latching switch cluster server.
|
|
1695
|
-
*
|
|
1696
|
-
* @remarks
|
|
1697
|
-
* This method adds a cluster server with default latching switch features and configuration.
|
|
1698
|
-
*/
|
|
1699
|
-
createDefaultLatchingSwitchClusterServer() {
|
|
1700
|
-
this.addClusterServer(this.getDefaultLatchingSwitchClusterServer());
|
|
1701
|
-
}
|
|
1702
|
-
/**
|
|
1703
|
-
* Triggers a switch event on the specified endpoint.
|
|
1704
|
-
*
|
|
1705
|
-
* @param {string} event - The type of event to trigger. Possible values are 'Single', 'Double', 'Long' for momentarySwitch and 'Press', 'Release' for latchingSwitch.
|
|
1706
|
-
* @param {Endpoint} endpoint - The endpoint on which to trigger the event (default the device endpoint).
|
|
1707
|
-
* @returns {void}
|
|
1708
|
-
*/
|
|
1709
|
-
triggerSwitchEvent(event, log, endpoint) {
|
|
1710
|
-
if (!endpoint)
|
|
1711
|
-
endpoint = this;
|
|
1712
|
-
if (['Single', 'Double', 'Long'].includes(event)) {
|
|
1713
|
-
const cluster = endpoint.getClusterServer(SwitchCluster.with(Switch.Feature.MomentarySwitch, Switch.Feature.MomentarySwitchRelease, Switch.Feature.MomentarySwitchLongPress, Switch.Feature.MomentarySwitchMultiPress));
|
|
1714
|
-
if (!cluster || !cluster.getFeatureMapAttribute().momentarySwitch) {
|
|
1715
|
-
log?.error(`triggerSwitchEvent ${event} error: Switch cluster with MomentarySwitch not found on endpoint ${endpoint.name}:${endpoint.number}`);
|
|
1716
|
-
return false;
|
|
1717
|
-
}
|
|
1718
|
-
if (endpoint.number === undefined) {
|
|
1719
|
-
log?.error(`triggerSwitchEvent ${event} error: Endpoint number not assigned on endpoint ${endpoint.name}:${endpoint.number}`);
|
|
1720
|
-
return false;
|
|
1721
|
-
}
|
|
1722
|
-
if (event === 'Single') {
|
|
1723
|
-
cluster.setCurrentPositionAttribute(1);
|
|
1724
|
-
cluster.triggerInitialPressEvent({ newPosition: 1 });
|
|
1725
|
-
cluster.setCurrentPositionAttribute(0);
|
|
1726
|
-
cluster.triggerShortReleaseEvent({ previousPosition: 1 });
|
|
1727
|
-
cluster.setCurrentPositionAttribute(0);
|
|
1728
|
-
cluster.triggerMultiPressCompleteEvent({ previousPosition: 1, totalNumberOfPressesCounted: 1 });
|
|
1729
|
-
log?.info(`${db}Trigger endpoint ${or}${endpoint.name}:${endpoint.number}${db} event ${hk}${cluster.name}.SinglePress${db}`);
|
|
1730
|
-
}
|
|
1731
|
-
if (event === 'Double') {
|
|
1732
|
-
cluster.setCurrentPositionAttribute(1);
|
|
1733
|
-
cluster.triggerInitialPressEvent({ newPosition: 1 });
|
|
1734
|
-
cluster.setCurrentPositionAttribute(0);
|
|
1735
|
-
cluster.triggerShortReleaseEvent({ previousPosition: 1 });
|
|
1736
|
-
cluster.setCurrentPositionAttribute(1);
|
|
1737
|
-
cluster.triggerInitialPressEvent({ newPosition: 1 });
|
|
1738
|
-
cluster.triggerMultiPressOngoingEvent({ newPosition: 1, currentNumberOfPressesCounted: 2 });
|
|
1739
|
-
cluster.setCurrentPositionAttribute(0);
|
|
1740
|
-
cluster.triggerShortReleaseEvent({ previousPosition: 1 });
|
|
1741
|
-
cluster.triggerMultiPressCompleteEvent({ previousPosition: 1, totalNumberOfPressesCounted: 2 });
|
|
1742
|
-
log?.info(`${db}Trigger endpoint ${or}${endpoint.name}:${endpoint.number}${db} event ${hk}${cluster.name}.DoublePress${db}`);
|
|
1743
|
-
}
|
|
1744
|
-
if (event === 'Long') {
|
|
1745
|
-
cluster.setCurrentPositionAttribute(1);
|
|
1746
|
-
cluster.triggerInitialPressEvent({ newPosition: 1 });
|
|
1747
|
-
cluster.triggerLongPressEvent({ newPosition: 1 });
|
|
1748
|
-
cluster.setCurrentPositionAttribute(0);
|
|
1749
|
-
cluster.triggerLongReleaseEvent({ previousPosition: 1 });
|
|
1750
|
-
log?.info(`${db}Trigger endpoint ${or}${endpoint.name}:${endpoint.number}${db} event ${hk}${cluster.name}.LongPress${db}`);
|
|
1751
|
-
}
|
|
1752
|
-
}
|
|
1753
|
-
if (['Press', 'Release'].includes(event)) {
|
|
1754
|
-
const cluster = endpoint.getClusterServer(Switch.Complete);
|
|
1755
|
-
if (!cluster || !cluster.getFeatureMapAttribute().latchingSwitch) {
|
|
1756
|
-
log?.error(`triggerSwitchEvent ${event} error: Switch cluster with LatchingSwitch not found on endpoint ${endpoint.name}:${endpoint.number}`);
|
|
1757
|
-
return false;
|
|
1758
|
-
}
|
|
1759
|
-
if (endpoint.number === undefined) {
|
|
1760
|
-
log?.error(`triggerSwitchEvent ${event} error: Endpoint number not assigned on endpoint ${endpoint.name}:${endpoint.number}`);
|
|
1761
|
-
return false;
|
|
1762
|
-
}
|
|
1763
|
-
if (event === 'Press') {
|
|
1764
|
-
cluster.setCurrentPositionAttribute(1);
|
|
1765
|
-
log?.info(`${db}Update endpoint ${or}${endpoint.name}:${endpoint.number}${db} attribute ${hk}${cluster.name}.CurrentPosition${db} to ${YELLOW}1${db}`);
|
|
1766
|
-
if (cluster.triggerSwitchLatchedEvent)
|
|
1767
|
-
cluster.triggerSwitchLatchedEvent({ newPosition: 1 });
|
|
1768
|
-
log?.info(`${db}Trigger endpoint ${or}${endpoint.name}:${endpoint.number}${db} event ${hk}${cluster.name}.Press${db}`);
|
|
1769
|
-
}
|
|
1770
|
-
if (event === 'Release') {
|
|
1771
|
-
cluster.setCurrentPositionAttribute(0);
|
|
1772
|
-
log?.info(`${db}Update endpoint ${or}${endpoint.name}:${endpoint.number}${db} attribute ${hk}${cluster.name}.CurrentPosition${db} to ${YELLOW}0${db}`);
|
|
1773
|
-
if (cluster.triggerSwitchLatchedEvent)
|
|
1774
|
-
cluster.triggerSwitchLatchedEvent({ newPosition: 0 });
|
|
1775
|
-
log?.info(`${db}Trigger endpoint ${or}${endpoint.name}:${endpoint.number}${db} event ${hk}${cluster.name}.Release${db}`);
|
|
1776
|
-
}
|
|
1777
|
-
}
|
|
1778
|
-
return true;
|
|
1779
|
-
}
|
|
1780
|
-
/**
|
|
1781
|
-
* Retrieves the default mode select cluster server.
|
|
1782
|
-
*
|
|
1783
|
-
* @param description - The description of the cluster server.
|
|
1784
|
-
* @param supportedModes - The supported modes for the cluster server.
|
|
1785
|
-
* @param currentMode - The current mode of the cluster server. Defaults to 0.
|
|
1786
|
-
* @param startUpMode - The startup mode of the cluster server. Defaults to 0.
|
|
1787
|
-
* @returns The default mode select cluster server.
|
|
1788
|
-
*/
|
|
1789
|
-
getDefaultModeSelectClusterServer(description, supportedModes, currentMode = 0, startUpMode = 0) {
|
|
1790
|
-
return ClusterServer(ModeSelectCluster, {
|
|
1791
|
-
description: description,
|
|
1792
|
-
standardNamespace: null,
|
|
1793
|
-
supportedModes: supportedModes,
|
|
1794
|
-
currentMode: currentMode,
|
|
1795
|
-
startUpMode: startUpMode,
|
|
1796
|
-
}, {
|
|
1797
|
-
changeToMode: async (data) => {
|
|
1798
|
-
this.log.debug('Matter command: ModeSelectCluster.changeToMode', data.request);
|
|
1799
|
-
await this.commandHandler.executeHandler('changeToMode', data);
|
|
1800
|
-
},
|
|
1801
|
-
});
|
|
1802
|
-
}
|
|
1803
|
-
/**
|
|
1804
|
-
* Creates a default mode select cluster server.
|
|
1805
|
-
*
|
|
1806
|
-
* @remarks
|
|
1807
|
-
* This method adds a cluster server for a mode select cluster with default settings.
|
|
1808
|
-
*
|
|
1809
|
-
* @param endpoint - The endpoint to add the cluster server to. Defaults to `this` if not provided.
|
|
1810
|
-
*/
|
|
1811
|
-
createDefaultModeSelectClusterServer(description, supportedModes, currentMode = 0, startUpMode = 0, endpoint) {
|
|
1812
|
-
if (!endpoint)
|
|
1813
|
-
endpoint = this;
|
|
1814
|
-
endpoint.addClusterServer(this.getDefaultModeSelectClusterServer(description, supportedModes, currentMode, startUpMode));
|
|
1815
|
-
}
|
|
1816
|
-
/**
|
|
1817
|
-
* Get a default occupancy sensing cluster server.
|
|
1818
|
-
*
|
|
1819
|
-
* @param occupied - A boolean indicating whether the occupancy is occupied or not. Default is false.
|
|
1820
|
-
*/
|
|
1821
|
-
getDefaultOccupancySensingClusterServer(occupied = false) {
|
|
1822
|
-
return ClusterServer(OccupancySensingCluster, {
|
|
1823
|
-
occupancy: { occupied },
|
|
1824
|
-
occupancySensorType: OccupancySensing.OccupancySensorType.Pir,
|
|
1825
|
-
occupancySensorTypeBitmap: { pir: true, ultrasonic: false, physicalContact: false },
|
|
1826
|
-
pirOccupiedToUnoccupiedDelay: 30,
|
|
1827
|
-
}, {});
|
|
1828
|
-
}
|
|
1829
|
-
/**
|
|
1830
|
-
* Creates a default occupancy sensing cluster server.
|
|
1831
|
-
*
|
|
1832
|
-
* @param occupied - A boolean indicating whether the occupancy is occupied or not. Default is false.
|
|
1833
|
-
*/
|
|
1834
|
-
createDefaultOccupancySensingClusterServer(occupied = false) {
|
|
1835
|
-
this.addClusterServer(this.getDefaultOccupancySensingClusterServer(occupied));
|
|
1836
|
-
}
|
|
1837
|
-
/**
|
|
1838
|
-
* Get a default Illuminance Measurement Cluster Server.
|
|
1839
|
-
*
|
|
1840
|
-
* @param measuredValue - The measured value of illuminance.
|
|
1841
|
-
*/
|
|
1842
|
-
getDefaultIlluminanceMeasurementClusterServer(measuredValue = 0) {
|
|
1843
|
-
return ClusterServer(IlluminanceMeasurementCluster, {
|
|
1844
|
-
measuredValue,
|
|
1845
|
-
minMeasuredValue: null,
|
|
1846
|
-
maxMeasuredValue: null,
|
|
1847
|
-
tolerance: 0,
|
|
1848
|
-
}, {}, {});
|
|
1849
|
-
}
|
|
1850
|
-
/**
|
|
1851
|
-
* Creates a default Illuminance Measurement Cluster Server.
|
|
1852
|
-
*
|
|
1853
|
-
* @param measuredValue - The measured value of illuminance.
|
|
1854
|
-
*/
|
|
1855
|
-
createDefaultIlluminanceMeasurementClusterServer(measuredValue = 0) {
|
|
1856
|
-
this.addClusterServer(this.getDefaultIlluminanceMeasurementClusterServer(measuredValue));
|
|
1857
|
-
}
|
|
1858
|
-
/**
|
|
1859
|
-
* Get a default flow measurement cluster server.
|
|
1860
|
-
*
|
|
1861
|
-
* @param measuredValue - The measured value of the flow in 10 x m/h.
|
|
1862
|
-
*/
|
|
1863
|
-
getDefaultFlowMeasurementClusterServer(measuredValue = 0) {
|
|
1864
|
-
return ClusterServer(FlowMeasurementCluster, {
|
|
1865
|
-
measuredValue,
|
|
1866
|
-
minMeasuredValue: null,
|
|
1867
|
-
maxMeasuredValue: null,
|
|
1868
|
-
tolerance: 0,
|
|
1869
|
-
}, {}, {});
|
|
1870
|
-
}
|
|
1871
|
-
/**
|
|
1872
|
-
* Creates a default flow measurement cluster server.
|
|
1873
|
-
*
|
|
1874
|
-
* @param measuredValue - The measured value of the of the flow in 10 x m/h.
|
|
1875
|
-
*/
|
|
1876
|
-
createDefaultFlowMeasurementClusterServer(measuredValue = 0) {
|
|
1877
|
-
this.addClusterServer(this.getDefaultFlowMeasurementClusterServer(measuredValue));
|
|
1878
|
-
}
|
|
1879
|
-
/**
|
|
1880
|
-
* Get a default temperature measurement cluster server.
|
|
1881
|
-
*
|
|
1882
|
-
* @param measuredValue - The measured value of the temperature x 100.
|
|
1883
|
-
*/
|
|
1884
|
-
getDefaultTemperatureMeasurementClusterServer(measuredValue = 0) {
|
|
1885
|
-
return ClusterServer(TemperatureMeasurementCluster, {
|
|
1886
|
-
measuredValue,
|
|
1887
|
-
minMeasuredValue: null,
|
|
1888
|
-
maxMeasuredValue: null,
|
|
1889
|
-
tolerance: 0,
|
|
1890
|
-
}, {}, {});
|
|
1891
|
-
}
|
|
1892
|
-
/**
|
|
1893
|
-
* Creates a default temperature measurement cluster server.
|
|
1894
|
-
*
|
|
1895
|
-
* @param measuredValue - The measured value of the temperature x 100.
|
|
1896
|
-
*/
|
|
1897
|
-
createDefaultTemperatureMeasurementClusterServer(measuredValue = 0) {
|
|
1898
|
-
this.addClusterServer(this.getDefaultTemperatureMeasurementClusterServer(measuredValue));
|
|
1899
|
-
}
|
|
1900
|
-
/**
|
|
1901
|
-
* Get a default RelativeHumidityMeasurementCluster server.
|
|
1902
|
-
*
|
|
1903
|
-
* @param measuredValue - The measured value of the relative humidity x 100.
|
|
1904
|
-
*/
|
|
1905
|
-
getDefaultRelativeHumidityMeasurementClusterServer(measuredValue = 0) {
|
|
1906
|
-
return ClusterServer(RelativeHumidityMeasurementCluster, {
|
|
1907
|
-
measuredValue,
|
|
1908
|
-
minMeasuredValue: null,
|
|
1909
|
-
maxMeasuredValue: null,
|
|
1910
|
-
tolerance: 0,
|
|
1911
|
-
}, {}, {});
|
|
1912
|
-
}
|
|
1913
|
-
/**
|
|
1914
|
-
* Creates a default RelativeHumidityMeasurementCluster server.
|
|
1915
|
-
*
|
|
1916
|
-
* @param measuredValue - The measured value of the relative humidity x 100.
|
|
1917
|
-
*/
|
|
1918
|
-
createDefaultRelativeHumidityMeasurementClusterServer(measuredValue = 0) {
|
|
1919
|
-
this.addClusterServer(this.getDefaultRelativeHumidityMeasurementClusterServer(measuredValue));
|
|
1920
|
-
}
|
|
1921
|
-
/**
|
|
1922
|
-
* Get a default Pressure Measurement Cluster Server.
|
|
1923
|
-
*
|
|
1924
|
-
* @param measuredValue - The measured value for the pressure.
|
|
1925
|
-
*/
|
|
1926
|
-
getDefaultPressureMeasurementClusterServer(measuredValue = 1000) {
|
|
1927
|
-
return ClusterServer(PressureMeasurementCluster, {
|
|
1928
|
-
measuredValue,
|
|
1929
|
-
minMeasuredValue: null,
|
|
1930
|
-
maxMeasuredValue: null,
|
|
1931
|
-
tolerance: 0,
|
|
1932
|
-
}, {}, {});
|
|
1933
|
-
}
|
|
1934
|
-
/**
|
|
1935
|
-
* Creates a default Pressure Measurement Cluster Server.
|
|
1936
|
-
*
|
|
1937
|
-
* @param measuredValue - The measured value for the pressure.
|
|
1938
|
-
*/
|
|
1939
|
-
createDefaultPressureMeasurementClusterServer(measuredValue = 1000) {
|
|
1940
|
-
this.addClusterServer(this.getDefaultPressureMeasurementClusterServer(measuredValue));
|
|
1941
|
-
}
|
|
1942
|
-
/**
|
|
1943
|
-
* Get a default boolean state cluster server.
|
|
1944
|
-
*
|
|
1945
|
-
* @param contact - Optional boolean value indicating the contact state. Defaults to `true` if not provided.
|
|
1946
|
-
*/
|
|
1947
|
-
getDefaultBooleanStateClusterServer(contact) {
|
|
1948
|
-
return ClusterServer(BooleanStateCluster, {
|
|
1949
|
-
stateValue: contact ?? true, // true=contact false=no_contact
|
|
1950
|
-
}, {}, {
|
|
1951
|
-
stateChange: true,
|
|
1952
|
-
});
|
|
1953
|
-
}
|
|
1954
|
-
/**
|
|
1955
|
-
* Creates a default boolean state configuration cluster server.
|
|
1956
|
-
*
|
|
1957
|
-
* @param contact - Optional boolean value indicating the contact state. Defaults to `true` if not provided.
|
|
1958
|
-
*/
|
|
1959
|
-
createDefaultBooleanStateClusterServer(contact) {
|
|
1960
|
-
this.addClusterServer(this.getDefaultBooleanStateClusterServer(contact));
|
|
1961
|
-
}
|
|
1962
|
-
/**
|
|
1963
|
-
* Get a default boolean state configuration cluster server.
|
|
1964
|
-
*
|
|
1965
|
-
* @param contact - Optional boolean value indicating the sensor fault state. Defaults to `false` if not provided.
|
|
1966
|
-
*/
|
|
1967
|
-
getDefaultBooleanStateConfigurationClusterServer(sensorFault = false) {
|
|
1968
|
-
return ClusterServer(BooleanStateConfigurationCluster.with(BooleanStateConfiguration.Feature.Visual, BooleanStateConfiguration.Feature.Audible, BooleanStateConfiguration.Feature.SensitivityLevel), {
|
|
1969
|
-
currentSensitivityLevel: 0,
|
|
1970
|
-
supportedSensitivityLevels: 2,
|
|
1971
|
-
defaultSensitivityLevel: 0,
|
|
1972
|
-
alarmsActive: { visual: false, audible: false },
|
|
1973
|
-
alarmsEnabled: { visual: false, audible: false },
|
|
1974
|
-
alarmsSupported: { visual: true, audible: true },
|
|
1975
|
-
// alarmsSuppressed: { visual: false, audible: false },
|
|
1976
|
-
sensorFault: { generalFault: sensorFault },
|
|
1977
|
-
}, {
|
|
1978
|
-
enableDisableAlarm: async ({ request, attributes }) => {
|
|
1979
|
-
this.log.debug('Matter command: enableDisableAlarm', request);
|
|
1980
|
-
await this.commandHandler.executeHandler('enableDisableAlarm', { request, attributes });
|
|
1981
|
-
},
|
|
1982
|
-
}, {
|
|
1983
|
-
alarmsStateChanged: true,
|
|
1984
|
-
sensorFault: true,
|
|
1985
|
-
});
|
|
1986
|
-
}
|
|
1987
|
-
/**
|
|
1988
|
-
* Creates a default boolean state configuration cluster server.
|
|
1989
|
-
*
|
|
1990
|
-
* @param contact - Optional boolean value indicating the sensor fault state. Defaults to `false` if not provided.
|
|
1991
|
-
*/
|
|
1992
|
-
createDefaultBooleanStateConfigurationClusterServer(sensorFault = false) {
|
|
1993
|
-
this.addClusterServer(this.getDefaultBooleanStateConfigurationClusterServer(sensorFault));
|
|
1994
|
-
}
|
|
1995
|
-
/**
|
|
1996
|
-
* Get a default power source replaceable battery cluster server.
|
|
1997
|
-
*
|
|
1998
|
-
* @param batPercentRemaining - The remaining battery percentage (default: 100).
|
|
1999
|
-
* @param batChargeLevel - The battery charge level (default: PowerSource.BatChargeLevel.Ok).
|
|
2000
|
-
* @param batVoltage - The battery voltage (default: 1500).
|
|
2001
|
-
* @param batReplacementDescription - The battery replacement description (default: 'Battery type').
|
|
2002
|
-
* @param batQuantity - The battery quantity (default: 1).
|
|
2003
|
-
*/
|
|
2004
|
-
getDefaultPowerSourceReplaceableBatteryClusterServer(batPercentRemaining = 100, batChargeLevel = PowerSource.BatChargeLevel.Ok, batVoltage = 1500, batReplacementDescription = 'Battery type', batQuantity = 1) {
|
|
2005
|
-
return ClusterServer(PowerSourceCluster.with(PowerSource.Feature.Battery, PowerSource.Feature.Replaceable), {
|
|
2006
|
-
status: PowerSource.PowerSourceStatus.Active,
|
|
2007
|
-
order: 0,
|
|
2008
|
-
description: 'Primary battery',
|
|
2009
|
-
batVoltage,
|
|
2010
|
-
batPercentRemaining: Math.min(Math.max(batPercentRemaining * 2, 0), 200),
|
|
2011
|
-
batChargeLevel,
|
|
2012
|
-
batReplacementNeeded: false,
|
|
2013
|
-
batReplaceability: PowerSource.BatReplaceability.UserReplaceable,
|
|
2014
|
-
activeBatFaults: undefined,
|
|
2015
|
-
batReplacementDescription,
|
|
2016
|
-
batQuantity,
|
|
2017
|
-
endpointList: [],
|
|
2018
|
-
}, {}, {});
|
|
2019
|
-
}
|
|
2020
|
-
/**
|
|
2021
|
-
* Creates a default power source replaceable battery cluster server.
|
|
2022
|
-
*
|
|
2023
|
-
* @param batPercentRemaining - The remaining battery percentage (default: 100).
|
|
2024
|
-
* @param batChargeLevel - The battery charge level (default: PowerSource.BatChargeLevel.Ok).
|
|
2025
|
-
* @param batVoltage - The battery voltage (default: 1500).
|
|
2026
|
-
* @param batReplacementDescription - The battery replacement description (default: 'Battery type').
|
|
2027
|
-
* @param batQuantity - The battery quantity (default: 1).
|
|
2028
|
-
*/
|
|
2029
|
-
createDefaultPowerSourceReplaceableBatteryClusterServer(batPercentRemaining = 100, batChargeLevel = PowerSource.BatChargeLevel.Ok, batVoltage = 1500, batReplacementDescription = 'Battery type', batQuantity = 1) {
|
|
2030
|
-
this.addClusterServer(this.getDefaultPowerSourceReplaceableBatteryClusterServer(batPercentRemaining, batChargeLevel, batVoltage, batReplacementDescription, batQuantity));
|
|
2031
|
-
}
|
|
2032
|
-
/**
|
|
2033
|
-
* Get a default power source rechargeable battery cluster server.
|
|
2034
|
-
*
|
|
2035
|
-
* @param batPercentRemaining - The remaining battery percentage (default: 100).
|
|
2036
|
-
* @param batChargeLevel - The battery charge level (default: PowerSource.BatChargeLevel.Ok).
|
|
2037
|
-
* @param batVoltage - The battery voltage (default: 1500).
|
|
2038
|
-
*/
|
|
2039
|
-
getDefaultPowerSourceRechargeableBatteryClusterServer(batPercentRemaining = 100, batChargeLevel = PowerSource.BatChargeLevel.Ok, batVoltage = 1500) {
|
|
2040
|
-
return ClusterServer(PowerSourceCluster.with(PowerSource.Feature.Battery, PowerSource.Feature.Rechargeable), {
|
|
2041
|
-
status: PowerSource.PowerSourceStatus.Active,
|
|
2042
|
-
order: 0,
|
|
2043
|
-
description: 'Primary battery',
|
|
2044
|
-
batVoltage,
|
|
2045
|
-
batPercentRemaining: Math.min(Math.max(batPercentRemaining * 2, 0), 200),
|
|
2046
|
-
batTimeRemaining: 1,
|
|
2047
|
-
batChargeLevel,
|
|
2048
|
-
batReplacementNeeded: false,
|
|
2049
|
-
batReplaceability: PowerSource.BatReplaceability.Unspecified,
|
|
2050
|
-
activeBatFaults: undefined,
|
|
2051
|
-
batChargeState: PowerSource.BatChargeState.IsNotCharging,
|
|
2052
|
-
batFunctionalWhileCharging: true,
|
|
2053
|
-
endpointList: [],
|
|
2054
|
-
}, {}, {});
|
|
2055
|
-
}
|
|
2056
|
-
/**
|
|
2057
|
-
* Creates a default power source rechargeable battery cluster server.
|
|
2058
|
-
*
|
|
2059
|
-
* @param batPercentRemaining - The remaining battery percentage (default: 100).
|
|
2060
|
-
* @param batChargeLevel - The battery charge level (default: PowerSource.BatChargeLevel.Ok).
|
|
2061
|
-
* @param batVoltage - The battery voltage (default: 1500).
|
|
2062
|
-
*/
|
|
2063
|
-
createDefaultPowerSourceRechargeableBatteryClusterServer(batPercentRemaining = 100, batChargeLevel = PowerSource.BatChargeLevel.Ok, batVoltage = 1500) {
|
|
2064
|
-
this.addClusterServer(this.getDefaultPowerSourceRechargeableBatteryClusterServer(batPercentRemaining, batChargeLevel, batVoltage));
|
|
2065
|
-
}
|
|
2066
|
-
/**
|
|
2067
|
-
* Get a default power source wired cluster server.
|
|
2068
|
-
*
|
|
2069
|
-
* @param wiredCurrentType - The type of wired current (default: PowerSource.WiredCurrentType.Ac)
|
|
2070
|
-
*/
|
|
2071
|
-
getDefaultPowerSourceWiredClusterServer(wiredCurrentType = PowerSource.WiredCurrentType.Ac) {
|
|
2072
|
-
return ClusterServer(PowerSourceCluster.with(PowerSource.Feature.Wired), {
|
|
2073
|
-
wiredCurrentType,
|
|
2074
|
-
description: wiredCurrentType === PowerSource.WiredCurrentType.Ac ? 'AC Power' : 'DC Power',
|
|
2075
|
-
status: PowerSource.PowerSourceStatus.Active,
|
|
2076
|
-
order: 0,
|
|
2077
|
-
endpointList: [],
|
|
2078
|
-
}, {}, {});
|
|
2079
|
-
}
|
|
2080
|
-
/**
|
|
2081
|
-
* Creates a default power source wired cluster server.
|
|
2082
|
-
*
|
|
2083
|
-
* @param wiredCurrentType - The type of wired current (default: PowerSource.WiredCurrentType.Ac)
|
|
2084
|
-
*/
|
|
2085
|
-
createDefaultPowerSourceWiredClusterServer(wiredCurrentType = PowerSource.WiredCurrentType.Ac) {
|
|
2086
|
-
this.addClusterServer(this.getDefaultPowerSourceWiredClusterServer(wiredCurrentType));
|
|
2087
|
-
}
|
|
2088
|
-
/**
|
|
2089
|
-
* @deprecated This function is deprecated by Matter 1.3 spec and will be removed in a future version.
|
|
2090
|
-
*/
|
|
2091
|
-
createDefaultPowerSourceConfigurationClusterServer(endpointNumber) {
|
|
2092
|
-
this.addClusterServer(ClusterServer(PowerSourceConfigurationCluster, {
|
|
2093
|
-
sources: endpointNumber ? [EndpointNumber(endpointNumber)] : [],
|
|
2094
|
-
}, {}, {}));
|
|
2095
|
-
}
|
|
2096
|
-
/**
|
|
2097
|
-
* Get a default air quality cluster server.
|
|
2098
|
-
*
|
|
2099
|
-
* @param airQuality The air quality type. Defaults to `AirQuality.AirQualityType.Unknown`.
|
|
2100
|
-
*/
|
|
2101
|
-
getDefaultAirQualityClusterServer(airQuality = AirQuality.AirQualityEnum.Unknown) {
|
|
2102
|
-
return ClusterServer(AirQualityCluster.with(AirQuality.Feature.Fair, AirQuality.Feature.Moderate, AirQuality.Feature.VeryPoor, AirQuality.Feature.ExtremelyPoor), {
|
|
2103
|
-
airQuality,
|
|
2104
|
-
}, {}, {});
|
|
2105
|
-
}
|
|
2106
|
-
/**
|
|
2107
|
-
* Creates a default air quality cluster server.
|
|
2108
|
-
*
|
|
2109
|
-
* @param airQuality The air quality type. Defaults to `AirQuality.AirQualityType.Unknown`.
|
|
2110
|
-
*/
|
|
2111
|
-
createDefaultAirQualityClusterServer(airQuality = AirQuality.AirQualityEnum.Unknown) {
|
|
2112
|
-
this.addClusterServer(this.getDefaultAirQualityClusterServer(airQuality));
|
|
2113
|
-
}
|
|
2114
|
-
/**
|
|
2115
|
-
* Get a default TVOC measurement cluster server.
|
|
2116
|
-
*
|
|
2117
|
-
* @param measuredValue - The measured value for TVOC.
|
|
2118
|
-
*/
|
|
2119
|
-
getDefaultTvocMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
2120
|
-
return ClusterServer(TotalVolatileOrganicCompoundsConcentrationMeasurementCluster.with('NumericMeasurement'), {
|
|
2121
|
-
measuredValue,
|
|
2122
|
-
minMeasuredValue: null,
|
|
2123
|
-
maxMeasuredValue: null,
|
|
2124
|
-
uncertainty: 0,
|
|
2125
|
-
measurementUnit,
|
|
2126
|
-
measurementMedium,
|
|
2127
|
-
}, {}, {});
|
|
2128
|
-
}
|
|
2129
|
-
/**
|
|
2130
|
-
* Creates a default TVOC measurement cluster server.
|
|
2131
|
-
*
|
|
2132
|
-
* @param measuredValue - The measured value for TVOC.
|
|
2133
|
-
*/
|
|
2134
|
-
createDefaultTvocMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
2135
|
-
this.addClusterServer(this.getDefaultTvocMeasurementClusterServer(measuredValue, measurementUnit, measurementMedium));
|
|
2136
|
-
}
|
|
2137
|
-
/**
|
|
2138
|
-
* Get a default heating thermostat cluster server with the specified parameters.
|
|
2139
|
-
* @param {number} [localTemperature] - The local temperature value in degrees Celsius. Defaults to 23°.
|
|
2140
|
-
* @param {number} [occupiedHeatingSetpoint] - The occupied heating setpoint value in degrees Celsius. Defaults to 21°.
|
|
2141
|
-
* @param {number} [minHeatSetpointLimit] - The minimum heat setpoint limit value. Defaults to 0°.
|
|
2142
|
-
* @param {number} [maxHeatSetpointLimit] - The maximum heat setpoint limit value. Defaults to 50°.
|
|
2143
|
-
* @returns {ThermostatClusterServer} A default thermostat cluster server configured with the specified parameters.
|
|
2144
|
-
*/
|
|
2145
|
-
getDefaultHeatingThermostatClusterServer(localTemperature = 23, occupiedHeatingSetpoint = 21, minHeatSetpointLimit = 0, maxHeatSetpointLimit = 50) {
|
|
2146
|
-
return ClusterServer(ThermostatCluster.with(Thermostat.Feature.Heating), {
|
|
2147
|
-
localTemperature: localTemperature * 100,
|
|
2148
|
-
systemMode: Thermostat.SystemMode.Heat,
|
|
2149
|
-
controlSequenceOfOperation: Thermostat.ControlSequenceOfOperation.HeatingOnly,
|
|
2150
|
-
// Thermostat.Feature.Heating
|
|
2151
|
-
occupiedHeatingSetpoint: occupiedHeatingSetpoint * 100,
|
|
2152
|
-
minHeatSetpointLimit: minHeatSetpointLimit * 100,
|
|
2153
|
-
maxHeatSetpointLimit: maxHeatSetpointLimit * 100,
|
|
2154
|
-
absMinHeatSetpointLimit: minHeatSetpointLimit * 100,
|
|
2155
|
-
absMaxHeatSetpointLimit: maxHeatSetpointLimit * 100,
|
|
2156
|
-
}, {
|
|
2157
|
-
setpointRaiseLower: async ({ request, attributes }) => {
|
|
2158
|
-
this.log.debug('Matter command: setpointRaiseLower', request);
|
|
2159
|
-
await this.commandHandler.executeHandler('setpointRaiseLower', { request, attributes });
|
|
2160
|
-
},
|
|
2161
|
-
}, {});
|
|
2162
|
-
}
|
|
2163
|
-
/**
|
|
2164
|
-
* Creates and adds a default heating thermostat cluster server to the device.
|
|
2165
|
-
*
|
|
2166
|
-
* @param {number} [localTemperature] - The local temperature value in degrees Celsius. Defaults to 23°.
|
|
2167
|
-
* @param {number} [occupiedHeatingSetpoint] - The occupied heating setpoint value in degrees Celsius. Defaults to 21°.
|
|
2168
|
-
* @param {number} [minHeatSetpointLimit] - The minimum heat setpoint limit value. Defaults to 0°.
|
|
2169
|
-
* @param {number} [maxHeatSetpointLimit] - The maximum heat setpoint limit value. Defaults to 50°.
|
|
2170
|
-
*/
|
|
2171
|
-
createDefaultHeatingThermostatClusterServer(localTemperature = 23, occupiedHeatingSetpoint = 25, minHeatSetpointLimit = 0, maxHeatSetpointLimit = 50) {
|
|
2172
|
-
this.addClusterServer(this.getDefaultHeatingThermostatClusterServer(localTemperature, occupiedHeatingSetpoint, minHeatSetpointLimit, maxHeatSetpointLimit));
|
|
2173
|
-
}
|
|
2174
|
-
/**
|
|
2175
|
-
* Get a default cooling thermostat cluster server with the specified parameters.
|
|
2176
|
-
* @param {number} [localTemperature] - The local temperature value in degrees Celsius. Defaults to 23°.
|
|
2177
|
-
* @param {number} [occupiedCoolingSetpoint] - The occupied cooling setpoint value in degrees Celsius. Defaults to 25°.
|
|
2178
|
-
* @param {number} [minCoolSetpointLimit] - The minimum cool setpoint limit value. Defaults to 0°.
|
|
2179
|
-
* @param {number} [maxCoolSetpointLimit] - The maximum cool setpoint limit value. Defaults to 50°.
|
|
2180
|
-
* @returns {ThermostatClusterServer} A default thermostat cluster server configured with the specified parameters.
|
|
2181
|
-
*/
|
|
2182
|
-
getDefaultCoolingThermostatClusterServer(localTemperature = 23, occupiedCoolingSetpoint = 25, minCoolSetpointLimit = 0, maxCoolSetpointLimit = 50) {
|
|
2183
|
-
return ClusterServer(ThermostatCluster.with(Thermostat.Feature.Cooling), {
|
|
2184
|
-
localTemperature: localTemperature * 100,
|
|
2185
|
-
systemMode: Thermostat.SystemMode.Cool,
|
|
2186
|
-
controlSequenceOfOperation: Thermostat.ControlSequenceOfOperation.CoolingOnly,
|
|
2187
|
-
// Thermostat.Feature.Cooling
|
|
2188
|
-
occupiedCoolingSetpoint: occupiedCoolingSetpoint * 100,
|
|
2189
|
-
minCoolSetpointLimit: minCoolSetpointLimit * 100,
|
|
2190
|
-
maxCoolSetpointLimit: maxCoolSetpointLimit * 100,
|
|
2191
|
-
absMinCoolSetpointLimit: minCoolSetpointLimit * 100,
|
|
2192
|
-
absMaxCoolSetpointLimit: maxCoolSetpointLimit * 100,
|
|
2193
|
-
}, {
|
|
2194
|
-
setpointRaiseLower: async ({ request, attributes }) => {
|
|
2195
|
-
this.log.debug('Matter command: setpointRaiseLower', request);
|
|
2196
|
-
await this.commandHandler.executeHandler('setpointRaiseLower', { request, attributes });
|
|
2197
|
-
},
|
|
2198
|
-
}, {});
|
|
2199
|
-
}
|
|
2200
|
-
/**
|
|
2201
|
-
* Creates and adds a default cooling thermostat cluster server to the device.
|
|
2202
|
-
*
|
|
2203
|
-
* @param {number} [localTemperature] - The local temperature value in degrees Celsius. Defaults to 23°.
|
|
2204
|
-
* @param {number} [occupiedCoolingSetpoint] - The occupied cooling setpoint value in degrees Celsius. Defaults to 25°.
|
|
2205
|
-
* @param {number} [minCoolSetpointLimit] - The minimum cool setpoint limit value. Defaults to 0°.
|
|
2206
|
-
* @param {number} [maxCoolSetpointLimit] - The maximum cool setpoint limit value. Defaults to 50°.
|
|
2207
|
-
*/
|
|
2208
|
-
createDefaultCoolingThermostatClusterServer(localTemperature = 23, occupiedCoolingSetpoint = 25, minCoolSetpointLimit = 0, maxCoolSetpointLimit = 50) {
|
|
2209
|
-
this.addClusterServer(this.getDefaultCoolingThermostatClusterServer(localTemperature, occupiedCoolingSetpoint, minCoolSetpointLimit, maxCoolSetpointLimit));
|
|
2210
|
-
}
|
|
2211
|
-
/**
|
|
2212
|
-
* Get a default thermostat cluster server with the specified parameters.
|
|
2213
|
-
*
|
|
2214
|
-
* @param {number} [localTemperature=23] - The local temperature value in degrees Celsius. Defaults to 23°.
|
|
2215
|
-
* @param {number} [occupiedHeatingSetpoint=21] - The occupied heating setpoint value in degrees Celsius. Defaults to 21°.
|
|
2216
|
-
* @param {number} [occupiedCoolingSetpoint=25] - The occupied cooling setpoint value in degrees Celsius. Defaults to 25°.
|
|
2217
|
-
* @param {number} [minSetpointDeadBand=1] - The minimum setpoint dead band value. Defaults to 1°.
|
|
2218
|
-
* @param {number} [minHeatSetpointLimit=0] - The minimum heat setpoint limit value. Defaults to 0°.
|
|
2219
|
-
* @param {number} [maxHeatSetpointLimit=50] - The maximum heat setpoint limit value. Defaults to 50°.
|
|
2220
|
-
* @param {number} [minCoolSetpointLimit=0] - The minimum cool setpoint limit value. Defaults to 0°.
|
|
2221
|
-
* @param {number} [maxCoolSetpointLimit=50] - The maximum cool setpoint limit value. Defaults to 50°.
|
|
2222
|
-
* @returns {ThermostatClusterServer} A default thermostat cluster server configured with the specified parameters.
|
|
2223
|
-
*/
|
|
2224
|
-
getDefaultThermostatClusterServer(localTemperature = 23, occupiedHeatingSetpoint = 21, occupiedCoolingSetpoint = 25, minSetpointDeadBand = 1, minHeatSetpointLimit = 0, maxHeatSetpointLimit = 50, minCoolSetpointLimit = 0, maxCoolSetpointLimit = 50) {
|
|
2225
|
-
return ClusterServer(ThermostatCluster.with(Thermostat.Feature.Heating, Thermostat.Feature.Cooling, Thermostat.Feature.AutoMode), {
|
|
2226
|
-
localTemperature: localTemperature * 100,
|
|
2227
|
-
systemMode: Thermostat.SystemMode.Auto,
|
|
2228
|
-
controlSequenceOfOperation: Thermostat.ControlSequenceOfOperation.CoolingAndHeating,
|
|
2229
|
-
// Thermostat.Feature.Heating
|
|
2230
|
-
occupiedHeatingSetpoint: occupiedHeatingSetpoint * 100,
|
|
2231
|
-
minHeatSetpointLimit: minHeatSetpointLimit * 100,
|
|
2232
|
-
maxHeatSetpointLimit: maxHeatSetpointLimit * 100,
|
|
2233
|
-
absMinHeatSetpointLimit: minHeatSetpointLimit * 100,
|
|
2234
|
-
absMaxHeatSetpointLimit: maxHeatSetpointLimit * 100,
|
|
2235
|
-
// Thermostat.Feature.Cooling
|
|
2236
|
-
occupiedCoolingSetpoint: occupiedCoolingSetpoint * 100,
|
|
2237
|
-
minCoolSetpointLimit: minCoolSetpointLimit * 100,
|
|
2238
|
-
maxCoolSetpointLimit: maxCoolSetpointLimit * 100,
|
|
2239
|
-
absMinCoolSetpointLimit: minCoolSetpointLimit * 100,
|
|
2240
|
-
absMaxCoolSetpointLimit: maxCoolSetpointLimit * 100,
|
|
2241
|
-
// Thermostat.Feature.AutoMode
|
|
2242
|
-
minSetpointDeadBand: minSetpointDeadBand * 100,
|
|
2243
|
-
thermostatRunningMode: Thermostat.ThermostatRunningMode.Off,
|
|
2244
|
-
}, {
|
|
2245
|
-
setpointRaiseLower: async ({ request, attributes }) => {
|
|
2246
|
-
this.log.debug('Matter command: setpointRaiseLower', request);
|
|
2247
|
-
await this.commandHandler.executeHandler('setpointRaiseLower', { request, attributes });
|
|
2248
|
-
},
|
|
2249
|
-
}, {});
|
|
2250
|
-
}
|
|
2251
|
-
/**
|
|
2252
|
-
* Creates and adds a default thermostat cluster server to the device.
|
|
2253
|
-
*
|
|
2254
|
-
* @param {number} [localTemperature=23] - The local temperature value in degrees Celsius. Defaults to 23°.
|
|
2255
|
-
* @param {number} [occupiedHeatingSetpoint=21] - The occupied heating setpoint value in degrees Celsius. Defaults to 21°.
|
|
2256
|
-
* @param {number} [occupiedCoolingSetpoint=25] - The occupied cooling setpoint value in degrees Celsius. Defaults to 25°.
|
|
2257
|
-
* @param {number} [minSetpointDeadBand=1] - The minimum setpoint dead band value. Defaults to 1°.
|
|
2258
|
-
* @param {number} [minHeatSetpointLimit=0] - The minimum heat setpoint limit value. Defaults to 0°.
|
|
2259
|
-
* @param {number} [maxHeatSetpointLimit=50] - The maximum heat setpoint limit value. Defaults to 50°.
|
|
2260
|
-
* @param {number} [minCoolSetpointLimit=0] - The minimum cool setpoint limit value. Defaults to 0°.
|
|
2261
|
-
* @param {number} [maxCoolSetpointLimit=50] - The maximum cool setpoint limit value. Defaults to 50°.
|
|
2262
|
-
*/
|
|
2263
|
-
createDefaultThermostatClusterServer(localTemperature = 23, occupiedHeatingSetpoint = 21, occupiedCoolingSetpoint = 25, minSetpointDeadBand = 1, minHeatSetpointLimit = 0, maxHeatSetpointLimit = 50, minCoolSetpointLimit = 0, maxCoolSetpointLimit = 50) {
|
|
2264
|
-
this.addClusterServer(this.getDefaultThermostatClusterServer(localTemperature, occupiedHeatingSetpoint, occupiedCoolingSetpoint, minSetpointDeadBand, minHeatSetpointLimit, maxHeatSetpointLimit, minCoolSetpointLimit, maxCoolSetpointLimit));
|
|
2265
|
-
}
|
|
2266
|
-
/**
|
|
2267
|
-
* Get a default dummy time sync cluster server. Only needed to create a thermostat.
|
|
2268
|
-
*/
|
|
2269
|
-
getDefaultTimeSyncClusterServer() {
|
|
2270
|
-
return ClusterServer(TimeSynchronizationCluster.with(TimeSynchronization.Feature.TimeZone), {
|
|
2271
|
-
utcTime: null,
|
|
2272
|
-
granularity: TimeSynchronization.Granularity.NoTimeGranularity,
|
|
2273
|
-
timeZone: [{ offset: 0, validAt: 0 }],
|
|
2274
|
-
dstOffset: [],
|
|
2275
|
-
localTime: null,
|
|
2276
|
-
timeZoneDatabase: TimeSynchronization.TimeZoneDatabase.None,
|
|
2277
|
-
timeZoneListMaxSize: 1,
|
|
2278
|
-
dstOffsetListMaxSize: 1,
|
|
2279
|
-
}, {
|
|
2280
|
-
setTimeZone: async ({ request, attributes }) => {
|
|
2281
|
-
this.log.debug('Matter command: setTimeZone', request);
|
|
2282
|
-
await this.commandHandler.executeHandler('setTimeZone', { request, attributes });
|
|
2283
|
-
return { dstOffsetsRequired: false };
|
|
2284
|
-
},
|
|
2285
|
-
setDstOffset: async ({ request, attributes }) => {
|
|
2286
|
-
this.log.debug('Matter command: setDstOffset', request);
|
|
2287
|
-
await this.commandHandler.executeHandler('setDstOffset', { request, attributes });
|
|
2288
|
-
},
|
|
2289
|
-
setUtcTime: async ({ request, attributes }) => {
|
|
2290
|
-
this.log.debug('Matter command: setUtcTime', request);
|
|
2291
|
-
await this.commandHandler.executeHandler('setUtcTime', { request, attributes });
|
|
2292
|
-
},
|
|
2293
|
-
}, {
|
|
2294
|
-
dstTableEmpty: true,
|
|
2295
|
-
dstStatus: true,
|
|
2296
|
-
timeZoneStatus: true,
|
|
2297
|
-
timeFailure: true,
|
|
2298
|
-
});
|
|
2299
|
-
}
|
|
2300
|
-
/**
|
|
2301
|
-
* Creates a default dummy time sync cluster server. Only needed to create a thermostat.
|
|
2302
|
-
*/
|
|
2303
|
-
createDefaultTimeSyncClusterServer() {
|
|
2304
|
-
this.addClusterServer(this.getDefaultTimeSyncClusterServer());
|
|
2305
|
-
}
|
|
2306
|
-
/**
|
|
2307
|
-
* Returns the default SmokeCOAlarm Cluster Server.
|
|
2308
|
-
*
|
|
2309
|
-
* @param smokeState - The state of the smoke alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
|
|
2310
|
-
* @param coState - The state of the CO alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
|
|
2311
|
-
* @returns The default SmokeCOAlarmClusterServer.
|
|
2312
|
-
*/
|
|
2313
|
-
getDefaultSmokeCOAlarmClusterServer(smokeState = SmokeCoAlarm.AlarmState.Normal, coState = SmokeCoAlarm.AlarmState.Normal) {
|
|
2314
|
-
return ClusterServer(SmokeCoAlarmCluster.with(SmokeCoAlarm.Feature.SmokeAlarm, SmokeCoAlarm.Feature.CoAlarm), {
|
|
2315
|
-
smokeState,
|
|
2316
|
-
coState,
|
|
2317
|
-
expressedState: SmokeCoAlarm.ExpressedState.Normal,
|
|
2318
|
-
batteryAlert: SmokeCoAlarm.AlarmState.Normal,
|
|
2319
|
-
deviceMuted: SmokeCoAlarm.MuteState.NotMuted,
|
|
2320
|
-
testInProgress: false,
|
|
2321
|
-
hardwareFaultAlert: false,
|
|
2322
|
-
endOfServiceAlert: SmokeCoAlarm.EndOfService.Normal,
|
|
2323
|
-
interconnectSmokeAlarm: SmokeCoAlarm.AlarmState.Normal,
|
|
2324
|
-
interconnectCoAlarm: SmokeCoAlarm.AlarmState.Normal,
|
|
2325
|
-
}, {
|
|
2326
|
-
selfTestRequest: async ({ request, attributes }) => {
|
|
2327
|
-
this.log.debug('Matter command: selfTestRequest');
|
|
2328
|
-
await this.commandHandler.executeHandler('selfTestRequest', { request, attributes });
|
|
2329
|
-
},
|
|
2330
|
-
}, {
|
|
2331
|
-
smokeAlarm: true,
|
|
2332
|
-
interconnectSmokeAlarm: true,
|
|
2333
|
-
coAlarm: true,
|
|
2334
|
-
interconnectCoAlarm: true,
|
|
2335
|
-
lowBattery: true,
|
|
2336
|
-
hardwareFault: true,
|
|
2337
|
-
endOfService: true,
|
|
2338
|
-
selfTestComplete: true,
|
|
2339
|
-
alarmMuted: true,
|
|
2340
|
-
muteEnded: true,
|
|
2341
|
-
allClear: true,
|
|
2342
|
-
});
|
|
2343
|
-
}
|
|
2344
|
-
/**
|
|
2345
|
-
* Create the default SmokeCOAlarm Cluster Server.
|
|
2346
|
-
*
|
|
2347
|
-
* @param smokeState - The state of the smoke alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
|
|
2348
|
-
* @param coState - The state of the CO alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
|
|
2349
|
-
* @returns The default SmokeCOAlarmClusterServer.
|
|
2350
|
-
*/
|
|
2351
|
-
createDefaultSmokeCOAlarmClusterServer(smokeState = SmokeCoAlarm.AlarmState.Normal, coState = SmokeCoAlarm.AlarmState.Normal) {
|
|
2352
|
-
this.addClusterServer(this.getDefaultSmokeCOAlarmClusterServer(smokeState, coState));
|
|
2353
|
-
}
|
|
2354
|
-
/**
|
|
2355
|
-
* Returns the default Carbon Monoxide Concentration Measurement Cluster Server.
|
|
2356
|
-
*
|
|
2357
|
-
* @param {number} measuredValue - The measured value of the concentration.
|
|
2358
|
-
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
2359
|
-
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
2360
|
-
* @returns {ClusterServer} - The default Carbon Monoxide Concentration Measurement Cluster Server.
|
|
2361
|
-
*/
|
|
2362
|
-
getDefaultCarbonMonoxideConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
2363
|
-
return ClusterServer(CarbonMonoxideConcentrationMeasurementCluster.with('NumericMeasurement'), {
|
|
2364
|
-
measuredValue,
|
|
2365
|
-
minMeasuredValue: null,
|
|
2366
|
-
maxMeasuredValue: null,
|
|
2367
|
-
uncertainty: 0,
|
|
2368
|
-
measurementUnit,
|
|
2369
|
-
measurementMedium,
|
|
2370
|
-
}, {}, {});
|
|
2371
|
-
}
|
|
2372
|
-
/**
|
|
2373
|
-
* Create the default Carbon Monoxide Concentration Measurement Cluster Server.
|
|
2374
|
-
*
|
|
2375
|
-
* @param {number} measuredValue - The measured value of the concentration.
|
|
2376
|
-
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
2377
|
-
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
2378
|
-
*/
|
|
2379
|
-
createDefaultCarbonMonoxideConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
2380
|
-
this.addClusterServer(this.getDefaultCarbonMonoxideConcentrationMeasurementClusterServer(measuredValue, measurementUnit, measurementMedium));
|
|
2381
|
-
}
|
|
2382
|
-
/**
|
|
2383
|
-
* Returns the default Carbon Dioxide Concentration Measurement Cluster Server.
|
|
2384
|
-
*
|
|
2385
|
-
* @param {number} measuredValue - The measured value of the concentration.
|
|
2386
|
-
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
2387
|
-
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
2388
|
-
* @returns {ClusterServer} - The default Carbon Monoxide Concentration Measurement Cluster Server.
|
|
2389
|
-
*/
|
|
2390
|
-
getDefaultCarbonDioxideConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
2391
|
-
return ClusterServer(CarbonDioxideConcentrationMeasurementCluster.with('NumericMeasurement'), {
|
|
2392
|
-
measuredValue,
|
|
2393
|
-
minMeasuredValue: null,
|
|
2394
|
-
maxMeasuredValue: null,
|
|
2395
|
-
uncertainty: 0,
|
|
2396
|
-
measurementUnit,
|
|
2397
|
-
measurementMedium,
|
|
2398
|
-
}, {}, {});
|
|
2399
|
-
}
|
|
2400
|
-
/**
|
|
2401
|
-
* Create the default Carbon Dioxide Concentration Measurement Cluster Server.
|
|
2402
|
-
*
|
|
2403
|
-
* @param {number} measuredValue - The measured value of the concentration.
|
|
2404
|
-
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
2405
|
-
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
2406
|
-
*/
|
|
2407
|
-
createDefaultCarbonDioxideConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
2408
|
-
this.addClusterServer(this.getDefaultCarbonDioxideConcentrationMeasurementClusterServer(measuredValue, measurementUnit, measurementMedium));
|
|
2409
|
-
}
|
|
2410
|
-
/**
|
|
2411
|
-
* Returns the default Formaldehyde Concentration Measurement Cluster Server.
|
|
2412
|
-
*
|
|
2413
|
-
* @param {number} measuredValue - The measured value of the concentration.
|
|
2414
|
-
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
2415
|
-
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
2416
|
-
* @returns {ClusterServer} - The default Carbon Monoxide Concentration Measurement Cluster Server.
|
|
2417
|
-
*/
|
|
2418
|
-
getDefaultFormaldehydeConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
2419
|
-
return ClusterServer(FormaldehydeConcentrationMeasurementCluster.with('NumericMeasurement'), {
|
|
2420
|
-
measuredValue,
|
|
2421
|
-
minMeasuredValue: null,
|
|
2422
|
-
maxMeasuredValue: null,
|
|
2423
|
-
uncertainty: 0,
|
|
2424
|
-
measurementUnit,
|
|
2425
|
-
measurementMedium,
|
|
2426
|
-
}, {}, {});
|
|
2427
|
-
}
|
|
2428
|
-
/**
|
|
2429
|
-
* Create the default Formaldehyde Concentration Measurement Cluster Server.
|
|
2430
|
-
*
|
|
2431
|
-
* @param {number} measuredValue - The measured value of the concentration.
|
|
2432
|
-
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
2433
|
-
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
2434
|
-
*/
|
|
2435
|
-
createDefaultFormaldehydeConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
2436
|
-
this.addClusterServer(this.getDefaultFormaldehydeConcentrationMeasurementClusterServer(measuredValue, measurementUnit, measurementMedium));
|
|
2437
|
-
}
|
|
2438
|
-
/**
|
|
2439
|
-
* Returns the default Pm1 Concentration Measurement Cluster Server.
|
|
2440
|
-
*
|
|
2441
|
-
* @param {number} measuredValue - The measured value of the concentration.
|
|
2442
|
-
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
2443
|
-
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
2444
|
-
* @returns {ClusterServer} - The default Carbon Monoxide Concentration Measurement Cluster Server.
|
|
2445
|
-
*/
|
|
2446
|
-
getDefaultPm1ConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
2447
|
-
return ClusterServer(Pm1ConcentrationMeasurementCluster.with('NumericMeasurement'), {
|
|
2448
|
-
measuredValue,
|
|
2449
|
-
minMeasuredValue: null,
|
|
2450
|
-
maxMeasuredValue: null,
|
|
2451
|
-
uncertainty: 0,
|
|
2452
|
-
measurementUnit,
|
|
2453
|
-
measurementMedium,
|
|
2454
|
-
}, {}, {});
|
|
2455
|
-
}
|
|
2456
|
-
/**
|
|
2457
|
-
* Create the default Pm1 Concentration Measurement Cluster Server.
|
|
2458
|
-
*
|
|
2459
|
-
* @param {number} measuredValue - The measured value of the concentration.
|
|
2460
|
-
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
2461
|
-
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
2462
|
-
*/
|
|
2463
|
-
createDefaultPm1ConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
2464
|
-
this.addClusterServer(this.getDefaultPm1ConcentrationMeasurementClusterServer(measuredValue, measurementUnit, measurementMedium));
|
|
2465
|
-
}
|
|
2466
|
-
/**
|
|
2467
|
-
* Returns the default Pm25 Concentration Measurement Cluster Server.
|
|
2468
|
-
*
|
|
2469
|
-
* @param {number} measuredValue - The measured value of the concentration.
|
|
2470
|
-
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
2471
|
-
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
2472
|
-
* @returns {ClusterServer} - The default Carbon Monoxide Concentration Measurement Cluster Server.
|
|
2473
|
-
*/
|
|
2474
|
-
getDefaultPm25ConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
2475
|
-
return ClusterServer(Pm25ConcentrationMeasurementCluster.with('NumericMeasurement'), {
|
|
2476
|
-
measuredValue,
|
|
2477
|
-
minMeasuredValue: null,
|
|
2478
|
-
maxMeasuredValue: null,
|
|
2479
|
-
uncertainty: 0,
|
|
2480
|
-
measurementUnit,
|
|
2481
|
-
measurementMedium,
|
|
2482
|
-
}, {}, {});
|
|
2483
|
-
}
|
|
2484
|
-
/**
|
|
2485
|
-
* Create the default Pm25 Concentration Measurement Cluster Server.
|
|
2486
|
-
*
|
|
2487
|
-
* @param {number} measuredValue - The measured value of the concentration.
|
|
2488
|
-
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
2489
|
-
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
2490
|
-
*/
|
|
2491
|
-
createDefaultPm25ConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
2492
|
-
this.addClusterServer(this.getDefaultPm25ConcentrationMeasurementClusterServer(measuredValue, measurementUnit, measurementMedium));
|
|
2493
|
-
}
|
|
2494
|
-
/**
|
|
2495
|
-
* Returns the default Pm10 Concentration Measurement Cluster Server.
|
|
2496
|
-
*
|
|
2497
|
-
* @param {number} measuredValue - The measured value of the concentration.
|
|
2498
|
-
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
2499
|
-
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
2500
|
-
* @returns {ClusterServer} - The default Carbon Monoxide Concentration Measurement Cluster Server.
|
|
2501
|
-
*/
|
|
2502
|
-
getDefaultPm10ConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
2503
|
-
return ClusterServer(Pm10ConcentrationMeasurementCluster.with('NumericMeasurement'), {
|
|
2504
|
-
measuredValue,
|
|
2505
|
-
minMeasuredValue: null,
|
|
2506
|
-
maxMeasuredValue: null,
|
|
2507
|
-
uncertainty: 0,
|
|
2508
|
-
measurementUnit,
|
|
2509
|
-
measurementMedium,
|
|
2510
|
-
}, {}, {});
|
|
2511
|
-
}
|
|
2512
|
-
/**
|
|
2513
|
-
* Create the default Pm10 Concentration Measurement Cluster Server.
|
|
2514
|
-
*
|
|
2515
|
-
* @param {number} measuredValue - The measured value of the concentration.
|
|
2516
|
-
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
2517
|
-
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
2518
|
-
*/
|
|
2519
|
-
createDefaultPm10ConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
2520
|
-
this.addClusterServer(this.getDefaultPm10ConcentrationMeasurementClusterServer(measuredValue, measurementUnit, measurementMedium));
|
|
2521
|
-
}
|
|
2522
|
-
/**
|
|
2523
|
-
* Returns the default Ozone Concentration Measurement Cluster Server.
|
|
2524
|
-
*
|
|
2525
|
-
* @param {number} measuredValue - The measured value of the concentration.
|
|
2526
|
-
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
2527
|
-
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
2528
|
-
* @returns {ClusterServer} - The default Carbon Monoxide Concentration Measurement Cluster Server.
|
|
2529
|
-
*/
|
|
2530
|
-
getDefaultOzoneConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ugm3, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
2531
|
-
return ClusterServer(OzoneConcentrationMeasurementCluster.with('NumericMeasurement'), {
|
|
2532
|
-
measuredValue,
|
|
2533
|
-
minMeasuredValue: null,
|
|
2534
|
-
maxMeasuredValue: null,
|
|
2535
|
-
uncertainty: 0,
|
|
2536
|
-
measurementUnit,
|
|
2537
|
-
measurementMedium,
|
|
2538
|
-
}, {}, {});
|
|
2539
|
-
}
|
|
2540
|
-
/**
|
|
2541
|
-
* Create the default Ozone Concentration Measurement Cluster Server.
|
|
2542
|
-
*
|
|
2543
|
-
* @param {number} measuredValue - The measured value of the concentration.
|
|
2544
|
-
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
2545
|
-
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
2546
|
-
*/
|
|
2547
|
-
createDefaultOzoneConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ugm3, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
2548
|
-
this.addClusterServer(this.getDefaultOzoneConcentrationMeasurementClusterServer(measuredValue, measurementUnit, measurementMedium));
|
|
2549
|
-
}
|
|
2550
|
-
/**
|
|
2551
|
-
* Returns the default Radon Concentration Measurement Cluster Server.
|
|
2552
|
-
*
|
|
2553
|
-
* @param {number} measuredValue - The measured value of the concentration.
|
|
2554
|
-
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
2555
|
-
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
2556
|
-
* @returns {ClusterServer} - The default Carbon Monoxide Concentration Measurement Cluster Server.
|
|
2557
|
-
*/
|
|
2558
|
-
getDefaultRadonConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
2559
|
-
return ClusterServer(RadonConcentrationMeasurementCluster.with('NumericMeasurement'), {
|
|
2560
|
-
measuredValue,
|
|
2561
|
-
minMeasuredValue: null,
|
|
2562
|
-
maxMeasuredValue: null,
|
|
2563
|
-
uncertainty: 0,
|
|
2564
|
-
measurementUnit,
|
|
2565
|
-
measurementMedium,
|
|
2566
|
-
}, {}, {});
|
|
2567
|
-
}
|
|
2568
|
-
/**
|
|
2569
|
-
* Create the default Radon Concentration Measurement Cluster Server.
|
|
2570
|
-
*
|
|
2571
|
-
* @param {number} measuredValue - The measured value of the concentration.
|
|
2572
|
-
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
2573
|
-
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
2574
|
-
*/
|
|
2575
|
-
createDefaultRadonConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
2576
|
-
this.addClusterServer(this.getDefaultRadonConcentrationMeasurementClusterServer(measuredValue, measurementUnit, measurementMedium));
|
|
2577
|
-
}
|
|
2578
|
-
/**
|
|
2579
|
-
* Returns the default Nitrogen Dioxide Concentration Measurement Cluster Server.
|
|
2580
|
-
*
|
|
2581
|
-
* @param {number} measuredValue - The measured value of the concentration.
|
|
2582
|
-
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
2583
|
-
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
2584
|
-
* @returns {ClusterServer} - The default Carbon Monoxide Concentration Measurement Cluster Server.
|
|
2585
|
-
*/
|
|
2586
|
-
getDefaultNitrogenDioxideConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ugm3, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
2587
|
-
return ClusterServer(NitrogenDioxideConcentrationMeasurementCluster.with('NumericMeasurement'), {
|
|
2588
|
-
measuredValue,
|
|
2589
|
-
minMeasuredValue: null,
|
|
2590
|
-
maxMeasuredValue: null,
|
|
2591
|
-
uncertainty: 0,
|
|
2592
|
-
measurementUnit,
|
|
2593
|
-
measurementMedium,
|
|
2594
|
-
}, {}, {});
|
|
2595
|
-
}
|
|
2596
|
-
/**
|
|
2597
|
-
* Create the default Nitrogen Dioxide Concentration Measurement Cluster Server.
|
|
2598
|
-
*
|
|
2599
|
-
* @param {number} measuredValue - The measured value of the concentration.
|
|
2600
|
-
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
2601
|
-
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
2602
|
-
*/
|
|
2603
|
-
createDefaultNitrogenDioxideConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ugm3, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
2604
|
-
this.addClusterServer(this.getDefaultNitrogenDioxideConcentrationMeasurementClusterServer(measuredValue, measurementUnit, measurementMedium));
|
|
2605
|
-
}
|
|
2606
|
-
/**
|
|
2607
|
-
* Returns the default fan control cluster server rev 2.
|
|
2608
|
-
*
|
|
2609
|
-
* @param fanMode The fan mode to set. Defaults to `FanControl.FanMode.Off`.
|
|
2610
|
-
* @returns The default fan control cluster server.
|
|
2611
|
-
*/
|
|
2612
|
-
getDefaultFanControlClusterServer(fanMode = FanControl.FanMode.Off) {
|
|
2613
|
-
return ClusterServer(FanControlCluster.with(FanControl.Feature.MultiSpeed, FanControl.Feature.Auto, FanControl.Feature.Step), {
|
|
2614
|
-
fanMode,
|
|
2615
|
-
fanModeSequence: FanControl.FanModeSequence.OffLowMedHighAuto,
|
|
2616
|
-
percentSetting: 0,
|
|
2617
|
-
percentCurrent: 0,
|
|
2618
|
-
speedMax: 100,
|
|
2619
|
-
speedSetting: 0,
|
|
2620
|
-
speedCurrent: 0,
|
|
2621
|
-
}, {
|
|
2622
|
-
step: async (data) => {
|
|
2623
|
-
this.log.debug('Matter command: step', data.request);
|
|
2624
|
-
await this.commandHandler.executeHandler('step', data);
|
|
2625
|
-
},
|
|
2626
|
-
}, {});
|
|
2627
|
-
}
|
|
2628
|
-
/**
|
|
2629
|
-
* Create the default fan control cluster server rev 2.
|
|
2630
|
-
*
|
|
2631
|
-
* @param fanMode The fan mode to set. Defaults to `FanControl.FanMode.Off`.
|
|
2632
|
-
* @returns The default fan control cluster server.
|
|
2633
|
-
*/
|
|
2634
|
-
createDefaultFanControlClusterServer(fanMode = FanControl.FanMode.Off) {
|
|
2635
|
-
this.addClusterServer(this.getDefaultFanControlClusterServer(fanMode));
|
|
2636
|
-
}
|
|
2637
|
-
/**
|
|
2638
|
-
* Returns the default Pump Configuration And Control cluster server.
|
|
2639
|
-
*
|
|
2640
|
-
* @param {PumpConfigurationAndControl.OperationMode} [pumpMode=PumpConfigurationAndControl.OperationMode.Normal] - The pump mode to set. Defaults to `PumpConfigurationAndControl.OperationMode.Normal`.
|
|
2641
|
-
* @returns {ClusterServer} - The default Pump Configuration And Control cluster server.
|
|
2642
|
-
*/
|
|
2643
|
-
getDefaultPumpConfigurationAndControlClusterServer(pumpMode = PumpConfigurationAndControl.OperationMode.Normal) {
|
|
2644
|
-
return ClusterServer(PumpConfigurationAndControlCluster.with(PumpConfigurationAndControl.Feature.ConstantSpeed), {
|
|
2645
|
-
minConstSpeed: null,
|
|
2646
|
-
maxConstSpeed: null,
|
|
2647
|
-
maxPressure: null,
|
|
2648
|
-
maxSpeed: null,
|
|
2649
|
-
maxFlow: null,
|
|
2650
|
-
effectiveOperationMode: pumpMode,
|
|
2651
|
-
effectiveControlMode: PumpConfigurationAndControl.ControlMode.ConstantSpeed,
|
|
2652
|
-
capacity: null,
|
|
2653
|
-
operationMode: pumpMode,
|
|
2654
|
-
}, {}, {});
|
|
2655
|
-
}
|
|
2656
|
-
/**
|
|
2657
|
-
* Creates the default Pump Configuration And Control cluster server.
|
|
2658
|
-
*
|
|
2659
|
-
* @param {PumpConfigurationAndControl.OperationMode} [pumpMode=PumpConfigurationAndControl.OperationMode.Normal] - The pump mode to set. Defaults to `PumpConfigurationAndControl.OperationMode.Normal`.
|
|
2660
|
-
* @returns {void}
|
|
2661
|
-
*/
|
|
2662
|
-
createDefaultPumpConfigurationAndControlClusterServer(pumpMode = PumpConfigurationAndControl.OperationMode.Normal) {
|
|
2663
|
-
this.addClusterServer(this.getDefaultPumpConfigurationAndControlClusterServer(pumpMode));
|
|
2664
|
-
}
|
|
2665
|
-
getDefaultValveConfigurationAndControlClusterServer(valveState = ValveConfigurationAndControl.ValveState.Closed, valveLevel = 0) {
|
|
2666
|
-
return ClusterServer(ValveConfigurationAndControlCluster.with(ValveConfigurationAndControl.Feature.Level), {
|
|
2667
|
-
currentState: valveState,
|
|
2668
|
-
targetState: valveState,
|
|
2669
|
-
currentLevel: valveLevel,
|
|
2670
|
-
targetLevel: valveLevel,
|
|
2671
|
-
openDuration: null,
|
|
2672
|
-
defaultOpenDuration: null,
|
|
2673
|
-
remainingDuration: null,
|
|
2674
|
-
}, {
|
|
2675
|
-
open: async (data) => {
|
|
2676
|
-
this.log.debug('Matter command: open', data.request);
|
|
2677
|
-
await this.commandHandler.executeHandler('open', data);
|
|
2678
|
-
},
|
|
2679
|
-
close: async (data) => {
|
|
2680
|
-
this.log.debug('Matter command: close');
|
|
2681
|
-
await this.commandHandler.executeHandler('close', data);
|
|
2682
|
-
},
|
|
2683
|
-
}, {});
|
|
2684
|
-
}
|
|
2685
|
-
/**
|
|
2686
|
-
* Create the default Valve Configuration And Control cluster server rev 2.
|
|
2687
|
-
*
|
|
2688
|
-
* @param {ValveConfigurationAndControl.ValveState} [valveState=ValveConfigurationAndControl.ValveState.Closed] - The valve state to set. Defaults to `ValveConfigurationAndControl.ValveState.Closed`.
|
|
2689
|
-
* @param {number} [valveLevel=0] - The valve level to set. Defaults to 0.
|
|
2690
|
-
* @returns {void}
|
|
2691
|
-
*/
|
|
2692
|
-
createDefaultValveConfigurationAndControlClusterServer(valveState = ValveConfigurationAndControl.ValveState.Closed, valveLevel = 0) {
|
|
2693
|
-
this.addClusterServer(this.getDefaultValveConfigurationAndControlClusterServer(valveState, valveLevel));
|
|
2694
|
-
}
|
|
2695
|
-
// NOTE Support of Device Energy Management Cluster is provisional.
|
|
2696
|
-
getDefaultDeviceEnergyManagementClusterServer() {
|
|
2697
|
-
return ClusterServer(DeviceEnergyManagementCluster.with(DeviceEnergyManagement.Feature.Pausable, DeviceEnergyManagement.Feature.PowerForecastReporting, DeviceEnergyManagement.Feature.StateForecastReporting), {
|
|
2698
|
-
esaType: DeviceEnergyManagement.EsaType.Other,
|
|
2699
|
-
esaCanGenerate: false,
|
|
2700
|
-
esaState: DeviceEnergyManagement.EsaState.Online,
|
|
2701
|
-
absMinPower: 0,
|
|
2702
|
-
absMaxPower: 0,
|
|
2703
|
-
optOutState: DeviceEnergyManagement.OptOutState.NoOptOut,
|
|
2704
|
-
forecast: null,
|
|
2705
|
-
}, {
|
|
2706
|
-
pauseRequest: async ({ request, attributes }) => {
|
|
2707
|
-
this.log.debug('Matter command: pauseRequest', request);
|
|
2708
|
-
await this.commandHandler.executeHandler('pauseRequest', { request, attributes });
|
|
2709
|
-
},
|
|
2710
|
-
resumeRequest: async () => {
|
|
2711
|
-
this.log.debug('Matter command: resumeRequest');
|
|
2712
|
-
await this.commandHandler.executeHandler('resumeRequest');
|
|
2713
|
-
},
|
|
2714
|
-
}, {
|
|
2715
|
-
paused: true,
|
|
2716
|
-
resumed: true,
|
|
2717
|
-
});
|
|
2718
|
-
}
|
|
2719
|
-
// NOTE Support of Device Energy Management Mode Cluster is provisional.
|
|
2720
|
-
getDefaultDeviceEnergyManagementModeClusterServer() {
|
|
2721
|
-
return ClusterServer(DeviceEnergyManagementModeCluster, {
|
|
2722
|
-
supportedModes: [
|
|
2723
|
-
{ label: 'Normal', mode: 1, modeTags: [{ value: 1 }] },
|
|
2724
|
-
{ label: 'Eco', mode: 2, modeTags: [{ value: 2 }] },
|
|
2725
|
-
],
|
|
2726
|
-
currentMode: 1,
|
|
2727
|
-
startUpMode: 1,
|
|
2728
|
-
}, {
|
|
2729
|
-
changeToMode: async ({ request, attributes }) => {
|
|
2730
|
-
this.log.debug('Matter command: DeviceEnergyManagementMode.changeToMode', request);
|
|
2731
|
-
await this.commandHandler.executeHandler('changeToMode', { request, attributes });
|
|
2732
|
-
},
|
|
2733
|
-
}, {});
|
|
2734
|
-
}
|
|
2735
|
-
}
|
|
2736
|
-
//# sourceMappingURL=matterbridgeDevice.js.map
|