matterbridge 3.1.4 → 3.1.5-dev-20250720-5a0b41e
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 +19 -0
- package/README-DEV.md +59 -0
- package/dist/cli.js +2 -91
- package/dist/cliEmitter.js +0 -30
- package/dist/clusters/export.js +0 -2
- package/dist/defaultConfigSchema.js +0 -24
- package/dist/deviceManager.js +1 -94
- package/dist/devices/batteryStorage.js +1 -48
- package/dist/devices/evse.js +10 -74
- package/dist/devices/export.js +0 -2
- package/dist/devices/heatPump.js +2 -50
- package/dist/devices/laundryDryer.js +6 -83
- package/dist/devices/laundryWasher.js +7 -91
- package/dist/devices/roboticVacuumCleaner.js +17 -97
- package/dist/devices/solarPower.js +0 -38
- package/dist/devices/waterHeater.js +2 -82
- package/dist/frontend.js +22 -430
- package/dist/globalMatterbridge.js +0 -47
- package/dist/helpers.js +0 -53
- package/dist/index.js +1 -30
- package/dist/logger/export.js +0 -1
- package/dist/matter/behaviors.js +0 -2
- package/dist/matter/clusters.js +0 -2
- package/dist/matter/devices.js +0 -2
- package/dist/matter/endpoints.js +0 -2
- package/dist/matter/export.js +0 -3
- package/dist/matter/types.js +0 -3
- package/dist/matterbridge.js +66 -802
- package/dist/matterbridgeAccessoryPlatform.js +0 -36
- package/dist/matterbridgeBehaviors.js +1 -61
- package/dist/matterbridgeDeviceTypes.js +15 -579
- package/dist/matterbridgeDynamicPlatform.js +0 -36
- package/dist/matterbridgeEndpoint.js +42 -1106
- package/dist/matterbridgeEndpointHelpers.js +12 -322
- package/dist/matterbridgePlatform.js +0 -233
- package/dist/matterbridgeTypes.js +0 -25
- package/dist/pluginManager.js +46 -350
- package/dist/shelly.js +7 -168
- package/dist/storage/export.js +0 -1
- package/dist/update.js +0 -54
- package/dist/utils/colorUtils.js +2 -263
- package/dist/utils/commandLine.js +0 -54
- package/dist/utils/copyDirectory.js +1 -38
- package/dist/utils/createDirectory.js +0 -33
- package/dist/utils/createZip.js +2 -47
- package/dist/utils/deepCopy.js +0 -39
- package/dist/utils/deepEqual.js +1 -72
- package/dist/utils/error.js +9 -0
- package/dist/utils/export.js +0 -1
- package/dist/utils/hex.js +0 -58
- package/dist/utils/isvalid.js +0 -101
- package/dist/utils/network.js +5 -81
- package/dist/utils/spawn.js +0 -18
- package/dist/utils/wait.js +9 -62
- package/npm-shrinkwrap.json +5 -5
- package/package.json +1 -2
- package/dist/cli.d.ts +0 -26
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/cliEmitter.d.ts +0 -34
- package/dist/cliEmitter.d.ts.map +0 -1
- package/dist/cliEmitter.js.map +0 -1
- package/dist/clusters/export.d.ts +0 -2
- package/dist/clusters/export.d.ts.map +0 -1
- package/dist/clusters/export.js.map +0 -1
- package/dist/defaultConfigSchema.d.ts +0 -28
- package/dist/defaultConfigSchema.d.ts.map +0 -1
- package/dist/defaultConfigSchema.js.map +0 -1
- package/dist/deviceManager.d.ts +0 -112
- package/dist/deviceManager.d.ts.map +0 -1
- package/dist/deviceManager.js.map +0 -1
- package/dist/devices/batteryStorage.d.ts +0 -48
- package/dist/devices/batteryStorage.d.ts.map +0 -1
- package/dist/devices/batteryStorage.js.map +0 -1
- package/dist/devices/evse.d.ts +0 -75
- package/dist/devices/evse.d.ts.map +0 -1
- package/dist/devices/evse.js.map +0 -1
- package/dist/devices/export.d.ts +0 -9
- package/dist/devices/export.d.ts.map +0 -1
- package/dist/devices/export.js.map +0 -1
- package/dist/devices/heatPump.d.ts +0 -47
- package/dist/devices/heatPump.d.ts.map +0 -1
- package/dist/devices/heatPump.js.map +0 -1
- package/dist/devices/laundryDryer.d.ts +0 -87
- package/dist/devices/laundryDryer.d.ts.map +0 -1
- package/dist/devices/laundryDryer.js.map +0 -1
- package/dist/devices/laundryWasher.d.ts +0 -242
- package/dist/devices/laundryWasher.d.ts.map +0 -1
- package/dist/devices/laundryWasher.js.map +0 -1
- package/dist/devices/roboticVacuumCleaner.d.ts +0 -110
- package/dist/devices/roboticVacuumCleaner.d.ts.map +0 -1
- package/dist/devices/roboticVacuumCleaner.js.map +0 -1
- package/dist/devices/solarPower.d.ts +0 -40
- package/dist/devices/solarPower.d.ts.map +0 -1
- package/dist/devices/solarPower.js.map +0 -1
- package/dist/devices/waterHeater.d.ts +0 -111
- package/dist/devices/waterHeater.d.ts.map +0 -1
- package/dist/devices/waterHeater.js.map +0 -1
- package/dist/frontend.d.ts +0 -304
- package/dist/frontend.d.ts.map +0 -1
- package/dist/frontend.js.map +0 -1
- package/dist/globalMatterbridge.d.ts +0 -59
- package/dist/globalMatterbridge.d.ts.map +0 -1
- package/dist/globalMatterbridge.js.map +0 -1
- package/dist/helpers.d.ts +0 -48
- package/dist/helpers.d.ts.map +0 -1
- package/dist/helpers.js.map +0 -1
- package/dist/index.d.ts +0 -33
- 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/behaviors.d.ts +0 -2
- package/dist/matter/behaviors.d.ts.map +0 -1
- package/dist/matter/behaviors.js.map +0 -1
- package/dist/matter/clusters.d.ts +0 -2
- package/dist/matter/clusters.d.ts.map +0 -1
- package/dist/matter/clusters.js.map +0 -1
- package/dist/matter/devices.d.ts +0 -2
- package/dist/matter/devices.d.ts.map +0 -1
- package/dist/matter/devices.js.map +0 -1
- package/dist/matter/endpoints.d.ts +0 -2
- package/dist/matter/endpoints.d.ts.map +0 -1
- package/dist/matter/endpoints.js.map +0 -1
- package/dist/matter/export.d.ts +0 -5
- package/dist/matter/export.d.ts.map +0 -1
- package/dist/matter/export.js.map +0 -1
- package/dist/matter/types.d.ts +0 -3
- package/dist/matter/types.d.ts.map +0 -1
- package/dist/matter/types.js.map +0 -1
- package/dist/matterbridge.d.ts +0 -444
- package/dist/matterbridge.d.ts.map +0 -1
- package/dist/matterbridge.js.map +0 -1
- package/dist/matterbridgeAccessoryPlatform.d.ts +0 -42
- package/dist/matterbridgeAccessoryPlatform.d.ts.map +0 -1
- package/dist/matterbridgeAccessoryPlatform.js.map +0 -1
- package/dist/matterbridgeBehaviors.d.ts +0 -1340
- package/dist/matterbridgeBehaviors.d.ts.map +0 -1
- package/dist/matterbridgeBehaviors.js.map +0 -1
- package/dist/matterbridgeDeviceTypes.d.ts +0 -709
- package/dist/matterbridgeDeviceTypes.d.ts.map +0 -1
- package/dist/matterbridgeDeviceTypes.js.map +0 -1
- package/dist/matterbridgeDynamicPlatform.d.ts +0 -42
- package/dist/matterbridgeDynamicPlatform.d.ts.map +0 -1
- package/dist/matterbridgeDynamicPlatform.js.map +0 -1
- package/dist/matterbridgeEndpoint.d.ts +0 -1250
- package/dist/matterbridgeEndpoint.d.ts.map +0 -1
- package/dist/matterbridgeEndpoint.js.map +0 -1
- package/dist/matterbridgeEndpointHelpers.d.ts +0 -3198
- package/dist/matterbridgeEndpointHelpers.d.ts.map +0 -1
- package/dist/matterbridgeEndpointHelpers.js.map +0 -1
- package/dist/matterbridgePlatform.d.ts +0 -310
- package/dist/matterbridgePlatform.d.ts.map +0 -1
- package/dist/matterbridgePlatform.js.map +0 -1
- package/dist/matterbridgeTypes.d.ts +0 -195
- package/dist/matterbridgeTypes.d.ts.map +0 -1
- package/dist/matterbridgeTypes.js.map +0 -1
- package/dist/pluginManager.d.ts +0 -291
- package/dist/pluginManager.d.ts.map +0 -1
- package/dist/pluginManager.js.map +0 -1
- package/dist/shelly.d.ts +0 -174
- package/dist/shelly.d.ts.map +0 -1
- package/dist/shelly.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/update.d.ts +0 -59
- package/dist/update.d.ts.map +0 -1
- package/dist/update.js.map +0 -1
- package/dist/utils/colorUtils.d.ts +0 -117
- package/dist/utils/colorUtils.d.ts.map +0 -1
- package/dist/utils/colorUtils.js.map +0 -1
- package/dist/utils/commandLine.d.ts +0 -59
- package/dist/utils/commandLine.d.ts.map +0 -1
- package/dist/utils/commandLine.js.map +0 -1
- package/dist/utils/copyDirectory.d.ts +0 -33
- package/dist/utils/copyDirectory.d.ts.map +0 -1
- package/dist/utils/copyDirectory.js.map +0 -1
- package/dist/utils/createDirectory.d.ts +0 -34
- package/dist/utils/createDirectory.d.ts.map +0 -1
- package/dist/utils/createDirectory.js.map +0 -1
- package/dist/utils/createZip.d.ts +0 -39
- package/dist/utils/createZip.d.ts.map +0 -1
- package/dist/utils/createZip.js.map +0 -1
- package/dist/utils/deepCopy.d.ts +0 -32
- package/dist/utils/deepCopy.d.ts.map +0 -1
- package/dist/utils/deepCopy.js.map +0 -1
- package/dist/utils/deepEqual.d.ts +0 -54
- package/dist/utils/deepEqual.d.ts.map +0 -1
- package/dist/utils/deepEqual.js.map +0 -1
- package/dist/utils/export.d.ts +0 -12
- package/dist/utils/export.d.ts.map +0 -1
- package/dist/utils/export.js.map +0 -1
- package/dist/utils/hex.d.ts +0 -49
- package/dist/utils/hex.d.ts.map +0 -1
- package/dist/utils/hex.js.map +0 -1
- package/dist/utils/isvalid.d.ts +0 -103
- package/dist/utils/isvalid.d.ts.map +0 -1
- package/dist/utils/isvalid.js.map +0 -1
- package/dist/utils/network.d.ts +0 -74
- package/dist/utils/network.d.ts.map +0 -1
- package/dist/utils/network.js.map +0 -1
- package/dist/utils/spawn.d.ts +0 -11
- package/dist/utils/spawn.d.ts.map +0 -1
- package/dist/utils/spawn.js.map +0 -1
- package/dist/utils/wait.d.ts +0 -56
- package/dist/utils/wait.d.ts.map +0 -1
- package/dist/utils/wait.js.map +0 -1
|
@@ -1,34 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file contains the helpers for the class MatterbridgeEndpoint.
|
|
3
|
-
*
|
|
4
|
-
* @file matterbridgeEndpointHelpers.ts
|
|
5
|
-
* @author Luca Liguori
|
|
6
|
-
* @created 2024-10-01
|
|
7
|
-
* @version 2.1.0
|
|
8
|
-
* @license Apache-2.0
|
|
9
|
-
*
|
|
10
|
-
* Copyright 2024, 2025, 2026 Luca Liguori.
|
|
11
|
-
*
|
|
12
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
13
|
-
* you may not use this file except in compliance with the License.
|
|
14
|
-
* You may obtain a copy of the License at
|
|
15
|
-
*
|
|
16
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
17
|
-
*
|
|
18
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
19
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
20
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
21
|
-
* See the License for the specific language governing permissions and
|
|
22
|
-
* limitations under the License.
|
|
23
|
-
*/
|
|
24
|
-
// Other modules
|
|
25
1
|
import { createHash } from 'node:crypto';
|
|
26
|
-
// AnsiLogger module
|
|
27
2
|
import { BLUE, CYAN, db, debugStringify, er, hk, or, YELLOW, zb } from 'node-ansi-logger';
|
|
28
|
-
// @matter
|
|
29
3
|
import { Lifecycle } from '@matter/main';
|
|
30
4
|
import { getClusterNameById } from '@matter/main/types';
|
|
31
|
-
// @matter clusters
|
|
32
5
|
import { PowerSource } from '@matter/main/clusters/power-source';
|
|
33
6
|
import { UserLabel } from '@matter/main/clusters/user-label';
|
|
34
7
|
import { FixedLabel } from '@matter/main/clusters/fixed-label';
|
|
@@ -73,7 +46,6 @@ import { TotalVolatileOrganicCompoundsConcentrationMeasurement } from '@matter/m
|
|
|
73
46
|
import { OperationalState } from '@matter/main/clusters/operational-state';
|
|
74
47
|
import { DeviceEnergyManagement } from '@matter/main/clusters/device-energy-management';
|
|
75
48
|
import { DeviceEnergyManagementMode } from '@matter/main/clusters/device-energy-management-mode';
|
|
76
|
-
// @matter behaviors
|
|
77
49
|
import { PowerSourceServer } from '@matter/main/behaviors/power-source';
|
|
78
50
|
import { UserLabelServer } from '@matter/main/behaviors/user-label';
|
|
79
51
|
import { FixedLabelServer } from '@matter/main/behaviors/fixed-label';
|
|
@@ -104,109 +76,53 @@ import { Pm10ConcentrationMeasurementServer } from '@matter/main/behaviors/pm10-
|
|
|
104
76
|
import { RadonConcentrationMeasurementServer } from '@matter/main/behaviors/radon-concentration-measurement';
|
|
105
77
|
import { TotalVolatileOrganicCompoundsConcentrationMeasurementServer } from '@matter/main/behaviors/total-volatile-organic-compounds-concentration-measurement';
|
|
106
78
|
import { DeviceEnergyManagementServer } from '@matter/node/behaviors/device-energy-management';
|
|
107
|
-
// Matterbridge
|
|
108
79
|
import { deepCopy, deepEqual, isValidArray } from './utils/export.js';
|
|
109
80
|
import { MatterbridgeIdentifyServer, MatterbridgeOnOffServer, MatterbridgeLevelControlServer, MatterbridgeColorControlServer, MatterbridgeLiftWindowCoveringServer, MatterbridgeThermostatServer, MatterbridgeFanControlServer, MatterbridgeDoorLockServer, MatterbridgeModeSelectServer, MatterbridgeValveConfigurationAndControlServer, MatterbridgeSmokeCoAlarmServer, MatterbridgeBooleanStateConfigurationServer, MatterbridgeOperationalStateServer, MatterbridgeDeviceEnergyManagementModeServer, } from './matterbridgeBehaviors.js';
|
|
110
|
-
/**
|
|
111
|
-
* Capitalizes the first letter of a string.
|
|
112
|
-
*
|
|
113
|
-
* @param {string} name - The string to capitalize.
|
|
114
|
-
* @returns {string} The string with the first letter capitalized.
|
|
115
|
-
*/
|
|
116
81
|
export function capitalizeFirstLetter(name) {
|
|
117
82
|
if (!name)
|
|
118
83
|
return name;
|
|
119
84
|
return name.charAt(0).toUpperCase() + name.slice(1);
|
|
120
85
|
}
|
|
121
|
-
/**
|
|
122
|
-
* Lowercases the first letter of a string.
|
|
123
|
-
*
|
|
124
|
-
* @param {string} name - The string to lowercase the first letter of.
|
|
125
|
-
* @returns {string} The string with the first letter lowercased.
|
|
126
|
-
*/
|
|
127
86
|
export function lowercaseFirstLetter(name) {
|
|
128
87
|
if (!name)
|
|
129
88
|
return name;
|
|
130
89
|
return name.charAt(0).toLowerCase() + name.slice(1);
|
|
131
90
|
}
|
|
132
|
-
/**
|
|
133
|
-
* Checks if the device name contains non-Latin characters.
|
|
134
|
-
*
|
|
135
|
-
* @param {string} deviceName - The name of the device to check.
|
|
136
|
-
* @returns {boolean} Returns true if the device name contains non-Latin characters, false otherwise.
|
|
137
|
-
*/
|
|
138
91
|
export function checkNotLatinCharacters(deviceName) {
|
|
139
92
|
const nonLatinRegexList = [
|
|
140
|
-
/[\u0400-\u04FF\u0500-\u052F]/,
|
|
141
|
-
/[\u2E80-\u9FFF]/,
|
|
142
|
-
/[\uAC00-\uD7AF]/,
|
|
143
|
-
/[\u0600-\u06FF\u0750-\u077F]/,
|
|
144
|
-
/[\u0590-\u05FF]/,
|
|
145
|
-
/[\u0900-\u097F]/,
|
|
146
|
-
/[\u0E00-\u0E7F]/,
|
|
147
|
-
/[\u1200-\u137F]/,
|
|
93
|
+
/[\u0400-\u04FF\u0500-\u052F]/,
|
|
94
|
+
/[\u2E80-\u9FFF]/,
|
|
95
|
+
/[\uAC00-\uD7AF]/,
|
|
96
|
+
/[\u0600-\u06FF\u0750-\u077F]/,
|
|
97
|
+
/[\u0590-\u05FF]/,
|
|
98
|
+
/[\u0900-\u097F]/,
|
|
99
|
+
/[\u0E00-\u0E7F]/,
|
|
100
|
+
/[\u1200-\u137F]/,
|
|
148
101
|
];
|
|
149
102
|
return nonLatinRegexList.some((regex) => regex.test(deviceName));
|
|
150
103
|
}
|
|
151
|
-
/**
|
|
152
|
-
* Generates a unique ID based on the device name.
|
|
153
|
-
*
|
|
154
|
-
* @param {string} deviceName - The name of the device to generate a unique ID for.
|
|
155
|
-
* @returns {string} A unique ID generated from the device name using MD5 hashing.
|
|
156
|
-
*/
|
|
157
104
|
export function generateUniqueId(deviceName) {
|
|
158
|
-
return createHash('md5').update(deviceName).digest('hex');
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Generates a unique ID based on four parameters.
|
|
162
|
-
*
|
|
163
|
-
* @param {string} param1 - The first parameter.
|
|
164
|
-
* @param {string} param2 - The second parameter.
|
|
165
|
-
* @param {string} param3 - The third parameter.
|
|
166
|
-
* @param {string} param4 - The fourth parameter.
|
|
167
|
-
* @returns {string} A unique ID generated from the concatenation of the parameters using MD5 hashing.
|
|
168
|
-
*/
|
|
105
|
+
return createHash('md5').update(deviceName).digest('hex');
|
|
106
|
+
}
|
|
169
107
|
export function createUniqueId(param1, param2, param3, param4) {
|
|
170
108
|
const hash = createHash('md5');
|
|
171
109
|
hash.update(param1 + param2 + param3 + param4);
|
|
172
110
|
return hash.digest('hex');
|
|
173
111
|
}
|
|
174
|
-
/**
|
|
175
|
-
* Maps a list of ClusterId to Behavior.Type for server clusters.
|
|
176
|
-
*
|
|
177
|
-
* @param {ClusterId[]} clusterServerList - The list of ClusterId to map.
|
|
178
|
-
* @returns {Behavior.Type[]} An array of Behavior.Type corresponding to the ClusterId in the server list.
|
|
179
|
-
*/
|
|
180
112
|
export function getBehaviourTypesFromClusterServerIds(clusterServerList) {
|
|
181
|
-
// Map Server ClusterId to Behavior.Type
|
|
182
113
|
const behaviorTypes = [];
|
|
183
114
|
clusterServerList.forEach((clusterId) => {
|
|
184
115
|
behaviorTypes.push(getBehaviourTypeFromClusterServerId(clusterId));
|
|
185
116
|
});
|
|
186
117
|
return behaviorTypes;
|
|
187
118
|
}
|
|
188
|
-
/**
|
|
189
|
-
* Maps a list of ClusterId to Behavior.Type for client clusters.
|
|
190
|
-
*
|
|
191
|
-
* @param {ClusterId[]} clusterClientList - The list of ClusterId to map.
|
|
192
|
-
* @returns {Behavior.Type[]} An array of Behavior.Type corresponding to the ClusterId in the client list.
|
|
193
|
-
*/
|
|
194
119
|
export function getBehaviourTypesFromClusterClientIds(clusterClientList) {
|
|
195
|
-
// Map Client ClusterId to Behavior.Type
|
|
196
120
|
const behaviorTypes = [];
|
|
197
121
|
clusterClientList.forEach((_clusterId) => {
|
|
198
|
-
// behaviorTypes.push(getBehaviourTypeFromClusterClientId(clusterId));
|
|
199
122
|
});
|
|
200
123
|
return behaviorTypes;
|
|
201
124
|
}
|
|
202
|
-
/**
|
|
203
|
-
* Maps a ClusterId to a Behavior.Type for server clusters.
|
|
204
|
-
*
|
|
205
|
-
* @param {ClusterId} clusterId - The ClusterId to map.
|
|
206
|
-
* @returns {Behavior.Type} The corresponding Behavior.Type for the given ClusterId.
|
|
207
|
-
*/
|
|
208
125
|
export function getBehaviourTypeFromClusterServerId(clusterId) {
|
|
209
|
-
// Map ClusterId to Server Behavior.Type
|
|
210
126
|
if (clusterId === PowerSource.Cluster.id)
|
|
211
127
|
return PowerSourceServer.with(PowerSource.Feature.Wired);
|
|
212
128
|
if (clusterId === UserLabel.Cluster.id)
|
|
@@ -297,22 +213,8 @@ export function getBehaviourTypeFromClusterServerId(clusterId) {
|
|
|
297
213
|
return MatterbridgeDeviceEnergyManagementModeServer;
|
|
298
214
|
return MatterbridgeIdentifyServer;
|
|
299
215
|
}
|
|
300
|
-
/**
|
|
301
|
-
* Maps a ClusterId to a Behavior.Type for client clusters.
|
|
302
|
-
*
|
|
303
|
-
* @param {ClusterId} _clusterId - The ClusterId to map.
|
|
304
|
-
*/
|
|
305
216
|
export function getBehaviourTypeFromClusterClientId(_clusterId) {
|
|
306
|
-
|
|
307
|
-
// return IdentifyClient;
|
|
308
|
-
}
|
|
309
|
-
/**
|
|
310
|
-
* Retrieves the Behavior.Type for a given cluster from the endpoint's supported behaviors.
|
|
311
|
-
*
|
|
312
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to retrieve the behavior from.
|
|
313
|
-
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to retrieve the behavior for.
|
|
314
|
-
* @returns {Behavior.Type | undefined} The Behavior.Type for the given cluster, or undefined if not found.
|
|
315
|
-
*/
|
|
217
|
+
}
|
|
316
218
|
export function getBehavior(endpoint, cluster) {
|
|
317
219
|
let behavior;
|
|
318
220
|
if (typeof cluster === 'string') {
|
|
@@ -329,18 +231,6 @@ export function getBehavior(endpoint, cluster) {
|
|
|
329
231
|
}
|
|
330
232
|
return behavior;
|
|
331
233
|
}
|
|
332
|
-
/**
|
|
333
|
-
* Invokes a command on the specified behavior of the endpoint. Used ONLY in Jest tests.
|
|
334
|
-
*
|
|
335
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to invoke the command on.
|
|
336
|
-
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to invoke the command on.
|
|
337
|
-
* @param {keyof MatterbridgeEndpointCommands} command - The command to invoke.
|
|
338
|
-
* @param {Record<string, boolean | number | bigint | string | object | null>} [params] - The parameters to pass to the command.
|
|
339
|
-
*
|
|
340
|
-
* @returns {Promise<boolean>} A promise that resolves to true if the command was invoked successfully, false otherwise.
|
|
341
|
-
*
|
|
342
|
-
* @deprecated Used ONLY in Jest tests.
|
|
343
|
-
*/
|
|
344
234
|
export async function invokeBehaviorCommand(endpoint, cluster, command, params) {
|
|
345
235
|
const behaviorId = getBehavior(endpoint, cluster)?.id;
|
|
346
236
|
if (!behaviorId) {
|
|
@@ -348,7 +238,6 @@ export async function invokeBehaviorCommand(endpoint, cluster, command, params)
|
|
|
348
238
|
return false;
|
|
349
239
|
}
|
|
350
240
|
await endpoint.act((agent) => {
|
|
351
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
352
241
|
const behavior = agent[behaviorId];
|
|
353
242
|
if (!(command in behavior) || typeof behavior[command] !== 'function') {
|
|
354
243
|
endpoint.log?.error(`invokeBehaviorCommand error: command ${hk}${command}${er} not found on agent for endpoint ${or}${endpoint.maybeId}${er}:${or}${endpoint.maybeNumber}${er}`);
|
|
@@ -358,18 +247,6 @@ export async function invokeBehaviorCommand(endpoint, cluster, command, params)
|
|
|
358
247
|
});
|
|
359
248
|
return true;
|
|
360
249
|
}
|
|
361
|
-
/**
|
|
362
|
-
* Invokes the subscription handler on the specified cluster and attribute of the endpoint. Used ONLY in Jest tests.
|
|
363
|
-
*
|
|
364
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to invoke the subscription handler on.
|
|
365
|
-
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to invoke the subscription handler on.
|
|
366
|
-
* @param {string} attribute - The attribute to invoke the subscription handler on.
|
|
367
|
-
* @param {unknown} newValue - The new value of the attribute.
|
|
368
|
-
* @param {unknown} oldValue - The old value of the attribute.
|
|
369
|
-
*
|
|
370
|
-
* @returns {Promise<boolean>} A promise that resolves to true if the subscription handler was invoked successfully, false otherwise.
|
|
371
|
-
* @deprecated Used ONLY in Jest tests.
|
|
372
|
-
*/
|
|
373
250
|
export async function invokeSubscribeHandler(endpoint, cluster, attribute, newValue, oldValue) {
|
|
374
251
|
const event = attribute + '$Changed';
|
|
375
252
|
const clusterName = getBehavior(endpoint, cluster)?.id;
|
|
@@ -386,17 +263,9 @@ export async function invokeSubscribeHandler(endpoint, cluster, attribute, newVa
|
|
|
386
263
|
endpoint.log.error(`invokeSubscribeHandler ${hk}${event}${er} error: cluster ${clusterName} not found on endpoint ${or}${endpoint.id}${er}:${or}${endpoint.number}${er}`);
|
|
387
264
|
return false;
|
|
388
265
|
}
|
|
389
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
390
|
-
// @ts-ignore
|
|
391
266
|
await endpoint.act((agent) => agent[clusterName].events[event].emit(newValue, oldValue, { ...agent.context, offline: false }));
|
|
392
267
|
return true;
|
|
393
268
|
}
|
|
394
|
-
/**
|
|
395
|
-
* Adds required cluster servers to the specified endpoint based on the device types.
|
|
396
|
-
*
|
|
397
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to add the required cluster servers to.
|
|
398
|
-
* @returns {void}
|
|
399
|
-
*/
|
|
400
269
|
export function addRequiredClusterServers(endpoint) {
|
|
401
270
|
const requiredServerList = [];
|
|
402
271
|
endpoint.log.debug(`addRequiredClusterServers for ${CYAN}${endpoint.maybeId}${db}`);
|
|
@@ -411,12 +280,6 @@ export function addRequiredClusterServers(endpoint) {
|
|
|
411
280
|
});
|
|
412
281
|
addClusterServers(endpoint, requiredServerList);
|
|
413
282
|
}
|
|
414
|
-
/**
|
|
415
|
-
* Adds optional cluster servers to the specified endpoint based on the device types.
|
|
416
|
-
*
|
|
417
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to add the optional cluster servers to.
|
|
418
|
-
* @returns {void}
|
|
419
|
-
*/
|
|
420
283
|
export function addOptionalClusterServers(endpoint) {
|
|
421
284
|
const optionalServerList = [];
|
|
422
285
|
endpoint.log.debug(`addOptionalClusterServers for ${CYAN}${endpoint.maybeId}${db}`);
|
|
@@ -431,12 +294,6 @@ export function addOptionalClusterServers(endpoint) {
|
|
|
431
294
|
});
|
|
432
295
|
addClusterServers(endpoint, optionalServerList);
|
|
433
296
|
}
|
|
434
|
-
/**
|
|
435
|
-
* Adds cluster servers to the specified endpoint based on the provided server list.
|
|
436
|
-
*
|
|
437
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to add the cluster servers to.
|
|
438
|
-
* @param {ClusterId[]} serverList - The list of cluster IDs to add.
|
|
439
|
-
*/
|
|
440
297
|
export function addClusterServers(endpoint, serverList) {
|
|
441
298
|
if (serverList.includes(PowerSource.Cluster.id))
|
|
442
299
|
endpoint.createDefaultPowerSourceWiredClusterServer();
|
|
@@ -517,13 +374,6 @@ export function addClusterServers(endpoint, serverList) {
|
|
|
517
374
|
if (serverList.includes(DeviceEnergyManagementMode.Cluster.id))
|
|
518
375
|
endpoint.createDefaultDeviceEnergyManagementModeClusterServer();
|
|
519
376
|
}
|
|
520
|
-
/**
|
|
521
|
-
* Adds a fixed label to the FixedLabel cluster. The FixedLabel cluster is created if it does not exist.
|
|
522
|
-
*
|
|
523
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to add the cluster servers to.
|
|
524
|
-
* @param {string} label - The label to add.
|
|
525
|
-
* @param {string} value - The value of the label.
|
|
526
|
-
*/
|
|
527
377
|
export async function addFixedLabel(endpoint, label, value) {
|
|
528
378
|
if (!endpoint.hasClusterServer(FixedLabel.Cluster.id)) {
|
|
529
379
|
endpoint.log.debug(`addFixedLabel: add cluster ${hk}FixedLabel${db}:${hk}fixedLabel${db} with label ${CYAN}${label}${db} value ${CYAN}${value}${db}`);
|
|
@@ -540,13 +390,6 @@ export async function addFixedLabel(endpoint, label, value) {
|
|
|
540
390
|
await endpoint.setAttribute(FixedLabel.Cluster.id, 'labelList', labelList, endpoint.log);
|
|
541
391
|
}
|
|
542
392
|
}
|
|
543
|
-
/**
|
|
544
|
-
* Adds a user label to the UserLabel cluster. The UserLabel cluster is created if it does not exist.
|
|
545
|
-
*
|
|
546
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to add the cluster servers to.
|
|
547
|
-
* @param {string} label - The label to add.
|
|
548
|
-
* @param {string} value - The value of the label.
|
|
549
|
-
*/
|
|
550
393
|
export async function addUserLabel(endpoint, label, value) {
|
|
551
394
|
if (!endpoint.hasClusterServer(UserLabel.Cluster.id)) {
|
|
552
395
|
endpoint.log.debug(`addUserLabel: add cluster ${hk}UserLabel${db}:${hk}userLabel${db} with label ${CYAN}${label}${db} value ${CYAN}${value}${db}`);
|
|
@@ -563,48 +406,16 @@ export async function addUserLabel(endpoint, label, value) {
|
|
|
563
406
|
await endpoint.setAttribute(UserLabel.Cluster.id, 'labelList', labelList, endpoint.log);
|
|
564
407
|
}
|
|
565
408
|
}
|
|
566
|
-
/**
|
|
567
|
-
* Returns the options for a given behavior type.
|
|
568
|
-
*
|
|
569
|
-
* @param {T} type - The behavior type.
|
|
570
|
-
* @param {Behavior.Options<T>} options - The options for the behavior type.
|
|
571
|
-
* @returns {Behavior.Options<T>} The options for the behavior type.
|
|
572
|
-
*/
|
|
573
409
|
export function optionsFor(type, options) {
|
|
574
410
|
return options;
|
|
575
411
|
}
|
|
576
|
-
/**
|
|
577
|
-
* Retrieves the cluster name by its ID.
|
|
578
|
-
*
|
|
579
|
-
* @param {Endpoint} endpoint - The endpoint to retrieve the cluster name from.
|
|
580
|
-
* @param {ClusterId} cluster - The ID of the cluster.
|
|
581
|
-
* @returns {string} The name of the cluster.
|
|
582
|
-
*/
|
|
583
412
|
export function getClusterId(endpoint, cluster) {
|
|
584
413
|
return endpoint.behaviors.supported[lowercaseFirstLetter(cluster)]?.schema?.id;
|
|
585
414
|
}
|
|
586
|
-
/**
|
|
587
|
-
* Retrieves the ID of an attribute from a cluster behavior.
|
|
588
|
-
*
|
|
589
|
-
* @param {Endpoint} endpoint - The endpoint to retrieve the attribute ID from.
|
|
590
|
-
* @param {string} cluster - The name of the cluster.
|
|
591
|
-
* @param {string} attribute - The name of the attribute.
|
|
592
|
-
* @returns {number | undefined} The ID of the attribute, or undefined if not found.
|
|
593
|
-
*/
|
|
594
415
|
export function getAttributeId(endpoint, cluster, attribute) {
|
|
595
416
|
const clusterBehavior = endpoint.behaviors.supported[lowercaseFirstLetter(cluster)];
|
|
596
417
|
return clusterBehavior?.cluster?.attributes[lowercaseFirstLetter(attribute)]?.id;
|
|
597
418
|
}
|
|
598
|
-
/**
|
|
599
|
-
* Retrieves the value of the provided attribute from the given cluster.
|
|
600
|
-
*
|
|
601
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to retrieve the attribute from.
|
|
602
|
-
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to retrieve the attribute from.
|
|
603
|
-
* @param {string} attribute - The name of the attribute to retrieve.
|
|
604
|
-
* @param {AnsiLogger} [log] - (Optional) The logger to use for logging the retrieve. Errors are logged to the endpoint logger.
|
|
605
|
-
* @returns {any} The value of the attribute, or undefined if the attribute is not found.
|
|
606
|
-
*/
|
|
607
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
608
419
|
export function getAttribute(endpoint, cluster, attribute, log) {
|
|
609
420
|
const clusterName = getBehavior(endpoint, cluster)?.id;
|
|
610
421
|
if (!clusterName) {
|
|
@@ -627,16 +438,6 @@ export function getAttribute(endpoint, cluster, attribute, log) {
|
|
|
627
438
|
log?.info(`${db}Get endpoint ${or}${endpoint.id}${db}:${or}${endpoint.number}${db} attribute ${hk}${capitalizeFirstLetter(clusterName)}${db}.${hk}${attribute}${db} value ${YELLOW}${value !== null && typeof value === 'object' ? debugStringify(value) : value}${db}`);
|
|
628
439
|
return value;
|
|
629
440
|
}
|
|
630
|
-
/**
|
|
631
|
-
* Sets the value of an attribute on a cluster server.
|
|
632
|
-
*
|
|
633
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to set the attribute on.
|
|
634
|
-
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to set the attribute on.
|
|
635
|
-
* @param {string} attribute - The name of the attribute.
|
|
636
|
-
* @param {boolean | number | bigint | string | object | null} value - The value to set for the attribute.
|
|
637
|
-
* @param {AnsiLogger} [log] - (Optional) The logger to use for logging the set. Errors are logged to the endpoint logger.
|
|
638
|
-
* @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the attribute was successfully set.
|
|
639
|
-
*/
|
|
640
441
|
export async function setAttribute(endpoint, cluster, attribute, value, log) {
|
|
641
442
|
const clusterName = getBehavior(endpoint, cluster)?.id;
|
|
642
443
|
if (!clusterName) {
|
|
@@ -662,16 +463,6 @@ export async function setAttribute(endpoint, cluster, attribute, value, log) {
|
|
|
662
463
|
`to ${YELLOW}${value !== null && typeof value === 'object' ? debugStringify(value) : value}${db}`);
|
|
663
464
|
return true;
|
|
664
465
|
}
|
|
665
|
-
/**
|
|
666
|
-
* Sets the value of an attribute on a cluster server.
|
|
667
|
-
*
|
|
668
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to update the attribute on.
|
|
669
|
-
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to update the attribute on.
|
|
670
|
-
* @param {string} attribute - The name of the attribute.
|
|
671
|
-
* @param {boolean | number | bigint | string | object | null} value - The value to set for the attribute.
|
|
672
|
-
* @param {AnsiLogger} [log] - (Optional) The logger to use for logging the update. Errors are logged to the endpoint logger.
|
|
673
|
-
* @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the attribute was successfully set.
|
|
674
|
-
*/
|
|
675
466
|
export async function updateAttribute(endpoint, cluster, attribute, value, log) {
|
|
676
467
|
const clusterName = getBehavior(endpoint, cluster)?.id;
|
|
677
468
|
if (!clusterName) {
|
|
@@ -702,24 +493,7 @@ export async function updateAttribute(endpoint, cluster, attribute, value, log)
|
|
|
702
493
|
`to ${YELLOW}${value !== null && typeof value === 'object' ? debugStringify(value) : value}${db}`);
|
|
703
494
|
return true;
|
|
704
495
|
}
|
|
705
|
-
|
|
706
|
-
* Subscribes to the provided attribute on a cluster.
|
|
707
|
-
*
|
|
708
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to subscribe the attribute to.
|
|
709
|
-
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to subscribe the attribute to.
|
|
710
|
-
* @param {string} attribute - The name of the attribute to subscribe to.
|
|
711
|
-
* @param {(newValue: any, oldValue: any, context: ActionContext) => void} listener - A callback function that will be called when the attribute value changes. When context.offline === true then the change is locally generated and not from the controller.
|
|
712
|
-
* @param {AnsiLogger} [log] - Optional logger for logging errors and information.
|
|
713
|
-
* @returns {boolean} - A boolean indicating whether the subscription was successful.
|
|
714
|
-
*
|
|
715
|
-
* @remarks The listener function (cannot be async) will receive three parameters:
|
|
716
|
-
* - `newValue`: The new value of the attribute.
|
|
717
|
-
* - `oldValue`: The old value of the attribute.
|
|
718
|
-
* - `context`: The action context, which includes information about the action that triggered the change. When context.offline === true then the change is locally generated and not from the controller.
|
|
719
|
-
*/
|
|
720
|
-
export async function subscribeAttribute(endpoint, cluster, attribute,
|
|
721
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
722
|
-
listener, log) {
|
|
496
|
+
export async function subscribeAttribute(endpoint, cluster, attribute, listener, log) {
|
|
723
497
|
const clusterName = getBehavior(endpoint, cluster)?.id;
|
|
724
498
|
if (!clusterName) {
|
|
725
499
|
endpoint.log.error(`subscribeAttribute ${hk}${attribute}${er} error: cluster not found on endpoint ${or}${endpoint.maybeId}${er}:${or}${endpoint.maybeNumber}${er}`);
|
|
@@ -729,7 +503,6 @@ listener, log) {
|
|
|
729
503
|
endpoint.log.debug(`subscribeAttribute ${hk}${clusterName}.${attribute}${db}: Endpoint ${or}${endpoint.maybeId}${db}:${or}${endpoint.maybeNumber}${db} is in the ${BLUE}${endpoint.construction.status}${db} state`);
|
|
730
504
|
await endpoint.construction.ready;
|
|
731
505
|
}
|
|
732
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
733
506
|
const events = endpoint.events;
|
|
734
507
|
attribute = lowercaseFirstLetter(attribute) + '$Changed';
|
|
735
508
|
if (!(clusterName in events) || !(attribute in events[clusterName])) {
|
|
@@ -740,17 +513,6 @@ listener, log) {
|
|
|
740
513
|
log?.info(`${db}Subscribed endpoint ${or}${endpoint.id}${db}:${or}${endpoint.number}${db} attribute ${hk}${capitalizeFirstLetter(clusterName)}${db}.${hk}${attribute}${db}`);
|
|
741
514
|
return true;
|
|
742
515
|
}
|
|
743
|
-
/**
|
|
744
|
-
* Triggers an event on the specified cluster.
|
|
745
|
-
*
|
|
746
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to trigger the event on.
|
|
747
|
-
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The ID of the cluster.
|
|
748
|
-
* @param {string} event - The name of the event to trigger.
|
|
749
|
-
* @param {Record<string, boolean | number | bigint | string | object | undefined | null>} payload - The payload to pass to the event.
|
|
750
|
-
* @param {AnsiLogger} [log] - Optional logger for logging information.
|
|
751
|
-
*
|
|
752
|
-
* @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the event was successfully triggered.
|
|
753
|
-
*/
|
|
754
516
|
export async function triggerEvent(endpoint, cluster, event, payload, log) {
|
|
755
517
|
const clusterName = getBehavior(endpoint, cluster)?.id;
|
|
756
518
|
if (!clusterName) {
|
|
@@ -761,24 +523,15 @@ export async function triggerEvent(endpoint, cluster, event, payload, log) {
|
|
|
761
523
|
endpoint.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`);
|
|
762
524
|
return false;
|
|
763
525
|
}
|
|
764
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
765
526
|
const events = endpoint.events;
|
|
766
527
|
if (!(clusterName in events) || !(event in events[clusterName])) {
|
|
767
528
|
endpoint.log.error(`triggerEvent ${hk}${event}${er} error: cluster ${clusterName} not found on endpoint ${or}${endpoint.id}${er}:${or}${endpoint.number}${er}`);
|
|
768
529
|
return false;
|
|
769
530
|
}
|
|
770
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
771
|
-
// @ts-ignore
|
|
772
531
|
await endpoint.act((agent) => agent[clusterName].events[event].emit(payload, agent.context));
|
|
773
532
|
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} `);
|
|
774
533
|
return true;
|
|
775
534
|
}
|
|
776
|
-
/**
|
|
777
|
-
* Get the default OperationalState Cluster Server.
|
|
778
|
-
*
|
|
779
|
-
* @param {OperationalState.OperationalStateEnum} operationalState - The initial operational state.
|
|
780
|
-
* @returns {Behavior.Options<MatterbridgeOperationalStateServer>} - The default options for the OperationalState cluster server.
|
|
781
|
-
*/
|
|
782
535
|
export function getDefaultOperationalStateClusterServer(operationalState = OperationalState.OperationalStateEnum.Stopped) {
|
|
783
536
|
return optionsFor(MatterbridgeOperationalStateServer, {
|
|
784
537
|
phaseList: [],
|
|
@@ -793,14 +546,6 @@ export function getDefaultOperationalStateClusterServer(operationalState = Opera
|
|
|
793
546
|
operationalError: { errorStateId: OperationalState.ErrorState.NoError, errorStateLabel: 'No error', errorStateDetails: 'Fully operational' },
|
|
794
547
|
});
|
|
795
548
|
}
|
|
796
|
-
/**
|
|
797
|
-
* Get the default TemperatureMeasurement cluster server options.
|
|
798
|
-
*
|
|
799
|
-
* @param {number | null} measuredValue - The measured value of the temperature x 100.
|
|
800
|
-
* @param {number | null} minMeasuredValue - The minimum measured value of the temperature x 100.
|
|
801
|
-
* @param {number | null} maxMeasuredValue - The maximum measured value of the temperature x 100.
|
|
802
|
-
* @returns {Behavior.Options<MatterbridgeTemperatureMeasurementServer>} - The default options for the TemperatureMeasurement cluster server.
|
|
803
|
-
*/
|
|
804
549
|
export function getDefaultTemperatureMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
805
550
|
return optionsFor(TemperatureMeasurementServer, {
|
|
806
551
|
measuredValue,
|
|
@@ -809,14 +554,6 @@ export function getDefaultTemperatureMeasurementClusterServer(measuredValue = nu
|
|
|
809
554
|
tolerance: 0,
|
|
810
555
|
});
|
|
811
556
|
}
|
|
812
|
-
/**
|
|
813
|
-
* Get the default RelativeHumidityMeasurement cluster server options.
|
|
814
|
-
*
|
|
815
|
-
* @param {number | null} measuredValue - The measured value of the relative humidity x 100.
|
|
816
|
-
* @param {number | null} minMeasuredValue - The minimum measured value of the relative humidity x 100.
|
|
817
|
-
* @param {number | null} maxMeasuredValue - The maximum measured value of the relative humidity x 100.
|
|
818
|
-
* @returns {Behavior.Options<MatterbridgeRelativeHumidityMeasurementServer>} - The default options for the RelativeHumidityMeasurement cluster server.
|
|
819
|
-
*/
|
|
820
557
|
export function getDefaultRelativeHumidityMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
821
558
|
return optionsFor(RelativeHumidityMeasurementServer, {
|
|
822
559
|
measuredValue,
|
|
@@ -825,14 +562,6 @@ export function getDefaultRelativeHumidityMeasurementClusterServer(measuredValue
|
|
|
825
562
|
tolerance: 0,
|
|
826
563
|
});
|
|
827
564
|
}
|
|
828
|
-
/**
|
|
829
|
-
* Get the default PressureMeasurement cluster server options.
|
|
830
|
-
*
|
|
831
|
-
* @param {number | null} measuredValue - The measured value for the pressure in kPa x 10.
|
|
832
|
-
* @param {number | null} minMeasuredValue - The minimum measured value for the pressure in kPa x 10.
|
|
833
|
-
* @param {number | null} maxMeasuredValue - The maximum measured value for the pressure in kPa x 10.
|
|
834
|
-
* @returns {Behavior.Options<MatterbridgePressureMeasurementServer>} - The default options for the PressureMeasurement cluster server.
|
|
835
|
-
*/
|
|
836
565
|
export function getDefaultPressureMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
837
566
|
return optionsFor(PressureMeasurementServer, {
|
|
838
567
|
measuredValue,
|
|
@@ -841,22 +570,6 @@ export function getDefaultPressureMeasurementClusterServer(measuredValue = null,
|
|
|
841
570
|
tolerance: 0,
|
|
842
571
|
});
|
|
843
572
|
}
|
|
844
|
-
/**
|
|
845
|
-
* Get the default IlluminanceMeasurement cluster server options.
|
|
846
|
-
*
|
|
847
|
-
* @param {number | null} measuredValue - The measured value of illuminance.
|
|
848
|
-
* @param {number | null} minMeasuredValue - The minimum measured value of illuminance.
|
|
849
|
-
* @param {number | null} maxMeasuredValue - The maximum measured value of illuminance.
|
|
850
|
-
*
|
|
851
|
-
* @returns {Behavior.Options<MatterbridgeIlluminanceMeasurementServer>} - The default options for the IlluminanceMeasurement cluster server.
|
|
852
|
-
*
|
|
853
|
-
* @remarks The default value for the illuminance measurement is null.
|
|
854
|
-
* This attribute SHALL indicate the illuminance in Lux (symbol lx) as follows:
|
|
855
|
-
* • MeasuredValue = 10,000 x log10(illuminance) + 1,
|
|
856
|
-
* where 1 lx <= illuminance <= 3.576 Mlx, corresponding to a MeasuredValue in the range 1 to 0xFFFE.
|
|
857
|
-
* • 0 indicates a value of illuminance that is too low to be measured
|
|
858
|
-
* • null indicates that the illuminance measurement is invalid.
|
|
859
|
-
*/
|
|
860
573
|
export function getDefaultIlluminanceMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
861
574
|
return optionsFor(IlluminanceMeasurementServer, {
|
|
862
575
|
measuredValue,
|
|
@@ -865,14 +578,6 @@ export function getDefaultIlluminanceMeasurementClusterServer(measuredValue = nu
|
|
|
865
578
|
tolerance: 0,
|
|
866
579
|
});
|
|
867
580
|
}
|
|
868
|
-
/**
|
|
869
|
-
* Get the default FlowMeasurement cluster server options.
|
|
870
|
-
*
|
|
871
|
-
* @param {number | null} measuredValue - The measured value of the flow in 10 x m3/h.
|
|
872
|
-
* @param {number | null} minMeasuredValue - The minimum measured value of the flow in 10 x m3/h.
|
|
873
|
-
* @param {number | null} maxMeasuredValue - The maximum measured value of the flow in 10 x m3/h.
|
|
874
|
-
* @returns {Behavior.Options<MatterbridgeFlowMeasurementServer>} - The default options for the FlowMeasurement cluster server.
|
|
875
|
-
*/
|
|
876
581
|
export function getDefaultFlowMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
877
582
|
return optionsFor(FlowMeasurementServer, {
|
|
878
583
|
measuredValue,
|
|
@@ -881,20 +586,6 @@ export function getDefaultFlowMeasurementClusterServer(measuredValue = null, min
|
|
|
881
586
|
tolerance: 0,
|
|
882
587
|
});
|
|
883
588
|
}
|
|
884
|
-
/**
|
|
885
|
-
* Get the default OccupancySensing cluster server options.
|
|
886
|
-
*
|
|
887
|
-
* @param {boolean} occupied - A boolean indicating whether the occupancy is occupied or not. Default is false.
|
|
888
|
-
* @param {number} holdTime - The hold time in seconds. Default is 30.
|
|
889
|
-
* @param {number} holdTimeMin - The minimum hold time in seconds. Default is 1.
|
|
890
|
-
* @param {number} holdTimeMax - The maximum hold time in seconds. Default is 300.
|
|
891
|
-
* @returns {Behavior.Options<MatterbridgeOccupancySensingServer>} - The default options for the OccupancySensing cluster server.
|
|
892
|
-
*
|
|
893
|
-
* @remarks The default value for the occupancy sensor type is PIR.
|
|
894
|
-
* Servers SHALL set these attributes for backward compatibility with clients implementing a cluster revision <= 4 as
|
|
895
|
-
* described in OccupancySensorType and OccupancySensorTypeBitmap Attributes.
|
|
896
|
-
* This replaces the 9 legacy attributes PIROccupiedToUnoccupiedDelay through PhysicalContactUnoccupiedToOccupiedThreshold.
|
|
897
|
-
*/
|
|
898
589
|
export function getDefaultOccupancySensingClusterServer(occupied = false, holdTime = 30, holdTimeMin = 1, holdTimeMax = 300) {
|
|
899
590
|
return optionsFor(OccupancySensingServer.with(OccupancySensing.Feature.PassiveInfrared), {
|
|
900
591
|
occupancy: { occupied },
|
|
@@ -906,4 +597,3 @@ export function getDefaultOccupancySensingClusterServer(occupied = false, holdTi
|
|
|
906
597
|
holdTimeLimits: { holdTimeMin, holdTimeMax, holdTimeDefault: holdTime },
|
|
907
598
|
});
|
|
908
599
|
}
|
|
909
|
-
//# sourceMappingURL=matterbridgeEndpointHelpers.js.map
|