matterbridge 3.0.2 → 3.0.3-dev-20250517-bcc5d13
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 +20 -3
- 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 +62 -369
- package/dist/helpers.js +0 -49
- package/dist/index.js +2 -31
- 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 +134 -873
- package/dist/matterbridgeAccessoryPlatform.js +0 -34
- package/dist/matterbridgeBehaviors.js +4 -53
- package/dist/matterbridgeDeviceTypes.js +12 -431
- package/dist/matterbridgeDynamicPlatform.js +0 -34
- package/dist/matterbridgeEndpoint.js +11 -807
- package/dist/matterbridgeEndpointHelpers.js +9 -147
- package/dist/matterbridgePlatform.js +7 -225
- package/dist/matterbridgeTypes.js +0 -24
- package/dist/pluginManager.js +3 -264
- package/dist/roboticVacuumCleaner.js +3 -39
- 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 +20 -56
- 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 -241
- package/dist/frontend.d.ts.map +0 -1
- package/dist/frontend.js.map +0 -1
- package/dist/helpers.d.ts +0 -46
- package/dist/helpers.d.ts.map +0 -1
- package/dist/helpers.js.map +0 -1
- package/dist/index.d.ts +0 -36
- 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 -435
- 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 -1188
- 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 -965
- 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 -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/roboticVacuumCleaner.d.ts +0 -43
- 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 -51
- package/dist/utils/wait.d.ts.map +0 -1
- package/dist/utils/wait.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,10 +71,8 @@ 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
77
|
import { MatterbridgeIdentifyServer, MatterbridgeOnOffServer, MatterbridgeLevelControlServer, MatterbridgeColorControlServer, MatterbridgeWindowCoveringServer, MatterbridgeThermostatServer, MatterbridgeFanControlServer, MatterbridgeDoorLockServer, MatterbridgeModeSelectServer, MatterbridgeValveConfigurationAndControlServer, MatterbridgeSmokeCoAlarmServer, MatterbridgeBooleanStateConfigurationServer, MatterbridgeOperationalStateServer, } from './matterbridgeBehaviors.js';
|
|
84
78
|
export function capitalizeFirstLetter(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)
|
|
@@ -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}`);
|
|
@@ -473,16 +437,6 @@ export function getAttributeId(endpoint, cluster, attribute) {
|
|
|
473
437
|
return endpoint.behaviors.supported[lowercaseFirstLetter(cluster)]?.schema?.children?.find((child) => child.name === capitalizeFirstLetter(attribute))?.id;
|
|
474
438
|
}
|
|
475
439
|
}
|
|
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
440
|
export function getAttribute(endpoint, cluster, attribute, log) {
|
|
487
441
|
const clusterName = getBehavior(endpoint, cluster)?.id;
|
|
488
442
|
if (!clusterName) {
|
|
@@ -505,16 +459,6 @@ export function getAttribute(endpoint, cluster, attribute, log) {
|
|
|
505
459
|
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
460
|
return value;
|
|
507
461
|
}
|
|
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
462
|
export async function setAttribute(endpoint, cluster, attribute, value, log) {
|
|
519
463
|
const clusterName = getBehavior(endpoint, cluster)?.id;
|
|
520
464
|
if (!clusterName) {
|
|
@@ -540,16 +484,6 @@ export async function setAttribute(endpoint, cluster, attribute, value, log) {
|
|
|
540
484
|
`to ${YELLOW}${value !== null && typeof value === 'object' ? debugStringify(value) : value}${db}`);
|
|
541
485
|
return true;
|
|
542
486
|
}
|
|
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
487
|
export async function updateAttribute(endpoint, cluster, attribute, value, log) {
|
|
554
488
|
const clusterName = getBehavior(endpoint, cluster)?.id;
|
|
555
489
|
if (!clusterName) {
|
|
@@ -580,17 +514,6 @@ export async function updateAttribute(endpoint, cluster, attribute, value, log)
|
|
|
580
514
|
`to ${YELLOW}${value !== null && typeof value === 'object' ? debugStringify(value) : value}${db}`);
|
|
581
515
|
return true;
|
|
582
516
|
}
|
|
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) => 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
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
594
517
|
export async function subscribeAttribute(endpoint, cluster, attribute, listener, log) {
|
|
595
518
|
const clusterName = getBehavior(endpoint, cluster)?.id;
|
|
596
519
|
if (!clusterName) {
|
|
@@ -601,7 +524,6 @@ export async function subscribeAttribute(endpoint, cluster, attribute, listener,
|
|
|
601
524
|
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`);
|
|
602
525
|
await endpoint.construction.ready;
|
|
603
526
|
}
|
|
604
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
605
527
|
const events = endpoint.events;
|
|
606
528
|
attribute = lowercaseFirstLetter(attribute) + '$Changed';
|
|
607
529
|
if (!(clusterName in events) || !(attribute in events[clusterName])) {
|
|
@@ -612,11 +534,6 @@ export async function subscribeAttribute(endpoint, cluster, attribute, listener,
|
|
|
612
534
|
log?.info(`${db}Subscribed endpoint ${or}${endpoint.id}${db}:${or}${endpoint.number}${db} attribute ${hk}${capitalizeFirstLetter(clusterName)}${db}.${hk}${attribute}${db}`);
|
|
613
535
|
return true;
|
|
614
536
|
}
|
|
615
|
-
/**
|
|
616
|
-
* Get the default OperationalState Cluster Server.
|
|
617
|
-
*
|
|
618
|
-
* @param {OperationalState.OperationalStateEnum} operationalState - The initial operational state.
|
|
619
|
-
*/
|
|
620
537
|
export function getDefaultOperationalStateClusterServer(operationalState = OperationalState.OperationalStateEnum.Stopped) {
|
|
621
538
|
return optionsFor(MatterbridgeOperationalStateServer, {
|
|
622
539
|
phaseList: [],
|
|
@@ -631,13 +548,6 @@ export function getDefaultOperationalStateClusterServer(operationalState = Opera
|
|
|
631
548
|
operationalError: { errorStateId: OperationalState.ErrorState.NoError, errorStateLabel: 'No error', errorStateDetails: 'Fully operational' },
|
|
632
549
|
});
|
|
633
550
|
}
|
|
634
|
-
/**
|
|
635
|
-
* Get the default TemperatureMeasurement cluster server options.
|
|
636
|
-
*
|
|
637
|
-
* @param {number | null} measuredValue - The measured value of the temperature x 100.
|
|
638
|
-
* @param {number | null} minMeasuredValue - The minimum measured value of the temperature x 100.
|
|
639
|
-
* @param {number | null} maxMeasuredValue - The maximum measured value of the temperature x 100.
|
|
640
|
-
*/
|
|
641
551
|
export function getDefaultTemperatureMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
642
552
|
return optionsFor(TemperatureMeasurementServer, {
|
|
643
553
|
measuredValue,
|
|
@@ -646,13 +556,6 @@ export function getDefaultTemperatureMeasurementClusterServer(measuredValue = nu
|
|
|
646
556
|
tolerance: 0,
|
|
647
557
|
});
|
|
648
558
|
}
|
|
649
|
-
/**
|
|
650
|
-
* Get the default RelativeHumidityMeasurement cluster server options.
|
|
651
|
-
*
|
|
652
|
-
* @param {number | null} measuredValue - The measured value of the relative humidity x 100.
|
|
653
|
-
* @param {number | null} minMeasuredValue - The minimum measured value of the relative humidity x 100.
|
|
654
|
-
* @param {number | null} maxMeasuredValue - The maximum measured value of the relative humidity x 100.
|
|
655
|
-
*/
|
|
656
559
|
export function getDefaultRelativeHumidityMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
657
560
|
return optionsFor(RelativeHumidityMeasurementServer, {
|
|
658
561
|
measuredValue,
|
|
@@ -661,13 +564,6 @@ export function getDefaultRelativeHumidityMeasurementClusterServer(measuredValue
|
|
|
661
564
|
tolerance: 0,
|
|
662
565
|
});
|
|
663
566
|
}
|
|
664
|
-
/**
|
|
665
|
-
* Get the default PressureMeasurement cluster server options.
|
|
666
|
-
*
|
|
667
|
-
* @param {number | null} measuredValue - The measured value for the pressure.
|
|
668
|
-
* @param {number | null} minMeasuredValue - The minimum measured value for the pressure.
|
|
669
|
-
* @param {number | null} maxMeasuredValue - The maximum measured value for the pressure.
|
|
670
|
-
*/
|
|
671
567
|
export function getDefaultPressureMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
672
568
|
return optionsFor(PressureMeasurementServer, {
|
|
673
569
|
measuredValue,
|
|
@@ -676,19 +572,6 @@ export function getDefaultPressureMeasurementClusterServer(measuredValue = null,
|
|
|
676
572
|
tolerance: 0,
|
|
677
573
|
});
|
|
678
574
|
}
|
|
679
|
-
/**
|
|
680
|
-
* Get the default IlluminanceMeasurement cluster server options.
|
|
681
|
-
*
|
|
682
|
-
* @param {number | null} measuredValue - The measured value of illuminance.
|
|
683
|
-
* @param {number | null} minMeasuredValue - The minimum measured value of illuminance.
|
|
684
|
-
* @param {number | null} maxMeasuredValue - The maximum measured value of illuminance.
|
|
685
|
-
* @remark The default value for the illuminance measurement is null.
|
|
686
|
-
* This attribute SHALL indicate the illuminance in Lux (symbol lx) as follows:
|
|
687
|
-
* • MeasuredValue = 10,000 x log10(illuminance) + 1,
|
|
688
|
-
* where 1 lx <= illuminance <= 3.576 Mlx, corresponding to a MeasuredValue in the range 1 to 0xFFFE.
|
|
689
|
-
* • 0 indicates a value of illuminance that is too low to be measured
|
|
690
|
-
* • null indicates that the illuminance measurement is invalid.
|
|
691
|
-
*/
|
|
692
575
|
export function getDefaultIlluminanceMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
693
576
|
return optionsFor(IlluminanceMeasurementServer, {
|
|
694
577
|
measuredValue,
|
|
@@ -697,13 +580,6 @@ export function getDefaultIlluminanceMeasurementClusterServer(measuredValue = nu
|
|
|
697
580
|
tolerance: 0,
|
|
698
581
|
});
|
|
699
582
|
}
|
|
700
|
-
/**
|
|
701
|
-
* Get the default FlowMeasurement cluster server options.
|
|
702
|
-
*
|
|
703
|
-
* @param {number | null} measuredValue - The measured value of the flow in 10 x m3/h.
|
|
704
|
-
* @param {number | null} minMeasuredValue - The minimum measured value of the flow in 10 x m3/h.
|
|
705
|
-
* @param {number | null} maxMeasuredValue - The maximum measured value of the flow in 10 x m3/h.
|
|
706
|
-
*/
|
|
707
583
|
export function getDefaultFlowMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
708
584
|
return optionsFor(FlowMeasurementServer, {
|
|
709
585
|
measuredValue,
|
|
@@ -712,19 +588,6 @@ export function getDefaultFlowMeasurementClusterServer(measuredValue = null, min
|
|
|
712
588
|
tolerance: 0,
|
|
713
589
|
});
|
|
714
590
|
}
|
|
715
|
-
/**
|
|
716
|
-
* Get the default OccupancySensing cluster server options.
|
|
717
|
-
*
|
|
718
|
-
* @param {boolean} occupied - A boolean indicating whether the occupancy is occupied or not. Default is false.
|
|
719
|
-
* @param {number} holdTime - The hold time in seconds. Default is 30.
|
|
720
|
-
* @param {number} holdTimeMin - The minimum hold time in seconds. Default is 1.
|
|
721
|
-
* @param {number} holdTimeMax - The maximum hold time in seconds. Default is 300.
|
|
722
|
-
*
|
|
723
|
-
* @remark The default value for the occupancy sensor type is PIR.
|
|
724
|
-
* Servers SHALL set these attributes for backward compatibility with clients implementing a cluster revision <= 4 as
|
|
725
|
-
* described in OccupancySensorType and OccupancySensorTypeBitmap Attributes.
|
|
726
|
-
* This replaces the 9 legacy attributes PIROccupiedToUnoccupiedDelay through PhysicalContactUnoccupiedToOccupiedThreshold.
|
|
727
|
-
*/
|
|
728
591
|
export function getDefaultOccupancySensingClusterServer(occupied = false, holdTime = 30, holdTimeMin = 1, holdTimeMax = 300) {
|
|
729
592
|
return optionsFor(OccupancySensingServer.with(OccupancySensing.Feature.PassiveInfrared), {
|
|
730
593
|
occupancy: { occupied },
|
|
@@ -736,4 +599,3 @@ export function getDefaultOccupancySensingClusterServer(occupied = false, holdTi
|
|
|
736
599
|
holdTimeLimits: { holdTimeMin, holdTimeMax, holdTimeDefault: holdTime },
|
|
737
600
|
});
|
|
738
601
|
}
|
|
739
|
-
//# sourceMappingURL=matterbridgeEndpointHelpers.js.map
|