matterbridge 3.0.7 → 3.0.8-dev-20250622-f9e44a2
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 +24 -0
- package/bin/matterbridge +2 -0
- package/dist/cli.js +5 -66
- package/dist/clusters/export.js +0 -2
- package/dist/defaultConfigSchema.js +0 -23
- package/dist/deviceManager.js +2 -95
- package/dist/devices/export.js +0 -2
- package/dist/evse.js +9 -65
- package/dist/frontend.js +47 -383
- package/dist/globalMatterbridge.js +0 -20
- package/dist/helpers.js +4 -52
- package/dist/index.js +2 -29
- package/dist/laundryWasher.js +7 -92
- 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 +53 -755
- package/dist/matterbridgeAccessoryPlatform.js +0 -34
- package/dist/matterbridgeBehaviors.js +1 -54
- package/dist/matterbridgeDeviceTypes.js +15 -578
- package/dist/matterbridgeDynamicPlatform.js +0 -34
- package/dist/matterbridgeEndpoint.js +45 -1000
- package/dist/matterbridgeEndpointHelpers.js +12 -206
- package/dist/matterbridgePlatform.js +13 -224
- package/dist/matterbridgeTypes.js +0 -24
- package/dist/pluginManager.js +4 -270
- package/dist/roboticVacuumCleaner.js +9 -84
- package/dist/shelly.js +9 -156
- 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/createDirectory.js +0 -31
- 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 +6 -77
- package/dist/utils/spawn.js +0 -16
- package/dist/utils/wait.js +10 -58
- package/dist/waterHeater.js +5 -65
- package/frontend/build/matterbridge 1250x1250.png +0 -0
- package/frontend/build/matterbridge 624x624.png +0 -0
- package/frontend/package-lock.json +19176 -0
- package/frontend/package.json +79 -0
- package/frontend/public/Shelly.svg +1 -0
- package/frontend/public/bmc-button.svg +22 -0
- package/frontend/public/discord.svg +5 -0
- package/frontend/public/favicon.ico +0 -0
- package/frontend/public/index.html +19 -0
- package/frontend/public/manifest.json +15 -0
- package/frontend/public/matter.png +0 -0
- package/frontend/public/matterbridge 1250x1250.png +0 -0
- package/frontend/public/matterbridge 32x32.png +0 -0
- package/frontend/public/matterbridge 624x624.png +0 -0
- package/frontend/public/matterbridge 64x64.png +0 -0
- package/frontend/public/matterbridge.svg +50 -0
- package/frontend/public/robots.txt +3 -0
- package/npm-shrinkwrap.json +27 -36
- 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/clusters/export.d.ts +0 -2
- package/dist/clusters/export.d.ts.map +0 -1
- package/dist/clusters/export.js.map +0 -1
- package/dist/defaultConfigSchema.d.ts +0 -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/devices/export.d.ts +0 -5
- package/dist/devices/export.d.ts.map +0 -1
- package/dist/devices/export.js.map +0 -1
- package/dist/evse.d.ts +0 -67
- package/dist/evse.d.ts.map +0 -1
- package/dist/evse.js.map +0 -1
- package/dist/frontend.d.ts +0 -256
- package/dist/frontend.d.ts.map +0 -1
- package/dist/frontend.js.map +0 -1
- package/dist/globalMatterbridge.d.ts +0 -32
- package/dist/globalMatterbridge.d.ts.map +0 -1
- package/dist/globalMatterbridge.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 -37
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/laundryWasher.d.ts +0 -243
- package/dist/laundryWasher.d.ts.map +0 -1
- package/dist/laundryWasher.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 -1333
- package/dist/matterbridgeBehaviors.d.ts.map +0 -1
- package/dist/matterbridgeBehaviors.js.map +0 -1
- package/dist/matterbridgeDeviceTypes.d.ts +0 -644
- 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 -1145
- package/dist/matterbridgeEndpoint.d.ts.map +0 -1
- package/dist/matterbridgeEndpoint.js.map +0 -1
- package/dist/matterbridgeEndpointHelpers.d.ts +0 -3083
- package/dist/matterbridgeEndpointHelpers.d.ts.map +0 -1
- package/dist/matterbridgeEndpointHelpers.js.map +0 -1
- package/dist/matterbridgePlatform.d.ts +0 -290
- package/dist/matterbridgePlatform.d.ts.map +0 -1
- package/dist/matterbridgePlatform.js.map +0 -1
- package/dist/matterbridgeTypes.d.ts +0 -196
- 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 -102
- package/dist/roboticVacuumCleaner.d.ts.map +0 -1
- package/dist/roboticVacuumCleaner.js.map +0 -1
- package/dist/shelly.d.ts +0 -161
- 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/createDirectory.d.ts +0 -32
- package/dist/utils/createDirectory.d.ts.map +0 -1
- package/dist/utils/createDirectory.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 -12
- package/dist/utils/export.d.ts.map +0 -1
- package/dist/utils/export.js.map +0 -1
- package/dist/utils/hex.d.ts +0 -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/spawn.d.ts +0 -12
- package/dist/utils/spawn.d.ts.map +0 -1
- package/dist/utils/spawn.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 -90
- package/dist/waterHeater.d.ts.map +0 -1
- package/dist/waterHeater.js.map +0 -1
- package/tsconfig.jest.json +0 -8
- package/tsconfig.production.json +0 -13
|
@@ -1,29 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* @file matterbridgeEndpointHelpers.ts
|
|
5
|
-
* @author Luca Liguori
|
|
6
|
-
* @date 2024-10-01
|
|
7
|
-
* @version 2.1.0
|
|
8
|
-
*
|
|
9
|
-
* Copyright 2024, 2025, 2026 Luca Liguori.
|
|
10
|
-
*
|
|
11
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12
|
-
* you may not use this file except in compliance with the License.
|
|
13
|
-
* You may obtain a copy of the License at
|
|
14
|
-
*
|
|
15
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
-
*
|
|
17
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
18
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
-
* See the License for the specific language governing permissions and
|
|
21
|
-
* limitations under the License. *
|
|
22
|
-
*/
|
|
23
|
-
// @matter
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { BLUE, CYAN, db, debugStringify, er, hk, or, YELLOW, zb } from 'node-ansi-logger';
|
|
24
3
|
import { Lifecycle } from '@matter/main';
|
|
25
4
|
import { getClusterNameById } from '@matter/main/types';
|
|
26
|
-
// @matter clusters
|
|
27
5
|
import { PowerSource } from '@matter/main/clusters/power-source';
|
|
28
6
|
import { UserLabel } from '@matter/main/clusters/user-label';
|
|
29
7
|
import { FixedLabel } from '@matter/main/clusters/fixed-label';
|
|
@@ -68,7 +46,6 @@ import { TotalVolatileOrganicCompoundsConcentrationMeasurement } from '@matter/m
|
|
|
68
46
|
import { OperationalState } from '@matter/main/clusters/operational-state';
|
|
69
47
|
import { DeviceEnergyManagement } from '@matter/main/clusters/device-energy-management';
|
|
70
48
|
import { DeviceEnergyManagementMode } from '@matter/main/clusters/device-energy-management-mode';
|
|
71
|
-
// @matter behaviors
|
|
72
49
|
import { PowerSourceServer } from '@matter/main/behaviors/power-source';
|
|
73
50
|
import { UserLabelServer } from '@matter/main/behaviors/user-label';
|
|
74
51
|
import { FixedLabelServer } from '@matter/main/behaviors/fixed-label';
|
|
@@ -99,10 +76,6 @@ import { Pm10ConcentrationMeasurementServer } from '@matter/main/behaviors/pm10-
|
|
|
99
76
|
import { RadonConcentrationMeasurementServer } from '@matter/main/behaviors/radon-concentration-measurement';
|
|
100
77
|
import { TotalVolatileOrganicCompoundsConcentrationMeasurementServer } from '@matter/main/behaviors/total-volatile-organic-compounds-concentration-measurement';
|
|
101
78
|
import { DeviceEnergyManagementServer } from '@matter/node/behaviors/device-energy-management';
|
|
102
|
-
// Other modules
|
|
103
|
-
import { createHash } from 'node:crypto';
|
|
104
|
-
import { BLUE, CYAN, db, debugStringify, er, hk, or, YELLOW, zb } from 'node-ansi-logger';
|
|
105
|
-
// Matterbridge
|
|
106
79
|
import { deepCopy, deepEqual, isValidArray } from './utils/export.js';
|
|
107
80
|
import { MatterbridgeIdentifyServer, MatterbridgeOnOffServer, MatterbridgeLevelControlServer, MatterbridgeColorControlServer, MatterbridgeLiftWindowCoveringServer, MatterbridgeThermostatServer, MatterbridgeFanControlServer, MatterbridgeDoorLockServer, MatterbridgeModeSelectServer, MatterbridgeValveConfigurationAndControlServer, MatterbridgeSmokeCoAlarmServer, MatterbridgeBooleanStateConfigurationServer, MatterbridgeOperationalStateServer, MatterbridgeDeviceEnergyManagementModeServer, } from './matterbridgeBehaviors.js';
|
|
108
81
|
export function capitalizeFirstLetter(name) {
|
|
@@ -117,19 +90,19 @@ export function lowercaseFirstLetter(name) {
|
|
|
117
90
|
}
|
|
118
91
|
export function checkNotLatinCharacters(deviceName) {
|
|
119
92
|
const nonLatinRegexList = [
|
|
120
|
-
/[\u0400-\u04FF\u0500-\u052F]/,
|
|
121
|
-
/[\u2E80-\u9FFF]/,
|
|
122
|
-
/[\uAC00-\uD7AF]/,
|
|
123
|
-
/[\u0600-\u06FF\u0750-\u077F]/,
|
|
124
|
-
/[\u0590-\u05FF]/,
|
|
125
|
-
/[\u0900-\u097F]/,
|
|
126
|
-
/[\u0E00-\u0E7F]/,
|
|
127
|
-
/[\u1200-\u137F]/,
|
|
93
|
+
/[\u0400-\u04FF\u0500-\u052F]/,
|
|
94
|
+
/[\u2E80-\u9FFF]/,
|
|
95
|
+
/[\uAC00-\uD7AF]/,
|
|
96
|
+
/[\u0600-\u06FF\u0750-\u077F]/,
|
|
97
|
+
/[\u0590-\u05FF]/,
|
|
98
|
+
/[\u0900-\u097F]/,
|
|
99
|
+
/[\u0E00-\u0E7F]/,
|
|
100
|
+
/[\u1200-\u137F]/,
|
|
128
101
|
];
|
|
129
102
|
return nonLatinRegexList.some((regex) => regex.test(deviceName));
|
|
130
103
|
}
|
|
131
104
|
export function generateUniqueId(deviceName) {
|
|
132
|
-
return createHash('md5').update(deviceName).digest('hex');
|
|
105
|
+
return createHash('md5').update(deviceName).digest('hex');
|
|
133
106
|
}
|
|
134
107
|
export function createUniqueId(param1, param2, param3, param4) {
|
|
135
108
|
const hash = createHash('md5');
|
|
@@ -137,7 +110,6 @@ export function createUniqueId(param1, param2, param3, param4) {
|
|
|
137
110
|
return hash.digest('hex');
|
|
138
111
|
}
|
|
139
112
|
export function getBehaviourTypesFromClusterServerIds(clusterServerList) {
|
|
140
|
-
// Map Server ClusterId to Behavior.Type
|
|
141
113
|
const behaviorTypes = [];
|
|
142
114
|
clusterServerList.forEach((clusterId) => {
|
|
143
115
|
behaviorTypes.push(getBehaviourTypeFromClusterServerId(clusterId));
|
|
@@ -145,15 +117,12 @@ export function getBehaviourTypesFromClusterServerIds(clusterServerList) {
|
|
|
145
117
|
return behaviorTypes;
|
|
146
118
|
}
|
|
147
119
|
export function getBehaviourTypesFromClusterClientIds(clusterClientList) {
|
|
148
|
-
// Map Client ClusterId to Behavior.Type
|
|
149
120
|
const behaviorTypes = [];
|
|
150
121
|
clusterClientList.forEach((_clusterId) => {
|
|
151
|
-
// behaviorTypes.push(getBehaviourTypeFromClusterClientId(clusterId));
|
|
152
122
|
});
|
|
153
123
|
return behaviorTypes;
|
|
154
124
|
}
|
|
155
125
|
export function getBehaviourTypeFromClusterServerId(clusterId) {
|
|
156
|
-
// Map ClusterId to Server Behavior.Type
|
|
157
126
|
if (clusterId === PowerSource.Cluster.id)
|
|
158
127
|
return PowerSourceServer.with(PowerSource.Feature.Wired);
|
|
159
128
|
if (clusterId === UserLabel.Cluster.id)
|
|
@@ -245,8 +214,6 @@ export function getBehaviourTypeFromClusterServerId(clusterId) {
|
|
|
245
214
|
return MatterbridgeIdentifyServer;
|
|
246
215
|
}
|
|
247
216
|
export function getBehaviourTypeFromClusterClientId(_clusterId) {
|
|
248
|
-
// Map ClusterId to Client Behavior.Type
|
|
249
|
-
// return IdentifyClient;
|
|
250
217
|
}
|
|
251
218
|
export function getBehavior(endpoint, cluster) {
|
|
252
219
|
let behavior;
|
|
@@ -264,11 +231,6 @@ export function getBehavior(endpoint, cluster) {
|
|
|
264
231
|
}
|
|
265
232
|
return behavior;
|
|
266
233
|
}
|
|
267
|
-
/**
|
|
268
|
-
* Invokes a command on the specified behavior of the endpoint. Used ONLY in Jest tests.
|
|
269
|
-
*
|
|
270
|
-
* @deprecated Used ONLY in Jest tests.
|
|
271
|
-
*/
|
|
272
234
|
export async function invokeBehaviorCommand(endpoint, cluster, command, params) {
|
|
273
235
|
const behaviorId = getBehavior(endpoint, cluster)?.id;
|
|
274
236
|
if (!behaviorId) {
|
|
@@ -276,7 +238,6 @@ export async function invokeBehaviorCommand(endpoint, cluster, command, params)
|
|
|
276
238
|
return false;
|
|
277
239
|
}
|
|
278
240
|
await endpoint.act((agent) => {
|
|
279
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
280
241
|
const behavior = agent[behaviorId];
|
|
281
242
|
if (!(command in behavior) || typeof behavior[command] !== 'function') {
|
|
282
243
|
endpoint.log?.error(`invokeBehaviorCommand error: command ${hk}${command}${er} not found on agent for endpoint ${or}${endpoint.maybeId}${er}:${or}${endpoint.maybeNumber}${er}`);
|
|
@@ -286,17 +247,6 @@ export async function invokeBehaviorCommand(endpoint, cluster, command, params)
|
|
|
286
247
|
});
|
|
287
248
|
return true;
|
|
288
249
|
}
|
|
289
|
-
/**
|
|
290
|
-
* Invokes the subscription handler on the specified cluster and attribute of the endpoint. Used ONLY in Jest tests.
|
|
291
|
-
*
|
|
292
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to invoke the subscription handler on.
|
|
293
|
-
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to invoke the subscription handler on.
|
|
294
|
-
* @param {string} attribute - The attribute to invoke the subscription handler on.
|
|
295
|
-
* @param {unknown} newValue - The new value of the attribute.
|
|
296
|
-
* @param {unknown} oldValue - The old value of the attribute.
|
|
297
|
-
*
|
|
298
|
-
* @deprecated Used ONLY in Jest tests.
|
|
299
|
-
*/
|
|
300
250
|
export async function invokeSubscribeHandler(endpoint, cluster, attribute, newValue, oldValue) {
|
|
301
251
|
const event = attribute + '$Changed';
|
|
302
252
|
const clusterName = getBehavior(endpoint, cluster)?.id;
|
|
@@ -313,8 +263,6 @@ export async function invokeSubscribeHandler(endpoint, cluster, attribute, newVa
|
|
|
313
263
|
endpoint.log.error(`invokeSubscribeHandler ${hk}${event}${er} error: cluster ${clusterName} not found on endpoint ${or}${endpoint.id}${er}:${or}${endpoint.number}${er}`);
|
|
314
264
|
return false;
|
|
315
265
|
}
|
|
316
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
317
|
-
// @ts-ignore
|
|
318
266
|
await endpoint.act((agent) => agent[clusterName].events[event].emit(newValue, oldValue, { ...agent.context, offline: false }));
|
|
319
267
|
return true;
|
|
320
268
|
}
|
|
@@ -346,13 +294,6 @@ export function addOptionalClusterServers(endpoint) {
|
|
|
346
294
|
});
|
|
347
295
|
addClusterServers(endpoint, optionalServerList);
|
|
348
296
|
}
|
|
349
|
-
/**
|
|
350
|
-
* Adds cluster servers to the specified endpoint based on the provided server list.
|
|
351
|
-
*
|
|
352
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to add the cluster servers to.
|
|
353
|
-
* @param {ClusterId[]} serverList - The list of cluster IDs to add.
|
|
354
|
-
* @returns void
|
|
355
|
-
*/
|
|
356
297
|
export function addClusterServers(endpoint, serverList) {
|
|
357
298
|
if (serverList.includes(PowerSource.Cluster.id))
|
|
358
299
|
endpoint.createDefaultPowerSourceWiredClusterServer();
|
|
@@ -433,13 +374,6 @@ export function addClusterServers(endpoint, serverList) {
|
|
|
433
374
|
if (serverList.includes(DeviceEnergyManagementMode.Cluster.id))
|
|
434
375
|
endpoint.createDefaultDeviceEnergyManagementModeClusterServer();
|
|
435
376
|
}
|
|
436
|
-
/**
|
|
437
|
-
* Adds a fixed label to the FixedLabel cluster. The FixedLabel cluster is created if it does not exist.
|
|
438
|
-
*
|
|
439
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to add the cluster servers to.
|
|
440
|
-
* @param {string} label - The label to add.
|
|
441
|
-
* @param {string} value - The value of the label.
|
|
442
|
-
*/
|
|
443
377
|
export async function addFixedLabel(endpoint, label, value) {
|
|
444
378
|
if (!endpoint.hasClusterServer(FixedLabel.Cluster.id)) {
|
|
445
379
|
endpoint.log.debug(`addFixedLabel: add cluster ${hk}FixedLabel${db}:${hk}fixedLabel${db} with label ${CYAN}${label}${db} value ${CYAN}${value}${db}`);
|
|
@@ -456,13 +390,6 @@ export async function addFixedLabel(endpoint, label, value) {
|
|
|
456
390
|
await endpoint.setAttribute(FixedLabel.Cluster.id, 'labelList', labelList, endpoint.log);
|
|
457
391
|
}
|
|
458
392
|
}
|
|
459
|
-
/**
|
|
460
|
-
* Adds a user label to the UserLabel cluster. The UserLabel cluster is created if it does not exist.
|
|
461
|
-
*
|
|
462
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to add the cluster servers to.
|
|
463
|
-
* @param {string} label - The label to add.
|
|
464
|
-
* @param {string} value - The value of the label.
|
|
465
|
-
*/
|
|
466
393
|
export async function addUserLabel(endpoint, label, value) {
|
|
467
394
|
if (!endpoint.hasClusterServer(UserLabel.Cluster.id)) {
|
|
468
395
|
endpoint.log.debug(`addUserLabel: add cluster ${hk}UserLabel${db}:${hk}userLabel${db} with label ${CYAN}${label}${db} value ${CYAN}${value}${db}`);
|
|
@@ -489,16 +416,6 @@ export function getAttributeId(endpoint, cluster, attribute) {
|
|
|
489
416
|
const clusterBehavior = endpoint.behaviors.supported[lowercaseFirstLetter(cluster)];
|
|
490
417
|
return clusterBehavior?.cluster?.attributes[lowercaseFirstLetter(attribute)]?.id;
|
|
491
418
|
}
|
|
492
|
-
/**
|
|
493
|
-
* Retrieves the value of the provided attribute from the given cluster.
|
|
494
|
-
*
|
|
495
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to retrieve the attribute from.
|
|
496
|
-
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to retrieve the attribute from.
|
|
497
|
-
* @param {string} attribute - The name of the attribute to retrieve.
|
|
498
|
-
* @param {AnsiLogger} [log] - (Optional) The logger to use for logging the retrieve. Errors are logged to the endpoint logger.
|
|
499
|
-
* @returns {any} The value of the attribute, or undefined if the attribute is not found.
|
|
500
|
-
*/
|
|
501
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
502
419
|
export function getAttribute(endpoint, cluster, attribute, log) {
|
|
503
420
|
const clusterName = getBehavior(endpoint, cluster)?.id;
|
|
504
421
|
if (!clusterName) {
|
|
@@ -521,16 +438,6 @@ export function getAttribute(endpoint, cluster, attribute, log) {
|
|
|
521
438
|
log?.info(`${db}Get endpoint ${or}${endpoint.id}${db}:${or}${endpoint.number}${db} attribute ${hk}${capitalizeFirstLetter(clusterName)}${db}.${hk}${attribute}${db} value ${YELLOW}${value !== null && typeof value === 'object' ? debugStringify(value) : value}${db}`);
|
|
522
439
|
return value;
|
|
523
440
|
}
|
|
524
|
-
/**
|
|
525
|
-
* Sets the value of an attribute on a cluster server.
|
|
526
|
-
*
|
|
527
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to set the attribute on.
|
|
528
|
-
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to set the attribute on.
|
|
529
|
-
* @param {string} attribute - The name of the attribute.
|
|
530
|
-
* @param {boolean | number | bigint | string | object | null} value - The value to set for the attribute.
|
|
531
|
-
* @param {AnsiLogger} [log] - (Optional) The logger to use for logging the set. Errors are logged to the endpoint logger.
|
|
532
|
-
* @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the attribute was successfully set.
|
|
533
|
-
*/
|
|
534
441
|
export async function setAttribute(endpoint, cluster, attribute, value, log) {
|
|
535
442
|
const clusterName = getBehavior(endpoint, cluster)?.id;
|
|
536
443
|
if (!clusterName) {
|
|
@@ -556,16 +463,6 @@ export async function setAttribute(endpoint, cluster, attribute, value, log) {
|
|
|
556
463
|
`to ${YELLOW}${value !== null && typeof value === 'object' ? debugStringify(value) : value}${db}`);
|
|
557
464
|
return true;
|
|
558
465
|
}
|
|
559
|
-
/**
|
|
560
|
-
* Sets the value of an attribute on a cluster server.
|
|
561
|
-
*
|
|
562
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to update the attribute on.
|
|
563
|
-
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to update the attribute on.
|
|
564
|
-
* @param {string} attribute - The name of the attribute.
|
|
565
|
-
* @param {boolean | number | bigint | string | object | null} value - The value to set for the attribute.
|
|
566
|
-
* @param {AnsiLogger} [log] - (Optional) The logger to use for logging the update. Errors are logged to the endpoint logger.
|
|
567
|
-
* @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the attribute was successfully set.
|
|
568
|
-
*/
|
|
569
466
|
export async function updateAttribute(endpoint, cluster, attribute, value, log) {
|
|
570
467
|
const clusterName = getBehavior(endpoint, cluster)?.id;
|
|
571
468
|
if (!clusterName) {
|
|
@@ -596,24 +493,7 @@ export async function updateAttribute(endpoint, cluster, attribute, value, log)
|
|
|
596
493
|
`to ${YELLOW}${value !== null && typeof value === 'object' ? debugStringify(value) : value}${db}`);
|
|
597
494
|
return true;
|
|
598
495
|
}
|
|
599
|
-
|
|
600
|
-
* Subscribes to the provided attribute on a cluster.
|
|
601
|
-
*
|
|
602
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to subscribe the attribute to.
|
|
603
|
-
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to subscribe the attribute to.
|
|
604
|
-
* @param {string} attribute - The name of the attribute to subscribe to.
|
|
605
|
-
* @param {(newValue: any, oldValue: any, context: ActionContext) => void} listener - A callback function that will be called when the attribute value changes. When context.offline === true then the change is locally generated and not from the controller.
|
|
606
|
-
* @param {AnsiLogger} [log] - Optional logger for logging errors and information.
|
|
607
|
-
* @returns {boolean} - A boolean indicating whether the subscription was successful.
|
|
608
|
-
*
|
|
609
|
-
* @remarks The listener function (cannot be async) will receive three parameters:
|
|
610
|
-
* - `newValue`: The new value of the attribute.
|
|
611
|
-
* - `oldValue`: The old value of the attribute.
|
|
612
|
-
* - `context`: The action context, which includes information about the action that triggered the change. When context.offline === true then the change is locally generated and not from the controller.
|
|
613
|
-
*/
|
|
614
|
-
export async function subscribeAttribute(endpoint, cluster, attribute,
|
|
615
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
616
|
-
listener, log) {
|
|
496
|
+
export async function subscribeAttribute(endpoint, cluster, attribute, listener, log) {
|
|
617
497
|
const clusterName = getBehavior(endpoint, cluster)?.id;
|
|
618
498
|
if (!clusterName) {
|
|
619
499
|
endpoint.log.error(`subscribeAttribute ${hk}${attribute}${er} error: cluster not found on endpoint ${or}${endpoint.maybeId}${er}:${or}${endpoint.maybeNumber}${er}`);
|
|
@@ -623,7 +503,6 @@ listener, log) {
|
|
|
623
503
|
endpoint.log.debug(`subscribeAttribute ${hk}${clusterName}.${attribute}${db}: Endpoint ${or}${endpoint.maybeId}${db}:${or}${endpoint.maybeNumber}${db} is in the ${BLUE}${endpoint.construction.status}${db} state`);
|
|
624
504
|
await endpoint.construction.ready;
|
|
625
505
|
}
|
|
626
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
627
506
|
const events = endpoint.events;
|
|
628
507
|
attribute = lowercaseFirstLetter(attribute) + '$Changed';
|
|
629
508
|
if (!(clusterName in events) || !(attribute in events[clusterName])) {
|
|
@@ -634,16 +513,6 @@ listener, log) {
|
|
|
634
513
|
log?.info(`${db}Subscribed endpoint ${or}${endpoint.id}${db}:${or}${endpoint.number}${db} attribute ${hk}${capitalizeFirstLetter(clusterName)}${db}.${hk}${attribute}${db}`);
|
|
635
514
|
return true;
|
|
636
515
|
}
|
|
637
|
-
/**
|
|
638
|
-
* Triggers an event on the specified cluster.
|
|
639
|
-
*
|
|
640
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to trigger the event on.
|
|
641
|
-
* @param {ClusterId} clusterId - The ID of the cluster.
|
|
642
|
-
* @param {string} event - The name of the event to trigger.
|
|
643
|
-
* @param {Record<string, boolean | number | bigint | string | object | undefined | null>} payload - The payload to pass to the event.
|
|
644
|
-
* @param {AnsiLogger} [log] - Optional logger for logging information.
|
|
645
|
-
* @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the event was successfully triggered.
|
|
646
|
-
*/
|
|
647
516
|
export async function triggerEvent(endpoint, cluster, event, payload, log) {
|
|
648
517
|
const clusterName = getBehavior(endpoint, cluster)?.id;
|
|
649
518
|
if (!clusterName) {
|
|
@@ -654,23 +523,15 @@ export async function triggerEvent(endpoint, cluster, event, payload, log) {
|
|
|
654
523
|
endpoint.log.error(`triggerEvent ${hk}${clusterName}.${event}${er} error: Endpoint ${or}${endpoint.maybeId}${er}:${or}${endpoint.maybeNumber}${er} is in the ${BLUE}${endpoint.construction.status}${er} state`);
|
|
655
524
|
return false;
|
|
656
525
|
}
|
|
657
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
658
526
|
const events = endpoint.events;
|
|
659
527
|
if (!(clusterName in events) || !(event in events[clusterName])) {
|
|
660
528
|
endpoint.log.error(`triggerEvent ${hk}${event}${er} error: cluster ${clusterName} not found on endpoint ${or}${endpoint.id}${er}:${or}${endpoint.number}${er}`);
|
|
661
529
|
return false;
|
|
662
530
|
}
|
|
663
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
664
|
-
// @ts-ignore
|
|
665
531
|
await endpoint.act((agent) => agent[clusterName].events[event].emit(payload, agent.context));
|
|
666
532
|
log?.info(`${db}Trigger event ${hk}${capitalizeFirstLetter(clusterName)}${db}.${hk}${event}${db} with ${debugStringify(payload)}${db} on endpoint ${or}${endpoint.id}${db}:${or}${endpoint.number}${db} `);
|
|
667
533
|
return true;
|
|
668
534
|
}
|
|
669
|
-
/**
|
|
670
|
-
* Get the default OperationalState Cluster Server.
|
|
671
|
-
*
|
|
672
|
-
* @param {OperationalState.OperationalStateEnum} operationalState - The initial operational state.
|
|
673
|
-
*/
|
|
674
535
|
export function getDefaultOperationalStateClusterServer(operationalState = OperationalState.OperationalStateEnum.Stopped) {
|
|
675
536
|
return optionsFor(MatterbridgeOperationalStateServer, {
|
|
676
537
|
phaseList: [],
|
|
@@ -685,13 +546,6 @@ export function getDefaultOperationalStateClusterServer(operationalState = Opera
|
|
|
685
546
|
operationalError: { errorStateId: OperationalState.ErrorState.NoError, errorStateLabel: 'No error', errorStateDetails: 'Fully operational' },
|
|
686
547
|
});
|
|
687
548
|
}
|
|
688
|
-
/**
|
|
689
|
-
* Get the default TemperatureMeasurement cluster server options.
|
|
690
|
-
*
|
|
691
|
-
* @param {number | null} measuredValue - The measured value of the temperature x 100.
|
|
692
|
-
* @param {number | null} minMeasuredValue - The minimum measured value of the temperature x 100.
|
|
693
|
-
* @param {number | null} maxMeasuredValue - The maximum measured value of the temperature x 100.
|
|
694
|
-
*/
|
|
695
549
|
export function getDefaultTemperatureMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
696
550
|
return optionsFor(TemperatureMeasurementServer, {
|
|
697
551
|
measuredValue,
|
|
@@ -700,13 +554,6 @@ export function getDefaultTemperatureMeasurementClusterServer(measuredValue = nu
|
|
|
700
554
|
tolerance: 0,
|
|
701
555
|
});
|
|
702
556
|
}
|
|
703
|
-
/**
|
|
704
|
-
* Get the default RelativeHumidityMeasurement cluster server options.
|
|
705
|
-
*
|
|
706
|
-
* @param {number | null} measuredValue - The measured value of the relative humidity x 100.
|
|
707
|
-
* @param {number | null} minMeasuredValue - The minimum measured value of the relative humidity x 100.
|
|
708
|
-
* @param {number | null} maxMeasuredValue - The maximum measured value of the relative humidity x 100.
|
|
709
|
-
*/
|
|
710
557
|
export function getDefaultRelativeHumidityMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
711
558
|
return optionsFor(RelativeHumidityMeasurementServer, {
|
|
712
559
|
measuredValue,
|
|
@@ -715,13 +562,6 @@ export function getDefaultRelativeHumidityMeasurementClusterServer(measuredValue
|
|
|
715
562
|
tolerance: 0,
|
|
716
563
|
});
|
|
717
564
|
}
|
|
718
|
-
/**
|
|
719
|
-
* Get the default PressureMeasurement cluster server options.
|
|
720
|
-
*
|
|
721
|
-
* @param {number | null} measuredValue - The measured value for the pressure.
|
|
722
|
-
* @param {number | null} minMeasuredValue - The minimum measured value for the pressure.
|
|
723
|
-
* @param {number | null} maxMeasuredValue - The maximum measured value for the pressure.
|
|
724
|
-
*/
|
|
725
565
|
export function getDefaultPressureMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
726
566
|
return optionsFor(PressureMeasurementServer, {
|
|
727
567
|
measuredValue,
|
|
@@ -730,19 +570,6 @@ export function getDefaultPressureMeasurementClusterServer(measuredValue = null,
|
|
|
730
570
|
tolerance: 0,
|
|
731
571
|
});
|
|
732
572
|
}
|
|
733
|
-
/**
|
|
734
|
-
* Get the default IlluminanceMeasurement cluster server options.
|
|
735
|
-
*
|
|
736
|
-
* @param {number | null} measuredValue - The measured value of illuminance.
|
|
737
|
-
* @param {number | null} minMeasuredValue - The minimum measured value of illuminance.
|
|
738
|
-
* @param {number | null} maxMeasuredValue - The maximum measured value of illuminance.
|
|
739
|
-
* @remark The default value for the illuminance measurement is null.
|
|
740
|
-
* This attribute SHALL indicate the illuminance in Lux (symbol lx) as follows:
|
|
741
|
-
* • MeasuredValue = 10,000 x log10(illuminance) + 1,
|
|
742
|
-
* where 1 lx <= illuminance <= 3.576 Mlx, corresponding to a MeasuredValue in the range 1 to 0xFFFE.
|
|
743
|
-
* • 0 indicates a value of illuminance that is too low to be measured
|
|
744
|
-
* • null indicates that the illuminance measurement is invalid.
|
|
745
|
-
*/
|
|
746
573
|
export function getDefaultIlluminanceMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
747
574
|
return optionsFor(IlluminanceMeasurementServer, {
|
|
748
575
|
measuredValue,
|
|
@@ -751,13 +578,6 @@ export function getDefaultIlluminanceMeasurementClusterServer(measuredValue = nu
|
|
|
751
578
|
tolerance: 0,
|
|
752
579
|
});
|
|
753
580
|
}
|
|
754
|
-
/**
|
|
755
|
-
* Get the default FlowMeasurement cluster server options.
|
|
756
|
-
*
|
|
757
|
-
* @param {number | null} measuredValue - The measured value of the flow in 10 x m3/h.
|
|
758
|
-
* @param {number | null} minMeasuredValue - The minimum measured value of the flow in 10 x m3/h.
|
|
759
|
-
* @param {number | null} maxMeasuredValue - The maximum measured value of the flow in 10 x m3/h.
|
|
760
|
-
*/
|
|
761
581
|
export function getDefaultFlowMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
762
582
|
return optionsFor(FlowMeasurementServer, {
|
|
763
583
|
measuredValue,
|
|
@@ -766,19 +586,6 @@ export function getDefaultFlowMeasurementClusterServer(measuredValue = null, min
|
|
|
766
586
|
tolerance: 0,
|
|
767
587
|
});
|
|
768
588
|
}
|
|
769
|
-
/**
|
|
770
|
-
* Get the default OccupancySensing cluster server options.
|
|
771
|
-
*
|
|
772
|
-
* @param {boolean} occupied - A boolean indicating whether the occupancy is occupied or not. Default is false.
|
|
773
|
-
* @param {number} holdTime - The hold time in seconds. Default is 30.
|
|
774
|
-
* @param {number} holdTimeMin - The minimum hold time in seconds. Default is 1.
|
|
775
|
-
* @param {number} holdTimeMax - The maximum hold time in seconds. Default is 300.
|
|
776
|
-
*
|
|
777
|
-
* @remark The default value for the occupancy sensor type is PIR.
|
|
778
|
-
* Servers SHALL set these attributes for backward compatibility with clients implementing a cluster revision <= 4 as
|
|
779
|
-
* described in OccupancySensorType and OccupancySensorTypeBitmap Attributes.
|
|
780
|
-
* This replaces the 9 legacy attributes PIROccupiedToUnoccupiedDelay through PhysicalContactUnoccupiedToOccupiedThreshold.
|
|
781
|
-
*/
|
|
782
589
|
export function getDefaultOccupancySensingClusterServer(occupied = false, holdTime = 30, holdTimeMin = 1, holdTimeMax = 300) {
|
|
783
590
|
return optionsFor(OccupancySensingServer.with(OccupancySensing.Feature.PassiveInfrared), {
|
|
784
591
|
occupancy: { occupied },
|
|
@@ -790,4 +597,3 @@ export function getDefaultOccupancySensingClusterServer(occupied = false, holdTi
|
|
|
790
597
|
holdTimeLimits: { holdTimeMin, holdTimeMax, holdTimeDefault: holdTime },
|
|
791
598
|
});
|
|
792
599
|
}
|
|
793
|
-
//# sourceMappingURL=matterbridgeEndpointHelpers.js.map
|