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