matterbridge 3.0.1 → 3.0.2-dev-20250509-ae61aa7
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 +26 -3
- package/README.md +2 -2
- 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 +37 -341
- package/dist/index.js +2 -28
- 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 -2
- package/dist/matter/types.js +0 -2
- package/dist/matterbridge.js +107 -748
- package/dist/matterbridgeAccessoryPlatform.js +0 -34
- package/dist/matterbridgeBehaviors.js +109 -48
- package/dist/matterbridgeDeviceTypes.js +12 -431
- package/dist/matterbridgeDynamicPlatform.js +0 -34
- package/dist/matterbridgeEndpoint.js +16 -814
- package/dist/matterbridgeEndpointHelpers.js +44 -148
- package/dist/matterbridgePlatform.js +7 -225
- package/dist/matterbridgeTypes.js +0 -24
- package/dist/pluginManager.js +3 -264
- package/dist/roboticVacuumCleaner.js +87 -0
- package/dist/shelly.js +6 -146
- package/dist/storage/export.js +0 -1
- package/dist/update.js +1 -53
- package/dist/utils/colorUtils.js +2 -205
- package/dist/utils/{parameter.js → commandLine.js} +1 -54
- package/dist/utils/copyDirectory.js +1 -37
- package/dist/utils/createZip.js +2 -42
- package/dist/utils/deepCopy.js +8 -43
- package/dist/utils/deepEqual.js +7 -69
- package/dist/utils/export.js +2 -2
- package/dist/utils/hex.js +27 -0
- package/dist/utils/isvalid.js +3 -93
- package/dist/utils/network.js +7 -78
- package/dist/utils/wait.js +5 -48
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -2
- 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 -240
- package/dist/frontend.d.ts.map +0 -1
- package/dist/frontend.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 -433
- 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 -1166
- package/dist/matterbridgeBehaviors.d.ts.map +0 -1
- package/dist/matterbridgeBehaviors.js.map +0 -1
- package/dist/matterbridgeDeviceTypes.d.ts +0 -494
- 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 -956
- package/dist/matterbridgeEndpoint.d.ts.map +0 -1
- package/dist/matterbridgeEndpoint.js.map +0 -1
- package/dist/matterbridgeEndpointHelpers.d.ts +0 -2706
- 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 -187
- 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/shelly.d.ts +0 -92
- 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 -32
- 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/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 -10
- package/dist/utils/export.d.ts.map +0 -1
- package/dist/utils/export.js.map +0 -1
- package/dist/utils/isvalid.d.ts +0 -95
- 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/parameter.d.ts +0 -58
- package/dist/utils/parameter.d.ts.map +0 -1
- package/dist/utils/parameter.js.map +0 -1
- package/dist/utils/wait.d.ts +0 -43
- package/dist/utils/wait.d.ts.map +0 -1
- package/dist/utils/wait.js.map +0 -1
|
@@ -1,15 +1,5 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
-
// Node.js modules
|
|
3
|
-
import { createHash } from 'node:crypto';
|
|
4
|
-
// AnsiLogger module
|
|
5
|
-
import { BLUE, CYAN, db, debugStringify, er, hk, or, YELLOW, zb } from './logger/export.js';
|
|
6
|
-
// Matterbridge
|
|
7
|
-
import { deepCopy, deepEqual, isValidArray } from './utils/export.js';
|
|
8
|
-
import { MatterbridgeIdentifyServer, MatterbridgeOnOffServer, MatterbridgeLevelControlServer, MatterbridgeColorControlServer, MatterbridgeWindowCoveringServer, MatterbridgeThermostatServer, MatterbridgeFanControlServer, MatterbridgeDoorLockServer, MatterbridgeModeSelectServer, MatterbridgeValveConfigurationAndControlServer, MatterbridgeSmokeCoAlarmServer, MatterbridgeBooleanStateConfigurationServer, MatterbridgeOperationalStateServer, } from './matterbridgeBehaviors.js';
|
|
9
|
-
// @matter
|
|
10
1
|
import { Lifecycle } from '@matter/main';
|
|
11
2
|
import { getClusterNameById } from '@matter/main/types';
|
|
12
|
-
// @matter clusters
|
|
13
3
|
import { PowerSource } from '@matter/main/clusters/power-source';
|
|
14
4
|
import { UserLabel } from '@matter/main/clusters/user-label';
|
|
15
5
|
import { FixedLabel } from '@matter/main/clusters/fixed-label';
|
|
@@ -52,7 +42,6 @@ import { Pm10ConcentrationMeasurement } from '@matter/main/clusters/pm10-concent
|
|
|
52
42
|
import { RadonConcentrationMeasurement } from '@matter/main/clusters/radon-concentration-measurement';
|
|
53
43
|
import { TotalVolatileOrganicCompoundsConcentrationMeasurement } from '@matter/main/clusters/total-volatile-organic-compounds-concentration-measurement';
|
|
54
44
|
import { OperationalState } from '@matter/main/clusters/operational-state';
|
|
55
|
-
// @matter behaviors
|
|
56
45
|
import { PowerSourceServer } from '@matter/main/behaviors/power-source';
|
|
57
46
|
import { UserLabelServer } from '@matter/main/behaviors/user-label';
|
|
58
47
|
import { FixedLabelServer } from '@matter/main/behaviors/fixed-label';
|
|
@@ -82,6 +71,10 @@ import { Pm25ConcentrationMeasurementServer } from '@matter/main/behaviors/pm25-
|
|
|
82
71
|
import { Pm10ConcentrationMeasurementServer } from '@matter/main/behaviors/pm10-concentration-measurement';
|
|
83
72
|
import { RadonConcentrationMeasurementServer } from '@matter/main/behaviors/radon-concentration-measurement';
|
|
84
73
|
import { TotalVolatileOrganicCompoundsConcentrationMeasurementServer } from '@matter/main/behaviors/total-volatile-organic-compounds-concentration-measurement';
|
|
74
|
+
import { createHash } from 'node:crypto';
|
|
75
|
+
import { BLUE, CYAN, db, debugStringify, er, hk, or, YELLOW, zb } from 'node-ansi-logger';
|
|
76
|
+
import { deepCopy, deepEqual, isValidArray } from './utils/export.js';
|
|
77
|
+
import { MatterbridgeIdentifyServer, MatterbridgeOnOffServer, MatterbridgeLevelControlServer, MatterbridgeColorControlServer, MatterbridgeWindowCoveringServer, MatterbridgeThermostatServer, MatterbridgeFanControlServer, MatterbridgeDoorLockServer, MatterbridgeModeSelectServer, MatterbridgeValveConfigurationAndControlServer, MatterbridgeSmokeCoAlarmServer, MatterbridgeBooleanStateConfigurationServer, MatterbridgeOperationalStateServer, } from './matterbridgeBehaviors.js';
|
|
85
78
|
export function capitalizeFirstLetter(name) {
|
|
86
79
|
if (!name)
|
|
87
80
|
return name;
|
|
@@ -94,19 +87,19 @@ export function lowercaseFirstLetter(name) {
|
|
|
94
87
|
}
|
|
95
88
|
export function checkNotLatinCharacters(deviceName) {
|
|
96
89
|
const nonLatinRegexList = [
|
|
97
|
-
/[\u0400-\u04FF\u0500-\u052F]/,
|
|
98
|
-
/[\u2E80-\u9FFF]/,
|
|
99
|
-
/[\uAC00-\uD7AF]/,
|
|
100
|
-
/[\u0600-\u06FF\u0750-\u077F]/,
|
|
101
|
-
/[\u0590-\u05FF]/,
|
|
102
|
-
/[\u0900-\u097F]/,
|
|
103
|
-
/[\u0E00-\u0E7F]/,
|
|
104
|
-
/[\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]/,
|
|
105
98
|
];
|
|
106
99
|
return nonLatinRegexList.some((regex) => regex.test(deviceName));
|
|
107
100
|
}
|
|
108
101
|
export function generateUniqueId(deviceName) {
|
|
109
|
-
return createHash('md5').update(deviceName).digest('hex');
|
|
102
|
+
return createHash('md5').update(deviceName).digest('hex');
|
|
110
103
|
}
|
|
111
104
|
export function createUniqueId(param1, param2, param3, param4) {
|
|
112
105
|
const hash = createHash('md5');
|
|
@@ -114,7 +107,6 @@ export function createUniqueId(param1, param2, param3, param4) {
|
|
|
114
107
|
return hash.digest('hex');
|
|
115
108
|
}
|
|
116
109
|
export function getBehaviourTypesFromClusterServerIds(clusterServerList) {
|
|
117
|
-
// Map Server ClusterId to Behavior.Type
|
|
118
110
|
const behaviorTypes = [];
|
|
119
111
|
clusterServerList.forEach((clusterId) => {
|
|
120
112
|
behaviorTypes.push(getBehaviourTypeFromClusterServerId(clusterId));
|
|
@@ -122,15 +114,12 @@ export function getBehaviourTypesFromClusterServerIds(clusterServerList) {
|
|
|
122
114
|
return behaviorTypes;
|
|
123
115
|
}
|
|
124
116
|
export function getBehaviourTypesFromClusterClientIds(clusterClientList) {
|
|
125
|
-
// Map Client ClusterId to Behavior.Type
|
|
126
117
|
const behaviorTypes = [];
|
|
127
|
-
clusterClientList.forEach((
|
|
128
|
-
// behaviorTypes.push(getBehaviourTypeFromClusterClientId(clusterId));
|
|
118
|
+
clusterClientList.forEach((_clusterId) => {
|
|
129
119
|
});
|
|
130
120
|
return behaviorTypes;
|
|
131
121
|
}
|
|
132
122
|
export function getBehaviourTypeFromClusterServerId(clusterId) {
|
|
133
|
-
// Map ClusterId to Server Behavior.Type
|
|
134
123
|
if (clusterId === PowerSource.Cluster.id)
|
|
135
124
|
return PowerSourceServer.with(PowerSource.Feature.Wired);
|
|
136
125
|
if (clusterId === UserLabel.Cluster.id)
|
|
@@ -217,9 +206,7 @@ export function getBehaviourTypeFromClusterServerId(clusterId) {
|
|
|
217
206
|
return TotalVolatileOrganicCompoundsConcentrationMeasurementServer.with('NumericMeasurement');
|
|
218
207
|
return MatterbridgeIdentifyServer;
|
|
219
208
|
}
|
|
220
|
-
export function getBehaviourTypeFromClusterClientId(
|
|
221
|
-
// Map ClusterId to Client Behavior.Type
|
|
222
|
-
// return IdentifyClient;
|
|
209
|
+
export function getBehaviourTypeFromClusterClientId(_clusterId) {
|
|
223
210
|
}
|
|
224
211
|
export function getBehavior(endpoint, cluster) {
|
|
225
212
|
let behavior;
|
|
@@ -237,6 +224,21 @@ export function getBehavior(endpoint, cluster) {
|
|
|
237
224
|
}
|
|
238
225
|
return behavior;
|
|
239
226
|
}
|
|
227
|
+
export async function invokeBehaviorCommand(endpoint, cluster, command, params) {
|
|
228
|
+
const behaviorId = getBehavior(endpoint, cluster)?.id;
|
|
229
|
+
if (!behaviorId) {
|
|
230
|
+
endpoint.log.error(`invokeBehaviorCommand error: command ${hk}${command}${er} not found on endpoint ${or}${endpoint.maybeId}${er}:${or}${endpoint.maybeNumber}${er}`);
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
await endpoint.act((agent) => {
|
|
234
|
+
const behavior = agent[behaviorId];
|
|
235
|
+
if (!(command in behavior) || typeof behavior[command] !== 'function') {
|
|
236
|
+
endpoint.log.error(`invokeBehaviorCommand error: command ${hk}${command}${er} not found on agent for endpoint ${or}${endpoint.maybeId}${er}:${or}${endpoint.maybeNumber}${er}`);
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
behavior[command](params);
|
|
240
|
+
});
|
|
241
|
+
}
|
|
240
242
|
export function addRequiredClusterServers(endpoint) {
|
|
241
243
|
const requiredServerList = [];
|
|
242
244
|
endpoint.log.debug(`addRequiredClusterServers for ${CYAN}${endpoint.maybeId}${db}`);
|
|
@@ -265,13 +267,6 @@ export function addOptionalClusterServers(endpoint) {
|
|
|
265
267
|
});
|
|
266
268
|
addClusterServers(endpoint, optionalServerList);
|
|
267
269
|
}
|
|
268
|
-
/**
|
|
269
|
-
* Adds cluster servers to the specified endpoint based on the provided server list.
|
|
270
|
-
*
|
|
271
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to add the cluster servers to.
|
|
272
|
-
* @param {ClusterId[]} serverList - The list of cluster IDs to add.
|
|
273
|
-
* @returns void
|
|
274
|
-
*/
|
|
275
270
|
export function addClusterServers(endpoint, serverList) {
|
|
276
271
|
if (serverList.includes(PowerSource.Cluster.id))
|
|
277
272
|
endpoint.createDefaultPowerSourceWiredClusterServer();
|
|
@@ -347,16 +342,7 @@ export function addClusterServers(endpoint, serverList) {
|
|
|
347
342
|
endpoint.createDefaultRadonConcentrationMeasurementClusterServer();
|
|
348
343
|
if (serverList.includes(TotalVolatileOrganicCompoundsConcentrationMeasurement.Cluster.id))
|
|
349
344
|
endpoint.createDefaultTvocMeasurementClusterServer();
|
|
350
|
-
// if (serverList.includes(DeviceEnergyManagement.Cluster.id)) endpoint.createDefaultDeviceEnergyManagementClusterServer();
|
|
351
|
-
// if (serverList.includes(DeviceEnergyManagementMode.Cluster.id)) endpoint.createDefaultDeviceEnergyManagementModeClusterServer();
|
|
352
345
|
}
|
|
353
|
-
/**
|
|
354
|
-
* Adds a fixed label to the FixedLabel cluster. The FixedLabel cluster is created if it does not exist.
|
|
355
|
-
*
|
|
356
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to add the cluster servers to.
|
|
357
|
-
* @param {string} label - The label to add.
|
|
358
|
-
* @param {string} value - The value of the label.
|
|
359
|
-
*/
|
|
360
346
|
export async function addFixedLabel(endpoint, label, value) {
|
|
361
347
|
if (!endpoint.hasClusterServer(FixedLabel.Cluster.id)) {
|
|
362
348
|
endpoint.log.debug(`addFixedLabel: add cluster ${hk}FixedLabel${db}:${hk}fixedLabel${db} with label ${CYAN}${label}${db} value ${CYAN}${value}${db}`);
|
|
@@ -373,13 +359,6 @@ export async function addFixedLabel(endpoint, label, value) {
|
|
|
373
359
|
await endpoint.setAttribute(FixedLabel.Cluster.id, 'labelList', labelList, endpoint.log);
|
|
374
360
|
}
|
|
375
361
|
}
|
|
376
|
-
/**
|
|
377
|
-
* Adds a user label to the UserLabel cluster. The UserLabel cluster is created if it does not exist.
|
|
378
|
-
*
|
|
379
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to add the cluster servers to.
|
|
380
|
-
* @param {string} label - The label to add.
|
|
381
|
-
* @param {string} value - The value of the label.
|
|
382
|
-
*/
|
|
383
362
|
export async function addUserLabel(endpoint, label, value) {
|
|
384
363
|
if (!endpoint.hasClusterServer(UserLabel.Cluster.id)) {
|
|
385
364
|
endpoint.log.debug(`addUserLabel: add cluster ${hk}UserLabel${db}:${hk}userLabel${db} with label ${CYAN}${label}${db} value ${CYAN}${value}${db}`);
|
|
@@ -457,16 +436,6 @@ export function getAttributeId(endpoint, cluster, attribute) {
|
|
|
457
436
|
return endpoint.behaviors.supported[lowercaseFirstLetter(cluster)]?.schema?.children?.find((child) => child.name === capitalizeFirstLetter(attribute))?.id;
|
|
458
437
|
}
|
|
459
438
|
}
|
|
460
|
-
/**
|
|
461
|
-
* Retrieves the value of the provided attribute from the given cluster.
|
|
462
|
-
*
|
|
463
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to retrieve the attribute from.
|
|
464
|
-
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to retrieve the attribute from.
|
|
465
|
-
* @param {string} attribute - The name of the attribute to retrieve.
|
|
466
|
-
* @param {AnsiLogger} [log] - (Optional) The logger to use for logging the retrieve. Errors are logged to the endpoint logger.
|
|
467
|
-
* @returns {any} The value of the attribute, or undefined if the attribute is not found.
|
|
468
|
-
*/
|
|
469
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
470
439
|
export function getAttribute(endpoint, cluster, attribute, log) {
|
|
471
440
|
const clusterName = getBehavior(endpoint, cluster)?.id;
|
|
472
441
|
if (!clusterName) {
|
|
@@ -489,16 +458,6 @@ export function getAttribute(endpoint, cluster, attribute, log) {
|
|
|
489
458
|
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}`);
|
|
490
459
|
return value;
|
|
491
460
|
}
|
|
492
|
-
/**
|
|
493
|
-
* Sets the value of an attribute on a cluster server.
|
|
494
|
-
*
|
|
495
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to set the attribute on.
|
|
496
|
-
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to set the attribute on.
|
|
497
|
-
* @param {string} attribute - The name of the attribute.
|
|
498
|
-
* @param {boolean | number | bigint | string | object | null} value - The value to set for the attribute.
|
|
499
|
-
* @param {AnsiLogger} [log] - (Optional) The logger to use for logging the set. Errors are logged to the endpoint logger.
|
|
500
|
-
* @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the attribute was successfully set.
|
|
501
|
-
*/
|
|
502
461
|
export async function setAttribute(endpoint, cluster, attribute, value, log) {
|
|
503
462
|
const clusterName = getBehavior(endpoint, cluster)?.id;
|
|
504
463
|
if (!clusterName) {
|
|
@@ -524,16 +483,6 @@ export async function setAttribute(endpoint, cluster, attribute, value, log) {
|
|
|
524
483
|
`to ${YELLOW}${value !== null && typeof value === 'object' ? debugStringify(value) : value}${db}`);
|
|
525
484
|
return true;
|
|
526
485
|
}
|
|
527
|
-
/**
|
|
528
|
-
* Sets the value of an attribute on a cluster server.
|
|
529
|
-
*
|
|
530
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to update the attribute on.
|
|
531
|
-
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to update the attribute on.
|
|
532
|
-
* @param {string} attribute - The name of the attribute.
|
|
533
|
-
* @param {boolean | number | bigint | string | object | null} value - The value to set for the attribute.
|
|
534
|
-
* @param {AnsiLogger} [log] - (Optional) The logger to use for logging the update. Errors are logged to the endpoint logger.
|
|
535
|
-
* @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the attribute was successfully set.
|
|
536
|
-
*/
|
|
537
486
|
export async function updateAttribute(endpoint, cluster, attribute, value, log) {
|
|
538
487
|
const clusterName = getBehavior(endpoint, cluster)?.id;
|
|
539
488
|
if (!clusterName) {
|
|
@@ -564,17 +513,6 @@ export async function updateAttribute(endpoint, cluster, attribute, value, log)
|
|
|
564
513
|
`to ${YELLOW}${value !== null && typeof value === 'object' ? debugStringify(value) : value}${db}`);
|
|
565
514
|
return true;
|
|
566
515
|
}
|
|
567
|
-
/**
|
|
568
|
-
* Subscribes to the provided attribute on a cluster.
|
|
569
|
-
*
|
|
570
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to subscribe the attribute to.
|
|
571
|
-
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to subscribe the attribute to.
|
|
572
|
-
* @param {string} attribute - The name of the attribute to subscribe to.
|
|
573
|
-
* @param {(newValue: any, oldValue: any) => void} listener - A callback function that will be called when the attribute value changes.
|
|
574
|
-
* @param {AnsiLogger} [log] - Optional logger for logging errors and information.
|
|
575
|
-
* @returns {boolean} - A boolean indicating whether the subscription was successful.
|
|
576
|
-
*/
|
|
577
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
578
516
|
export async function subscribeAttribute(endpoint, cluster, attribute, listener, log) {
|
|
579
517
|
const clusterName = getBehavior(endpoint, cluster)?.id;
|
|
580
518
|
if (!clusterName) {
|
|
@@ -585,7 +523,6 @@ export async function subscribeAttribute(endpoint, cluster, attribute, listener,
|
|
|
585
523
|
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`);
|
|
586
524
|
await endpoint.construction.ready;
|
|
587
525
|
}
|
|
588
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
589
526
|
const events = endpoint.events;
|
|
590
527
|
attribute = lowercaseFirstLetter(attribute) + '$Changed';
|
|
591
528
|
if (!(clusterName in events) || !(attribute in events[clusterName])) {
|
|
@@ -596,13 +533,20 @@ export async function subscribeAttribute(endpoint, cluster, attribute, listener,
|
|
|
596
533
|
log?.info(`${db}Subscribed endpoint ${or}${endpoint.id}${db}:${or}${endpoint.number}${db} attribute ${hk}${capitalizeFirstLetter(clusterName)}${db}.${hk}${attribute}${db}`);
|
|
597
534
|
return true;
|
|
598
535
|
}
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
536
|
+
export function getDefaultOperationalStateClusterServer(operationalState = OperationalState.OperationalStateEnum.Stopped) {
|
|
537
|
+
return optionsFor(MatterbridgeOperationalStateServer, {
|
|
538
|
+
phaseList: [],
|
|
539
|
+
currentPhase: null,
|
|
540
|
+
operationalStateList: [
|
|
541
|
+
{ operationalStateId: OperationalState.OperationalStateEnum.Stopped, operationalStateLabel: 'Stopped' },
|
|
542
|
+
{ operationalStateId: OperationalState.OperationalStateEnum.Running, operationalStateLabel: 'Running' },
|
|
543
|
+
{ operationalStateId: OperationalState.OperationalStateEnum.Paused, operationalStateLabel: 'Paused' },
|
|
544
|
+
{ operationalStateId: OperationalState.OperationalStateEnum.Error, operationalStateLabel: 'Error' },
|
|
545
|
+
],
|
|
546
|
+
operationalState,
|
|
547
|
+
operationalError: { errorStateId: OperationalState.ErrorState.NoError, errorStateLabel: 'No error', errorStateDetails: 'Fully operational' },
|
|
548
|
+
});
|
|
549
|
+
}
|
|
606
550
|
export function getDefaultTemperatureMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
607
551
|
return optionsFor(TemperatureMeasurementServer, {
|
|
608
552
|
measuredValue,
|
|
@@ -611,13 +555,6 @@ export function getDefaultTemperatureMeasurementClusterServer(measuredValue = nu
|
|
|
611
555
|
tolerance: 0,
|
|
612
556
|
});
|
|
613
557
|
}
|
|
614
|
-
/**
|
|
615
|
-
* Get the default RelativeHumidityMeasurement cluster server options.
|
|
616
|
-
*
|
|
617
|
-
* @param {number | null} measuredValue - The measured value of the relative humidity x 100.
|
|
618
|
-
* @param {number | null} minMeasuredValue - The minimum measured value of the relative humidity x 100.
|
|
619
|
-
* @param {number | null} maxMeasuredValue - The maximum measured value of the relative humidity x 100.
|
|
620
|
-
*/
|
|
621
558
|
export function getDefaultRelativeHumidityMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
622
559
|
return optionsFor(RelativeHumidityMeasurementServer, {
|
|
623
560
|
measuredValue,
|
|
@@ -626,13 +563,6 @@ export function getDefaultRelativeHumidityMeasurementClusterServer(measuredValue
|
|
|
626
563
|
tolerance: 0,
|
|
627
564
|
});
|
|
628
565
|
}
|
|
629
|
-
/**
|
|
630
|
-
* Get the default PressureMeasurement cluster server options.
|
|
631
|
-
*
|
|
632
|
-
* @param {number | null} measuredValue - The measured value for the pressure.
|
|
633
|
-
* @param {number | null} minMeasuredValue - The minimum measured value for the pressure.
|
|
634
|
-
* @param {number | null} maxMeasuredValue - The maximum measured value for the pressure.
|
|
635
|
-
*/
|
|
636
566
|
export function getDefaultPressureMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
637
567
|
return optionsFor(PressureMeasurementServer, {
|
|
638
568
|
measuredValue,
|
|
@@ -641,19 +571,6 @@ export function getDefaultPressureMeasurementClusterServer(measuredValue = null,
|
|
|
641
571
|
tolerance: 0,
|
|
642
572
|
});
|
|
643
573
|
}
|
|
644
|
-
/**
|
|
645
|
-
* Get the default IlluminanceMeasurement cluster server options.
|
|
646
|
-
*
|
|
647
|
-
* @param {number | null} measuredValue - The measured value of illuminance.
|
|
648
|
-
* @param {number | null} minMeasuredValue - The minimum measured value of illuminance.
|
|
649
|
-
* @param {number | null} maxMeasuredValue - The maximum measured value of illuminance.
|
|
650
|
-
* @remark The default value for the illuminance measurement is null.
|
|
651
|
-
* This attribute SHALL indicate the illuminance in Lux (symbol lx) as follows:
|
|
652
|
-
* • MeasuredValue = 10,000 x log10(illuminance) + 1,
|
|
653
|
-
* where 1 lx <= illuminance <= 3.576 Mlx, corresponding to a MeasuredValue in the range 1 to 0xFFFE.
|
|
654
|
-
* • 0 indicates a value of illuminance that is too low to be measured
|
|
655
|
-
* • null indicates that the illuminance measurement is invalid.
|
|
656
|
-
*/
|
|
657
574
|
export function getDefaultIlluminanceMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
658
575
|
return optionsFor(IlluminanceMeasurementServer, {
|
|
659
576
|
measuredValue,
|
|
@@ -662,13 +579,6 @@ export function getDefaultIlluminanceMeasurementClusterServer(measuredValue = nu
|
|
|
662
579
|
tolerance: 0,
|
|
663
580
|
});
|
|
664
581
|
}
|
|
665
|
-
/**
|
|
666
|
-
* Get the default FlowMeasurement cluster server options.
|
|
667
|
-
*
|
|
668
|
-
* @param {number | null} measuredValue - The measured value of the flow in 10 x m3/h.
|
|
669
|
-
* @param {number | null} minMeasuredValue - The minimum measured value of the flow in 10 x m3/h.
|
|
670
|
-
* @param {number | null} maxMeasuredValue - The maximum measured value of the flow in 10 x m3/h.
|
|
671
|
-
*/
|
|
672
582
|
export function getDefaultFlowMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
673
583
|
return optionsFor(FlowMeasurementServer, {
|
|
674
584
|
measuredValue,
|
|
@@ -677,19 +587,6 @@ export function getDefaultFlowMeasurementClusterServer(measuredValue = null, min
|
|
|
677
587
|
tolerance: 0,
|
|
678
588
|
});
|
|
679
589
|
}
|
|
680
|
-
/**
|
|
681
|
-
* Get the default OccupancySensing cluster server options.
|
|
682
|
-
*
|
|
683
|
-
* @param {boolean} occupied - A boolean indicating whether the occupancy is occupied or not. Default is false.
|
|
684
|
-
* @param {number} holdTime - The hold time in seconds. Default is 30.
|
|
685
|
-
* @param {number} holdTimeMin - The minimum hold time in seconds. Default is 1.
|
|
686
|
-
* @param {number} holdTimeMax - The maximum hold time in seconds. Default is 300.
|
|
687
|
-
*
|
|
688
|
-
* @remark The default value for the occupancy sensor type is PIR.
|
|
689
|
-
* Servers SHALL set these attributes for backward compatibility with clients implementing a cluster revision <= 4 as
|
|
690
|
-
* described in OccupancySensorType and OccupancySensorTypeBitmap Attributes.
|
|
691
|
-
* This replaces the 9 legacy attributes PIROccupiedToUnoccupiedDelay through PhysicalContactUnoccupiedToOccupiedThreshold.
|
|
692
|
-
*/
|
|
693
590
|
export function getDefaultOccupancySensingClusterServer(occupied = false, holdTime = 30, holdTimeMin = 1, holdTimeMax = 300) {
|
|
694
591
|
return optionsFor(OccupancySensingServer.with(OccupancySensing.Feature.PassiveInfrared), {
|
|
695
592
|
occupancy: { occupied },
|
|
@@ -701,4 +598,3 @@ export function getDefaultOccupancySensingClusterServer(occupied = false, holdTi
|
|
|
701
598
|
holdTimeLimits: { holdTimeMin, holdTimeMax, holdTimeDefault: holdTime },
|
|
702
599
|
});
|
|
703
600
|
}
|
|
704
|
-
//# sourceMappingURL=matterbridgeEndpointHelpers.js.map
|