matterbridge 3.0.1 → 3.0.2-dev-20250508-7214e17
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 -0
- package/README.md +1 -1
- 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 +15 -328
- 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 +80 -747
- 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 +13 -814
- package/dist/matterbridgeEndpointHelpers.js +29 -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;
|
|
@@ -265,13 +252,6 @@ export function addOptionalClusterServers(endpoint) {
|
|
|
265
252
|
});
|
|
266
253
|
addClusterServers(endpoint, optionalServerList);
|
|
267
254
|
}
|
|
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
255
|
export function addClusterServers(endpoint, serverList) {
|
|
276
256
|
if (serverList.includes(PowerSource.Cluster.id))
|
|
277
257
|
endpoint.createDefaultPowerSourceWiredClusterServer();
|
|
@@ -347,16 +327,7 @@ export function addClusterServers(endpoint, serverList) {
|
|
|
347
327
|
endpoint.createDefaultRadonConcentrationMeasurementClusterServer();
|
|
348
328
|
if (serverList.includes(TotalVolatileOrganicCompoundsConcentrationMeasurement.Cluster.id))
|
|
349
329
|
endpoint.createDefaultTvocMeasurementClusterServer();
|
|
350
|
-
// if (serverList.includes(DeviceEnergyManagement.Cluster.id)) endpoint.createDefaultDeviceEnergyManagementClusterServer();
|
|
351
|
-
// if (serverList.includes(DeviceEnergyManagementMode.Cluster.id)) endpoint.createDefaultDeviceEnergyManagementModeClusterServer();
|
|
352
330
|
}
|
|
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
331
|
export async function addFixedLabel(endpoint, label, value) {
|
|
361
332
|
if (!endpoint.hasClusterServer(FixedLabel.Cluster.id)) {
|
|
362
333
|
endpoint.log.debug(`addFixedLabel: add cluster ${hk}FixedLabel${db}:${hk}fixedLabel${db} with label ${CYAN}${label}${db} value ${CYAN}${value}${db}`);
|
|
@@ -373,13 +344,6 @@ export async function addFixedLabel(endpoint, label, value) {
|
|
|
373
344
|
await endpoint.setAttribute(FixedLabel.Cluster.id, 'labelList', labelList, endpoint.log);
|
|
374
345
|
}
|
|
375
346
|
}
|
|
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
347
|
export async function addUserLabel(endpoint, label, value) {
|
|
384
348
|
if (!endpoint.hasClusterServer(UserLabel.Cluster.id)) {
|
|
385
349
|
endpoint.log.debug(`addUserLabel: add cluster ${hk}UserLabel${db}:${hk}userLabel${db} with label ${CYAN}${label}${db} value ${CYAN}${value}${db}`);
|
|
@@ -457,16 +421,6 @@ export function getAttributeId(endpoint, cluster, attribute) {
|
|
|
457
421
|
return endpoint.behaviors.supported[lowercaseFirstLetter(cluster)]?.schema?.children?.find((child) => child.name === capitalizeFirstLetter(attribute))?.id;
|
|
458
422
|
}
|
|
459
423
|
}
|
|
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
424
|
export function getAttribute(endpoint, cluster, attribute, log) {
|
|
471
425
|
const clusterName = getBehavior(endpoint, cluster)?.id;
|
|
472
426
|
if (!clusterName) {
|
|
@@ -489,16 +443,6 @@ export function getAttribute(endpoint, cluster, attribute, log) {
|
|
|
489
443
|
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
444
|
return value;
|
|
491
445
|
}
|
|
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
446
|
export async function setAttribute(endpoint, cluster, attribute, value, log) {
|
|
503
447
|
const clusterName = getBehavior(endpoint, cluster)?.id;
|
|
504
448
|
if (!clusterName) {
|
|
@@ -524,16 +468,6 @@ export async function setAttribute(endpoint, cluster, attribute, value, log) {
|
|
|
524
468
|
`to ${YELLOW}${value !== null && typeof value === 'object' ? debugStringify(value) : value}${db}`);
|
|
525
469
|
return true;
|
|
526
470
|
}
|
|
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
471
|
export async function updateAttribute(endpoint, cluster, attribute, value, log) {
|
|
538
472
|
const clusterName = getBehavior(endpoint, cluster)?.id;
|
|
539
473
|
if (!clusterName) {
|
|
@@ -564,17 +498,6 @@ export async function updateAttribute(endpoint, cluster, attribute, value, log)
|
|
|
564
498
|
`to ${YELLOW}${value !== null && typeof value === 'object' ? debugStringify(value) : value}${db}`);
|
|
565
499
|
return true;
|
|
566
500
|
}
|
|
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
501
|
export async function subscribeAttribute(endpoint, cluster, attribute, listener, log) {
|
|
579
502
|
const clusterName = getBehavior(endpoint, cluster)?.id;
|
|
580
503
|
if (!clusterName) {
|
|
@@ -585,7 +508,6 @@ export async function subscribeAttribute(endpoint, cluster, attribute, listener,
|
|
|
585
508
|
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
509
|
await endpoint.construction.ready;
|
|
587
510
|
}
|
|
588
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
589
511
|
const events = endpoint.events;
|
|
590
512
|
attribute = lowercaseFirstLetter(attribute) + '$Changed';
|
|
591
513
|
if (!(clusterName in events) || !(attribute in events[clusterName])) {
|
|
@@ -596,13 +518,20 @@ export async function subscribeAttribute(endpoint, cluster, attribute, listener,
|
|
|
596
518
|
log?.info(`${db}Subscribed endpoint ${or}${endpoint.id}${db}:${or}${endpoint.number}${db} attribute ${hk}${capitalizeFirstLetter(clusterName)}${db}.${hk}${attribute}${db}`);
|
|
597
519
|
return true;
|
|
598
520
|
}
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
521
|
+
export function getDefaultOperationalStateClusterServer(operationalState = OperationalState.OperationalStateEnum.Stopped) {
|
|
522
|
+
return optionsFor(MatterbridgeOperationalStateServer, {
|
|
523
|
+
phaseList: [],
|
|
524
|
+
currentPhase: null,
|
|
525
|
+
operationalStateList: [
|
|
526
|
+
{ operationalStateId: OperationalState.OperationalStateEnum.Stopped, operationalStateLabel: 'Stopped' },
|
|
527
|
+
{ operationalStateId: OperationalState.OperationalStateEnum.Running, operationalStateLabel: 'Running' },
|
|
528
|
+
{ operationalStateId: OperationalState.OperationalStateEnum.Paused, operationalStateLabel: 'Paused' },
|
|
529
|
+
{ operationalStateId: OperationalState.OperationalStateEnum.Error, operationalStateLabel: 'Error' },
|
|
530
|
+
],
|
|
531
|
+
operationalState,
|
|
532
|
+
operationalError: { errorStateId: OperationalState.ErrorState.NoError, errorStateLabel: 'No error', errorStateDetails: 'Fully operational' },
|
|
533
|
+
});
|
|
534
|
+
}
|
|
606
535
|
export function getDefaultTemperatureMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
607
536
|
return optionsFor(TemperatureMeasurementServer, {
|
|
608
537
|
measuredValue,
|
|
@@ -611,13 +540,6 @@ export function getDefaultTemperatureMeasurementClusterServer(measuredValue = nu
|
|
|
611
540
|
tolerance: 0,
|
|
612
541
|
});
|
|
613
542
|
}
|
|
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
543
|
export function getDefaultRelativeHumidityMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
622
544
|
return optionsFor(RelativeHumidityMeasurementServer, {
|
|
623
545
|
measuredValue,
|
|
@@ -626,13 +548,6 @@ export function getDefaultRelativeHumidityMeasurementClusterServer(measuredValue
|
|
|
626
548
|
tolerance: 0,
|
|
627
549
|
});
|
|
628
550
|
}
|
|
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
551
|
export function getDefaultPressureMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
637
552
|
return optionsFor(PressureMeasurementServer, {
|
|
638
553
|
measuredValue,
|
|
@@ -641,19 +556,6 @@ export function getDefaultPressureMeasurementClusterServer(measuredValue = null,
|
|
|
641
556
|
tolerance: 0,
|
|
642
557
|
});
|
|
643
558
|
}
|
|
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
559
|
export function getDefaultIlluminanceMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
658
560
|
return optionsFor(IlluminanceMeasurementServer, {
|
|
659
561
|
measuredValue,
|
|
@@ -662,13 +564,6 @@ export function getDefaultIlluminanceMeasurementClusterServer(measuredValue = nu
|
|
|
662
564
|
tolerance: 0,
|
|
663
565
|
});
|
|
664
566
|
}
|
|
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
567
|
export function getDefaultFlowMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
673
568
|
return optionsFor(FlowMeasurementServer, {
|
|
674
569
|
measuredValue,
|
|
@@ -677,19 +572,6 @@ export function getDefaultFlowMeasurementClusterServer(measuredValue = null, min
|
|
|
677
572
|
tolerance: 0,
|
|
678
573
|
});
|
|
679
574
|
}
|
|
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
575
|
export function getDefaultOccupancySensingClusterServer(occupied = false, holdTime = 30, holdTimeMin = 1, holdTimeMax = 300) {
|
|
694
576
|
return optionsFor(OccupancySensingServer.with(OccupancySensing.Feature.PassiveInfrared), {
|
|
695
577
|
occupancy: { occupied },
|
|
@@ -701,4 +583,3 @@ export function getDefaultOccupancySensingClusterServer(occupied = false, holdTi
|
|
|
701
583
|
holdTimeLimits: { holdTimeMin, holdTimeMax, holdTimeDefault: holdTime },
|
|
702
584
|
});
|
|
703
585
|
}
|
|
704
|
-
//# sourceMappingURL=matterbridgeEndpointHelpers.js.map
|