matterbridge 3.3.7-dev-20251109-a306ab9 → 3.3.7
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/dist/broadcastServer.d.ts +115 -0
- package/dist/broadcastServer.d.ts.map +1 -0
- package/dist/broadcastServer.js +93 -1
- package/dist/broadcastServer.js.map +1 -0
- package/dist/broadcastServerTypes.d.ts +806 -0
- package/dist/broadcastServerTypes.d.ts.map +1 -0
- package/dist/broadcastServerTypes.js +24 -0
- package/dist/broadcastServerTypes.js.map +1 -0
- package/dist/cli.d.ts +30 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +97 -1
- package/dist/cli.js.map +1 -0
- package/dist/cliEmitter.d.ts +50 -0
- package/dist/cliEmitter.d.ts.map +1 -0
- package/dist/cliEmitter.js +37 -0
- package/dist/cliEmitter.js.map +1 -0
- package/dist/cliHistory.d.ts +48 -0
- package/dist/cliHistory.d.ts.map +1 -0
- package/dist/cliHistory.js +38 -0
- package/dist/cliHistory.js.map +1 -0
- package/dist/clusters/export.d.ts +2 -0
- package/dist/clusters/export.d.ts.map +1 -0
- package/dist/clusters/export.js +2 -0
- package/dist/clusters/export.js.map +1 -0
- package/dist/defaultConfigSchema.d.ts +28 -0
- package/dist/defaultConfigSchema.d.ts.map +1 -0
- package/dist/defaultConfigSchema.js +24 -0
- package/dist/defaultConfigSchema.js.map +1 -0
- package/dist/deviceManager.d.ts +128 -0
- package/dist/deviceManager.d.ts.map +1 -0
- package/dist/deviceManager.js +105 -1
- package/dist/deviceManager.js.map +1 -0
- package/dist/devices/airConditioner.d.ts +98 -0
- package/dist/devices/airConditioner.d.ts.map +1 -0
- package/dist/devices/airConditioner.js +57 -0
- package/dist/devices/airConditioner.js.map +1 -0
- package/dist/devices/batteryStorage.d.ts +48 -0
- package/dist/devices/batteryStorage.d.ts.map +1 -0
- package/dist/devices/batteryStorage.js +48 -1
- package/dist/devices/batteryStorage.js.map +1 -0
- package/dist/devices/cooktop.d.ts +60 -0
- package/dist/devices/cooktop.d.ts.map +1 -0
- package/dist/devices/cooktop.js +55 -0
- package/dist/devices/cooktop.js.map +1 -0
- package/dist/devices/dishwasher.d.ts +71 -0
- package/dist/devices/dishwasher.d.ts.map +1 -0
- package/dist/devices/dishwasher.js +57 -0
- package/dist/devices/dishwasher.js.map +1 -0
- package/dist/devices/evse.d.ts +76 -0
- package/dist/devices/evse.d.ts.map +1 -0
- package/dist/devices/evse.js +74 -10
- package/dist/devices/evse.js.map +1 -0
- package/dist/devices/export.d.ts +17 -0
- package/dist/devices/export.d.ts.map +1 -0
- package/dist/devices/export.js +5 -0
- package/dist/devices/export.js.map +1 -0
- package/dist/devices/extractorHood.d.ts +46 -0
- package/dist/devices/extractorHood.d.ts.map +1 -0
- package/dist/devices/extractorHood.js +42 -0
- package/dist/devices/extractorHood.js.map +1 -0
- package/dist/devices/heatPump.d.ts +47 -0
- package/dist/devices/heatPump.d.ts.map +1 -0
- package/dist/devices/heatPump.js +50 -2
- package/dist/devices/heatPump.js.map +1 -0
- package/dist/devices/laundryDryer.d.ts +67 -0
- package/dist/devices/laundryDryer.d.ts.map +1 -0
- package/dist/devices/laundryDryer.js +62 -3
- package/dist/devices/laundryDryer.js.map +1 -0
- package/dist/devices/laundryWasher.d.ts +81 -0
- package/dist/devices/laundryWasher.d.ts.map +1 -0
- package/dist/devices/laundryWasher.js +70 -4
- package/dist/devices/laundryWasher.js.map +1 -0
- package/dist/devices/microwaveOven.d.ts +168 -0
- package/dist/devices/microwaveOven.d.ts.map +1 -0
- package/dist/devices/microwaveOven.js +88 -5
- package/dist/devices/microwaveOven.js.map +1 -0
- package/dist/devices/oven.d.ts +105 -0
- package/dist/devices/oven.d.ts.map +1 -0
- package/dist/devices/oven.js +85 -0
- package/dist/devices/oven.js.map +1 -0
- package/dist/devices/refrigerator.d.ts +118 -0
- package/dist/devices/refrigerator.d.ts.map +1 -0
- package/dist/devices/refrigerator.js +102 -0
- package/dist/devices/refrigerator.js.map +1 -0
- package/dist/devices/roboticVacuumCleaner.d.ts +112 -0
- package/dist/devices/roboticVacuumCleaner.d.ts.map +1 -0
- package/dist/devices/roboticVacuumCleaner.js +100 -9
- package/dist/devices/roboticVacuumCleaner.js.map +1 -0
- package/dist/devices/solarPower.d.ts +40 -0
- package/dist/devices/solarPower.d.ts.map +1 -0
- package/dist/devices/solarPower.js +38 -0
- package/dist/devices/solarPower.js.map +1 -0
- package/dist/devices/speaker.d.ts +87 -0
- package/dist/devices/speaker.d.ts.map +1 -0
- package/dist/devices/speaker.js +84 -0
- package/dist/devices/speaker.js.map +1 -0
- package/dist/devices/temperatureControl.d.ts +166 -0
- package/dist/devices/temperatureControl.d.ts.map +1 -0
- package/dist/devices/temperatureControl.js +24 -3
- package/dist/devices/temperatureControl.js.map +1 -0
- package/dist/devices/waterHeater.d.ts +111 -0
- package/dist/devices/waterHeater.d.ts.map +1 -0
- package/dist/devices/waterHeater.js +82 -2
- package/dist/devices/waterHeater.js.map +1 -0
- package/dist/dgram/coap.d.ts +205 -0
- package/dist/dgram/coap.d.ts.map +1 -0
- package/dist/dgram/coap.js +126 -13
- package/dist/dgram/coap.js.map +1 -0
- package/dist/dgram/dgram.d.ts +141 -0
- package/dist/dgram/dgram.d.ts.map +1 -0
- package/dist/dgram/dgram.js +114 -2
- package/dist/dgram/dgram.js.map +1 -0
- package/dist/dgram/mb_coap.d.ts +24 -0
- package/dist/dgram/mb_coap.d.ts.map +1 -0
- package/dist/dgram/mb_coap.js +41 -3
- package/dist/dgram/mb_coap.js.map +1 -0
- package/dist/dgram/mb_mdns.d.ts +24 -0
- package/dist/dgram/mb_mdns.d.ts.map +1 -0
- package/dist/dgram/mb_mdns.js +80 -15
- package/dist/dgram/mb_mdns.js.map +1 -0
- package/dist/dgram/mdns.d.ts +290 -0
- package/dist/dgram/mdns.d.ts.map +1 -0
- package/dist/dgram/mdns.js +299 -137
- package/dist/dgram/mdns.js.map +1 -0
- package/dist/dgram/multicast.d.ts +67 -0
- package/dist/dgram/multicast.d.ts.map +1 -0
- package/dist/dgram/multicast.js +62 -1
- package/dist/dgram/multicast.js.map +1 -0
- package/dist/dgram/unicast.d.ts +56 -0
- package/dist/dgram/unicast.d.ts.map +1 -0
- package/dist/dgram/unicast.js +54 -0
- package/dist/dgram/unicast.js.map +1 -0
- package/dist/frontend.d.ts +238 -0
- package/dist/frontend.d.ts.map +1 -0
- package/dist/frontend.js +451 -35
- package/dist/frontend.js.map +1 -0
- package/dist/frontendTypes.d.ts +529 -0
- package/dist/frontendTypes.d.ts.map +1 -0
- package/dist/frontendTypes.js +45 -0
- package/dist/frontendTypes.js.map +1 -0
- package/dist/helpers.d.ts +48 -0
- package/dist/helpers.d.ts.map +1 -0
- package/dist/helpers.js +53 -0
- package/dist/helpers.js.map +1 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/logger/export.d.ts +2 -0
- package/dist/logger/export.d.ts.map +1 -0
- package/dist/logger/export.js +1 -0
- package/dist/logger/export.js.map +1 -0
- package/dist/matter/behaviors.d.ts +2 -0
- package/dist/matter/behaviors.d.ts.map +1 -0
- package/dist/matter/behaviors.js +2 -0
- package/dist/matter/behaviors.js.map +1 -0
- package/dist/matter/clusters.d.ts +2 -0
- package/dist/matter/clusters.d.ts.map +1 -0
- package/dist/matter/clusters.js +2 -0
- package/dist/matter/clusters.js.map +1 -0
- package/dist/matter/devices.d.ts +2 -0
- package/dist/matter/devices.d.ts.map +1 -0
- package/dist/matter/devices.js +2 -0
- package/dist/matter/devices.js.map +1 -0
- package/dist/matter/endpoints.d.ts +2 -0
- package/dist/matter/endpoints.d.ts.map +1 -0
- package/dist/matter/endpoints.js +2 -0
- package/dist/matter/endpoints.js.map +1 -0
- package/dist/matter/export.d.ts +5 -0
- package/dist/matter/export.d.ts.map +1 -0
- package/dist/matter/export.js +3 -0
- package/dist/matter/export.js.map +1 -0
- package/dist/matter/types.d.ts +3 -0
- package/dist/matter/types.d.ts.map +1 -0
- package/dist/matter/types.js +3 -0
- package/dist/matter/types.js.map +1 -0
- package/dist/matterbridge.d.ts +478 -0
- package/dist/matterbridge.d.ts.map +1 -0
- package/dist/matterbridge.js +828 -46
- package/dist/matterbridge.js.map +1 -0
- package/dist/matterbridgeAccessoryPlatform.d.ts +42 -0
- package/dist/matterbridgeAccessoryPlatform.d.ts.map +1 -0
- package/dist/matterbridgeAccessoryPlatform.js +37 -0
- package/dist/matterbridgeAccessoryPlatform.js.map +1 -0
- package/dist/matterbridgeBehaviors.d.ts +2404 -0
- package/dist/matterbridgeBehaviors.d.ts.map +1 -0
- package/dist/matterbridgeBehaviors.js +68 -5
- package/dist/matterbridgeBehaviors.js.map +1 -0
- package/dist/matterbridgeDeviceTypes.d.ts +770 -0
- package/dist/matterbridgeDeviceTypes.d.ts.map +1 -0
- package/dist/matterbridgeDeviceTypes.js +638 -17
- package/dist/matterbridgeDeviceTypes.js.map +1 -0
- package/dist/matterbridgeDynamicPlatform.d.ts +42 -0
- package/dist/matterbridgeDynamicPlatform.d.ts.map +1 -0
- package/dist/matterbridgeDynamicPlatform.js +37 -0
- package/dist/matterbridgeDynamicPlatform.js.map +1 -0
- package/dist/matterbridgeEndpoint.d.ts +1556 -0
- package/dist/matterbridgeEndpoint.d.ts.map +1 -0
- package/dist/matterbridgeEndpoint.js +1408 -52
- package/dist/matterbridgeEndpoint.js.map +1 -0
- package/dist/matterbridgeEndpointHelpers.d.ts +758 -0
- package/dist/matterbridgeEndpointHelpers.d.ts.map +1 -0
- package/dist/matterbridgeEndpointHelpers.js +464 -19
- package/dist/matterbridgeEndpointHelpers.js.map +1 -0
- package/dist/matterbridgePlatform.d.ts +402 -0
- package/dist/matterbridgePlatform.d.ts.map +1 -0
- package/dist/matterbridgePlatform.js +341 -1
- package/dist/matterbridgePlatform.js.map +1 -0
- package/dist/matterbridgeTypes.d.ts +239 -0
- package/dist/matterbridgeTypes.d.ts.map +1 -0
- package/dist/matterbridgeTypes.js +26 -0
- package/dist/matterbridgeTypes.js.map +1 -0
- package/dist/pluginManager.d.ts +371 -0
- package/dist/pluginManager.d.ts.map +1 -0
- package/dist/pluginManager.js +339 -4
- package/dist/pluginManager.js.map +1 -0
- package/dist/shelly.d.ts +174 -0
- package/dist/shelly.d.ts.map +1 -0
- package/dist/shelly.js +168 -7
- package/dist/shelly.js.map +1 -0
- package/dist/storage/export.d.ts +2 -0
- package/dist/storage/export.d.ts.map +1 -0
- package/dist/storage/export.js +1 -0
- package/dist/storage/export.js.map +1 -0
- package/dist/update.d.ts +75 -0
- package/dist/update.d.ts.map +1 -0
- package/dist/update.js +69 -0
- package/dist/update.js.map +1 -0
- package/dist/utils/colorUtils.d.ts +101 -0
- package/dist/utils/colorUtils.d.ts.map +1 -0
- package/dist/utils/colorUtils.js +97 -2
- package/dist/utils/colorUtils.js.map +1 -0
- package/dist/utils/commandLine.d.ts +66 -0
- package/dist/utils/commandLine.d.ts.map +1 -0
- package/dist/utils/commandLine.js +60 -0
- package/dist/utils/commandLine.js.map +1 -0
- package/dist/utils/copyDirectory.d.ts +33 -0
- package/dist/utils/copyDirectory.d.ts.map +1 -0
- package/dist/utils/copyDirectory.js +38 -1
- package/dist/utils/copyDirectory.js.map +1 -0
- package/dist/utils/createDirectory.d.ts +34 -0
- package/dist/utils/createDirectory.d.ts.map +1 -0
- package/dist/utils/createDirectory.js +33 -0
- package/dist/utils/createDirectory.js.map +1 -0
- package/dist/utils/createZip.d.ts +39 -0
- package/dist/utils/createZip.d.ts.map +1 -0
- package/dist/utils/createZip.js +47 -2
- package/dist/utils/createZip.js.map +1 -0
- package/dist/utils/deepCopy.d.ts +32 -0
- package/dist/utils/deepCopy.d.ts.map +1 -0
- package/dist/utils/deepCopy.js +39 -0
- package/dist/utils/deepCopy.js.map +1 -0
- package/dist/utils/deepEqual.d.ts +54 -0
- package/dist/utils/deepEqual.d.ts.map +1 -0
- package/dist/utils/deepEqual.js +72 -1
- package/dist/utils/deepEqual.js.map +1 -0
- package/dist/utils/error.d.ts +44 -0
- package/dist/utils/error.d.ts.map +1 -0
- package/dist/utils/error.js +41 -0
- package/dist/utils/error.js.map +1 -0
- package/dist/utils/export.d.ts +13 -0
- package/dist/utils/export.d.ts.map +1 -0
- package/dist/utils/export.js +1 -0
- package/dist/utils/export.js.map +1 -0
- package/dist/utils/format.d.ts +53 -0
- package/dist/utils/format.d.ts.map +1 -0
- package/dist/utils/format.js +49 -0
- package/dist/utils/format.js.map +1 -0
- package/dist/utils/hex.d.ts +89 -0
- package/dist/utils/hex.d.ts.map +1 -0
- package/dist/utils/hex.js +124 -0
- package/dist/utils/hex.js.map +1 -0
- package/dist/utils/inspector.d.ts +87 -0
- package/dist/utils/inspector.d.ts.map +1 -0
- package/dist/utils/inspector.js +69 -1
- package/dist/utils/inspector.js.map +1 -0
- package/dist/utils/isvalid.d.ts +103 -0
- package/dist/utils/isvalid.d.ts.map +1 -0
- package/dist/utils/isvalid.js +101 -0
- package/dist/utils/isvalid.js.map +1 -0
- package/dist/utils/jestHelpers.d.ts +139 -0
- package/dist/utils/jestHelpers.d.ts.map +1 -0
- package/dist/utils/jestHelpers.js +153 -3
- package/dist/utils/jestHelpers.js.map +1 -0
- package/dist/utils/network.d.ts +101 -0
- package/dist/utils/network.d.ts.map +1 -0
- package/dist/utils/network.js +96 -5
- package/dist/utils/network.js.map +1 -0
- package/dist/utils/spawn.d.ts +35 -0
- package/dist/utils/spawn.d.ts.map +1 -0
- package/dist/utils/spawn.js +71 -0
- package/dist/utils/spawn.js.map +1 -0
- package/dist/utils/tracker.d.ts +108 -0
- package/dist/utils/tracker.d.ts.map +1 -0
- package/dist/utils/tracker.js +64 -1
- package/dist/utils/tracker.js.map +1 -0
- package/dist/utils/wait.d.ts +54 -0
- package/dist/utils/wait.d.ts.map +1 -0
- package/dist/utils/wait.js +60 -8
- package/dist/utils/wait.js.map +1 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +2 -1
|
@@ -1,10 +1,38 @@
|
|
|
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
|
|
1
25
|
if (process.argv.includes('--loader') || process.argv.includes('-loader'))
|
|
2
26
|
console.log('\u001B[32mMatterbridgeEndpointHelpers loaded.\u001B[40;0m');
|
|
27
|
+
// Other modules
|
|
3
28
|
import { createHash } from 'node:crypto';
|
|
29
|
+
// AnsiLogger module
|
|
4
30
|
import { BLUE, CYAN, db, debugStringify, er, hk, or, YELLOW, zb } from 'node-ansi-logger';
|
|
31
|
+
// @matter
|
|
5
32
|
import { Lifecycle } from '@matter/general';
|
|
6
33
|
import { MeasurementType } from '@matter/types/globals';
|
|
7
34
|
import { getClusterNameById } from '@matter/types/cluster';
|
|
35
|
+
// @matter clusters
|
|
8
36
|
import { PowerSource } from '@matter/types/clusters/power-source';
|
|
9
37
|
import { UserLabel } from '@matter/types/clusters/user-label';
|
|
10
38
|
import { FixedLabel } from '@matter/types/clusters/fixed-label';
|
|
@@ -49,6 +77,7 @@ import { TotalVolatileOrganicCompoundsConcentrationMeasurement } from '@matter/t
|
|
|
49
77
|
import { OperationalState } from '@matter/types/clusters/operational-state';
|
|
50
78
|
import { DeviceEnergyManagement } from '@matter/types/clusters/device-energy-management';
|
|
51
79
|
import { DeviceEnergyManagementMode } from '@matter/types/clusters/device-energy-management-mode';
|
|
80
|
+
// @matter behaviors
|
|
52
81
|
import { PowerSourceServer } from '@matter/node/behaviors/power-source';
|
|
53
82
|
import { UserLabelServer } from '@matter/node/behaviors/user-label';
|
|
54
83
|
import { FixedLabelServer } from '@matter/node/behaviors/fixed-label';
|
|
@@ -79,58 +108,128 @@ import { Pm10ConcentrationMeasurementServer } from '@matter/node/behaviors/pm10-
|
|
|
79
108
|
import { RadonConcentrationMeasurementServer } from '@matter/node/behaviors/radon-concentration-measurement';
|
|
80
109
|
import { TotalVolatileOrganicCompoundsConcentrationMeasurementServer } from '@matter/node/behaviors/total-volatile-organic-compounds-concentration-measurement';
|
|
81
110
|
import { DeviceEnergyManagementServer } from '@matter/node/behaviors/device-energy-management';
|
|
111
|
+
// Matterbridge
|
|
82
112
|
import { deepCopy } from './utils/deepCopy.js';
|
|
83
113
|
import { deepEqual } from './utils/deepEqual.js';
|
|
84
114
|
import { isValidArray } from './utils/isvalid.js';
|
|
85
115
|
import { MatterbridgeIdentifyServer, MatterbridgeOnOffServer, MatterbridgeLevelControlServer, MatterbridgeColorControlServer, MatterbridgeLiftWindowCoveringServer, MatterbridgeThermostatServer, MatterbridgeFanControlServer, MatterbridgeDoorLockServer, MatterbridgeModeSelectServer, MatterbridgeValveConfigurationAndControlServer, MatterbridgeSmokeCoAlarmServer, MatterbridgeBooleanStateConfigurationServer, MatterbridgeOperationalStateServer, MatterbridgeDeviceEnergyManagementModeServer, MatterbridgePowerSourceServer, MatterbridgeDeviceEnergyManagementServer, } from './matterbridgeBehaviors.js';
|
|
116
|
+
/**
|
|
117
|
+
* Capitalizes the first letter of a string.
|
|
118
|
+
*
|
|
119
|
+
* @param {string} name - The string to capitalize.
|
|
120
|
+
* @returns {string} The string with the first letter capitalized.
|
|
121
|
+
*/
|
|
86
122
|
export function capitalizeFirstLetter(name) {
|
|
87
123
|
if (!name)
|
|
88
124
|
return name;
|
|
89
125
|
return name.charAt(0).toUpperCase() + name.slice(1);
|
|
90
126
|
}
|
|
127
|
+
/**
|
|
128
|
+
* Lowercases the first letter of a string.
|
|
129
|
+
*
|
|
130
|
+
* @param {string} name - The string to lowercase the first letter of.
|
|
131
|
+
* @returns {string} The string with the first letter lowercased.
|
|
132
|
+
*/
|
|
91
133
|
export function lowercaseFirstLetter(name) {
|
|
92
134
|
if (!name)
|
|
93
135
|
return name;
|
|
94
136
|
return name.charAt(0).toLowerCase() + name.slice(1);
|
|
95
137
|
}
|
|
138
|
+
/**
|
|
139
|
+
* Checks if the device name contains non-Latin characters.
|
|
140
|
+
*
|
|
141
|
+
* @param {string} deviceName - The name of the device to check.
|
|
142
|
+
* @returns {boolean} Returns true if the device name contains non-Latin characters, false otherwise.
|
|
143
|
+
*/
|
|
96
144
|
export function checkNotLatinCharacters(deviceName) {
|
|
97
145
|
const nonLatinRegexList = [
|
|
98
|
-
/[\u0400-\u04FF\u0500-\u052F]/,
|
|
99
|
-
/[\u2E80-\u9FFF]/,
|
|
100
|
-
/[\uAC00-\uD7AF]/,
|
|
101
|
-
/[\u0600-\u06FF\u0750-\u077F]/,
|
|
102
|
-
/[\u0590-\u05FF]/,
|
|
103
|
-
/[\u0900-\u097F]/,
|
|
104
|
-
/[\u0E00-\u0E7F]/,
|
|
105
|
-
/[\u1200-\u137F]/,
|
|
146
|
+
/[\u0400-\u04FF\u0500-\u052F]/, // Cyrillic
|
|
147
|
+
/[\u2E80-\u9FFF]/, // CJK (Chinese, Japanese, Korean)
|
|
148
|
+
/[\uAC00-\uD7AF]/, // Korean Hangul
|
|
149
|
+
/[\u0600-\u06FF\u0750-\u077F]/, // Arabic, Persian
|
|
150
|
+
/[\u0590-\u05FF]/, // Hebrew
|
|
151
|
+
/[\u0900-\u097F]/, // Devanagari (Hindi, Sanskrit)
|
|
152
|
+
/[\u0E00-\u0E7F]/, // Thai
|
|
153
|
+
/[\u1200-\u137F]/, // Ethiopic (Amharic, Tigrinya)
|
|
106
154
|
];
|
|
107
155
|
return nonLatinRegexList.some((regex) => regex.test(deviceName));
|
|
108
156
|
}
|
|
157
|
+
/**
|
|
158
|
+
* Generates a unique ID based on the device name.
|
|
159
|
+
*
|
|
160
|
+
* @param {string} deviceName - The name of the device to generate a unique ID for.
|
|
161
|
+
* @returns {string} A unique ID generated from the device name using MD5 hashing.
|
|
162
|
+
*/
|
|
109
163
|
export function generateUniqueId(deviceName) {
|
|
110
|
-
return createHash('md5').update(deviceName).digest('hex');
|
|
164
|
+
return createHash('md5').update(deviceName).digest('hex'); // MD5 hash of the device name
|
|
111
165
|
}
|
|
166
|
+
/**
|
|
167
|
+
* Generates a unique ID based on four parameters.
|
|
168
|
+
*
|
|
169
|
+
* @param {string} param1 - The first parameter.
|
|
170
|
+
* @param {string} param2 - The second parameter.
|
|
171
|
+
* @param {string} param3 - The third parameter.
|
|
172
|
+
* @param {string} param4 - The fourth parameter.
|
|
173
|
+
* @returns {string} A unique ID generated from the concatenation of the parameters using MD5 hashing.
|
|
174
|
+
*/
|
|
112
175
|
export function createUniqueId(param1, param2, param3, param4) {
|
|
113
176
|
const hash = createHash('md5');
|
|
114
177
|
hash.update(param1 + param2 + param3 + param4);
|
|
115
178
|
return hash.digest('hex');
|
|
116
179
|
}
|
|
180
|
+
/**
|
|
181
|
+
* Retrieves the features for a specific behavior.
|
|
182
|
+
*
|
|
183
|
+
* @param {Endpoint} endpoint - The endpoint to retrieve the features from.
|
|
184
|
+
* @param {string} behavior - The behavior to retrieve the features for.
|
|
185
|
+
*
|
|
186
|
+
* @returns {Record<string, boolean | undefined>} The features for the specified behavior.
|
|
187
|
+
*
|
|
188
|
+
* @remarks Use with:
|
|
189
|
+
* ```typescript
|
|
190
|
+
* expect(featuresFor(device, 'powerSource').wired).toBe(true);
|
|
191
|
+
* ```
|
|
192
|
+
*/
|
|
117
193
|
export function featuresFor(endpoint, behavior) {
|
|
194
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
118
195
|
return endpoint.behaviors.supported[lowercaseFirstLetter(behavior)]['cluster']['supportedFeatures'];
|
|
119
196
|
}
|
|
197
|
+
/**
|
|
198
|
+
* Maps a list of ClusterId to Behavior.Type for server clusters.
|
|
199
|
+
*
|
|
200
|
+
* @param {ClusterId[]} clusterServerList - The list of ClusterId to map.
|
|
201
|
+
* @returns {Behavior.Type[]} An array of Behavior.Type corresponding to the ClusterId in the server list.
|
|
202
|
+
*/
|
|
120
203
|
export function getBehaviourTypesFromClusterServerIds(clusterServerList) {
|
|
204
|
+
// Map Server ClusterId to Behavior.Type
|
|
121
205
|
const behaviorTypes = [];
|
|
122
206
|
clusterServerList.forEach((clusterId) => {
|
|
123
207
|
behaviorTypes.push(getBehaviourTypeFromClusterServerId(clusterId));
|
|
124
208
|
});
|
|
125
209
|
return behaviorTypes;
|
|
126
210
|
}
|
|
211
|
+
/**
|
|
212
|
+
* Maps a list of ClusterId to Behavior.Type for client clusters.
|
|
213
|
+
*
|
|
214
|
+
* @param {ClusterId[]} clusterClientList - The list of ClusterId to map.
|
|
215
|
+
* @returns {Behavior.Type[]} An array of Behavior.Type corresponding to the ClusterId in the client list.
|
|
216
|
+
*/
|
|
127
217
|
export function getBehaviourTypesFromClusterClientIds(clusterClientList) {
|
|
218
|
+
// Map Client ClusterId to Behavior.Type
|
|
128
219
|
const behaviorTypes = [];
|
|
129
220
|
clusterClientList.forEach((_clusterId) => {
|
|
221
|
+
// behaviorTypes.push(getBehaviourTypeFromClusterClientId(clusterId));
|
|
130
222
|
});
|
|
131
223
|
return behaviorTypes;
|
|
132
224
|
}
|
|
225
|
+
/**
|
|
226
|
+
* Maps a ClusterId to a Behavior.Type for server clusters.
|
|
227
|
+
*
|
|
228
|
+
* @param {ClusterId} clusterId - The ClusterId to map.
|
|
229
|
+
* @returns {Behavior.Type} The corresponding Behavior.Type for the given ClusterId.
|
|
230
|
+
*/
|
|
133
231
|
export function getBehaviourTypeFromClusterServerId(clusterId) {
|
|
232
|
+
// Map ClusterId to Server Behavior.Type
|
|
134
233
|
if (clusterId === PowerSource.Cluster.id)
|
|
135
234
|
return PowerSourceServer.with(PowerSource.Feature.Wired);
|
|
136
235
|
if (clusterId === UserLabel.Cluster.id)
|
|
@@ -221,8 +320,22 @@ export function getBehaviourTypeFromClusterServerId(clusterId) {
|
|
|
221
320
|
return MatterbridgeDeviceEnergyManagementModeServer;
|
|
222
321
|
return MatterbridgeIdentifyServer;
|
|
223
322
|
}
|
|
323
|
+
/**
|
|
324
|
+
* Maps a ClusterId to a Behavior.Type for client clusters.
|
|
325
|
+
*
|
|
326
|
+
* @param {ClusterId} _clusterId - The ClusterId to map.
|
|
327
|
+
*/
|
|
224
328
|
export function getBehaviourTypeFromClusterClientId(_clusterId) {
|
|
329
|
+
// Map ClusterId to Client Behavior.Type
|
|
330
|
+
// return IdentifyClient;
|
|
225
331
|
}
|
|
332
|
+
/**
|
|
333
|
+
* Retrieves the Behavior.Type for a given cluster from the endpoint's supported behaviors.
|
|
334
|
+
*
|
|
335
|
+
* @param {MatterbridgeEndpoint} endpoint - The endpoint to retrieve the behavior from.
|
|
336
|
+
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to retrieve the behavior for.
|
|
337
|
+
* @returns {Behavior.Type | undefined} The Behavior.Type for the given cluster, or undefined if not found.
|
|
338
|
+
*/
|
|
226
339
|
export function getBehavior(endpoint, cluster) {
|
|
227
340
|
let behavior;
|
|
228
341
|
if (typeof cluster === 'string') {
|
|
@@ -239,6 +352,18 @@ export function getBehavior(endpoint, cluster) {
|
|
|
239
352
|
}
|
|
240
353
|
return behavior;
|
|
241
354
|
}
|
|
355
|
+
/**
|
|
356
|
+
* Invokes a command on the specified behavior of the endpoint. Used ONLY in Jest tests.
|
|
357
|
+
*
|
|
358
|
+
* @param {MatterbridgeEndpoint} endpoint - The endpoint to invoke the command on.
|
|
359
|
+
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to invoke the command on.
|
|
360
|
+
* @param {keyof MatterbridgeEndpointCommands} command - The command to invoke.
|
|
361
|
+
* @param {Record<string, boolean | number | bigint | string | object | null>} [params] - The parameters to pass to the command.
|
|
362
|
+
*
|
|
363
|
+
* @returns {Promise<boolean>} A promise that resolves to true if the command was invoked successfully, false otherwise.
|
|
364
|
+
*
|
|
365
|
+
* @deprecated Used ONLY in Jest tests.
|
|
366
|
+
*/
|
|
242
367
|
export async function invokeBehaviorCommand(endpoint, cluster, command, params) {
|
|
243
368
|
const behaviorId = getBehavior(endpoint, cluster)?.id;
|
|
244
369
|
if (!behaviorId) {
|
|
@@ -246,6 +371,7 @@ export async function invokeBehaviorCommand(endpoint, cluster, command, params)
|
|
|
246
371
|
return false;
|
|
247
372
|
}
|
|
248
373
|
await endpoint.act((agent) => {
|
|
374
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
249
375
|
const behavior = agent[behaviorId];
|
|
250
376
|
if (!(command in behavior) || typeof behavior[command] !== 'function') {
|
|
251
377
|
endpoint.log?.error(`invokeBehaviorCommand error: command ${hk}${command}${er} not found on agent for endpoint ${or}${endpoint.maybeId}${er}:${or}${endpoint.maybeNumber}${er}`);
|
|
@@ -255,6 +381,19 @@ export async function invokeBehaviorCommand(endpoint, cluster, command, params)
|
|
|
255
381
|
});
|
|
256
382
|
return true;
|
|
257
383
|
}
|
|
384
|
+
/**
|
|
385
|
+
* Invokes the subscription handler on the specified cluster and attribute of the endpoint. Used ONLY in Jest tests.
|
|
386
|
+
*
|
|
387
|
+
* @param {MatterbridgeEndpoint} endpoint - The endpoint to invoke the subscription handler on.
|
|
388
|
+
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to invoke the subscription handler on.
|
|
389
|
+
* @param {string} attribute - The attribute to invoke the subscription handler on.
|
|
390
|
+
* @param {unknown} newValue - The new value of the attribute.
|
|
391
|
+
* @param {unknown} oldValue - The old value of the attribute.
|
|
392
|
+
*
|
|
393
|
+
* @returns {Promise<boolean>} A promise that resolves to true if the subscription handler was invoked successfully, false otherwise.
|
|
394
|
+
*
|
|
395
|
+
* @deprecated Used ONLY in Jest tests.
|
|
396
|
+
*/
|
|
258
397
|
export async function invokeSubscribeHandler(endpoint, cluster, attribute, newValue, oldValue) {
|
|
259
398
|
const event = attribute + '$Changed';
|
|
260
399
|
const clusterName = getBehavior(endpoint, cluster)?.id;
|
|
@@ -271,9 +410,17 @@ export async function invokeSubscribeHandler(endpoint, cluster, attribute, newVa
|
|
|
271
410
|
endpoint.log.error(`invokeSubscribeHandler ${hk}${event}${er} error: cluster ${clusterName} not found on endpoint ${or}${endpoint.id}${er}:${or}${endpoint.number}${er}`);
|
|
272
411
|
return false;
|
|
273
412
|
}
|
|
413
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
414
|
+
// @ts-ignore
|
|
274
415
|
await endpoint.act((agent) => agent[clusterName].events[event].emit(newValue, oldValue, { ...agent.context, offline: false }));
|
|
275
416
|
return true;
|
|
276
417
|
}
|
|
418
|
+
/**
|
|
419
|
+
* Adds required cluster servers to the specified endpoint based on the device types.
|
|
420
|
+
*
|
|
421
|
+
* @param {MatterbridgeEndpoint} endpoint - The endpoint to add the required cluster servers to.
|
|
422
|
+
* @returns {void}
|
|
423
|
+
*/
|
|
277
424
|
export function addRequiredClusterServers(endpoint) {
|
|
278
425
|
const requiredServerList = [];
|
|
279
426
|
endpoint.log.debug(`addRequiredClusterServers for ${CYAN}${endpoint.maybeId}${db}`);
|
|
@@ -288,6 +435,12 @@ export function addRequiredClusterServers(endpoint) {
|
|
|
288
435
|
});
|
|
289
436
|
addClusterServers(endpoint, requiredServerList);
|
|
290
437
|
}
|
|
438
|
+
/**
|
|
439
|
+
* Adds optional cluster servers to the specified endpoint based on the device types.
|
|
440
|
+
*
|
|
441
|
+
* @param {MatterbridgeEndpoint} endpoint - The endpoint to add the optional cluster servers to.
|
|
442
|
+
* @returns {void}
|
|
443
|
+
*/
|
|
291
444
|
export function addOptionalClusterServers(endpoint) {
|
|
292
445
|
const optionalServerList = [];
|
|
293
446
|
endpoint.log.debug(`addOptionalClusterServers for ${CYAN}${endpoint.maybeId}${db}`);
|
|
@@ -302,6 +455,12 @@ export function addOptionalClusterServers(endpoint) {
|
|
|
302
455
|
});
|
|
303
456
|
addClusterServers(endpoint, optionalServerList);
|
|
304
457
|
}
|
|
458
|
+
/**
|
|
459
|
+
* Adds cluster servers to the specified endpoint based on the provided server list.
|
|
460
|
+
*
|
|
461
|
+
* @param {MatterbridgeEndpoint} endpoint - The endpoint to add the cluster servers to.
|
|
462
|
+
* @param {ClusterId[]} serverList - The list of cluster IDs to add.
|
|
463
|
+
*/
|
|
305
464
|
export function addClusterServers(endpoint, serverList) {
|
|
306
465
|
if (serverList.includes(PowerSource.Cluster.id))
|
|
307
466
|
endpoint.createDefaultPowerSourceWiredClusterServer();
|
|
@@ -382,6 +541,13 @@ export function addClusterServers(endpoint, serverList) {
|
|
|
382
541
|
if (serverList.includes(DeviceEnergyManagementMode.Cluster.id))
|
|
383
542
|
endpoint.createDefaultDeviceEnergyManagementModeClusterServer();
|
|
384
543
|
}
|
|
544
|
+
/**
|
|
545
|
+
* Adds a fixed label to the FixedLabel cluster. The FixedLabel cluster is created if it does not exist.
|
|
546
|
+
*
|
|
547
|
+
* @param {MatterbridgeEndpoint} endpoint - The endpoint to add the cluster servers to.
|
|
548
|
+
* @param {string} label - The label to add. Max 16 characters.
|
|
549
|
+
* @param {string} value - The value of the label. Max 16 characters.
|
|
550
|
+
*/
|
|
385
551
|
export async function addFixedLabel(endpoint, label, value) {
|
|
386
552
|
if (!endpoint.hasClusterServer(FixedLabel.Cluster.id)) {
|
|
387
553
|
endpoint.log.debug(`addFixedLabel: add cluster ${hk}FixedLabel${db}:${hk}fixedLabel${db} with label ${CYAN}${label}${db} value ${CYAN}${value}${db}`);
|
|
@@ -398,6 +564,13 @@ export async function addFixedLabel(endpoint, label, value) {
|
|
|
398
564
|
await endpoint.setAttribute(FixedLabel.Cluster.id, 'labelList', labelList, endpoint.log);
|
|
399
565
|
}
|
|
400
566
|
}
|
|
567
|
+
/**
|
|
568
|
+
* Adds a user label to the UserLabel cluster. The UserLabel cluster is created if it does not exist.
|
|
569
|
+
*
|
|
570
|
+
* @param {MatterbridgeEndpoint} endpoint - The endpoint to add the cluster servers to.
|
|
571
|
+
* @param {string} label - The label to add. Max 16 characters.
|
|
572
|
+
* @param {string} value - The value of the label. Max 16 characters.
|
|
573
|
+
*/
|
|
401
574
|
export async function addUserLabel(endpoint, label, value) {
|
|
402
575
|
if (!endpoint.hasClusterServer(UserLabel.Cluster.id)) {
|
|
403
576
|
endpoint.log.debug(`addUserLabel: add cluster ${hk}UserLabel${db}:${hk}userLabel${db} with label ${CYAN}${label}${db} value ${CYAN}${value}${db}`);
|
|
@@ -414,16 +587,48 @@ export async function addUserLabel(endpoint, label, value) {
|
|
|
414
587
|
await endpoint.setAttribute(UserLabel.Cluster.id, 'labelList', labelList, endpoint.log);
|
|
415
588
|
}
|
|
416
589
|
}
|
|
590
|
+
/**
|
|
591
|
+
* Returns the options for a given behavior type.
|
|
592
|
+
*
|
|
593
|
+
* @param {T} type - The behavior type.
|
|
594
|
+
* @param {Behavior.Options<T>} options - The options for the behavior type.
|
|
595
|
+
* @returns {Behavior.Options<T>} The options for the behavior type.
|
|
596
|
+
*/
|
|
417
597
|
export function optionsFor(type, options) {
|
|
418
598
|
return options;
|
|
419
599
|
}
|
|
600
|
+
/**
|
|
601
|
+
* Retrieves the cluster ID.
|
|
602
|
+
*
|
|
603
|
+
* @param {Endpoint} endpoint - The endpoint to retrieve the cluster ID from.
|
|
604
|
+
* @param {ClusterId} cluster - The ID of the cluster.
|
|
605
|
+
* @returns {number | undefined} The ID of the cluster.
|
|
606
|
+
*/
|
|
420
607
|
export function getClusterId(endpoint, cluster) {
|
|
421
608
|
return endpoint.behaviors.supported[lowercaseFirstLetter(cluster)]?.schema?.id;
|
|
422
609
|
}
|
|
610
|
+
/**
|
|
611
|
+
* Retrieves the ID of an attribute from a cluster behavior.
|
|
612
|
+
*
|
|
613
|
+
* @param {Endpoint} endpoint - The endpoint to retrieve the attribute ID from.
|
|
614
|
+
* @param {string} cluster - The name of the cluster.
|
|
615
|
+
* @param {string} attribute - The name of the attribute.
|
|
616
|
+
* @returns {number | undefined} The ID of the attribute, or undefined if not found.
|
|
617
|
+
*/
|
|
423
618
|
export function getAttributeId(endpoint, cluster, attribute) {
|
|
424
619
|
const clusterBehavior = endpoint.behaviors.supported[lowercaseFirstLetter(cluster)];
|
|
425
620
|
return clusterBehavior?.cluster?.attributes[lowercaseFirstLetter(attribute)]?.id;
|
|
426
621
|
}
|
|
622
|
+
/**
|
|
623
|
+
* Retrieves the value of the provided attribute from the given cluster.
|
|
624
|
+
*
|
|
625
|
+
* @param {MatterbridgeEndpoint} endpoint - The endpoint to retrieve the attribute from.
|
|
626
|
+
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to retrieve the attribute from.
|
|
627
|
+
* @param {string} attribute - The name of the attribute to retrieve.
|
|
628
|
+
* @param {AnsiLogger} [log] - (Optional) The logger to use for logging the retrieve. Errors are logged to the endpoint logger.
|
|
629
|
+
* @returns {any} The value of the attribute, or undefined if the attribute is not found.
|
|
630
|
+
*/
|
|
631
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
427
632
|
export function getAttribute(endpoint, cluster, attribute, log) {
|
|
428
633
|
const clusterName = getBehavior(endpoint, cluster)?.id;
|
|
429
634
|
if (!clusterName) {
|
|
@@ -446,6 +651,16 @@ export function getAttribute(endpoint, cluster, attribute, log) {
|
|
|
446
651
|
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}`);
|
|
447
652
|
return value;
|
|
448
653
|
}
|
|
654
|
+
/**
|
|
655
|
+
* Sets the value of an attribute on a cluster server.
|
|
656
|
+
*
|
|
657
|
+
* @param {MatterbridgeEndpoint} endpoint - The endpoint to set the attribute on.
|
|
658
|
+
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to set the attribute on.
|
|
659
|
+
* @param {string} attribute - The name of the attribute.
|
|
660
|
+
* @param {boolean | number | bigint | string | object | null} value - The value to set for the attribute.
|
|
661
|
+
* @param {AnsiLogger} [log] - (Optional) The logger to use for logging the set. Errors are logged to the endpoint logger.
|
|
662
|
+
* @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the attribute was successfully set.
|
|
663
|
+
*/
|
|
449
664
|
export async function setAttribute(endpoint, cluster, attribute, value, log) {
|
|
450
665
|
const clusterName = getBehavior(endpoint, cluster)?.id;
|
|
451
666
|
if (!clusterName) {
|
|
@@ -471,6 +686,16 @@ export async function setAttribute(endpoint, cluster, attribute, value, log) {
|
|
|
471
686
|
`to ${YELLOW}${value !== null && typeof value === 'object' ? debugStringify(value) : value}${db}`);
|
|
472
687
|
return true;
|
|
473
688
|
}
|
|
689
|
+
/**
|
|
690
|
+
* Sets the value of an attribute on a cluster server.
|
|
691
|
+
*
|
|
692
|
+
* @param {MatterbridgeEndpoint} endpoint - The endpoint to update the attribute on.
|
|
693
|
+
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to update the attribute on.
|
|
694
|
+
* @param {string} attribute - The name of the attribute.
|
|
695
|
+
* @param {boolean | number | bigint | string | object | null} value - The value to set for the attribute.
|
|
696
|
+
* @param {AnsiLogger} [log] - (Optional) The logger to use for logging the update. Errors are logged to the endpoint logger.
|
|
697
|
+
* @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the attribute was successfully set.
|
|
698
|
+
*/
|
|
474
699
|
export async function updateAttribute(endpoint, cluster, attribute, value, log) {
|
|
475
700
|
const clusterName = getBehavior(endpoint, cluster)?.id;
|
|
476
701
|
if (!clusterName) {
|
|
@@ -501,7 +726,24 @@ export async function updateAttribute(endpoint, cluster, attribute, value, log)
|
|
|
501
726
|
`to ${YELLOW}${value !== null && typeof value === 'object' ? debugStringify(value) : value}${db}`);
|
|
502
727
|
return true;
|
|
503
728
|
}
|
|
504
|
-
|
|
729
|
+
/**
|
|
730
|
+
* Subscribes to the provided attribute on a cluster.
|
|
731
|
+
*
|
|
732
|
+
* @param {MatterbridgeEndpoint} endpoint - The endpoint to subscribe the attribute to.
|
|
733
|
+
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to subscribe the attribute to.
|
|
734
|
+
* @param {string} attribute - The name of the attribute to subscribe to.
|
|
735
|
+
* @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.
|
|
736
|
+
* @param {AnsiLogger} [log] - Optional logger for logging errors and information.
|
|
737
|
+
* @returns {boolean} - A boolean indicating whether the subscription was successful.
|
|
738
|
+
*
|
|
739
|
+
* @remarks The listener function (cannot be async) will receive three parameters:
|
|
740
|
+
* - `newValue`: The new value of the attribute.
|
|
741
|
+
* - `oldValue`: The old value of the attribute.
|
|
742
|
+
* - `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.
|
|
743
|
+
*/
|
|
744
|
+
export async function subscribeAttribute(endpoint, cluster, attribute,
|
|
745
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
746
|
+
listener, log) {
|
|
505
747
|
const clusterName = getBehavior(endpoint, cluster)?.id;
|
|
506
748
|
if (!clusterName) {
|
|
507
749
|
endpoint.log.error(`subscribeAttribute ${hk}${attribute}${er} error: cluster not found on endpoint ${or}${endpoint.maybeId}${er}:${or}${endpoint.maybeNumber}${er}`);
|
|
@@ -511,6 +753,7 @@ export async function subscribeAttribute(endpoint, cluster, attribute, listener,
|
|
|
511
753
|
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`);
|
|
512
754
|
await endpoint.construction.ready;
|
|
513
755
|
}
|
|
756
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
514
757
|
const events = endpoint.events;
|
|
515
758
|
attribute = lowercaseFirstLetter(attribute) + '$Changed';
|
|
516
759
|
if (!(clusterName in events) || !(attribute in events[clusterName])) {
|
|
@@ -521,6 +764,17 @@ export async function subscribeAttribute(endpoint, cluster, attribute, listener,
|
|
|
521
764
|
log?.info(`${db}Subscribed endpoint ${or}${endpoint.id}${db}:${or}${endpoint.number}${db} attribute ${hk}${capitalizeFirstLetter(clusterName)}${db}.${hk}${attribute}${db}`);
|
|
522
765
|
return true;
|
|
523
766
|
}
|
|
767
|
+
/**
|
|
768
|
+
* Triggers an event on the specified cluster.
|
|
769
|
+
*
|
|
770
|
+
* @param {MatterbridgeEndpoint} endpoint - The endpoint to trigger the event on.
|
|
771
|
+
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The ID of the cluster.
|
|
772
|
+
* @param {string} event - The name of the event to trigger.
|
|
773
|
+
* @param {Record<string, boolean | number | bigint | string | object | undefined | null>} payload - The payload to pass to the event.
|
|
774
|
+
* @param {AnsiLogger} [log] - Optional logger for logging information.
|
|
775
|
+
*
|
|
776
|
+
* @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the event was successfully triggered.
|
|
777
|
+
*/
|
|
524
778
|
export async function triggerEvent(endpoint, cluster, event, payload, log) {
|
|
525
779
|
const clusterName = getBehavior(endpoint, cluster)?.id;
|
|
526
780
|
if (!clusterName) {
|
|
@@ -531,58 +785,120 @@ export async function triggerEvent(endpoint, cluster, event, payload, log) {
|
|
|
531
785
|
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`);
|
|
532
786
|
return false;
|
|
533
787
|
}
|
|
788
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
534
789
|
const events = endpoint.events;
|
|
535
790
|
if (!(clusterName in events) || !(event in events[clusterName])) {
|
|
536
791
|
endpoint.log.error(`triggerEvent ${hk}${event}${er} error: cluster ${clusterName} not found on endpoint ${or}${endpoint.id}${er}:${or}${endpoint.number}${er}`);
|
|
537
792
|
return false;
|
|
538
793
|
}
|
|
794
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
795
|
+
// @ts-ignore
|
|
539
796
|
await endpoint.act((agent) => agent[clusterName].events[event].emit(payload, agent.context));
|
|
540
797
|
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} `);
|
|
541
798
|
return true;
|
|
542
799
|
}
|
|
800
|
+
/** Utility Cluster Helpers */
|
|
801
|
+
/**
|
|
802
|
+
* Get the default power source wired cluster server options.
|
|
803
|
+
*
|
|
804
|
+
* @param {PowerSource.WiredCurrentType} wiredCurrentType - The type of wired current (default: PowerSource.WiredCurrentType.Ac)
|
|
805
|
+
* @returns {Behavior.Options<PowerSourceClusterServer>} The options for the power source wired cluster server.
|
|
806
|
+
*
|
|
807
|
+
* @remarks
|
|
808
|
+
* - order: The order of the power source is a persisted attribute that indicates the order in which the power sources are used.
|
|
809
|
+
* - description: The description of the power source is a fixed attribute that describes the power source type.
|
|
810
|
+
* - 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).
|
|
811
|
+
*/
|
|
543
812
|
export function getDefaultPowerSourceWiredClusterServer(wiredCurrentType = PowerSource.WiredCurrentType.Ac) {
|
|
544
813
|
return optionsFor(MatterbridgePowerSourceServer.with(PowerSource.Feature.Wired), {
|
|
814
|
+
// Base attributes
|
|
545
815
|
status: PowerSource.PowerSourceStatus.Active,
|
|
546
816
|
order: 0,
|
|
547
817
|
description: wiredCurrentType === PowerSource.WiredCurrentType.Ac ? 'AC Power' : 'DC Power',
|
|
548
|
-
endpointList: [],
|
|
818
|
+
endpointList: [], // Will be filled by the MatterbridgePowerSourceServer
|
|
819
|
+
// Wired feature attributes
|
|
549
820
|
wiredCurrentType,
|
|
550
821
|
});
|
|
551
822
|
}
|
|
823
|
+
/**
|
|
824
|
+
* Get the default power source replaceable battery cluster server options.
|
|
825
|
+
*
|
|
826
|
+
* @param {number} batPercentRemaining - The remaining battery percentage (default: 100). The attribute is in the range 0-200.
|
|
827
|
+
* @param {PowerSource.BatChargeLevel} batChargeLevel - The battery charge level (default: PowerSource.BatChargeLevel.Ok).
|
|
828
|
+
* @param {number} batVoltage - The battery voltage (default: 1500).
|
|
829
|
+
* @param {string} batReplacementDescription - The description of the battery replacement (default: 'Battery type').
|
|
830
|
+
* @param {number} batQuantity - The quantity of the battery (default: 1).
|
|
831
|
+
* @param {PowerSource.BatReplaceability} batReplaceability - The replaceability of the battery (default: PowerSource.BatReplaceability.Unspecified).
|
|
832
|
+
* @returns {Behavior.Options<PowerSourceClusterServer>} The options for the power source replaceable battery cluster server.
|
|
833
|
+
*
|
|
834
|
+
* @remarks
|
|
835
|
+
* - order: The order of the power source is a persisted attribute that indicates the order in which the power sources are used.
|
|
836
|
+
* - description: The description of the power source is a fixed attribute that describes the power source type.
|
|
837
|
+
* - batReplaceability: The replaceability of the battery is a fixed attribute that indicates whether the battery is user-replaceable or not.
|
|
838
|
+
* - batReplacementDescription: The description of the battery replacement is a fixed attribute that describes the battery type.
|
|
839
|
+
* - batQuantity: The quantity of the battery is a fixed attribute that indicates how many batteries are present in the device.
|
|
840
|
+
*/
|
|
552
841
|
export function getDefaultPowerSourceReplaceableBatteryClusterServer(batPercentRemaining = 100, batChargeLevel = PowerSource.BatChargeLevel.Ok, batVoltage = 1500, batReplacementDescription = 'Battery type', batQuantity = 1, batReplaceability = PowerSource.BatReplaceability.UserReplaceable) {
|
|
553
842
|
return optionsFor(MatterbridgePowerSourceServer.with(PowerSource.Feature.Battery, PowerSource.Feature.Replaceable), {
|
|
843
|
+
// Base attributes
|
|
554
844
|
status: PowerSource.PowerSourceStatus.Active,
|
|
555
845
|
order: 0,
|
|
556
846
|
description: 'Primary battery',
|
|
557
|
-
endpointList: [],
|
|
847
|
+
endpointList: [], // Will be filled by the MatterbridgePowerSourceServer
|
|
848
|
+
// Battery feature attributes
|
|
558
849
|
batVoltage,
|
|
559
850
|
batPercentRemaining: Math.min(Math.max(batPercentRemaining * 2, 0), 200),
|
|
560
851
|
batChargeLevel,
|
|
561
852
|
batReplacementNeeded: false,
|
|
562
853
|
batReplaceability,
|
|
563
854
|
activeBatFaults: undefined,
|
|
855
|
+
// Replaceable feature attributes
|
|
564
856
|
batReplacementDescription,
|
|
565
857
|
batQuantity,
|
|
566
858
|
});
|
|
567
859
|
}
|
|
860
|
+
/**
|
|
861
|
+
* Creates a default power source rechargeable battery cluster server.
|
|
862
|
+
*
|
|
863
|
+
* @param {number} [batPercentRemaining] - The remaining battery percentage (default: 100). The attribute is in the range 0-200.
|
|
864
|
+
* @param {PowerSource.BatChargeLevel} [batChargeLevel] - The battery charge level (default: PowerSource.BatChargeLevel.Ok).
|
|
865
|
+
* @param {number} [batVoltage] - The battery voltage in mV (default: 1500).
|
|
866
|
+
* @param {PowerSource.BatReplaceability} [batReplaceability] - The replaceability of the battery (default: PowerSource.BatReplaceability.Unspecified).
|
|
867
|
+
* @returns {Behavior.Options<PowerSourceClusterServer>} The options for the power source rechargeable battery cluster server.
|
|
868
|
+
*
|
|
869
|
+
* @remarks
|
|
870
|
+
* - order: The order of the power source is a persisted attribute that indicates the order in which the power sources are used.
|
|
871
|
+
* - description: The description of the power source is a fixed attribute that describes the power source type.
|
|
872
|
+
* - batReplaceability: The replaceability of the battery is a fixed attribute that indicates whether the battery is user-replaceable or not.
|
|
873
|
+
*/
|
|
568
874
|
export function getDefaultPowerSourceRechargeableBatteryClusterServer(batPercentRemaining = 100, batChargeLevel = PowerSource.BatChargeLevel.Ok, batVoltage = 1500, batReplaceability = PowerSource.BatReplaceability.Unspecified) {
|
|
569
875
|
return optionsFor(MatterbridgePowerSourceServer.with(PowerSource.Feature.Battery, PowerSource.Feature.Rechargeable), {
|
|
876
|
+
// Base attributes
|
|
570
877
|
status: PowerSource.PowerSourceStatus.Active,
|
|
571
878
|
order: 0,
|
|
572
879
|
description: 'Primary battery',
|
|
573
|
-
endpointList: [],
|
|
880
|
+
endpointList: [], // Will be filled by the MatterbridgePowerSourceServer
|
|
881
|
+
// Battery feature attributes
|
|
574
882
|
batVoltage,
|
|
575
883
|
batPercentRemaining: Math.min(Math.max(batPercentRemaining * 2, 0), 200),
|
|
576
|
-
batTimeRemaining: null,
|
|
884
|
+
batTimeRemaining: null, // Indicates the estimated time in seconds before the battery will no longer be able to provide power to the Node
|
|
577
885
|
batChargeLevel,
|
|
578
886
|
batReplacementNeeded: false,
|
|
579
887
|
batReplaceability,
|
|
580
888
|
batPresent: true,
|
|
581
889
|
activeBatFaults: [],
|
|
890
|
+
// Rechargeable feature attributes
|
|
582
891
|
batChargeState: PowerSource.BatChargeState.IsNotCharging,
|
|
583
892
|
batFunctionalWhileCharging: true,
|
|
584
893
|
});
|
|
585
894
|
}
|
|
895
|
+
/**
|
|
896
|
+
* Get the default Electrical Energy Measurement Cluster Server options with features ImportedEnergy, ExportedEnergy, and CumulativeEnergy.
|
|
897
|
+
*
|
|
898
|
+
* @param {number} energyImported - The total consumption value in mW/h.
|
|
899
|
+
* @param {number} energyExported - The total production value in mW/h.
|
|
900
|
+
* @returns {Behavior.Options<ElectricalEnergyMeasurementServer>} - The default options for the Electrical Energy Measurement Cluster Server.
|
|
901
|
+
*/
|
|
586
902
|
export function getDefaultElectricalEnergyMeasurementClusterServer(energyImported = null, energyExported = null) {
|
|
587
903
|
return optionsFor(ElectricalEnergyMeasurementServer.with(ElectricalEnergyMeasurement.Feature.ImportedEnergy, ElectricalEnergyMeasurement.Feature.ExportedEnergy, ElectricalEnergyMeasurement.Feature.CumulativeEnergy), {
|
|
588
904
|
accuracy: {
|
|
@@ -597,6 +913,15 @@ export function getDefaultElectricalEnergyMeasurementClusterServer(energyImporte
|
|
|
597
913
|
cumulativeEnergyExported: energyExported !== null && energyExported >= 0 ? { energy: energyExported } : null,
|
|
598
914
|
});
|
|
599
915
|
}
|
|
916
|
+
/**
|
|
917
|
+
* Get the default Electrical Power Measurement Cluster Server options with features AlternatingCurrent.
|
|
918
|
+
*
|
|
919
|
+
* @param {number} voltage - The voltage value in millivolts.
|
|
920
|
+
* @param {number} current - The current value in milliamperes.
|
|
921
|
+
* @param {number} power - The power value in milliwatts.
|
|
922
|
+
* @param {number} frequency - The frequency value in millihertz.
|
|
923
|
+
* @returns {Behavior.Options<ElectricalPowerMeasurementServer>} - The default options for the Electrical Power Measurement Cluster Server.
|
|
924
|
+
*/
|
|
600
925
|
export function getDefaultElectricalPowerMeasurementClusterServer(voltage = null, current = null, power = null, frequency = null) {
|
|
601
926
|
return optionsFor(ElectricalPowerMeasurementServer.with(ElectricalPowerMeasurement.Feature.AlternatingCurrent), {
|
|
602
927
|
powerMode: ElectricalPowerMeasurement.PowerMode.Ac,
|
|
@@ -637,6 +962,15 @@ export function getDefaultElectricalPowerMeasurementClusterServer(voltage = null
|
|
|
637
962
|
frequency: frequency,
|
|
638
963
|
});
|
|
639
964
|
}
|
|
965
|
+
/**
|
|
966
|
+
* Get the default Electrical Apparent Power Measurement Cluster Server with features AlternatingCurrent.
|
|
967
|
+
*
|
|
968
|
+
* @param {number} voltage - The voltage value in millivolts.
|
|
969
|
+
* @param {number} apparentCurrent - The current value in milliamperes.
|
|
970
|
+
* @param {number} apparentPower - The apparent power value in millivoltamperes.
|
|
971
|
+
* @param {number} frequency - The frequency value in millihertz.
|
|
972
|
+
* @returns {Behavior.Options<ElectricalPowerMeasurementServer>} - The default options for the Electrical Apparent Power Measurement Cluster Server.
|
|
973
|
+
*/
|
|
640
974
|
export function getApparentElectricalPowerMeasurementClusterServer(voltage = null, apparentCurrent = null, apparentPower = null, frequency = null) {
|
|
641
975
|
return optionsFor(ElectricalPowerMeasurementServer.with(ElectricalPowerMeasurement.Feature.AlternatingCurrent), {
|
|
642
976
|
powerMode: ElectricalPowerMeasurement.PowerMode.Ac,
|
|
@@ -677,18 +1011,53 @@ export function getApparentElectricalPowerMeasurementClusterServer(voltage = nul
|
|
|
677
1011
|
frequency: frequency,
|
|
678
1012
|
});
|
|
679
1013
|
}
|
|
1014
|
+
/**
|
|
1015
|
+
* Get the default Device Energy Management Cluster Server with feature PowerForecastReporting and with the specified ESA type, ESA canGenerate, ESA state, and power limits.
|
|
1016
|
+
*
|
|
1017
|
+
* @param {DeviceEnergyManagement.EsaType} [esaType] - The ESA type. Defaults to `DeviceEnergyManagement.EsaType.Other`.
|
|
1018
|
+
* @param {boolean} [esaCanGenerate] - Indicates if the ESA can generate energy. Defaults to `false`.
|
|
1019
|
+
* @param {DeviceEnergyManagement.EsaState} [esaState] - The ESA state. Defaults to `DeviceEnergyManagement.EsaState.Online`.
|
|
1020
|
+
* @param {number} [absMinPower] - Indicate the minimum electrical power in mw that the ESA can consume when switched on. Defaults to `0` if not provided.
|
|
1021
|
+
* @param {number} [absMaxPower] - Indicate the maximum electrical power in mw that the ESA can consume when switched on. Defaults to `0` if not provided.
|
|
1022
|
+
* @returns {Behavior.Options<DeviceEnergyManagementClusterServer>} - The default options for the Device Energy Management Cluster Server.
|
|
1023
|
+
*
|
|
1024
|
+
* @remarks
|
|
1025
|
+
* - The forecast attribute is set to null, indicating that there is no forecast currently available.
|
|
1026
|
+
* - The ESA type and canGenerate attributes are fixed and cannot be changed after creation.
|
|
1027
|
+
* - The ESA state is set to Online by default.
|
|
1028
|
+
* - The absolute minimum and maximum power attributes are set to 0 by default.
|
|
1029
|
+
* - For example, a battery storage inverter that can charge its battery at a maximum power of 2000W and can
|
|
1030
|
+
* discharge the battery at a maximum power of 3000W, would have a absMinPower: -3000W, absMaxPower: 2000W.
|
|
1031
|
+
*/
|
|
680
1032
|
export function getDefaultDeviceEnergyManagementClusterServer(esaType = DeviceEnergyManagement.EsaType.Other, esaCanGenerate = false, esaState = DeviceEnergyManagement.EsaState.Online, absMinPower = 0, absMaxPower = 0) {
|
|
681
1033
|
return optionsFor(MatterbridgeDeviceEnergyManagementServer.with(DeviceEnergyManagement.Feature.PowerForecastReporting, DeviceEnergyManagement.Feature.PowerAdjustment), {
|
|
682
|
-
esaType,
|
|
683
|
-
esaCanGenerate,
|
|
1034
|
+
esaType, // Fixed attribute
|
|
1035
|
+
esaCanGenerate, // Fixed attribute
|
|
684
1036
|
esaState,
|
|
685
1037
|
absMinPower,
|
|
686
1038
|
absMaxPower,
|
|
687
|
-
|
|
1039
|
+
// PowerAdjustment feature (commands: powerAdjustRequest and cancelPowerAdjustRequest events: powerAdjustStart and powerAdjustEnd)
|
|
1040
|
+
powerAdjustmentCapability: null, // A null value indicates that no power adjustment is currently possible, and nor is any adjustment currently active
|
|
688
1041
|
optOutState: DeviceEnergyManagement.OptOutState.NoOptOut,
|
|
689
|
-
|
|
1042
|
+
// PowerForecastReporting
|
|
1043
|
+
forecast: null, // A null value indicates that there is no forecast currently available
|
|
690
1044
|
});
|
|
691
1045
|
}
|
|
1046
|
+
/**
|
|
1047
|
+
* Get the default EnergyManagementMode Cluster Server.
|
|
1048
|
+
*
|
|
1049
|
+
* @param {number} [currentMode] - The current mode of the EnergyManagementMode cluster. Defaults to mode 1 (DeviceEnergyManagementMode.ModeTag.NoOptimization).
|
|
1050
|
+
* @param {EnergyManagementMode.ModeOption[]} [supportedModes] - The supported modes for the DeviceEnergyManagementMode cluster. The attribute is fixed and defaults to a predefined set of cluster modes.
|
|
1051
|
+
* @returns {Behavior.Options<DeviceEnergyManagementModeClusterServer>} - The default options for the Device Energy Management Mode cluster server.
|
|
1052
|
+
*
|
|
1053
|
+
* @remarks
|
|
1054
|
+
* A few examples of Device Energy Management modes and their mode tags are provided below.
|
|
1055
|
+
* - For the "No Energy Management (Forecast reporting only)" mode, tags: 0x4000 (NoOptimization).
|
|
1056
|
+
* - For the "Device Energy Management" mode, tags: 0x4001 (DeviceOptimization).
|
|
1057
|
+
* - For the "Home Energy Management" mode, tags: 0x4001 (DeviceOptimization), 0x4002 (LocalOptimization).
|
|
1058
|
+
* - For the "Grid Energy Management" mode, tags: 0x4003 (GridOptimization).
|
|
1059
|
+
* - For the "Full Energy Management" mode, tags: 0x4001 (DeviceOptimization), 0x4002 (LocalOptimization), 0x4003 (GridOptimization).
|
|
1060
|
+
*/
|
|
692
1061
|
export function getDefaultDeviceEnergyManagementModeClusterServer(currentMode, supportedModes) {
|
|
693
1062
|
return optionsFor(MatterbridgeDeviceEnergyManagementModeServer, {
|
|
694
1063
|
supportedModes: supportedModes ?? [
|
|
@@ -709,10 +1078,24 @@ export function getDefaultDeviceEnergyManagementModeClusterServer(currentMode, s
|
|
|
709
1078
|
mode: 5,
|
|
710
1079
|
modeTags: [{ value: DeviceEnergyManagementMode.ModeTag.DeviceOptimization }, { value: DeviceEnergyManagementMode.ModeTag.LocalOptimization }, { value: DeviceEnergyManagementMode.ModeTag.GridOptimization }],
|
|
711
1080
|
},
|
|
712
|
-
],
|
|
1081
|
+
], // Fixed attribute
|
|
713
1082
|
currentMode: currentMode ?? 1,
|
|
714
1083
|
});
|
|
715
1084
|
}
|
|
1085
|
+
/** Application Cluster Helpers */
|
|
1086
|
+
/**
|
|
1087
|
+
* Get the default OperationalState Cluster Server.
|
|
1088
|
+
*
|
|
1089
|
+
* @param {OperationalState.OperationalStateEnum} operationalState - The initial operational state id.
|
|
1090
|
+
* @returns {Behavior.Options<MatterbridgeOperationalStateServer>} - The default options for the OperationalState cluster server.
|
|
1091
|
+
*
|
|
1092
|
+
* @remarks
|
|
1093
|
+
* This method adds a cluster server with a default operational state configuration:
|
|
1094
|
+
* - { operationalStateId: OperationalState.OperationalStateEnum.Stopped, operationalStateLabel: 'Stopped' },
|
|
1095
|
+
* - { operationalStateId: OperationalState.OperationalStateEnum.Running, operationalStateLabel: 'Running' },
|
|
1096
|
+
* - { operationalStateId: OperationalState.OperationalStateEnum.Paused, operationalStateLabel: 'Paused' },
|
|
1097
|
+
* - { operationalStateId: OperationalState.OperationalStateEnum.Error, operationalStateLabel: 'Error' },
|
|
1098
|
+
*/
|
|
716
1099
|
export function getDefaultOperationalStateClusterServer(operationalState = OperationalState.OperationalStateEnum.Stopped) {
|
|
717
1100
|
return optionsFor(MatterbridgeOperationalStateServer, {
|
|
718
1101
|
phaseList: [],
|
|
@@ -728,6 +1111,14 @@ export function getDefaultOperationalStateClusterServer(operationalState = Opera
|
|
|
728
1111
|
operationalError: { errorStateId: OperationalState.ErrorState.NoError, errorStateLabel: 'No error', errorStateDetails: 'Fully operational' },
|
|
729
1112
|
});
|
|
730
1113
|
}
|
|
1114
|
+
/**
|
|
1115
|
+
* Get the default TemperatureMeasurement cluster server options.
|
|
1116
|
+
*
|
|
1117
|
+
* @param {number | null} measuredValue - The measured value of the temperature x 100.
|
|
1118
|
+
* @param {number | null} minMeasuredValue - The minimum measured value of the temperature x 100.
|
|
1119
|
+
* @param {number | null} maxMeasuredValue - The maximum measured value of the temperature x 100.
|
|
1120
|
+
* @returns {Behavior.Options<MatterbridgeTemperatureMeasurementServer>} - The default options for the TemperatureMeasurement cluster server.
|
|
1121
|
+
*/
|
|
731
1122
|
export function getDefaultTemperatureMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
732
1123
|
return optionsFor(TemperatureMeasurementServer, {
|
|
733
1124
|
measuredValue,
|
|
@@ -736,6 +1127,14 @@ export function getDefaultTemperatureMeasurementClusterServer(measuredValue = nu
|
|
|
736
1127
|
tolerance: 0,
|
|
737
1128
|
});
|
|
738
1129
|
}
|
|
1130
|
+
/**
|
|
1131
|
+
* Get the default RelativeHumidityMeasurement cluster server options.
|
|
1132
|
+
*
|
|
1133
|
+
* @param {number | null} measuredValue - The measured value of the relative humidity x 100.
|
|
1134
|
+
* @param {number | null} minMeasuredValue - The minimum measured value of the relative humidity x 100.
|
|
1135
|
+
* @param {number | null} maxMeasuredValue - The maximum measured value of the relative humidity x 100.
|
|
1136
|
+
* @returns {Behavior.Options<MatterbridgeRelativeHumidityMeasurementServer>} - The default options for the RelativeHumidityMeasurement cluster server.
|
|
1137
|
+
*/
|
|
739
1138
|
export function getDefaultRelativeHumidityMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
740
1139
|
return optionsFor(RelativeHumidityMeasurementServer, {
|
|
741
1140
|
measuredValue,
|
|
@@ -744,6 +1143,14 @@ export function getDefaultRelativeHumidityMeasurementClusterServer(measuredValue
|
|
|
744
1143
|
tolerance: 0,
|
|
745
1144
|
});
|
|
746
1145
|
}
|
|
1146
|
+
/**
|
|
1147
|
+
* Get the default PressureMeasurement cluster server options.
|
|
1148
|
+
*
|
|
1149
|
+
* @param {number | null} measuredValue - The measured value for the pressure in kPa x 10.
|
|
1150
|
+
* @param {number | null} minMeasuredValue - The minimum measured value for the pressure in kPa x 10.
|
|
1151
|
+
* @param {number | null} maxMeasuredValue - The maximum measured value for the pressure in kPa x 10.
|
|
1152
|
+
* @returns {Behavior.Options<MatterbridgePressureMeasurementServer>} - The default options for the PressureMeasurement cluster server.
|
|
1153
|
+
*/
|
|
747
1154
|
export function getDefaultPressureMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
748
1155
|
return optionsFor(PressureMeasurementServer, {
|
|
749
1156
|
measuredValue,
|
|
@@ -752,6 +1159,21 @@ export function getDefaultPressureMeasurementClusterServer(measuredValue = null,
|
|
|
752
1159
|
tolerance: 0,
|
|
753
1160
|
});
|
|
754
1161
|
}
|
|
1162
|
+
/**
|
|
1163
|
+
* Get the default IlluminanceMeasurement cluster server options.
|
|
1164
|
+
*
|
|
1165
|
+
* @param {number | null} measuredValue - The measured value of illuminance.
|
|
1166
|
+
* @param {number | null} minMeasuredValue - The minimum measured value of illuminance.
|
|
1167
|
+
* @param {number | null} maxMeasuredValue - The maximum measured value of illuminance.
|
|
1168
|
+
* @returns {Behavior.Options<MatterbridgeIlluminanceMeasurementServer>} - The default options for the IlluminanceMeasurement cluster server.
|
|
1169
|
+
*
|
|
1170
|
+
* @remarks The default value for the illuminance measurement is null.
|
|
1171
|
+
* This attribute SHALL indicate the illuminance in Lux (symbol lx) as follows:
|
|
1172
|
+
* • MeasuredValue = 10,000 x log10(illuminance) + 1,
|
|
1173
|
+
* where 1 lx <= illuminance <= 3.576 Mlx, corresponding to a MeasuredValue in the range 1 to 0xFFFE.
|
|
1174
|
+
* • 0 indicates a value of illuminance that is too low to be measured
|
|
1175
|
+
* • null indicates that the illuminance measurement is invalid.
|
|
1176
|
+
*/
|
|
755
1177
|
export function getDefaultIlluminanceMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
756
1178
|
return optionsFor(IlluminanceMeasurementServer, {
|
|
757
1179
|
measuredValue,
|
|
@@ -760,6 +1182,14 @@ export function getDefaultIlluminanceMeasurementClusterServer(measuredValue = nu
|
|
|
760
1182
|
tolerance: 0,
|
|
761
1183
|
});
|
|
762
1184
|
}
|
|
1185
|
+
/**
|
|
1186
|
+
* Get the default FlowMeasurement cluster server options.
|
|
1187
|
+
*
|
|
1188
|
+
* @param {number | null} measuredValue - The measured value of the flow in 10 x m3/h.
|
|
1189
|
+
* @param {number | null} minMeasuredValue - The minimum measured value of the flow in 10 x m3/h.
|
|
1190
|
+
* @param {number | null} maxMeasuredValue - The maximum measured value of the flow in 10 x m3/h.
|
|
1191
|
+
* @returns {Behavior.Options<MatterbridgeFlowMeasurementServer>} - The default options for the FlowMeasurement cluster server.
|
|
1192
|
+
*/
|
|
763
1193
|
export function getDefaultFlowMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
764
1194
|
return optionsFor(FlowMeasurementServer, {
|
|
765
1195
|
measuredValue,
|
|
@@ -768,6 +1198,20 @@ export function getDefaultFlowMeasurementClusterServer(measuredValue = null, min
|
|
|
768
1198
|
tolerance: 0,
|
|
769
1199
|
});
|
|
770
1200
|
}
|
|
1201
|
+
/**
|
|
1202
|
+
* Get the default OccupancySensing cluster server options.
|
|
1203
|
+
*
|
|
1204
|
+
* @param {boolean} occupied - A boolean indicating whether the occupancy is occupied or not. Default is false.
|
|
1205
|
+
* @param {number} holdTime - The hold time in seconds. Default is 30.
|
|
1206
|
+
* @param {number} holdTimeMin - The minimum hold time in seconds. Default is 1.
|
|
1207
|
+
* @param {number} holdTimeMax - The maximum hold time in seconds. Default is 300.
|
|
1208
|
+
* @returns {Behavior.Options<MatterbridgeOccupancySensingServer>} - The default options for the OccupancySensing cluster server.
|
|
1209
|
+
*
|
|
1210
|
+
* @remarks The default value for the occupancy sensor type is PIR.
|
|
1211
|
+
* Servers SHALL set these attributes for backward compatibility with clients implementing a cluster revision <= 4 as
|
|
1212
|
+
* described in OccupancySensorType and OccupancySensorTypeBitmap Attributes.
|
|
1213
|
+
* This replaces the 9 legacy attributes PIROccupiedToUnoccupiedDelay through PhysicalContactUnoccupiedToOccupiedThreshold.
|
|
1214
|
+
*/
|
|
771
1215
|
export function getDefaultOccupancySensingClusterServer(occupied = false, holdTime = 30, holdTimeMin = 1, holdTimeMax = 300) {
|
|
772
1216
|
return optionsFor(OccupancySensingServer.with(OccupancySensing.Feature.PassiveInfrared), {
|
|
773
1217
|
occupancy: { occupied },
|
|
@@ -779,3 +1223,4 @@ export function getDefaultOccupancySensingClusterServer(occupied = false, holdTi
|
|
|
779
1223
|
holdTimeLimits: { holdTimeMin, holdTimeMax, holdTimeDefault: holdTime },
|
|
780
1224
|
});
|
|
781
1225
|
}
|
|
1226
|
+
//# sourceMappingURL=matterbridgeEndpointHelpers.js.map
|