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