matterbridge 3.5.2 → 3.5.3-dev-20260202-e19e9b6
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 +30 -1
- package/README-DOCKER.md +2 -2
- package/README.md +14 -9
- package/dist/broadcastServer.d.ts +0 -115
- package/dist/broadcastServer.js +0 -117
- package/dist/broadcastServerTypes.d.ts +0 -43
- package/dist/broadcastServerTypes.js +0 -24
- package/dist/checkUpdates.d.ts +0 -75
- package/dist/checkUpdates.js +1 -91
- package/dist/cli.d.ts +0 -24
- package/dist/cli.js +1 -97
- package/dist/cliEmitter.d.ts +0 -36
- package/dist/cliEmitter.js +0 -37
- package/dist/cliHistory.d.ts +0 -42
- package/dist/cliHistory.js +0 -38
- package/dist/clusters/export.d.ts +0 -1
- package/dist/clusters/export.js +0 -2
- package/dist/deviceManager.d.ts +0 -108
- package/dist/deviceManager.js +1 -114
- package/dist/devices/airConditioner.d.ts +0 -75
- package/dist/devices/airConditioner.js +0 -57
- package/dist/devices/basicVideoPlayer.d.ts +0 -58
- package/dist/devices/basicVideoPlayer.js +1 -56
- package/dist/devices/batteryStorage.d.ts +0 -43
- package/dist/devices/batteryStorage.js +1 -48
- package/dist/devices/castingVideoPlayer.d.ts +0 -63
- package/dist/devices/castingVideoPlayer.js +2 -65
- package/dist/devices/cooktop.d.ts +0 -55
- package/dist/devices/cooktop.js +0 -56
- package/dist/devices/dishwasher.d.ts +0 -55
- package/dist/devices/dishwasher.js +0 -57
- package/dist/devices/evse.d.ts +0 -57
- package/dist/devices/evse.js +10 -74
- package/dist/devices/export.d.ts +0 -1
- package/dist/devices/export.js +0 -5
- package/dist/devices/extractorHood.d.ts +0 -41
- package/dist/devices/extractorHood.js +0 -43
- package/dist/devices/heatPump.d.ts +0 -43
- package/dist/devices/heatPump.js +2 -50
- package/dist/devices/laundryDryer.d.ts +0 -58
- package/dist/devices/laundryDryer.js +3 -62
- package/dist/devices/laundryWasher.d.ts +0 -64
- package/dist/devices/laundryWasher.js +4 -70
- package/dist/devices/microwaveOven.d.ts +1 -77
- package/dist/devices/microwaveOven.js +5 -88
- package/dist/devices/oven.d.ts +0 -82
- package/dist/devices/oven.js +0 -85
- package/dist/devices/refrigerator.d.ts +0 -100
- package/dist/devices/refrigerator.js +0 -102
- package/dist/devices/roboticVacuumCleaner.d.ts +0 -83
- package/dist/devices/roboticVacuumCleaner.js +9 -100
- package/dist/devices/solarPower.d.ts +0 -36
- package/dist/devices/solarPower.js +0 -38
- package/dist/devices/speaker.d.ts +0 -79
- package/dist/devices/speaker.js +0 -84
- package/dist/devices/temperatureControl.d.ts +0 -21
- package/dist/devices/temperatureControl.js +3 -24
- package/dist/devices/waterHeater.d.ts +0 -74
- package/dist/devices/waterHeater.js +2 -82
- package/dist/dgram/export.d.ts +0 -1
- package/dist/dgram/export.js +0 -1
- package/dist/frontend.d.ts +0 -187
- package/dist/frontend.js +37 -498
- package/dist/frontendTypes.d.ts +0 -57
- package/dist/frontendTypes.js +0 -45
- package/dist/helpers.d.ts +0 -43
- package/dist/helpers.js +0 -54
- package/dist/index.d.ts +0 -23
- package/dist/index.js +0 -25
- package/dist/jestutils/export.d.ts +0 -1
- package/dist/jestutils/export.js +0 -1
- package/dist/jestutils/jestHelpers.d.ts +0 -255
- package/dist/jestutils/jestHelpers.js +15 -371
- package/dist/logger/export.d.ts +0 -1
- package/dist/logger/export.js +0 -1
- package/dist/matter/behaviors.d.ts +0 -1
- package/dist/matter/behaviors.js +0 -2
- package/dist/matter/clusters.d.ts +0 -1
- package/dist/matter/clusters.js +0 -2
- package/dist/matter/devices.d.ts +0 -1
- package/dist/matter/devices.js +0 -2
- package/dist/matter/endpoints.d.ts +0 -1
- package/dist/matter/endpoints.js +0 -2
- package/dist/matter/export.d.ts +0 -1
- package/dist/matter/export.js +0 -2
- package/dist/matter/types.d.ts +0 -1
- package/dist/matter/types.js +0 -2
- package/dist/matterNode.d.ts +0 -258
- package/dist/matterNode.js +8 -359
- package/dist/matterbridge.d.ts +0 -373
- package/dist/matterbridge.js +46 -854
- package/dist/matterbridgeAccessoryPlatform.d.ts +0 -42
- package/dist/matterbridgeAccessoryPlatform.js +0 -50
- package/dist/matterbridgeBehaviors.d.ts +0 -24
- package/dist/matterbridgeBehaviors.js +5 -65
- package/dist/matterbridgeDeviceTypes.d.ts +0 -649
- package/dist/matterbridgeDeviceTypes.js +6 -673
- package/dist/matterbridgeDynamicPlatform.d.ts +0 -42
- package/dist/matterbridgeDynamicPlatform.js +0 -50
- package/dist/matterbridgeEndpoint.d.ts +0 -1369
- package/dist/matterbridgeEndpoint.js +54 -1507
- package/dist/matterbridgeEndpointHelpers.d.ts +0 -425
- package/dist/matterbridgeEndpointHelpers.js +20 -482
- package/dist/matterbridgeEndpointTypes.d.ts +0 -70
- package/dist/matterbridgeEndpointTypes.js +0 -25
- package/dist/matterbridgePlatform.d.ts +0 -434
- package/dist/matterbridgePlatform.js +1 -472
- package/dist/matterbridgePlatformTypes.d.ts +0 -29
- package/dist/matterbridgePlatformTypes.js +0 -24
- package/dist/matterbridgeTypes.d.ts +0 -46
- package/dist/matterbridgeTypes.js +0 -26
- package/dist/mb_coap.d.ts +0 -23
- package/dist/mb_coap.js +3 -41
- package/dist/mb_health.d.ts +0 -67
- package/dist/mb_health.js +0 -70
- package/dist/mb_mdns.d.ts +0 -23
- package/dist/mb_mdns.js +36 -94
- package/dist/pluginManager.d.ts +0 -305
- package/dist/pluginManager.js +5 -342
- package/dist/shelly.d.ts +0 -157
- package/dist/shelly.js +7 -178
- package/dist/spawn.d.ts +0 -32
- package/dist/spawn.js +1 -71
- package/dist/storage/export.d.ts +0 -1
- package/dist/storage/export.js +0 -1
- package/dist/utils/export.d.ts +0 -1
- package/dist/utils/export.js +0 -1
- package/dist/worker.d.ts +0 -61
- package/dist/worker.js +4 -65
- package/dist/workerCheckUpdates.d.ts +0 -24
- package/dist/workerCheckUpdates.js +5 -36
- package/dist/workerGlobalPrefix.d.ts +0 -24
- package/dist/workerGlobalPrefix.js +5 -36
- package/dist/workerTypes.d.ts +0 -25
- package/dist/workerTypes.js +0 -24
- package/frontend/build/assets/index.js +4 -4
- package/frontend/build/assets/vendor_emotion.js +1 -1
- package/frontend/build/assets/vendor_lodash.js +1 -1
- package/frontend/build/assets/vendor_mdi.js +1 -1
- package/frontend/build/assets/vendor_mui.js +22 -22
- package/frontend/build/assets/vendor_node_modules.js +20 -20
- package/frontend/build/assets/vendor_notistack.js +2 -2
- package/frontend/build/assets/vendor_qrcode.js +1 -1
- package/frontend/build/assets/vendor_rjsf.js +8 -8
- package/frontend/build/index.html +1 -1
- package/frontend/package.json +48 -47
- package/npm-shrinkwrap.json +77 -47
- package/package.json +7 -7
- package/dist/broadcastServer.d.ts.map +0 -1
- package/dist/broadcastServer.js.map +0 -1
- package/dist/broadcastServerTypes.d.ts.map +0 -1
- package/dist/broadcastServerTypes.js.map +0 -1
- package/dist/checkUpdates.d.ts.map +0 -1
- package/dist/checkUpdates.js.map +0 -1
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/cliEmitter.d.ts.map +0 -1
- package/dist/cliEmitter.js.map +0 -1
- package/dist/cliHistory.d.ts.map +0 -1
- package/dist/cliHistory.js.map +0 -1
- package/dist/clusters/export.d.ts.map +0 -1
- package/dist/clusters/export.js.map +0 -1
- package/dist/deviceManager.d.ts.map +0 -1
- package/dist/deviceManager.js.map +0 -1
- package/dist/devices/airConditioner.d.ts.map +0 -1
- package/dist/devices/airConditioner.js.map +0 -1
- package/dist/devices/basicVideoPlayer.d.ts.map +0 -1
- package/dist/devices/basicVideoPlayer.js.map +0 -1
- package/dist/devices/batteryStorage.d.ts.map +0 -1
- package/dist/devices/batteryStorage.js.map +0 -1
- package/dist/devices/castingVideoPlayer.d.ts.map +0 -1
- package/dist/devices/castingVideoPlayer.js.map +0 -1
- package/dist/devices/cooktop.d.ts.map +0 -1
- package/dist/devices/cooktop.js.map +0 -1
- package/dist/devices/dishwasher.d.ts.map +0 -1
- package/dist/devices/dishwasher.js.map +0 -1
- package/dist/devices/evse.d.ts.map +0 -1
- package/dist/devices/evse.js.map +0 -1
- package/dist/devices/export.d.ts.map +0 -1
- package/dist/devices/export.js.map +0 -1
- package/dist/devices/extractorHood.d.ts.map +0 -1
- package/dist/devices/extractorHood.js.map +0 -1
- package/dist/devices/heatPump.d.ts.map +0 -1
- package/dist/devices/heatPump.js.map +0 -1
- package/dist/devices/laundryDryer.d.ts.map +0 -1
- package/dist/devices/laundryDryer.js.map +0 -1
- package/dist/devices/laundryWasher.d.ts.map +0 -1
- package/dist/devices/laundryWasher.js.map +0 -1
- package/dist/devices/microwaveOven.d.ts.map +0 -1
- package/dist/devices/microwaveOven.js.map +0 -1
- package/dist/devices/oven.d.ts.map +0 -1
- package/dist/devices/oven.js.map +0 -1
- package/dist/devices/refrigerator.d.ts.map +0 -1
- package/dist/devices/refrigerator.js.map +0 -1
- package/dist/devices/roboticVacuumCleaner.d.ts.map +0 -1
- package/dist/devices/roboticVacuumCleaner.js.map +0 -1
- package/dist/devices/solarPower.d.ts.map +0 -1
- package/dist/devices/solarPower.js.map +0 -1
- package/dist/devices/speaker.d.ts.map +0 -1
- package/dist/devices/speaker.js.map +0 -1
- package/dist/devices/temperatureControl.d.ts.map +0 -1
- package/dist/devices/temperatureControl.js.map +0 -1
- package/dist/devices/waterHeater.d.ts.map +0 -1
- package/dist/devices/waterHeater.js.map +0 -1
- package/dist/dgram/export.d.ts.map +0 -1
- package/dist/dgram/export.js.map +0 -1
- package/dist/frontend.d.ts.map +0 -1
- package/dist/frontend.js.map +0 -1
- package/dist/frontendTypes.d.ts.map +0 -1
- package/dist/frontendTypes.js.map +0 -1
- package/dist/helpers.d.ts.map +0 -1
- package/dist/helpers.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/jestutils/export.d.ts.map +0 -1
- package/dist/jestutils/export.js.map +0 -1
- package/dist/jestutils/jestHelpers.d.ts.map +0 -1
- package/dist/jestutils/jestHelpers.js.map +0 -1
- package/dist/logger/export.d.ts.map +0 -1
- package/dist/logger/export.js.map +0 -1
- package/dist/matter/behaviors.d.ts.map +0 -1
- package/dist/matter/behaviors.js.map +0 -1
- package/dist/matter/clusters.d.ts.map +0 -1
- package/dist/matter/clusters.js.map +0 -1
- package/dist/matter/devices.d.ts.map +0 -1
- package/dist/matter/devices.js.map +0 -1
- package/dist/matter/endpoints.d.ts.map +0 -1
- package/dist/matter/endpoints.js.map +0 -1
- package/dist/matter/export.d.ts.map +0 -1
- package/dist/matter/export.js.map +0 -1
- package/dist/matter/types.d.ts.map +0 -1
- package/dist/matter/types.js.map +0 -1
- package/dist/matterNode.d.ts.map +0 -1
- package/dist/matterNode.js.map +0 -1
- package/dist/matterbridge.d.ts.map +0 -1
- package/dist/matterbridge.js.map +0 -1
- package/dist/matterbridgeAccessoryPlatform.d.ts.map +0 -1
- package/dist/matterbridgeAccessoryPlatform.js.map +0 -1
- package/dist/matterbridgeBehaviors.d.ts.map +0 -1
- package/dist/matterbridgeBehaviors.js.map +0 -1
- package/dist/matterbridgeDeviceTypes.d.ts.map +0 -1
- package/dist/matterbridgeDeviceTypes.js.map +0 -1
- package/dist/matterbridgeDynamicPlatform.d.ts.map +0 -1
- package/dist/matterbridgeDynamicPlatform.js.map +0 -1
- package/dist/matterbridgeEndpoint.d.ts.map +0 -1
- package/dist/matterbridgeEndpoint.js.map +0 -1
- package/dist/matterbridgeEndpointHelpers.d.ts.map +0 -1
- package/dist/matterbridgeEndpointHelpers.js.map +0 -1
- package/dist/matterbridgeEndpointTypes.d.ts.map +0 -1
- package/dist/matterbridgeEndpointTypes.js.map +0 -1
- package/dist/matterbridgePlatform.d.ts.map +0 -1
- package/dist/matterbridgePlatform.js.map +0 -1
- package/dist/matterbridgePlatformTypes.d.ts.map +0 -1
- package/dist/matterbridgePlatformTypes.js.map +0 -1
- package/dist/matterbridgeTypes.d.ts.map +0 -1
- package/dist/matterbridgeTypes.js.map +0 -1
- package/dist/mb_coap.d.ts.map +0 -1
- package/dist/mb_coap.js.map +0 -1
- package/dist/mb_health.d.ts.map +0 -1
- package/dist/mb_health.js.map +0 -1
- package/dist/mb_mdns.d.ts.map +0 -1
- package/dist/mb_mdns.js.map +0 -1
- package/dist/pluginManager.d.ts.map +0 -1
- package/dist/pluginManager.js.map +0 -1
- package/dist/shelly.d.ts.map +0 -1
- package/dist/shelly.js.map +0 -1
- package/dist/spawn.d.ts.map +0 -1
- package/dist/spawn.js.map +0 -1
- package/dist/storage/export.d.ts.map +0 -1
- package/dist/storage/export.js.map +0 -1
- package/dist/utils/export.d.ts.map +0 -1
- package/dist/utils/export.js.map +0 -1
- package/dist/worker.d.ts.map +0 -1
- package/dist/worker.js.map +0 -1
- package/dist/workerCheckUpdates.d.ts.map +0 -1
- package/dist/workerCheckUpdates.js.map +0 -1
- package/dist/workerGlobalPrefix.d.ts.map +0 -1
- package/dist/workerGlobalPrefix.js.map +0 -1
- package/dist/workerTypes.d.ts.map +0 -1
- package/dist/workerTypes.js.map +0 -1
|
@@ -1,38 +1,10 @@
|
|
|
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
|
-
// eslint-disable-next-line no-console
|
|
25
1
|
if (process.argv.includes('--loader') || process.argv.includes('-loader'))
|
|
26
2
|
console.log('\u001B[32mMatterbridgeEndpointHelpers loaded.\u001B[40;0m');
|
|
27
|
-
// Other modules
|
|
28
3
|
import { createHash } from 'node:crypto';
|
|
29
|
-
// AnsiLogger module
|
|
30
4
|
import { BLUE, CYAN, db, debugStringify, er, hk, or, YELLOW, zb } from 'node-ansi-logger';
|
|
31
|
-
// @matter
|
|
32
5
|
import { Lifecycle } from '@matter/general';
|
|
33
6
|
import { MeasurementType } from '@matter/types/globals';
|
|
34
7
|
import { getClusterNameById } from '@matter/types/cluster';
|
|
35
|
-
// @matter clusters
|
|
36
8
|
import { PowerSource } from '@matter/types/clusters/power-source';
|
|
37
9
|
import { UserLabel } from '@matter/types/clusters/user-label';
|
|
38
10
|
import { FixedLabel } from '@matter/types/clusters/fixed-label';
|
|
@@ -78,7 +50,6 @@ import { TotalVolatileOrganicCompoundsConcentrationMeasurement } from '@matter/t
|
|
|
78
50
|
import { OperationalState } from '@matter/types/clusters/operational-state';
|
|
79
51
|
import { DeviceEnergyManagement } from '@matter/types/clusters/device-energy-management';
|
|
80
52
|
import { DeviceEnergyManagementMode } from '@matter/types/clusters/device-energy-management-mode';
|
|
81
|
-
// @matter behaviors
|
|
82
53
|
import { PowerSourceServer } from '@matter/node/behaviors/power-source';
|
|
83
54
|
import { UserLabelServer } from '@matter/node/behaviors/user-label';
|
|
84
55
|
import { FixedLabelServer } from '@matter/node/behaviors/fixed-label';
|
|
@@ -111,128 +82,59 @@ import { RadonConcentrationMeasurementServer } from '@matter/node/behaviors/rado
|
|
|
111
82
|
import { TotalVolatileOrganicCompoundsConcentrationMeasurementServer } from '@matter/node/behaviors/total-volatile-organic-compounds-concentration-measurement';
|
|
112
83
|
import { deepCopy, deepEqual, isValidArray } from '@matterbridge/utils';
|
|
113
84
|
import { MatterbridgeIdentifyServer, MatterbridgeOnOffServer, MatterbridgeLevelControlServer, MatterbridgeColorControlServer, MatterbridgeLiftWindowCoveringServer, MatterbridgeThermostatServer, MatterbridgeFanControlServer, MatterbridgeDoorLockServer, MatterbridgeModeSelectServer, MatterbridgeValveConfigurationAndControlServer, MatterbridgeSmokeCoAlarmServer, MatterbridgeBooleanStateConfigurationServer, MatterbridgeOperationalStateServer, MatterbridgePowerSourceServer, MatterbridgeDeviceEnergyManagementServer, MatterbridgeDeviceEnergyManagementModeServer, } from './matterbridgeBehaviors.js';
|
|
114
|
-
/**
|
|
115
|
-
* Capitalizes the first letter of a string.
|
|
116
|
-
*
|
|
117
|
-
* @param {string} name - The string to capitalize.
|
|
118
|
-
* @returns {string} The string with the first letter capitalized.
|
|
119
|
-
*/
|
|
120
85
|
export function capitalizeFirstLetter(name) {
|
|
121
86
|
if (!name)
|
|
122
87
|
return name;
|
|
123
88
|
return name.charAt(0).toUpperCase() + name.slice(1);
|
|
124
89
|
}
|
|
125
|
-
/**
|
|
126
|
-
* Lowercases the first letter of a string.
|
|
127
|
-
*
|
|
128
|
-
* @param {string} name - The string to lowercase the first letter of.
|
|
129
|
-
* @returns {string} The string with the first letter lowercased.
|
|
130
|
-
*/
|
|
131
90
|
export function lowercaseFirstLetter(name) {
|
|
132
91
|
if (!name)
|
|
133
92
|
return name;
|
|
134
93
|
return name.charAt(0).toLowerCase() + name.slice(1);
|
|
135
94
|
}
|
|
136
|
-
/**
|
|
137
|
-
* Checks if the device name contains non-Latin characters.
|
|
138
|
-
*
|
|
139
|
-
* @param {string} deviceName - The name of the device to check.
|
|
140
|
-
* @returns {boolean} Returns true if the device name contains non-Latin characters, false otherwise.
|
|
141
|
-
*/
|
|
142
95
|
export function checkNotLatinCharacters(deviceName) {
|
|
143
96
|
const nonLatinRegexList = [
|
|
144
|
-
/[\u0400-\u04FF\u0500-\u052F]/,
|
|
145
|
-
/[\u2E80-\u9FFF]/,
|
|
146
|
-
/[\uAC00-\uD7AF]/,
|
|
147
|
-
/[\u0600-\u06FF\u0750-\u077F]/,
|
|
148
|
-
/[\u0590-\u05FF]/,
|
|
149
|
-
/[\u0900-\u097F]/,
|
|
150
|
-
/[\u0E00-\u0E7F]/,
|
|
151
|
-
/[\u1200-\u137F]/,
|
|
97
|
+
/[\u0400-\u04FF\u0500-\u052F]/,
|
|
98
|
+
/[\u2E80-\u9FFF]/,
|
|
99
|
+
/[\uAC00-\uD7AF]/,
|
|
100
|
+
/[\u0600-\u06FF\u0750-\u077F]/,
|
|
101
|
+
/[\u0590-\u05FF]/,
|
|
102
|
+
/[\u0900-\u097F]/,
|
|
103
|
+
/[\u0E00-\u0E7F]/,
|
|
104
|
+
/[\u1200-\u137F]/,
|
|
152
105
|
];
|
|
153
106
|
return nonLatinRegexList.some((regex) => regex.test(deviceName));
|
|
154
107
|
}
|
|
155
|
-
/**
|
|
156
|
-
* Generates a unique ID based on the device name.
|
|
157
|
-
*
|
|
158
|
-
* @param {string} deviceName - The name of the device to generate a unique ID for.
|
|
159
|
-
* @returns {string} A unique ID generated from the device name using MD5 hashing.
|
|
160
|
-
*/
|
|
161
108
|
export function generateUniqueId(deviceName) {
|
|
162
|
-
return createHash('md5').update(deviceName).digest('hex');
|
|
109
|
+
return createHash('md5').update(deviceName).digest('hex');
|
|
163
110
|
}
|
|
164
|
-
/**
|
|
165
|
-
* Generates a unique ID based on four parameters.
|
|
166
|
-
*
|
|
167
|
-
* @param {string} param1 - The first parameter.
|
|
168
|
-
* @param {string} param2 - The second parameter.
|
|
169
|
-
* @param {string} param3 - The third parameter.
|
|
170
|
-
* @param {string} param4 - The fourth parameter.
|
|
171
|
-
* @returns {string} A unique ID generated from the concatenation of the parameters using MD5 hashing.
|
|
172
|
-
*/
|
|
173
111
|
export function createUniqueId(param1, param2, param3, param4) {
|
|
174
112
|
const hash = createHash('md5');
|
|
175
113
|
hash.update(param1 + param2 + param3 + param4);
|
|
176
114
|
return hash.digest('hex');
|
|
177
115
|
}
|
|
178
|
-
/**
|
|
179
|
-
* Retrieves the features for a specific behavior.
|
|
180
|
-
*
|
|
181
|
-
* @param {Endpoint} endpoint - The endpoint to retrieve the features from.
|
|
182
|
-
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to retrieve the features for.
|
|
183
|
-
*
|
|
184
|
-
* @returns {Record<string, boolean | undefined>} The features for the specified behavior.
|
|
185
|
-
*
|
|
186
|
-
* @remarks Use with:
|
|
187
|
-
* ```typescript
|
|
188
|
-
* expect(featuresFor(device, 'powerSource').wired).toBe(true);
|
|
189
|
-
* ```
|
|
190
|
-
*/
|
|
191
116
|
export function featuresFor(endpoint, cluster) {
|
|
192
117
|
const behaviorId = getBehavior(endpoint, cluster)?.id;
|
|
193
118
|
if (!behaviorId) {
|
|
194
119
|
endpoint.log?.error(`featuresFor error: cluster not found on endpoint ${or}${endpoint.maybeId}${er}:${or}${endpoint.maybeNumber}${er}`);
|
|
195
120
|
return {};
|
|
196
121
|
}
|
|
197
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
198
122
|
return endpoint.behaviors.supported[lowercaseFirstLetter(behaviorId)]['cluster']['supportedFeatures'];
|
|
199
123
|
}
|
|
200
|
-
/**
|
|
201
|
-
* Maps a list of ClusterId to Behavior.Type for server clusters.
|
|
202
|
-
*
|
|
203
|
-
* @param {ClusterId[]} clusterServerList - The list of ClusterId to map.
|
|
204
|
-
* @returns {Behavior.Type[]} An array of Behavior.Type corresponding to the ClusterId in the server list.
|
|
205
|
-
*/
|
|
206
124
|
export function getBehaviourTypesFromClusterServerIds(clusterServerList) {
|
|
207
|
-
// Map Server ClusterId to Behavior.Type
|
|
208
125
|
const behaviorTypes = [];
|
|
209
126
|
clusterServerList.forEach((clusterId) => {
|
|
210
127
|
behaviorTypes.push(getBehaviourTypeFromClusterServerId(clusterId));
|
|
211
128
|
});
|
|
212
129
|
return behaviorTypes;
|
|
213
130
|
}
|
|
214
|
-
/**
|
|
215
|
-
* Maps a list of ClusterId to Behavior.Type for client clusters.
|
|
216
|
-
*
|
|
217
|
-
* @param {ClusterId[]} clusterClientList - The list of ClusterId to map.
|
|
218
|
-
* @returns {Behavior.Type[]} An array of Behavior.Type corresponding to the ClusterId in the client list.
|
|
219
|
-
*/
|
|
220
131
|
export function getBehaviourTypesFromClusterClientIds(clusterClientList) {
|
|
221
|
-
// Map Client ClusterId to Behavior.Type
|
|
222
132
|
const behaviorTypes = [];
|
|
223
133
|
clusterClientList.forEach((_clusterId) => {
|
|
224
|
-
// behaviorTypes.push(getBehaviourTypeFromClusterClientId(clusterId));
|
|
225
134
|
});
|
|
226
135
|
return behaviorTypes;
|
|
227
136
|
}
|
|
228
|
-
/**
|
|
229
|
-
* Maps a ClusterId to a Behavior.Type for server clusters.
|
|
230
|
-
*
|
|
231
|
-
* @param {ClusterId} clusterId - The ClusterId to map.
|
|
232
|
-
* @returns {Behavior.Type} The corresponding Behavior.Type for the given ClusterId.
|
|
233
|
-
*/
|
|
234
137
|
export function getBehaviourTypeFromClusterServerId(clusterId) {
|
|
235
|
-
// Map ClusterId to Server Behavior.Type
|
|
236
138
|
if (clusterId === PowerSource.Cluster.id)
|
|
237
139
|
return PowerSourceServer.with(PowerSource.Feature.Wired);
|
|
238
140
|
if (clusterId === UserLabel.Cluster.id)
|
|
@@ -325,22 +227,8 @@ export function getBehaviourTypeFromClusterServerId(clusterId) {
|
|
|
325
227
|
return MatterbridgeDeviceEnergyManagementModeServer;
|
|
326
228
|
return MatterbridgeIdentifyServer;
|
|
327
229
|
}
|
|
328
|
-
/**
|
|
329
|
-
* Maps a ClusterId to a Behavior.Type for client clusters.
|
|
330
|
-
*
|
|
331
|
-
* @param {ClusterId} _clusterId - The ClusterId to map.
|
|
332
|
-
*/
|
|
333
230
|
export function getBehaviourTypeFromClusterClientId(_clusterId) {
|
|
334
|
-
// Map ClusterId to Client Behavior.Type
|
|
335
|
-
// return IdentifyClient;
|
|
336
231
|
}
|
|
337
|
-
/**
|
|
338
|
-
* Retrieves the Behavior.Type for a given cluster from the endpoint's supported behaviors.
|
|
339
|
-
*
|
|
340
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to retrieve the behavior from.
|
|
341
|
-
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to retrieve the behavior for.
|
|
342
|
-
* @returns {Behavior.Type | undefined} The Behavior.Type for the given cluster, or undefined if not found.
|
|
343
|
-
*/
|
|
344
232
|
export function getBehavior(endpoint, cluster) {
|
|
345
233
|
let behavior;
|
|
346
234
|
if (typeof cluster === 'string') {
|
|
@@ -357,18 +245,6 @@ export function getBehavior(endpoint, cluster) {
|
|
|
357
245
|
}
|
|
358
246
|
return behavior;
|
|
359
247
|
}
|
|
360
|
-
/**
|
|
361
|
-
* Invokes a command on the specified behavior of the endpoint. Used ONLY in Jest tests.
|
|
362
|
-
*
|
|
363
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to invoke the command on.
|
|
364
|
-
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to invoke the command on.
|
|
365
|
-
* @param {keyof MatterbridgeEndpointCommands} command - The command to invoke.
|
|
366
|
-
* @param {Record<string, boolean | number | bigint | string | object | null>} [params] - The parameters to pass to the command.
|
|
367
|
-
*
|
|
368
|
-
* @returns {Promise<boolean>} A promise that resolves to true if the command was invoked successfully, false otherwise.
|
|
369
|
-
*
|
|
370
|
-
* @deprecated Used ONLY in Jest tests.
|
|
371
|
-
*/
|
|
372
248
|
export async function invokeBehaviorCommand(endpoint, cluster, command, params) {
|
|
373
249
|
const behaviorId = getBehavior(endpoint, cluster)?.id;
|
|
374
250
|
if (!behaviorId) {
|
|
@@ -376,7 +252,6 @@ export async function invokeBehaviorCommand(endpoint, cluster, command, params)
|
|
|
376
252
|
return false;
|
|
377
253
|
}
|
|
378
254
|
await endpoint.act((agent) => {
|
|
379
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
380
255
|
const behavior = agent[behaviorId];
|
|
381
256
|
if (!(command in behavior) || typeof behavior[command] !== 'function') {
|
|
382
257
|
endpoint.log?.error(`invokeBehaviorCommand error: command ${hk}${command}${er} not found on agent for endpoint ${or}${endpoint.maybeId}${er}:${or}${endpoint.maybeNumber}${er}`);
|
|
@@ -386,19 +261,6 @@ export async function invokeBehaviorCommand(endpoint, cluster, command, params)
|
|
|
386
261
|
});
|
|
387
262
|
return true;
|
|
388
263
|
}
|
|
389
|
-
/**
|
|
390
|
-
* Invokes the subscription handler on the specified cluster and attribute of the endpoint. Used ONLY in Jest tests.
|
|
391
|
-
*
|
|
392
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to invoke the subscription handler on.
|
|
393
|
-
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to invoke the subscription handler on.
|
|
394
|
-
* @param {string} attribute - The attribute to invoke the subscription handler on.
|
|
395
|
-
* @param {unknown} newValue - The new value of the attribute.
|
|
396
|
-
* @param {unknown} oldValue - The old value of the attribute.
|
|
397
|
-
*
|
|
398
|
-
* @returns {Promise<boolean>} A promise that resolves to true if the subscription handler was invoked successfully, false otherwise.
|
|
399
|
-
*
|
|
400
|
-
* @deprecated Used ONLY in Jest tests.
|
|
401
|
-
*/
|
|
402
264
|
export async function invokeSubscribeHandler(endpoint, cluster, attribute, newValue, oldValue) {
|
|
403
265
|
const event = attribute + '$Changed';
|
|
404
266
|
const behaviorId = getBehavior(endpoint, cluster)?.id;
|
|
@@ -415,17 +277,9 @@ export async function invokeSubscribeHandler(endpoint, cluster, attribute, newVa
|
|
|
415
277
|
endpoint.log.error(`invokeSubscribeHandler ${hk}${event}${er} error: cluster ${behaviorId} not found on endpoint ${or}${endpoint.id}${er}:${or}${endpoint.number}${er}`);
|
|
416
278
|
return false;
|
|
417
279
|
}
|
|
418
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
419
|
-
// @ts-ignore
|
|
420
280
|
await endpoint.act((agent) => agent[behaviorId].events[event].emit(newValue, oldValue, { ...agent.context, offline: false, fabric: 1 }));
|
|
421
281
|
return true;
|
|
422
282
|
}
|
|
423
|
-
/**
|
|
424
|
-
* Adds required cluster servers to the specified endpoint based on the device types.
|
|
425
|
-
*
|
|
426
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to add the required cluster servers to.
|
|
427
|
-
* @returns {void}
|
|
428
|
-
*/
|
|
429
283
|
export function addRequiredClusterServers(endpoint) {
|
|
430
284
|
const requiredServerList = [];
|
|
431
285
|
endpoint.log.debug(`addRequiredClusterServers for ${CYAN}${endpoint.maybeId}${db}`);
|
|
@@ -440,12 +294,6 @@ export function addRequiredClusterServers(endpoint) {
|
|
|
440
294
|
});
|
|
441
295
|
addClusterServers(endpoint, requiredServerList);
|
|
442
296
|
}
|
|
443
|
-
/**
|
|
444
|
-
* Adds optional cluster servers to the specified endpoint based on the device types.
|
|
445
|
-
*
|
|
446
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to add the optional cluster servers to.
|
|
447
|
-
* @returns {void}
|
|
448
|
-
*/
|
|
449
297
|
export function addOptionalClusterServers(endpoint) {
|
|
450
298
|
const optionalServerList = [];
|
|
451
299
|
endpoint.log.debug(`addOptionalClusterServers for ${CYAN}${endpoint.maybeId}${db}`);
|
|
@@ -460,12 +308,6 @@ export function addOptionalClusterServers(endpoint) {
|
|
|
460
308
|
});
|
|
461
309
|
addClusterServers(endpoint, optionalServerList);
|
|
462
310
|
}
|
|
463
|
-
/**
|
|
464
|
-
* Adds cluster servers to the specified endpoint based on the provided server list.
|
|
465
|
-
*
|
|
466
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to add the cluster servers to.
|
|
467
|
-
* @param {ClusterId[]} serverList - The list of cluster IDs to add.
|
|
468
|
-
*/
|
|
469
311
|
export function addClusterServers(endpoint, serverList) {
|
|
470
312
|
if (serverList.includes(PowerSource.Cluster.id))
|
|
471
313
|
endpoint.createDefaultPowerSourceWiredClusterServer();
|
|
@@ -548,13 +390,6 @@ export function addClusterServers(endpoint, serverList) {
|
|
|
548
390
|
if (serverList.includes(DeviceEnergyManagementMode.Cluster.id))
|
|
549
391
|
endpoint.createDefaultDeviceEnergyManagementModeClusterServer();
|
|
550
392
|
}
|
|
551
|
-
/**
|
|
552
|
-
* Adds a fixed label to the FixedLabel cluster. The FixedLabel cluster is created if it does not exist.
|
|
553
|
-
*
|
|
554
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to add the cluster servers to.
|
|
555
|
-
* @param {string} label - The label to add. Max 16 characters.
|
|
556
|
-
* @param {string} value - The value of the label. Max 16 characters.
|
|
557
|
-
*/
|
|
558
393
|
export async function addFixedLabel(endpoint, label, value) {
|
|
559
394
|
if (!endpoint.hasClusterServer(FixedLabel.Cluster.id)) {
|
|
560
395
|
endpoint.log.debug(`addFixedLabel: add cluster ${hk}FixedLabel${db}:${hk}fixedLabel${db} with label ${CYAN}${label}${db} value ${CYAN}${value}${db}`);
|
|
@@ -571,13 +406,6 @@ export async function addFixedLabel(endpoint, label, value) {
|
|
|
571
406
|
await endpoint.setAttribute(FixedLabel.Cluster.id, 'labelList', labelList, endpoint.log);
|
|
572
407
|
}
|
|
573
408
|
}
|
|
574
|
-
/**
|
|
575
|
-
* Adds a user label to the UserLabel cluster. The UserLabel cluster is created if it does not exist.
|
|
576
|
-
*
|
|
577
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to add the cluster servers to.
|
|
578
|
-
* @param {string} label - The label to add. Max 16 characters.
|
|
579
|
-
* @param {string} value - The value of the label. Max 16 characters.
|
|
580
|
-
*/
|
|
581
409
|
export async function addUserLabel(endpoint, label, value) {
|
|
582
410
|
if (!endpoint.hasClusterServer(UserLabel.Cluster.id)) {
|
|
583
411
|
endpoint.log.debug(`addUserLabel: add cluster ${hk}UserLabel${db}:${hk}userLabel${db} with label ${CYAN}${label}${db} value ${CYAN}${value}${db}`);
|
|
@@ -594,48 +422,16 @@ export async function addUserLabel(endpoint, label, value) {
|
|
|
594
422
|
await endpoint.setAttribute(UserLabel.Cluster.id, 'labelList', labelList, endpoint.log);
|
|
595
423
|
}
|
|
596
424
|
}
|
|
597
|
-
/**
|
|
598
|
-
* Returns the options for a given behavior type.
|
|
599
|
-
*
|
|
600
|
-
* @param {T} type - The behavior type.
|
|
601
|
-
* @param {Behavior.Options<T>} options - The options for the behavior type.
|
|
602
|
-
* @returns {Behavior.Options<T>} The options for the behavior type.
|
|
603
|
-
*/
|
|
604
425
|
export function optionsFor(type, options) {
|
|
605
426
|
return options;
|
|
606
427
|
}
|
|
607
|
-
/**
|
|
608
|
-
* Retrieves the cluster ID.
|
|
609
|
-
*
|
|
610
|
-
* @param {Endpoint} endpoint - The endpoint to retrieve the cluster ID from.
|
|
611
|
-
* @param {ClusterId} cluster - The ID of the cluster.
|
|
612
|
-
* @returns {number | undefined} The ID of the cluster.
|
|
613
|
-
*/
|
|
614
428
|
export function getClusterId(endpoint, cluster) {
|
|
615
429
|
return endpoint.behaviors.supported[lowercaseFirstLetter(cluster)]?.schema?.id;
|
|
616
430
|
}
|
|
617
|
-
/**
|
|
618
|
-
* Retrieves the ID of an attribute from a cluster behavior.
|
|
619
|
-
*
|
|
620
|
-
* @param {Endpoint} endpoint - The endpoint to retrieve the attribute ID from.
|
|
621
|
-
* @param {string} cluster - The name of the cluster.
|
|
622
|
-
* @param {string} attribute - The name of the attribute.
|
|
623
|
-
* @returns {number | undefined} The ID of the attribute, or undefined if not found.
|
|
624
|
-
*/
|
|
625
431
|
export function getAttributeId(endpoint, cluster, attribute) {
|
|
626
432
|
const clusterBehavior = endpoint.behaviors.supported[lowercaseFirstLetter(cluster)];
|
|
627
433
|
return clusterBehavior?.cluster?.attributes[lowercaseFirstLetter(attribute)]?.id;
|
|
628
434
|
}
|
|
629
|
-
/**
|
|
630
|
-
* Retrieves the value of the provided attribute from the given cluster.
|
|
631
|
-
*
|
|
632
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to retrieve the attribute from.
|
|
633
|
-
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to retrieve the attribute from.
|
|
634
|
-
* @param {string} attribute - The name of the attribute to retrieve.
|
|
635
|
-
* @param {AnsiLogger} [log] - (Optional) The logger to use for logging the retrieve. Errors are logged to the endpoint logger.
|
|
636
|
-
* @returns {any} The value of the attribute, or undefined if the attribute is not found.
|
|
637
|
-
*/
|
|
638
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
639
435
|
export function getAttribute(endpoint, cluster, attribute, log) {
|
|
640
436
|
const clusterName = getBehavior(endpoint, cluster)?.id;
|
|
641
437
|
if (!clusterName) {
|
|
@@ -658,16 +454,6 @@ export function getAttribute(endpoint, cluster, attribute, log) {
|
|
|
658
454
|
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}`);
|
|
659
455
|
return value;
|
|
660
456
|
}
|
|
661
|
-
/**
|
|
662
|
-
* Sets the value of an attribute on a cluster server.
|
|
663
|
-
*
|
|
664
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to set the attribute on.
|
|
665
|
-
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to set the attribute on.
|
|
666
|
-
* @param {string} attribute - The name of the attribute.
|
|
667
|
-
* @param {boolean | number | bigint | string | object | null} value - The value to set for the attribute.
|
|
668
|
-
* @param {AnsiLogger} [log] - (Optional) The logger to use for logging the set. Errors are logged to the endpoint logger.
|
|
669
|
-
* @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the attribute was successfully set.
|
|
670
|
-
*/
|
|
671
457
|
export async function setAttribute(endpoint, cluster, attribute, value, log) {
|
|
672
458
|
const clusterName = getBehavior(endpoint, cluster)?.id;
|
|
673
459
|
if (!clusterName) {
|
|
@@ -693,16 +479,6 @@ export async function setAttribute(endpoint, cluster, attribute, value, log) {
|
|
|
693
479
|
`to ${YELLOW}${value !== null && typeof value === 'object' ? debugStringify(value) : value}${db}`);
|
|
694
480
|
return true;
|
|
695
481
|
}
|
|
696
|
-
/**
|
|
697
|
-
* Sets the value of an attribute on a cluster server.
|
|
698
|
-
*
|
|
699
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to update the attribute on.
|
|
700
|
-
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to update the attribute on.
|
|
701
|
-
* @param {string} attribute - The name of the attribute.
|
|
702
|
-
* @param {boolean | number | bigint | string | object | null} value - The value to set for the attribute.
|
|
703
|
-
* @param {AnsiLogger} [log] - (Optional) The logger to use for logging the update. Errors are logged to the endpoint logger.
|
|
704
|
-
* @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the attribute was successfully set.
|
|
705
|
-
*/
|
|
706
482
|
export async function updateAttribute(endpoint, cluster, attribute, value, log) {
|
|
707
483
|
const clusterName = getBehavior(endpoint, cluster)?.id;
|
|
708
484
|
if (!clusterName) {
|
|
@@ -733,24 +509,7 @@ export async function updateAttribute(endpoint, cluster, attribute, value, log)
|
|
|
733
509
|
`to ${YELLOW}${value !== null && typeof value === 'object' ? debugStringify(value) : value}${db}`);
|
|
734
510
|
return true;
|
|
735
511
|
}
|
|
736
|
-
|
|
737
|
-
* Subscribes to the provided attribute on a cluster.
|
|
738
|
-
*
|
|
739
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to subscribe the attribute to.
|
|
740
|
-
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to subscribe the attribute to.
|
|
741
|
-
* @param {string} attribute - The name of the attribute to subscribe to.
|
|
742
|
-
* @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.
|
|
743
|
-
* @param {AnsiLogger} [log] - Optional logger for logging errors and information.
|
|
744
|
-
* @returns {boolean} - A boolean indicating whether the subscription was successful.
|
|
745
|
-
*
|
|
746
|
-
* @remarks The listener function (cannot be async) will receive three parameters:
|
|
747
|
-
* - `newValue`: The new value of the attribute.
|
|
748
|
-
* - `oldValue`: The old value of the attribute.
|
|
749
|
-
* - `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.
|
|
750
|
-
*/
|
|
751
|
-
export async function subscribeAttribute(endpoint, cluster, attribute,
|
|
752
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
753
|
-
listener, log) {
|
|
512
|
+
export async function subscribeAttribute(endpoint, cluster, attribute, listener, log) {
|
|
754
513
|
const clusterName = getBehavior(endpoint, cluster)?.id;
|
|
755
514
|
if (!clusterName) {
|
|
756
515
|
endpoint.log.error(`subscribeAttribute ${hk}${attribute}${er} error: cluster not found on endpoint ${or}${endpoint.maybeId}${er}:${or}${endpoint.maybeNumber}${er}`);
|
|
@@ -760,7 +519,6 @@ listener, log) {
|
|
|
760
519
|
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`);
|
|
761
520
|
await endpoint.construction.ready;
|
|
762
521
|
}
|
|
763
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
764
522
|
const events = endpoint.events;
|
|
765
523
|
attribute = lowercaseFirstLetter(attribute) + '$Changed';
|
|
766
524
|
if (!(clusterName in events) || !(attribute in events[clusterName])) {
|
|
@@ -771,17 +529,6 @@ listener, log) {
|
|
|
771
529
|
log?.info(`${db}Subscribed endpoint ${or}${endpoint.id}${db}:${or}${endpoint.number}${db} attribute ${hk}${capitalizeFirstLetter(clusterName)}${db}.${hk}${attribute}${db}`);
|
|
772
530
|
return true;
|
|
773
531
|
}
|
|
774
|
-
/**
|
|
775
|
-
* Triggers an event on the specified cluster.
|
|
776
|
-
*
|
|
777
|
-
* @param {MatterbridgeEndpoint} endpoint - The endpoint to trigger the event on.
|
|
778
|
-
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The ID of the cluster.
|
|
779
|
-
* @param {string} event - The name of the event to trigger.
|
|
780
|
-
* @param {Record<string, boolean | number | bigint | string | object | undefined | null>} payload - The payload to pass to the event.
|
|
781
|
-
* @param {AnsiLogger} [log] - Optional logger for logging information.
|
|
782
|
-
*
|
|
783
|
-
* @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the event was successfully triggered.
|
|
784
|
-
*/
|
|
785
532
|
export async function triggerEvent(endpoint, cluster, event, payload, log) {
|
|
786
533
|
const clusterName = getBehavior(endpoint, cluster)?.id;
|
|
787
534
|
if (!clusterName) {
|
|
@@ -792,63 +539,30 @@ export async function triggerEvent(endpoint, cluster, event, payload, log) {
|
|
|
792
539
|
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`);
|
|
793
540
|
return false;
|
|
794
541
|
}
|
|
795
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
796
542
|
const events = endpoint.events;
|
|
797
543
|
if (!(clusterName in events) || !(event in events[clusterName])) {
|
|
798
544
|
endpoint.log.error(`triggerEvent ${hk}${event}${er} error: cluster ${clusterName} not found on endpoint ${or}${endpoint.id}${er}:${or}${endpoint.number}${er}`);
|
|
799
545
|
return false;
|
|
800
546
|
}
|
|
801
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
802
|
-
// @ts-ignore
|
|
803
547
|
await endpoint.act((agent) => agent[clusterName].events[event].emit(payload, agent.context));
|
|
804
548
|
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} `);
|
|
805
549
|
return true;
|
|
806
550
|
}
|
|
807
|
-
/** Utility Cluster Helpers */
|
|
808
|
-
/**
|
|
809
|
-
* Get the default power source wired cluster server options.
|
|
810
|
-
*
|
|
811
|
-
* @param {PowerSource.WiredCurrentType} wiredCurrentType - The type of wired current (default: PowerSource.WiredCurrentType.Ac)
|
|
812
|
-
* @returns {Behavior.Options<PowerSourceClusterServer>} The options for the power source wired cluster server.
|
|
813
|
-
*
|
|
814
|
-
* @remarks
|
|
815
|
-
* - order: The order of the power source is a persisted attribute that indicates the order in which the power sources are used.
|
|
816
|
-
* - description: The description of the power source is a fixed attribute that describes the power source type.
|
|
817
|
-
* - wiredCurrentType: The type of wired current is a fixed attribute that indicates the type of wired current used by the power source (AC or DC).
|
|
818
|
-
*/
|
|
819
551
|
export function getDefaultPowerSourceWiredClusterServer(wiredCurrentType = PowerSource.WiredCurrentType.Ac) {
|
|
820
552
|
return optionsFor(MatterbridgePowerSourceServer.with(PowerSource.Feature.Wired), {
|
|
821
|
-
// Base attributes
|
|
822
553
|
status: PowerSource.PowerSourceStatus.Active,
|
|
823
554
|
order: 0,
|
|
824
555
|
description: wiredCurrentType === PowerSource.WiredCurrentType.Ac ? 'AC Power' : 'DC Power',
|
|
825
|
-
endpointList: [],
|
|
826
|
-
// Wired feature attributes
|
|
556
|
+
endpointList: [],
|
|
827
557
|
wiredCurrentType,
|
|
828
558
|
});
|
|
829
559
|
}
|
|
830
|
-
/**
|
|
831
|
-
* Get the default power source battery cluster server options.
|
|
832
|
-
*
|
|
833
|
-
* @param {null | number} batPercentRemaining - The remaining battery percentage (default: null). The attribute is in the range 0-200.
|
|
834
|
-
* @param {PowerSource.BatChargeLevel} batChargeLevel - The battery charge level (default: PowerSource.BatChargeLevel.Ok).
|
|
835
|
-
* @param {null | number} batVoltage - The battery voltage (default: null).
|
|
836
|
-
* @param {PowerSource.BatReplaceability} batReplaceability - The replaceability of the battery (default: PowerSource.BatReplaceability.Unspecified).
|
|
837
|
-
* @returns {Behavior.Options<PowerSourceClusterServer>} The options for the power source replaceable battery cluster server.
|
|
838
|
-
*
|
|
839
|
-
* @remarks
|
|
840
|
-
* - order: The order of the power source is a persisted attribute that indicates the order in which the power sources are used.
|
|
841
|
-
* - description: The description of the power source is a fixed attribute that describes the power source type.
|
|
842
|
-
* - batReplaceability: The replaceability of the battery is a fixed attribute that indicates whether the battery is user-replaceable or not.
|
|
843
|
-
*/
|
|
844
560
|
export function getDefaultPowerSourceBatteryClusterServer(batPercentRemaining = null, batChargeLevel = PowerSource.BatChargeLevel.Ok, batVoltage = null, batReplaceability = PowerSource.BatReplaceability.Unspecified) {
|
|
845
561
|
return optionsFor(MatterbridgePowerSourceServer.with(PowerSource.Feature.Battery), {
|
|
846
|
-
// Base attributes
|
|
847
562
|
status: PowerSource.PowerSourceStatus.Active,
|
|
848
563
|
order: 0,
|
|
849
564
|
description: 'Primary battery',
|
|
850
|
-
endpointList: [],
|
|
851
|
-
// Battery feature attributes
|
|
565
|
+
endpointList: [],
|
|
852
566
|
batVoltage,
|
|
853
567
|
batPercentRemaining: batPercentRemaining !== null ? Math.min(Math.max(batPercentRemaining * 2, 0), 200) : null,
|
|
854
568
|
batChargeLevel,
|
|
@@ -856,85 +570,40 @@ export function getDefaultPowerSourceBatteryClusterServer(batPercentRemaining =
|
|
|
856
570
|
batReplaceability,
|
|
857
571
|
});
|
|
858
572
|
}
|
|
859
|
-
/**
|
|
860
|
-
* Get the default power source replaceable battery cluster server options.
|
|
861
|
-
*
|
|
862
|
-
* @param {number} batPercentRemaining - The remaining battery percentage (default: 100). The attribute is in the range 0-200.
|
|
863
|
-
* @param {PowerSource.BatChargeLevel} batChargeLevel - The battery charge level (default: PowerSource.BatChargeLevel.Ok).
|
|
864
|
-
* @param {number} batVoltage - The battery voltage (default: 1500).
|
|
865
|
-
* @param {string} batReplacementDescription - The description of the battery replacement (default: 'Battery type').
|
|
866
|
-
* @param {number} batQuantity - The quantity of the battery (default: 1).
|
|
867
|
-
* @param {PowerSource.BatReplaceability} batReplaceability - The replaceability of the battery (default: PowerSource.BatReplaceability.UserReplaceable).
|
|
868
|
-
* @returns {Behavior.Options<PowerSourceClusterServer>} The options for the power source replaceable battery cluster server.
|
|
869
|
-
*
|
|
870
|
-
* @remarks
|
|
871
|
-
* - order: The order of the power source is a persisted attribute that indicates the order in which the power sources are used.
|
|
872
|
-
* - description: The description of the power source is a fixed attribute that describes the power source type.
|
|
873
|
-
* - batReplaceability: The replaceability of the battery is a fixed attribute that indicates whether the battery is user-replaceable or not.
|
|
874
|
-
* - batReplacementDescription: The description of the battery replacement is a fixed attribute that describes the battery type.
|
|
875
|
-
* - batQuantity: The quantity of the battery is a fixed attribute that indicates how many batteries are present in the device.
|
|
876
|
-
*/
|
|
877
573
|
export function getDefaultPowerSourceReplaceableBatteryClusterServer(batPercentRemaining = 100, batChargeLevel = PowerSource.BatChargeLevel.Ok, batVoltage = 1500, batReplacementDescription = 'Battery type', batQuantity = 1, batReplaceability = PowerSource.BatReplaceability.UserReplaceable) {
|
|
878
574
|
return optionsFor(MatterbridgePowerSourceServer.with(PowerSource.Feature.Battery, PowerSource.Feature.Replaceable), {
|
|
879
|
-
// Base attributes
|
|
880
575
|
status: PowerSource.PowerSourceStatus.Active,
|
|
881
576
|
order: 0,
|
|
882
577
|
description: 'Primary battery',
|
|
883
|
-
endpointList: [],
|
|
884
|
-
// Battery feature attributes
|
|
578
|
+
endpointList: [],
|
|
885
579
|
batVoltage,
|
|
886
580
|
batPercentRemaining: Math.min(Math.max(batPercentRemaining * 2, 0), 200),
|
|
887
581
|
batChargeLevel,
|
|
888
582
|
batReplacementNeeded: false,
|
|
889
583
|
batReplaceability,
|
|
890
584
|
activeBatFaults: undefined,
|
|
891
|
-
// Replaceable feature attributes
|
|
892
585
|
batReplacementDescription,
|
|
893
586
|
batQuantity,
|
|
894
587
|
});
|
|
895
588
|
}
|
|
896
|
-
/**
|
|
897
|
-
* Creates a default power source rechargeable battery cluster server.
|
|
898
|
-
*
|
|
899
|
-
* @param {number} [batPercentRemaining] - The remaining battery percentage (default: 100). The attribute is in the range 0-200.
|
|
900
|
-
* @param {PowerSource.BatChargeLevel} [batChargeLevel] - The battery charge level (default: PowerSource.BatChargeLevel.Ok).
|
|
901
|
-
* @param {number} [batVoltage] - The battery voltage in mV (default: 1500).
|
|
902
|
-
* @param {PowerSource.BatReplaceability} [batReplaceability] - The replaceability of the battery (default: PowerSource.BatReplaceability.Unspecified).
|
|
903
|
-
* @returns {Behavior.Options<PowerSourceClusterServer>} The options for the power source rechargeable battery cluster server.
|
|
904
|
-
*
|
|
905
|
-
* @remarks
|
|
906
|
-
* - order: The order of the power source is a persisted attribute that indicates the order in which the power sources are used.
|
|
907
|
-
* - description: The description of the power source is a fixed attribute that describes the power source type.
|
|
908
|
-
* - batReplaceability: The replaceability of the battery is a fixed attribute that indicates whether the battery is user-replaceable or not.
|
|
909
|
-
*/
|
|
910
589
|
export function getDefaultPowerSourceRechargeableBatteryClusterServer(batPercentRemaining = 100, batChargeLevel = PowerSource.BatChargeLevel.Ok, batVoltage = 1500, batReplaceability = PowerSource.BatReplaceability.Unspecified) {
|
|
911
590
|
return optionsFor(MatterbridgePowerSourceServer.with(PowerSource.Feature.Battery, PowerSource.Feature.Rechargeable), {
|
|
912
|
-
// Base attributes
|
|
913
591
|
status: PowerSource.PowerSourceStatus.Active,
|
|
914
592
|
order: 0,
|
|
915
593
|
description: 'Primary battery',
|
|
916
|
-
endpointList: [],
|
|
917
|
-
// Battery feature attributes
|
|
594
|
+
endpointList: [],
|
|
918
595
|
batVoltage,
|
|
919
596
|
batPercentRemaining: Math.min(Math.max(batPercentRemaining * 2, 0), 200),
|
|
920
|
-
batTimeRemaining: null,
|
|
597
|
+
batTimeRemaining: null,
|
|
921
598
|
batChargeLevel,
|
|
922
599
|
batReplacementNeeded: false,
|
|
923
600
|
batReplaceability,
|
|
924
601
|
batPresent: true,
|
|
925
602
|
activeBatFaults: [],
|
|
926
|
-
// Rechargeable feature attributes
|
|
927
603
|
batChargeState: PowerSource.BatChargeState.IsNotCharging,
|
|
928
604
|
batFunctionalWhileCharging: true,
|
|
929
605
|
});
|
|
930
606
|
}
|
|
931
|
-
/**
|
|
932
|
-
* Get the default Electrical Energy Measurement Cluster Server options with features ImportedEnergy, ExportedEnergy, and CumulativeEnergy.
|
|
933
|
-
*
|
|
934
|
-
* @param {number} energyImported - The total consumption value in mW/h.
|
|
935
|
-
* @param {number} energyExported - The total production value in mW/h.
|
|
936
|
-
* @returns {Behavior.Options<ElectricalEnergyMeasurementServer>} - The default options for the Electrical Energy Measurement Cluster Server.
|
|
937
|
-
*/
|
|
938
607
|
export function getDefaultElectricalEnergyMeasurementClusterServer(energyImported = null, energyExported = null) {
|
|
939
608
|
return optionsFor(ElectricalEnergyMeasurementServer.with(ElectricalEnergyMeasurement.Feature.ImportedEnergy, ElectricalEnergyMeasurement.Feature.ExportedEnergy, ElectricalEnergyMeasurement.Feature.CumulativeEnergy), {
|
|
940
609
|
accuracy: {
|
|
@@ -949,15 +618,6 @@ export function getDefaultElectricalEnergyMeasurementClusterServer(energyImporte
|
|
|
949
618
|
cumulativeEnergyExported: energyExported !== null && energyExported >= 0 ? { energy: energyExported } : null,
|
|
950
619
|
});
|
|
951
620
|
}
|
|
952
|
-
/**
|
|
953
|
-
* Get the default Electrical Power Measurement Cluster Server options with features AlternatingCurrent.
|
|
954
|
-
*
|
|
955
|
-
* @param {number} voltage - The voltage value in millivolts.
|
|
956
|
-
* @param {number} current - The current value in milliamperes.
|
|
957
|
-
* @param {number} power - The power value in milliwatts.
|
|
958
|
-
* @param {number} frequency - The frequency value in millihertz.
|
|
959
|
-
* @returns {Behavior.Options<ElectricalPowerMeasurementServer>} - The default options for the Electrical Power Measurement Cluster Server.
|
|
960
|
-
*/
|
|
961
621
|
export function getDefaultElectricalPowerMeasurementClusterServer(voltage = null, current = null, power = null, frequency = null) {
|
|
962
622
|
return optionsFor(ElectricalPowerMeasurementServer.with(ElectricalPowerMeasurement.Feature.AlternatingCurrent), {
|
|
963
623
|
powerMode: ElectricalPowerMeasurement.PowerMode.Ac,
|
|
@@ -998,15 +658,6 @@ export function getDefaultElectricalPowerMeasurementClusterServer(voltage = null
|
|
|
998
658
|
frequency: frequency,
|
|
999
659
|
});
|
|
1000
660
|
}
|
|
1001
|
-
/**
|
|
1002
|
-
* Get the default Electrical Apparent Power Measurement Cluster Server with features AlternatingCurrent.
|
|
1003
|
-
*
|
|
1004
|
-
* @param {number} voltage - The voltage value in millivolts.
|
|
1005
|
-
* @param {number} apparentCurrent - The current value in milliamperes.
|
|
1006
|
-
* @param {number} apparentPower - The apparent power value in millivoltamperes.
|
|
1007
|
-
* @param {number} frequency - The frequency value in millihertz.
|
|
1008
|
-
* @returns {Behavior.Options<ElectricalPowerMeasurementServer>} - The default options for the Electrical Apparent Power Measurement Cluster Server.
|
|
1009
|
-
*/
|
|
1010
661
|
export function getApparentElectricalPowerMeasurementClusterServer(voltage = null, apparentCurrent = null, apparentPower = null, frequency = null) {
|
|
1011
662
|
return optionsFor(ElectricalPowerMeasurementServer.with(ElectricalPowerMeasurement.Feature.AlternatingCurrent), {
|
|
1012
663
|
powerMode: ElectricalPowerMeasurement.PowerMode.Ac,
|
|
@@ -1047,55 +698,19 @@ export function getApparentElectricalPowerMeasurementClusterServer(voltage = nul
|
|
|
1047
698
|
frequency: frequency,
|
|
1048
699
|
});
|
|
1049
700
|
}
|
|
1050
|
-
/**
|
|
1051
|
-
* Get the default Device Energy Management Cluster Server with feature PowerForecastReporting and with the specified ESA type, ESA canGenerate, ESA state, and power limits.
|
|
1052
|
-
*
|
|
1053
|
-
* @param {DeviceEnergyManagement.EsaType} [esaType] - The ESA type. Defaults to `DeviceEnergyManagement.EsaType.Other`.
|
|
1054
|
-
* @param {boolean} [esaCanGenerate] - Indicates if the ESA can generate energy. Defaults to `false`.
|
|
1055
|
-
* @param {DeviceEnergyManagement.EsaState} [esaState] - The ESA state. Defaults to `DeviceEnergyManagement.EsaState.Online`.
|
|
1056
|
-
* @param {number} [absMinPower] - Indicate the minimum electrical power in mw that the ESA can consume when switched on. Defaults to `0` if not provided.
|
|
1057
|
-
* @param {number} [absMaxPower] - Indicate the maximum electrical power in mw that the ESA can consume when switched on. Defaults to `0` if not provided.
|
|
1058
|
-
* @returns {Behavior.Options<DeviceEnergyManagementClusterServer>} - The default options for the Device Energy Management Cluster Server.
|
|
1059
|
-
*
|
|
1060
|
-
* @remarks
|
|
1061
|
-
* - The forecast attribute is set to null, indicating that there is no forecast currently available.
|
|
1062
|
-
* - The ESA type and canGenerate attributes are fixed and cannot be changed after creation.
|
|
1063
|
-
* - The ESA state is set to Online by default.
|
|
1064
|
-
* - The absolute minimum and maximum power attributes are set to 0 by default.
|
|
1065
|
-
* - For example, a battery storage inverter that can charge its battery at a maximum power of 2000W and can
|
|
1066
|
-
* discharge the battery at a maximum power of 3000W, would have a absMinPower: -3000W, absMaxPower: 2000W.
|
|
1067
|
-
*/
|
|
1068
701
|
export function getDefaultDeviceEnergyManagementClusterServer(esaType = DeviceEnergyManagement.EsaType.Other, esaCanGenerate = false, esaState = DeviceEnergyManagement.EsaState.Online, absMinPower = 0, absMaxPower = 0) {
|
|
1069
702
|
return optionsFor(MatterbridgeDeviceEnergyManagementServer.with(DeviceEnergyManagement.Feature.PowerForecastReporting, DeviceEnergyManagement.Feature.PowerAdjustment), {
|
|
1070
|
-
esaType,
|
|
1071
|
-
esaCanGenerate,
|
|
703
|
+
esaType,
|
|
704
|
+
esaCanGenerate,
|
|
1072
705
|
esaState,
|
|
1073
706
|
absMinPower,
|
|
1074
707
|
absMaxPower,
|
|
1075
|
-
|
|
1076
|
-
powerAdjustmentCapability: null, // A null value indicates that no power adjustment is currently possible, and nor is any adjustment currently active
|
|
708
|
+
powerAdjustmentCapability: null,
|
|
1077
709
|
optOutState: DeviceEnergyManagement.OptOutState.NoOptOut,
|
|
1078
|
-
|
|
1079
|
-
forecast: null, // A null value indicates that there is no forecast currently available
|
|
710
|
+
forecast: null,
|
|
1080
711
|
});
|
|
1081
712
|
}
|
|
1082
|
-
/**
|
|
1083
|
-
* Get the default EnergyManagementMode Cluster Server.
|
|
1084
|
-
*
|
|
1085
|
-
* @param {number} [currentMode] - The current mode of the EnergyManagementMode cluster. Defaults to mode 1 (DeviceEnergyManagementMode.ModeTag.NoOptimization).
|
|
1086
|
-
* @param {EnergyManagementMode.ModeOption[]} [supportedModes] - The supported modes for the DeviceEnergyManagementMode cluster. The attribute is fixed and defaults to a predefined set of cluster modes.
|
|
1087
|
-
* @returns {Behavior.Options<DeviceEnergyManagementModeClusterServer>} - The default options for the Device Energy Management Mode cluster server.
|
|
1088
|
-
*
|
|
1089
|
-
* @remarks
|
|
1090
|
-
* A few examples of Device Energy Management modes and their mode tags are provided below.
|
|
1091
|
-
* - For the "No Energy Management (Forecast reporting only)" mode, tags: 0x4000 (NoOptimization).
|
|
1092
|
-
* - For the "Device Energy Management" mode, tags: 0x4001 (DeviceOptimization).
|
|
1093
|
-
* - For the "Home Energy Management" mode, tags: 0x4001 (DeviceOptimization), 0x4002 (LocalOptimization).
|
|
1094
|
-
* - For the "Grid Energy Management" mode, tags: 0x4003 (GridOptimization).
|
|
1095
|
-
* - For the "Full Energy Management" mode, tags: 0x4001 (DeviceOptimization), 0x4002 (LocalOptimization), 0x4003 (GridOptimization).
|
|
1096
|
-
*/
|
|
1097
713
|
export function getDefaultDeviceEnergyManagementModeClusterServer(currentMode, supportedModes) {
|
|
1098
|
-
// TODO: matter.js 0.16.0 needs a with() method
|
|
1099
714
|
return optionsFor(MatterbridgeDeviceEnergyManagementModeServer.with(), {
|
|
1100
715
|
supportedModes: supportedModes ?? [
|
|
1101
716
|
{ label: 'No Energy Management (Forecast reporting only)', mode: 1, modeTags: [{ value: DeviceEnergyManagementMode.ModeTag.NoOptimization }] },
|
|
@@ -1115,26 +730,11 @@ export function getDefaultDeviceEnergyManagementModeClusterServer(currentMode, s
|
|
|
1115
730
|
mode: 5,
|
|
1116
731
|
modeTags: [{ value: DeviceEnergyManagementMode.ModeTag.DeviceOptimization }, { value: DeviceEnergyManagementMode.ModeTag.LocalOptimization }, { value: DeviceEnergyManagementMode.ModeTag.GridOptimization }],
|
|
1117
732
|
},
|
|
1118
|
-
],
|
|
733
|
+
],
|
|
1119
734
|
currentMode: currentMode ?? 1,
|
|
1120
735
|
});
|
|
1121
736
|
}
|
|
1122
|
-
/** Application Cluster Helpers */
|
|
1123
|
-
/**
|
|
1124
|
-
* Get the default OperationalState Cluster Server.
|
|
1125
|
-
*
|
|
1126
|
-
* @param {OperationalState.OperationalStateEnum} operationalState - The initial operational state id.
|
|
1127
|
-
* @returns {Behavior.Options<MatterbridgeOperationalStateServer>} - The default options for the OperationalState cluster server.
|
|
1128
|
-
*
|
|
1129
|
-
* @remarks
|
|
1130
|
-
* This method adds a cluster server with a default operational state configuration:
|
|
1131
|
-
* - { operationalStateId: OperationalState.OperationalStateEnum.Stopped, operationalStateLabel: 'Stopped' },
|
|
1132
|
-
* - { operationalStateId: OperationalState.OperationalStateEnum.Running, operationalStateLabel: 'Running' },
|
|
1133
|
-
* - { operationalStateId: OperationalState.OperationalStateEnum.Paused, operationalStateLabel: 'Paused' },
|
|
1134
|
-
* - { operationalStateId: OperationalState.OperationalStateEnum.Error, operationalStateLabel: 'Error' },
|
|
1135
|
-
*/
|
|
1136
737
|
export function getDefaultOperationalStateClusterServer(operationalState = OperationalState.OperationalStateEnum.Stopped) {
|
|
1137
|
-
// TODO: matter.js 0.16.0 needs a with() method
|
|
1138
738
|
return optionsFor(MatterbridgeOperationalStateServer.with(), {
|
|
1139
739
|
phaseList: [],
|
|
1140
740
|
currentPhase: null,
|
|
@@ -1149,14 +749,6 @@ export function getDefaultOperationalStateClusterServer(operationalState = Opera
|
|
|
1149
749
|
operationalError: { errorStateId: OperationalState.ErrorState.NoError, errorStateDetails: 'Fully operational' },
|
|
1150
750
|
});
|
|
1151
751
|
}
|
|
1152
|
-
/**
|
|
1153
|
-
* Get the default TemperatureMeasurement cluster server options.
|
|
1154
|
-
*
|
|
1155
|
-
* @param {number | null} measuredValue - The measured value of the temperature x 100.
|
|
1156
|
-
* @param {number | null} minMeasuredValue - The minimum measured value of the temperature x 100.
|
|
1157
|
-
* @param {number | null} maxMeasuredValue - The maximum measured value of the temperature x 100.
|
|
1158
|
-
* @returns {Behavior.Options<MatterbridgeTemperatureMeasurementServer>} - The default options for the TemperatureMeasurement cluster server.
|
|
1159
|
-
*/
|
|
1160
752
|
export function getDefaultTemperatureMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
1161
753
|
return optionsFor(TemperatureMeasurementServer, {
|
|
1162
754
|
measuredValue,
|
|
@@ -1165,14 +757,6 @@ export function getDefaultTemperatureMeasurementClusterServer(measuredValue = nu
|
|
|
1165
757
|
tolerance: 0,
|
|
1166
758
|
});
|
|
1167
759
|
}
|
|
1168
|
-
/**
|
|
1169
|
-
* Get the default RelativeHumidityMeasurement cluster server options.
|
|
1170
|
-
*
|
|
1171
|
-
* @param {number | null} measuredValue - The measured value of the relative humidity x 100.
|
|
1172
|
-
* @param {number | null} minMeasuredValue - The minimum measured value of the relative humidity x 100.
|
|
1173
|
-
* @param {number | null} maxMeasuredValue - The maximum measured value of the relative humidity x 100.
|
|
1174
|
-
* @returns {Behavior.Options<MatterbridgeRelativeHumidityMeasurementServer>} - The default options for the RelativeHumidityMeasurement cluster server.
|
|
1175
|
-
*/
|
|
1176
760
|
export function getDefaultRelativeHumidityMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
1177
761
|
return optionsFor(RelativeHumidityMeasurementServer, {
|
|
1178
762
|
measuredValue,
|
|
@@ -1181,14 +765,6 @@ export function getDefaultRelativeHumidityMeasurementClusterServer(measuredValue
|
|
|
1181
765
|
tolerance: 0,
|
|
1182
766
|
});
|
|
1183
767
|
}
|
|
1184
|
-
/**
|
|
1185
|
-
* Get the default PressureMeasurement cluster server options.
|
|
1186
|
-
*
|
|
1187
|
-
* @param {number | null} measuredValue - The measured value for the pressure in kPa x 10.
|
|
1188
|
-
* @param {number | null} minMeasuredValue - The minimum measured value for the pressure in kPa x 10.
|
|
1189
|
-
* @param {number | null} maxMeasuredValue - The maximum measured value for the pressure in kPa x 10.
|
|
1190
|
-
* @returns {Behavior.Options<MatterbridgePressureMeasurementServer>} - The default options for the PressureMeasurement cluster server.
|
|
1191
|
-
*/
|
|
1192
768
|
export function getDefaultPressureMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
1193
769
|
return optionsFor(PressureMeasurementServer, {
|
|
1194
770
|
measuredValue,
|
|
@@ -1197,21 +773,6 @@ export function getDefaultPressureMeasurementClusterServer(measuredValue = null,
|
|
|
1197
773
|
tolerance: 0,
|
|
1198
774
|
});
|
|
1199
775
|
}
|
|
1200
|
-
/**
|
|
1201
|
-
* Get the default IlluminanceMeasurement cluster server options.
|
|
1202
|
-
*
|
|
1203
|
-
* @param {number | null} measuredValue - The measured value of illuminance.
|
|
1204
|
-
* @param {number | null} minMeasuredValue - The minimum measured value of illuminance.
|
|
1205
|
-
* @param {number | null} maxMeasuredValue - The maximum measured value of illuminance.
|
|
1206
|
-
* @returns {Behavior.Options<MatterbridgeIlluminanceMeasurementServer>} - The default options for the IlluminanceMeasurement cluster server.
|
|
1207
|
-
*
|
|
1208
|
-
* @remarks The default value for the illuminance measurement is null.
|
|
1209
|
-
* This attribute SHALL indicate the illuminance in Lux (symbol lx) as follows:
|
|
1210
|
-
* • MeasuredValue = 10,000 x log10(illuminance) + 1,
|
|
1211
|
-
* where 1 lx <= illuminance <= 3.576 Mlx, corresponding to a MeasuredValue in the range 1 to 0xFFFE.
|
|
1212
|
-
* • 0 indicates a value of illuminance that is too low to be measured
|
|
1213
|
-
* • null indicates that the illuminance measurement is invalid.
|
|
1214
|
-
*/
|
|
1215
776
|
export function getDefaultIlluminanceMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
1216
777
|
return optionsFor(IlluminanceMeasurementServer, {
|
|
1217
778
|
measuredValue,
|
|
@@ -1220,14 +781,6 @@ export function getDefaultIlluminanceMeasurementClusterServer(measuredValue = nu
|
|
|
1220
781
|
tolerance: 0,
|
|
1221
782
|
});
|
|
1222
783
|
}
|
|
1223
|
-
/**
|
|
1224
|
-
* Get the default FlowMeasurement cluster server options.
|
|
1225
|
-
*
|
|
1226
|
-
* @param {number | null} measuredValue - The measured value of the flow in 10 x m3/h.
|
|
1227
|
-
* @param {number | null} minMeasuredValue - The minimum measured value of the flow in 10 x m3/h.
|
|
1228
|
-
* @param {number | null} maxMeasuredValue - The maximum measured value of the flow in 10 x m3/h.
|
|
1229
|
-
* @returns {Behavior.Options<MatterbridgeFlowMeasurementServer>} - The default options for the FlowMeasurement cluster server.
|
|
1230
|
-
*/
|
|
1231
784
|
export function getDefaultFlowMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
1232
785
|
return optionsFor(FlowMeasurementServer, {
|
|
1233
786
|
measuredValue,
|
|
@@ -1236,20 +789,6 @@ export function getDefaultFlowMeasurementClusterServer(measuredValue = null, min
|
|
|
1236
789
|
tolerance: 0,
|
|
1237
790
|
});
|
|
1238
791
|
}
|
|
1239
|
-
/**
|
|
1240
|
-
* Get the default OccupancySensing cluster server options.
|
|
1241
|
-
*
|
|
1242
|
-
* @param {boolean} occupied - A boolean indicating whether the occupancy is occupied or not. Default is false.
|
|
1243
|
-
* @param {number} holdTime - The hold time in seconds. Default is 30.
|
|
1244
|
-
* @param {number} holdTimeMin - The minimum hold time in seconds. Default is 1.
|
|
1245
|
-
* @param {number} holdTimeMax - The maximum hold time in seconds. Default is 300.
|
|
1246
|
-
* @returns {Behavior.Options<MatterbridgeOccupancySensingServer>} - The default options for the OccupancySensing cluster server.
|
|
1247
|
-
*
|
|
1248
|
-
* @remarks The default value for the occupancy sensor type is PIR.
|
|
1249
|
-
* Servers SHALL set these attributes for backward compatibility with clients implementing a cluster revision <= 4 as
|
|
1250
|
-
* described in OccupancySensorType and OccupancySensorTypeBitmap Attributes.
|
|
1251
|
-
* This replaces the 9 legacy attributes PIROccupiedToUnoccupiedDelay through PhysicalContactUnoccupiedToOccupiedThreshold.
|
|
1252
|
-
*/
|
|
1253
792
|
export function getDefaultOccupancySensingClusterServer(occupied = false, holdTime = 30, holdTimeMin = 1, holdTimeMax = 300) {
|
|
1254
793
|
return optionsFor(OccupancySensingServer.with(OccupancySensing.Feature.PassiveInfrared), {
|
|
1255
794
|
occupancy: { occupied },
|
|
@@ -1262,4 +801,3 @@ export function getDefaultOccupancySensingClusterServer(occupied = false, holdTi
|
|
|
1262
801
|
holdTimeLimits: { holdTimeMin, holdTimeMax, holdTimeDefault: holdTime },
|
|
1263
802
|
});
|
|
1264
803
|
}
|
|
1265
|
-
//# sourceMappingURL=matterbridgeEndpointHelpers.js.map
|