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