matterbridge 3.2.0 → 3.2.1-dev-20250802-516a522
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 +21 -0
- package/dist/cli.js +2 -91
- package/dist/cliEmitter.js +0 -30
- package/dist/clusters/export.js +0 -2
- package/dist/defaultConfigSchema.js +0 -24
- package/dist/deviceManager.js +1 -94
- package/dist/devices/batteryStorage.js +1 -48
- package/dist/devices/dishwasher.js +3 -78
- package/dist/devices/evse.js +10 -74
- package/dist/devices/export.js +0 -2
- package/dist/devices/extractorHood.js +0 -42
- package/dist/devices/heatPump.js +2 -50
- package/dist/devices/laundryDryer.js +6 -83
- package/dist/devices/laundryWasher.js +7 -91
- package/dist/devices/roboticVacuumCleaner.js +7 -93
- package/dist/devices/solarPower.js +0 -38
- package/dist/devices/waterHeater.js +2 -82
- package/dist/dgram/coap.js +13 -126
- package/dist/dgram/dgram.js +2 -113
- package/dist/dgram/mb_coap.js +3 -41
- package/dist/dgram/mb_mdns.js +13 -51
- package/dist/dgram/mdns.js +137 -298
- package/dist/dgram/multicast.js +1 -60
- package/dist/dgram/unicast.js +0 -54
- package/dist/frontend.js +23 -448
- package/dist/globalMatterbridge.js +0 -47
- package/dist/helpers.js +0 -53
- package/dist/index.js +1 -30
- 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 -3
- package/dist/matter/types.js +0 -3
- package/dist/matterbridge.js +50 -805
- package/dist/matterbridgeAccessoryPlatform.js +0 -36
- package/dist/matterbridgeBehaviors.js +5 -65
- package/dist/matterbridgeDeviceTypes.js +15 -579
- package/dist/matterbridgeDynamicPlatform.js +0 -36
- package/dist/matterbridgeEndpoint.js +55 -1234
- package/dist/matterbridgeEndpointHelpers.js +12 -344
- package/dist/matterbridgePlatform.js +35 -248
- package/dist/matterbridgeTypes.js +0 -25
- package/dist/pluginManager.js +3 -249
- package/dist/shelly.js +7 -168
- package/dist/storage/export.js +0 -1
- package/dist/update.js +0 -69
- package/dist/utils/colorUtils.js +2 -263
- package/dist/utils/commandLine.js +0 -54
- package/dist/utils/copyDirectory.js +1 -38
- package/dist/utils/createDirectory.js +0 -33
- package/dist/utils/createZip.js +2 -47
- package/dist/utils/deepCopy.js +0 -39
- package/dist/utils/deepEqual.js +1 -72
- package/dist/utils/error.js +0 -41
- package/dist/utils/export.js +0 -1
- package/dist/utils/hex.js +0 -123
- package/dist/utils/isvalid.js +0 -101
- package/dist/utils/network.js +5 -94
- package/dist/utils/spawn.js +0 -40
- package/dist/utils/wait.js +9 -62
- package/docs/404.html +107 -0
- package/docs/HomeAssistant.svg +2 -0
- package/docs/Shelly.svg +1 -0
- package/docs/Somfy.svg +1 -0
- package/docs/Zigbee2MQTT.svg +1 -0
- package/docs/_config.yml +86 -0
- package/docs/bmc-button.svg +22 -0
- package/docs/index.html +774 -0
- package/docs/matterbridge.svg +50 -0
- package/docs/robots.txt +4 -0
- package/npm-shrinkwrap.json +45 -45
- package/package.json +5 -3
- package/dist/cli.d.ts +0 -26
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/cliEmitter.d.ts +0 -34
- package/dist/cliEmitter.d.ts.map +0 -1
- package/dist/cliEmitter.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 -28
- package/dist/defaultConfigSchema.d.ts.map +0 -1
- package/dist/defaultConfigSchema.js.map +0 -1
- package/dist/deviceManager.d.ts +0 -112
- package/dist/deviceManager.d.ts.map +0 -1
- package/dist/deviceManager.js.map +0 -1
- package/dist/devices/batteryStorage.d.ts +0 -48
- package/dist/devices/batteryStorage.d.ts.map +0 -1
- package/dist/devices/batteryStorage.js.map +0 -1
- package/dist/devices/dishwasher.d.ts +0 -91
- package/dist/devices/dishwasher.d.ts.map +0 -1
- package/dist/devices/dishwasher.js.map +0 -1
- package/dist/devices/evse.d.ts +0 -75
- package/dist/devices/evse.d.ts.map +0 -1
- package/dist/devices/evse.js.map +0 -1
- package/dist/devices/export.d.ts +0 -11
- package/dist/devices/export.d.ts.map +0 -1
- package/dist/devices/export.js.map +0 -1
- package/dist/devices/extractorHood.d.ts +0 -46
- package/dist/devices/extractorHood.d.ts.map +0 -1
- package/dist/devices/extractorHood.js.map +0 -1
- package/dist/devices/heatPump.d.ts +0 -47
- package/dist/devices/heatPump.d.ts.map +0 -1
- package/dist/devices/heatPump.js.map +0 -1
- package/dist/devices/laundryDryer.d.ts +0 -87
- package/dist/devices/laundryDryer.d.ts.map +0 -1
- package/dist/devices/laundryDryer.js.map +0 -1
- package/dist/devices/laundryWasher.d.ts +0 -242
- package/dist/devices/laundryWasher.d.ts.map +0 -1
- package/dist/devices/laundryWasher.js.map +0 -1
- package/dist/devices/roboticVacuumCleaner.d.ts +0 -112
- package/dist/devices/roboticVacuumCleaner.d.ts.map +0 -1
- package/dist/devices/roboticVacuumCleaner.js.map +0 -1
- package/dist/devices/solarPower.d.ts +0 -40
- package/dist/devices/solarPower.d.ts.map +0 -1
- package/dist/devices/solarPower.js.map +0 -1
- package/dist/devices/waterHeater.d.ts +0 -111
- package/dist/devices/waterHeater.d.ts.map +0 -1
- package/dist/devices/waterHeater.js.map +0 -1
- package/dist/dgram/coap.d.ts +0 -205
- package/dist/dgram/coap.d.ts.map +0 -1
- package/dist/dgram/coap.js.map +0 -1
- package/dist/dgram/dgram.d.ts +0 -140
- package/dist/dgram/dgram.d.ts.map +0 -1
- package/dist/dgram/dgram.js.map +0 -1
- package/dist/dgram/mb_coap.d.ts +0 -24
- package/dist/dgram/mb_coap.d.ts.map +0 -1
- package/dist/dgram/mb_coap.js.map +0 -1
- package/dist/dgram/mb_mdns.d.ts +0 -24
- package/dist/dgram/mb_mdns.d.ts.map +0 -1
- package/dist/dgram/mb_mdns.js.map +0 -1
- package/dist/dgram/mdns.d.ts +0 -288
- package/dist/dgram/mdns.d.ts.map +0 -1
- package/dist/dgram/mdns.js.map +0 -1
- package/dist/dgram/multicast.d.ts +0 -65
- package/dist/dgram/multicast.d.ts.map +0 -1
- package/dist/dgram/multicast.js.map +0 -1
- package/dist/dgram/unicast.d.ts +0 -56
- package/dist/dgram/unicast.d.ts.map +0 -1
- package/dist/dgram/unicast.js.map +0 -1
- package/dist/frontend.d.ts +0 -313
- package/dist/frontend.d.ts.map +0 -1
- package/dist/frontend.js.map +0 -1
- package/dist/globalMatterbridge.d.ts +0 -59
- package/dist/globalMatterbridge.d.ts.map +0 -1
- package/dist/globalMatterbridge.js.map +0 -1
- package/dist/helpers.d.ts +0 -48
- package/dist/helpers.d.ts.map +0 -1
- package/dist/helpers.js.map +0 -1
- package/dist/index.d.ts +0 -33
- 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 -463
- package/dist/matterbridge.d.ts.map +0 -1
- package/dist/matterbridge.js.map +0 -1
- package/dist/matterbridgeAccessoryPlatform.d.ts +0 -42
- package/dist/matterbridgeAccessoryPlatform.d.ts.map +0 -1
- package/dist/matterbridgeAccessoryPlatform.js.map +0 -1
- package/dist/matterbridgeBehaviors.d.ts +0 -1351
- package/dist/matterbridgeBehaviors.d.ts.map +0 -1
- package/dist/matterbridgeBehaviors.js.map +0 -1
- package/dist/matterbridgeDeviceTypes.d.ts +0 -709
- package/dist/matterbridgeDeviceTypes.d.ts.map +0 -1
- package/dist/matterbridgeDeviceTypes.js.map +0 -1
- package/dist/matterbridgeDynamicPlatform.d.ts +0 -42
- package/dist/matterbridgeDynamicPlatform.d.ts.map +0 -1
- package/dist/matterbridgeDynamicPlatform.js.map +0 -1
- package/dist/matterbridgeEndpoint.d.ts +0 -1354
- package/dist/matterbridgeEndpoint.d.ts.map +0 -1
- package/dist/matterbridgeEndpoint.js.map +0 -1
- package/dist/matterbridgeEndpointHelpers.d.ts +0 -406
- package/dist/matterbridgeEndpointHelpers.d.ts.map +0 -1
- package/dist/matterbridgeEndpointHelpers.js.map +0 -1
- package/dist/matterbridgePlatform.d.ts +0 -310
- package/dist/matterbridgePlatform.d.ts.map +0 -1
- package/dist/matterbridgePlatform.js.map +0 -1
- package/dist/matterbridgeTypes.d.ts +0 -197
- package/dist/matterbridgeTypes.d.ts.map +0 -1
- package/dist/matterbridgeTypes.js.map +0 -1
- package/dist/pluginManager.d.ts +0 -270
- package/dist/pluginManager.d.ts.map +0 -1
- package/dist/pluginManager.js.map +0 -1
- package/dist/shelly.d.ts +0 -174
- 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 -75
- package/dist/update.d.ts.map +0 -1
- package/dist/update.js.map +0 -1
- package/dist/utils/colorUtils.d.ts +0 -117
- package/dist/utils/colorUtils.d.ts.map +0 -1
- package/dist/utils/colorUtils.js.map +0 -1
- package/dist/utils/commandLine.d.ts +0 -59
- package/dist/utils/commandLine.d.ts.map +0 -1
- package/dist/utils/commandLine.js.map +0 -1
- package/dist/utils/copyDirectory.d.ts +0 -33
- package/dist/utils/copyDirectory.d.ts.map +0 -1
- package/dist/utils/copyDirectory.js.map +0 -1
- package/dist/utils/createDirectory.d.ts +0 -34
- package/dist/utils/createDirectory.d.ts.map +0 -1
- package/dist/utils/createDirectory.js.map +0 -1
- package/dist/utils/createZip.d.ts +0 -39
- package/dist/utils/createZip.d.ts.map +0 -1
- package/dist/utils/createZip.js.map +0 -1
- package/dist/utils/deepCopy.d.ts +0 -32
- package/dist/utils/deepCopy.d.ts.map +0 -1
- package/dist/utils/deepCopy.js.map +0 -1
- package/dist/utils/deepEqual.d.ts +0 -54
- package/dist/utils/deepEqual.d.ts.map +0 -1
- package/dist/utils/deepEqual.js.map +0 -1
- package/dist/utils/error.d.ts +0 -44
- package/dist/utils/error.d.ts.map +0 -1
- package/dist/utils/error.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 -89
- package/dist/utils/hex.d.ts.map +0 -1
- package/dist/utils/hex.js.map +0 -1
- package/dist/utils/isvalid.d.ts +0 -103
- package/dist/utils/isvalid.d.ts.map +0 -1
- package/dist/utils/isvalid.js.map +0 -1
- package/dist/utils/network.d.ts +0 -84
- package/dist/utils/network.d.ts.map +0 -1
- package/dist/utils/network.js.map +0 -1
- package/dist/utils/spawn.d.ts +0 -33
- package/dist/utils/spawn.d.ts.map +0 -1
- package/dist/utils/spawn.js.map +0 -1
- package/dist/utils/wait.d.ts +0 -56
- package/dist/utils/wait.d.ts.map +0 -1
- package/dist/utils/wait.js.map +0 -1
|
@@ -1,34 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file contains the helpers for the class MatterbridgeEndpoint.
|
|
3
|
-
*
|
|
4
|
-
* @file matterbridgeEndpointHelpers.ts
|
|
5
|
-
* @author Luca Liguori
|
|
6
|
-
* @created 2024-10-01
|
|
7
|
-
* @version 2.1.0
|
|
8
|
-
* @license Apache-2.0
|
|
9
|
-
*
|
|
10
|
-
* Copyright 2024, 2025, 2026 Luca Liguori.
|
|
11
|
-
*
|
|
12
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
13
|
-
* you may not use this file except in compliance with the License.
|
|
14
|
-
* You may obtain a copy of the License at
|
|
15
|
-
*
|
|
16
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
17
|
-
*
|
|
18
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
19
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
20
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
21
|
-
* See the License for the specific language governing permissions and
|
|
22
|
-
* limitations under the License.
|
|
23
|
-
*/
|
|
24
|
-
// Other modules
|
|
25
1
|
import { createHash } from 'node:crypto';
|
|
26
|
-
// AnsiLogger module
|
|
27
2
|
import { BLUE, CYAN, db, debugStringify, er, hk, or, YELLOW, zb } from 'node-ansi-logger';
|
|
28
|
-
// @matter
|
|
29
3
|
import { Lifecycle } from '@matter/main';
|
|
30
4
|
import { getClusterNameById } from '@matter/main/types';
|
|
31
|
-
// @matter clusters
|
|
32
5
|
import { PowerSource } from '@matter/main/clusters/power-source';
|
|
33
6
|
import { UserLabel } from '@matter/main/clusters/user-label';
|
|
34
7
|
import { FixedLabel } from '@matter/main/clusters/fixed-label';
|
|
@@ -73,7 +46,6 @@ import { TotalVolatileOrganicCompoundsConcentrationMeasurement } from '@matter/m
|
|
|
73
46
|
import { OperationalState } from '@matter/main/clusters/operational-state';
|
|
74
47
|
import { DeviceEnergyManagement } from '@matter/main/clusters/device-energy-management';
|
|
75
48
|
import { DeviceEnergyManagementMode } from '@matter/main/clusters/device-energy-management-mode';
|
|
76
|
-
// @matter behaviors
|
|
77
49
|
import { PowerSourceServer } from '@matter/main/behaviors/power-source';
|
|
78
50
|
import { UserLabelServer } from '@matter/main/behaviors/user-label';
|
|
79
51
|
import { FixedLabelServer } from '@matter/main/behaviors/fixed-label';
|
|
@@ -104,126 +76,56 @@ import { Pm10ConcentrationMeasurementServer } from '@matter/main/behaviors/pm10-
|
|
|
104
76
|
import { RadonConcentrationMeasurementServer } from '@matter/main/behaviors/radon-concentration-measurement';
|
|
105
77
|
import { TotalVolatileOrganicCompoundsConcentrationMeasurementServer } from '@matter/main/behaviors/total-volatile-organic-compounds-concentration-measurement';
|
|
106
78
|
import { DeviceEnergyManagementServer } from '@matter/node/behaviors/device-energy-management';
|
|
107
|
-
// Matterbridge
|
|
108
79
|
import { deepCopy, deepEqual, isValidArray } from './utils/export.js';
|
|
109
80
|
import { MatterbridgeIdentifyServer, MatterbridgeOnOffServer, MatterbridgeLevelControlServer, MatterbridgeColorControlServer, MatterbridgeLiftWindowCoveringServer, MatterbridgeThermostatServer, MatterbridgeFanControlServer, MatterbridgeDoorLockServer, MatterbridgeModeSelectServer, MatterbridgeValveConfigurationAndControlServer, MatterbridgeSmokeCoAlarmServer, MatterbridgeBooleanStateConfigurationServer, MatterbridgeOperationalStateServer, MatterbridgeDeviceEnergyManagementModeServer, } from './matterbridgeBehaviors.js';
|
|
110
|
-
/**
|
|
111
|
-
* Capitalizes the first letter of a string.
|
|
112
|
-
*
|
|
113
|
-
* @param {string} name - The string to capitalize.
|
|
114
|
-
* @returns {string} The string with the first letter capitalized.
|
|
115
|
-
*/
|
|
116
81
|
export function capitalizeFirstLetter(name) {
|
|
117
82
|
if (!name)
|
|
118
83
|
return name;
|
|
119
84
|
return name.charAt(0).toUpperCase() + name.slice(1);
|
|
120
85
|
}
|
|
121
|
-
/**
|
|
122
|
-
* Lowercases the first letter of a string.
|
|
123
|
-
*
|
|
124
|
-
* @param {string} name - The string to lowercase the first letter of.
|
|
125
|
-
* @returns {string} The string with the first letter lowercased.
|
|
126
|
-
*/
|
|
127
86
|
export function lowercaseFirstLetter(name) {
|
|
128
87
|
if (!name)
|
|
129
88
|
return name;
|
|
130
89
|
return name.charAt(0).toLowerCase() + name.slice(1);
|
|
131
90
|
}
|
|
132
|
-
/**
|
|
133
|
-
* Checks if the device name contains non-Latin characters.
|
|
134
|
-
*
|
|
135
|
-
* @param {string} deviceName - The name of the device to check.
|
|
136
|
-
* @returns {boolean} Returns true if the device name contains non-Latin characters, false otherwise.
|
|
137
|
-
*/
|
|
138
91
|
export function checkNotLatinCharacters(deviceName) {
|
|
139
92
|
const nonLatinRegexList = [
|
|
140
|
-
/[\u0400-\u04FF\u0500-\u052F]/,
|
|
141
|
-
/[\u2E80-\u9FFF]/,
|
|
142
|
-
/[\uAC00-\uD7AF]/,
|
|
143
|
-
/[\u0600-\u06FF\u0750-\u077F]/,
|
|
144
|
-
/[\u0590-\u05FF]/,
|
|
145
|
-
/[\u0900-\u097F]/,
|
|
146
|
-
/[\u0E00-\u0E7F]/,
|
|
147
|
-
/[\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]/,
|
|
148
101
|
];
|
|
149
102
|
return nonLatinRegexList.some((regex) => regex.test(deviceName));
|
|
150
103
|
}
|
|
151
|
-
/**
|
|
152
|
-
* Generates a unique ID based on the device name.
|
|
153
|
-
*
|
|
154
|
-
* @param {string} deviceName - The name of the device to generate a unique ID for.
|
|
155
|
-
* @returns {string} A unique ID generated from the device name using MD5 hashing.
|
|
156
|
-
*/
|
|
157
104
|
export function generateUniqueId(deviceName) {
|
|
158
|
-
return createHash('md5').update(deviceName).digest('hex');
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Generates a unique ID based on four parameters.
|
|
162
|
-
*
|
|
163
|
-
* @param {string} param1 - The first parameter.
|
|
164
|
-
* @param {string} param2 - The second parameter.
|
|
165
|
-
* @param {string} param3 - The third parameter.
|
|
166
|
-
* @param {string} param4 - The fourth parameter.
|
|
167
|
-
* @returns {string} A unique ID generated from the concatenation of the parameters using MD5 hashing.
|
|
168
|
-
*/
|
|
105
|
+
return createHash('md5').update(deviceName).digest('hex');
|
|
106
|
+
}
|
|
169
107
|
export function createUniqueId(param1, param2, param3, param4) {
|
|
170
108
|
const hash = createHash('md5');
|
|
171
109
|
hash.update(param1 + param2 + param3 + param4);
|
|
172
110
|
return hash.digest('hex');
|
|
173
111
|
}
|
|
174
|
-
/**
|
|
175
|
-
* Retrieves the features for a specific behavior.
|
|
176
|
-
*
|
|
177
|
-
* @param {Endpoint} endpoint - The endpoint to retrieve the features from.
|
|
178
|
-
* @param {string} behavior - The behavior to retrieve the features for.
|
|
179
|
-
*
|
|
180
|
-
* @returns {Record<string, boolean | undefined>} The features for the specified behavior.
|
|
181
|
-
*
|
|
182
|
-
* @remarks Use with:
|
|
183
|
-
* ```typescript
|
|
184
|
-
* expect(featuresFor(device, 'powerSource').wired).toBe(true);
|
|
185
|
-
* ```
|
|
186
|
-
*/
|
|
187
112
|
export function featuresFor(endpoint, behavior) {
|
|
188
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
189
113
|
return endpoint.behaviors.supported[lowercaseFirstLetter(behavior)]['cluster']['supportedFeatures'];
|
|
190
114
|
}
|
|
191
|
-
/**
|
|
192
|
-
* Maps a list of ClusterId to Behavior.Type for server clusters.
|
|
193
|
-
*
|
|
194
|
-
* @param {ClusterId[]} clusterServerList - The list of ClusterId to map.
|
|
195
|
-
* @returns {Behavior.Type[]} An array of Behavior.Type corresponding to the ClusterId in the server list.
|
|
196
|
-
*/
|
|
197
115
|
export function getBehaviourTypesFromClusterServerIds(clusterServerList) {
|
|
198
|
-
// Map Server ClusterId to Behavior.Type
|
|
199
116
|
const behaviorTypes = [];
|
|
200
117
|
clusterServerList.forEach((clusterId) => {
|
|
201
118
|
behaviorTypes.push(getBehaviourTypeFromClusterServerId(clusterId));
|
|
202
119
|
});
|
|
203
120
|
return behaviorTypes;
|
|
204
121
|
}
|
|
205
|
-
/**
|
|
206
|
-
* Maps a list of ClusterId to Behavior.Type for client clusters.
|
|
207
|
-
*
|
|
208
|
-
* @param {ClusterId[]} clusterClientList - The list of ClusterId to map.
|
|
209
|
-
* @returns {Behavior.Type[]} An array of Behavior.Type corresponding to the ClusterId in the client list.
|
|
210
|
-
*/
|
|
211
122
|
export function getBehaviourTypesFromClusterClientIds(clusterClientList) {
|
|
212
|
-
// Map Client ClusterId to Behavior.Type
|
|
213
123
|
const behaviorTypes = [];
|
|
214
124
|
clusterClientList.forEach((_clusterId) => {
|
|
215
|
-
// behaviorTypes.push(getBehaviourTypeFromClusterClientId(clusterId));
|
|
216
125
|
});
|
|
217
126
|
return behaviorTypes;
|
|
218
127
|
}
|
|
219
|
-
/**
|
|
220
|
-
* Maps a ClusterId to a Behavior.Type for server clusters.
|
|
221
|
-
*
|
|
222
|
-
* @param {ClusterId} clusterId - The ClusterId to map.
|
|
223
|
-
* @returns {Behavior.Type} The corresponding Behavior.Type for the given ClusterId.
|
|
224
|
-
*/
|
|
225
128
|
export function getBehaviourTypeFromClusterServerId(clusterId) {
|
|
226
|
-
// Map ClusterId to Server Behavior.Type
|
|
227
129
|
if (clusterId === PowerSource.Cluster.id)
|
|
228
130
|
return PowerSourceServer.with(PowerSource.Feature.Wired);
|
|
229
131
|
if (clusterId === UserLabel.Cluster.id)
|
|
@@ -314,22 +216,8 @@ export function getBehaviourTypeFromClusterServerId(clusterId) {
|
|
|
314
216
|
return MatterbridgeDeviceEnergyManagementModeServer;
|
|
315
217
|
return MatterbridgeIdentifyServer;
|
|
316
218
|
}
|
|
317
|
-
/**
|
|
318
|
-
* Maps a ClusterId to a Behavior.Type for client clusters.
|
|
319
|
-
*
|
|
320
|
-
* @param {ClusterId} _clusterId - The ClusterId to map.
|
|
321
|
-
*/
|
|
322
219
|
export function getBehaviourTypeFromClusterClientId(_clusterId) {
|
|
323
|
-
|
|
324
|
-
// return IdentifyClient;
|
|
325
|
-
}
|
|
326
|
-
/**
|
|
327
|
-
* Retrieves the Behavior.Type for a given cluster from the endpoint's supported behaviors.
|
|
328
|
-
*
|
|
329
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to retrieve the behavior from.
|
|
330
|
-
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to retrieve the behavior for.
|
|
331
|
-
* @returns {Behavior.Type | undefined} The Behavior.Type for the given cluster, or undefined if not found.
|
|
332
|
-
*/
|
|
220
|
+
}
|
|
333
221
|
export function getBehavior(endpoint, cluster) {
|
|
334
222
|
let behavior;
|
|
335
223
|
if (typeof cluster === 'string') {
|
|
@@ -346,18 +234,6 @@ export function getBehavior(endpoint, cluster) {
|
|
|
346
234
|
}
|
|
347
235
|
return behavior;
|
|
348
236
|
}
|
|
349
|
-
/**
|
|
350
|
-
* Invokes a command on the specified behavior of the endpoint. Used ONLY in Jest tests.
|
|
351
|
-
*
|
|
352
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to invoke the command on.
|
|
353
|
-
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to invoke the command on.
|
|
354
|
-
* @param {keyof MatterbridgeEndpointCommands} command - The command to invoke.
|
|
355
|
-
* @param {Record<string, boolean | number | bigint | string | object | null>} [params] - The parameters to pass to the command.
|
|
356
|
-
*
|
|
357
|
-
* @returns {Promise<boolean>} A promise that resolves to true if the command was invoked successfully, false otherwise.
|
|
358
|
-
*
|
|
359
|
-
* @deprecated Used ONLY in Jest tests.
|
|
360
|
-
*/
|
|
361
237
|
export async function invokeBehaviorCommand(endpoint, cluster, command, params) {
|
|
362
238
|
const behaviorId = getBehavior(endpoint, cluster)?.id;
|
|
363
239
|
if (!behaviorId) {
|
|
@@ -365,7 +241,6 @@ export async function invokeBehaviorCommand(endpoint, cluster, command, params)
|
|
|
365
241
|
return false;
|
|
366
242
|
}
|
|
367
243
|
await endpoint.act((agent) => {
|
|
368
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
369
244
|
const behavior = agent[behaviorId];
|
|
370
245
|
if (!(command in behavior) || typeof behavior[command] !== 'function') {
|
|
371
246
|
endpoint.log?.error(`invokeBehaviorCommand error: command ${hk}${command}${er} not found on agent for endpoint ${or}${endpoint.maybeId}${er}:${or}${endpoint.maybeNumber}${er}`);
|
|
@@ -375,18 +250,6 @@ export async function invokeBehaviorCommand(endpoint, cluster, command, params)
|
|
|
375
250
|
});
|
|
376
251
|
return true;
|
|
377
252
|
}
|
|
378
|
-
/**
|
|
379
|
-
* Invokes the subscription handler on the specified cluster and attribute of the endpoint. Used ONLY in Jest tests.
|
|
380
|
-
*
|
|
381
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to invoke the subscription handler on.
|
|
382
|
-
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to invoke the subscription handler on.
|
|
383
|
-
* @param {string} attribute - The attribute to invoke the subscription handler on.
|
|
384
|
-
* @param {unknown} newValue - The new value of the attribute.
|
|
385
|
-
* @param {unknown} oldValue - The old value of the attribute.
|
|
386
|
-
*
|
|
387
|
-
* @returns {Promise<boolean>} A promise that resolves to true if the subscription handler was invoked successfully, false otherwise.
|
|
388
|
-
* @deprecated Used ONLY in Jest tests.
|
|
389
|
-
*/
|
|
390
253
|
export async function invokeSubscribeHandler(endpoint, cluster, attribute, newValue, oldValue) {
|
|
391
254
|
const event = attribute + '$Changed';
|
|
392
255
|
const clusterName = getBehavior(endpoint, cluster)?.id;
|
|
@@ -403,17 +266,9 @@ export async function invokeSubscribeHandler(endpoint, cluster, attribute, newVa
|
|
|
403
266
|
endpoint.log.error(`invokeSubscribeHandler ${hk}${event}${er} error: cluster ${clusterName} not found on endpoint ${or}${endpoint.id}${er}:${or}${endpoint.number}${er}`);
|
|
404
267
|
return false;
|
|
405
268
|
}
|
|
406
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
407
|
-
// @ts-ignore
|
|
408
269
|
await endpoint.act((agent) => agent[clusterName].events[event].emit(newValue, oldValue, { ...agent.context, offline: false }));
|
|
409
270
|
return true;
|
|
410
271
|
}
|
|
411
|
-
/**
|
|
412
|
-
* Adds required cluster servers to the specified endpoint based on the device types.
|
|
413
|
-
*
|
|
414
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to add the required cluster servers to.
|
|
415
|
-
* @returns {void}
|
|
416
|
-
*/
|
|
417
272
|
export function addRequiredClusterServers(endpoint) {
|
|
418
273
|
const requiredServerList = [];
|
|
419
274
|
endpoint.log.debug(`addRequiredClusterServers for ${CYAN}${endpoint.maybeId}${db}`);
|
|
@@ -428,12 +283,6 @@ export function addRequiredClusterServers(endpoint) {
|
|
|
428
283
|
});
|
|
429
284
|
addClusterServers(endpoint, requiredServerList);
|
|
430
285
|
}
|
|
431
|
-
/**
|
|
432
|
-
* Adds optional cluster servers to the specified endpoint based on the device types.
|
|
433
|
-
*
|
|
434
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to add the optional cluster servers to.
|
|
435
|
-
* @returns {void}
|
|
436
|
-
*/
|
|
437
286
|
export function addOptionalClusterServers(endpoint) {
|
|
438
287
|
const optionalServerList = [];
|
|
439
288
|
endpoint.log.debug(`addOptionalClusterServers for ${CYAN}${endpoint.maybeId}${db}`);
|
|
@@ -448,12 +297,6 @@ export function addOptionalClusterServers(endpoint) {
|
|
|
448
297
|
});
|
|
449
298
|
addClusterServers(endpoint, optionalServerList);
|
|
450
299
|
}
|
|
451
|
-
/**
|
|
452
|
-
* Adds cluster servers to the specified endpoint based on the provided server list.
|
|
453
|
-
*
|
|
454
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to add the cluster servers to.
|
|
455
|
-
* @param {ClusterId[]} serverList - The list of cluster IDs to add.
|
|
456
|
-
*/
|
|
457
300
|
export function addClusterServers(endpoint, serverList) {
|
|
458
301
|
if (serverList.includes(PowerSource.Cluster.id))
|
|
459
302
|
endpoint.createDefaultPowerSourceWiredClusterServer();
|
|
@@ -534,13 +377,6 @@ export function addClusterServers(endpoint, serverList) {
|
|
|
534
377
|
if (serverList.includes(DeviceEnergyManagementMode.Cluster.id))
|
|
535
378
|
endpoint.createDefaultDeviceEnergyManagementModeClusterServer();
|
|
536
379
|
}
|
|
537
|
-
/**
|
|
538
|
-
* Adds a fixed label to the FixedLabel cluster. The FixedLabel cluster is created if it does not exist.
|
|
539
|
-
*
|
|
540
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to add the cluster servers to.
|
|
541
|
-
* @param {string} label - The label to add. Max 16 characters.
|
|
542
|
-
* @param {string} value - The value of the label. Max 16 characters.
|
|
543
|
-
*/
|
|
544
380
|
export async function addFixedLabel(endpoint, label, value) {
|
|
545
381
|
if (!endpoint.hasClusterServer(FixedLabel.Cluster.id)) {
|
|
546
382
|
endpoint.log.debug(`addFixedLabel: add cluster ${hk}FixedLabel${db}:${hk}fixedLabel${db} with label ${CYAN}${label}${db} value ${CYAN}${value}${db}`);
|
|
@@ -557,13 +393,6 @@ export async function addFixedLabel(endpoint, label, value) {
|
|
|
557
393
|
await endpoint.setAttribute(FixedLabel.Cluster.id, 'labelList', labelList, endpoint.log);
|
|
558
394
|
}
|
|
559
395
|
}
|
|
560
|
-
/**
|
|
561
|
-
* Adds a user label to the UserLabel cluster. The UserLabel cluster is created if it does not exist.
|
|
562
|
-
*
|
|
563
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to add the cluster servers to.
|
|
564
|
-
* @param {string} label - The label to add. Max 16 characters.
|
|
565
|
-
* @param {string} value - The value of the label. Max 16 characters.
|
|
566
|
-
*/
|
|
567
396
|
export async function addUserLabel(endpoint, label, value) {
|
|
568
397
|
if (!endpoint.hasClusterServer(UserLabel.Cluster.id)) {
|
|
569
398
|
endpoint.log.debug(`addUserLabel: add cluster ${hk}UserLabel${db}:${hk}userLabel${db} with label ${CYAN}${label}${db} value ${CYAN}${value}${db}`);
|
|
@@ -580,48 +409,16 @@ export async function addUserLabel(endpoint, label, value) {
|
|
|
580
409
|
await endpoint.setAttribute(UserLabel.Cluster.id, 'labelList', labelList, endpoint.log);
|
|
581
410
|
}
|
|
582
411
|
}
|
|
583
|
-
/**
|
|
584
|
-
* Returns the options for a given behavior type.
|
|
585
|
-
*
|
|
586
|
-
* @param {T} type - The behavior type.
|
|
587
|
-
* @param {Behavior.Options<T>} options - The options for the behavior type.
|
|
588
|
-
* @returns {Behavior.Options<T>} The options for the behavior type.
|
|
589
|
-
*/
|
|
590
412
|
export function optionsFor(type, options) {
|
|
591
413
|
return options;
|
|
592
414
|
}
|
|
593
|
-
/**
|
|
594
|
-
* Retrieves the cluster name by its ID.
|
|
595
|
-
*
|
|
596
|
-
* @param {Endpoint} endpoint - The endpoint to retrieve the cluster name from.
|
|
597
|
-
* @param {ClusterId} cluster - The ID of the cluster.
|
|
598
|
-
* @returns {string} The name of the cluster.
|
|
599
|
-
*/
|
|
600
415
|
export function getClusterId(endpoint, cluster) {
|
|
601
416
|
return endpoint.behaviors.supported[lowercaseFirstLetter(cluster)]?.schema?.id;
|
|
602
417
|
}
|
|
603
|
-
/**
|
|
604
|
-
* Retrieves the ID of an attribute from a cluster behavior.
|
|
605
|
-
*
|
|
606
|
-
* @param {Endpoint} endpoint - The endpoint to retrieve the attribute ID from.
|
|
607
|
-
* @param {string} cluster - The name of the cluster.
|
|
608
|
-
* @param {string} attribute - The name of the attribute.
|
|
609
|
-
* @returns {number | undefined} The ID of the attribute, or undefined if not found.
|
|
610
|
-
*/
|
|
611
418
|
export function getAttributeId(endpoint, cluster, attribute) {
|
|
612
419
|
const clusterBehavior = endpoint.behaviors.supported[lowercaseFirstLetter(cluster)];
|
|
613
420
|
return clusterBehavior?.cluster?.attributes[lowercaseFirstLetter(attribute)]?.id;
|
|
614
421
|
}
|
|
615
|
-
/**
|
|
616
|
-
* Retrieves the value of the provided attribute from the given cluster.
|
|
617
|
-
*
|
|
618
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to retrieve the attribute from.
|
|
619
|
-
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to retrieve the attribute from.
|
|
620
|
-
* @param {string} attribute - The name of the attribute to retrieve.
|
|
621
|
-
* @param {AnsiLogger} [log] - (Optional) The logger to use for logging the retrieve. Errors are logged to the endpoint logger.
|
|
622
|
-
* @returns {any} The value of the attribute, or undefined if the attribute is not found.
|
|
623
|
-
*/
|
|
624
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
625
422
|
export function getAttribute(endpoint, cluster, attribute, log) {
|
|
626
423
|
const clusterName = getBehavior(endpoint, cluster)?.id;
|
|
627
424
|
if (!clusterName) {
|
|
@@ -644,16 +441,6 @@ export function getAttribute(endpoint, cluster, attribute, log) {
|
|
|
644
441
|
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}`);
|
|
645
442
|
return value;
|
|
646
443
|
}
|
|
647
|
-
/**
|
|
648
|
-
* Sets the value of an attribute on a cluster server.
|
|
649
|
-
*
|
|
650
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to set the attribute on.
|
|
651
|
-
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to set the attribute on.
|
|
652
|
-
* @param {string} attribute - The name of the attribute.
|
|
653
|
-
* @param {boolean | number | bigint | string | object | null} value - The value to set for the attribute.
|
|
654
|
-
* @param {AnsiLogger} [log] - (Optional) The logger to use for logging the set. Errors are logged to the endpoint logger.
|
|
655
|
-
* @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the attribute was successfully set.
|
|
656
|
-
*/
|
|
657
444
|
export async function setAttribute(endpoint, cluster, attribute, value, log) {
|
|
658
445
|
const clusterName = getBehavior(endpoint, cluster)?.id;
|
|
659
446
|
if (!clusterName) {
|
|
@@ -679,16 +466,6 @@ export async function setAttribute(endpoint, cluster, attribute, value, log) {
|
|
|
679
466
|
`to ${YELLOW}${value !== null && typeof value === 'object' ? debugStringify(value) : value}${db}`);
|
|
680
467
|
return true;
|
|
681
468
|
}
|
|
682
|
-
/**
|
|
683
|
-
* Sets the value of an attribute on a cluster server.
|
|
684
|
-
*
|
|
685
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to update the attribute on.
|
|
686
|
-
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to update the attribute on.
|
|
687
|
-
* @param {string} attribute - The name of the attribute.
|
|
688
|
-
* @param {boolean | number | bigint | string | object | null} value - The value to set for the attribute.
|
|
689
|
-
* @param {AnsiLogger} [log] - (Optional) The logger to use for logging the update. Errors are logged to the endpoint logger.
|
|
690
|
-
* @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the attribute was successfully set.
|
|
691
|
-
*/
|
|
692
469
|
export async function updateAttribute(endpoint, cluster, attribute, value, log) {
|
|
693
470
|
const clusterName = getBehavior(endpoint, cluster)?.id;
|
|
694
471
|
if (!clusterName) {
|
|
@@ -719,24 +496,7 @@ export async function updateAttribute(endpoint, cluster, attribute, value, log)
|
|
|
719
496
|
`to ${YELLOW}${value !== null && typeof value === 'object' ? debugStringify(value) : value}${db}`);
|
|
720
497
|
return true;
|
|
721
498
|
}
|
|
722
|
-
|
|
723
|
-
* Subscribes to the provided attribute on a cluster.
|
|
724
|
-
*
|
|
725
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to subscribe the attribute to.
|
|
726
|
-
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to subscribe the attribute to.
|
|
727
|
-
* @param {string} attribute - The name of the attribute to subscribe to.
|
|
728
|
-
* @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.
|
|
729
|
-
* @param {AnsiLogger} [log] - Optional logger for logging errors and information.
|
|
730
|
-
* @returns {boolean} - A boolean indicating whether the subscription was successful.
|
|
731
|
-
*
|
|
732
|
-
* @remarks The listener function (cannot be async) will receive three parameters:
|
|
733
|
-
* - `newValue`: The new value of the attribute.
|
|
734
|
-
* - `oldValue`: The old value of the attribute.
|
|
735
|
-
* - `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.
|
|
736
|
-
*/
|
|
737
|
-
export async function subscribeAttribute(endpoint, cluster, attribute,
|
|
738
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
739
|
-
listener, log) {
|
|
499
|
+
export async function subscribeAttribute(endpoint, cluster, attribute, listener, log) {
|
|
740
500
|
const clusterName = getBehavior(endpoint, cluster)?.id;
|
|
741
501
|
if (!clusterName) {
|
|
742
502
|
endpoint.log.error(`subscribeAttribute ${hk}${attribute}${er} error: cluster not found on endpoint ${or}${endpoint.maybeId}${er}:${or}${endpoint.maybeNumber}${er}`);
|
|
@@ -746,7 +506,6 @@ listener, log) {
|
|
|
746
506
|
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`);
|
|
747
507
|
await endpoint.construction.ready;
|
|
748
508
|
}
|
|
749
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
750
509
|
const events = endpoint.events;
|
|
751
510
|
attribute = lowercaseFirstLetter(attribute) + '$Changed';
|
|
752
511
|
if (!(clusterName in events) || !(attribute in events[clusterName])) {
|
|
@@ -757,17 +516,6 @@ listener, log) {
|
|
|
757
516
|
log?.info(`${db}Subscribed endpoint ${or}${endpoint.id}${db}:${or}${endpoint.number}${db} attribute ${hk}${capitalizeFirstLetter(clusterName)}${db}.${hk}${attribute}${db}`);
|
|
758
517
|
return true;
|
|
759
518
|
}
|
|
760
|
-
/**
|
|
761
|
-
* Triggers an event on the specified cluster.
|
|
762
|
-
*
|
|
763
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to trigger the event on.
|
|
764
|
-
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The ID of the cluster.
|
|
765
|
-
* @param {string} event - The name of the event to trigger.
|
|
766
|
-
* @param {Record<string, boolean | number | bigint | string | object | undefined | null>} payload - The payload to pass to the event.
|
|
767
|
-
* @param {AnsiLogger} [log] - Optional logger for logging information.
|
|
768
|
-
*
|
|
769
|
-
* @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the event was successfully triggered.
|
|
770
|
-
*/
|
|
771
519
|
export async function triggerEvent(endpoint, cluster, event, payload, log) {
|
|
772
520
|
const clusterName = getBehavior(endpoint, cluster)?.id;
|
|
773
521
|
if (!clusterName) {
|
|
@@ -778,32 +526,15 @@ export async function triggerEvent(endpoint, cluster, event, payload, log) {
|
|
|
778
526
|
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`);
|
|
779
527
|
return false;
|
|
780
528
|
}
|
|
781
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
782
529
|
const events = endpoint.events;
|
|
783
530
|
if (!(clusterName in events) || !(event in events[clusterName])) {
|
|
784
531
|
endpoint.log.error(`triggerEvent ${hk}${event}${er} error: cluster ${clusterName} not found on endpoint ${or}${endpoint.id}${er}:${or}${endpoint.number}${er}`);
|
|
785
532
|
return false;
|
|
786
533
|
}
|
|
787
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
788
|
-
// @ts-ignore
|
|
789
534
|
await endpoint.act((agent) => agent[clusterName].events[event].emit(payload, agent.context));
|
|
790
535
|
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} `);
|
|
791
536
|
return true;
|
|
792
537
|
}
|
|
793
|
-
/**
|
|
794
|
-
* Get the default OperationalState Cluster Server.
|
|
795
|
-
*
|
|
796
|
-
* @param {OperationalState.OperationalStateEnum} operationalState - The initial operational state id.
|
|
797
|
-
*
|
|
798
|
-
* @returns {Behavior.Options<MatterbridgeOperationalStateServer>} - The default options for the OperationalState cluster server.
|
|
799
|
-
*
|
|
800
|
-
* @remarks
|
|
801
|
-
* This method adds a cluster server with a default operational state configuration:
|
|
802
|
-
* - { operationalStateId: OperationalState.OperationalStateEnum.Stopped, operationalStateLabel: 'Stopped' },
|
|
803
|
-
* - { operationalStateId: OperationalState.OperationalStateEnum.Running, operationalStateLabel: 'Running' },
|
|
804
|
-
* - { operationalStateId: OperationalState.OperationalStateEnum.Paused, operationalStateLabel: 'Paused' },
|
|
805
|
-
* - { operationalStateId: OperationalState.OperationalStateEnum.Error, operationalStateLabel: 'Error' },
|
|
806
|
-
*/
|
|
807
538
|
export function getDefaultOperationalStateClusterServer(operationalState = OperationalState.OperationalStateEnum.Stopped) {
|
|
808
539
|
return optionsFor(MatterbridgeOperationalStateServer, {
|
|
809
540
|
phaseList: [],
|
|
@@ -819,14 +550,6 @@ export function getDefaultOperationalStateClusterServer(operationalState = Opera
|
|
|
819
550
|
operationalError: { errorStateId: OperationalState.ErrorState.NoError, errorStateLabel: 'No error', errorStateDetails: 'Fully operational' },
|
|
820
551
|
});
|
|
821
552
|
}
|
|
822
|
-
/**
|
|
823
|
-
* Get the default TemperatureMeasurement cluster server options.
|
|
824
|
-
*
|
|
825
|
-
* @param {number | null} measuredValue - The measured value of the temperature x 100.
|
|
826
|
-
* @param {number | null} minMeasuredValue - The minimum measured value of the temperature x 100.
|
|
827
|
-
* @param {number | null} maxMeasuredValue - The maximum measured value of the temperature x 100.
|
|
828
|
-
* @returns {Behavior.Options<MatterbridgeTemperatureMeasurementServer>} - The default options for the TemperatureMeasurement cluster server.
|
|
829
|
-
*/
|
|
830
553
|
export function getDefaultTemperatureMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
831
554
|
return optionsFor(TemperatureMeasurementServer, {
|
|
832
555
|
measuredValue,
|
|
@@ -835,14 +558,6 @@ export function getDefaultTemperatureMeasurementClusterServer(measuredValue = nu
|
|
|
835
558
|
tolerance: 0,
|
|
836
559
|
});
|
|
837
560
|
}
|
|
838
|
-
/**
|
|
839
|
-
* Get the default RelativeHumidityMeasurement cluster server options.
|
|
840
|
-
*
|
|
841
|
-
* @param {number | null} measuredValue - The measured value of the relative humidity x 100.
|
|
842
|
-
* @param {number | null} minMeasuredValue - The minimum measured value of the relative humidity x 100.
|
|
843
|
-
* @param {number | null} maxMeasuredValue - The maximum measured value of the relative humidity x 100.
|
|
844
|
-
* @returns {Behavior.Options<MatterbridgeRelativeHumidityMeasurementServer>} - The default options for the RelativeHumidityMeasurement cluster server.
|
|
845
|
-
*/
|
|
846
561
|
export function getDefaultRelativeHumidityMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
847
562
|
return optionsFor(RelativeHumidityMeasurementServer, {
|
|
848
563
|
measuredValue,
|
|
@@ -851,14 +566,6 @@ export function getDefaultRelativeHumidityMeasurementClusterServer(measuredValue
|
|
|
851
566
|
tolerance: 0,
|
|
852
567
|
});
|
|
853
568
|
}
|
|
854
|
-
/**
|
|
855
|
-
* Get the default PressureMeasurement cluster server options.
|
|
856
|
-
*
|
|
857
|
-
* @param {number | null} measuredValue - The measured value for the pressure in kPa x 10.
|
|
858
|
-
* @param {number | null} minMeasuredValue - The minimum measured value for the pressure in kPa x 10.
|
|
859
|
-
* @param {number | null} maxMeasuredValue - The maximum measured value for the pressure in kPa x 10.
|
|
860
|
-
* @returns {Behavior.Options<MatterbridgePressureMeasurementServer>} - The default options for the PressureMeasurement cluster server.
|
|
861
|
-
*/
|
|
862
569
|
export function getDefaultPressureMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
863
570
|
return optionsFor(PressureMeasurementServer, {
|
|
864
571
|
measuredValue,
|
|
@@ -867,22 +574,6 @@ export function getDefaultPressureMeasurementClusterServer(measuredValue = null,
|
|
|
867
574
|
tolerance: 0,
|
|
868
575
|
});
|
|
869
576
|
}
|
|
870
|
-
/**
|
|
871
|
-
* Get the default IlluminanceMeasurement cluster server options.
|
|
872
|
-
*
|
|
873
|
-
* @param {number | null} measuredValue - The measured value of illuminance.
|
|
874
|
-
* @param {number | null} minMeasuredValue - The minimum measured value of illuminance.
|
|
875
|
-
* @param {number | null} maxMeasuredValue - The maximum measured value of illuminance.
|
|
876
|
-
*
|
|
877
|
-
* @returns {Behavior.Options<MatterbridgeIlluminanceMeasurementServer>} - The default options for the IlluminanceMeasurement cluster server.
|
|
878
|
-
*
|
|
879
|
-
* @remarks The default value for the illuminance measurement is null.
|
|
880
|
-
* This attribute SHALL indicate the illuminance in Lux (symbol lx) as follows:
|
|
881
|
-
* • MeasuredValue = 10,000 x log10(illuminance) + 1,
|
|
882
|
-
* where 1 lx <= illuminance <= 3.576 Mlx, corresponding to a MeasuredValue in the range 1 to 0xFFFE.
|
|
883
|
-
* • 0 indicates a value of illuminance that is too low to be measured
|
|
884
|
-
* • null indicates that the illuminance measurement is invalid.
|
|
885
|
-
*/
|
|
886
577
|
export function getDefaultIlluminanceMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
887
578
|
return optionsFor(IlluminanceMeasurementServer, {
|
|
888
579
|
measuredValue,
|
|
@@ -891,14 +582,6 @@ export function getDefaultIlluminanceMeasurementClusterServer(measuredValue = nu
|
|
|
891
582
|
tolerance: 0,
|
|
892
583
|
});
|
|
893
584
|
}
|
|
894
|
-
/**
|
|
895
|
-
* Get the default FlowMeasurement cluster server options.
|
|
896
|
-
*
|
|
897
|
-
* @param {number | null} measuredValue - The measured value of the flow in 10 x m3/h.
|
|
898
|
-
* @param {number | null} minMeasuredValue - The minimum measured value of the flow in 10 x m3/h.
|
|
899
|
-
* @param {number | null} maxMeasuredValue - The maximum measured value of the flow in 10 x m3/h.
|
|
900
|
-
* @returns {Behavior.Options<MatterbridgeFlowMeasurementServer>} - The default options for the FlowMeasurement cluster server.
|
|
901
|
-
*/
|
|
902
585
|
export function getDefaultFlowMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
903
586
|
return optionsFor(FlowMeasurementServer, {
|
|
904
587
|
measuredValue,
|
|
@@ -907,20 +590,6 @@ export function getDefaultFlowMeasurementClusterServer(measuredValue = null, min
|
|
|
907
590
|
tolerance: 0,
|
|
908
591
|
});
|
|
909
592
|
}
|
|
910
|
-
/**
|
|
911
|
-
* Get the default OccupancySensing cluster server options.
|
|
912
|
-
*
|
|
913
|
-
* @param {boolean} occupied - A boolean indicating whether the occupancy is occupied or not. Default is false.
|
|
914
|
-
* @param {number} holdTime - The hold time in seconds. Default is 30.
|
|
915
|
-
* @param {number} holdTimeMin - The minimum hold time in seconds. Default is 1.
|
|
916
|
-
* @param {number} holdTimeMax - The maximum hold time in seconds. Default is 300.
|
|
917
|
-
* @returns {Behavior.Options<MatterbridgeOccupancySensingServer>} - The default options for the OccupancySensing cluster server.
|
|
918
|
-
*
|
|
919
|
-
* @remarks The default value for the occupancy sensor type is PIR.
|
|
920
|
-
* Servers SHALL set these attributes for backward compatibility with clients implementing a cluster revision <= 4 as
|
|
921
|
-
* described in OccupancySensorType and OccupancySensorTypeBitmap Attributes.
|
|
922
|
-
* This replaces the 9 legacy attributes PIROccupiedToUnoccupiedDelay through PhysicalContactUnoccupiedToOccupiedThreshold.
|
|
923
|
-
*/
|
|
924
593
|
export function getDefaultOccupancySensingClusterServer(occupied = false, holdTime = 30, holdTimeMin = 1, holdTimeMax = 300) {
|
|
925
594
|
return optionsFor(OccupancySensingServer.with(OccupancySensing.Feature.PassiveInfrared), {
|
|
926
595
|
occupancy: { occupied },
|
|
@@ -932,4 +601,3 @@ export function getDefaultOccupancySensingClusterServer(occupied = false, holdTi
|
|
|
932
601
|
holdTimeLimits: { holdTimeMin, holdTimeMax, holdTimeDefault: holdTime },
|
|
933
602
|
});
|
|
934
603
|
}
|
|
935
|
-
//# sourceMappingURL=matterbridgeEndpointHelpers.js.map
|