matterbridge 1.3.7 → 1.3.8
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 +9 -0
- package/dist/matterbridge.d.ts +0 -5
- package/dist/matterbridge.d.ts.map +1 -1
- package/dist/matterbridge.js +1 -23
- package/dist/matterbridge.js.map +1 -1
- package/dist/matterbridgeDeviceV8.d.ts +2941 -2
- package/dist/matterbridgeDeviceV8.d.ts.map +1 -1
- package/dist/matterbridgeDeviceV8.js +1806 -41
- package/dist/matterbridgeDeviceV8.js.map +1 -1
- package/dist/matterbridgeV8.d.ts +2 -1
- package/dist/matterbridgeV8.d.ts.map +1 -1
- package/dist/matterbridgeV8.js +84 -22
- package/dist/matterbridgeV8.js.map +1 -1
- package/package.json +1 -1
|
@@ -8,18 +8,45 @@ import { GroupsServer } from '@project-chip/matter.js/behavior/definitions/group
|
|
|
8
8
|
import { ScenesServer } from '@project-chip/matter.js/behavior/definitions/scenes';
|
|
9
9
|
import { OnOffServer } from '@project-chip/matter.js/behavior/definitions/on-off';
|
|
10
10
|
import { TemperatureMeasurementServer } from '@project-chip/matter.js/behavior/definitions/temperature-measurement';
|
|
11
|
+
import { RelativeHumidityMeasurementServer } from '@project-chip/matter.js/behavior/definitions/relative-humidity-measurement';
|
|
11
12
|
import { BridgedDeviceBasicInformationServer } from '@project-chip/matter.js/behavior/definitions/bridged-device-basic-information';
|
|
12
|
-
import { BridgedDeviceBasicInformation, Groups, Identify, OnOff, Scenes, TemperatureMeasurement, getClusterNameById } from '@project-chip/matter-node.js/cluster';
|
|
13
|
+
import { BasicInformationCluster, BooleanState, BooleanStateCluster, BridgedDeviceBasicInformation, BridgedDeviceBasicInformationCluster, ClusterServer, ColorControl, ColorControlCluster, DoorLock, DoorLockCluster, ElectricalMeasurement, ElectricalMeasurementCluster, FanControl, FanControlCluster, FlowMeasurement, FlowMeasurementCluster, Groups, Identify, IdentifyCluster, IlluminanceMeasurement, IlluminanceMeasurementCluster, LevelControl, LevelControlCluster, OccupancySensing, OccupancySensingCluster, OnOff, OnOffCluster, PowerSource, PowerSourceCluster, PowerSourceConfigurationCluster, PressureMeasurement, PressureMeasurementCluster, RelativeHumidityMeasurement, RelativeHumidityMeasurementCluster, Scenes, Switch, SwitchCluster, TemperatureMeasurement, TemperatureMeasurementCluster, Thermostat, ThermostatCluster, ThreadNetworkDiagnostics, ThreadNetworkDiagnosticsCluster, TimeSync, TimeSyncCluster, WindowCovering, WindowCoveringCluster, createDefaultGroupsClusterServer, createDefaultScenesClusterServer, getClusterNameById, } from '@project-chip/matter-node.js/cluster';
|
|
14
|
+
import { EndpointNumber, VendorId } from '@project-chip/matter-node.js/datatype';
|
|
13
15
|
// Matterbridge imports
|
|
14
16
|
import { AnsiLogger, db, hk, zb } from 'node-ansi-logger';
|
|
17
|
+
import { BooleanStateConfiguration, BooleanStateConfigurationCluster } from './cluster/BooleanStateConfigurationCluster.js';
|
|
18
|
+
import { PowerTopology, PowerTopologyCluster } from './cluster/PowerTopologyCluster.js';
|
|
19
|
+
import { ElectricalPowerMeasurement, ElectricalPowerMeasurementCluster } from './cluster/ElectricalPowerMeasurementCluster.js';
|
|
20
|
+
import { ElectricalEnergyMeasurement, ElectricalEnergyMeasurementCluster } from './cluster/ElectricalEnergyMeasurementCluster.js';
|
|
21
|
+
import { SmokeCoAlarm, SmokeCoAlarmCluster } from './cluster/SmokeCoAlarmCluster.js';
|
|
22
|
+
import { AirQuality, AirQualityCluster } from './cluster/AirQualityCluster.js';
|
|
23
|
+
import { CarbonMonoxideConcentrationMeasurement, CarbonMonoxideConcentrationMeasurementCluster } from './cluster/CarbonMonoxideConcentrationMeasurementCluster.js';
|
|
24
|
+
import { CarbonDioxideConcentrationMeasurement, CarbonDioxideConcentrationMeasurementCluster } from './cluster/CarbonDioxideConcentrationMeasurementCluster.js';
|
|
25
|
+
import { NitrogenDioxideConcentrationMeasurement, NitrogenDioxideConcentrationMeasurementCluster } from './cluster/NitrogenDioxideConcentrationMeasurementCluster.js';
|
|
26
|
+
import { OzoneConcentrationMeasurement, OzoneConcentrationMeasurementCluster } from './cluster/OzoneConcentrationMeasurementCluster.js';
|
|
27
|
+
import { FormaldehydeConcentrationMeasurement, FormaldehydeConcentrationMeasurementCluster } from './cluster/FormaldehydeConcentrationMeasurementCluster.js';
|
|
28
|
+
import { Pm1ConcentrationMeasurement, Pm1ConcentrationMeasurementCluster } from './cluster/Pm1ConcentrationMeasurementCluster.js';
|
|
29
|
+
import { Pm25ConcentrationMeasurement, Pm25ConcentrationMeasurementCluster } from './cluster/Pm25ConcentrationMeasurementCluster.js';
|
|
30
|
+
import { Pm10ConcentrationMeasurement, Pm10ConcentrationMeasurementCluster } from './cluster/Pm10ConcentrationMeasurementCluster.js';
|
|
31
|
+
import { RadonConcentrationMeasurement, RadonConcentrationMeasurementCluster } from './cluster/RadonConcentrationMeasurementCluster.js';
|
|
32
|
+
import { TvocMeasurement, TvocMeasurementCluster } from './cluster/TvocCluster.js';
|
|
33
|
+
import { DeviceEnergyManagement, DeviceEnergyManagementCluster } from './cluster/DeviceEnergyManagementCluster.js';
|
|
34
|
+
import { DeviceEnergyManagementMode, DeviceEnergyManagementModeCluster } from './cluster/DeviceEnergyManagementModeCluster.js';
|
|
35
|
+
import { EveHistory, EveHistoryCluster } from 'matter-history';
|
|
36
|
+
import { createHash } from 'crypto';
|
|
37
|
+
import { MeasurementType } from './cluster/MeasurementType.js';
|
|
38
|
+
import { ConcentrationMeasurement } from './cluster/ConcentrationMeasurementCluster.js';
|
|
15
39
|
export class MatterbridgeDeviceV8 extends Endpoint {
|
|
16
40
|
static bridgeMode = '';
|
|
17
41
|
log;
|
|
18
42
|
serialNumber = undefined;
|
|
19
43
|
deviceName = undefined;
|
|
20
44
|
uniqueId = undefined;
|
|
21
|
-
//
|
|
22
|
-
deviceTypes =
|
|
45
|
+
// Maps matter endpoints to endpointV8
|
|
46
|
+
deviceTypes = new Map();
|
|
47
|
+
clusterServers = new Map();
|
|
48
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
49
|
+
clusterClients = new Map();
|
|
23
50
|
/**
|
|
24
51
|
* Represents a Matterbridge device.
|
|
25
52
|
* @constructor
|
|
@@ -27,9 +54,36 @@ export class MatterbridgeDeviceV8 extends Endpoint {
|
|
|
27
54
|
* @param {EndpointOptions} [options={}] - The options for the device.
|
|
28
55
|
*/
|
|
29
56
|
constructor(definition, options = {}) {
|
|
57
|
+
// Convert the DeviceTypeDefinition to a EndpointType.Options
|
|
58
|
+
const deviceTypeDefinitionV8 = {
|
|
59
|
+
name: definition.name.replace('-', '_'),
|
|
60
|
+
deviceType: definition.code,
|
|
61
|
+
deviceRevision: definition.revision,
|
|
62
|
+
deviceClass: definition.deviceClass,
|
|
63
|
+
requirements: {
|
|
64
|
+
server: {
|
|
65
|
+
mandatory: SupportedBehaviors(...MatterbridgeDeviceV8.getBehaviourTypesFromClusterServerIds(definition.requiredServerClusters)),
|
|
66
|
+
optional: SupportedBehaviors(...MatterbridgeDeviceV8.getBehaviourTypesFromClusterServerIds(definition.optionalServerClusters)),
|
|
67
|
+
},
|
|
68
|
+
client: {
|
|
69
|
+
mandatory: SupportedBehaviors(...MatterbridgeDeviceV8.getBehaviourTypesFromClusterClientIds(definition.requiredClientClusters)),
|
|
70
|
+
optional: SupportedBehaviors(...MatterbridgeDeviceV8.getBehaviourTypesFromClusterClientIds(definition.optionalClientClusters)),
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
behaviors: SupportedBehaviors(...MatterbridgeDeviceV8.getBehaviourTypesFromClusterServerIds(definition.requiredServerClusters)),
|
|
74
|
+
};
|
|
75
|
+
const endpointV8 = MutableEndpoint(deviceTypeDefinitionV8);
|
|
76
|
+
const optionsV8 = {
|
|
77
|
+
id: options.uniqueStorageKey,
|
|
78
|
+
};
|
|
79
|
+
super(endpointV8, optionsV8);
|
|
80
|
+
this.log = new AnsiLogger({ logName: 'MatterbridgeDevice', logTimestampFormat: 4 /* TimestampFormat.TIME_MILLIS */, logDebug: true });
|
|
81
|
+
this.deviceTypes.set(definition.code, definition);
|
|
82
|
+
}
|
|
83
|
+
static getBehaviourTypesFromClusterServerIds(clusterServerList) {
|
|
30
84
|
// Map ClusterId to Behavior.Type
|
|
31
85
|
const behaviorTypes = [];
|
|
32
|
-
|
|
86
|
+
clusterServerList.forEach((clusterId) => {
|
|
33
87
|
if (clusterId === Identify.Cluster.id)
|
|
34
88
|
behaviorTypes.push(IdentifyServer);
|
|
35
89
|
if (clusterId === Groups.Cluster.id)
|
|
@@ -38,44 +92,22 @@ export class MatterbridgeDeviceV8 extends Endpoint {
|
|
|
38
92
|
behaviorTypes.push(ScenesServer);
|
|
39
93
|
if (clusterId === OnOff.Cluster.id)
|
|
40
94
|
behaviorTypes.push(OnOffServer);
|
|
41
|
-
if (clusterId === BridgedDeviceBasicInformation.Cluster.id)
|
|
42
|
-
behaviorTypes.push(BridgedDeviceBasicInformationServer);
|
|
43
95
|
if (clusterId === TemperatureMeasurement.Cluster.id)
|
|
44
96
|
behaviorTypes.push(TemperatureMeasurementServer);
|
|
97
|
+
if (clusterId === RelativeHumidityMeasurement.Cluster.id)
|
|
98
|
+
behaviorTypes.push(RelativeHumidityMeasurementServer);
|
|
99
|
+
if (clusterId === BridgedDeviceBasicInformation.Cluster.id)
|
|
100
|
+
behaviorTypes.push(BridgedDeviceBasicInformationServer);
|
|
45
101
|
});
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
mandatory: {},
|
|
54
|
-
optional: {},
|
|
55
|
-
},
|
|
56
|
-
client: {
|
|
57
|
-
mandatory: {},
|
|
58
|
-
optional: {},
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
behaviors: SupportedBehaviors(...behaviorTypes),
|
|
102
|
+
return behaviorTypes;
|
|
103
|
+
}
|
|
104
|
+
static getBehaviourTypesFromClusterClientIds(clusterServerList) {
|
|
105
|
+
// Map ClusterId to Behavior.Type
|
|
106
|
+
const behaviorTypes = [];
|
|
107
|
+
clusterServerList.forEach((clusterId) => {
|
|
108
|
+
//
|
|
62
109
|
});
|
|
63
|
-
|
|
64
|
-
id: options.uniqueStorageKey,
|
|
65
|
-
bridgedDeviceBasicInformation: {
|
|
66
|
-
vendorId: 0xfff1,
|
|
67
|
-
vendorName: 'Metterbridge',
|
|
68
|
-
productName: 'Light',
|
|
69
|
-
productLabel: 'Light',
|
|
70
|
-
nodeLabel: 'Light',
|
|
71
|
-
serialNumber: '0x1234567869',
|
|
72
|
-
uniqueId: '0x1234567869',
|
|
73
|
-
reachable: true,
|
|
74
|
-
},
|
|
75
|
-
};
|
|
76
|
-
super(definitionV8, optionsV8);
|
|
77
|
-
this.log = new AnsiLogger({ logName: 'MatterbridgeDevice', logTimestampFormat: 4 /* TimestampFormat.TIME_MILLIS */, logDebug: true });
|
|
78
|
-
this.deviceTypes.push(definition);
|
|
110
|
+
return behaviorTypes;
|
|
79
111
|
}
|
|
80
112
|
/**
|
|
81
113
|
* Loads an instance of the MatterbridgeDevice class.
|
|
@@ -93,9 +125,9 @@ export class MatterbridgeDeviceV8 extends Endpoint {
|
|
|
93
125
|
* @param {DeviceTypeDefinition} deviceType - The device type to add.
|
|
94
126
|
*/
|
|
95
127
|
addDeviceType(deviceType) {
|
|
96
|
-
if (!this.deviceTypes.
|
|
128
|
+
if (!this.deviceTypes.has(deviceType.code)) {
|
|
97
129
|
this.log.debug(`addDeviceType: ${zb}${deviceType.code}${db}-${zb}${deviceType.name}${db}`);
|
|
98
|
-
this.deviceTypes.
|
|
130
|
+
this.deviceTypes.set(deviceType.code, deviceType);
|
|
99
131
|
}
|
|
100
132
|
}
|
|
101
133
|
/**
|
|
@@ -117,7 +149,1740 @@ export class MatterbridgeDeviceV8 extends Endpoint {
|
|
|
117
149
|
includeServerList.forEach((clusterId) => {
|
|
118
150
|
this.log.debug(`- with cluster: ${hk}${clusterId}${db}-${hk}${getClusterNameById(clusterId)}${db}`);
|
|
119
151
|
});
|
|
120
|
-
|
|
152
|
+
this.addClusterServerFromList(this, includeServerList);
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Adds a child endpoint with one or more device types with the required cluster servers and the specified cluster servers.
|
|
156
|
+
* If the child endpoint is not already present in the childEndpoints, it will be added.
|
|
157
|
+
* If the child endpoint is already present in the childEndpoints, the device types and cluster servers will be added to the existing child endpoint.
|
|
158
|
+
*
|
|
159
|
+
* @param {string} endpointName - The name of the new enpoint to add.
|
|
160
|
+
* @param {AtLeastOne<DeviceTypeDefinition>} deviceTypes - The device types to add.
|
|
161
|
+
* @param {ClusterId[]} includeServerList - The list of cluster IDs to include.
|
|
162
|
+
* @returns {Endpoint} - The child endpoint that was found or added.
|
|
163
|
+
*/
|
|
164
|
+
addChildDeviceTypeWithClusterServer(endpointName, deviceTypes, includeServerList) {
|
|
165
|
+
/*
|
|
166
|
+
this.log.debug(`addChildDeviceTypeWithClusterServer: ${CYAN}${endpointName}${db}`);
|
|
167
|
+
let child = this.getChildEndpoints().find((endpoint) => endpoint.uniqueStorageKey === endpointName);
|
|
168
|
+
if (!child) {
|
|
169
|
+
child = new Endpoint(deviceTypes, { uniqueStorageKey: endpointName });
|
|
170
|
+
child.addFixedLabel('endpointName', endpointName);
|
|
171
|
+
}
|
|
172
|
+
deviceTypes.forEach((deviceType) => {
|
|
173
|
+
this.log.debug(`- with deviceType: ${zb}${deviceType.code}${db}-${zb}${deviceType.name}${db}`);
|
|
174
|
+
deviceType.requiredServerClusters.forEach((clusterId) => {
|
|
175
|
+
if (!includeServerList.includes(clusterId)) includeServerList.push(clusterId);
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
includeServerList.forEach((clusterId) => {
|
|
179
|
+
this.log.debug(`- with cluster: ${hk}${clusterId}${db}-${hk}${getClusterNameById(clusterId)}${db}`);
|
|
180
|
+
});
|
|
181
|
+
this.addClusterServerFromList(child, includeServerList);
|
|
182
|
+
this.addChildEndpoint(child);
|
|
183
|
+
return child;
|
|
184
|
+
*/
|
|
185
|
+
}
|
|
186
|
+
getClusterServer(cluster) {
|
|
187
|
+
const clusterServer = this.clusterServers.get(cluster.id);
|
|
188
|
+
if (clusterServer !== undefined) {
|
|
189
|
+
return clusterServer;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
addClusterServer(cluster) {
|
|
193
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
194
|
+
const options = {};
|
|
195
|
+
for (const attribute of Object.values(cluster.attributes)) {
|
|
196
|
+
if (attribute.id < 0xfff0) {
|
|
197
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
198
|
+
options[attribute.name] = attribute.value;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
this.log.debug(`addClusterServer: ${cluster.name} with options:`, options);
|
|
202
|
+
const behaviorTypes = MatterbridgeDeviceV8.getBehaviourTypesFromClusterServerIds([cluster.id]);
|
|
203
|
+
this.behaviors.require(behaviorTypes[0], options);
|
|
204
|
+
this.clusterServers.set(cluster.id, cluster);
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Adds cluster servers to the specified endpoint based on the provided server list.
|
|
208
|
+
*
|
|
209
|
+
* @param {Endpoint} endpoint - The endpoint to add cluster servers to.
|
|
210
|
+
* @param {ClusterId[]} includeServerList - The list of cluster IDs to include.
|
|
211
|
+
* @returns void
|
|
212
|
+
*/
|
|
213
|
+
addClusterServerFromList(endpoint, includeServerList) {
|
|
214
|
+
if (includeServerList.includes(Identify.Cluster.id))
|
|
215
|
+
endpoint.addClusterServer(this.getDefaultIdentifyClusterServer());
|
|
216
|
+
if (includeServerList.includes(Groups.Cluster.id))
|
|
217
|
+
endpoint.addClusterServer(this.getDefaultGroupsClusterServer());
|
|
218
|
+
if (includeServerList.includes(Scenes.Cluster.id))
|
|
219
|
+
endpoint.addClusterServer(this.getDefaultScenesClusterServer());
|
|
220
|
+
if (includeServerList.includes(OnOff.Cluster.id))
|
|
221
|
+
endpoint.addClusterServer(this.getDefaultOnOffClusterServer());
|
|
222
|
+
if (includeServerList.includes(LevelControl.Cluster.id))
|
|
223
|
+
endpoint.addClusterServer(this.getDefaultLevelControlClusterServer());
|
|
224
|
+
if (includeServerList.includes(ColorControl.Cluster.id))
|
|
225
|
+
endpoint.addClusterServer(this.getDefaultColorControlClusterServer());
|
|
226
|
+
if (includeServerList.includes(Switch.Cluster.id))
|
|
227
|
+
endpoint.addClusterServer(this.getDefaultSwitchClusterServer());
|
|
228
|
+
if (includeServerList.includes(DoorLock.Cluster.id))
|
|
229
|
+
endpoint.addClusterServer(this.getDefaultDoorLockClusterServer());
|
|
230
|
+
if (includeServerList.includes(Thermostat.Cluster.id))
|
|
231
|
+
endpoint.addClusterServer(this.getDefaultThermostatClusterServer());
|
|
232
|
+
if (includeServerList.includes(TimeSync.Cluster.id))
|
|
233
|
+
endpoint.addClusterServer(this.getDefaultTimeSyncClusterServer());
|
|
234
|
+
if (includeServerList.includes(WindowCovering.Cluster.id))
|
|
235
|
+
endpoint.addClusterServer(this.getDefaultWindowCoveringClusterServer());
|
|
236
|
+
if (includeServerList.includes(TemperatureMeasurement.Cluster.id))
|
|
237
|
+
endpoint.addClusterServer(this.getDefaultTemperatureMeasurementClusterServer());
|
|
238
|
+
if (includeServerList.includes(RelativeHumidityMeasurement.Cluster.id))
|
|
239
|
+
endpoint.addClusterServer(this.getDefaultRelativeHumidityMeasurementClusterServer());
|
|
240
|
+
if (includeServerList.includes(PressureMeasurement.Cluster.id))
|
|
241
|
+
endpoint.addClusterServer(this.getDefaultPressureMeasurementClusterServer());
|
|
242
|
+
if (includeServerList.includes(FlowMeasurement.Cluster.id))
|
|
243
|
+
endpoint.addClusterServer(this.getDefaultFlowMeasurementClusterServer());
|
|
244
|
+
if (includeServerList.includes(BooleanState.Cluster.id))
|
|
245
|
+
endpoint.addClusterServer(this.getDefaultBooleanStateClusterServer());
|
|
246
|
+
if (includeServerList.includes(BooleanStateConfiguration.Cluster.id))
|
|
247
|
+
endpoint.addClusterServer(this.getDefaultBooleanStateConfigurationClusterServer());
|
|
248
|
+
if (includeServerList.includes(OccupancySensing.Cluster.id))
|
|
249
|
+
endpoint.addClusterServer(this.getDefaultOccupancySensingClusterServer());
|
|
250
|
+
if (includeServerList.includes(IlluminanceMeasurement.Cluster.id))
|
|
251
|
+
endpoint.addClusterServer(this.getDefaultIlluminanceMeasurementClusterServer());
|
|
252
|
+
if (includeServerList.includes(PowerSource.Cluster.id))
|
|
253
|
+
endpoint.addClusterServer(this.getDefaultPowerSourceWiredClusterServer());
|
|
254
|
+
if (includeServerList.includes(EveHistory.Cluster.id))
|
|
255
|
+
endpoint.addClusterServer(this.getDefaultStaticEveHistoryClusterServer());
|
|
256
|
+
if (includeServerList.includes(ElectricalMeasurement.Cluster.id))
|
|
257
|
+
endpoint.addClusterServer(this.getDefaultElectricalMeasurementClusterServer());
|
|
258
|
+
if (includeServerList.includes(PowerTopology.Cluster.id))
|
|
259
|
+
endpoint.addClusterServer(this.getDefaultPowerTopologyClusterServer());
|
|
260
|
+
if (includeServerList.includes(ElectricalPowerMeasurement.Cluster.id))
|
|
261
|
+
endpoint.addClusterServer(this.getDefaultElectricalPowerMeasurementClusterServer());
|
|
262
|
+
if (includeServerList.includes(ElectricalEnergyMeasurement.Cluster.id))
|
|
263
|
+
endpoint.addClusterServer(this.getDefaultElectricalEnergyMeasurementClusterServer());
|
|
264
|
+
if (includeServerList.includes(SmokeCoAlarm.Cluster.id))
|
|
265
|
+
endpoint.addClusterServer(this.getDefaultSmokeCOAlarmClusterServer());
|
|
266
|
+
if (includeServerList.includes(AirQuality.Cluster.id))
|
|
267
|
+
endpoint.addClusterServer(this.getDefaultAirQualityClusterServer());
|
|
268
|
+
if (includeServerList.includes(CarbonMonoxideConcentrationMeasurement.Cluster.id))
|
|
269
|
+
endpoint.addClusterServer(this.getDefaultCarbonMonoxideConcentrationMeasurementClusterServer());
|
|
270
|
+
if (includeServerList.includes(CarbonDioxideConcentrationMeasurement.Cluster.id))
|
|
271
|
+
endpoint.addClusterServer(this.getDefaultCarbonDioxideConcentrationMeasurementClusterServer());
|
|
272
|
+
if (includeServerList.includes(NitrogenDioxideConcentrationMeasurement.Cluster.id))
|
|
273
|
+
endpoint.addClusterServer(this.getDefaultNitrogenDioxideConcentrationMeasurementClusterServer());
|
|
274
|
+
if (includeServerList.includes(OzoneConcentrationMeasurement.Cluster.id))
|
|
275
|
+
endpoint.addClusterServer(this.getDefaultOzoneConcentrationMeasurementClusterServer());
|
|
276
|
+
if (includeServerList.includes(FormaldehydeConcentrationMeasurement.Cluster.id))
|
|
277
|
+
endpoint.addClusterServer(this.getDefaultFormaldehydeConcentrationMeasurementClusterServer());
|
|
278
|
+
if (includeServerList.includes(Pm1ConcentrationMeasurement.Cluster.id))
|
|
279
|
+
endpoint.addClusterServer(this.getDefaultPm1ConcentrationMeasurementClusterServer());
|
|
280
|
+
if (includeServerList.includes(Pm25ConcentrationMeasurement.Cluster.id))
|
|
281
|
+
endpoint.addClusterServer(this.getDefaultPm25ConcentrationMeasurementClusterServer());
|
|
282
|
+
if (includeServerList.includes(Pm10ConcentrationMeasurement.Cluster.id))
|
|
283
|
+
endpoint.addClusterServer(this.getDefaultPm10ConcentrationMeasurementClusterServer());
|
|
284
|
+
if (includeServerList.includes(RadonConcentrationMeasurement.Cluster.id))
|
|
285
|
+
endpoint.addClusterServer(this.getDefaultRadonConcentrationMeasurementClusterServer());
|
|
286
|
+
if (includeServerList.includes(TvocMeasurement.Cluster.id))
|
|
287
|
+
endpoint.addClusterServer(this.getDefaultTvocMeasurementClusterServer());
|
|
288
|
+
if (includeServerList.includes(FanControl.Cluster.id))
|
|
289
|
+
endpoint.addClusterServer(this.getDefaultFanControlClusterServer());
|
|
290
|
+
if (includeServerList.includes(DeviceEnergyManagement.Cluster.id))
|
|
291
|
+
endpoint.addClusterServer(this.getDefaultDeviceEnergyManagementClusterServer());
|
|
292
|
+
if (includeServerList.includes(DeviceEnergyManagementMode.Cluster.id))
|
|
293
|
+
endpoint.addClusterServer(this.getDefaultDeviceEnergyManagementModeClusterServer());
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Returns a default static EveHistoryClusterServer object with the specified voltage, current, power, and consumption values.
|
|
297
|
+
* This shows up in HA as a static sensor!
|
|
298
|
+
* @param voltage - The voltage value (default: 0).
|
|
299
|
+
* @param current - The current value (default: 0).
|
|
300
|
+
* @param power - The power value (default: 0).
|
|
301
|
+
* @param consumption - The consumption value (default: 0).
|
|
302
|
+
* @returns The default static EveHistoryClusterServer object.
|
|
303
|
+
*/
|
|
304
|
+
getDefaultStaticEveHistoryClusterServer(voltage = 0, current = 0, power = 0, consumption = 0) {
|
|
305
|
+
return ClusterServer(EveHistoryCluster.with(EveHistory.Feature.EveEnergy), {
|
|
306
|
+
// Dynamic attributes
|
|
307
|
+
ConfigDataGet: Uint8Array.fromHex(''),
|
|
308
|
+
ConfigDataSet: Uint8Array.fromHex(''),
|
|
309
|
+
HistoryStatus: Uint8Array.fromHex(''),
|
|
310
|
+
HistoryEntries: Uint8Array.fromHex(''),
|
|
311
|
+
HistoryRequest: Uint8Array.fromHex(''),
|
|
312
|
+
HistorySetTime: Uint8Array.fromHex(''),
|
|
313
|
+
LastEvent: 0,
|
|
314
|
+
ResetTotal: 0,
|
|
315
|
+
// Normal attributes
|
|
316
|
+
Voltage: voltage,
|
|
317
|
+
Current: current,
|
|
318
|
+
Consumption: power,
|
|
319
|
+
TotalConsumption: consumption,
|
|
320
|
+
EnergyUnknown: 1,
|
|
321
|
+
ChildLock: false,
|
|
322
|
+
RLoc: 46080,
|
|
323
|
+
}, {}, {});
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Get a default IdentifyCluster server.
|
|
327
|
+
*/
|
|
328
|
+
getDefaultIdentifyClusterServer() {
|
|
329
|
+
return ClusterServer(IdentifyCluster, {
|
|
330
|
+
identifyTime: 0,
|
|
331
|
+
identifyType: Identify.IdentifyType.None,
|
|
332
|
+
}, {
|
|
333
|
+
identify: async (data) => {
|
|
334
|
+
this.log.debug('Matter command: Identify');
|
|
335
|
+
// await this.commandHandler.executeHandler('identify', data);
|
|
336
|
+
},
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Creates a default IdentifyCluster server.
|
|
341
|
+
*/
|
|
342
|
+
createDefaultIdentifyClusterServer() {
|
|
343
|
+
this.addClusterServer(this.getDefaultIdentifyClusterServer());
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Get a default IdentifyCluster server.
|
|
347
|
+
*/
|
|
348
|
+
getDefaultGroupsClusterServer() {
|
|
349
|
+
return createDefaultGroupsClusterServer();
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Creates a default groups cluster server and adds it to the device.
|
|
353
|
+
*/
|
|
354
|
+
createDefaultGroupsClusterServer() {
|
|
355
|
+
this.addClusterServer(this.getDefaultGroupsClusterServer());
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Get a default scenes cluster server and adds it to the current instance.
|
|
359
|
+
*/
|
|
360
|
+
getDefaultScenesClusterServer() {
|
|
361
|
+
return createDefaultScenesClusterServer();
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Creates a default scenes cluster server and adds it to the current instance.
|
|
365
|
+
*/
|
|
366
|
+
createDefaultScenesClusterServer() {
|
|
367
|
+
this.addClusterServer(this.getDefaultScenesClusterServer());
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Creates a unique identifier based on the provided parameters.
|
|
371
|
+
* @param param1 - The first parameter.
|
|
372
|
+
* @param param2 - The second parameter.
|
|
373
|
+
* @param param3 - The third parameter.
|
|
374
|
+
* @param param4 - The fourth parameter.
|
|
375
|
+
* @returns A unique identifier generated using the MD5 hash algorithm.
|
|
376
|
+
*/
|
|
377
|
+
createUniqueId(param1, param2, param3, param4) {
|
|
378
|
+
const hash = createHash('md5');
|
|
379
|
+
hash.update(param1 + param2 + param3 + param4);
|
|
380
|
+
return hash.digest('hex');
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Get a default Basic Information Cluster Server.
|
|
384
|
+
*
|
|
385
|
+
* @param deviceName - The name of the device.
|
|
386
|
+
* @param serialNumber - The serial number of the device.
|
|
387
|
+
* @param vendorId - The vendor ID of the device.
|
|
388
|
+
* @param vendorName - The vendor name of the device.
|
|
389
|
+
* @param productId - The product ID of the device.
|
|
390
|
+
* @param productName - The product name of the device.
|
|
391
|
+
* @param softwareVersion - The software version of the device. Default is 1.
|
|
392
|
+
* @param softwareVersionString - The software version string of the device. Default is 'v.1.0.0'.
|
|
393
|
+
* @param hardwareVersion - The hardware version of the device. Default is 1.
|
|
394
|
+
* @param hardwareVersionString - The hardware version string of the device. Default is 'v.1.0.0'.
|
|
395
|
+
*/
|
|
396
|
+
getDefaultBasicInformationClusterServer(deviceName, serialNumber, vendorId, vendorName, productId, productName, softwareVersion = 1, softwareVersionString = '1.0.0', hardwareVersion = 1, hardwareVersionString = '1.0.0') {
|
|
397
|
+
return ClusterServer(BasicInformationCluster, {
|
|
398
|
+
dataModelRevision: 1,
|
|
399
|
+
location: 'XX',
|
|
400
|
+
vendorId: VendorId(vendorId),
|
|
401
|
+
vendorName: vendorName.slice(0, 32),
|
|
402
|
+
productId: productId,
|
|
403
|
+
productName: productName.slice(0, 32),
|
|
404
|
+
productLabel: deviceName.slice(0, 64),
|
|
405
|
+
nodeLabel: deviceName.slice(0, 32),
|
|
406
|
+
serialNumber: serialNumber.slice(0, 32),
|
|
407
|
+
uniqueId: this.createUniqueId(deviceName, serialNumber, vendorName, productName),
|
|
408
|
+
softwareVersion,
|
|
409
|
+
softwareVersionString: softwareVersionString.slice(0, 64),
|
|
410
|
+
hardwareVersion,
|
|
411
|
+
hardwareVersionString: hardwareVersionString.slice(0, 64),
|
|
412
|
+
reachable: true,
|
|
413
|
+
capabilityMinima: { caseSessionsPerFabric: 3, subscriptionsPerFabric: 3 },
|
|
414
|
+
}, {}, {
|
|
415
|
+
startUp: true,
|
|
416
|
+
shutDown: true,
|
|
417
|
+
leave: true,
|
|
418
|
+
reachableChanged: true,
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* Creates a default Basic Information Cluster Server.
|
|
423
|
+
*
|
|
424
|
+
* @param deviceName - The name of the device.
|
|
425
|
+
* @param serialNumber - The serial number of the device.
|
|
426
|
+
* @param vendorId - The vendor ID of the device.
|
|
427
|
+
* @param vendorName - The vendor name of the device.
|
|
428
|
+
* @param productId - The product ID of the device.
|
|
429
|
+
* @param productName - The product name of the device.
|
|
430
|
+
* @param softwareVersion - The software version of the device. Default is 1.
|
|
431
|
+
* @param softwareVersionString - The software version string of the device. Default is 'v.1.0.0'.
|
|
432
|
+
* @param hardwareVersion - The hardware version of the device. Default is 1.
|
|
433
|
+
* @param hardwareVersionString - The hardware version string of the device. Default is 'v.1.0.0'.
|
|
434
|
+
*/
|
|
435
|
+
createDefaultBasicInformationClusterServer(deviceName, serialNumber, vendorId, vendorName, productId, productName, softwareVersion = 1, softwareVersionString = '1.0.0', hardwareVersion = 1, hardwareVersionString = '1.0.0') {
|
|
436
|
+
this.deviceName = deviceName;
|
|
437
|
+
this.serialNumber = serialNumber;
|
|
438
|
+
this.uniqueId = this.createUniqueId(deviceName, serialNumber, vendorName, productName);
|
|
439
|
+
if (MatterbridgeDeviceV8.bridgeMode === 'bridge') {
|
|
440
|
+
this.createDefaultBridgedDeviceBasicInformationClusterServer(deviceName, serialNumber, vendorId, vendorName, productName, softwareVersion, softwareVersionString, hardwareVersion, hardwareVersionString);
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
this.addClusterServer(this.getDefaultBasicInformationClusterServer(deviceName, serialNumber, vendorId, vendorName, productId, productName, softwareVersion, softwareVersionString, hardwareVersion, hardwareVersionString));
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* Get a default BridgedDeviceBasicInformationClusterServer.
|
|
447
|
+
*
|
|
448
|
+
* @param deviceName - The name of the device.
|
|
449
|
+
* @param serialNumber - The serial number of the device.
|
|
450
|
+
* @param vendorId - The vendor ID of the device.
|
|
451
|
+
* @param vendorName - The name of the vendor.
|
|
452
|
+
* @param productName - The name of the product.
|
|
453
|
+
* @param softwareVersion - The software version of the device. Default is 1.
|
|
454
|
+
* @param softwareVersionString - The software version string of the device. Default is 'v.1.0.0'.
|
|
455
|
+
* @param hardwareVersion - The hardware version of the device. Default is 1.
|
|
456
|
+
* @param hardwareVersionString - The hardware version string of the device. Default is 'v.1.0.0'.
|
|
457
|
+
*/
|
|
458
|
+
getDefaultBridgedDeviceBasicInformationClusterServer(deviceName, serialNumber, vendorId, vendorName, productName, softwareVersion = 1, softwareVersionString = '1.0.0', hardwareVersion = 1, hardwareVersionString = '1.0.0') {
|
|
459
|
+
return ClusterServer(BridgedDeviceBasicInformationCluster, {
|
|
460
|
+
vendorId: vendorId !== undefined ? VendorId(vendorId) : undefined, // 4874
|
|
461
|
+
vendorName: vendorName.slice(0, 32),
|
|
462
|
+
// productId: 0x8000,
|
|
463
|
+
productName: productName.slice(0, 32),
|
|
464
|
+
productLabel: deviceName.slice(0, 64),
|
|
465
|
+
nodeLabel: deviceName.slice(0, 32),
|
|
466
|
+
serialNumber: serialNumber.slice(0, 32),
|
|
467
|
+
uniqueId: this.createUniqueId(deviceName, serialNumber, vendorName, productName),
|
|
468
|
+
softwareVersion,
|
|
469
|
+
softwareVersionString: softwareVersionString.slice(0, 64),
|
|
470
|
+
hardwareVersion,
|
|
471
|
+
hardwareVersionString: hardwareVersionString.slice(0, 64),
|
|
472
|
+
reachable: true,
|
|
473
|
+
}, {}, {
|
|
474
|
+
reachableChanged: true,
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* Creates a default BridgedDeviceBasicInformationClusterServer.
|
|
479
|
+
*
|
|
480
|
+
* @param deviceName - The name of the device.
|
|
481
|
+
* @param serialNumber - The serial number of the device.
|
|
482
|
+
* @param vendorId - The vendor ID of the device.
|
|
483
|
+
* @param vendorName - The name of the vendor.
|
|
484
|
+
* @param productName - The name of the product.
|
|
485
|
+
* @param softwareVersion - The software version of the device. Default is 1.
|
|
486
|
+
* @param softwareVersionString - The software version string of the device. Default is 'v.1.0.0'.
|
|
487
|
+
* @param hardwareVersion - The hardware version of the device. Default is 1.
|
|
488
|
+
* @param hardwareVersionString - The hardware version string of the device. Default is 'v.1.0.0'.
|
|
489
|
+
*/
|
|
490
|
+
createDefaultBridgedDeviceBasicInformationClusterServer(deviceName, serialNumber, vendorId, vendorName, productName, softwareVersion = 1, softwareVersionString = '1.0.0', hardwareVersion = 1, hardwareVersionString = '1.0.0') {
|
|
491
|
+
this.deviceName = deviceName;
|
|
492
|
+
this.serialNumber = serialNumber;
|
|
493
|
+
this.uniqueId = this.createUniqueId(deviceName, serialNumber, vendorName, productName);
|
|
494
|
+
this.addClusterServer(this.getDefaultBridgedDeviceBasicInformationClusterServer(deviceName, serialNumber, vendorId, vendorName, productName, softwareVersion, softwareVersionString, hardwareVersion, hardwareVersionString));
|
|
495
|
+
}
|
|
496
|
+
/**
|
|
497
|
+
* Get a default Electrical Energy Measurement Cluster Server.
|
|
498
|
+
*
|
|
499
|
+
* @param energy - The total consumption value.
|
|
500
|
+
*/
|
|
501
|
+
getDefaultPowerTopologyClusterServer() {
|
|
502
|
+
return ClusterServer(PowerTopologyCluster.with(PowerTopology.Feature.TreeTopology), {}, {}, {});
|
|
503
|
+
}
|
|
504
|
+
/**
|
|
505
|
+
* Get a default Electrical Energy Measurement Cluster Server.
|
|
506
|
+
*
|
|
507
|
+
* @param energy - The total consumption value.
|
|
508
|
+
*/
|
|
509
|
+
getDefaultElectricalEnergyMeasurementClusterServer(energy = 0) {
|
|
510
|
+
return ClusterServer(ElectricalEnergyMeasurementCluster.with(ElectricalEnergyMeasurement.Feature.ImportedEnergy, ElectricalEnergyMeasurement.Feature.ExportedEnergy, ElectricalEnergyMeasurement.Feature.CumulativeEnergy), {
|
|
511
|
+
accuracy: {
|
|
512
|
+
measurementType: MeasurementType.ElectricalEnergy,
|
|
513
|
+
measured: true,
|
|
514
|
+
minMeasuredValue: 0,
|
|
515
|
+
maxMeasuredValue: 0,
|
|
516
|
+
accuracyRanges: [{ rangeMin: 0, rangeMax: 2 ** 62, fixedMin: 10, fixedMax: 10, fixedTypical: 0 }],
|
|
517
|
+
},
|
|
518
|
+
cumulativeEnergyImported: { energy },
|
|
519
|
+
cumulativeEnergyExported: null,
|
|
520
|
+
}, {}, {
|
|
521
|
+
cumulativeEnergyMeasured: true,
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* Get a default Electrical Power Measurement Cluster Server.
|
|
526
|
+
*
|
|
527
|
+
* @param energy - The total consumption value.
|
|
528
|
+
*/
|
|
529
|
+
getDefaultElectricalPowerMeasurementClusterServer(voltage = 0, current = 0, power = 0) {
|
|
530
|
+
return ClusterServer(ElectricalPowerMeasurementCluster.with(ElectricalPowerMeasurement.Feature.AlternatingCurrent), {
|
|
531
|
+
powerMode: ElectricalPowerMeasurement.PowerMode.Ac,
|
|
532
|
+
numberOfMeasurementTypes: 3,
|
|
533
|
+
accuracy: [
|
|
534
|
+
{
|
|
535
|
+
measurementType: MeasurementType.Voltage,
|
|
536
|
+
measured: true,
|
|
537
|
+
minMeasuredValue: 0,
|
|
538
|
+
maxMeasuredValue: 100,
|
|
539
|
+
accuracyRanges: [{ rangeMin: 0, rangeMax: 2 ** 62, fixedMin: 10, fixedMax: 10, fixedTypical: 0 }],
|
|
540
|
+
},
|
|
541
|
+
{
|
|
542
|
+
measurementType: MeasurementType.ActiveCurrent,
|
|
543
|
+
measured: true,
|
|
544
|
+
minMeasuredValue: 0,
|
|
545
|
+
maxMeasuredValue: 100,
|
|
546
|
+
accuracyRanges: [{ rangeMin: 0, rangeMax: 2 ** 62, fixedMin: 10, fixedMax: 10, fixedTypical: 0 }],
|
|
547
|
+
},
|
|
548
|
+
{
|
|
549
|
+
measurementType: MeasurementType.ActivePower,
|
|
550
|
+
measured: true,
|
|
551
|
+
minMeasuredValue: 0,
|
|
552
|
+
maxMeasuredValue: 100,
|
|
553
|
+
accuracyRanges: [{ rangeMin: 0, rangeMax: 2 ** 62, fixedMin: 10, fixedMax: 10, fixedTypical: 0 }],
|
|
554
|
+
},
|
|
555
|
+
],
|
|
556
|
+
voltage: voltage,
|
|
557
|
+
activeCurrent: current,
|
|
558
|
+
activePower: power,
|
|
559
|
+
}, {}, {});
|
|
560
|
+
}
|
|
561
|
+
/**
|
|
562
|
+
* @deprecated This method is deprecated and will be removed in a future version.
|
|
563
|
+
* Get a default Electrical Measurement Cluster Server.
|
|
564
|
+
*
|
|
565
|
+
* @param voltage - The RMS voltage value.
|
|
566
|
+
* @param current - The RMS current value.
|
|
567
|
+
* @param power - The active power value.
|
|
568
|
+
* @param consumption - The total active power consumption value.
|
|
569
|
+
*/
|
|
570
|
+
getDefaultElectricalMeasurementClusterServer(voltage = 0, current = 0, power = 0, consumption = 0) {
|
|
571
|
+
return ClusterServer(ElectricalMeasurementCluster, {
|
|
572
|
+
rmsVoltage: voltage,
|
|
573
|
+
rmsCurrent: current,
|
|
574
|
+
activePower: power,
|
|
575
|
+
totalActivePower: consumption,
|
|
576
|
+
}, {}, {});
|
|
577
|
+
}
|
|
578
|
+
/**
|
|
579
|
+
* @deprecated This method is deprecated and will be removed in a future version.
|
|
580
|
+
* Creates a default Electrical Measurement Cluster Server.
|
|
581
|
+
*
|
|
582
|
+
* @param voltage - The RMS voltage value.
|
|
583
|
+
* @param current - The RMS current value.
|
|
584
|
+
* @param power - The active power value.
|
|
585
|
+
* @param consumption - The total active power consumption value.
|
|
586
|
+
*/
|
|
587
|
+
createDefaultElectricalMeasurementClusterServer(voltage = 0, current = 0, power = 0, consumption = 0) {
|
|
588
|
+
this.addClusterServer(this.getDefaultElectricalMeasurementClusterServer(voltage, current, power, consumption));
|
|
589
|
+
}
|
|
590
|
+
/**
|
|
591
|
+
* Creates a default Dummy Thread Network Diagnostics Cluster server.
|
|
592
|
+
*
|
|
593
|
+
* @remarks
|
|
594
|
+
* This method adds a cluster server used only to give the networkName to Eve app.
|
|
595
|
+
*
|
|
596
|
+
* @returns void
|
|
597
|
+
*/
|
|
598
|
+
createDefaultDummyThreadNetworkDiagnosticsClusterServer() {
|
|
599
|
+
this.addClusterServer(ClusterServer(ThreadNetworkDiagnosticsCluster.with(ThreadNetworkDiagnostics.Feature.PacketCounts, ThreadNetworkDiagnostics.Feature.ErrorCounts), {
|
|
600
|
+
channel: 1,
|
|
601
|
+
routingRole: ThreadNetworkDiagnostics.RoutingRole.Router,
|
|
602
|
+
networkName: 'MyMatterThread',
|
|
603
|
+
panId: 0,
|
|
604
|
+
extendedPanId: 0,
|
|
605
|
+
meshLocalPrefix: null,
|
|
606
|
+
neighborTable: [],
|
|
607
|
+
routeTable: [],
|
|
608
|
+
partitionId: null,
|
|
609
|
+
weighting: null,
|
|
610
|
+
dataVersion: null,
|
|
611
|
+
stableDataVersion: null,
|
|
612
|
+
leaderRouterId: null,
|
|
613
|
+
securityPolicy: null,
|
|
614
|
+
channelPage0Mask: null,
|
|
615
|
+
operationalDatasetComponents: null,
|
|
616
|
+
overrunCount: 0,
|
|
617
|
+
activeNetworkFaults: [],
|
|
618
|
+
}, {
|
|
619
|
+
resetCounts: async (data) => {
|
|
620
|
+
this.log.debug('Matter command: resetCounts');
|
|
621
|
+
// await this.commandHandler.executeHandler('resetCounts', data);
|
|
622
|
+
},
|
|
623
|
+
}, {}));
|
|
624
|
+
}
|
|
625
|
+
/**
|
|
626
|
+
* Get a default OnOff cluster server.
|
|
627
|
+
*
|
|
628
|
+
* @param onOff - The initial state of the OnOff cluster (default: false).
|
|
629
|
+
*/
|
|
630
|
+
getDefaultOnOffClusterServer(onOff = false) {
|
|
631
|
+
return ClusterServer(OnOffCluster, {
|
|
632
|
+
onOff,
|
|
633
|
+
}, {
|
|
634
|
+
on: async (data) => {
|
|
635
|
+
this.log.debug('Matter command: on onOff:', data.attributes.onOff.getLocal());
|
|
636
|
+
// await this.commandHandler.executeHandler('on', data);
|
|
637
|
+
},
|
|
638
|
+
off: async (data) => {
|
|
639
|
+
this.log.debug('Matter command: off onOff:', data.attributes.onOff.getLocal());
|
|
640
|
+
// await this.commandHandler.executeHandler('off', data);
|
|
641
|
+
},
|
|
642
|
+
toggle: async (data) => {
|
|
643
|
+
this.log.debug('Matter command: toggle onOff:', data.attributes.onOff.getLocal());
|
|
644
|
+
// await this.commandHandler.executeHandler('toggle', data);
|
|
645
|
+
},
|
|
646
|
+
}, {});
|
|
647
|
+
}
|
|
648
|
+
/**
|
|
649
|
+
* Creates a default OnOff cluster server.
|
|
650
|
+
*
|
|
651
|
+
* @param onOff - The initial state of the OnOff cluster (default: false).
|
|
652
|
+
*/
|
|
653
|
+
createDefaultOnOffClusterServer(onOff = false) {
|
|
654
|
+
this.addClusterServer(this.getDefaultOnOffClusterServer(onOff));
|
|
655
|
+
}
|
|
656
|
+
/**
|
|
657
|
+
* Get a default level control cluster server.
|
|
658
|
+
*
|
|
659
|
+
* @param currentLevel - The current level (default: 0).
|
|
660
|
+
*/
|
|
661
|
+
getDefaultLevelControlClusterServer(currentLevel = 0) {
|
|
662
|
+
return ClusterServer(LevelControlCluster.with(LevelControl.Feature.OnOff), {
|
|
663
|
+
currentLevel,
|
|
664
|
+
onLevel: 0,
|
|
665
|
+
options: {
|
|
666
|
+
executeIfOff: false,
|
|
667
|
+
coupleColorTempToLevel: false,
|
|
668
|
+
},
|
|
669
|
+
}, {
|
|
670
|
+
moveToLevel: async ({ request, attributes, endpoint }) => {
|
|
671
|
+
this.log.debug('Matter command: moveToLevel request:', request, 'attributes.currentLevel:', attributes.currentLevel.getLocal());
|
|
672
|
+
// await this.commandHandler.executeHandler('moveToLevel', { request, attributes, endpoint });
|
|
673
|
+
},
|
|
674
|
+
move: async () => {
|
|
675
|
+
this.log.error('Matter command: move not implemented');
|
|
676
|
+
},
|
|
677
|
+
step: async () => {
|
|
678
|
+
this.log.error('Matter command: step not implemented');
|
|
679
|
+
},
|
|
680
|
+
stop: async () => {
|
|
681
|
+
this.log.error('Matter command: stop not implemented');
|
|
682
|
+
},
|
|
683
|
+
moveToLevelWithOnOff: async ({ request, attributes, endpoint }) => {
|
|
684
|
+
this.log.debug('Matter command: moveToLevelWithOnOff request:', request, 'attributes.currentLevel:', attributes.currentLevel.getLocal());
|
|
685
|
+
// await this.commandHandler.executeHandler('moveToLevelWithOnOff', { request, attributes, endpoint });
|
|
686
|
+
},
|
|
687
|
+
moveWithOnOff: async () => {
|
|
688
|
+
this.log.error('Matter command: moveWithOnOff not implemented');
|
|
689
|
+
},
|
|
690
|
+
stepWithOnOff: async () => {
|
|
691
|
+
this.log.error('Matter command: stepWithOnOff not implemented');
|
|
692
|
+
},
|
|
693
|
+
stopWithOnOff: async () => {
|
|
694
|
+
this.log.error('Matter command: stopWithOnOff not implemented');
|
|
695
|
+
},
|
|
696
|
+
});
|
|
697
|
+
}
|
|
698
|
+
/**
|
|
699
|
+
* Creates a default level control cluster server.
|
|
700
|
+
*
|
|
701
|
+
* @param currentLevel - The current level (default: 0).
|
|
702
|
+
*/
|
|
703
|
+
createDefaultLevelControlClusterServer(currentLevel = 0) {
|
|
704
|
+
this.addClusterServer(this.getDefaultLevelControlClusterServer(currentLevel));
|
|
705
|
+
}
|
|
706
|
+
/**
|
|
707
|
+
* Get a default color control cluster server.
|
|
708
|
+
*
|
|
709
|
+
* @param currentHue - The current hue value.
|
|
710
|
+
* @param currentSaturation - The current saturation value.
|
|
711
|
+
* @param colorTemperatureMireds - The color temperature in mireds.
|
|
712
|
+
* @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds.
|
|
713
|
+
* @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds.
|
|
714
|
+
*/
|
|
715
|
+
getDefaultColorControlClusterServer(currentHue = 0, currentSaturation = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
|
|
716
|
+
return ClusterServer(ColorControlCluster.with(ColorControl.Feature.HueSaturation, ColorControl.Feature.ColorTemperature), {
|
|
717
|
+
colorMode: ColorControl.ColorMode.CurrentHueAndCurrentSaturation,
|
|
718
|
+
options: {
|
|
719
|
+
executeIfOff: false,
|
|
720
|
+
},
|
|
721
|
+
numberOfPrimaries: null,
|
|
722
|
+
enhancedColorMode: ColorControl.EnhancedColorMode.CurrentHueAndCurrentSaturation,
|
|
723
|
+
colorCapabilities: { xy: false, hueSaturation: true, colorLoop: false, enhancedHue: false, colorTemperature: true },
|
|
724
|
+
currentHue,
|
|
725
|
+
currentSaturation,
|
|
726
|
+
colorTemperatureMireds,
|
|
727
|
+
colorTempPhysicalMinMireds,
|
|
728
|
+
colorTempPhysicalMaxMireds,
|
|
729
|
+
}, {
|
|
730
|
+
moveToHue: async ({ request, attributes, endpoint }) => {
|
|
731
|
+
this.log.debug('Matter command: moveToHue request:', request, 'attributes.currentHue:', attributes.currentHue.getLocal());
|
|
732
|
+
// attributes.currentHue.setLocal(request.hue);
|
|
733
|
+
// this.commandHandler.executeHandler('moveToHue', { request, attributes, endpoint });
|
|
734
|
+
},
|
|
735
|
+
moveHue: async () => {
|
|
736
|
+
this.log.error('Matter command: moveHue not implemented');
|
|
737
|
+
},
|
|
738
|
+
stepHue: async () => {
|
|
739
|
+
this.log.error('Matter command: stepHue not implemented');
|
|
740
|
+
},
|
|
741
|
+
moveToSaturation: async ({ request, attributes, endpoint }) => {
|
|
742
|
+
this.log.debug('Matter command: moveToSaturation request:', request, 'attributes.currentSaturation:', attributes.currentSaturation.getLocal());
|
|
743
|
+
// attributes.currentSaturation.setLocal(request.saturation);
|
|
744
|
+
// this.commandHandler.executeHandler('moveToSaturation', { request, attributes, endpoint });
|
|
745
|
+
},
|
|
746
|
+
moveSaturation: async () => {
|
|
747
|
+
this.log.error('Matter command: moveSaturation not implemented');
|
|
748
|
+
},
|
|
749
|
+
stepSaturation: async () => {
|
|
750
|
+
this.log.error('Matter command: stepSaturation not implemented');
|
|
751
|
+
},
|
|
752
|
+
moveToHueAndSaturation: async ({ request, attributes, endpoint }) => {
|
|
753
|
+
this.log.debug('Matter command: moveToHueAndSaturation request:', request, 'attributes.currentHue:', attributes.currentHue.getLocal(), 'attributes.currentSaturation:', attributes.currentSaturation.getLocal());
|
|
754
|
+
// attributes.currentHue.setLocal(request.hue);
|
|
755
|
+
// attributes.currentSaturation.setLocal(request.saturation);
|
|
756
|
+
// this.commandHandler.executeHandler('moveToHueAndSaturation', { request, attributes, endpoint });
|
|
757
|
+
},
|
|
758
|
+
stopMoveStep: async () => {
|
|
759
|
+
this.log.error('Matter command: stopMoveStep not implemented');
|
|
760
|
+
},
|
|
761
|
+
moveToColorTemperature: async ({ request, attributes, endpoint }) => {
|
|
762
|
+
this.log.debug('Matter command: moveToColorTemperature request:', request, 'attributes.colorTemperatureMireds:', attributes.colorTemperatureMireds.getLocal());
|
|
763
|
+
// attributes.colorTemperatureMireds.setLocal(request.colorTemperatureMireds);
|
|
764
|
+
// this.commandHandler.executeHandler('moveToColorTemperature', { request, attributes, endpoint });
|
|
765
|
+
},
|
|
766
|
+
moveColorTemperature: async () => {
|
|
767
|
+
this.log.error('Matter command: moveColorTemperature not implemented');
|
|
768
|
+
},
|
|
769
|
+
stepColorTemperature: async () => {
|
|
770
|
+
this.log.error('Matter command: stepColorTemperature not implemented');
|
|
771
|
+
},
|
|
772
|
+
}, {});
|
|
773
|
+
}
|
|
774
|
+
/**
|
|
775
|
+
* Creates a default color control cluster server.
|
|
776
|
+
*
|
|
777
|
+
* @param currentHue - The current hue value.
|
|
778
|
+
* @param currentSaturation - The current saturation value.
|
|
779
|
+
* @param colorTemperatureMireds - The color temperature in mireds.
|
|
780
|
+
* @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds.
|
|
781
|
+
* @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds.
|
|
782
|
+
*/
|
|
783
|
+
createDefaultColorControlClusterServer(currentHue = 0, currentSaturation = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
|
|
784
|
+
this.addClusterServer(this.getDefaultColorControlClusterServer(currentHue, currentSaturation, colorTemperatureMireds, colorTempPhysicalMinMireds, colorTempPhysicalMaxMireds));
|
|
785
|
+
}
|
|
786
|
+
/**
|
|
787
|
+
* Get a default color control cluster server.
|
|
788
|
+
*
|
|
789
|
+
* @param currentHue - The current hue value.
|
|
790
|
+
* @param currentSaturation - The current saturation value.
|
|
791
|
+
* @param colorTemperatureMireds - The color temperature in mireds.
|
|
792
|
+
* @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds.
|
|
793
|
+
* @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds.
|
|
794
|
+
*/
|
|
795
|
+
getDefaultXYColorControlClusterServer(currentX = 0, currentY = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
|
|
796
|
+
return ClusterServer(ColorControlCluster.with(ColorControl.Feature.Xy, ColorControl.Feature.HueSaturation, ColorControl.Feature.ColorTemperature), {
|
|
797
|
+
colorMode: ColorControl.ColorMode.CurrentHueAndCurrentSaturation,
|
|
798
|
+
options: {
|
|
799
|
+
executeIfOff: false,
|
|
800
|
+
},
|
|
801
|
+
numberOfPrimaries: null,
|
|
802
|
+
enhancedColorMode: ColorControl.EnhancedColorMode.CurrentHueAndCurrentSaturation,
|
|
803
|
+
colorCapabilities: { xy: true, hueSaturation: true, colorLoop: false, enhancedHue: false, colorTemperature: true },
|
|
804
|
+
currentHue: 0,
|
|
805
|
+
currentSaturation: 0,
|
|
806
|
+
currentX,
|
|
807
|
+
currentY,
|
|
808
|
+
colorTemperatureMireds,
|
|
809
|
+
colorTempPhysicalMinMireds,
|
|
810
|
+
colorTempPhysicalMaxMireds,
|
|
811
|
+
}, {
|
|
812
|
+
moveToColor: async (data) => {
|
|
813
|
+
this.log.debug('Matter command: moveToColor request:', data.request, 'attributes.currentHue:', data.attributes.currentX.getLocal(), data.attributes.currentY.getLocal());
|
|
814
|
+
// this.commandHandler.executeHandler('moveToColor', data);
|
|
815
|
+
},
|
|
816
|
+
moveColor: async () => {
|
|
817
|
+
this.log.error('Matter command: moveColor not implemented');
|
|
818
|
+
},
|
|
819
|
+
stepColor: async () => {
|
|
820
|
+
this.log.error('Matter command: stepColor not implemented');
|
|
821
|
+
},
|
|
822
|
+
moveToHue: async ({ request, attributes, endpoint }) => {
|
|
823
|
+
this.log.debug('Matter command: moveToHue request:', request, 'attributes.currentHue:', attributes.currentHue.getLocal());
|
|
824
|
+
// this.commandHandler.executeHandler('moveToHue', { request, attributes, endpoint });
|
|
825
|
+
},
|
|
826
|
+
moveHue: async () => {
|
|
827
|
+
this.log.error('Matter command: moveHue not implemented');
|
|
828
|
+
},
|
|
829
|
+
stepHue: async () => {
|
|
830
|
+
this.log.error('Matter command: stepHue not implemented');
|
|
831
|
+
},
|
|
832
|
+
moveToSaturation: async ({ request, attributes, endpoint }) => {
|
|
833
|
+
this.log.debug('Matter command: moveToSaturation request:', request, 'attributes.currentSaturation:', attributes.currentSaturation.getLocal());
|
|
834
|
+
// this.commandHandler.executeHandler('moveToSaturation', { request, attributes, endpoint });
|
|
835
|
+
},
|
|
836
|
+
moveSaturation: async () => {
|
|
837
|
+
this.log.error('Matter command: moveSaturation not implemented');
|
|
838
|
+
},
|
|
839
|
+
stepSaturation: async () => {
|
|
840
|
+
this.log.error('Matter command: stepSaturation not implemented');
|
|
841
|
+
},
|
|
842
|
+
moveToHueAndSaturation: async ({ request, attributes, endpoint }) => {
|
|
843
|
+
this.log.debug('Matter command: moveToHueAndSaturation request:', request, 'attributes.currentHue:', attributes.currentHue.getLocal(), 'attributes.currentSaturation:', attributes.currentSaturation.getLocal());
|
|
844
|
+
// this.commandHandler.executeHandler('moveToHueAndSaturation', { request, attributes, endpoint });
|
|
845
|
+
},
|
|
846
|
+
stopMoveStep: async () => {
|
|
847
|
+
this.log.error('Matter command: stopMoveStep not implemented');
|
|
848
|
+
},
|
|
849
|
+
moveToColorTemperature: async ({ request, attributes, endpoint }) => {
|
|
850
|
+
this.log.debug('Matter command: moveToColorTemperature request:', request, 'attributes.colorTemperatureMireds:', attributes.colorTemperatureMireds.getLocal());
|
|
851
|
+
// this.commandHandler.executeHandler('moveToColorTemperature', { request, attributes, endpoint });
|
|
852
|
+
},
|
|
853
|
+
moveColorTemperature: async () => {
|
|
854
|
+
this.log.error('Matter command: moveColorTemperature not implemented');
|
|
855
|
+
},
|
|
856
|
+
stepColorTemperature: async () => {
|
|
857
|
+
this.log.error('Matter command: stepColorTemperature not implemented');
|
|
858
|
+
},
|
|
859
|
+
}, {});
|
|
860
|
+
}
|
|
861
|
+
/**
|
|
862
|
+
* Creates a default color control cluster server.
|
|
863
|
+
*
|
|
864
|
+
* @param currentHue - The current hue value.
|
|
865
|
+
* @param currentSaturation - The current saturation value.
|
|
866
|
+
* @param colorTemperatureMireds - The color temperature in mireds.
|
|
867
|
+
* @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds.
|
|
868
|
+
* @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds.
|
|
869
|
+
*/
|
|
870
|
+
createDefaultXYColorControlClusterServer(currentX = 0, currentY = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
|
|
871
|
+
this.addClusterServer(this.getDefaultXYColorControlClusterServer(currentX, currentY, colorTemperatureMireds, colorTempPhysicalMinMireds, colorTempPhysicalMaxMireds));
|
|
872
|
+
}
|
|
873
|
+
/**
|
|
874
|
+
* Get a default window covering cluster server.
|
|
875
|
+
*
|
|
876
|
+
* @param positionPercent100ths - The position percentage in 100ths (0-10000). Defaults to 0.
|
|
877
|
+
*/
|
|
878
|
+
getDefaultWindowCoveringClusterServer(positionPercent100ths) {
|
|
879
|
+
return ClusterServer(WindowCoveringCluster.with(WindowCovering.Feature.Lift, WindowCovering.Feature.PositionAwareLift, WindowCovering.Feature.AbsolutePosition), {
|
|
880
|
+
type: WindowCovering.WindowCoveringType.Rollershade,
|
|
881
|
+
configStatus: {
|
|
882
|
+
operational: true,
|
|
883
|
+
onlineReserved: true,
|
|
884
|
+
liftMovementReversed: false,
|
|
885
|
+
liftPositionAware: true,
|
|
886
|
+
tiltPositionAware: false,
|
|
887
|
+
liftEncoderControlled: false,
|
|
888
|
+
tiltEncoderControlled: false,
|
|
889
|
+
},
|
|
890
|
+
operationalStatus: { global: WindowCovering.MovementStatus.Stopped, lift: WindowCovering.MovementStatus.Stopped, tilt: WindowCovering.MovementStatus.Stopped },
|
|
891
|
+
endProductType: WindowCovering.EndProductType.RollerShade,
|
|
892
|
+
mode: { motorDirectionReversed: false, calibrationMode: false, maintenanceMode: false, ledFeedback: false },
|
|
893
|
+
targetPositionLiftPercent100ths: positionPercent100ths ?? 0, // 0 Fully open 10000 fully closed
|
|
894
|
+
currentPositionLiftPercent100ths: positionPercent100ths ?? 0, // 0 Fully open 10000 fully closed
|
|
895
|
+
installedClosedLimitLift: 10000,
|
|
896
|
+
installedOpenLimitLift: 0,
|
|
897
|
+
}, {
|
|
898
|
+
upOrOpen: async (data) => {
|
|
899
|
+
this.log.debug('Matter command: upOrOpen');
|
|
900
|
+
// await this.commandHandler.executeHandler('upOrOpen', data);
|
|
901
|
+
},
|
|
902
|
+
downOrClose: async (data) => {
|
|
903
|
+
this.log.debug('Matter command: downOrClose');
|
|
904
|
+
// await this.commandHandler.executeHandler('downOrClose', data);
|
|
905
|
+
},
|
|
906
|
+
stopMotion: async (data) => {
|
|
907
|
+
this.log.debug('Matter command: stopMotion');
|
|
908
|
+
// await this.commandHandler.executeHandler('stopMotion', data);
|
|
909
|
+
},
|
|
910
|
+
goToLiftPercentage: async (data) => {
|
|
911
|
+
this.log.debug(`Matter command: goToLiftPercentage: ${data.request.liftPercent100thsValue} current: ${data.attributes.currentPositionLiftPercent100ths?.getLocal()} ` +
|
|
912
|
+
`target: ${data.attributes.targetPositionLiftPercent100ths?.getLocal()} status: ${data.attributes.operationalStatus.getLocal().lift}`);
|
|
913
|
+
// await this.commandHandler.executeHandler('goToLiftPercentage', data);
|
|
914
|
+
},
|
|
915
|
+
}, {});
|
|
916
|
+
}
|
|
917
|
+
/**
|
|
918
|
+
* Creates a default window covering cluster server.
|
|
919
|
+
*
|
|
920
|
+
* @param positionPercent100ths - The position percentage in 100ths (0-10000). Defaults to 0.
|
|
921
|
+
*/
|
|
922
|
+
createDefaultWindowCoveringClusterServer(positionPercent100ths) {
|
|
923
|
+
this.addClusterServer(this.getDefaultWindowCoveringClusterServer(positionPercent100ths));
|
|
924
|
+
}
|
|
925
|
+
/**
|
|
926
|
+
* Sets the window covering target position as the current position and stops the movement.
|
|
927
|
+
*/
|
|
928
|
+
setWindowCoveringTargetAsCurrentAndStopped(endpoint) {
|
|
929
|
+
if (!endpoint)
|
|
930
|
+
endpoint = this;
|
|
931
|
+
const windowCoveringCluster = endpoint.getClusterServer(WindowCoveringCluster.with(WindowCovering.Feature.Lift, WindowCovering.Feature.PositionAwareLift, WindowCovering.Feature.AbsolutePosition));
|
|
932
|
+
if (windowCoveringCluster) {
|
|
933
|
+
const position = windowCoveringCluster.getCurrentPositionLiftPercent100thsAttribute();
|
|
934
|
+
if (position !== null) {
|
|
935
|
+
windowCoveringCluster.setTargetPositionLiftPercent100thsAttribute(position);
|
|
936
|
+
windowCoveringCluster.setOperationalStatusAttribute({
|
|
937
|
+
global: WindowCovering.MovementStatus.Stopped,
|
|
938
|
+
lift: WindowCovering.MovementStatus.Stopped,
|
|
939
|
+
tilt: 0,
|
|
940
|
+
});
|
|
941
|
+
}
|
|
942
|
+
this.log.debug(`Set WindowCovering currentPositionLiftPercent100ths and targetPositionLiftPercent100ths to ${position} and operationalStatus to Stopped.`);
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
/**
|
|
946
|
+
* Sets the current and target status of a window covering.
|
|
947
|
+
* @param current - The current position of the window covering.
|
|
948
|
+
* @param target - The target position of the window covering.
|
|
949
|
+
* @param status - The movement status of the window covering.
|
|
950
|
+
*/
|
|
951
|
+
setWindowCoveringCurrentTargetStatus(current, target, status, endpoint) {
|
|
952
|
+
if (!endpoint)
|
|
953
|
+
endpoint = this;
|
|
954
|
+
const windowCoveringCluster = endpoint.getClusterServer(WindowCoveringCluster.with(WindowCovering.Feature.Lift, WindowCovering.Feature.PositionAwareLift, WindowCovering.Feature.AbsolutePosition));
|
|
955
|
+
if (windowCoveringCluster) {
|
|
956
|
+
windowCoveringCluster.setCurrentPositionLiftPercent100thsAttribute(current);
|
|
957
|
+
windowCoveringCluster.setTargetPositionLiftPercent100thsAttribute(target);
|
|
958
|
+
windowCoveringCluster.setOperationalStatusAttribute({
|
|
959
|
+
global: status,
|
|
960
|
+
lift: status,
|
|
961
|
+
tilt: 0,
|
|
962
|
+
});
|
|
963
|
+
}
|
|
964
|
+
this.log.debug(`Set WindowCovering currentPositionLiftPercent100ths: ${current}, targetPositionLiftPercent100ths: ${target} and operationalStatus: ${status}.`);
|
|
965
|
+
}
|
|
966
|
+
/**
|
|
967
|
+
* Sets the status of the window covering.
|
|
968
|
+
* @param {WindowCovering.MovementStatus} status - The movement status to set.
|
|
969
|
+
*/
|
|
970
|
+
setWindowCoveringStatus(status, endpoint) {
|
|
971
|
+
if (!endpoint)
|
|
972
|
+
endpoint = this;
|
|
973
|
+
const windowCovering = endpoint.getClusterServer(WindowCoveringCluster.with(WindowCovering.Feature.Lift, WindowCovering.Feature.PositionAwareLift, WindowCovering.Feature.AbsolutePosition));
|
|
974
|
+
if (!windowCovering)
|
|
975
|
+
return;
|
|
976
|
+
windowCovering.setOperationalStatusAttribute({ global: status, lift: status, tilt: 0 });
|
|
977
|
+
this.log.debug(`Set WindowCovering operationalStatus: ${status}`);
|
|
978
|
+
}
|
|
979
|
+
/**
|
|
980
|
+
* Retrieves the status of the window covering.
|
|
981
|
+
* @returns The global operational status of the window covering.
|
|
982
|
+
*/
|
|
983
|
+
getWindowCoveringStatus(endpoint) {
|
|
984
|
+
if (!endpoint)
|
|
985
|
+
endpoint = this;
|
|
986
|
+
const windowCovering = endpoint.getClusterServer(WindowCoveringCluster.with(WindowCovering.Feature.Lift, WindowCovering.Feature.PositionAwareLift, WindowCovering.Feature.AbsolutePosition));
|
|
987
|
+
if (!windowCovering)
|
|
988
|
+
return undefined;
|
|
989
|
+
const status = windowCovering.getOperationalStatusAttribute();
|
|
990
|
+
this.log.debug(`Get WindowCovering operationalStatus: ${status.global}`);
|
|
991
|
+
return status.global;
|
|
992
|
+
}
|
|
993
|
+
/**
|
|
994
|
+
* Sets the target and current position of the window covering.
|
|
995
|
+
*
|
|
996
|
+
* @param position - The position to set, specified as a number.
|
|
997
|
+
*/
|
|
998
|
+
setWindowCoveringTargetAndCurrentPosition(position, endpoint) {
|
|
999
|
+
if (!endpoint)
|
|
1000
|
+
endpoint = this;
|
|
1001
|
+
const windowCovering = endpoint.getClusterServer(WindowCoveringCluster.with(WindowCovering.Feature.Lift, WindowCovering.Feature.PositionAwareLift));
|
|
1002
|
+
if (!windowCovering)
|
|
1003
|
+
return;
|
|
1004
|
+
windowCovering.setCurrentPositionLiftPercent100thsAttribute(position);
|
|
1005
|
+
windowCovering.setTargetPositionLiftPercent100thsAttribute(position);
|
|
1006
|
+
this.log.debug(`Set WindowCovering currentPositionLiftPercent100ths: ${position} and targetPositionLiftPercent100ths: ${position}.`);
|
|
1007
|
+
}
|
|
1008
|
+
/**
|
|
1009
|
+
* Get a default door lock cluster server.
|
|
1010
|
+
*
|
|
1011
|
+
* @remarks
|
|
1012
|
+
* This method adds a cluster server for a door lock cluster with default settings.
|
|
1013
|
+
*
|
|
1014
|
+
*/
|
|
1015
|
+
getDefaultDoorLockClusterServer(lockState = DoorLock.LockState.Locked, lockType = DoorLock.LockType.Deadbolt) {
|
|
1016
|
+
return ClusterServer(DoorLockCluster, {
|
|
1017
|
+
operatingMode: DoorLock.OperatingMode.Normal,
|
|
1018
|
+
lockState,
|
|
1019
|
+
lockType,
|
|
1020
|
+
actuatorEnabled: false,
|
|
1021
|
+
supportedOperatingModes: { normal: true, vacation: false, privacy: false, noRemoteLockUnlock: false, passage: false },
|
|
1022
|
+
}, {
|
|
1023
|
+
lockDoor: async (data) => {
|
|
1024
|
+
this.log.debug('Matter command: lockDoor', data.request);
|
|
1025
|
+
// await this.commandHandler.executeHandler('lockDoor', data);
|
|
1026
|
+
},
|
|
1027
|
+
unlockDoor: async (data) => {
|
|
1028
|
+
this.log.debug('Matter command: unlockDoor', data.request);
|
|
1029
|
+
// await this.commandHandler.executeHandler('unlockDoor', data);
|
|
1030
|
+
},
|
|
1031
|
+
}, {
|
|
1032
|
+
doorLockAlarm: true,
|
|
1033
|
+
lockOperation: true,
|
|
1034
|
+
lockOperationError: true,
|
|
1035
|
+
});
|
|
1036
|
+
}
|
|
1037
|
+
/**
|
|
1038
|
+
* Creates a default door lock cluster server.
|
|
1039
|
+
*
|
|
1040
|
+
* @remarks
|
|
1041
|
+
* This method adds a cluster server for a door lock cluster with default settings.
|
|
1042
|
+
*
|
|
1043
|
+
*/
|
|
1044
|
+
createDefaultDoorLockClusterServer(lockState = DoorLock.LockState.Locked, lockType = DoorLock.LockType.Deadbolt) {
|
|
1045
|
+
this.addClusterServer(this.getDefaultDoorLockClusterServer(lockState, lockType));
|
|
1046
|
+
}
|
|
1047
|
+
/**
|
|
1048
|
+
* Get a default momentary switch cluster server.
|
|
1049
|
+
*
|
|
1050
|
+
* @remarks
|
|
1051
|
+
* This method adds a cluster server with default momentary switch features and configurations suitable for (AppleHome) Single Double Long automations.
|
|
1052
|
+
*/
|
|
1053
|
+
getDefaultSwitchClusterServer() {
|
|
1054
|
+
return ClusterServer(SwitchCluster.with(Switch.Feature.MomentarySwitch, Switch.Feature.MomentarySwitchRelease, Switch.Feature.MomentarySwitchLongPress, Switch.Feature.MomentarySwitchMultiPress), {
|
|
1055
|
+
numberOfPositions: 2,
|
|
1056
|
+
currentPosition: 0,
|
|
1057
|
+
multiPressMax: 2,
|
|
1058
|
+
}, {}, {
|
|
1059
|
+
initialPress: true,
|
|
1060
|
+
longPress: true,
|
|
1061
|
+
shortRelease: true,
|
|
1062
|
+
longRelease: true,
|
|
1063
|
+
multiPressOngoing: true,
|
|
1064
|
+
multiPressComplete: true,
|
|
1065
|
+
});
|
|
1066
|
+
}
|
|
1067
|
+
/**
|
|
1068
|
+
* Creates a default momentary switch cluster server.
|
|
1069
|
+
*
|
|
1070
|
+
* @remarks
|
|
1071
|
+
* This method adds a cluster server with default momentary switch features and configurations.
|
|
1072
|
+
*/
|
|
1073
|
+
createDefaultSwitchClusterServer() {
|
|
1074
|
+
this.addClusterServer(this.getDefaultSwitchClusterServer());
|
|
1075
|
+
// this.addFixedLabel('orientation', 'Switch');
|
|
1076
|
+
// this.addFixedLabel('label', 'Switch');
|
|
1077
|
+
}
|
|
1078
|
+
/**
|
|
1079
|
+
* Get a default latching switch cluster server.
|
|
1080
|
+
*
|
|
1081
|
+
* @remarks
|
|
1082
|
+
* This method adds a cluster server with default latching switch features and configuration.
|
|
1083
|
+
*/
|
|
1084
|
+
getDefaultLatchingSwitchClusterServer() {
|
|
1085
|
+
return ClusterServer(SwitchCluster.with(Switch.Feature.LatchingSwitch), {
|
|
1086
|
+
numberOfPositions: 2,
|
|
1087
|
+
currentPosition: 0,
|
|
1088
|
+
}, {}, {
|
|
1089
|
+
switchLatched: true,
|
|
1090
|
+
});
|
|
1091
|
+
}
|
|
1092
|
+
/**
|
|
1093
|
+
* Creates a default latching switch cluster server.
|
|
1094
|
+
*
|
|
1095
|
+
* @remarks
|
|
1096
|
+
* This method adds a cluster server with default latching switch features and configuration.
|
|
1097
|
+
*/
|
|
1098
|
+
createDefaultLatchingSwitchClusterServer() {
|
|
1099
|
+
this.addClusterServer(this.getDefaultLatchingSwitchClusterServer());
|
|
1100
|
+
// this.addFixedLabel('orientation', 'Switch');
|
|
1101
|
+
// this.addFixedLabel('label', 'Switch');
|
|
1102
|
+
}
|
|
1103
|
+
/*
|
|
1104
|
+
getDefaultModeSelectClusterServer(description: string, supportedModes: ModeSelect.ModeOptionStruct[], currentMode = 0, startUpMode = 0) {
|
|
1105
|
+
return ClusterServer(
|
|
1106
|
+
ModeSelectCluster,
|
|
1107
|
+
{
|
|
1108
|
+
description: description,
|
|
1109
|
+
standardNamespace: null,
|
|
1110
|
+
supportedModes: supportedModes,
|
|
1111
|
+
currentMode: currentMode,
|
|
1112
|
+
startUpMode: startUpMode,
|
|
1113
|
+
},
|
|
1114
|
+
{
|
|
1115
|
+
changeToMode: async (data) => {
|
|
1116
|
+
this.log.debug('Matter command: changeToMode', data.request);
|
|
1117
|
+
await this.commandHandler.executeHandler('changeToMode', data);
|
|
1118
|
+
},
|
|
1119
|
+
},
|
|
1120
|
+
);
|
|
1121
|
+
}
|
|
1122
|
+
createDefaultModeSelectClusterServer(endpoint?: Endpoint) {
|
|
1123
|
+
if (!endpoint) endpoint = this as Endpoint;
|
|
1124
|
+
endpoint.addClusterServer(
|
|
1125
|
+
this.getDefaultModeSelectClusterServer('Mode select', [
|
|
1126
|
+
{ label: 'Mode 0', mode: 0, semanticTags: [{ mfgCode: VendorId(0xfff1), value: 0 }] },
|
|
1127
|
+
{ label: 'Mode 1', mode: 1, semanticTags: [{ mfgCode: VendorId(0xfff1), value: 1 }] },
|
|
1128
|
+
]),
|
|
1129
|
+
);
|
|
1130
|
+
}
|
|
1131
|
+
*/
|
|
1132
|
+
/**
|
|
1133
|
+
* Get a default occupancy sensing cluster server.
|
|
1134
|
+
*
|
|
1135
|
+
* @param occupied - A boolean indicating whether the occupancy is occupied or not. Default is false.
|
|
1136
|
+
*/
|
|
1137
|
+
getDefaultOccupancySensingClusterServer(occupied = false) {
|
|
1138
|
+
return ClusterServer(OccupancySensingCluster, {
|
|
1139
|
+
occupancy: { occupied },
|
|
1140
|
+
occupancySensorType: OccupancySensing.OccupancySensorType.Pir,
|
|
1141
|
+
occupancySensorTypeBitmap: { pir: true, ultrasonic: false, physicalContact: false },
|
|
1142
|
+
pirOccupiedToUnoccupiedDelay: 30,
|
|
1143
|
+
}, {});
|
|
1144
|
+
}
|
|
1145
|
+
/**
|
|
1146
|
+
* Creates a default occupancy sensing cluster server.
|
|
1147
|
+
*
|
|
1148
|
+
* @param occupied - A boolean indicating whether the occupancy is occupied or not. Default is false.
|
|
1149
|
+
*/
|
|
1150
|
+
createDefaultOccupancySensingClusterServer(occupied = false) {
|
|
1151
|
+
this.addClusterServer(this.getDefaultOccupancySensingClusterServer(occupied));
|
|
1152
|
+
}
|
|
1153
|
+
/**
|
|
1154
|
+
* Get a default Illuminance Measurement Cluster Server.
|
|
1155
|
+
*
|
|
1156
|
+
* @param measuredValue - The measured value of illuminance.
|
|
1157
|
+
*/
|
|
1158
|
+
getDefaultIlluminanceMeasurementClusterServer(measuredValue = 0) {
|
|
1159
|
+
return ClusterServer(IlluminanceMeasurementCluster, {
|
|
1160
|
+
measuredValue,
|
|
1161
|
+
minMeasuredValue: null,
|
|
1162
|
+
maxMeasuredValue: null,
|
|
1163
|
+
tolerance: 0,
|
|
1164
|
+
}, {}, {});
|
|
1165
|
+
}
|
|
1166
|
+
/**
|
|
1167
|
+
* Creates a default Illuminance Measurement Cluster Server.
|
|
1168
|
+
*
|
|
1169
|
+
* @param measuredValue - The measured value of illuminance.
|
|
1170
|
+
*/
|
|
1171
|
+
createDefaultIlluminanceMeasurementClusterServer(measuredValue = 0) {
|
|
1172
|
+
this.addClusterServer(this.getDefaultIlluminanceMeasurementClusterServer(measuredValue));
|
|
1173
|
+
}
|
|
1174
|
+
/**
|
|
1175
|
+
* Get a default flow measurement cluster server.
|
|
1176
|
+
*
|
|
1177
|
+
* @param measuredValue - The measured value of the temperature.
|
|
1178
|
+
*/
|
|
1179
|
+
getDefaultFlowMeasurementClusterServer(measuredValue = 0) {
|
|
1180
|
+
return ClusterServer(FlowMeasurementCluster, {
|
|
1181
|
+
measuredValue,
|
|
1182
|
+
minMeasuredValue: null,
|
|
1183
|
+
maxMeasuredValue: null,
|
|
1184
|
+
tolerance: 0,
|
|
1185
|
+
}, {}, {});
|
|
1186
|
+
}
|
|
1187
|
+
/**
|
|
1188
|
+
* Creates a default flow measurement cluster server.
|
|
1189
|
+
*
|
|
1190
|
+
* @param measuredValue - The measured value of the temperature.
|
|
1191
|
+
*/
|
|
1192
|
+
createDefaultFlowMeasurementClusterServer(measuredValue = 0) {
|
|
1193
|
+
this.addClusterServer(this.getDefaultFlowMeasurementClusterServer(measuredValue));
|
|
1194
|
+
}
|
|
1195
|
+
/**
|
|
1196
|
+
* Get a default temperature measurement cluster server.
|
|
1197
|
+
*
|
|
1198
|
+
* @param measuredValue - The measured value of the temperature.
|
|
1199
|
+
*/
|
|
1200
|
+
getDefaultTemperatureMeasurementClusterServer(measuredValue = 0) {
|
|
1201
|
+
return ClusterServer(TemperatureMeasurementCluster, {
|
|
1202
|
+
measuredValue,
|
|
1203
|
+
minMeasuredValue: null,
|
|
1204
|
+
maxMeasuredValue: null,
|
|
1205
|
+
tolerance: 0,
|
|
1206
|
+
}, {}, {});
|
|
1207
|
+
}
|
|
1208
|
+
/**
|
|
1209
|
+
* Creates a default temperature measurement cluster server.
|
|
1210
|
+
*
|
|
1211
|
+
* @param measuredValue - The measured value of the temperature.
|
|
1212
|
+
*/
|
|
1213
|
+
createDefaultTemperatureMeasurementClusterServer(measuredValue = 0) {
|
|
1214
|
+
this.addClusterServer(this.getDefaultTemperatureMeasurementClusterServer(measuredValue));
|
|
1215
|
+
}
|
|
1216
|
+
/**
|
|
1217
|
+
* Get a default RelativeHumidityMeasurementCluster server.
|
|
1218
|
+
*
|
|
1219
|
+
* @param measuredValue - The measured value of the relative humidity.
|
|
1220
|
+
*/
|
|
1221
|
+
getDefaultRelativeHumidityMeasurementClusterServer(measuredValue = 0) {
|
|
1222
|
+
return ClusterServer(RelativeHumidityMeasurementCluster, {
|
|
1223
|
+
measuredValue,
|
|
1224
|
+
minMeasuredValue: null,
|
|
1225
|
+
maxMeasuredValue: null,
|
|
1226
|
+
tolerance: 0,
|
|
1227
|
+
}, {}, {});
|
|
1228
|
+
}
|
|
1229
|
+
/**
|
|
1230
|
+
* Creates a default RelativeHumidityMeasurementCluster server.
|
|
1231
|
+
*
|
|
1232
|
+
* @param measuredValue - The measured value of the relative humidity.
|
|
1233
|
+
*/
|
|
1234
|
+
createDefaultRelativeHumidityMeasurementClusterServer(measuredValue = 0) {
|
|
1235
|
+
this.addClusterServer(this.getDefaultRelativeHumidityMeasurementClusterServer(measuredValue));
|
|
1236
|
+
}
|
|
1237
|
+
/**
|
|
1238
|
+
* Get a default Pressure Measurement Cluster Server.
|
|
1239
|
+
*
|
|
1240
|
+
* @param measuredValue - The measured value for the pressure.
|
|
1241
|
+
*/
|
|
1242
|
+
getDefaultPressureMeasurementClusterServer(measuredValue = 1000) {
|
|
1243
|
+
return ClusterServer(PressureMeasurementCluster, {
|
|
1244
|
+
measuredValue,
|
|
1245
|
+
minMeasuredValue: null,
|
|
1246
|
+
maxMeasuredValue: null,
|
|
1247
|
+
tolerance: 0,
|
|
1248
|
+
}, {}, {});
|
|
1249
|
+
}
|
|
1250
|
+
/**
|
|
1251
|
+
* Creates a default Pressure Measurement Cluster Server.
|
|
1252
|
+
*
|
|
1253
|
+
* @param measuredValue - The measured value for the pressure.
|
|
1254
|
+
*/
|
|
1255
|
+
createDefaultPressureMeasurementClusterServer(measuredValue = 1000) {
|
|
1256
|
+
this.addClusterServer(this.getDefaultPressureMeasurementClusterServer(measuredValue));
|
|
1257
|
+
}
|
|
1258
|
+
/**
|
|
1259
|
+
* Get a default boolean state cluster server.
|
|
1260
|
+
*
|
|
1261
|
+
* @param contact - Optional boolean value indicating the contact state. Defaults to `true` if not provided.
|
|
1262
|
+
*/
|
|
1263
|
+
getDefaultBooleanStateClusterServer(contact) {
|
|
1264
|
+
return ClusterServer(BooleanStateCluster, {
|
|
1265
|
+
stateValue: contact ?? true, // true=contact false=no_contact
|
|
1266
|
+
}, {}, {
|
|
1267
|
+
stateChange: true,
|
|
1268
|
+
});
|
|
1269
|
+
}
|
|
1270
|
+
/**
|
|
1271
|
+
* Creates a default boolean state configuration cluster server.
|
|
1272
|
+
*
|
|
1273
|
+
* @param contact - Optional boolean value indicating the contact state. Defaults to `true` if not provided.
|
|
1274
|
+
*/
|
|
1275
|
+
createDefaultBooleanStateClusterServer(contact) {
|
|
1276
|
+
this.addClusterServer(this.getDefaultBooleanStateClusterServer(contact));
|
|
1277
|
+
}
|
|
1278
|
+
/**
|
|
1279
|
+
* Get a default boolean state configuration cluster server.
|
|
1280
|
+
*
|
|
1281
|
+
* @param contact - Optional boolean value indicating the sensor fault state. Defaults to `false` if not provided.
|
|
1282
|
+
*/
|
|
1283
|
+
getDefaultBooleanStateConfigurationClusterServer(sensorFault = false) {
|
|
1284
|
+
return ClusterServer(BooleanStateConfigurationCluster.with(BooleanStateConfiguration.Feature.Visual, BooleanStateConfiguration.Feature.Audible, BooleanStateConfiguration.Feature.SensitivityLevel), {
|
|
1285
|
+
currentSensitivityLevel: 0,
|
|
1286
|
+
supportedSensitivityLevels: 2,
|
|
1287
|
+
defaultSensitivityLevel: 0,
|
|
1288
|
+
alarmsActive: { visual: false, audible: false },
|
|
1289
|
+
alarmsEnabled: { visual: false, audible: false },
|
|
1290
|
+
alarmsSupported: { visual: true, audible: true },
|
|
1291
|
+
// alarmsSuppressed: { visual: false, audible: false },
|
|
1292
|
+
sensorFault: { generalFault: sensorFault },
|
|
1293
|
+
}, {
|
|
1294
|
+
enableDisableAlarm: async ({ request, attributes }) => {
|
|
1295
|
+
this.log.debug('Matter command: enableDisableAlarm', request);
|
|
1296
|
+
// await this.commandHandler.executeHandler('enableDisableAlarm', { request, attributes });
|
|
1297
|
+
},
|
|
1298
|
+
}, {
|
|
1299
|
+
alarmsStateChanged: true,
|
|
1300
|
+
sensorFault: true,
|
|
1301
|
+
});
|
|
1302
|
+
}
|
|
1303
|
+
/**
|
|
1304
|
+
* Creates a default boolean state configuration cluster server.
|
|
1305
|
+
*
|
|
1306
|
+
* @param contact - Optional boolean value indicating the sensor fault state. Defaults to `false` if not provided.
|
|
1307
|
+
*/
|
|
1308
|
+
createDefaultBooleanStateConfigurationClusterServer(sensorFault = false) {
|
|
1309
|
+
this.addClusterServer(this.getDefaultBooleanStateConfigurationClusterServer(sensorFault));
|
|
1310
|
+
}
|
|
1311
|
+
/**
|
|
1312
|
+
* Get a default power source replaceable battery cluster server.
|
|
1313
|
+
*
|
|
1314
|
+
* @param batPercentRemaining - The remaining battery percentage (default: 100).
|
|
1315
|
+
* @param batChargeLevel - The battery charge level (default: PowerSource.BatChargeLevel.Ok).
|
|
1316
|
+
* @param batVoltage - The battery voltage (default: 1500).
|
|
1317
|
+
* @param batReplacementDescription - The battery replacement description (default: 'Battery type').
|
|
1318
|
+
* @param batQuantity - The battery quantity (default: 1).
|
|
1319
|
+
*/
|
|
1320
|
+
getDefaultPowerSourceReplaceableBatteryClusterServer(batPercentRemaining = 100, batChargeLevel = PowerSource.BatChargeLevel.Ok, batVoltage = 1500, batReplacementDescription = 'Battery type', batQuantity = 1) {
|
|
1321
|
+
return ClusterServer(PowerSourceCluster.with(PowerSource.Feature.Battery, PowerSource.Feature.Replaceable), {
|
|
1322
|
+
status: PowerSource.PowerSourceStatus.Active,
|
|
1323
|
+
order: 0,
|
|
1324
|
+
description: 'Primary battery',
|
|
1325
|
+
batVoltage,
|
|
1326
|
+
batPercentRemaining: Math.min(Math.max(batPercentRemaining * 2, 0), 200),
|
|
1327
|
+
batChargeLevel,
|
|
1328
|
+
batReplacementNeeded: false,
|
|
1329
|
+
batReplaceability: PowerSource.BatReplaceability.UserReplaceable,
|
|
1330
|
+
activeBatFaults: undefined,
|
|
1331
|
+
batReplacementDescription,
|
|
1332
|
+
batQuantity,
|
|
1333
|
+
}, {}, {});
|
|
1334
|
+
}
|
|
1335
|
+
/**
|
|
1336
|
+
* Creates a default power source replaceable battery cluster server.
|
|
1337
|
+
*
|
|
1338
|
+
* @param batPercentRemaining - The remaining battery percentage (default: 100).
|
|
1339
|
+
* @param batChargeLevel - The battery charge level (default: PowerSource.BatChargeLevel.Ok).
|
|
1340
|
+
* @param batVoltage - The battery voltage (default: 1500).
|
|
1341
|
+
* @param batReplacementDescription - The battery replacement description (default: 'Battery type').
|
|
1342
|
+
* @param batQuantity - The battery quantity (default: 1).
|
|
1343
|
+
*/
|
|
1344
|
+
createDefaultPowerSourceReplaceableBatteryClusterServer(batPercentRemaining = 100, batChargeLevel = PowerSource.BatChargeLevel.Ok, batVoltage = 1500, batReplacementDescription = 'Battery type', batQuantity = 1) {
|
|
1345
|
+
this.addClusterServer(this.getDefaultPowerSourceReplaceableBatteryClusterServer(batPercentRemaining, batChargeLevel, batVoltage, batReplacementDescription, batQuantity));
|
|
1346
|
+
}
|
|
1347
|
+
/**
|
|
1348
|
+
* Get a default power source rechargeable battery cluster server.
|
|
1349
|
+
*
|
|
1350
|
+
* @param batPercentRemaining - The remaining battery percentage (default: 100).
|
|
1351
|
+
* @param batChargeLevel - The battery charge level (default: PowerSource.BatChargeLevel.Ok).
|
|
1352
|
+
* @param batVoltage - The battery voltage (default: 1500).
|
|
1353
|
+
*/
|
|
1354
|
+
getDefaultPowerSourceRechargeableBatteryClusterServer(batPercentRemaining = 100, batChargeLevel = PowerSource.BatChargeLevel.Ok, batVoltage = 1500) {
|
|
1355
|
+
return ClusterServer(PowerSourceCluster.with(PowerSource.Feature.Battery, PowerSource.Feature.Rechargeable), {
|
|
1356
|
+
status: PowerSource.PowerSourceStatus.Active,
|
|
1357
|
+
order: 0,
|
|
1358
|
+
description: 'Primary battery',
|
|
1359
|
+
batVoltage,
|
|
1360
|
+
batPercentRemaining: Math.min(Math.max(batPercentRemaining * 2, 0), 200),
|
|
1361
|
+
batTimeRemaining: 1,
|
|
1362
|
+
batChargeLevel,
|
|
1363
|
+
batReplacementNeeded: false,
|
|
1364
|
+
batReplaceability: PowerSource.BatReplaceability.Unspecified,
|
|
1365
|
+
activeBatFaults: undefined,
|
|
1366
|
+
batChargeState: PowerSource.BatChargeState.IsNotCharging,
|
|
1367
|
+
batFunctionalWhileCharging: true,
|
|
1368
|
+
}, {}, {});
|
|
1369
|
+
}
|
|
1370
|
+
/**
|
|
1371
|
+
* Creates a default power source rechargeable battery cluster server.
|
|
1372
|
+
*
|
|
1373
|
+
* @param batPercentRemaining - The remaining battery percentage (default: 100).
|
|
1374
|
+
* @param batChargeLevel - The battery charge level (default: PowerSource.BatChargeLevel.Ok).
|
|
1375
|
+
* @param batVoltage - The battery voltage (default: 1500).
|
|
1376
|
+
*/
|
|
1377
|
+
createDefaultPowerSourceRechargeableBatteryClusterServer(batPercentRemaining = 100, batChargeLevel = PowerSource.BatChargeLevel.Ok, batVoltage = 1500) {
|
|
1378
|
+
this.addClusterServer(this.getDefaultPowerSourceRechargeableBatteryClusterServer(batPercentRemaining, batChargeLevel, batVoltage));
|
|
1379
|
+
}
|
|
1380
|
+
/**
|
|
1381
|
+
* Get a default power source wired cluster server.
|
|
1382
|
+
*
|
|
1383
|
+
* @param wiredCurrentType - The type of wired current (default: PowerSource.WiredCurrentType.Ac)
|
|
1384
|
+
*/
|
|
1385
|
+
getDefaultPowerSourceWiredClusterServer(wiredCurrentType = PowerSource.WiredCurrentType.Ac) {
|
|
1386
|
+
return ClusterServer(PowerSourceCluster.with(PowerSource.Feature.Wired), {
|
|
1387
|
+
wiredCurrentType,
|
|
1388
|
+
description: wiredCurrentType === PowerSource.WiredCurrentType.Ac ? 'AC Power' : 'DC Power',
|
|
1389
|
+
status: PowerSource.PowerSourceStatus.Active,
|
|
1390
|
+
order: 0,
|
|
1391
|
+
}, {}, {});
|
|
1392
|
+
}
|
|
1393
|
+
/**
|
|
1394
|
+
* Creates a default power source wired cluster server.
|
|
1395
|
+
*
|
|
1396
|
+
* @param wiredCurrentType - The type of wired current (default: PowerSource.WiredCurrentType.Ac)
|
|
1397
|
+
*/
|
|
1398
|
+
createDefaultPowerSourceWiredClusterServer(wiredCurrentType = PowerSource.WiredCurrentType.Ac) {
|
|
1399
|
+
this.addClusterServer(this.getDefaultPowerSourceWiredClusterServer(wiredCurrentType));
|
|
1400
|
+
}
|
|
1401
|
+
/**
|
|
1402
|
+
* @deprecated This function is deprecated by Matter 1.3 spec and will be removed in a future version.
|
|
1403
|
+
*/
|
|
1404
|
+
createDefaultPowerSourceConfigurationClusterServer(endpointNumber) {
|
|
1405
|
+
this.addClusterServer(ClusterServer(PowerSourceConfigurationCluster, {
|
|
1406
|
+
sources: endpointNumber ? [EndpointNumber(endpointNumber)] : [],
|
|
1407
|
+
}, {}, {}));
|
|
1408
|
+
}
|
|
1409
|
+
/**
|
|
1410
|
+
* Get a default air quality cluster server.
|
|
1411
|
+
*
|
|
1412
|
+
* @param airQuality The air quality type. Defaults to `AirQuality.AirQualityType.Unknown`.
|
|
1413
|
+
*/
|
|
1414
|
+
getDefaultAirQualityClusterServer(airQuality = AirQuality.AirQualityType.Unknown) {
|
|
1415
|
+
return ClusterServer(AirQualityCluster.with(AirQuality.Feature.FairAirQuality, AirQuality.Feature.ModerateAirQuality, AirQuality.Feature.VeryPoorAirQuality), {
|
|
1416
|
+
airQuality,
|
|
1417
|
+
}, {}, {});
|
|
1418
|
+
}
|
|
1419
|
+
/**
|
|
1420
|
+
* Creates a default air quality cluster server.
|
|
1421
|
+
*
|
|
1422
|
+
* @param airQuality The air quality type. Defaults to `AirQuality.AirQualityType.Unknown`.
|
|
1423
|
+
*/
|
|
1424
|
+
createDefaultAirQualityClusterServer(airQuality = AirQuality.AirQualityType.Unknown) {
|
|
1425
|
+
this.addClusterServer(this.getDefaultAirQualityClusterServer(airQuality));
|
|
1426
|
+
}
|
|
1427
|
+
/**
|
|
1428
|
+
* Get a default TVOC measurement cluster server.
|
|
1429
|
+
*
|
|
1430
|
+
* @param measuredValue - The measured value for TVOC.
|
|
1431
|
+
*/
|
|
1432
|
+
getDefaultTvocMeasurementClusterServer(measuredValue = 0) {
|
|
1433
|
+
return ClusterServer(TvocMeasurementCluster.with(TvocMeasurement.Feature.NumericMeasurement), {
|
|
1434
|
+
measuredValue,
|
|
1435
|
+
minMeasuredValue: null,
|
|
1436
|
+
maxMeasuredValue: null,
|
|
1437
|
+
}, {}, {});
|
|
1438
|
+
}
|
|
1439
|
+
/**
|
|
1440
|
+
* Creates a default TVOC measurement cluster server.
|
|
1441
|
+
*
|
|
1442
|
+
* @param measuredValue - The measured value for TVOC.
|
|
1443
|
+
*/
|
|
1444
|
+
createDefaultTvocMeasurementClusterServer(measuredValue = 0) {
|
|
1445
|
+
this.addClusterServer(this.getDefaultTvocMeasurementClusterServer(measuredValue));
|
|
1446
|
+
}
|
|
1447
|
+
/**
|
|
1448
|
+
* Get a default thermostat cluster server with the specified parameters.
|
|
1449
|
+
*
|
|
1450
|
+
* @param localTemperature - The local temperature value in degrees Celsius. Defaults to 23.
|
|
1451
|
+
* @param occupiedHeatingSetpoint - The occupied heating setpoint value in degrees Celsius. Defaults to 21.
|
|
1452
|
+
* @param occupiedCoolingSetpoint - The occupied cooling setpoint value in degrees Celsius. Defaults to 25.
|
|
1453
|
+
* @param minSetpointDeadBand - The minimum setpoint dead band value.
|
|
1454
|
+
*/
|
|
1455
|
+
getDefaultThermostatClusterServer(localTemperature = 23, occupiedHeatingSetpoint = 21, occupiedCoolingSetpoint = 25, minSetpointDeadBand = 1) {
|
|
1456
|
+
return ClusterServer(ThermostatCluster.with(Thermostat.Feature.Heating, Thermostat.Feature.Cooling, Thermostat.Feature.AutoMode), {
|
|
1457
|
+
localTemperature: localTemperature * 100,
|
|
1458
|
+
occupiedHeatingSetpoint: occupiedHeatingSetpoint * 100,
|
|
1459
|
+
occupiedCoolingSetpoint: occupiedCoolingSetpoint * 100,
|
|
1460
|
+
minHeatSetpointLimit: 0,
|
|
1461
|
+
maxHeatSetpointLimit: 5000,
|
|
1462
|
+
absMinHeatSetpointLimit: 0,
|
|
1463
|
+
absMaxHeatSetpointLimit: 5000,
|
|
1464
|
+
minCoolSetpointLimit: 0,
|
|
1465
|
+
maxCoolSetpointLimit: 5000,
|
|
1466
|
+
absMinCoolSetpointLimit: 0,
|
|
1467
|
+
absMaxCoolSetpointLimit: 5000,
|
|
1468
|
+
minSetpointDeadBand,
|
|
1469
|
+
systemMode: Thermostat.SystemMode.Off,
|
|
1470
|
+
controlSequenceOfOperation: Thermostat.ControlSequenceOfOperation.CoolingAndHeating,
|
|
1471
|
+
thermostatRunningMode: Thermostat.ThermostatRunningMode.Off,
|
|
1472
|
+
}, {
|
|
1473
|
+
setpointRaiseLower: async ({ request, attributes }) => {
|
|
1474
|
+
this.log.debug('Matter command: setpointRaiseLower', request);
|
|
1475
|
+
// await this.commandHandler.executeHandler('setpointRaiseLower', { request, attributes });
|
|
1476
|
+
},
|
|
1477
|
+
}, {});
|
|
1478
|
+
}
|
|
1479
|
+
/**
|
|
1480
|
+
* Creates and adds a default thermostat cluster server to the device.
|
|
1481
|
+
*
|
|
1482
|
+
* @param localTemperature - The local temperature value.
|
|
1483
|
+
* @param occupiedHeatingSetpoint - The occupied heating setpoint value.
|
|
1484
|
+
* @param occupiedCoolingSetpoint - The occupied cooling setpoint value.
|
|
1485
|
+
* @param minSetpointDeadBand - The minimum setpoint dead band value.
|
|
1486
|
+
*/
|
|
1487
|
+
createDefaultThermostatClusterServer(localTemperature = 23, occupiedHeatingSetpoint = 21, occupiedCoolingSetpoint = 25, minSetpointDeadBand = 1) {
|
|
1488
|
+
this.addClusterServer(this.getDefaultThermostatClusterServer(localTemperature, occupiedHeatingSetpoint, occupiedCoolingSetpoint, minSetpointDeadBand));
|
|
1489
|
+
}
|
|
1490
|
+
/**
|
|
1491
|
+
* Get a default dummy time sync cluster server. Only needed to create a thermostat.
|
|
1492
|
+
*/
|
|
1493
|
+
getDefaultTimeSyncClusterServer() {
|
|
1494
|
+
return ClusterServer(TimeSyncCluster.with(TimeSync.Feature.TimeZone), {
|
|
1495
|
+
utcTime: null,
|
|
1496
|
+
granularity: TimeSync.Granularity.NoTimeGranularity,
|
|
1497
|
+
timeZone: [{ offset: 0, validAt: 0 }],
|
|
1498
|
+
trustedTimeNodeId: null,
|
|
1499
|
+
dstOffset: [],
|
|
1500
|
+
localTime: null,
|
|
1501
|
+
timeZoneDatabase: true,
|
|
1502
|
+
}, {
|
|
1503
|
+
setUtcTime: async ({ request, attributes }) => {
|
|
1504
|
+
this.log.debug('Matter command: setUtcTime', request);
|
|
1505
|
+
// await this.commandHandler.executeHandler('setUtcTime', { request, attributes });
|
|
1506
|
+
},
|
|
1507
|
+
}, {
|
|
1508
|
+
dstTableEmpty: true,
|
|
1509
|
+
dstStatus: true,
|
|
1510
|
+
timeZoneStatus: true,
|
|
1511
|
+
});
|
|
1512
|
+
}
|
|
1513
|
+
/**
|
|
1514
|
+
* Creates a default dummy time sync cluster server. Only needed to create a thermostat.
|
|
1515
|
+
*/
|
|
1516
|
+
createDefaultTimeSyncClusterServer() {
|
|
1517
|
+
this.addClusterServer(this.getDefaultTimeSyncClusterServer());
|
|
1518
|
+
}
|
|
1519
|
+
/**
|
|
1520
|
+
* Returns the default SmokeCOAlarm Cluster Server.
|
|
1521
|
+
*
|
|
1522
|
+
* @param smokeState - The state of the smoke alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
|
|
1523
|
+
* @param coState - The state of the CO alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
|
|
1524
|
+
* @returns The default SmokeCOAlarmClusterServer.
|
|
1525
|
+
*/
|
|
1526
|
+
getDefaultSmokeCOAlarmClusterServer(smokeState = SmokeCoAlarm.AlarmState.Normal, coState = SmokeCoAlarm.AlarmState.Normal) {
|
|
1527
|
+
return ClusterServer(SmokeCoAlarmCluster.with(SmokeCoAlarm.Feature.SmokeAlarm, SmokeCoAlarm.Feature.CoAlarm), {
|
|
1528
|
+
smokeState,
|
|
1529
|
+
coState,
|
|
1530
|
+
expressedState: SmokeCoAlarm.ExpressedState.Normal,
|
|
1531
|
+
batteryAlert: SmokeCoAlarm.AlarmState.Normal,
|
|
1532
|
+
deviceMuted: SmokeCoAlarm.MuteState.NotMuted,
|
|
1533
|
+
testInProgress: false,
|
|
1534
|
+
hardwareFaultAlert: false,
|
|
1535
|
+
endOfServiceAlert: SmokeCoAlarm.EndOfService.Normal,
|
|
1536
|
+
interconnectSmokeAlarm: SmokeCoAlarm.AlarmState.Normal,
|
|
1537
|
+
interconnectCoAlarm: SmokeCoAlarm.AlarmState.Normal,
|
|
1538
|
+
}, {
|
|
1539
|
+
selfTestRequest: async ({ request, attributes }) => {
|
|
1540
|
+
this.log.debug('Matter command: selfTestRequest');
|
|
1541
|
+
// await this.commandHandler.executeHandler('selfTestRequest', { request, attributes });
|
|
1542
|
+
},
|
|
1543
|
+
}, {
|
|
1544
|
+
smokeAlarm: true,
|
|
1545
|
+
interconnectSmokeAlarm: true,
|
|
1546
|
+
coAlarm: true,
|
|
1547
|
+
interconnectCoAlarm: true,
|
|
1548
|
+
lowBattery: true,
|
|
1549
|
+
hardwareFault: true,
|
|
1550
|
+
endOfService: true,
|
|
1551
|
+
selfTestComplete: true,
|
|
1552
|
+
alarmMuted: true,
|
|
1553
|
+
muteEnded: true,
|
|
1554
|
+
allClear: true,
|
|
1555
|
+
});
|
|
1556
|
+
}
|
|
1557
|
+
/**
|
|
1558
|
+
* Create the default SmokeCOAlarm Cluster Server.
|
|
1559
|
+
*
|
|
1560
|
+
* @param smokeState - The state of the smoke alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
|
|
1561
|
+
* @param coState - The state of the CO alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
|
|
1562
|
+
* @returns The default SmokeCOAlarmClusterServer.
|
|
1563
|
+
*/
|
|
1564
|
+
createDefaultSmokeCOAlarmClusterServer(smokeState = SmokeCoAlarm.AlarmState.Normal, coState = SmokeCoAlarm.AlarmState.Normal) {
|
|
1565
|
+
this.addClusterServer(this.getDefaultSmokeCOAlarmClusterServer(smokeState, coState));
|
|
1566
|
+
}
|
|
1567
|
+
/**
|
|
1568
|
+
* Returns the default Carbon Monoxide Concentration Measurement Cluster Server.
|
|
1569
|
+
*
|
|
1570
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
1571
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
1572
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
1573
|
+
* @returns {ClusterServer} - The default Carbon Monoxide Concentration Measurement Cluster Server.
|
|
1574
|
+
*/
|
|
1575
|
+
getDefaultCarbonMonoxideConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1576
|
+
return ClusterServer(CarbonMonoxideConcentrationMeasurementCluster.with('NumericMeasurement'), {
|
|
1577
|
+
measuredValue,
|
|
1578
|
+
minMeasuredValue: null,
|
|
1579
|
+
maxMeasuredValue: null,
|
|
1580
|
+
uncertainty: 0,
|
|
1581
|
+
measurementUnit,
|
|
1582
|
+
measurementMedium,
|
|
1583
|
+
}, {}, {});
|
|
1584
|
+
}
|
|
1585
|
+
/**
|
|
1586
|
+
* Create the default Carbon Monoxide Concentration Measurement Cluster Server.
|
|
1587
|
+
*
|
|
1588
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
1589
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
1590
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
1591
|
+
*/
|
|
1592
|
+
createDefaultCarbonMonoxideConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1593
|
+
this.addClusterServer(this.getDefaultCarbonMonoxideConcentrationMeasurementClusterServer(measuredValue, measurementUnit, measurementMedium));
|
|
1594
|
+
}
|
|
1595
|
+
/**
|
|
1596
|
+
* Returns the default Carbon Dioxide Concentration Measurement Cluster Server.
|
|
1597
|
+
*
|
|
1598
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
1599
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
1600
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
1601
|
+
* @returns {ClusterServer} - The default Carbon Monoxide Concentration Measurement Cluster Server.
|
|
1602
|
+
*/
|
|
1603
|
+
getDefaultCarbonDioxideConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1604
|
+
return ClusterServer(CarbonDioxideConcentrationMeasurementCluster.with('NumericMeasurement'), {
|
|
1605
|
+
measuredValue,
|
|
1606
|
+
minMeasuredValue: null,
|
|
1607
|
+
maxMeasuredValue: null,
|
|
1608
|
+
uncertainty: 0,
|
|
1609
|
+
measurementUnit,
|
|
1610
|
+
measurementMedium,
|
|
1611
|
+
}, {}, {});
|
|
1612
|
+
}
|
|
1613
|
+
/**
|
|
1614
|
+
* Create the default Carbon Dioxide Concentration Measurement Cluster Server.
|
|
1615
|
+
*
|
|
1616
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
1617
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
1618
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
1619
|
+
*/
|
|
1620
|
+
createDefaultCarbonDioxideConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1621
|
+
this.addClusterServer(this.getDefaultCarbonDioxideConcentrationMeasurementClusterServer(measuredValue, measurementUnit, measurementMedium));
|
|
1622
|
+
}
|
|
1623
|
+
/**
|
|
1624
|
+
* Returns the default Formaldehyde Concentration Measurement Cluster Server.
|
|
1625
|
+
*
|
|
1626
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
1627
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
1628
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
1629
|
+
* @returns {ClusterServer} - The default Carbon Monoxide Concentration Measurement Cluster Server.
|
|
1630
|
+
*/
|
|
1631
|
+
getDefaultFormaldehydeConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1632
|
+
return ClusterServer(FormaldehydeConcentrationMeasurementCluster.with('NumericMeasurement'), {
|
|
1633
|
+
measuredValue,
|
|
1634
|
+
minMeasuredValue: null,
|
|
1635
|
+
maxMeasuredValue: null,
|
|
1636
|
+
uncertainty: 0,
|
|
1637
|
+
measurementUnit,
|
|
1638
|
+
measurementMedium,
|
|
1639
|
+
}, {}, {});
|
|
1640
|
+
}
|
|
1641
|
+
/**
|
|
1642
|
+
* Create the default Formaldehyde Concentration Measurement Cluster Server.
|
|
1643
|
+
*
|
|
1644
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
1645
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
1646
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
1647
|
+
*/
|
|
1648
|
+
createDefaultFormaldehydeConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1649
|
+
this.addClusterServer(this.getDefaultFormaldehydeConcentrationMeasurementClusterServer(measuredValue, measurementUnit, measurementMedium));
|
|
1650
|
+
}
|
|
1651
|
+
/**
|
|
1652
|
+
* Returns the default Pm1 Concentration Measurement Cluster Server.
|
|
1653
|
+
*
|
|
1654
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
1655
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
1656
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
1657
|
+
* @returns {ClusterServer} - The default Carbon Monoxide Concentration Measurement Cluster Server.
|
|
1658
|
+
*/
|
|
1659
|
+
getDefaultPm1ConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1660
|
+
return ClusterServer(Pm1ConcentrationMeasurementCluster.with('NumericMeasurement'), {
|
|
1661
|
+
measuredValue,
|
|
1662
|
+
minMeasuredValue: null,
|
|
1663
|
+
maxMeasuredValue: null,
|
|
1664
|
+
uncertainty: 0,
|
|
1665
|
+
measurementUnit,
|
|
1666
|
+
measurementMedium,
|
|
1667
|
+
}, {}, {});
|
|
1668
|
+
}
|
|
1669
|
+
/**
|
|
1670
|
+
* Create the default Pm1 Concentration Measurement Cluster Server.
|
|
1671
|
+
*
|
|
1672
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
1673
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
1674
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
1675
|
+
*/
|
|
1676
|
+
createDefaulPm1ConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1677
|
+
this.addClusterServer(this.getDefaultPm1ConcentrationMeasurementClusterServer(measuredValue, measurementUnit, measurementMedium));
|
|
1678
|
+
}
|
|
1679
|
+
/**
|
|
1680
|
+
* Returns the default Pm25 Concentration Measurement Cluster Server.
|
|
1681
|
+
*
|
|
1682
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
1683
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
1684
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
1685
|
+
* @returns {ClusterServer} - The default Carbon Monoxide Concentration Measurement Cluster Server.
|
|
1686
|
+
*/
|
|
1687
|
+
getDefaultPm25ConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1688
|
+
return ClusterServer(Pm25ConcentrationMeasurementCluster.with('NumericMeasurement'), {
|
|
1689
|
+
measuredValue,
|
|
1690
|
+
minMeasuredValue: null,
|
|
1691
|
+
maxMeasuredValue: null,
|
|
1692
|
+
uncertainty: 0,
|
|
1693
|
+
measurementUnit,
|
|
1694
|
+
measurementMedium,
|
|
1695
|
+
}, {}, {});
|
|
1696
|
+
}
|
|
1697
|
+
/**
|
|
1698
|
+
* Create the default Pm25 Concentration Measurement Cluster Server.
|
|
1699
|
+
*
|
|
1700
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
1701
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
1702
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
1703
|
+
*/
|
|
1704
|
+
createDefaulPm25ConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1705
|
+
this.addClusterServer(this.getDefaultPm25ConcentrationMeasurementClusterServer(measuredValue, measurementUnit, measurementMedium));
|
|
1706
|
+
}
|
|
1707
|
+
/**
|
|
1708
|
+
* Returns the default Pm10 Concentration Measurement Cluster Server.
|
|
1709
|
+
*
|
|
1710
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
1711
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
1712
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
1713
|
+
* @returns {ClusterServer} - The default Carbon Monoxide Concentration Measurement Cluster Server.
|
|
1714
|
+
*/
|
|
1715
|
+
getDefaultPm10ConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1716
|
+
return ClusterServer(Pm10ConcentrationMeasurementCluster.with('NumericMeasurement'), {
|
|
1717
|
+
measuredValue,
|
|
1718
|
+
minMeasuredValue: null,
|
|
1719
|
+
maxMeasuredValue: null,
|
|
1720
|
+
uncertainty: 0,
|
|
1721
|
+
measurementUnit,
|
|
1722
|
+
measurementMedium,
|
|
1723
|
+
}, {}, {});
|
|
1724
|
+
}
|
|
1725
|
+
/**
|
|
1726
|
+
* Create the default Pm10 Concentration Measurement Cluster Server.
|
|
1727
|
+
*
|
|
1728
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
1729
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
1730
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
1731
|
+
*/
|
|
1732
|
+
createDefaulPm10ConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1733
|
+
this.addClusterServer(this.getDefaultPm10ConcentrationMeasurementClusterServer(measuredValue, measurementUnit, measurementMedium));
|
|
1734
|
+
}
|
|
1735
|
+
/**
|
|
1736
|
+
* Returns the default Ozone Concentration Measurement Cluster Server.
|
|
1737
|
+
*
|
|
1738
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
1739
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
1740
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
1741
|
+
* @returns {ClusterServer} - The default Carbon Monoxide Concentration Measurement Cluster Server.
|
|
1742
|
+
*/
|
|
1743
|
+
getDefaultOzoneConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ugm3, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1744
|
+
return ClusterServer(OzoneConcentrationMeasurementCluster.with('NumericMeasurement'), {
|
|
1745
|
+
measuredValue,
|
|
1746
|
+
minMeasuredValue: null,
|
|
1747
|
+
maxMeasuredValue: null,
|
|
1748
|
+
uncertainty: 0,
|
|
1749
|
+
measurementUnit,
|
|
1750
|
+
measurementMedium,
|
|
1751
|
+
}, {}, {});
|
|
1752
|
+
}
|
|
1753
|
+
/**
|
|
1754
|
+
* Create the default Ozone Concentration Measurement Cluster Server.
|
|
1755
|
+
*
|
|
1756
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
1757
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
1758
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
1759
|
+
*/
|
|
1760
|
+
createDefaulOzoneConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ugm3, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1761
|
+
this.addClusterServer(this.getDefaultOzoneConcentrationMeasurementClusterServer(measuredValue, measurementUnit, measurementMedium));
|
|
1762
|
+
}
|
|
1763
|
+
/**
|
|
1764
|
+
* Returns the default Radon Concentration Measurement Cluster Server.
|
|
1765
|
+
*
|
|
1766
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
1767
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
1768
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
1769
|
+
* @returns {ClusterServer} - The default Carbon Monoxide Concentration Measurement Cluster Server.
|
|
1770
|
+
*/
|
|
1771
|
+
getDefaultRadonConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1772
|
+
return ClusterServer(RadonConcentrationMeasurementCluster.with('NumericMeasurement'), {
|
|
1773
|
+
measuredValue,
|
|
1774
|
+
minMeasuredValue: null,
|
|
1775
|
+
maxMeasuredValue: null,
|
|
1776
|
+
uncertainty: 0,
|
|
1777
|
+
measurementUnit,
|
|
1778
|
+
measurementMedium,
|
|
1779
|
+
}, {}, {});
|
|
1780
|
+
}
|
|
1781
|
+
/**
|
|
1782
|
+
* Create the default Radon Concentration Measurement Cluster Server.
|
|
1783
|
+
*
|
|
1784
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
1785
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
1786
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
1787
|
+
*/
|
|
1788
|
+
createDefaulRadonConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1789
|
+
this.addClusterServer(this.getDefaultRadonConcentrationMeasurementClusterServer(measuredValue, measurementUnit, measurementMedium));
|
|
1790
|
+
}
|
|
1791
|
+
/**
|
|
1792
|
+
* Returns the default Nitrogen Dioxide Concentration Measurement Cluster Server.
|
|
1793
|
+
*
|
|
1794
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
1795
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
1796
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
1797
|
+
* @returns {ClusterServer} - The default Carbon Monoxide Concentration Measurement Cluster Server.
|
|
1798
|
+
*/
|
|
1799
|
+
getDefaultNitrogenDioxideConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ugm3, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1800
|
+
return ClusterServer(NitrogenDioxideConcentrationMeasurementCluster.with('NumericMeasurement'), {
|
|
1801
|
+
measuredValue,
|
|
1802
|
+
minMeasuredValue: null,
|
|
1803
|
+
maxMeasuredValue: null,
|
|
1804
|
+
uncertainty: 0,
|
|
1805
|
+
measurementUnit,
|
|
1806
|
+
measurementMedium,
|
|
1807
|
+
}, {}, {});
|
|
1808
|
+
}
|
|
1809
|
+
/**
|
|
1810
|
+
* Create the default Nitrogen Dioxide Concentration Measurement Cluster Server.
|
|
1811
|
+
*
|
|
1812
|
+
* @param {number} measuredValue - The measured value of the concentration.
|
|
1813
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement.
|
|
1814
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The medium of measurement.
|
|
1815
|
+
*/
|
|
1816
|
+
createDefaulNitrogenDioxideConcentrationMeasurementClusterServer(measuredValue = 0, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ugm3, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1817
|
+
this.addClusterServer(this.getDefaultNitrogenDioxideConcentrationMeasurementClusterServer(measuredValue, measurementUnit, measurementMedium));
|
|
1818
|
+
}
|
|
1819
|
+
/**
|
|
1820
|
+
* Returns the default fan control cluster server rev 2.
|
|
1821
|
+
*
|
|
1822
|
+
* @param fanMode The fan mode to set. Defaults to `FanControl.FanMode.Off`.
|
|
1823
|
+
* @returns The default fan control cluster server.
|
|
1824
|
+
*/
|
|
1825
|
+
getDefaultFanControlClusterServer(fanMode = FanControl.FanMode.Off) {
|
|
1826
|
+
return ClusterServer(FanControlCluster.with(FanControl.Feature.MultiSpeed, FanControl.Feature.Auto /* , FanControl.Feature.Step*/), {
|
|
1827
|
+
fanMode,
|
|
1828
|
+
fanModeSequence: FanControl.FanModeSequence.OffLowMedHighAuto,
|
|
1829
|
+
percentSetting: 0,
|
|
1830
|
+
percentCurrent: 0,
|
|
1831
|
+
speedMax: 100,
|
|
1832
|
+
speedSetting: 0,
|
|
1833
|
+
speedCurrent: 0,
|
|
1834
|
+
}, {
|
|
1835
|
+
/*
|
|
1836
|
+
step: async ({ request, attributes }) => {
|
|
1837
|
+
this.log.debug('Matter command: step', request);
|
|
1838
|
+
await this.commandHandler.executeHandler('step', { request, attributes });
|
|
1839
|
+
},
|
|
1840
|
+
*/
|
|
1841
|
+
}, {});
|
|
1842
|
+
}
|
|
1843
|
+
/**
|
|
1844
|
+
* Create the default fan control cluster server rev 2.
|
|
1845
|
+
*
|
|
1846
|
+
* @param fanMode The fan mode to set. Defaults to `FanControl.FanMode.Off`.
|
|
1847
|
+
* @returns The default fan control cluster server.
|
|
1848
|
+
*/
|
|
1849
|
+
createDefaultFanControlClusterServer(fanMode = FanControl.FanMode.Off) {
|
|
1850
|
+
this.addClusterServer(this.getDefaultFanControlClusterServer(fanMode));
|
|
1851
|
+
}
|
|
1852
|
+
// NOTE Support of Device Energy Management Cluster is provisional.
|
|
1853
|
+
getDefaultDeviceEnergyManagementClusterServer() {
|
|
1854
|
+
return ClusterServer(DeviceEnergyManagementCluster.with(DeviceEnergyManagement.Feature.Pausable, DeviceEnergyManagement.Feature.PowerForecastReporting, DeviceEnergyManagement.Feature.StateForecastReporting), {
|
|
1855
|
+
esaType: DeviceEnergyManagement.EsaType.Other,
|
|
1856
|
+
esaCanGenerate: false,
|
|
1857
|
+
esaState: DeviceEnergyManagement.EsaState.Online,
|
|
1858
|
+
absMinPower: 0,
|
|
1859
|
+
absMaxPower: 0,
|
|
1860
|
+
optOutState: DeviceEnergyManagement.OptOutState.NoOptOut,
|
|
1861
|
+
forecast: null,
|
|
1862
|
+
}, {
|
|
1863
|
+
pauseRequest: async ({ request, attributes }) => {
|
|
1864
|
+
this.log.debug('Matter command: pauseRequest', request);
|
|
1865
|
+
// await this.commandHandler.executeHandler('pauseRequest', { request, attributes });
|
|
1866
|
+
},
|
|
1867
|
+
resumeRequest: async () => {
|
|
1868
|
+
this.log.debug('Matter command: resumeRequest');
|
|
1869
|
+
// await this.commandHandler.executeHandler('resumeRequest');
|
|
1870
|
+
},
|
|
1871
|
+
}, {
|
|
1872
|
+
paused: true,
|
|
1873
|
+
resumed: true,
|
|
1874
|
+
});
|
|
1875
|
+
}
|
|
1876
|
+
// NOTE Support of Device Energy Management Mode Cluster is provisional.
|
|
1877
|
+
getDefaultDeviceEnergyManagementModeClusterServer() {
|
|
1878
|
+
return ClusterServer(DeviceEnergyManagementModeCluster, {
|
|
1879
|
+
esaType: DeviceEnergyManagement.EsaType.Other,
|
|
1880
|
+
esaCanGenerate: false,
|
|
1881
|
+
esaState: DeviceEnergyManagement.EsaState.Online,
|
|
1882
|
+
absMinPower: 0,
|
|
1883
|
+
absMaxPower: 0,
|
|
1884
|
+
optOutState: DeviceEnergyManagement.OptOutState.NoOptOut,
|
|
1885
|
+
}, {}, {});
|
|
121
1886
|
}
|
|
122
1887
|
}
|
|
123
1888
|
//# sourceMappingURL=matterbridgeDeviceV8.js.map
|