matterbridge 3.3.7 → 3.3.8-dev-20251114-9b65e59
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 +37 -0
- package/README-SERVICE-OPT.md +4 -4
- package/README.md +4 -0
- package/dist/broadcastServer.js +1 -93
- package/dist/broadcastServerTypes.js +0 -24
- package/dist/cli.js +1 -97
- package/dist/cliEmitter.js +0 -37
- package/dist/cliHistory.js +0 -38
- package/dist/clusters/export.js +0 -2
- package/dist/defaultConfigSchema.js +0 -24
- package/dist/deviceManager.js +1 -105
- package/dist/devices/airConditioner.js +1 -58
- package/dist/devices/batteryStorage.js +2 -49
- package/dist/devices/cooktop.js +1 -56
- package/dist/devices/dishwasher.js +1 -58
- package/dist/devices/evse.js +11 -75
- package/dist/devices/export.js +0 -5
- package/dist/devices/extractorHood.js +1 -43
- package/dist/devices/heatPump.js +3 -51
- package/dist/devices/laundryDryer.js +4 -63
- package/dist/devices/laundryWasher.js +5 -71
- package/dist/devices/microwaveOven.js +6 -89
- package/dist/devices/oven.js +1 -86
- package/dist/devices/refrigerator.js +2 -104
- package/dist/devices/roboticVacuumCleaner.js +10 -101
- package/dist/devices/solarPower.js +1 -39
- package/dist/devices/speaker.js +1 -85
- package/dist/devices/temperatureControl.js +3 -24
- package/dist/devices/waterHeater.js +3 -83
- package/dist/dgram/coap.js +13 -126
- package/dist/dgram/dgram.js +2 -114
- package/dist/dgram/mb_coap.js +3 -41
- package/dist/dgram/mb_mdns.js +15 -80
- package/dist/dgram/mdns.js +137 -299
- package/dist/dgram/multicast.js +1 -62
- package/dist/dgram/unicast.js +0 -54
- package/dist/frontend.js +40 -452
- package/dist/frontendTypes.js +0 -45
- package/dist/helpers.js +0 -53
- package/dist/index.js +1 -25
- package/dist/jestutils/export.js +1 -0
- package/dist/{utils → jestutils}/jestHelpers.js +167 -175
- package/dist/logger/export.js +0 -1
- package/dist/matter/behaviors.js +0 -2
- package/dist/matter/clusters.js +0 -2
- package/dist/matter/devices.js +0 -2
- package/dist/matter/endpoints.js +0 -2
- package/dist/matter/export.js +0 -3
- package/dist/matter/types.js +0 -3
- package/dist/matterbridge.js +50 -838
- package/dist/matterbridgeAccessoryPlatform.js +0 -37
- package/dist/matterbridgeBehaviors.js +5 -68
- package/dist/matterbridgeDeviceTypes.js +27 -653
- package/dist/matterbridgeDynamicPlatform.js +0 -37
- package/dist/matterbridgeEndpoint.js +73 -1429
- package/dist/matterbridgeEndpointHelpers.js +42 -475
- package/dist/matterbridgeEndpointTypes.js +3 -0
- package/dist/matterbridgePlatform.js +18 -341
- package/dist/matterbridgeTypes.js +0 -26
- package/dist/pluginManager.js +5 -340
- package/dist/shelly.js +7 -168
- package/dist/storage/export.js +0 -1
- package/dist/update.js +0 -69
- package/dist/utils/colorUtils.js +2 -97
- package/dist/utils/commandLine.js +0 -60
- package/dist/utils/copyDirectory.js +1 -38
- package/dist/utils/createDirectory.js +0 -33
- package/dist/utils/createZip.js +2 -47
- package/dist/utils/deepCopy.js +0 -39
- package/dist/utils/deepEqual.js +1 -72
- package/dist/utils/error.js +2 -43
- package/dist/utils/export.js +0 -1
- package/dist/utils/format.js +0 -49
- package/dist/utils/hex.js +0 -124
- package/dist/utils/inspector.js +1 -69
- package/dist/utils/isvalid.js +0 -101
- package/dist/utils/network.js +5 -96
- package/dist/utils/spawn.js +0 -71
- package/dist/utils/tracker.js +1 -64
- package/dist/utils/wait.js +8 -60
- package/npm-shrinkwrap.json +8 -8
- package/package.json +5 -2
- package/scripts/fetch-chip.mjs +100 -0
- package/dist/broadcastServer.d.ts +0 -115
- package/dist/broadcastServer.d.ts.map +0 -1
- package/dist/broadcastServer.js.map +0 -1
- package/dist/broadcastServerTypes.d.ts +0 -806
- package/dist/broadcastServerTypes.d.ts.map +0 -1
- package/dist/broadcastServerTypes.js.map +0 -1
- package/dist/cli.d.ts +0 -30
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/cliEmitter.d.ts +0 -50
- package/dist/cliEmitter.d.ts.map +0 -1
- package/dist/cliEmitter.js.map +0 -1
- package/dist/cliHistory.d.ts +0 -48
- package/dist/cliHistory.d.ts.map +0 -1
- package/dist/cliHistory.js.map +0 -1
- package/dist/clusters/export.d.ts +0 -2
- package/dist/clusters/export.d.ts.map +0 -1
- package/dist/clusters/export.js.map +0 -1
- package/dist/defaultConfigSchema.d.ts +0 -28
- package/dist/defaultConfigSchema.d.ts.map +0 -1
- package/dist/defaultConfigSchema.js.map +0 -1
- package/dist/deviceManager.d.ts +0 -128
- package/dist/deviceManager.d.ts.map +0 -1
- package/dist/deviceManager.js.map +0 -1
- package/dist/devices/airConditioner.d.ts +0 -98
- package/dist/devices/airConditioner.d.ts.map +0 -1
- package/dist/devices/airConditioner.js.map +0 -1
- package/dist/devices/batteryStorage.d.ts +0 -48
- package/dist/devices/batteryStorage.d.ts.map +0 -1
- package/dist/devices/batteryStorage.js.map +0 -1
- package/dist/devices/cooktop.d.ts +0 -60
- package/dist/devices/cooktop.d.ts.map +0 -1
- package/dist/devices/cooktop.js.map +0 -1
- package/dist/devices/dishwasher.d.ts +0 -71
- package/dist/devices/dishwasher.d.ts.map +0 -1
- package/dist/devices/dishwasher.js.map +0 -1
- package/dist/devices/evse.d.ts +0 -76
- package/dist/devices/evse.d.ts.map +0 -1
- package/dist/devices/evse.js.map +0 -1
- package/dist/devices/export.d.ts +0 -17
- package/dist/devices/export.d.ts.map +0 -1
- package/dist/devices/export.js.map +0 -1
- package/dist/devices/extractorHood.d.ts +0 -46
- package/dist/devices/extractorHood.d.ts.map +0 -1
- package/dist/devices/extractorHood.js.map +0 -1
- package/dist/devices/heatPump.d.ts +0 -47
- package/dist/devices/heatPump.d.ts.map +0 -1
- package/dist/devices/heatPump.js.map +0 -1
- package/dist/devices/laundryDryer.d.ts +0 -67
- package/dist/devices/laundryDryer.d.ts.map +0 -1
- package/dist/devices/laundryDryer.js.map +0 -1
- package/dist/devices/laundryWasher.d.ts +0 -81
- package/dist/devices/laundryWasher.d.ts.map +0 -1
- package/dist/devices/laundryWasher.js.map +0 -1
- package/dist/devices/microwaveOven.d.ts +0 -168
- package/dist/devices/microwaveOven.d.ts.map +0 -1
- package/dist/devices/microwaveOven.js.map +0 -1
- package/dist/devices/oven.d.ts +0 -105
- package/dist/devices/oven.d.ts.map +0 -1
- package/dist/devices/oven.js.map +0 -1
- package/dist/devices/refrigerator.d.ts +0 -118
- package/dist/devices/refrigerator.d.ts.map +0 -1
- package/dist/devices/refrigerator.js.map +0 -1
- package/dist/devices/roboticVacuumCleaner.d.ts +0 -112
- package/dist/devices/roboticVacuumCleaner.d.ts.map +0 -1
- package/dist/devices/roboticVacuumCleaner.js.map +0 -1
- package/dist/devices/solarPower.d.ts +0 -40
- package/dist/devices/solarPower.d.ts.map +0 -1
- package/dist/devices/solarPower.js.map +0 -1
- package/dist/devices/speaker.d.ts +0 -87
- package/dist/devices/speaker.d.ts.map +0 -1
- package/dist/devices/speaker.js.map +0 -1
- package/dist/devices/temperatureControl.d.ts +0 -166
- package/dist/devices/temperatureControl.d.ts.map +0 -1
- package/dist/devices/temperatureControl.js.map +0 -1
- package/dist/devices/waterHeater.d.ts +0 -111
- package/dist/devices/waterHeater.d.ts.map +0 -1
- package/dist/devices/waterHeater.js.map +0 -1
- package/dist/dgram/coap.d.ts +0 -205
- package/dist/dgram/coap.d.ts.map +0 -1
- package/dist/dgram/coap.js.map +0 -1
- package/dist/dgram/dgram.d.ts +0 -141
- package/dist/dgram/dgram.d.ts.map +0 -1
- package/dist/dgram/dgram.js.map +0 -1
- package/dist/dgram/mb_coap.d.ts +0 -24
- package/dist/dgram/mb_coap.d.ts.map +0 -1
- package/dist/dgram/mb_coap.js.map +0 -1
- package/dist/dgram/mb_mdns.d.ts +0 -24
- package/dist/dgram/mb_mdns.d.ts.map +0 -1
- package/dist/dgram/mb_mdns.js.map +0 -1
- package/dist/dgram/mdns.d.ts +0 -290
- package/dist/dgram/mdns.d.ts.map +0 -1
- package/dist/dgram/mdns.js.map +0 -1
- package/dist/dgram/multicast.d.ts +0 -67
- package/dist/dgram/multicast.d.ts.map +0 -1
- package/dist/dgram/multicast.js.map +0 -1
- package/dist/dgram/unicast.d.ts +0 -56
- package/dist/dgram/unicast.d.ts.map +0 -1
- package/dist/dgram/unicast.js.map +0 -1
- package/dist/frontend.d.ts +0 -238
- package/dist/frontend.d.ts.map +0 -1
- package/dist/frontend.js.map +0 -1
- package/dist/frontendTypes.d.ts +0 -529
- package/dist/frontendTypes.d.ts.map +0 -1
- package/dist/frontendTypes.js.map +0 -1
- package/dist/helpers.d.ts +0 -48
- package/dist/helpers.d.ts.map +0 -1
- package/dist/helpers.js.map +0 -1
- package/dist/index.d.ts +0 -33
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/logger/export.d.ts +0 -2
- package/dist/logger/export.d.ts.map +0 -1
- package/dist/logger/export.js.map +0 -1
- package/dist/matter/behaviors.d.ts +0 -2
- package/dist/matter/behaviors.d.ts.map +0 -1
- package/dist/matter/behaviors.js.map +0 -1
- package/dist/matter/clusters.d.ts +0 -2
- package/dist/matter/clusters.d.ts.map +0 -1
- package/dist/matter/clusters.js.map +0 -1
- package/dist/matter/devices.d.ts +0 -2
- package/dist/matter/devices.d.ts.map +0 -1
- package/dist/matter/devices.js.map +0 -1
- package/dist/matter/endpoints.d.ts +0 -2
- package/dist/matter/endpoints.d.ts.map +0 -1
- package/dist/matter/endpoints.js.map +0 -1
- package/dist/matter/export.d.ts +0 -5
- package/dist/matter/export.d.ts.map +0 -1
- package/dist/matter/export.js.map +0 -1
- package/dist/matter/types.d.ts +0 -3
- package/dist/matter/types.d.ts.map +0 -1
- package/dist/matter/types.js.map +0 -1
- package/dist/matterbridge.d.ts +0 -478
- package/dist/matterbridge.d.ts.map +0 -1
- package/dist/matterbridge.js.map +0 -1
- package/dist/matterbridgeAccessoryPlatform.d.ts +0 -42
- package/dist/matterbridgeAccessoryPlatform.d.ts.map +0 -1
- package/dist/matterbridgeAccessoryPlatform.js.map +0 -1
- package/dist/matterbridgeBehaviors.d.ts +0 -2404
- package/dist/matterbridgeBehaviors.d.ts.map +0 -1
- package/dist/matterbridgeBehaviors.js.map +0 -1
- package/dist/matterbridgeDeviceTypes.d.ts +0 -770
- package/dist/matterbridgeDeviceTypes.d.ts.map +0 -1
- package/dist/matterbridgeDeviceTypes.js.map +0 -1
- package/dist/matterbridgeDynamicPlatform.d.ts +0 -42
- package/dist/matterbridgeDynamicPlatform.d.ts.map +0 -1
- package/dist/matterbridgeDynamicPlatform.js.map +0 -1
- package/dist/matterbridgeEndpoint.d.ts +0 -1556
- package/dist/matterbridgeEndpoint.d.ts.map +0 -1
- package/dist/matterbridgeEndpoint.js.map +0 -1
- package/dist/matterbridgeEndpointHelpers.d.ts +0 -758
- package/dist/matterbridgeEndpointHelpers.d.ts.map +0 -1
- package/dist/matterbridgeEndpointHelpers.js.map +0 -1
- package/dist/matterbridgePlatform.d.ts +0 -402
- package/dist/matterbridgePlatform.d.ts.map +0 -1
- package/dist/matterbridgePlatform.js.map +0 -1
- package/dist/matterbridgeTypes.d.ts +0 -239
- package/dist/matterbridgeTypes.d.ts.map +0 -1
- package/dist/matterbridgeTypes.js.map +0 -1
- package/dist/pluginManager.d.ts +0 -371
- package/dist/pluginManager.d.ts.map +0 -1
- package/dist/pluginManager.js.map +0 -1
- package/dist/shelly.d.ts +0 -174
- package/dist/shelly.d.ts.map +0 -1
- package/dist/shelly.js.map +0 -1
- package/dist/storage/export.d.ts +0 -2
- package/dist/storage/export.d.ts.map +0 -1
- package/dist/storage/export.js.map +0 -1
- package/dist/update.d.ts +0 -75
- package/dist/update.d.ts.map +0 -1
- package/dist/update.js.map +0 -1
- package/dist/utils/colorUtils.d.ts +0 -101
- package/dist/utils/colorUtils.d.ts.map +0 -1
- package/dist/utils/colorUtils.js.map +0 -1
- package/dist/utils/commandLine.d.ts +0 -66
- package/dist/utils/commandLine.d.ts.map +0 -1
- package/dist/utils/commandLine.js.map +0 -1
- package/dist/utils/copyDirectory.d.ts +0 -33
- package/dist/utils/copyDirectory.d.ts.map +0 -1
- package/dist/utils/copyDirectory.js.map +0 -1
- package/dist/utils/createDirectory.d.ts +0 -34
- package/dist/utils/createDirectory.d.ts.map +0 -1
- package/dist/utils/createDirectory.js.map +0 -1
- package/dist/utils/createZip.d.ts +0 -39
- package/dist/utils/createZip.d.ts.map +0 -1
- package/dist/utils/createZip.js.map +0 -1
- package/dist/utils/deepCopy.d.ts +0 -32
- package/dist/utils/deepCopy.d.ts.map +0 -1
- package/dist/utils/deepCopy.js.map +0 -1
- package/dist/utils/deepEqual.d.ts +0 -54
- package/dist/utils/deepEqual.d.ts.map +0 -1
- package/dist/utils/deepEqual.js.map +0 -1
- package/dist/utils/error.d.ts +0 -44
- package/dist/utils/error.d.ts.map +0 -1
- package/dist/utils/error.js.map +0 -1
- package/dist/utils/export.d.ts +0 -13
- package/dist/utils/export.d.ts.map +0 -1
- package/dist/utils/export.js.map +0 -1
- package/dist/utils/format.d.ts +0 -53
- package/dist/utils/format.d.ts.map +0 -1
- package/dist/utils/format.js.map +0 -1
- package/dist/utils/hex.d.ts +0 -89
- package/dist/utils/hex.d.ts.map +0 -1
- package/dist/utils/hex.js.map +0 -1
- package/dist/utils/inspector.d.ts +0 -87
- package/dist/utils/inspector.d.ts.map +0 -1
- package/dist/utils/inspector.js.map +0 -1
- package/dist/utils/isvalid.d.ts +0 -103
- package/dist/utils/isvalid.d.ts.map +0 -1
- package/dist/utils/isvalid.js.map +0 -1
- package/dist/utils/jestHelpers.d.ts +0 -139
- package/dist/utils/jestHelpers.d.ts.map +0 -1
- package/dist/utils/jestHelpers.js.map +0 -1
- package/dist/utils/network.d.ts +0 -101
- package/dist/utils/network.d.ts.map +0 -1
- package/dist/utils/network.js.map +0 -1
- package/dist/utils/spawn.d.ts +0 -35
- package/dist/utils/spawn.d.ts.map +0 -1
- package/dist/utils/spawn.js.map +0 -1
- package/dist/utils/tracker.d.ts +0 -108
- package/dist/utils/tracker.d.ts.map +0 -1
- package/dist/utils/tracker.js.map +0 -1
- package/dist/utils/wait.d.ts +0 -54
- package/dist/utils/wait.d.ts.map +0 -1
- package/dist/utils/wait.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';
|
|
@@ -77,7 +49,6 @@ import { TotalVolatileOrganicCompoundsConcentrationMeasurement } from '@matter/t
|
|
|
77
49
|
import { OperationalState } from '@matter/types/clusters/operational-state';
|
|
78
50
|
import { DeviceEnergyManagement } from '@matter/types/clusters/device-energy-management';
|
|
79
51
|
import { DeviceEnergyManagementMode } from '@matter/types/clusters/device-energy-management-mode';
|
|
80
|
-
// @matter behaviors
|
|
81
52
|
import { PowerSourceServer } from '@matter/node/behaviors/power-source';
|
|
82
53
|
import { UserLabelServer } from '@matter/node/behaviors/user-label';
|
|
83
54
|
import { FixedLabelServer } from '@matter/node/behaviors/fixed-label';
|
|
@@ -107,129 +78,58 @@ import { Pm25ConcentrationMeasurementServer } from '@matter/node/behaviors/pm25-
|
|
|
107
78
|
import { Pm10ConcentrationMeasurementServer } from '@matter/node/behaviors/pm10-concentration-measurement';
|
|
108
79
|
import { RadonConcentrationMeasurementServer } from '@matter/node/behaviors/radon-concentration-measurement';
|
|
109
80
|
import { TotalVolatileOrganicCompoundsConcentrationMeasurementServer } from '@matter/node/behaviors/total-volatile-organic-compounds-concentration-measurement';
|
|
110
|
-
import { DeviceEnergyManagementServer } from '@matter/node/behaviors/device-energy-management';
|
|
111
|
-
// Matterbridge
|
|
112
81
|
import { deepCopy } from './utils/deepCopy.js';
|
|
113
82
|
import { deepEqual } from './utils/deepEqual.js';
|
|
114
83
|
import { isValidArray } from './utils/isvalid.js';
|
|
115
|
-
import { MatterbridgeIdentifyServer, MatterbridgeOnOffServer, MatterbridgeLevelControlServer, MatterbridgeColorControlServer, MatterbridgeLiftWindowCoveringServer, MatterbridgeThermostatServer, MatterbridgeFanControlServer, MatterbridgeDoorLockServer, MatterbridgeModeSelectServer, MatterbridgeValveConfigurationAndControlServer, MatterbridgeSmokeCoAlarmServer, MatterbridgeBooleanStateConfigurationServer, MatterbridgeOperationalStateServer,
|
|
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
|
-
*/
|
|
84
|
+
import { MatterbridgeIdentifyServer, MatterbridgeOnOffServer, MatterbridgeLevelControlServer, MatterbridgeColorControlServer, MatterbridgeLiftWindowCoveringServer, MatterbridgeThermostatServer, MatterbridgeFanControlServer, MatterbridgeDoorLockServer, MatterbridgeModeSelectServer, MatterbridgeValveConfigurationAndControlServer, MatterbridgeSmokeCoAlarmServer, MatterbridgeBooleanStateConfigurationServer, MatterbridgeOperationalStateServer, MatterbridgePowerSourceServer, MatterbridgeDeviceEnergyManagementServer, MatterbridgeDeviceEnergyManagementModeServer, } from './matterbridgeBehaviors.js';
|
|
122
85
|
export function capitalizeFirstLetter(name) {
|
|
123
86
|
if (!name)
|
|
124
87
|
return name;
|
|
125
88
|
return name.charAt(0).toUpperCase() + name.slice(1);
|
|
126
89
|
}
|
|
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
|
-
*/
|
|
133
90
|
export function lowercaseFirstLetter(name) {
|
|
134
91
|
if (!name)
|
|
135
92
|
return name;
|
|
136
93
|
return name.charAt(0).toLowerCase() + name.slice(1);
|
|
137
94
|
}
|
|
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
|
-
*/
|
|
144
95
|
export function checkNotLatinCharacters(deviceName) {
|
|
145
96
|
const nonLatinRegexList = [
|
|
146
|
-
/[\u0400-\u04FF\u0500-\u052F]/,
|
|
147
|
-
/[\u2E80-\u9FFF]/,
|
|
148
|
-
/[\uAC00-\uD7AF]/,
|
|
149
|
-
/[\u0600-\u06FF\u0750-\u077F]/,
|
|
150
|
-
/[\u0590-\u05FF]/,
|
|
151
|
-
/[\u0900-\u097F]/,
|
|
152
|
-
/[\u0E00-\u0E7F]/,
|
|
153
|
-
/[\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]/,
|
|
154
105
|
];
|
|
155
106
|
return nonLatinRegexList.some((regex) => regex.test(deviceName));
|
|
156
107
|
}
|
|
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
|
-
*/
|
|
163
108
|
export function generateUniqueId(deviceName) {
|
|
164
|
-
return createHash('md5').update(deviceName).digest('hex');
|
|
109
|
+
return createHash('md5').update(deviceName).digest('hex');
|
|
165
110
|
}
|
|
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
|
-
*/
|
|
175
111
|
export function createUniqueId(param1, param2, param3, param4) {
|
|
176
112
|
const hash = createHash('md5');
|
|
177
113
|
hash.update(param1 + param2 + param3 + param4);
|
|
178
114
|
return hash.digest('hex');
|
|
179
115
|
}
|
|
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
|
-
*/
|
|
193
116
|
export function featuresFor(endpoint, behavior) {
|
|
194
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
195
117
|
return endpoint.behaviors.supported[lowercaseFirstLetter(behavior)]['cluster']['supportedFeatures'];
|
|
196
118
|
}
|
|
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
|
-
*/
|
|
203
119
|
export function getBehaviourTypesFromClusterServerIds(clusterServerList) {
|
|
204
|
-
// Map Server ClusterId to Behavior.Type
|
|
205
120
|
const behaviorTypes = [];
|
|
206
121
|
clusterServerList.forEach((clusterId) => {
|
|
207
122
|
behaviorTypes.push(getBehaviourTypeFromClusterServerId(clusterId));
|
|
208
123
|
});
|
|
209
124
|
return behaviorTypes;
|
|
210
125
|
}
|
|
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
|
-
*/
|
|
217
126
|
export function getBehaviourTypesFromClusterClientIds(clusterClientList) {
|
|
218
|
-
// Map Client ClusterId to Behavior.Type
|
|
219
127
|
const behaviorTypes = [];
|
|
220
128
|
clusterClientList.forEach((_clusterId) => {
|
|
221
|
-
// behaviorTypes.push(getBehaviourTypeFromClusterClientId(clusterId));
|
|
222
129
|
});
|
|
223
130
|
return behaviorTypes;
|
|
224
131
|
}
|
|
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
|
-
*/
|
|
231
132
|
export function getBehaviourTypeFromClusterServerId(clusterId) {
|
|
232
|
-
// Map ClusterId to Server Behavior.Type
|
|
233
133
|
if (clusterId === PowerSource.Cluster.id)
|
|
234
134
|
return PowerSourceServer.with(PowerSource.Feature.Wired);
|
|
235
135
|
if (clusterId === UserLabel.Cluster.id)
|
|
@@ -315,27 +215,13 @@ export function getBehaviourTypeFromClusterServerId(clusterId) {
|
|
|
315
215
|
if (clusterId === TotalVolatileOrganicCompoundsConcentrationMeasurement.Cluster.id)
|
|
316
216
|
return TotalVolatileOrganicCompoundsConcentrationMeasurementServer.with('NumericMeasurement');
|
|
317
217
|
if (clusterId === DeviceEnergyManagement.Cluster.id)
|
|
318
|
-
return
|
|
218
|
+
return MatterbridgeDeviceEnergyManagementServer.with('PowerForecastReporting');
|
|
319
219
|
if (clusterId === DeviceEnergyManagementMode.Cluster.id)
|
|
320
220
|
return MatterbridgeDeviceEnergyManagementModeServer;
|
|
321
221
|
return MatterbridgeIdentifyServer;
|
|
322
222
|
}
|
|
323
|
-
/**
|
|
324
|
-
* Maps a ClusterId to a Behavior.Type for client clusters.
|
|
325
|
-
*
|
|
326
|
-
* @param {ClusterId} _clusterId - The ClusterId to map.
|
|
327
|
-
*/
|
|
328
223
|
export function getBehaviourTypeFromClusterClientId(_clusterId) {
|
|
329
|
-
// Map ClusterId to Client Behavior.Type
|
|
330
|
-
// return IdentifyClient;
|
|
331
224
|
}
|
|
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
|
-
*/
|
|
339
225
|
export function getBehavior(endpoint, cluster) {
|
|
340
226
|
let behavior;
|
|
341
227
|
if (typeof cluster === 'string') {
|
|
@@ -352,18 +238,6 @@ export function getBehavior(endpoint, cluster) {
|
|
|
352
238
|
}
|
|
353
239
|
return behavior;
|
|
354
240
|
}
|
|
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
|
-
*/
|
|
367
241
|
export async function invokeBehaviorCommand(endpoint, cluster, command, params) {
|
|
368
242
|
const behaviorId = getBehavior(endpoint, cluster)?.id;
|
|
369
243
|
if (!behaviorId) {
|
|
@@ -371,7 +245,6 @@ export async function invokeBehaviorCommand(endpoint, cluster, command, params)
|
|
|
371
245
|
return false;
|
|
372
246
|
}
|
|
373
247
|
await endpoint.act((agent) => {
|
|
374
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
375
248
|
const behavior = agent[behaviorId];
|
|
376
249
|
if (!(command in behavior) || typeof behavior[command] !== 'function') {
|
|
377
250
|
endpoint.log?.error(`invokeBehaviorCommand error: command ${hk}${command}${er} not found on agent for endpoint ${or}${endpoint.maybeId}${er}:${or}${endpoint.maybeNumber}${er}`);
|
|
@@ -381,46 +254,25 @@ export async function invokeBehaviorCommand(endpoint, cluster, command, params)
|
|
|
381
254
|
});
|
|
382
255
|
return true;
|
|
383
256
|
}
|
|
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
|
-
*/
|
|
397
257
|
export async function invokeSubscribeHandler(endpoint, cluster, attribute, newValue, oldValue) {
|
|
398
258
|
const event = attribute + '$Changed';
|
|
399
|
-
const
|
|
400
|
-
if (!
|
|
259
|
+
const behaviorId = getBehavior(endpoint, cluster)?.id;
|
|
260
|
+
if (!behaviorId) {
|
|
401
261
|
endpoint.log.error(`invokeSubscribeHandler ${hk}${event}${er} error: cluster not found on endpoint ${or}${endpoint.maybeId}${er}:${or}${endpoint.maybeNumber}${er}`);
|
|
402
262
|
return false;
|
|
403
263
|
}
|
|
404
264
|
if (endpoint.construction.status !== Lifecycle.Status.Active) {
|
|
405
|
-
endpoint.log.error(`invokeSubscribeHandler ${hk}${
|
|
265
|
+
endpoint.log.error(`invokeSubscribeHandler ${hk}${behaviorId}.${event}${er} error: Endpoint ${or}${endpoint.maybeId}${er}:${or}${endpoint.maybeNumber}${er} is in the ${BLUE}${endpoint.construction.status}${er} state`);
|
|
406
266
|
return false;
|
|
407
267
|
}
|
|
408
268
|
const events = endpoint.events;
|
|
409
|
-
if (!(
|
|
410
|
-
endpoint.log.error(`invokeSubscribeHandler ${hk}${event}${er} error: cluster ${
|
|
269
|
+
if (!(behaviorId in events) || !(event in events[behaviorId])) {
|
|
270
|
+
endpoint.log.error(`invokeSubscribeHandler ${hk}${event}${er} error: cluster ${behaviorId} not found on endpoint ${or}${endpoint.id}${er}:${or}${endpoint.number}${er}`);
|
|
411
271
|
return false;
|
|
412
272
|
}
|
|
413
|
-
|
|
414
|
-
// @ts-ignore
|
|
415
|
-
await endpoint.act((agent) => agent[clusterName].events[event].emit(newValue, oldValue, { ...agent.context, offline: false }));
|
|
273
|
+
await endpoint.act((agent) => agent[behaviorId].events[event].emit(newValue, oldValue, { ...agent.context, offline: false }));
|
|
416
274
|
return true;
|
|
417
275
|
}
|
|
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
|
-
*/
|
|
424
276
|
export function addRequiredClusterServers(endpoint) {
|
|
425
277
|
const requiredServerList = [];
|
|
426
278
|
endpoint.log.debug(`addRequiredClusterServers for ${CYAN}${endpoint.maybeId}${db}`);
|
|
@@ -435,12 +287,6 @@ export function addRequiredClusterServers(endpoint) {
|
|
|
435
287
|
});
|
|
436
288
|
addClusterServers(endpoint, requiredServerList);
|
|
437
289
|
}
|
|
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
|
-
*/
|
|
444
290
|
export function addOptionalClusterServers(endpoint) {
|
|
445
291
|
const optionalServerList = [];
|
|
446
292
|
endpoint.log.debug(`addOptionalClusterServers for ${CYAN}${endpoint.maybeId}${db}`);
|
|
@@ -455,12 +301,6 @@ export function addOptionalClusterServers(endpoint) {
|
|
|
455
301
|
});
|
|
456
302
|
addClusterServers(endpoint, optionalServerList);
|
|
457
303
|
}
|
|
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
|
-
*/
|
|
464
304
|
export function addClusterServers(endpoint, serverList) {
|
|
465
305
|
if (serverList.includes(PowerSource.Cluster.id))
|
|
466
306
|
endpoint.createDefaultPowerSourceWiredClusterServer();
|
|
@@ -541,13 +381,6 @@ export function addClusterServers(endpoint, serverList) {
|
|
|
541
381
|
if (serverList.includes(DeviceEnergyManagementMode.Cluster.id))
|
|
542
382
|
endpoint.createDefaultDeviceEnergyManagementModeClusterServer();
|
|
543
383
|
}
|
|
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
|
-
*/
|
|
551
384
|
export async function addFixedLabel(endpoint, label, value) {
|
|
552
385
|
if (!endpoint.hasClusterServer(FixedLabel.Cluster.id)) {
|
|
553
386
|
endpoint.log.debug(`addFixedLabel: add cluster ${hk}FixedLabel${db}:${hk}fixedLabel${db} with label ${CYAN}${label}${db} value ${CYAN}${value}${db}`);
|
|
@@ -564,13 +397,6 @@ export async function addFixedLabel(endpoint, label, value) {
|
|
|
564
397
|
await endpoint.setAttribute(FixedLabel.Cluster.id, 'labelList', labelList, endpoint.log);
|
|
565
398
|
}
|
|
566
399
|
}
|
|
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
|
-
*/
|
|
574
400
|
export async function addUserLabel(endpoint, label, value) {
|
|
575
401
|
if (!endpoint.hasClusterServer(UserLabel.Cluster.id)) {
|
|
576
402
|
endpoint.log.debug(`addUserLabel: add cluster ${hk}UserLabel${db}:${hk}userLabel${db} with label ${CYAN}${label}${db} value ${CYAN}${value}${db}`);
|
|
@@ -587,48 +413,16 @@ export async function addUserLabel(endpoint, label, value) {
|
|
|
587
413
|
await endpoint.setAttribute(UserLabel.Cluster.id, 'labelList', labelList, endpoint.log);
|
|
588
414
|
}
|
|
589
415
|
}
|
|
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
|
-
*/
|
|
597
416
|
export function optionsFor(type, options) {
|
|
598
417
|
return options;
|
|
599
418
|
}
|
|
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
|
-
*/
|
|
607
419
|
export function getClusterId(endpoint, cluster) {
|
|
608
420
|
return endpoint.behaviors.supported[lowercaseFirstLetter(cluster)]?.schema?.id;
|
|
609
421
|
}
|
|
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
|
-
*/
|
|
618
422
|
export function getAttributeId(endpoint, cluster, attribute) {
|
|
619
423
|
const clusterBehavior = endpoint.behaviors.supported[lowercaseFirstLetter(cluster)];
|
|
620
424
|
return clusterBehavior?.cluster?.attributes[lowercaseFirstLetter(attribute)]?.id;
|
|
621
425
|
}
|
|
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
|
|
632
426
|
export function getAttribute(endpoint, cluster, attribute, log) {
|
|
633
427
|
const clusterName = getBehavior(endpoint, cluster)?.id;
|
|
634
428
|
if (!clusterName) {
|
|
@@ -651,16 +445,6 @@ export function getAttribute(endpoint, cluster, attribute, log) {
|
|
|
651
445
|
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}`);
|
|
652
446
|
return value;
|
|
653
447
|
}
|
|
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
|
-
*/
|
|
664
448
|
export async function setAttribute(endpoint, cluster, attribute, value, log) {
|
|
665
449
|
const clusterName = getBehavior(endpoint, cluster)?.id;
|
|
666
450
|
if (!clusterName) {
|
|
@@ -686,16 +470,6 @@ export async function setAttribute(endpoint, cluster, attribute, value, log) {
|
|
|
686
470
|
`to ${YELLOW}${value !== null && typeof value === 'object' ? debugStringify(value) : value}${db}`);
|
|
687
471
|
return true;
|
|
688
472
|
}
|
|
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
|
-
*/
|
|
699
473
|
export async function updateAttribute(endpoint, cluster, attribute, value, log) {
|
|
700
474
|
const clusterName = getBehavior(endpoint, cluster)?.id;
|
|
701
475
|
if (!clusterName) {
|
|
@@ -726,24 +500,7 @@ export async function updateAttribute(endpoint, cluster, attribute, value, log)
|
|
|
726
500
|
`to ${YELLOW}${value !== null && typeof value === 'object' ? debugStringify(value) : value}${db}`);
|
|
727
501
|
return true;
|
|
728
502
|
}
|
|
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) {
|
|
503
|
+
export async function subscribeAttribute(endpoint, cluster, attribute, listener, log) {
|
|
747
504
|
const clusterName = getBehavior(endpoint, cluster)?.id;
|
|
748
505
|
if (!clusterName) {
|
|
749
506
|
endpoint.log.error(`subscribeAttribute ${hk}${attribute}${er} error: cluster not found on endpoint ${or}${endpoint.maybeId}${er}:${or}${endpoint.maybeNumber}${er}`);
|
|
@@ -753,7 +510,6 @@ listener, log) {
|
|
|
753
510
|
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`);
|
|
754
511
|
await endpoint.construction.ready;
|
|
755
512
|
}
|
|
756
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
757
513
|
const events = endpoint.events;
|
|
758
514
|
attribute = lowercaseFirstLetter(attribute) + '$Changed';
|
|
759
515
|
if (!(clusterName in events) || !(attribute in events[clusterName])) {
|
|
@@ -764,17 +520,6 @@ listener, log) {
|
|
|
764
520
|
log?.info(`${db}Subscribed endpoint ${or}${endpoint.id}${db}:${or}${endpoint.number}${db} attribute ${hk}${capitalizeFirstLetter(clusterName)}${db}.${hk}${attribute}${db}`);
|
|
765
521
|
return true;
|
|
766
522
|
}
|
|
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
|
-
*/
|
|
778
523
|
export async function triggerEvent(endpoint, cluster, event, payload, log) {
|
|
779
524
|
const clusterName = getBehavior(endpoint, cluster)?.id;
|
|
780
525
|
if (!clusterName) {
|
|
@@ -785,120 +530,71 @@ export async function triggerEvent(endpoint, cluster, event, payload, log) {
|
|
|
785
530
|
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`);
|
|
786
531
|
return false;
|
|
787
532
|
}
|
|
788
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
789
533
|
const events = endpoint.events;
|
|
790
534
|
if (!(clusterName in events) || !(event in events[clusterName])) {
|
|
791
535
|
endpoint.log.error(`triggerEvent ${hk}${event}${er} error: cluster ${clusterName} not found on endpoint ${or}${endpoint.id}${er}:${or}${endpoint.number}${er}`);
|
|
792
536
|
return false;
|
|
793
537
|
}
|
|
794
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
795
|
-
// @ts-ignore
|
|
796
538
|
await endpoint.act((agent) => agent[clusterName].events[event].emit(payload, agent.context));
|
|
797
539
|
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} `);
|
|
798
540
|
return true;
|
|
799
541
|
}
|
|
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
|
-
*/
|
|
812
542
|
export function getDefaultPowerSourceWiredClusterServer(wiredCurrentType = PowerSource.WiredCurrentType.Ac) {
|
|
813
543
|
return optionsFor(MatterbridgePowerSourceServer.with(PowerSource.Feature.Wired), {
|
|
814
|
-
// Base attributes
|
|
815
544
|
status: PowerSource.PowerSourceStatus.Active,
|
|
816
545
|
order: 0,
|
|
817
546
|
description: wiredCurrentType === PowerSource.WiredCurrentType.Ac ? 'AC Power' : 'DC Power',
|
|
818
|
-
endpointList: [],
|
|
819
|
-
// Wired feature attributes
|
|
547
|
+
endpointList: [],
|
|
820
548
|
wiredCurrentType,
|
|
821
549
|
});
|
|
822
550
|
}
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
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
|
-
*/
|
|
551
|
+
export function getDefaultPowerSourceBatteryClusterServer(batPercentRemaining = null, batChargeLevel = PowerSource.BatChargeLevel.Ok, batVoltage = null, batReplaceability = PowerSource.BatReplaceability.Unspecified) {
|
|
552
|
+
return optionsFor(MatterbridgePowerSourceServer.with(PowerSource.Feature.Battery), {
|
|
553
|
+
status: PowerSource.PowerSourceStatus.Active,
|
|
554
|
+
order: 0,
|
|
555
|
+
description: 'Primary battery',
|
|
556
|
+
endpointList: [],
|
|
557
|
+
batVoltage,
|
|
558
|
+
batPercentRemaining: batPercentRemaining !== null ? Math.min(Math.max(batPercentRemaining * 2, 0), 200) : null,
|
|
559
|
+
batChargeLevel,
|
|
560
|
+
batReplacementNeeded: false,
|
|
561
|
+
batReplaceability,
|
|
562
|
+
});
|
|
563
|
+
}
|
|
841
564
|
export function getDefaultPowerSourceReplaceableBatteryClusterServer(batPercentRemaining = 100, batChargeLevel = PowerSource.BatChargeLevel.Ok, batVoltage = 1500, batReplacementDescription = 'Battery type', batQuantity = 1, batReplaceability = PowerSource.BatReplaceability.UserReplaceable) {
|
|
842
565
|
return optionsFor(MatterbridgePowerSourceServer.with(PowerSource.Feature.Battery, PowerSource.Feature.Replaceable), {
|
|
843
|
-
// Base attributes
|
|
844
566
|
status: PowerSource.PowerSourceStatus.Active,
|
|
845
567
|
order: 0,
|
|
846
568
|
description: 'Primary battery',
|
|
847
|
-
endpointList: [],
|
|
848
|
-
// Battery feature attributes
|
|
569
|
+
endpointList: [],
|
|
849
570
|
batVoltage,
|
|
850
571
|
batPercentRemaining: Math.min(Math.max(batPercentRemaining * 2, 0), 200),
|
|
851
572
|
batChargeLevel,
|
|
852
573
|
batReplacementNeeded: false,
|
|
853
574
|
batReplaceability,
|
|
854
575
|
activeBatFaults: undefined,
|
|
855
|
-
// Replaceable feature attributes
|
|
856
576
|
batReplacementDescription,
|
|
857
577
|
batQuantity,
|
|
858
578
|
});
|
|
859
579
|
}
|
|
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
|
-
*/
|
|
874
580
|
export function getDefaultPowerSourceRechargeableBatteryClusterServer(batPercentRemaining = 100, batChargeLevel = PowerSource.BatChargeLevel.Ok, batVoltage = 1500, batReplaceability = PowerSource.BatReplaceability.Unspecified) {
|
|
875
581
|
return optionsFor(MatterbridgePowerSourceServer.with(PowerSource.Feature.Battery, PowerSource.Feature.Rechargeable), {
|
|
876
|
-
// Base attributes
|
|
877
582
|
status: PowerSource.PowerSourceStatus.Active,
|
|
878
583
|
order: 0,
|
|
879
584
|
description: 'Primary battery',
|
|
880
|
-
endpointList: [],
|
|
881
|
-
// Battery feature attributes
|
|
585
|
+
endpointList: [],
|
|
882
586
|
batVoltage,
|
|
883
587
|
batPercentRemaining: Math.min(Math.max(batPercentRemaining * 2, 0), 200),
|
|
884
|
-
batTimeRemaining: null,
|
|
588
|
+
batTimeRemaining: null,
|
|
885
589
|
batChargeLevel,
|
|
886
590
|
batReplacementNeeded: false,
|
|
887
591
|
batReplaceability,
|
|
888
592
|
batPresent: true,
|
|
889
593
|
activeBatFaults: [],
|
|
890
|
-
// Rechargeable feature attributes
|
|
891
594
|
batChargeState: PowerSource.BatChargeState.IsNotCharging,
|
|
892
595
|
batFunctionalWhileCharging: true,
|
|
893
596
|
});
|
|
894
597
|
}
|
|
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
|
-
*/
|
|
902
598
|
export function getDefaultElectricalEnergyMeasurementClusterServer(energyImported = null, energyExported = null) {
|
|
903
599
|
return optionsFor(ElectricalEnergyMeasurementServer.with(ElectricalEnergyMeasurement.Feature.ImportedEnergy, ElectricalEnergyMeasurement.Feature.ExportedEnergy, ElectricalEnergyMeasurement.Feature.CumulativeEnergy), {
|
|
904
600
|
accuracy: {
|
|
@@ -913,15 +609,6 @@ export function getDefaultElectricalEnergyMeasurementClusterServer(energyImporte
|
|
|
913
609
|
cumulativeEnergyExported: energyExported !== null && energyExported >= 0 ? { energy: energyExported } : null,
|
|
914
610
|
});
|
|
915
611
|
}
|
|
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
|
-
*/
|
|
925
612
|
export function getDefaultElectricalPowerMeasurementClusterServer(voltage = null, current = null, power = null, frequency = null) {
|
|
926
613
|
return optionsFor(ElectricalPowerMeasurementServer.with(ElectricalPowerMeasurement.Feature.AlternatingCurrent), {
|
|
927
614
|
powerMode: ElectricalPowerMeasurement.PowerMode.Ac,
|
|
@@ -962,15 +649,6 @@ export function getDefaultElectricalPowerMeasurementClusterServer(voltage = null
|
|
|
962
649
|
frequency: frequency,
|
|
963
650
|
});
|
|
964
651
|
}
|
|
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
|
-
*/
|
|
974
652
|
export function getApparentElectricalPowerMeasurementClusterServer(voltage = null, apparentCurrent = null, apparentPower = null, frequency = null) {
|
|
975
653
|
return optionsFor(ElectricalPowerMeasurementServer.with(ElectricalPowerMeasurement.Feature.AlternatingCurrent), {
|
|
976
654
|
powerMode: ElectricalPowerMeasurement.PowerMode.Ac,
|
|
@@ -1011,55 +689,20 @@ export function getApparentElectricalPowerMeasurementClusterServer(voltage = nul
|
|
|
1011
689
|
frequency: frequency,
|
|
1012
690
|
});
|
|
1013
691
|
}
|
|
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
|
-
*/
|
|
1032
692
|
export function getDefaultDeviceEnergyManagementClusterServer(esaType = DeviceEnergyManagement.EsaType.Other, esaCanGenerate = false, esaState = DeviceEnergyManagement.EsaState.Online, absMinPower = 0, absMaxPower = 0) {
|
|
1033
693
|
return optionsFor(MatterbridgeDeviceEnergyManagementServer.with(DeviceEnergyManagement.Feature.PowerForecastReporting, DeviceEnergyManagement.Feature.PowerAdjustment), {
|
|
1034
|
-
esaType,
|
|
1035
|
-
esaCanGenerate,
|
|
694
|
+
esaType,
|
|
695
|
+
esaCanGenerate,
|
|
1036
696
|
esaState,
|
|
1037
697
|
absMinPower,
|
|
1038
698
|
absMaxPower,
|
|
1039
|
-
|
|
1040
|
-
powerAdjustmentCapability: null, // A null value indicates that no power adjustment is currently possible, and nor is any adjustment currently active
|
|
699
|
+
powerAdjustmentCapability: null,
|
|
1041
700
|
optOutState: DeviceEnergyManagement.OptOutState.NoOptOut,
|
|
1042
|
-
|
|
1043
|
-
forecast: null, // A null value indicates that there is no forecast currently available
|
|
701
|
+
forecast: null,
|
|
1044
702
|
});
|
|
1045
703
|
}
|
|
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
|
-
*/
|
|
1061
704
|
export function getDefaultDeviceEnergyManagementModeClusterServer(currentMode, supportedModes) {
|
|
1062
|
-
return optionsFor(MatterbridgeDeviceEnergyManagementModeServer, {
|
|
705
|
+
return optionsFor(MatterbridgeDeviceEnergyManagementModeServer.with(), {
|
|
1063
706
|
supportedModes: supportedModes ?? [
|
|
1064
707
|
{ label: 'No Energy Management (Forecast reporting only)', mode: 1, modeTags: [{ value: DeviceEnergyManagementMode.ModeTag.NoOptimization }] },
|
|
1065
708
|
{
|
|
@@ -1078,26 +721,12 @@ export function getDefaultDeviceEnergyManagementModeClusterServer(currentMode, s
|
|
|
1078
721
|
mode: 5,
|
|
1079
722
|
modeTags: [{ value: DeviceEnergyManagementMode.ModeTag.DeviceOptimization }, { value: DeviceEnergyManagementMode.ModeTag.LocalOptimization }, { value: DeviceEnergyManagementMode.ModeTag.GridOptimization }],
|
|
1080
723
|
},
|
|
1081
|
-
],
|
|
724
|
+
],
|
|
1082
725
|
currentMode: currentMode ?? 1,
|
|
1083
726
|
});
|
|
1084
727
|
}
|
|
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
|
-
*/
|
|
1099
728
|
export function getDefaultOperationalStateClusterServer(operationalState = OperationalState.OperationalStateEnum.Stopped) {
|
|
1100
|
-
return optionsFor(MatterbridgeOperationalStateServer, {
|
|
729
|
+
return optionsFor(MatterbridgeOperationalStateServer.with(), {
|
|
1101
730
|
phaseList: [],
|
|
1102
731
|
currentPhase: null,
|
|
1103
732
|
countdownTime: null,
|
|
@@ -1111,14 +740,6 @@ export function getDefaultOperationalStateClusterServer(operationalState = Opera
|
|
|
1111
740
|
operationalError: { errorStateId: OperationalState.ErrorState.NoError, errorStateLabel: 'No error', errorStateDetails: 'Fully operational' },
|
|
1112
741
|
});
|
|
1113
742
|
}
|
|
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
|
-
*/
|
|
1122
743
|
export function getDefaultTemperatureMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
1123
744
|
return optionsFor(TemperatureMeasurementServer, {
|
|
1124
745
|
measuredValue,
|
|
@@ -1127,14 +748,6 @@ export function getDefaultTemperatureMeasurementClusterServer(measuredValue = nu
|
|
|
1127
748
|
tolerance: 0,
|
|
1128
749
|
});
|
|
1129
750
|
}
|
|
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
|
-
*/
|
|
1138
751
|
export function getDefaultRelativeHumidityMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
1139
752
|
return optionsFor(RelativeHumidityMeasurementServer, {
|
|
1140
753
|
measuredValue,
|
|
@@ -1143,14 +756,6 @@ export function getDefaultRelativeHumidityMeasurementClusterServer(measuredValue
|
|
|
1143
756
|
tolerance: 0,
|
|
1144
757
|
});
|
|
1145
758
|
}
|
|
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
|
-
*/
|
|
1154
759
|
export function getDefaultPressureMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
1155
760
|
return optionsFor(PressureMeasurementServer, {
|
|
1156
761
|
measuredValue,
|
|
@@ -1159,21 +764,6 @@ export function getDefaultPressureMeasurementClusterServer(measuredValue = null,
|
|
|
1159
764
|
tolerance: 0,
|
|
1160
765
|
});
|
|
1161
766
|
}
|
|
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
|
-
*/
|
|
1177
767
|
export function getDefaultIlluminanceMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
1178
768
|
return optionsFor(IlluminanceMeasurementServer, {
|
|
1179
769
|
measuredValue,
|
|
@@ -1182,14 +772,6 @@ export function getDefaultIlluminanceMeasurementClusterServer(measuredValue = nu
|
|
|
1182
772
|
tolerance: 0,
|
|
1183
773
|
});
|
|
1184
774
|
}
|
|
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
|
-
*/
|
|
1193
775
|
export function getDefaultFlowMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
1194
776
|
return optionsFor(FlowMeasurementServer, {
|
|
1195
777
|
measuredValue,
|
|
@@ -1198,20 +780,6 @@ export function getDefaultFlowMeasurementClusterServer(measuredValue = null, min
|
|
|
1198
780
|
tolerance: 0,
|
|
1199
781
|
});
|
|
1200
782
|
}
|
|
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
|
-
*/
|
|
1215
783
|
export function getDefaultOccupancySensingClusterServer(occupied = false, holdTime = 30, holdTimeMin = 1, holdTimeMax = 300) {
|
|
1216
784
|
return optionsFor(OccupancySensingServer.with(OccupancySensing.Feature.PassiveInfrared), {
|
|
1217
785
|
occupancy: { occupied },
|
|
@@ -1223,4 +791,3 @@ export function getDefaultOccupancySensingClusterServer(occupied = false, holdTi
|
|
|
1223
791
|
holdTimeLimits: { holdTimeMin, holdTimeMax, holdTimeDefault: holdTime },
|
|
1224
792
|
});
|
|
1225
793
|
}
|
|
1226
|
-
//# sourceMappingURL=matterbridgeEndpointHelpers.js.map
|