matterbridge 3.0.3 → 3.0.4-dev-20250525-b1cbfb7
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 +25 -4
- package/README.md +6 -12
- package/dist/cli.js +2 -37
- package/dist/cluster/export.js +0 -2
- package/dist/defaultConfigSchema.js +0 -23
- package/dist/deviceManager.js +1 -94
- package/dist/frontend.js +100 -437
- package/dist/helpers.js +9 -53
- package/dist/index.js +1 -27
- 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 +1 -3
- package/dist/matter/types.js +0 -2
- package/dist/matterbridge.js +47 -747
- package/dist/matterbridgeAccessoryPlatform.js +0 -34
- package/dist/matterbridgeBehaviors.js +43 -61
- package/dist/matterbridgeDeviceTypes.js +15 -563
- package/dist/matterbridgeDynamicPlatform.js +0 -34
- package/dist/matterbridgeEndpoint.js +68 -837
- package/dist/matterbridgeEndpointHelpers.js +33 -204
- package/dist/matterbridgePlatform.js +7 -225
- package/dist/matterbridgeTypes.js +0 -24
- package/dist/pluginManager.js +3 -264
- package/dist/roboticVacuumCleaner.js +3 -78
- package/dist/shelly.js +7 -155
- package/dist/storage/export.js +0 -1
- package/dist/update.js +0 -53
- package/dist/utils/colorUtils.js +2 -205
- package/dist/utils/commandLine.js +0 -53
- package/dist/utils/copyDirectory.js +1 -37
- package/dist/utils/createZip.js +2 -42
- package/dist/utils/deepCopy.js +0 -38
- package/dist/utils/deepEqual.js +1 -71
- package/dist/utils/export.js +0 -1
- package/dist/utils/hex.js +0 -57
- package/dist/utils/isvalid.js +0 -100
- package/dist/utils/network.js +5 -76
- package/dist/utils/wait.js +9 -58
- package/dist/waterHeater.js +0 -52
- package/npm-shrinkwrap.json +10 -10
- package/package.json +2 -3
- package/dist/cli.d.ts +0 -29
- 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 -114
- package/dist/deviceManager.d.ts.map +0 -1
- package/dist/deviceManager.js.map +0 -1
- package/dist/frontend.d.ts +0 -241
- package/dist/frontend.d.ts.map +0 -1
- package/dist/frontend.js.map +0 -1
- package/dist/helpers.d.ts +0 -47
- package/dist/helpers.d.ts.map +0 -1
- package/dist/helpers.js.map +0 -1
- package/dist/index.d.ts +0 -35
- 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 -445
- package/dist/matterbridge.d.ts.map +0 -1
- package/dist/matterbridge.js.map +0 -1
- package/dist/matterbridgeAccessoryPlatform.d.ts +0 -40
- package/dist/matterbridgeAccessoryPlatform.d.ts.map +0 -1
- package/dist/matterbridgeAccessoryPlatform.js.map +0 -1
- package/dist/matterbridgeBehaviors.d.ts +0 -1201
- package/dist/matterbridgeBehaviors.d.ts.map +0 -1
- package/dist/matterbridgeBehaviors.js.map +0 -1
- package/dist/matterbridgeDeviceTypes.d.ts +0 -629
- package/dist/matterbridgeDeviceTypes.d.ts.map +0 -1
- package/dist/matterbridgeDeviceTypes.js.map +0 -1
- package/dist/matterbridgeDynamicPlatform.d.ts +0 -40
- package/dist/matterbridgeDynamicPlatform.d.ts.map +0 -1
- package/dist/matterbridgeDynamicPlatform.js.map +0 -1
- package/dist/matterbridgeEndpoint.d.ts +0 -967
- package/dist/matterbridgeEndpoint.d.ts.map +0 -1
- package/dist/matterbridgeEndpoint.js.map +0 -1
- package/dist/matterbridgeEndpointHelpers.d.ts +0 -2728
- package/dist/matterbridgeEndpointHelpers.d.ts.map +0 -1
- package/dist/matterbridgeEndpointHelpers.js.map +0 -1
- package/dist/matterbridgePlatform.d.ts +0 -294
- package/dist/matterbridgePlatform.d.ts.map +0 -1
- package/dist/matterbridgePlatform.js.map +0 -1
- package/dist/matterbridgeTypes.d.ts +0 -188
- package/dist/matterbridgeTypes.d.ts.map +0 -1
- package/dist/matterbridgeTypes.js.map +0 -1
- package/dist/pluginManager.d.ts +0 -273
- package/dist/pluginManager.d.ts.map +0 -1
- package/dist/pluginManager.js.map +0 -1
- package/dist/roboticVacuumCleaner.d.ts +0 -82
- package/dist/roboticVacuumCleaner.d.ts.map +0 -1
- package/dist/roboticVacuumCleaner.js.map +0 -1
- package/dist/shelly.d.ts +0 -153
- 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 -58
- package/dist/update.d.ts.map +0 -1
- package/dist/update.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/commandLine.d.ts +0 -58
- package/dist/utils/commandLine.d.ts.map +0 -1
- package/dist/utils/commandLine.js.map +0 -1
- package/dist/utils/copyDirectory.d.ts +0 -32
- package/dist/utils/copyDirectory.d.ts.map +0 -1
- package/dist/utils/copyDirectory.js.map +0 -1
- package/dist/utils/createZip.d.ts +0 -38
- package/dist/utils/createZip.d.ts.map +0 -1
- package/dist/utils/createZip.js.map +0 -1
- package/dist/utils/deepCopy.d.ts +0 -31
- package/dist/utils/deepCopy.d.ts.map +0 -1
- package/dist/utils/deepCopy.js.map +0 -1
- package/dist/utils/deepEqual.d.ts +0 -53
- package/dist/utils/deepEqual.d.ts.map +0 -1
- package/dist/utils/deepEqual.js.map +0 -1
- package/dist/utils/export.d.ts +0 -11
- package/dist/utils/export.d.ts.map +0 -1
- package/dist/utils/export.js.map +0 -1
- package/dist/utils/hex.d.ts +0 -48
- package/dist/utils/hex.d.ts.map +0 -1
- package/dist/utils/hex.js.map +0 -1
- package/dist/utils/isvalid.d.ts +0 -102
- package/dist/utils/isvalid.d.ts.map +0 -1
- package/dist/utils/isvalid.js.map +0 -1
- package/dist/utils/network.d.ts +0 -69
- package/dist/utils/network.d.ts.map +0 -1
- package/dist/utils/network.js.map +0 -1
- package/dist/utils/wait.d.ts +0 -52
- package/dist/utils/wait.d.ts.map +0 -1
- package/dist/utils/wait.js.map +0 -1
- package/dist/waterHeater.d.ts +0 -75
- package/dist/waterHeater.d.ts.map +0 -1
- package/dist/waterHeater.js.map +0 -1
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
// src\matterbridgeEndpointHelpers.ts
|
|
2
|
-
// @matter
|
|
3
1
|
import { Lifecycle } from '@matter/main';
|
|
4
2
|
import { getClusterNameById } from '@matter/main/types';
|
|
5
|
-
// @matter clusters
|
|
6
3
|
import { PowerSource } from '@matter/main/clusters/power-source';
|
|
7
4
|
import { UserLabel } from '@matter/main/clusters/user-label';
|
|
8
5
|
import { FixedLabel } from '@matter/main/clusters/fixed-label';
|
|
@@ -45,7 +42,6 @@ import { Pm10ConcentrationMeasurement } from '@matter/main/clusters/pm10-concent
|
|
|
45
42
|
import { RadonConcentrationMeasurement } from '@matter/main/clusters/radon-concentration-measurement';
|
|
46
43
|
import { TotalVolatileOrganicCompoundsConcentrationMeasurement } from '@matter/main/clusters/total-volatile-organic-compounds-concentration-measurement';
|
|
47
44
|
import { OperationalState } from '@matter/main/clusters/operational-state';
|
|
48
|
-
// @matter behaviors
|
|
49
45
|
import { PowerSourceServer } from '@matter/main/behaviors/power-source';
|
|
50
46
|
import { UserLabelServer } from '@matter/main/behaviors/user-label';
|
|
51
47
|
import { FixedLabelServer } from '@matter/main/behaviors/fixed-label';
|
|
@@ -75,12 +71,10 @@ import { Pm25ConcentrationMeasurementServer } from '@matter/main/behaviors/pm25-
|
|
|
75
71
|
import { Pm10ConcentrationMeasurementServer } from '@matter/main/behaviors/pm10-concentration-measurement';
|
|
76
72
|
import { RadonConcentrationMeasurementServer } from '@matter/main/behaviors/radon-concentration-measurement';
|
|
77
73
|
import { TotalVolatileOrganicCompoundsConcentrationMeasurementServer } from '@matter/main/behaviors/total-volatile-organic-compounds-concentration-measurement';
|
|
78
|
-
// Other modules
|
|
79
74
|
import { createHash } from 'node:crypto';
|
|
80
75
|
import { BLUE, CYAN, db, debugStringify, er, hk, or, YELLOW, zb } from 'node-ansi-logger';
|
|
81
|
-
// Matterbridge
|
|
82
76
|
import { deepCopy, deepEqual, isValidArray } from './utils/export.js';
|
|
83
|
-
import { MatterbridgeIdentifyServer, MatterbridgeOnOffServer, MatterbridgeLevelControlServer, MatterbridgeColorControlServer,
|
|
77
|
+
import { MatterbridgeIdentifyServer, MatterbridgeOnOffServer, MatterbridgeLevelControlServer, MatterbridgeColorControlServer, MatterbridgeLiftWindowCoveringServer, MatterbridgeThermostatServer, MatterbridgeFanControlServer, MatterbridgeDoorLockServer, MatterbridgeModeSelectServer, MatterbridgeValveConfigurationAndControlServer, MatterbridgeSmokeCoAlarmServer, MatterbridgeBooleanStateConfigurationServer, MatterbridgeOperationalStateServer, } from './matterbridgeBehaviors.js';
|
|
84
78
|
export function capitalizeFirstLetter(name) {
|
|
85
79
|
if (!name)
|
|
86
80
|
return name;
|
|
@@ -93,19 +87,19 @@ export function lowercaseFirstLetter(name) {
|
|
|
93
87
|
}
|
|
94
88
|
export function checkNotLatinCharacters(deviceName) {
|
|
95
89
|
const nonLatinRegexList = [
|
|
96
|
-
/[\u0400-\u04FF\u0500-\u052F]/,
|
|
97
|
-
/[\u2E80-\u9FFF]/,
|
|
98
|
-
/[\uAC00-\uD7AF]/,
|
|
99
|
-
/[\u0600-\u06FF\u0750-\u077F]/,
|
|
100
|
-
/[\u0590-\u05FF]/,
|
|
101
|
-
/[\u0900-\u097F]/,
|
|
102
|
-
/[\u0E00-\u0E7F]/,
|
|
103
|
-
/[\u1200-\u137F]/,
|
|
90
|
+
/[\u0400-\u04FF\u0500-\u052F]/,
|
|
91
|
+
/[\u2E80-\u9FFF]/,
|
|
92
|
+
/[\uAC00-\uD7AF]/,
|
|
93
|
+
/[\u0600-\u06FF\u0750-\u077F]/,
|
|
94
|
+
/[\u0590-\u05FF]/,
|
|
95
|
+
/[\u0900-\u097F]/,
|
|
96
|
+
/[\u0E00-\u0E7F]/,
|
|
97
|
+
/[\u1200-\u137F]/,
|
|
104
98
|
];
|
|
105
99
|
return nonLatinRegexList.some((regex) => regex.test(deviceName));
|
|
106
100
|
}
|
|
107
101
|
export function generateUniqueId(deviceName) {
|
|
108
|
-
return createHash('md5').update(deviceName).digest('hex');
|
|
102
|
+
return createHash('md5').update(deviceName).digest('hex');
|
|
109
103
|
}
|
|
110
104
|
export function createUniqueId(param1, param2, param3, param4) {
|
|
111
105
|
const hash = createHash('md5');
|
|
@@ -113,7 +107,6 @@ export function createUniqueId(param1, param2, param3, param4) {
|
|
|
113
107
|
return hash.digest('hex');
|
|
114
108
|
}
|
|
115
109
|
export function getBehaviourTypesFromClusterServerIds(clusterServerList) {
|
|
116
|
-
// Map Server ClusterId to Behavior.Type
|
|
117
110
|
const behaviorTypes = [];
|
|
118
111
|
clusterServerList.forEach((clusterId) => {
|
|
119
112
|
behaviorTypes.push(getBehaviourTypeFromClusterServerId(clusterId));
|
|
@@ -121,15 +114,12 @@ export function getBehaviourTypesFromClusterServerIds(clusterServerList) {
|
|
|
121
114
|
return behaviorTypes;
|
|
122
115
|
}
|
|
123
116
|
export function getBehaviourTypesFromClusterClientIds(clusterClientList) {
|
|
124
|
-
// Map Client ClusterId to Behavior.Type
|
|
125
117
|
const behaviorTypes = [];
|
|
126
118
|
clusterClientList.forEach((_clusterId) => {
|
|
127
|
-
// behaviorTypes.push(getBehaviourTypeFromClusterClientId(clusterId));
|
|
128
119
|
});
|
|
129
120
|
return behaviorTypes;
|
|
130
121
|
}
|
|
131
122
|
export function getBehaviourTypeFromClusterServerId(clusterId) {
|
|
132
|
-
// Map ClusterId to Server Behavior.Type
|
|
133
123
|
if (clusterId === PowerSource.Cluster.id)
|
|
134
124
|
return PowerSourceServer.with(PowerSource.Feature.Wired);
|
|
135
125
|
if (clusterId === UserLabel.Cluster.id)
|
|
@@ -151,7 +141,7 @@ export function getBehaviourTypeFromClusterServerId(clusterId) {
|
|
|
151
141
|
if (clusterId === ColorControl.Cluster.id)
|
|
152
142
|
return MatterbridgeColorControlServer;
|
|
153
143
|
if (clusterId === WindowCovering.Cluster.id)
|
|
154
|
-
return
|
|
144
|
+
return MatterbridgeLiftWindowCoveringServer.with('Lift', 'PositionAwareLift');
|
|
155
145
|
if (clusterId === Thermostat.Cluster.id)
|
|
156
146
|
return MatterbridgeThermostatServer.with('AutoMode', 'Heating', 'Cooling');
|
|
157
147
|
if (clusterId === FanControl.Cluster.id)
|
|
@@ -217,8 +207,6 @@ export function getBehaviourTypeFromClusterServerId(clusterId) {
|
|
|
217
207
|
return MatterbridgeIdentifyServer;
|
|
218
208
|
}
|
|
219
209
|
export function getBehaviourTypeFromClusterClientId(_clusterId) {
|
|
220
|
-
// Map ClusterId to Client Behavior.Type
|
|
221
|
-
// return IdentifyClient;
|
|
222
210
|
}
|
|
223
211
|
export function getBehavior(endpoint, cluster) {
|
|
224
212
|
let behavior;
|
|
@@ -243,7 +231,6 @@ export async function invokeBehaviorCommand(endpoint, cluster, command, params)
|
|
|
243
231
|
return false;
|
|
244
232
|
}
|
|
245
233
|
await endpoint.act((agent) => {
|
|
246
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
247
234
|
const behavior = agent[behaviorId];
|
|
248
235
|
if (!(command in behavior) || typeof behavior[command] !== 'function') {
|
|
249
236
|
endpoint.log?.error(`invokeBehaviorCommand error: command ${hk}${command}${er} not found on agent for endpoint ${or}${endpoint.maybeId}${er}:${or}${endpoint.maybeNumber}${er}`);
|
|
@@ -281,13 +268,6 @@ export function addOptionalClusterServers(endpoint) {
|
|
|
281
268
|
});
|
|
282
269
|
addClusterServers(endpoint, optionalServerList);
|
|
283
270
|
}
|
|
284
|
-
/**
|
|
285
|
-
* Adds cluster servers to the specified endpoint based on the provided server list.
|
|
286
|
-
*
|
|
287
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to add the cluster servers to.
|
|
288
|
-
* @param {ClusterId[]} serverList - The list of cluster IDs to add.
|
|
289
|
-
* @returns void
|
|
290
|
-
*/
|
|
291
271
|
export function addClusterServers(endpoint, serverList) {
|
|
292
272
|
if (serverList.includes(PowerSource.Cluster.id))
|
|
293
273
|
endpoint.createDefaultPowerSourceWiredClusterServer();
|
|
@@ -363,16 +343,7 @@ export function addClusterServers(endpoint, serverList) {
|
|
|
363
343
|
endpoint.createDefaultRadonConcentrationMeasurementClusterServer();
|
|
364
344
|
if (serverList.includes(TotalVolatileOrganicCompoundsConcentrationMeasurement.Cluster.id))
|
|
365
345
|
endpoint.createDefaultTvocMeasurementClusterServer();
|
|
366
|
-
// if (serverList.includes(DeviceEnergyManagement.Cluster.id)) endpoint.createDefaultDeviceEnergyManagementClusterServer();
|
|
367
|
-
// if (serverList.includes(DeviceEnergyManagementMode.Cluster.id)) endpoint.createDefaultDeviceEnergyManagementModeClusterServer();
|
|
368
346
|
}
|
|
369
|
-
/**
|
|
370
|
-
* Adds a fixed label to the FixedLabel cluster. The FixedLabel cluster is created if it does not exist.
|
|
371
|
-
*
|
|
372
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to add the cluster servers to.
|
|
373
|
-
* @param {string} label - The label to add.
|
|
374
|
-
* @param {string} value - The value of the label.
|
|
375
|
-
*/
|
|
376
347
|
export async function addFixedLabel(endpoint, label, value) {
|
|
377
348
|
if (!endpoint.hasClusterServer(FixedLabel.Cluster.id)) {
|
|
378
349
|
endpoint.log.debug(`addFixedLabel: add cluster ${hk}FixedLabel${db}:${hk}fixedLabel${db} with label ${CYAN}${label}${db} value ${CYAN}${value}${db}`);
|
|
@@ -389,13 +360,6 @@ export async function addFixedLabel(endpoint, label, value) {
|
|
|
389
360
|
await endpoint.setAttribute(FixedLabel.Cluster.id, 'labelList', labelList, endpoint.log);
|
|
390
361
|
}
|
|
391
362
|
}
|
|
392
|
-
/**
|
|
393
|
-
* Adds a user label to the UserLabel cluster. The UserLabel cluster is created if it does not exist.
|
|
394
|
-
*
|
|
395
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to add the cluster servers to.
|
|
396
|
-
* @param {string} label - The label to add.
|
|
397
|
-
* @param {string} value - The value of the label.
|
|
398
|
-
*/
|
|
399
363
|
export async function addUserLabel(endpoint, label, value) {
|
|
400
364
|
if (!endpoint.hasClusterServer(UserLabel.Cluster.id)) {
|
|
401
365
|
endpoint.log.debug(`addUserLabel: add cluster ${hk}UserLabel${db}:${hk}userLabel${db} with label ${CYAN}${label}${db} value ${CYAN}${value}${db}`);
|
|
@@ -419,70 +383,9 @@ export function getClusterId(endpoint, cluster) {
|
|
|
419
383
|
return endpoint.behaviors.supported[lowercaseFirstLetter(cluster)]?.schema?.id;
|
|
420
384
|
}
|
|
421
385
|
export function getAttributeId(endpoint, cluster, attribute) {
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
else if (attribute === 'featureMap')
|
|
425
|
-
return 0xfffc;
|
|
426
|
-
else if (attribute === 'eventList')
|
|
427
|
-
return 0xfffa;
|
|
428
|
-
else if (attribute === 'generatedCommandList')
|
|
429
|
-
return 0xfff8;
|
|
430
|
-
else if (attribute === 'acceptedCommandList')
|
|
431
|
-
return 0xfff9;
|
|
432
|
-
else if (attribute === 'clusterRevision')
|
|
433
|
-
return 0xfffd;
|
|
434
|
-
else {
|
|
435
|
-
if (endpoint.behaviors.supported[lowercaseFirstLetter(cluster)]?.schema?.type === 'ConcentrationMeasurement') {
|
|
436
|
-
if (attribute === 'measuredValue')
|
|
437
|
-
return 0x0;
|
|
438
|
-
else if (attribute === 'minMeasuredValue')
|
|
439
|
-
return 0x1;
|
|
440
|
-
else if (attribute === 'maxMeasuredValue')
|
|
441
|
-
return 0x2;
|
|
442
|
-
else if (attribute === 'peakMeasuredValue')
|
|
443
|
-
return 0x3;
|
|
444
|
-
else if (attribute === 'peakMeasuredValueWindow')
|
|
445
|
-
return 0x4;
|
|
446
|
-
else if (attribute === 'averageMeasuredValue')
|
|
447
|
-
return 0x5;
|
|
448
|
-
else if (attribute === 'averageMeasuredValueWindow')
|
|
449
|
-
return 0x6;
|
|
450
|
-
else if (attribute === 'uncertainty')
|
|
451
|
-
return 0x7;
|
|
452
|
-
else if (attribute === 'measurementUnit')
|
|
453
|
-
return 0x8;
|
|
454
|
-
else if (attribute === 'measurementMedium')
|
|
455
|
-
return 0x9;
|
|
456
|
-
else if (attribute === 'levelValue')
|
|
457
|
-
return 0xa;
|
|
458
|
-
}
|
|
459
|
-
if (endpoint.behaviors.supported[lowercaseFirstLetter(cluster)]?.schema?.type === 'OperationalState') {
|
|
460
|
-
if (attribute === 'phaseList')
|
|
461
|
-
return 0x0;
|
|
462
|
-
else if (attribute === 'currentPhase')
|
|
463
|
-
return 0x1;
|
|
464
|
-
else if (attribute === 'countdownTime')
|
|
465
|
-
return 0x2;
|
|
466
|
-
else if (attribute === 'operationalStateList')
|
|
467
|
-
return 0x3;
|
|
468
|
-
else if (attribute === 'operationalState')
|
|
469
|
-
return 0x4;
|
|
470
|
-
else if (attribute === 'operationalError')
|
|
471
|
-
return 0x5;
|
|
472
|
-
}
|
|
473
|
-
return endpoint.behaviors.supported[lowercaseFirstLetter(cluster)]?.schema?.children?.find((child) => child.name === capitalizeFirstLetter(attribute))?.id;
|
|
474
|
-
}
|
|
386
|
+
const clusterBehavior = endpoint.behaviors.supported[lowercaseFirstLetter(cluster)];
|
|
387
|
+
return clusterBehavior?.cluster.attributes[lowercaseFirstLetter(attribute)]?.id;
|
|
475
388
|
}
|
|
476
|
-
/**
|
|
477
|
-
* Retrieves the value of the provided attribute from the given cluster.
|
|
478
|
-
*
|
|
479
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to retrieve the attribute from.
|
|
480
|
-
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to retrieve the attribute from.
|
|
481
|
-
* @param {string} attribute - The name of the attribute to retrieve.
|
|
482
|
-
* @param {AnsiLogger} [log] - (Optional) The logger to use for logging the retrieve. Errors are logged to the endpoint logger.
|
|
483
|
-
* @returns {any} The value of the attribute, or undefined if the attribute is not found.
|
|
484
|
-
*/
|
|
485
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
486
389
|
export function getAttribute(endpoint, cluster, attribute, log) {
|
|
487
390
|
const clusterName = getBehavior(endpoint, cluster)?.id;
|
|
488
391
|
if (!clusterName) {
|
|
@@ -505,16 +408,6 @@ export function getAttribute(endpoint, cluster, attribute, log) {
|
|
|
505
408
|
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}`);
|
|
506
409
|
return value;
|
|
507
410
|
}
|
|
508
|
-
/**
|
|
509
|
-
* Sets the value of an attribute on a cluster server.
|
|
510
|
-
*
|
|
511
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to set the attribute on.
|
|
512
|
-
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to set the attribute on.
|
|
513
|
-
* @param {string} attribute - The name of the attribute.
|
|
514
|
-
* @param {boolean | number | bigint | string | object | null} value - The value to set for the attribute.
|
|
515
|
-
* @param {AnsiLogger} [log] - (Optional) The logger to use for logging the set. Errors are logged to the endpoint logger.
|
|
516
|
-
* @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the attribute was successfully set.
|
|
517
|
-
*/
|
|
518
411
|
export async function setAttribute(endpoint, cluster, attribute, value, log) {
|
|
519
412
|
const clusterName = getBehavior(endpoint, cluster)?.id;
|
|
520
413
|
if (!clusterName) {
|
|
@@ -540,16 +433,6 @@ export async function setAttribute(endpoint, cluster, attribute, value, log) {
|
|
|
540
433
|
`to ${YELLOW}${value !== null && typeof value === 'object' ? debugStringify(value) : value}${db}`);
|
|
541
434
|
return true;
|
|
542
435
|
}
|
|
543
|
-
/**
|
|
544
|
-
* Sets the value of an attribute on a cluster server.
|
|
545
|
-
*
|
|
546
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to update the attribute on.
|
|
547
|
-
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to update the attribute on.
|
|
548
|
-
* @param {string} attribute - The name of the attribute.
|
|
549
|
-
* @param {boolean | number | bigint | string | object | null} value - The value to set for the attribute.
|
|
550
|
-
* @param {AnsiLogger} [log] - (Optional) The logger to use for logging the update. Errors are logged to the endpoint logger.
|
|
551
|
-
* @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the attribute was successfully set.
|
|
552
|
-
*/
|
|
553
436
|
export async function updateAttribute(endpoint, cluster, attribute, value, log) {
|
|
554
437
|
const clusterName = getBehavior(endpoint, cluster)?.id;
|
|
555
438
|
if (!clusterName) {
|
|
@@ -580,19 +463,7 @@ export async function updateAttribute(endpoint, cluster, attribute, value, log)
|
|
|
580
463
|
`to ${YELLOW}${value !== null && typeof value === 'object' ? debugStringify(value) : value}${db}`);
|
|
581
464
|
return true;
|
|
582
465
|
}
|
|
583
|
-
|
|
584
|
-
* Subscribes to the provided attribute on a cluster.
|
|
585
|
-
*
|
|
586
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to subscribe the attribute to.
|
|
587
|
-
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to subscribe the attribute to.
|
|
588
|
-
* @param {string} attribute - The name of the attribute to subscribe to.
|
|
589
|
-
* @param {(newValue: any, oldValue: any, context?: any) => void} listener - A callback function that will be called when the attribute value changes.
|
|
590
|
-
* @param {AnsiLogger} [log] - Optional logger for logging errors and information.
|
|
591
|
-
* @returns {boolean} - A boolean indicating whether the subscription was successful.
|
|
592
|
-
*/
|
|
593
|
-
export async function subscribeAttribute(endpoint, cluster, attribute,
|
|
594
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
595
|
-
listener, log) {
|
|
466
|
+
export async function subscribeAttribute(endpoint, cluster, attribute, listener, log) {
|
|
596
467
|
const clusterName = getBehavior(endpoint, cluster)?.id;
|
|
597
468
|
if (!clusterName) {
|
|
598
469
|
endpoint.log.error(`subscribeAttribute ${hk}${attribute}${er} error: cluster not found on endpoint ${or}${endpoint.maybeId}${er}:${or}${endpoint.maybeNumber}${er}`);
|
|
@@ -602,7 +473,6 @@ listener, log) {
|
|
|
602
473
|
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`);
|
|
603
474
|
await endpoint.construction.ready;
|
|
604
475
|
}
|
|
605
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
606
476
|
const events = endpoint.events;
|
|
607
477
|
attribute = lowercaseFirstLetter(attribute) + '$Changed';
|
|
608
478
|
if (!(clusterName in events) || !(attribute in events[clusterName])) {
|
|
@@ -613,11 +483,25 @@ listener, log) {
|
|
|
613
483
|
log?.info(`${db}Subscribed endpoint ${or}${endpoint.id}${db}:${or}${endpoint.number}${db} attribute ${hk}${capitalizeFirstLetter(clusterName)}${db}.${hk}${attribute}${db}`);
|
|
614
484
|
return true;
|
|
615
485
|
}
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
486
|
+
export async function triggerEvent(endpoint, cluster, event, payload, log) {
|
|
487
|
+
const clusterName = getBehavior(endpoint, cluster)?.id;
|
|
488
|
+
if (!clusterName) {
|
|
489
|
+
endpoint.log.error(`triggerEvent ${hk}${event}${er} error: cluster not found on endpoint ${or}${endpoint.maybeId}${er}:${or}${endpoint.maybeNumber}${er}`);
|
|
490
|
+
return false;
|
|
491
|
+
}
|
|
492
|
+
if (endpoint.construction.status !== Lifecycle.Status.Active) {
|
|
493
|
+
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`);
|
|
494
|
+
return false;
|
|
495
|
+
}
|
|
496
|
+
const events = endpoint.events;
|
|
497
|
+
if (!(clusterName in events) || !(event in events[clusterName])) {
|
|
498
|
+
endpoint.log.error(`triggerEvent ${hk}${event}${er} error: cluster ${clusterName} not found on endpoint ${or}${endpoint.id}${er}:${or}${endpoint.number}${er}`);
|
|
499
|
+
return false;
|
|
500
|
+
}
|
|
501
|
+
await endpoint.act((agent) => agent[clusterName].events[event].emit(payload, agent.context));
|
|
502
|
+
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} `);
|
|
503
|
+
return true;
|
|
504
|
+
}
|
|
621
505
|
export function getDefaultOperationalStateClusterServer(operationalState = OperationalState.OperationalStateEnum.Stopped) {
|
|
622
506
|
return optionsFor(MatterbridgeOperationalStateServer, {
|
|
623
507
|
phaseList: [],
|
|
@@ -632,13 +516,6 @@ export function getDefaultOperationalStateClusterServer(operationalState = Opera
|
|
|
632
516
|
operationalError: { errorStateId: OperationalState.ErrorState.NoError, errorStateLabel: 'No error', errorStateDetails: 'Fully operational' },
|
|
633
517
|
});
|
|
634
518
|
}
|
|
635
|
-
/**
|
|
636
|
-
* Get the default TemperatureMeasurement cluster server options.
|
|
637
|
-
*
|
|
638
|
-
* @param {number | null} measuredValue - The measured value of the temperature x 100.
|
|
639
|
-
* @param {number | null} minMeasuredValue - The minimum measured value of the temperature x 100.
|
|
640
|
-
* @param {number | null} maxMeasuredValue - The maximum measured value of the temperature x 100.
|
|
641
|
-
*/
|
|
642
519
|
export function getDefaultTemperatureMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
643
520
|
return optionsFor(TemperatureMeasurementServer, {
|
|
644
521
|
measuredValue,
|
|
@@ -647,13 +524,6 @@ export function getDefaultTemperatureMeasurementClusterServer(measuredValue = nu
|
|
|
647
524
|
tolerance: 0,
|
|
648
525
|
});
|
|
649
526
|
}
|
|
650
|
-
/**
|
|
651
|
-
* Get the default RelativeHumidityMeasurement cluster server options.
|
|
652
|
-
*
|
|
653
|
-
* @param {number | null} measuredValue - The measured value of the relative humidity x 100.
|
|
654
|
-
* @param {number | null} minMeasuredValue - The minimum measured value of the relative humidity x 100.
|
|
655
|
-
* @param {number | null} maxMeasuredValue - The maximum measured value of the relative humidity x 100.
|
|
656
|
-
*/
|
|
657
527
|
export function getDefaultRelativeHumidityMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
658
528
|
return optionsFor(RelativeHumidityMeasurementServer, {
|
|
659
529
|
measuredValue,
|
|
@@ -662,13 +532,6 @@ export function getDefaultRelativeHumidityMeasurementClusterServer(measuredValue
|
|
|
662
532
|
tolerance: 0,
|
|
663
533
|
});
|
|
664
534
|
}
|
|
665
|
-
/**
|
|
666
|
-
* Get the default PressureMeasurement cluster server options.
|
|
667
|
-
*
|
|
668
|
-
* @param {number | null} measuredValue - The measured value for the pressure.
|
|
669
|
-
* @param {number | null} minMeasuredValue - The minimum measured value for the pressure.
|
|
670
|
-
* @param {number | null} maxMeasuredValue - The maximum measured value for the pressure.
|
|
671
|
-
*/
|
|
672
535
|
export function getDefaultPressureMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
673
536
|
return optionsFor(PressureMeasurementServer, {
|
|
674
537
|
measuredValue,
|
|
@@ -677,19 +540,6 @@ export function getDefaultPressureMeasurementClusterServer(measuredValue = null,
|
|
|
677
540
|
tolerance: 0,
|
|
678
541
|
});
|
|
679
542
|
}
|
|
680
|
-
/**
|
|
681
|
-
* Get the default IlluminanceMeasurement cluster server options.
|
|
682
|
-
*
|
|
683
|
-
* @param {number | null} measuredValue - The measured value of illuminance.
|
|
684
|
-
* @param {number | null} minMeasuredValue - The minimum measured value of illuminance.
|
|
685
|
-
* @param {number | null} maxMeasuredValue - The maximum measured value of illuminance.
|
|
686
|
-
* @remark The default value for the illuminance measurement is null.
|
|
687
|
-
* This attribute SHALL indicate the illuminance in Lux (symbol lx) as follows:
|
|
688
|
-
* • MeasuredValue = 10,000 x log10(illuminance) + 1,
|
|
689
|
-
* where 1 lx <= illuminance <= 3.576 Mlx, corresponding to a MeasuredValue in the range 1 to 0xFFFE.
|
|
690
|
-
* • 0 indicates a value of illuminance that is too low to be measured
|
|
691
|
-
* • null indicates that the illuminance measurement is invalid.
|
|
692
|
-
*/
|
|
693
543
|
export function getDefaultIlluminanceMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
694
544
|
return optionsFor(IlluminanceMeasurementServer, {
|
|
695
545
|
measuredValue,
|
|
@@ -698,13 +548,6 @@ export function getDefaultIlluminanceMeasurementClusterServer(measuredValue = nu
|
|
|
698
548
|
tolerance: 0,
|
|
699
549
|
});
|
|
700
550
|
}
|
|
701
|
-
/**
|
|
702
|
-
* Get the default FlowMeasurement cluster server options.
|
|
703
|
-
*
|
|
704
|
-
* @param {number | null} measuredValue - The measured value of the flow in 10 x m3/h.
|
|
705
|
-
* @param {number | null} minMeasuredValue - The minimum measured value of the flow in 10 x m3/h.
|
|
706
|
-
* @param {number | null} maxMeasuredValue - The maximum measured value of the flow in 10 x m3/h.
|
|
707
|
-
*/
|
|
708
551
|
export function getDefaultFlowMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
709
552
|
return optionsFor(FlowMeasurementServer, {
|
|
710
553
|
measuredValue,
|
|
@@ -713,19 +556,6 @@ export function getDefaultFlowMeasurementClusterServer(measuredValue = null, min
|
|
|
713
556
|
tolerance: 0,
|
|
714
557
|
});
|
|
715
558
|
}
|
|
716
|
-
/**
|
|
717
|
-
* Get the default OccupancySensing cluster server options.
|
|
718
|
-
*
|
|
719
|
-
* @param {boolean} occupied - A boolean indicating whether the occupancy is occupied or not. Default is false.
|
|
720
|
-
* @param {number} holdTime - The hold time in seconds. Default is 30.
|
|
721
|
-
* @param {number} holdTimeMin - The minimum hold time in seconds. Default is 1.
|
|
722
|
-
* @param {number} holdTimeMax - The maximum hold time in seconds. Default is 300.
|
|
723
|
-
*
|
|
724
|
-
* @remark The default value for the occupancy sensor type is PIR.
|
|
725
|
-
* Servers SHALL set these attributes for backward compatibility with clients implementing a cluster revision <= 4 as
|
|
726
|
-
* described in OccupancySensorType and OccupancySensorTypeBitmap Attributes.
|
|
727
|
-
* This replaces the 9 legacy attributes PIROccupiedToUnoccupiedDelay through PhysicalContactUnoccupiedToOccupiedThreshold.
|
|
728
|
-
*/
|
|
729
559
|
export function getDefaultOccupancySensingClusterServer(occupied = false, holdTime = 30, holdTimeMin = 1, holdTimeMax = 300) {
|
|
730
560
|
return optionsFor(OccupancySensingServer.with(OccupancySensing.Feature.PassiveInfrared), {
|
|
731
561
|
occupancy: { occupied },
|
|
@@ -737,4 +567,3 @@ export function getDefaultOccupancySensingClusterServer(occupied = false, holdTi
|
|
|
737
567
|
holdTimeLimits: { holdTimeMin, holdTimeMax, holdTimeDefault: holdTime },
|
|
738
568
|
});
|
|
739
569
|
}
|
|
740
|
-
//# sourceMappingURL=matterbridgeEndpointHelpers.js.map
|