matterbridge 3.2.7-dev-20250913-9d0d095 → 3.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -1
- package/dist/cli.d.ts +26 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +91 -2
- package/dist/cli.js.map +1 -0
- package/dist/cliEmitter.d.ts +34 -0
- package/dist/cliEmitter.d.ts.map +1 -0
- package/dist/cliEmitter.js +30 -0
- package/dist/cliEmitter.js.map +1 -0
- package/dist/clusters/export.d.ts +2 -0
- package/dist/clusters/export.d.ts.map +1 -0
- package/dist/clusters/export.js +2 -0
- package/dist/clusters/export.js.map +1 -0
- package/dist/defaultConfigSchema.d.ts +28 -0
- package/dist/defaultConfigSchema.d.ts.map +1 -0
- package/dist/defaultConfigSchema.js +24 -0
- package/dist/defaultConfigSchema.js.map +1 -0
- package/dist/deviceManager.d.ts +112 -0
- package/dist/deviceManager.d.ts.map +1 -0
- package/dist/deviceManager.js +94 -1
- package/dist/deviceManager.js.map +1 -0
- package/dist/devices/airConditioner.d.ts +98 -0
- package/dist/devices/airConditioner.d.ts.map +1 -0
- package/dist/devices/airConditioner.js +57 -0
- package/dist/devices/airConditioner.js.map +1 -0
- package/dist/devices/batteryStorage.d.ts +48 -0
- package/dist/devices/batteryStorage.d.ts.map +1 -0
- package/dist/devices/batteryStorage.js +48 -1
- package/dist/devices/batteryStorage.js.map +1 -0
- package/dist/devices/cooktop.d.ts +60 -0
- package/dist/devices/cooktop.d.ts.map +1 -0
- package/dist/devices/cooktop.js +55 -0
- package/dist/devices/cooktop.js.map +1 -0
- package/dist/devices/dishwasher.d.ts +71 -0
- package/dist/devices/dishwasher.d.ts.map +1 -0
- package/dist/devices/dishwasher.js +57 -0
- package/dist/devices/dishwasher.js.map +1 -0
- package/dist/devices/evse.d.ts +75 -0
- package/dist/devices/evse.d.ts.map +1 -0
- package/dist/devices/evse.js +74 -10
- package/dist/devices/evse.js.map +1 -0
- package/dist/devices/export.d.ts +17 -0
- package/dist/devices/export.d.ts.map +1 -0
- package/dist/devices/export.js +5 -0
- package/dist/devices/export.js.map +1 -0
- package/dist/devices/extractorHood.d.ts +46 -0
- package/dist/devices/extractorHood.d.ts.map +1 -0
- package/dist/devices/extractorHood.js +42 -0
- package/dist/devices/extractorHood.js.map +1 -0
- package/dist/devices/heatPump.d.ts +47 -0
- package/dist/devices/heatPump.d.ts.map +1 -0
- package/dist/devices/heatPump.js +50 -2
- package/dist/devices/heatPump.js.map +1 -0
- package/dist/devices/laundryDryer.d.ts +67 -0
- package/dist/devices/laundryDryer.d.ts.map +1 -0
- package/dist/devices/laundryDryer.js +62 -3
- package/dist/devices/laundryDryer.js.map +1 -0
- package/dist/devices/laundryWasher.d.ts +81 -0
- package/dist/devices/laundryWasher.d.ts.map +1 -0
- package/dist/devices/laundryWasher.js +70 -4
- package/dist/devices/laundryWasher.js.map +1 -0
- package/dist/devices/microwaveOven.d.ts +168 -0
- package/dist/devices/microwaveOven.d.ts.map +1 -0
- package/dist/devices/microwaveOven.js +88 -5
- package/dist/devices/microwaveOven.js.map +1 -0
- package/dist/devices/oven.d.ts +105 -0
- package/dist/devices/oven.d.ts.map +1 -0
- package/dist/devices/oven.js +85 -0
- package/dist/devices/oven.js.map +1 -0
- package/dist/devices/refrigerator.d.ts +118 -0
- package/dist/devices/refrigerator.d.ts.map +1 -0
- package/dist/devices/refrigerator.js +102 -0
- package/dist/devices/refrigerator.js.map +1 -0
- package/dist/devices/roboticVacuumCleaner.d.ts +112 -0
- package/dist/devices/roboticVacuumCleaner.d.ts.map +1 -0
- package/dist/devices/roboticVacuumCleaner.js +100 -9
- package/dist/devices/roboticVacuumCleaner.js.map +1 -0
- package/dist/devices/solarPower.d.ts +40 -0
- package/dist/devices/solarPower.d.ts.map +1 -0
- package/dist/devices/solarPower.js +38 -0
- package/dist/devices/solarPower.js.map +1 -0
- package/dist/devices/speaker.d.ts +87 -0
- package/dist/devices/speaker.d.ts.map +1 -0
- package/dist/devices/speaker.js +84 -0
- package/dist/devices/speaker.js.map +1 -0
- package/dist/devices/temperatureControl.d.ts +166 -0
- package/dist/devices/temperatureControl.d.ts.map +1 -0
- package/dist/devices/temperatureControl.js +25 -3
- package/dist/devices/temperatureControl.js.map +1 -0
- package/dist/devices/waterHeater.d.ts +111 -0
- package/dist/devices/waterHeater.d.ts.map +1 -0
- package/dist/devices/waterHeater.js +82 -2
- package/dist/devices/waterHeater.js.map +1 -0
- package/dist/dgram/coap.d.ts +205 -0
- package/dist/dgram/coap.d.ts.map +1 -0
- package/dist/dgram/coap.js +126 -13
- package/dist/dgram/coap.js.map +1 -0
- package/dist/dgram/dgram.d.ts +141 -0
- package/dist/dgram/dgram.d.ts.map +1 -0
- package/dist/dgram/dgram.js +114 -2
- package/dist/dgram/dgram.js.map +1 -0
- package/dist/dgram/mb_coap.d.ts +24 -0
- package/dist/dgram/mb_coap.d.ts.map +1 -0
- package/dist/dgram/mb_coap.js +41 -3
- package/dist/dgram/mb_coap.js.map +1 -0
- package/dist/dgram/mb_mdns.d.ts +24 -0
- package/dist/dgram/mb_mdns.d.ts.map +1 -0
- package/dist/dgram/mb_mdns.js +80 -15
- package/dist/dgram/mb_mdns.js.map +1 -0
- package/dist/dgram/mdns.d.ts +290 -0
- package/dist/dgram/mdns.d.ts.map +1 -0
- package/dist/dgram/mdns.js +299 -137
- package/dist/dgram/mdns.js.map +1 -0
- package/dist/dgram/multicast.d.ts +67 -0
- package/dist/dgram/multicast.d.ts.map +1 -0
- package/dist/dgram/multicast.js +62 -1
- package/dist/dgram/multicast.js.map +1 -0
- package/dist/dgram/unicast.d.ts +56 -0
- package/dist/dgram/unicast.d.ts.map +1 -0
- package/dist/dgram/unicast.js +54 -0
- package/dist/dgram/unicast.js.map +1 -0
- package/dist/frontend.d.ts +315 -0
- package/dist/frontend.d.ts.map +1 -0
- package/dist/frontend.js +456 -25
- package/dist/frontend.js.map +1 -0
- package/dist/globalMatterbridge.d.ts +59 -0
- package/dist/globalMatterbridge.d.ts.map +1 -0
- package/dist/globalMatterbridge.js +47 -0
- package/dist/globalMatterbridge.js.map +1 -0
- package/dist/helpers.d.ts +48 -0
- package/dist/helpers.d.ts.map +1 -0
- package/dist/helpers.js +53 -0
- package/dist/helpers.js.map +1 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +30 -1
- package/dist/index.js.map +1 -0
- package/dist/logger/export.d.ts +2 -0
- package/dist/logger/export.d.ts.map +1 -0
- package/dist/logger/export.js +1 -0
- package/dist/logger/export.js.map +1 -0
- package/dist/matter/behaviors.d.ts +2 -0
- package/dist/matter/behaviors.d.ts.map +1 -0
- package/dist/matter/behaviors.js +2 -0
- package/dist/matter/behaviors.js.map +1 -0
- package/dist/matter/clusters.d.ts +2 -0
- package/dist/matter/clusters.d.ts.map +1 -0
- package/dist/matter/clusters.js +2 -0
- package/dist/matter/clusters.js.map +1 -0
- package/dist/matter/devices.d.ts +2 -0
- package/dist/matter/devices.d.ts.map +1 -0
- package/dist/matter/devices.js +2 -0
- package/dist/matter/devices.js.map +1 -0
- package/dist/matter/endpoints.d.ts +2 -0
- package/dist/matter/endpoints.d.ts.map +1 -0
- package/dist/matter/endpoints.js +2 -0
- package/dist/matter/endpoints.js.map +1 -0
- package/dist/matter/export.d.ts +5 -0
- package/dist/matter/export.d.ts.map +1 -0
- package/dist/matter/export.js +3 -0
- package/dist/matter/export.js.map +1 -0
- package/dist/matter/types.d.ts +3 -0
- package/dist/matter/types.d.ts.map +1 -0
- package/dist/matter/types.js +3 -0
- package/dist/matter/types.js.map +1 -0
- package/dist/matterbridge.d.ts +465 -0
- package/dist/matterbridge.d.ts.map +1 -0
- package/dist/matterbridge.js +789 -51
- package/dist/matterbridge.js.map +1 -0
- package/dist/matterbridgeAccessoryPlatform.d.ts +42 -0
- package/dist/matterbridgeAccessoryPlatform.d.ts.map +1 -0
- package/dist/matterbridgeAccessoryPlatform.js +36 -0
- package/dist/matterbridgeAccessoryPlatform.js.map +1 -0
- package/dist/matterbridgeBehaviors.d.ts +1747 -0
- package/dist/matterbridgeBehaviors.d.ts.map +1 -0
- package/dist/matterbridgeBehaviors.js +65 -5
- package/dist/matterbridgeBehaviors.js.map +1 -0
- package/dist/matterbridgeDeviceTypes.d.ts +761 -0
- package/dist/matterbridgeDeviceTypes.d.ts.map +1 -0
- package/dist/matterbridgeDeviceTypes.js +630 -17
- package/dist/matterbridgeDeviceTypes.js.map +1 -0
- package/dist/matterbridgeDynamicPlatform.d.ts +42 -0
- package/dist/matterbridgeDynamicPlatform.d.ts.map +1 -0
- package/dist/matterbridgeDynamicPlatform.js +36 -0
- package/dist/matterbridgeDynamicPlatform.js.map +1 -0
- package/dist/matterbridgeEndpoint.d.ts +1515 -0
- package/dist/matterbridgeEndpoint.d.ts.map +1 -0
- package/dist/matterbridgeEndpoint.js +1379 -55
- package/dist/matterbridgeEndpoint.js.map +1 -0
- package/dist/matterbridgeEndpointHelpers.d.ts +407 -0
- package/dist/matterbridgeEndpointHelpers.d.ts.map +1 -0
- package/dist/matterbridgeEndpointHelpers.js +345 -12
- package/dist/matterbridgeEndpointHelpers.js.map +1 -0
- package/dist/matterbridgePlatform.d.ts +380 -0
- package/dist/matterbridgePlatform.d.ts.map +1 -0
- package/dist/matterbridgePlatform.js +304 -0
- package/dist/matterbridgePlatform.js.map +1 -0
- package/dist/matterbridgeTypes.d.ts +204 -0
- package/dist/matterbridgeTypes.d.ts.map +1 -0
- package/dist/matterbridgeTypes.js +25 -0
- package/dist/matterbridgeTypes.js.map +1 -0
- package/dist/pluginManager.d.ts +270 -0
- package/dist/pluginManager.d.ts.map +1 -0
- package/dist/pluginManager.js +249 -3
- package/dist/pluginManager.js.map +1 -0
- package/dist/shelly.d.ts +174 -0
- package/dist/shelly.d.ts.map +1 -0
- package/dist/shelly.js +168 -7
- package/dist/shelly.js.map +1 -0
- package/dist/storage/export.d.ts +2 -0
- package/dist/storage/export.d.ts.map +1 -0
- package/dist/storage/export.js +1 -0
- package/dist/storage/export.js.map +1 -0
- package/dist/update.d.ts +75 -0
- package/dist/update.d.ts.map +1 -0
- package/dist/update.js +69 -0
- package/dist/update.js.map +1 -0
- package/dist/utils/colorUtils.d.ts +99 -0
- package/dist/utils/colorUtils.d.ts.map +1 -0
- package/dist/utils/colorUtils.js +97 -2
- package/dist/utils/colorUtils.js.map +1 -0
- package/dist/utils/commandLine.d.ts +59 -0
- package/dist/utils/commandLine.d.ts.map +1 -0
- package/dist/utils/commandLine.js +54 -0
- package/dist/utils/commandLine.js.map +1 -0
- package/dist/utils/copyDirectory.d.ts +33 -0
- package/dist/utils/copyDirectory.d.ts.map +1 -0
- package/dist/utils/copyDirectory.js +38 -1
- package/dist/utils/copyDirectory.js.map +1 -0
- package/dist/utils/createDirectory.d.ts +34 -0
- package/dist/utils/createDirectory.d.ts.map +1 -0
- package/dist/utils/createDirectory.js +33 -0
- package/dist/utils/createDirectory.js.map +1 -0
- package/dist/utils/createZip.d.ts +39 -0
- package/dist/utils/createZip.d.ts.map +1 -0
- package/dist/utils/createZip.js +47 -2
- package/dist/utils/createZip.js.map +1 -0
- package/dist/utils/deepCopy.d.ts +32 -0
- package/dist/utils/deepCopy.d.ts.map +1 -0
- package/dist/utils/deepCopy.js +39 -0
- package/dist/utils/deepCopy.js.map +1 -0
- package/dist/utils/deepEqual.d.ts +54 -0
- package/dist/utils/deepEqual.d.ts.map +1 -0
- package/dist/utils/deepEqual.js +72 -1
- package/dist/utils/deepEqual.js.map +1 -0
- package/dist/utils/error.d.ts +44 -0
- package/dist/utils/error.d.ts.map +1 -0
- package/dist/utils/error.js +41 -0
- package/dist/utils/error.js.map +1 -0
- package/dist/utils/export.d.ts +13 -0
- package/dist/utils/export.d.ts.map +1 -0
- package/dist/utils/export.js +1 -0
- package/dist/utils/export.js.map +1 -0
- package/dist/utils/hex.d.ts +89 -0
- package/dist/utils/hex.d.ts.map +1 -0
- package/dist/utils/hex.js +124 -0
- package/dist/utils/hex.js.map +1 -0
- package/dist/utils/isvalid.d.ts +103 -0
- package/dist/utils/isvalid.d.ts.map +1 -0
- package/dist/utils/isvalid.js +101 -0
- package/dist/utils/isvalid.js.map +1 -0
- package/dist/utils/jestHelpers.d.ts +137 -0
- package/dist/utils/jestHelpers.d.ts.map +1 -0
- package/dist/utils/jestHelpers.js +153 -3
- package/dist/utils/jestHelpers.js.map +1 -0
- package/dist/utils/network.d.ts +84 -0
- package/dist/utils/network.d.ts.map +1 -0
- package/dist/utils/network.js +91 -5
- package/dist/utils/network.js.map +1 -0
- package/dist/utils/spawn.d.ts +33 -0
- package/dist/utils/spawn.d.ts.map +1 -0
- package/dist/utils/spawn.js +40 -0
- package/dist/utils/spawn.js.map +1 -0
- package/dist/utils/wait.d.ts +54 -0
- package/dist/utils/wait.d.ts.map +1 -0
- package/dist/utils/wait.js +60 -8
- package/dist/utils/wait.js.map +1 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +2 -1
|
@@ -1,5 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file contains the class MatterbridgeEndpoint that extends the Endpoint class from the Matter.js library.
|
|
3
|
+
*
|
|
4
|
+
* @file matterbridgeEndpoint.ts
|
|
5
|
+
* @author Luca Liguori
|
|
6
|
+
* @created 2024-10-01
|
|
7
|
+
* @version 2.1.1
|
|
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
|
+
// @matter
|
|
1
25
|
import { Endpoint, Lifecycle, MutableEndpoint, NamedHandler, SupportedBehaviors, UINT16_MAX, UINT32_MAX, VendorId } from '@matter/main';
|
|
2
26
|
import { getClusterNameById, MeasurementType } from '@matter/main/types';
|
|
27
|
+
// @matter clusters
|
|
3
28
|
import { Descriptor } from '@matter/main/clusters/descriptor';
|
|
4
29
|
import { PowerSource } from '@matter/main/clusters/power-source';
|
|
5
30
|
import { BridgedDeviceBasicInformation } from '@matter/main/clusters/bridged-device-basic-information';
|
|
@@ -26,6 +51,7 @@ import { ThermostatUserInterfaceConfiguration } from '@matter/main/clusters/ther
|
|
|
26
51
|
import { OperationalState } from '@matter/main/clusters/operational-state';
|
|
27
52
|
import { DeviceEnergyManagement } from '@matter/main/clusters/device-energy-management';
|
|
28
53
|
import { DeviceEnergyManagementMode } from '@matter/main/clusters/device-energy-management-mode';
|
|
54
|
+
// @matter behaviors
|
|
29
55
|
import { DescriptorServer } from '@matter/main/behaviors/descriptor';
|
|
30
56
|
import { PowerSourceServer } from '@matter/main/behaviors/power-source';
|
|
31
57
|
import { BridgedDeviceBasicInformationServer } from '@matter/main/behaviors/bridged-device-basic-information';
|
|
@@ -57,16 +83,35 @@ import { TotalVolatileOrganicCompoundsConcentrationMeasurementServer } from '@ma
|
|
|
57
83
|
import { FanControlServer } from '@matter/main/behaviors/fan-control';
|
|
58
84
|
import { ResourceMonitoring } from '@matter/main/clusters/resource-monitoring';
|
|
59
85
|
import { ThermostatUserInterfaceConfigurationServer } from '@matter/main/behaviors/thermostat-user-interface-configuration';
|
|
86
|
+
// AnsiLogger module
|
|
60
87
|
import { AnsiLogger, CYAN, YELLOW, db, debugStringify, hk, or, zb } from './logger/export.js';
|
|
61
88
|
import { isValidNumber, isValidObject, isValidString } from './utils/export.js';
|
|
62
89
|
import { MatterbridgeServer, MatterbridgeIdentifyServer, MatterbridgeOnOffServer, MatterbridgeLevelControlServer, MatterbridgeColorControlServer, MatterbridgeLiftWindowCoveringServer, MatterbridgeLiftTiltWindowCoveringServer, MatterbridgeThermostatServer, MatterbridgeFanControlServer, MatterbridgeDoorLockServer, MatterbridgeModeSelectServer, MatterbridgeValveConfigurationAndControlServer, MatterbridgeSmokeCoAlarmServer, MatterbridgeBooleanStateConfigurationServer, MatterbridgeSwitchServer, MatterbridgeOperationalStateServer, MatterbridgeDeviceEnergyManagementModeServer, MatterbridgeDeviceEnergyManagementServer, MatterbridgeActivatedCarbonFilterMonitoringServer, MatterbridgeHepaFilterMonitoringServer, MatterbridgeEnhancedColorControlServer, } from './matterbridgeBehaviors.js';
|
|
63
90
|
import { addClusterServers, addFixedLabel, addOptionalClusterServers, addRequiredClusterServers, addUserLabel, createUniqueId, getBehavior, getBehaviourTypesFromClusterClientIds, getBehaviourTypesFromClusterServerIds, getDefaultOperationalStateClusterServer, getDefaultFlowMeasurementClusterServer, getDefaultIlluminanceMeasurementClusterServer, getDefaultPressureMeasurementClusterServer, getDefaultRelativeHumidityMeasurementClusterServer, getDefaultTemperatureMeasurementClusterServer, getDefaultOccupancySensingClusterServer, lowercaseFirstLetter, updateAttribute, getClusterId, getAttributeId, setAttribute, getAttribute, checkNotLatinCharacters, generateUniqueId, subscribeAttribute, invokeBehaviorCommand, triggerEvent, featuresFor, } from './matterbridgeEndpointHelpers.js';
|
|
64
91
|
export class MatterbridgeEndpoint extends Endpoint {
|
|
65
|
-
|
|
92
|
+
/** The default log level of the new MatterbridgeEndpoints */
|
|
93
|
+
static logLevel = "info" /* LogLevel.INFO */;
|
|
94
|
+
/**
|
|
95
|
+
* Activates a special mode for this endpoint.
|
|
96
|
+
* - 'server': it creates the device server node and add the device as Matter device that needs to be paired individually.
|
|
97
|
+
* In this case the bridge mode is not relevant. The device is autonomous. The main use case is a workaround for the Apple Home rvc issue.
|
|
98
|
+
*
|
|
99
|
+
* - 'matter': it adds the device directly to the bridge server node as Matter device. In this case the implementation must respect
|
|
100
|
+
* the 9.2.3. Disambiguation rule (i.e. use taglist if needed cause the device doesn't have nodeLabel).
|
|
101
|
+
* Furthermore the device will be a part of the bridge (i.e. will have the same name and will be in the same room).
|
|
102
|
+
* See 9.12.2.2. Native Matter functionality in Bridge.
|
|
103
|
+
*
|
|
104
|
+
* @remarks
|
|
105
|
+
* Always use createDefaultBasicInformationClusterServer() to create the BasicInformation cluster server.
|
|
106
|
+
*/
|
|
66
107
|
mode = undefined;
|
|
108
|
+
/** The server node of the endpoint, if it is a single not bridged endpoint */
|
|
67
109
|
serverNode;
|
|
110
|
+
/** The logger instance for the MatterbridgeEndpoint */
|
|
68
111
|
log;
|
|
112
|
+
/** The plugin name this MatterbridgeEndpoint belongs to */
|
|
69
113
|
plugin = undefined;
|
|
114
|
+
/** The configuration URL of the device, if available */
|
|
70
115
|
configUrl = undefined;
|
|
71
116
|
deviceName = undefined;
|
|
72
117
|
serialNumber = undefined;
|
|
@@ -80,14 +125,28 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
80
125
|
hardwareVersion = undefined;
|
|
81
126
|
hardwareVersionString = undefined;
|
|
82
127
|
productUrl = 'https://www.npmjs.com/package/matterbridge';
|
|
128
|
+
/** The name of the first device type of the endpoint (old api compatibility) */
|
|
83
129
|
name = undefined;
|
|
130
|
+
/** The code of the first device type of the endpoint (old api compatibility) */
|
|
84
131
|
deviceType = undefined;
|
|
132
|
+
/** The original id (with spaces and .) of the endpoint (old api compatibility) */
|
|
85
133
|
uniqueStorageKey = undefined;
|
|
86
134
|
tagList = undefined;
|
|
135
|
+
/** Maps the DeviceTypeDefinitions with their code */
|
|
87
136
|
deviceTypes = new Map();
|
|
137
|
+
/** Command handler for the MatterbridgeEndpoint commands */
|
|
88
138
|
commandHandler = new NamedHandler();
|
|
139
|
+
/**
|
|
140
|
+
* Represents a MatterbridgeEndpoint.
|
|
141
|
+
*
|
|
142
|
+
* @class MatterbridgeEndpoint
|
|
143
|
+
* @param {DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>} definition - The DeviceTypeDefinition(s) of the endpoint.
|
|
144
|
+
* @param {MatterbridgeEndpointOptions} [options] - The options for the device.
|
|
145
|
+
* @param {boolean} [debug] - Debug flag.
|
|
146
|
+
*/
|
|
89
147
|
constructor(definition, options = {}, debug = false) {
|
|
90
148
|
let deviceTypeList = [];
|
|
149
|
+
// Get the first DeviceTypeDefinition
|
|
91
150
|
let firstDefinition;
|
|
92
151
|
if (Array.isArray(definition)) {
|
|
93
152
|
firstDefinition = definition[0];
|
|
@@ -100,6 +159,7 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
100
159
|
firstDefinition = definition;
|
|
101
160
|
deviceTypeList = [{ deviceType: firstDefinition.code, revision: firstDefinition.revision }];
|
|
102
161
|
}
|
|
162
|
+
// Convert the first DeviceTypeDefinition to an EndpointType.Options
|
|
103
163
|
const deviceTypeDefinitionV8 = {
|
|
104
164
|
name: firstDefinition.name.replace('-', '_'),
|
|
105
165
|
deviceType: firstDefinition.code,
|
|
@@ -118,17 +178,20 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
118
178
|
behaviors: options.tagList ? SupportedBehaviors(DescriptorServer.with(Descriptor.Feature.TagList)) : SupportedBehaviors(DescriptorServer),
|
|
119
179
|
};
|
|
120
180
|
const endpointV8 = MutableEndpoint(deviceTypeDefinitionV8);
|
|
181
|
+
// Check if the uniqueStorageKey is valid
|
|
121
182
|
if (options.uniqueStorageKey && checkNotLatinCharacters(options.uniqueStorageKey)) {
|
|
122
183
|
options.uniqueStorageKey = generateUniqueId(options.uniqueStorageKey);
|
|
123
184
|
}
|
|
124
185
|
if (options.id && checkNotLatinCharacters(options.id)) {
|
|
125
186
|
options.id = generateUniqueId(options.id);
|
|
126
187
|
}
|
|
188
|
+
// Convert the options to an Endpoint.Options
|
|
127
189
|
const optionsV8 = {
|
|
128
190
|
id: options.uniqueStorageKey?.replace(/[ .]/g, ''),
|
|
129
191
|
number: options.endpointId,
|
|
130
192
|
descriptor: options.tagList ? { tagList: options.tagList, deviceTypeList } : { deviceTypeList },
|
|
131
193
|
};
|
|
194
|
+
// Override the deprecated uniqueStorageKey && endpointId with id and number if provided
|
|
132
195
|
if (options.id !== undefined) {
|
|
133
196
|
optionsV8.id = options.id.replace(/[ .]/g, '');
|
|
134
197
|
}
|
|
@@ -148,16 +211,53 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
148
211
|
}
|
|
149
212
|
else
|
|
150
213
|
this.deviceTypes.set(firstDefinition.code, firstDefinition);
|
|
151
|
-
|
|
214
|
+
// console.log('MatterbridgeEndpoint.option', options);
|
|
215
|
+
// console.log('MatterbridgeEndpoint.endpointV8', endpointV8);
|
|
216
|
+
// console.log('MatterbridgeEndpoint.optionsV8', optionsV8);
|
|
217
|
+
// Create the logger
|
|
218
|
+
this.log = new AnsiLogger({ logName: options.uniqueStorageKey ?? 'MatterbridgeEndpoint', logTimestampFormat: 4 /* TimestampFormat.TIME_MILLIS */, logLevel: debug === true ? "debug" /* LogLevel.DEBUG */ : MatterbridgeEndpoint.logLevel });
|
|
152
219
|
this.log.debug(`${YELLOW}new${db} MatterbridgeEndpoint: ${zb}${'0x' + firstDefinition.code.toString(16).padStart(4, '0')}${db}-${zb}${firstDefinition.name}${db} mode: ${CYAN}${this.mode}${db} id: ${CYAN}${optionsV8.id}${db} number: ${CYAN}${optionsV8.number}${db} taglist: ${CYAN}${options.tagList ? debugStringify(options.tagList) : 'undefined'}${db}`);
|
|
220
|
+
// Add MatterbridgeServer
|
|
153
221
|
this.behaviors.require(MatterbridgeServer, { log: this.log, commandHandler: this.commandHandler });
|
|
154
222
|
}
|
|
223
|
+
/**
|
|
224
|
+
* Loads an instance of the MatterbridgeEndpoint class.
|
|
225
|
+
*
|
|
226
|
+
* @param {DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>} definition - The DeviceTypeDefinition(s) of the device.
|
|
227
|
+
* @param {MatterbridgeEndpointOptions} [options] - The options for the device.
|
|
228
|
+
* @param {boolean} [debug] - Debug flag.
|
|
229
|
+
* @returns {Promise<MatterbridgeEndpoint>} MatterbridgeEndpoint instance.
|
|
230
|
+
*/
|
|
155
231
|
static async loadInstance(definition, options = {}, debug = false) {
|
|
156
232
|
return new MatterbridgeEndpoint(definition, options, debug);
|
|
157
233
|
}
|
|
234
|
+
/**
|
|
235
|
+
* Get all the device types of this endpoint.
|
|
236
|
+
*
|
|
237
|
+
* @returns {DeviceTypeDefinition[]} The device types of this endpoint.
|
|
238
|
+
*/
|
|
158
239
|
getDeviceTypes() {
|
|
159
240
|
return Array.from(this.deviceTypes.values());
|
|
160
241
|
}
|
|
242
|
+
/**
|
|
243
|
+
* Checks if the provided cluster server is supported by this endpoint.
|
|
244
|
+
*
|
|
245
|
+
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to check.
|
|
246
|
+
* @returns {boolean} True if the cluster server is supported, false otherwise.
|
|
247
|
+
*
|
|
248
|
+
* @example
|
|
249
|
+
*
|
|
250
|
+
* The following examples are all valid ways to check if the 'OnOff' cluster server is supported by the endpoint:
|
|
251
|
+
* ```typescript
|
|
252
|
+
* if(device.hasClusterServer(OnOffBehavior)) ...
|
|
253
|
+
* if(device.hasClusterServer(OnOffServer)) ...
|
|
254
|
+
* if(device.hasClusterServer(OnOffCluster)) ...
|
|
255
|
+
* if(device.hasClusterServer(OnOff.Cluster)) ...
|
|
256
|
+
* if(device.hasClusterServer(OnOff.Cluster.id)) ...
|
|
257
|
+
* if(device.hasClusterServer('OnOff')) ...
|
|
258
|
+
* ```
|
|
259
|
+
* The last has the advantage of being able to check for clusters without imports. Just use the name found in the Matter specs.
|
|
260
|
+
*/
|
|
161
261
|
hasClusterServer(cluster) {
|
|
162
262
|
const behavior = getBehavior(this, cluster);
|
|
163
263
|
if (behavior)
|
|
@@ -165,6 +265,26 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
165
265
|
else
|
|
166
266
|
return false;
|
|
167
267
|
}
|
|
268
|
+
/**
|
|
269
|
+
* Checks if the provided attribute server is supported for a given cluster of this endpoint.
|
|
270
|
+
*
|
|
271
|
+
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to check.
|
|
272
|
+
* @param {string} attribute - The attribute name to check.
|
|
273
|
+
* @returns {boolean} True if the attribute server is supported, false otherwise.
|
|
274
|
+
*
|
|
275
|
+
* @example
|
|
276
|
+
*
|
|
277
|
+
* The following examples are all valid ways to check if the 'onOff' attribute of the 'OnOff' cluster server is supported by the endpoint:
|
|
278
|
+
* ```typescript
|
|
279
|
+
* if(device.hasAttributeServer(OnOffBehavior, 'onOff')) ...
|
|
280
|
+
* if(device.hasAttributeServer(OnOffServer, 'onOff')) ...
|
|
281
|
+
* if(device.hasAttributeServer(OnOffCluster, 'onOff')) ...
|
|
282
|
+
* if(device.hasAttributeServer(OnOff.Cluster, 'onOff')) ...
|
|
283
|
+
* if(device.hasAttributeServer(OnOff.Cluster.id, 'onOff')) ...
|
|
284
|
+
* if(device.hasAttributeServer('OnOff', 'onOff')) ...
|
|
285
|
+
* ```
|
|
286
|
+
* The last has the advantage of being able to check for clusters attributes without imports. Just use the names found in the Matter specs.
|
|
287
|
+
*/
|
|
168
288
|
hasAttributeServer(cluster, attribute) {
|
|
169
289
|
const behavior = getBehavior(this, cluster);
|
|
170
290
|
if (!behavior || !this.behaviors.supported[behavior.id])
|
|
@@ -173,82 +293,279 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
173
293
|
const defaults = this.behaviors.defaultsFor(behavior);
|
|
174
294
|
return lowercaseFirstLetter(attribute) in options || lowercaseFirstLetter(attribute) in defaults;
|
|
175
295
|
}
|
|
296
|
+
/**
|
|
297
|
+
* Retrieves the initial options for the provided cluster server.
|
|
298
|
+
*
|
|
299
|
+
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to get options for.
|
|
300
|
+
* @returns {Record<string, boolean | number | bigint | string | object | null> | undefined} The options for the provided cluster server, or undefined if the cluster is not supported.
|
|
301
|
+
*/
|
|
176
302
|
getClusterServerOptions(cluster) {
|
|
177
303
|
const behavior = getBehavior(this, cluster);
|
|
178
304
|
if (!behavior)
|
|
179
305
|
return undefined;
|
|
180
306
|
return this.behaviors.optionsFor(behavior);
|
|
181
307
|
}
|
|
308
|
+
/**
|
|
309
|
+
* Retrieves the value of the provided attribute from the given cluster.
|
|
310
|
+
*
|
|
311
|
+
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to retrieve the attribute from.
|
|
312
|
+
* @param {string} attribute - The name of the attribute to retrieve.
|
|
313
|
+
* @param {AnsiLogger} [log] - Optional logger for error and info messages.
|
|
314
|
+
* @returns {any} The value of the attribute, or undefined if the attribute is not found.
|
|
315
|
+
*
|
|
316
|
+
* @example
|
|
317
|
+
*
|
|
318
|
+
* The following examples are all valid ways to retrieve the 'onOff' attribute of the 'OnOff' cluster server:
|
|
319
|
+
* ```typescript
|
|
320
|
+
* device.getAttribute(OnOffBehavior, 'onOff')
|
|
321
|
+
* device.getAttribute(OnOffServer, 'onOff')
|
|
322
|
+
* device.getAttribute(OnOffCluster, 'onOff')
|
|
323
|
+
* device.getAttribute(OnOff.Cluster, 'onOff')
|
|
324
|
+
* device.getAttribute(OnOff.Cluster.id, 'onOff')
|
|
325
|
+
* device.getAttribute('OnOff', 'onOff')
|
|
326
|
+
* ```
|
|
327
|
+
* The last has the advantage of being able to retrieve cluster attributes without imports. Just use the names found in the Matter specs.
|
|
328
|
+
*/
|
|
329
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
182
330
|
getAttribute(cluster, attribute, log) {
|
|
183
331
|
return getAttribute(this, cluster, attribute, log);
|
|
184
332
|
}
|
|
333
|
+
/**
|
|
334
|
+
* Sets the value of an attribute on a cluster server.
|
|
335
|
+
*
|
|
336
|
+
* @param {Behavior.Type | ClusterType | ClusterId | string} clusterId - The ID of the cluster.
|
|
337
|
+
* @param {string} attribute - The name of the attribute.
|
|
338
|
+
* @param {boolean | number | bigint | string | object | null} value - The value to set for the attribute.
|
|
339
|
+
* @param {AnsiLogger} [log] - (Optional) The logger to use for logging errors and information.
|
|
340
|
+
* @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the attribute was successfully set.
|
|
341
|
+
*
|
|
342
|
+
* @example
|
|
343
|
+
*
|
|
344
|
+
* The following examples are all valid ways to set the 'onOff' attribute of the 'OnOff' cluster server:
|
|
345
|
+
* ```typescript
|
|
346
|
+
* await device.setAttribute(OnOffBehavior, 'onOff', true)
|
|
347
|
+
* await device.setAttribute(OnOffServer, 'onOff', true)
|
|
348
|
+
* await device.setAttribute(OnOffCluster, 'onOff', true)
|
|
349
|
+
* await device.setAttribute(OnOff.Cluster, 'onOff', true)
|
|
350
|
+
* await device.setAttribute(OnOff.Cluster.id, 'onOff', true)
|
|
351
|
+
* await device.setAttribute('OnOff', 'onOff', true)
|
|
352
|
+
* ```
|
|
353
|
+
* The last has the advantage of being able to set cluster attributes without imports. Just use the names found in the Matter specs.
|
|
354
|
+
*/
|
|
185
355
|
async setAttribute(clusterId, attribute, value, log) {
|
|
186
356
|
return await setAttribute(this, clusterId, attribute, value, log);
|
|
187
357
|
}
|
|
358
|
+
/**
|
|
359
|
+
* Update the value of an attribute on a cluster server only if the value is different.
|
|
360
|
+
*
|
|
361
|
+
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to set the attribute on.
|
|
362
|
+
* @param {string} attribute - The name of the attribute.
|
|
363
|
+
* @param {boolean | number | bigint | string | object | null} value - The value to set for the attribute.
|
|
364
|
+
* @param {AnsiLogger} [log] - (Optional) The logger to use for logging the update. Errors are logged to the endpoint logger.
|
|
365
|
+
* @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the attribute was successfully set.
|
|
366
|
+
*
|
|
367
|
+
* @example
|
|
368
|
+
*
|
|
369
|
+
* The following examples are all valid ways to update the 'onOff' attribute of the 'OnOff' cluster server:
|
|
370
|
+
* ```typescript
|
|
371
|
+
* await device.updateAttribute(OnOffBehavior, 'onOff', true)
|
|
372
|
+
* await device.updateAttribute(OnOffServer, 'onOff', true)
|
|
373
|
+
* await device.updateAttribute(OnOffCluster, 'onOff', true)
|
|
374
|
+
* await device.updateAttribute(OnOff.Cluster, 'onOff', true)
|
|
375
|
+
* await device.updateAttribute(OnOff.Cluster.id, 'onOff', true)
|
|
376
|
+
* await device.updateAttribute('OnOff', 'onOff', true)
|
|
377
|
+
* ```
|
|
378
|
+
* The last has the advantage of being able to update cluster attributes without imports. Just use the names found in the Matter specs.
|
|
379
|
+
*/
|
|
188
380
|
async updateAttribute(cluster, attribute, value, log) {
|
|
189
381
|
return await updateAttribute(this, cluster, attribute, value, log);
|
|
190
382
|
}
|
|
383
|
+
/**
|
|
384
|
+
* Subscribes to the provided attribute on a cluster.
|
|
385
|
+
*
|
|
386
|
+
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to subscribe the attribute to.
|
|
387
|
+
* @param {string} attribute - The name of the attribute to subscribe to.
|
|
388
|
+
* @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.
|
|
389
|
+
* @param {AnsiLogger} [log] - Optional logger for logging errors and information.
|
|
390
|
+
* @returns {Promise<boolean>} - A boolean indicating whether the subscription was successful.
|
|
391
|
+
*
|
|
392
|
+
* @remarks
|
|
393
|
+
* The listener function (cannot be async!) will receive three parameters:
|
|
394
|
+
* - `newValue`: The new value of the attribute.
|
|
395
|
+
* - `oldValue`: The old value of the attribute.
|
|
396
|
+
* - `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.
|
|
397
|
+
*/
|
|
398
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
191
399
|
async subscribeAttribute(cluster, attribute, listener, log) {
|
|
192
400
|
return await subscribeAttribute(this, cluster, attribute, listener, log);
|
|
193
401
|
}
|
|
402
|
+
/**
|
|
403
|
+
* Triggers an event on the specified cluster.
|
|
404
|
+
*
|
|
405
|
+
* @param {ClusterId} cluster - The ID of the cluster.
|
|
406
|
+
* @param {string} event - The name of the event to trigger.
|
|
407
|
+
* @param {Record<string, boolean | number | bigint | string | object | undefined | null>} payload - The payload to pass to the event.
|
|
408
|
+
* @param {AnsiLogger} [log] - Optional logger for logging information.
|
|
409
|
+
* @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the event was successfully triggered.
|
|
410
|
+
*/
|
|
194
411
|
async triggerEvent(cluster, event, payload, log) {
|
|
195
412
|
return await triggerEvent(this, cluster, event, payload, log);
|
|
196
413
|
}
|
|
414
|
+
/**
|
|
415
|
+
* Adds cluster servers from the provided server list.
|
|
416
|
+
*
|
|
417
|
+
* @param {ClusterId[]} serverList - The list of cluster IDs to add.
|
|
418
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
419
|
+
*/
|
|
197
420
|
addClusterServers(serverList) {
|
|
198
421
|
addClusterServers(this, serverList);
|
|
199
422
|
return this;
|
|
200
423
|
}
|
|
424
|
+
/**
|
|
425
|
+
* Adds a fixed label to the FixedLabel cluster. If the cluster server is not present, it will be added.
|
|
426
|
+
*
|
|
427
|
+
* @param {string} label - The label to add.
|
|
428
|
+
* @param {string} value - The value of the label.
|
|
429
|
+
* @returns {Promise<this>} The current MatterbridgeEndpoint instance for chaining.
|
|
430
|
+
*/
|
|
201
431
|
async addFixedLabel(label, value) {
|
|
202
432
|
await addFixedLabel(this, label, value);
|
|
203
433
|
return this;
|
|
204
434
|
}
|
|
435
|
+
/**
|
|
436
|
+
* Adds a user label to the UserLabel cluster. If the cluster server is not present, it will be added.
|
|
437
|
+
*
|
|
438
|
+
* @param {string} label - The label to add.
|
|
439
|
+
* @param {string} value - The value of the label.
|
|
440
|
+
* @returns {Promise<this>} The current MatterbridgeEndpoint instance for chaining.
|
|
441
|
+
*/
|
|
205
442
|
async addUserLabel(label, value) {
|
|
206
443
|
await addUserLabel(this, label, value);
|
|
207
444
|
return this;
|
|
208
445
|
}
|
|
446
|
+
/**
|
|
447
|
+
* Adds a command handler for the specified command.
|
|
448
|
+
*
|
|
449
|
+
* @param {keyof MatterbridgeEndpointCommands} command - The command to add the handler for.
|
|
450
|
+
* @param {CommandHandlerFunction} handler - The handler function to execute when the command is received.
|
|
451
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
452
|
+
*
|
|
453
|
+
* @remarks
|
|
454
|
+
* The handler function will receive an object with the following properties:
|
|
455
|
+
* - `request`: The request object sent with the command.
|
|
456
|
+
* - `cluster`: The id of the cluster that received the command (i.e. "onOff").
|
|
457
|
+
* - `attributes`: The current attributes of the cluster that received the command (i.e. { onOff: true}).
|
|
458
|
+
* - `endpoint`: The MatterbridgeEndpoint instance that received the command.
|
|
459
|
+
*/
|
|
209
460
|
addCommandHandler(command, handler) {
|
|
210
461
|
this.commandHandler.addHandler(command, handler);
|
|
211
462
|
return this;
|
|
212
463
|
}
|
|
464
|
+
/**
|
|
465
|
+
* Execute the command handler for the specified command. Used ONLY in Jest tests.
|
|
466
|
+
*
|
|
467
|
+
* @param {keyof MatterbridgeEndpointCommands} command - The command to execute.
|
|
468
|
+
* @param {Record<string, boolean | number | bigint | string | object | null>} [request] - The optional request to pass to the handler function.
|
|
469
|
+
* @param {string} [cluster] - The optional cluster to pass to the handler function.
|
|
470
|
+
* @param {Record<string, boolean | number | bigint | string | object | null>} [attributes] - The optional attributes to pass to the handler function.
|
|
471
|
+
* @param {MatterbridgeEndpoint} [endpoint] - The optional MatterbridgeEndpoint instance to pass to the handler function
|
|
472
|
+
*
|
|
473
|
+
* @deprecated Used ONLY in Jest tests.
|
|
474
|
+
*/
|
|
213
475
|
async executeCommandHandler(command, request, cluster, attributes, endpoint) {
|
|
214
476
|
await this.commandHandler.executeHandler(command, { request, cluster, attributes, endpoint });
|
|
215
477
|
}
|
|
478
|
+
/**
|
|
479
|
+
* Invokes a behavior command on the specified cluster. Used ONLY in Jest tests.
|
|
480
|
+
*
|
|
481
|
+
* @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to invoke the command on.
|
|
482
|
+
* @param {string} command - The command to invoke.
|
|
483
|
+
* @param {Record<string, boolean | number | bigint | string | object | null>} [params] - The optional parameters to pass to the command.
|
|
484
|
+
*
|
|
485
|
+
* @deprecated Used ONLY in Jest tests.
|
|
486
|
+
*/
|
|
216
487
|
async invokeBehaviorCommand(cluster, command, params) {
|
|
217
488
|
await invokeBehaviorCommand(this, cluster, command, params);
|
|
218
489
|
}
|
|
490
|
+
/**
|
|
491
|
+
* Adds the required cluster servers (only if they are not present) for the device types of the specified endpoint.
|
|
492
|
+
*
|
|
493
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
494
|
+
*/
|
|
219
495
|
addRequiredClusterServers() {
|
|
220
496
|
addRequiredClusterServers(this);
|
|
221
497
|
return this;
|
|
222
498
|
}
|
|
499
|
+
/**
|
|
500
|
+
* Adds the optional cluster servers (only if they are not present) for the device types of the specified endpoint.
|
|
501
|
+
*
|
|
502
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
503
|
+
*/
|
|
223
504
|
addOptionalClusterServers() {
|
|
224
505
|
addOptionalClusterServers(this);
|
|
225
506
|
return this;
|
|
226
507
|
}
|
|
508
|
+
/**
|
|
509
|
+
* Retrieves all cluster servers.
|
|
510
|
+
*
|
|
511
|
+
* @returns {Behavior.Type[]} An array of all cluster servers.
|
|
512
|
+
*/
|
|
227
513
|
getAllClusterServers() {
|
|
228
514
|
return Object.values(this.behaviors.supported);
|
|
229
515
|
}
|
|
516
|
+
/**
|
|
517
|
+
* Retrieves the names of all cluster servers.
|
|
518
|
+
*
|
|
519
|
+
* @returns {string[]} An array of all cluster server names.
|
|
520
|
+
*/
|
|
230
521
|
getAllClusterServerNames() {
|
|
231
522
|
return Object.keys(this.behaviors.supported);
|
|
232
523
|
}
|
|
524
|
+
/**
|
|
525
|
+
* Iterates over each attribute of each cluster server of the device state and calls the provided callback function.
|
|
526
|
+
*
|
|
527
|
+
* @param {Function} callback - The callback function to call with the cluster name, cluster id, attribute name, attribute id and attribute value.
|
|
528
|
+
*/
|
|
233
529
|
forEachAttribute(callback) {
|
|
234
530
|
if (!this.lifecycle.isReady || this.construction.status !== Lifecycle.Status.Active)
|
|
235
531
|
return;
|
|
236
532
|
for (const [clusterName, clusterAttributes] of Object.entries(this.state)) {
|
|
533
|
+
// Skip if the key / cluster name is a number, cause they are double indexed.
|
|
237
534
|
if (!isNaN(Number(clusterName)))
|
|
238
535
|
continue;
|
|
239
536
|
for (const [attributeName, attributeValue] of Object.entries(clusterAttributes)) {
|
|
537
|
+
// Skip if the behavior has no associated cluster (i.e. matterbridge server)
|
|
240
538
|
const clusterId = getClusterId(this, clusterName);
|
|
241
539
|
if (clusterId === undefined) {
|
|
540
|
+
// this.log.debug(`***forEachAttribute: cluster ${clusterName} not found`);
|
|
242
541
|
continue;
|
|
243
542
|
}
|
|
543
|
+
// Skip if the attribute is not present in the ClusterBehavior.Type. Also skip if the attribute it is an internal state.
|
|
244
544
|
const attributeId = getAttributeId(this, clusterName, attributeName);
|
|
245
545
|
if (attributeId === undefined) {
|
|
546
|
+
// this.log.debug(`***forEachAttribute: attribute ${clusterName}.${attributeName} not found`);
|
|
246
547
|
continue;
|
|
247
548
|
}
|
|
248
549
|
callback(clusterName, clusterId, attributeName, attributeId, attributeValue);
|
|
249
550
|
}
|
|
250
551
|
}
|
|
251
552
|
}
|
|
553
|
+
/**
|
|
554
|
+
* Adds a child endpoint with the specified device types and options.
|
|
555
|
+
* If the child endpoint is not already present, it will be created and added.
|
|
556
|
+
* If the child endpoint is already present, the existing child endpoint will be returned.
|
|
557
|
+
*
|
|
558
|
+
* @param {string} endpointName - The name of the new endpoint to add.
|
|
559
|
+
* @param {DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>} definition - The device types to add.
|
|
560
|
+
* @param {MatterbridgeEndpointOptions} [options] - The options for the endpoint.
|
|
561
|
+
* @param {boolean} [debug] - Whether to enable debug logging.
|
|
562
|
+
* @returns {MatterbridgeEndpoint} - The child endpoint that was found or added.
|
|
563
|
+
*
|
|
564
|
+
* @example
|
|
565
|
+
* ```typescript
|
|
566
|
+
* const endpoint = device.addChildDeviceType('Temperature', [temperatureSensor], { tagList: [{ mfgCode: null, namespaceId: LocationTag.Indoor.namespaceId, tag: LocationTag.Indoor.tag, label: null }] }, true);
|
|
567
|
+
* ```
|
|
568
|
+
*/
|
|
252
569
|
addChildDeviceType(endpointName, definition, options = {}, debug = false) {
|
|
253
570
|
this.log.debug(`addChildDeviceType: ${CYAN}${endpointName}${db}`);
|
|
254
571
|
let alreadyAdded = false;
|
|
@@ -288,6 +605,23 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
288
605
|
}
|
|
289
606
|
return child;
|
|
290
607
|
}
|
|
608
|
+
/**
|
|
609
|
+
* Adds a child endpoint with one or more device types with the required cluster servers and the specified cluster servers.
|
|
610
|
+
* If the child endpoint is not already present in the childEndpoints, it will be added.
|
|
611
|
+
* If the child endpoint is already present in the childEndpoints, the device types and cluster servers will be added to the existing child endpoint.
|
|
612
|
+
*
|
|
613
|
+
* @param {string} endpointName - The name of the new enpoint to add.
|
|
614
|
+
* @param {DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>} definition - The device types to add.
|
|
615
|
+
* @param {ClusterId[]} [serverList] - The list of cluster IDs to include.
|
|
616
|
+
* @param {MatterbridgeEndpointOptions} [options] - The options for the device.
|
|
617
|
+
* @param {boolean} [debug] - Whether to enable debug logging.
|
|
618
|
+
* @returns {MatterbridgeEndpoint} - The child endpoint that was found or added.
|
|
619
|
+
*
|
|
620
|
+
* @example
|
|
621
|
+
* ```typescript
|
|
622
|
+
* const endpoint = device.addChildDeviceTypeWithClusterServer('Temperature', [temperatureSensor], [], { tagList: [{ mfgCode: null, namespaceId: LocationTag.Indoor.namespaceId, tag: LocationTag.Indoor.tag, label: null }] }, true);
|
|
623
|
+
* ```
|
|
624
|
+
*/
|
|
291
625
|
addChildDeviceTypeWithClusterServer(endpointName, definition, serverList = [], options = {}, debug = false) {
|
|
292
626
|
this.log.debug(`addChildDeviceTypeWithClusterServer: ${CYAN}${endpointName}${db}`);
|
|
293
627
|
let alreadyAdded = false;
|
|
@@ -350,15 +684,39 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
350
684
|
}
|
|
351
685
|
return child;
|
|
352
686
|
}
|
|
687
|
+
/**
|
|
688
|
+
* Retrieves a child endpoint by its name.
|
|
689
|
+
*
|
|
690
|
+
* @param {string} endpointName - The name of the endpoint to retrieve.
|
|
691
|
+
* @returns {Endpoint | undefined} The child endpoint with the specified name, or undefined if not found.
|
|
692
|
+
*/
|
|
353
693
|
getChildEndpointByName(endpointName) {
|
|
354
694
|
return this.parts.find((part) => part.id === endpointName);
|
|
355
695
|
}
|
|
696
|
+
/**
|
|
697
|
+
* Retrieves a child endpoint by its EndpointNumber.
|
|
698
|
+
*
|
|
699
|
+
* @param {EndpointNumber} endpointNumber - The EndpointNumber of the endpoint to retrieve.
|
|
700
|
+
* @returns {MatterbridgeEndpoint | undefined} The child endpoint with the specified EndpointNumber, or undefined if not found.
|
|
701
|
+
*/
|
|
356
702
|
getChildEndpoint(endpointNumber) {
|
|
357
703
|
return this.parts.find((part) => part.number === endpointNumber);
|
|
358
704
|
}
|
|
705
|
+
/**
|
|
706
|
+
* Get all the child endpoints of this endpoint.
|
|
707
|
+
*
|
|
708
|
+
* @returns {MatterbridgeEndpoint[]} The child endpoints.
|
|
709
|
+
*/
|
|
359
710
|
getChildEndpoints() {
|
|
360
711
|
return Array.from(this.parts);
|
|
361
712
|
}
|
|
713
|
+
/**
|
|
714
|
+
* Serializes the Matterbridge device into a serialized object.
|
|
715
|
+
*
|
|
716
|
+
* @param {MatterbridgeEndpoint} device - The Matterbridge device to serialize.
|
|
717
|
+
*
|
|
718
|
+
* @returns {SerializedMatterbridgeEndpoint | undefined} The serialized Matterbridge device object.
|
|
719
|
+
*/
|
|
362
720
|
static serialize(device) {
|
|
363
721
|
if (!device.serialNumber || !device.deviceName || !device.uniqueId)
|
|
364
722
|
return;
|
|
@@ -381,9 +739,16 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
381
739
|
serialized.clusterServersId.push(BridgedDeviceBasicInformation.Cluster.id);
|
|
382
740
|
if (behaviorName === 'powerSource')
|
|
383
741
|
serialized.clusterServersId.push(PowerSource.Cluster.id);
|
|
742
|
+
// serialized.clusterServersId.push(this.behaviors.supported[behaviorName]cluster.id);
|
|
384
743
|
});
|
|
385
744
|
return serialized;
|
|
386
745
|
}
|
|
746
|
+
/**
|
|
747
|
+
* Deserializes the device into a serialized object.
|
|
748
|
+
*
|
|
749
|
+
* @param {SerializedMatterbridgeEndpoint} serializedDevice - The serialized Matterbridge device object.
|
|
750
|
+
* @returns {MatterbridgeEndpoint | undefined} The deserialized Matterbridge device.
|
|
751
|
+
*/
|
|
387
752
|
static deserialize(serializedDevice) {
|
|
388
753
|
const device = new MatterbridgeEndpoint(serializedDevice.deviceTypes, { uniqueStorageKey: serializedDevice.endpointName, endpointId: serializedDevice.endpoint }, false);
|
|
389
754
|
device.plugin = serializedDevice.pluginName;
|
|
@@ -399,55 +764,126 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
399
764
|
device.createDefaultBridgedDeviceBasicInformationClusterServer(serializedDevice.deviceName, serializedDevice.serialNumber, serializedDevice.vendorId ?? 0xfff1, serializedDevice.vendorName ?? 'Matterbridge', serializedDevice.productName ?? 'Matterbridge device');
|
|
400
765
|
else if (clusterId === PowerSource.Cluster.id)
|
|
401
766
|
device.createDefaultPowerSourceWiredClusterServer();
|
|
767
|
+
// else addClusterServerFromList(device, [clusterId]);
|
|
402
768
|
}
|
|
403
769
|
return device;
|
|
404
770
|
}
|
|
771
|
+
/**
|
|
772
|
+
* Creates a default power source wired cluster server.
|
|
773
|
+
*
|
|
774
|
+
* @param {PowerSource.WiredCurrentType} wiredCurrentType - The type of wired current (default: PowerSource.WiredCurrentType.Ac)
|
|
775
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
776
|
+
*
|
|
777
|
+
* @remarks
|
|
778
|
+
* - order: The order of the power source is a persisted attribute that indicates the order in which the power sources are used.
|
|
779
|
+
* - description: The description of the power source is a fixed attribute that describes the power source type.
|
|
780
|
+
* - 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).
|
|
781
|
+
*/
|
|
405
782
|
createDefaultPowerSourceWiredClusterServer(wiredCurrentType = PowerSource.WiredCurrentType.Ac) {
|
|
406
783
|
this.behaviors.require(PowerSourceServer.with(PowerSource.Feature.Wired), {
|
|
784
|
+
// Base attributes
|
|
407
785
|
status: PowerSource.PowerSourceStatus.Active,
|
|
408
786
|
order: 0,
|
|
409
787
|
description: wiredCurrentType === PowerSource.WiredCurrentType.Ac ? 'AC Power' : 'DC Power',
|
|
410
788
|
endpointList: [],
|
|
789
|
+
// Wired feature attributes
|
|
411
790
|
wiredCurrentType,
|
|
412
791
|
});
|
|
413
792
|
return this;
|
|
414
793
|
}
|
|
794
|
+
/**
|
|
795
|
+
* Creates a default power source replaceable battery cluster server.
|
|
796
|
+
*
|
|
797
|
+
* @param {number} batPercentRemaining - The remaining battery percentage (default: 100).
|
|
798
|
+
* @param {PowerSource.BatChargeLevel} batChargeLevel - The battery charge level (default: PowerSource.BatChargeLevel.Ok).
|
|
799
|
+
* @param {number} batVoltage - The battery voltage (default: 1500).
|
|
800
|
+
* @param {string} batReplacementDescription - The description of the battery replacement (default: 'Battery type').
|
|
801
|
+
* @param {number} batQuantity - The quantity of the battery (default: 1).
|
|
802
|
+
* @param {PowerSource.BatReplaceability} batReplaceability - The replaceability of the battery (default: PowerSource.BatReplaceability.Unspecified).
|
|
803
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
804
|
+
*
|
|
805
|
+
* @remarks
|
|
806
|
+
* - order: The order of the power source is a persisted attribute that indicates the order in which the power sources are used.
|
|
807
|
+
* - description: The description of the power source is a fixed attribute that describes the power source type.
|
|
808
|
+
* - batReplaceability: The replaceability of the battery is a fixed attribute that indicates whether the battery is user-replaceable or not.
|
|
809
|
+
* - batReplacementDescription: The description of the battery replacement is a fixed attribute that describes the battery type.
|
|
810
|
+
* - batQuantity: The quantity of the battery is a fixed attribute that indicates how many batteries are present in the device.
|
|
811
|
+
*/
|
|
415
812
|
createDefaultPowerSourceReplaceableBatteryClusterServer(batPercentRemaining = 100, batChargeLevel = PowerSource.BatChargeLevel.Ok, batVoltage = 1500, batReplacementDescription = 'Battery type', batQuantity = 1, batReplaceability = PowerSource.BatReplaceability.UserReplaceable) {
|
|
416
813
|
this.behaviors.require(PowerSourceServer.with(PowerSource.Feature.Battery, PowerSource.Feature.Replaceable), {
|
|
814
|
+
// Base attributes
|
|
417
815
|
status: PowerSource.PowerSourceStatus.Active,
|
|
418
816
|
order: 0,
|
|
419
817
|
description: 'Primary battery',
|
|
420
818
|
endpointList: [],
|
|
819
|
+
// Battery feature attributes
|
|
421
820
|
batVoltage,
|
|
422
821
|
batPercentRemaining: Math.min(Math.max(batPercentRemaining * 2, 0), 200),
|
|
423
822
|
batChargeLevel,
|
|
424
823
|
batReplacementNeeded: false,
|
|
425
824
|
batReplaceability,
|
|
426
825
|
activeBatFaults: undefined,
|
|
826
|
+
// Replaceable feature attributes
|
|
427
827
|
batReplacementDescription,
|
|
428
828
|
batQuantity,
|
|
429
829
|
});
|
|
430
830
|
return this;
|
|
431
831
|
}
|
|
832
|
+
/**
|
|
833
|
+
* Creates a default power source rechargeable battery cluster server.
|
|
834
|
+
*
|
|
835
|
+
* @param {number} [batPercentRemaining] - The remaining battery percentage (default: 100).
|
|
836
|
+
* @param {PowerSource.BatChargeLevel} [batChargeLevel] - The battery charge level (default: PowerSource.BatChargeLevel.Ok).
|
|
837
|
+
* @param {number} [batVoltage] - The battery voltage in mV (default: 1500).
|
|
838
|
+
* @param {PowerSource.BatReplaceability} [batReplaceability] - The replaceability of the battery (default: PowerSource.BatReplaceability.Unspecified).
|
|
839
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
840
|
+
*
|
|
841
|
+
* @remarks
|
|
842
|
+
* - order: The order of the power source is a persisted attribute that indicates the order in which the power sources are used.
|
|
843
|
+
* - description: The description of the power source is a fixed attribute that describes the power source type.
|
|
844
|
+
* - batReplaceability: The replaceability of the battery is a fixed attribute that indicates whether the battery is user-replaceable or not.
|
|
845
|
+
*/
|
|
432
846
|
createDefaultPowerSourceRechargeableBatteryClusterServer(batPercentRemaining = 100, batChargeLevel = PowerSource.BatChargeLevel.Ok, batVoltage = 1500, batReplaceability = PowerSource.BatReplaceability.Unspecified) {
|
|
433
847
|
this.behaviors.require(PowerSourceServer.with(PowerSource.Feature.Battery, PowerSource.Feature.Rechargeable), {
|
|
848
|
+
// Base attributes
|
|
434
849
|
status: PowerSource.PowerSourceStatus.Active,
|
|
435
850
|
order: 0,
|
|
436
851
|
description: 'Primary battery',
|
|
437
852
|
endpointList: [],
|
|
853
|
+
// Battery feature attributes
|
|
438
854
|
batVoltage,
|
|
439
855
|
batPercentRemaining: Math.min(Math.max(batPercentRemaining * 2, 0), 200),
|
|
440
|
-
batTimeRemaining: null,
|
|
856
|
+
batTimeRemaining: null, // Indicates the estimated time in seconds before the battery will no longer be able to provide power to the Node
|
|
441
857
|
batChargeLevel,
|
|
442
858
|
batReplacementNeeded: false,
|
|
443
859
|
batReplaceability,
|
|
444
860
|
batPresent: true,
|
|
445
861
|
activeBatFaults: [],
|
|
862
|
+
// Rechargeable feature attributes
|
|
446
863
|
batChargeState: PowerSource.BatChargeState.IsNotCharging,
|
|
447
864
|
batFunctionalWhileCharging: true,
|
|
448
865
|
});
|
|
449
866
|
return this;
|
|
450
867
|
}
|
|
868
|
+
/**
|
|
869
|
+
* Setup the default Basic Information Cluster Server attributes for the server node.
|
|
870
|
+
*
|
|
871
|
+
* This method sets the device name, serial number, unique ID, vendor ID, vendor name, product ID, product name, software version, software version string, hardware version and hardware version string.
|
|
872
|
+
*
|
|
873
|
+
* The actual BasicInformationClusterServer is created by the Matterbridge class for device.mode = 'server' and for the device of an AccessoryPlatform.
|
|
874
|
+
*
|
|
875
|
+
* @param {string} deviceName - The name of the device.
|
|
876
|
+
* @param {string} serialNumber - The serial number of the device.
|
|
877
|
+
* @param {number} [vendorId] - The vendor ID of the device. Default is 0xfff1 (Matter Test VendorId).
|
|
878
|
+
* @param {string} [vendorName] - The name of the vendor. Default is 'Matterbridge'.
|
|
879
|
+
* @param {number} [productId] - The product ID of the device. Default is 0x8000 (Matter Test ProductId).
|
|
880
|
+
* @param {string} [productName] - The name of the product. Default is 'Matterbridge device'.
|
|
881
|
+
* @param {number} [softwareVersion] - The software version of the device. Default is 1.
|
|
882
|
+
* @param {string} [softwareVersionString] - The software version string of the device. Default is '1.0.0'.
|
|
883
|
+
* @param {number} [hardwareVersion] - The hardware version of the device. Default is 1.
|
|
884
|
+
* @param {string} [hardwareVersionString] - The hardware version string of the device. Default is '1.0.0'.
|
|
885
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
886
|
+
*/
|
|
451
887
|
createDefaultBasicInformationClusterServer(deviceName, serialNumber, vendorId = 0xfff1, vendorName = 'Matterbridge', productId = 0x8000, productName = 'Matterbridge device', softwareVersion = 1, softwareVersionString = '1.0.0', hardwareVersion = 1, hardwareVersionString = '1.0.0') {
|
|
452
888
|
this.log.logName = deviceName;
|
|
453
889
|
this.deviceName = deviceName;
|
|
@@ -463,6 +899,26 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
463
899
|
this.hardwareVersionString = hardwareVersionString;
|
|
464
900
|
return this;
|
|
465
901
|
}
|
|
902
|
+
/**
|
|
903
|
+
* Creates a default BridgedDeviceBasicInformationClusterServer for the aggregator endpoints.
|
|
904
|
+
*
|
|
905
|
+
* This method sets the device name, serial number, unique ID, vendor ID, vendor name, product name, software version, software version string, hardware version and hardware version string.
|
|
906
|
+
*
|
|
907
|
+
* @param {string} deviceName - The name of the device.
|
|
908
|
+
* @param {string} serialNumber - The serial number of the device.
|
|
909
|
+
* @param {number} [vendorId] - The vendor ID of the device. Default is 0xfff1 (Matter Test VendorId).
|
|
910
|
+
* @param {string} [vendorName] - The name of the vendor. Default is 'Matterbridge'.
|
|
911
|
+
* @param {string} [productName] - The name of the product. Default is 'Matterbridge device'.
|
|
912
|
+
* @param {number} [softwareVersion] - The software version of the device. Default is 1.
|
|
913
|
+
* @param {string} [softwareVersionString] - The software version string of the device. Default is '1.0.0'.
|
|
914
|
+
* @param {number} [hardwareVersion] - The hardware version of the device. Default is 1.
|
|
915
|
+
* @param {string} [hardwareVersionString] - The hardware version string of the device. Default is '1.0.0'.
|
|
916
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
917
|
+
*
|
|
918
|
+
* @remarks
|
|
919
|
+
* - The productId doesn't exist on the BridgedDeviceBasicInformation cluster.
|
|
920
|
+
* - The bridgedNode device type must be added to the deviceTypeList of the Descriptor cluster.
|
|
921
|
+
*/
|
|
466
922
|
createDefaultBridgedDeviceBasicInformationClusterServer(deviceName, serialNumber, vendorId = 0xfff1, vendorName = 'Matterbridge', productName = 'Matterbridge device', softwareVersion = 1, softwareVersionString = '1.0.0', hardwareVersion = 1, hardwareVersionString = '1.0.0') {
|
|
467
923
|
this.log.logName = deviceName;
|
|
468
924
|
this.deviceName = deviceName;
|
|
@@ -495,6 +951,13 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
495
951
|
});
|
|
496
952
|
return this;
|
|
497
953
|
}
|
|
954
|
+
/**
|
|
955
|
+
* Creates a default identify cluster server with the specified identify time and type.
|
|
956
|
+
*
|
|
957
|
+
* @param {number} [identifyTime] - The time to identify the server. Defaults to 0.
|
|
958
|
+
* @param {Identify.IdentifyType} [identifyType] - The type of identification. Defaults to Identify.IdentifyType.None.
|
|
959
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
960
|
+
*/
|
|
498
961
|
createDefaultIdentifyClusterServer(identifyTime = 0, identifyType = Identify.IdentifyType.None) {
|
|
499
962
|
this.behaviors.require(MatterbridgeIdentifyServer, {
|
|
500
963
|
identifyTime,
|
|
@@ -502,14 +965,36 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
502
965
|
});
|
|
503
966
|
return this;
|
|
504
967
|
}
|
|
968
|
+
/**
|
|
969
|
+
* Creates a default groups cluster server.
|
|
970
|
+
*
|
|
971
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
972
|
+
*/
|
|
505
973
|
createDefaultGroupsClusterServer() {
|
|
506
974
|
this.behaviors.require(GroupsServer);
|
|
507
975
|
return this;
|
|
508
976
|
}
|
|
977
|
+
/**
|
|
978
|
+
* Creates a default scenes management cluster server.
|
|
979
|
+
*
|
|
980
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
981
|
+
*
|
|
982
|
+
* @remarks The scenes management cluster server is still provisional and so not yet implemented.
|
|
983
|
+
*/
|
|
509
984
|
createDefaultScenesClusterServer() {
|
|
510
985
|
this.behaviors.require(ScenesManagementServer);
|
|
511
986
|
return this;
|
|
512
987
|
}
|
|
988
|
+
/**
|
|
989
|
+
* Creates a default OnOff cluster server for light devices with feature Lighting.
|
|
990
|
+
*
|
|
991
|
+
* @param {boolean} [onOff] - The initial state of the OnOff cluster.
|
|
992
|
+
* @param {boolean} [globalSceneControl] - The global scene control state.
|
|
993
|
+
* @param {number} [onTime] - The on time value.
|
|
994
|
+
* @param {number} [offWaitTime] - The off wait time value.
|
|
995
|
+
* @param {OnOff.StartUpOnOff | null} [startUpOnOff] - The start-up OnOff state. Null means previous state.
|
|
996
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
997
|
+
*/
|
|
513
998
|
createDefaultOnOffClusterServer(onOff = false, globalSceneControl = false, onTime = 0, offWaitTime = 0, startUpOnOff = null) {
|
|
514
999
|
this.behaviors.require(MatterbridgeOnOffServer.with(OnOff.Feature.Lighting), {
|
|
515
1000
|
onOff,
|
|
@@ -520,24 +1005,73 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
520
1005
|
});
|
|
521
1006
|
return this;
|
|
522
1007
|
}
|
|
1008
|
+
/**
|
|
1009
|
+
* Creates an OnOff cluster server without features.
|
|
1010
|
+
*
|
|
1011
|
+
* @param {boolean} [onOff] - The initial state of the OnOff cluster.
|
|
1012
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1013
|
+
*/
|
|
523
1014
|
createOnOffClusterServer(onOff = false) {
|
|
524
1015
|
this.behaviors.require(MatterbridgeOnOffServer, {
|
|
525
1016
|
onOff,
|
|
526
1017
|
});
|
|
527
1018
|
return this;
|
|
528
1019
|
}
|
|
1020
|
+
/**
|
|
1021
|
+
* Creates a DeadFront OnOff cluster server with feature DeadFrontBehavior.
|
|
1022
|
+
*
|
|
1023
|
+
* The "dead front" state is linked to the OnOff attribute
|
|
1024
|
+
* in the On/Off cluster having the value False. Thus, the Off command of the On/Off cluster SHALL
|
|
1025
|
+
* move the device into the "dead front" state, the On command of the On/Off cluster SHALL bring the
|
|
1026
|
+
* device out of the "dead front" state, and the device SHALL adhere with the associated requirements
|
|
1027
|
+
* on subscription handling and event reporting.
|
|
1028
|
+
*
|
|
1029
|
+
* @param {boolean} [onOff] - The initial state of the OnOff cluster.
|
|
1030
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1031
|
+
*/
|
|
529
1032
|
createDeadFrontOnOffClusterServer(onOff = false) {
|
|
530
1033
|
this.behaviors.require(MatterbridgeOnOffServer.with(OnOff.Feature.DeadFrontBehavior), {
|
|
531
1034
|
onOff,
|
|
532
1035
|
});
|
|
533
1036
|
return this;
|
|
534
1037
|
}
|
|
1038
|
+
/**
|
|
1039
|
+
* Creates an OffOnly OnOff cluster server with feature OffOnly.
|
|
1040
|
+
*
|
|
1041
|
+
* @param {boolean} [onOff] - The initial state of the OnOff cluster.
|
|
1042
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1043
|
+
*/
|
|
535
1044
|
createOffOnlyOnOffClusterServer(onOff = false) {
|
|
536
1045
|
this.behaviors.require(MatterbridgeOnOffServer.with(OnOff.Feature.OffOnly), {
|
|
537
1046
|
onOff,
|
|
538
1047
|
});
|
|
539
1048
|
return this;
|
|
540
1049
|
}
|
|
1050
|
+
/**
|
|
1051
|
+
* Creates a default level control cluster server for light devices with feature OnOff and Lighting.
|
|
1052
|
+
*
|
|
1053
|
+
* @param {number} [currentLevel] - The current level (default: 254).
|
|
1054
|
+
* @param {number} [minLevel] - The minimum level (default: 1).
|
|
1055
|
+
* @param {number} [maxLevel] - The maximum level (default: 254).
|
|
1056
|
+
* @param {number | null} [onLevel] - The on level (default: null).
|
|
1057
|
+
* @param {number | null} [startUpCurrentLevel] - The startUp on level (default: null).
|
|
1058
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1059
|
+
*
|
|
1060
|
+
* @remarks OptionMasks and OptionOverride fields of moveToLevel and moveToLevelWithOnOff commands requests
|
|
1061
|
+
*
|
|
1062
|
+
* Each bit in the Options attribute SHALL determine the corresponding bit in the temporary Options
|
|
1063
|
+
* bitmap, unless the OptionsMask field is present and has the corresponding bit set to 1, in which
|
|
1064
|
+
* case the corresponding bit in the OptionsOverride field SHALL determine the corresponding bit in
|
|
1065
|
+
* the temporary Options bitmap.
|
|
1066
|
+
*
|
|
1067
|
+
* @remarks 'With On/Off' Commands
|
|
1068
|
+
*
|
|
1069
|
+
* Before commencing any command that has the effect of setting the CurrentLevel attribute above
|
|
1070
|
+
* the minimum level allowed by the device, the OnOff attribute of the On/Off cluster on the same endpoint, if implemented, SHALL be set to TRUE (‘On’).
|
|
1071
|
+
*
|
|
1072
|
+
* If any command that has the effect of setting the CurrentLevel attribute to the minimum level
|
|
1073
|
+
* allowed by the device, the OnOff attribute of the On/Off cluster on the same endpoint, if implemented, SHALL be set to FALSE (‘Off’).
|
|
1074
|
+
*/
|
|
541
1075
|
createDefaultLevelControlClusterServer(currentLevel = 254, minLevel = 1, maxLevel = 254, onLevel = null, startUpCurrentLevel = null) {
|
|
542
1076
|
this.behaviors.require(MatterbridgeLevelControlServer.with(LevelControl.Feature.OnOff, LevelControl.Feature.Lighting), {
|
|
543
1077
|
currentLevel,
|
|
@@ -553,6 +1087,13 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
553
1087
|
});
|
|
554
1088
|
return this;
|
|
555
1089
|
}
|
|
1090
|
+
/**
|
|
1091
|
+
* Creates a level control cluster server without features.
|
|
1092
|
+
*
|
|
1093
|
+
* @param {number} [currentLevel] - The current level (default: 254).
|
|
1094
|
+
* @param {number | null} [onLevel] - The on level (default: null).
|
|
1095
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1096
|
+
*/
|
|
556
1097
|
createLevelControlClusterServer(currentLevel = 254, onLevel = null) {
|
|
557
1098
|
this.behaviors.require(MatterbridgeLevelControlServer, {
|
|
558
1099
|
currentLevel,
|
|
@@ -564,6 +1105,40 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
564
1105
|
});
|
|
565
1106
|
return this;
|
|
566
1107
|
}
|
|
1108
|
+
/**
|
|
1109
|
+
* Creates a default color control cluster server with features Xy, HueSaturation and ColorTemperature.
|
|
1110
|
+
*
|
|
1111
|
+
* @param {number} currentX - The current X value (range 0-65279).
|
|
1112
|
+
* @param {number} currentY - The current Y value (range 0-65279).
|
|
1113
|
+
* @param {number} currentHue - The current hue value (range: 0-254).
|
|
1114
|
+
* @param {number} currentSaturation - The current saturation value (range: 0-254).
|
|
1115
|
+
* @param {number} colorTemperatureMireds - The color temperature in mireds (range colorTempPhysicalMinMireds-colorTempPhysicalMaxMireds).
|
|
1116
|
+
* @param {number} colorTempPhysicalMinMireds - The physical minimum color temperature in mireds (default 147).
|
|
1117
|
+
* @param {number} colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds (default 500).
|
|
1118
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1119
|
+
*
|
|
1120
|
+
* @remarks colorMode and enhancedColorMode persist across restarts.
|
|
1121
|
+
* @remarks currentHue and currentSaturation persist across restarts.
|
|
1122
|
+
* @remarks currentX and currentY persist across restarts.
|
|
1123
|
+
* @remarks colorTemperatureMireds persists across restarts.
|
|
1124
|
+
* @remarks startUpColorTemperatureMireds persists across restarts.
|
|
1125
|
+
* @remarks coupleColorTempToLevelMinMireds persists across restarts.
|
|
1126
|
+
*
|
|
1127
|
+
* @remarks OptionMasks and OptionOverride fields of color control commands requests
|
|
1128
|
+
*
|
|
1129
|
+
* Each bit in the Options attribute SHALL determine the corresponding bit in the temporary Options
|
|
1130
|
+
* bitmap, unless the OptionsMask field is present and has the corresponding bit set to 1, in which
|
|
1131
|
+
* case the corresponding bit in the OptionsOverride field SHALL determine the corresponding bit in
|
|
1132
|
+
* the temporary Options bitmap.
|
|
1133
|
+
*
|
|
1134
|
+
* @remarks CoupleColorTempToLevel
|
|
1135
|
+
*
|
|
1136
|
+
* If the CoupleColorTempToLevel bit of the Options attribute of the Level Control cluster is equal to 1
|
|
1137
|
+
* and the ColorMode or EnhancedColorMode attribute is set to 2 (ColorTemperatureMireds) then a
|
|
1138
|
+
* change in the CurrentLevel attribute SHALL affect the ColorTemperatureMireds attribute.
|
|
1139
|
+
* This relationship is manufacturer specific, with the qualification that the maximum value of the CurrentLevel attribute
|
|
1140
|
+
* SHALL correspond to a ColorTemperatureMired attribute value equal to the CoupleColorTempToLevelMinMireds attribute.
|
|
1141
|
+
*/
|
|
567
1142
|
createDefaultColorControlClusterServer(currentX = 0, currentY = 0, currentHue = 0, currentSaturation = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
|
|
568
1143
|
this.behaviors.require(MatterbridgeColorControlServer.with(ColorControl.Feature.Xy, ColorControl.Feature.HueSaturation, ColorControl.Feature.ColorTemperature), {
|
|
569
1144
|
colorMode: ColorControl.ColorMode.CurrentHueAndCurrentSaturation,
|
|
@@ -586,6 +1161,40 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
586
1161
|
});
|
|
587
1162
|
return this;
|
|
588
1163
|
}
|
|
1164
|
+
/**
|
|
1165
|
+
* Creates a default color control cluster server with features Xy, HueSaturation, EnhancedHueSaturation and ColorTemperature.
|
|
1166
|
+
*
|
|
1167
|
+
* @param {number} currentX - The current X value (range 0-65279).
|
|
1168
|
+
* @param {number} currentY - The current Y value (range 0-65279).
|
|
1169
|
+
* @param {number} enhancedCurrentHue - The enhanced current hue value (range: 0-65535).
|
|
1170
|
+
* @param {number} currentSaturation - The current saturation value (range: 0-254).
|
|
1171
|
+
* @param {number} colorTemperatureMireds - The color temperature in mireds (range colorTempPhysicalMinMireds-colorTempPhysicalMaxMireds).
|
|
1172
|
+
* @param {number} colorTempPhysicalMinMireds - The physical minimum color temperature in mireds (default 147).
|
|
1173
|
+
* @param {number} colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds (default 500).
|
|
1174
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1175
|
+
*
|
|
1176
|
+
* @remarks colorMode and enhancedColorMode persist across restarts.
|
|
1177
|
+
* @remarks currentHue and currentSaturation persist across restarts.
|
|
1178
|
+
* @remarks currentX and currentY persist across restarts.
|
|
1179
|
+
* @remarks colorTemperatureMireds persists across restarts.
|
|
1180
|
+
* @remarks startUpColorTemperatureMireds persists across restarts.
|
|
1181
|
+
* @remarks coupleColorTempToLevelMinMireds persists across restarts.
|
|
1182
|
+
*
|
|
1183
|
+
* @remarks OptionMasks and OptionOverride field
|
|
1184
|
+
*
|
|
1185
|
+
* Each bit in the Options attribute SHALL determine the corresponding bit in the temporary Options
|
|
1186
|
+
* bitmap, unless the OptionsMask field is present and has the corresponding bit set to 1, in which
|
|
1187
|
+
* case the corresponding bit in the OptionsOverride field SHALL determine the corresponding bit in
|
|
1188
|
+
* the temporary Options bitmap.
|
|
1189
|
+
*
|
|
1190
|
+
* @remarks CoupleColorTempToLevel
|
|
1191
|
+
*
|
|
1192
|
+
* If the CoupleColorTempToLevel bit of the Options attribute of the Level Control cluster is equal to 1
|
|
1193
|
+
* and the ColorMode or EnhancedColorMode attribute is set to 2 (ColorTemperatureMireds) then a
|
|
1194
|
+
* change in the CurrentLevel attribute SHALL affect the ColorTemperatureMireds attribute.
|
|
1195
|
+
* This relationship is manufacturer specific, with the qualification that the maximum value of the CurrentLevel attribute
|
|
1196
|
+
* SHALL correspond to a ColorTemperatureMired attribute value equal to the CoupleColorTempToLevelMinMireds attribute.
|
|
1197
|
+
*/
|
|
589
1198
|
createEnhancedColorControlClusterServer(currentX = 0, currentY = 0, enhancedCurrentHue = 0, currentSaturation = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
|
|
590
1199
|
this.behaviors.require(MatterbridgeEnhancedColorControlServer.with(ColorControl.Feature.Xy, ColorControl.Feature.HueSaturation, ColorControl.Feature.EnhancedHue, ColorControl.Feature.ColorTemperature), {
|
|
591
1200
|
colorMode: ColorControl.ColorMode.CurrentHueAndCurrentSaturation,
|
|
@@ -597,7 +1206,7 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
597
1206
|
numberOfPrimaries: null,
|
|
598
1207
|
currentX,
|
|
599
1208
|
currentY,
|
|
600
|
-
currentHue: Math.round((enhancedCurrentHue / 65535) * 254),
|
|
1209
|
+
currentHue: Math.round((enhancedCurrentHue / 65535) * 254), // currentHue range is 0-254 and enhancedCurrentHue range is 0-65535
|
|
601
1210
|
enhancedCurrentHue,
|
|
602
1211
|
currentSaturation,
|
|
603
1212
|
colorTemperatureMireds,
|
|
@@ -609,6 +1218,25 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
609
1218
|
});
|
|
610
1219
|
return this;
|
|
611
1220
|
}
|
|
1221
|
+
/**
|
|
1222
|
+
* Creates a Xy color control cluster server with feature Xy and ColorTemperature.
|
|
1223
|
+
*
|
|
1224
|
+
* @param {number} currentX - The current X value (range 0-65279).
|
|
1225
|
+
* @param {number} currentY - The current Y value (range 0-65279).
|
|
1226
|
+
* @param {number} colorTemperatureMireds - The color temperature in mireds (range colorTempPhysicalMinMireds-colorTempPhysicalMaxMireds).
|
|
1227
|
+
* @param {number} colorTempPhysicalMinMireds - The physical minimum color temperature in mireds (default 147).
|
|
1228
|
+
* @param {number} colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds (default 500).
|
|
1229
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1230
|
+
*
|
|
1231
|
+
* @remarks
|
|
1232
|
+
* From zigbee to matter = Math.max(Math.min(Math.round(x * 65536), 65279), 0)
|
|
1233
|
+
*
|
|
1234
|
+
* @remarks colorMode and enhancedColorMode persist across restarts.
|
|
1235
|
+
* @remarks currentX and currentY persist across restarts.
|
|
1236
|
+
* @remarks colorTemperatureMireds persists across restarts.
|
|
1237
|
+
* @remarks startUpColorTemperatureMireds persists across restarts.
|
|
1238
|
+
* @remarks coupleColorTempToLevelMinMireds persists across restarts.
|
|
1239
|
+
*/
|
|
612
1240
|
createXyColorControlClusterServer(currentX = 0, currentY = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
|
|
613
1241
|
this.behaviors.require(MatterbridgeColorControlServer.with(ColorControl.Feature.Xy, ColorControl.Feature.ColorTemperature), {
|
|
614
1242
|
colorMode: ColorControl.ColorMode.CurrentXAndCurrentY,
|
|
@@ -629,6 +1257,22 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
629
1257
|
});
|
|
630
1258
|
return this;
|
|
631
1259
|
}
|
|
1260
|
+
/**
|
|
1261
|
+
* Creates a default hue and saturation control cluster server with feature HueSaturation and ColorTemperature.
|
|
1262
|
+
*
|
|
1263
|
+
* @param {number} currentHue - The current hue value (range: 0-254).
|
|
1264
|
+
* @param {number} currentSaturation - The current saturation value (range: 0-254).
|
|
1265
|
+
* @param {number} colorTemperatureMireds - The color temperature in mireds (range colorTempPhysicalMinMireds-colorTempPhysicalMaxMireds).
|
|
1266
|
+
* @param {number} colorTempPhysicalMinMireds - The physical minimum color temperature in mireds (default 147).
|
|
1267
|
+
* @param {number} colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds (default 500).
|
|
1268
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1269
|
+
*
|
|
1270
|
+
* @remarks colorMode and enhancedColorMode persist across restarts.
|
|
1271
|
+
* @remarks currentHue and currentSaturation persist across restarts.
|
|
1272
|
+
* @remarks colorTemperatureMireds persists across restarts.
|
|
1273
|
+
* @remarks startUpColorTemperatureMireds persists across restarts.
|
|
1274
|
+
* @remarks coupleColorTempToLevelMinMireds persists across restarts.
|
|
1275
|
+
*/
|
|
632
1276
|
createHsColorControlClusterServer(currentHue = 0, currentSaturation = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
|
|
633
1277
|
this.behaviors.require(MatterbridgeColorControlServer.with(ColorControl.Feature.HueSaturation, ColorControl.Feature.ColorTemperature), {
|
|
634
1278
|
colorMode: ColorControl.ColorMode.CurrentHueAndCurrentSaturation,
|
|
@@ -649,6 +1293,20 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
649
1293
|
});
|
|
650
1294
|
return this;
|
|
651
1295
|
}
|
|
1296
|
+
/**
|
|
1297
|
+
* Creates a color temperature color control cluster server with feature ColorTemperature.
|
|
1298
|
+
* This cluster server is used for devices that only support color temperature control.
|
|
1299
|
+
*
|
|
1300
|
+
* @param {number} colorTemperatureMireds - The color temperature in mireds (range colorTempPhysicalMinMireds-colorTempPhysicalMaxMireds).
|
|
1301
|
+
* @param {number} colorTempPhysicalMinMireds - The physical minimum color temperature in mireds (default 147).
|
|
1302
|
+
* @param {number} colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds (default 500).
|
|
1303
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1304
|
+
*
|
|
1305
|
+
* @remarks colorMode and enhancedColorMode persist across restarts.
|
|
1306
|
+
* @remarks colorTemperatureMireds persists across restarts.
|
|
1307
|
+
* @remarks startUpColorTemperatureMireds persists across restarts.
|
|
1308
|
+
* @remarks coupleColorTempToLevelMinMireds persists across restarts.
|
|
1309
|
+
*/
|
|
652
1310
|
createCtColorControlClusterServer(colorTemperatureMireds = 250, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
|
|
653
1311
|
this.behaviors.require(MatterbridgeColorControlServer.with(ColorControl.Feature.ColorTemperature), {
|
|
654
1312
|
colorMode: ColorControl.ColorMode.ColorTemperatureMireds,
|
|
@@ -667,15 +1325,47 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
667
1325
|
});
|
|
668
1326
|
return this;
|
|
669
1327
|
}
|
|
1328
|
+
/**
|
|
1329
|
+
* Configures the color control mode for the device.
|
|
1330
|
+
*
|
|
1331
|
+
* @param {ColorControl.ColorMode} colorMode - The color mode to set.
|
|
1332
|
+
*
|
|
1333
|
+
* @remarks colorMode and enhancedColorMode persist across restarts.
|
|
1334
|
+
*/
|
|
670
1335
|
async configureColorControlMode(colorMode) {
|
|
1336
|
+
if (isValidNumber(colorMode, ColorControl.ColorMode.CurrentHueAndCurrentSaturation, ColorControl.ColorMode.ColorTemperatureMireds)) {
|
|
1337
|
+
await this.setAttribute(ColorControl.Cluster.id, 'colorMode', colorMode, this.log);
|
|
1338
|
+
await this.setAttribute(ColorControl.Cluster.id, 'enhancedColorMode', colorMode, this.log);
|
|
1339
|
+
}
|
|
1340
|
+
}
|
|
1341
|
+
/**
|
|
1342
|
+
* Configures the enhanced color control mode for the device.
|
|
1343
|
+
*
|
|
1344
|
+
* @param {ColorControl.EnhancedColorMode} colorMode - The enhanced color mode to set.
|
|
1345
|
+
*
|
|
1346
|
+
* @remarks colorMode and enhancedColorMode persist across restarts.
|
|
1347
|
+
*/
|
|
1348
|
+
async configureEnhancedColorControlMode(colorMode) {
|
|
671
1349
|
if (isValidNumber(colorMode, ColorControl.EnhancedColorMode.CurrentHueAndCurrentSaturation, ColorControl.EnhancedColorMode.EnhancedCurrentHueAndCurrentSaturation)) {
|
|
672
1350
|
await this.setAttribute(ColorControl.Cluster.id, 'colorMode', colorMode === ColorControl.EnhancedColorMode.EnhancedCurrentHueAndCurrentSaturation ? ColorControl.ColorMode.CurrentHueAndCurrentSaturation : colorMode, this.log);
|
|
673
1351
|
await this.setAttribute(ColorControl.Cluster.id, 'enhancedColorMode', colorMode, this.log);
|
|
674
1352
|
}
|
|
675
1353
|
}
|
|
1354
|
+
/**
|
|
1355
|
+
* Creates a default window covering cluster server with feature Lift and PositionAwareLift.
|
|
1356
|
+
*
|
|
1357
|
+
* @param {number} positionPercent100ths - The position percentage in 100ths (0-10000). Defaults to 0. Matter uses 10000 = fully closed 0 = fully opened.
|
|
1358
|
+
* @param {WindowCovering.WindowCoveringType} type - The type of window covering (default: WindowCovering.WindowCoveringType.Rollershade). Must support feature Lift.
|
|
1359
|
+
* @param {WindowCovering.EndProductType} endProductType - The end product type (default: WindowCovering.EndProductType.RollerShade). Must support feature Lift.
|
|
1360
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1361
|
+
*
|
|
1362
|
+
* @remarks mode attributes is writable and persists across restarts.
|
|
1363
|
+
* currentPositionLiftPercent100ths persists across restarts.
|
|
1364
|
+
* configStatus attributes persists across restarts.
|
|
1365
|
+
*/
|
|
676
1366
|
createDefaultWindowCoveringClusterServer(positionPercent100ths, type = WindowCovering.WindowCoveringType.Rollershade, endProductType = WindowCovering.EndProductType.RollerShade) {
|
|
677
1367
|
this.behaviors.require(MatterbridgeLiftWindowCoveringServer.with(WindowCovering.Feature.Lift, WindowCovering.Feature.PositionAwareLift), {
|
|
678
|
-
type,
|
|
1368
|
+
type, // Must support feature Lift
|
|
679
1369
|
numberOfActuationsLift: 0,
|
|
680
1370
|
configStatus: {
|
|
681
1371
|
operational: true,
|
|
@@ -683,20 +1373,33 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
683
1373
|
liftMovementReversed: false,
|
|
684
1374
|
liftPositionAware: true,
|
|
685
1375
|
tiltPositionAware: false,
|
|
686
|
-
liftEncoderControlled: false,
|
|
687
|
-
tiltEncoderControlled: false,
|
|
1376
|
+
liftEncoderControlled: false, // 0 = Timer Controlled 1 = Encoder Controlled
|
|
1377
|
+
tiltEncoderControlled: false, // 0 = Timer Controlled 1 = Encoder Controlled
|
|
688
1378
|
},
|
|
689
1379
|
operationalStatus: { global: WindowCovering.MovementStatus.Stopped, lift: WindowCovering.MovementStatus.Stopped, tilt: WindowCovering.MovementStatus.Stopped },
|
|
690
|
-
endProductType,
|
|
1380
|
+
endProductType, // Must support feature Lift
|
|
691
1381
|
mode: { motorDirectionReversed: false, calibrationMode: false, maintenanceMode: false, ledFeedback: false },
|
|
692
|
-
targetPositionLiftPercent100ths: positionPercent100ths ?? 0,
|
|
693
|
-
currentPositionLiftPercent100ths: positionPercent100ths ?? 0,
|
|
1382
|
+
targetPositionLiftPercent100ths: positionPercent100ths ?? 0, // 0 Fully open 10000 fully closed
|
|
1383
|
+
currentPositionLiftPercent100ths: positionPercent100ths ?? 0, // 0 Fully open 10000 fully closed
|
|
694
1384
|
});
|
|
695
1385
|
return this;
|
|
696
1386
|
}
|
|
1387
|
+
/**
|
|
1388
|
+
* Creates a default window covering cluster server with features Lift, PositionAwareLift, Tilt, PositionAwareTilt.
|
|
1389
|
+
*
|
|
1390
|
+
* @param {number} positionLiftPercent100ths - The lift position percentage in 100ths (0-10000). Defaults to 0. Matter uses 10000 = fully closed 0 = fully opened.
|
|
1391
|
+
* @param {number} positionTiltPercent100ths - The tilt position percentage in 100ths (0-10000). Defaults to 0. Matter uses 10000 = fully closed 0 = fully opened.
|
|
1392
|
+
* @param {WindowCovering.WindowCoveringType} type - The type of window covering (default: WindowCovering.WindowCoveringType.TiltBlindLift). Must support features Lift and Tilt.
|
|
1393
|
+
* @param {WindowCovering.EndProductType} endProductType - The end product type (default: WindowCovering.EndProductType.InteriorBlind). Must support features Lift and Tilt.
|
|
1394
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1395
|
+
*
|
|
1396
|
+
* @remarks mode attributes is writable and persists across restarts.
|
|
1397
|
+
* currentPositionTiltPercent100ths persists across restarts.
|
|
1398
|
+
* configStatus attributes persists across restarts.
|
|
1399
|
+
*/
|
|
697
1400
|
createDefaultLiftTiltWindowCoveringClusterServer(positionLiftPercent100ths, positionTiltPercent100ths, type = WindowCovering.WindowCoveringType.TiltBlindLift, endProductType = WindowCovering.EndProductType.InteriorBlind) {
|
|
698
1401
|
this.behaviors.require(MatterbridgeLiftTiltWindowCoveringServer.with(WindowCovering.Feature.Lift, WindowCovering.Feature.PositionAwareLift, WindowCovering.Feature.Tilt, WindowCovering.Feature.PositionAwareTilt), {
|
|
699
|
-
type,
|
|
1402
|
+
type, // Must support features Lift and Tilt
|
|
700
1403
|
numberOfActuationsLift: 0,
|
|
701
1404
|
numberOfActuationsTilt: 0,
|
|
702
1405
|
configStatus: {
|
|
@@ -705,19 +1408,23 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
705
1408
|
liftMovementReversed: false,
|
|
706
1409
|
liftPositionAware: true,
|
|
707
1410
|
tiltPositionAware: true,
|
|
708
|
-
liftEncoderControlled: false,
|
|
709
|
-
tiltEncoderControlled: false,
|
|
1411
|
+
liftEncoderControlled: false, // 0 = Timer Controlled 1 = Encoder Controlled
|
|
1412
|
+
tiltEncoderControlled: false, // 0 = Timer Controlled 1 = Encoder Controlled
|
|
710
1413
|
},
|
|
711
1414
|
operationalStatus: { global: WindowCovering.MovementStatus.Stopped, lift: WindowCovering.MovementStatus.Stopped, tilt: WindowCovering.MovementStatus.Stopped },
|
|
712
|
-
endProductType,
|
|
1415
|
+
endProductType, // Must support features Lift and Tilt
|
|
713
1416
|
mode: { motorDirectionReversed: false, calibrationMode: false, maintenanceMode: false, ledFeedback: false },
|
|
714
|
-
targetPositionLiftPercent100ths: positionLiftPercent100ths ?? 0,
|
|
715
|
-
currentPositionLiftPercent100ths: positionLiftPercent100ths ?? 0,
|
|
716
|
-
targetPositionTiltPercent100ths: positionTiltPercent100ths ?? 0,
|
|
717
|
-
currentPositionTiltPercent100ths: positionTiltPercent100ths ?? 0,
|
|
1417
|
+
targetPositionLiftPercent100ths: positionLiftPercent100ths ?? 0, // 0 Fully open 10000 fully closed
|
|
1418
|
+
currentPositionLiftPercent100ths: positionLiftPercent100ths ?? 0, // 0 Fully open 10000 fully closed
|
|
1419
|
+
targetPositionTiltPercent100ths: positionTiltPercent100ths ?? 0, // 0 Fully open 10000 fully closed
|
|
1420
|
+
currentPositionTiltPercent100ths: positionTiltPercent100ths ?? 0, // 0 Fully open 10000 fully closed
|
|
718
1421
|
});
|
|
719
1422
|
return this;
|
|
720
1423
|
}
|
|
1424
|
+
/**
|
|
1425
|
+
* Sets the window covering lift target position as the current position and stops the movement.
|
|
1426
|
+
*
|
|
1427
|
+
*/
|
|
721
1428
|
async setWindowCoveringTargetAsCurrentAndStopped() {
|
|
722
1429
|
const position = this.getAttribute(WindowCovering.Cluster.id, 'currentPositionLiftPercent100ths', this.log);
|
|
723
1430
|
if (isValidNumber(position, 0, 10000)) {
|
|
@@ -737,6 +1444,13 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
737
1444
|
this.log.debug(`Set WindowCovering currentPositionTiltPercent100ths and targetPositionTiltPercent100ths to ${position} and operationalStatus to Stopped.`);
|
|
738
1445
|
}
|
|
739
1446
|
}
|
|
1447
|
+
/**
|
|
1448
|
+
* Sets the lift current and target position and the status of a window covering.
|
|
1449
|
+
*
|
|
1450
|
+
* @param {number} current - The current position of the window covering.
|
|
1451
|
+
* @param {number} target - The target position of the window covering.
|
|
1452
|
+
* @param {WindowCovering.MovementStatus} status - The movement status of the window covering.
|
|
1453
|
+
*/
|
|
740
1454
|
async setWindowCoveringCurrentTargetStatus(current, target, status) {
|
|
741
1455
|
await this.setAttribute(WindowCovering.Cluster.id, 'currentPositionLiftPercent100ths', current, this.log);
|
|
742
1456
|
await this.setAttribute(WindowCovering.Cluster.id, 'targetPositionLiftPercent100ths', target, this.log);
|
|
@@ -747,6 +1461,11 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
747
1461
|
}, this.log);
|
|
748
1462
|
this.log.debug(`Set WindowCovering currentPositionLiftPercent100ths: ${current}, targetPositionLiftPercent100ths: ${target} and operationalStatus: ${status}.`);
|
|
749
1463
|
}
|
|
1464
|
+
/**
|
|
1465
|
+
* Sets the status of the window covering.
|
|
1466
|
+
*
|
|
1467
|
+
* @param {WindowCovering.MovementStatus} status - The movement status to set.
|
|
1468
|
+
*/
|
|
750
1469
|
async setWindowCoveringStatus(status) {
|
|
751
1470
|
await this.setAttribute(WindowCovering.Cluster.id, 'operationalStatus', {
|
|
752
1471
|
global: status,
|
|
@@ -755,6 +1474,11 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
755
1474
|
}, this.log);
|
|
756
1475
|
this.log.debug(`Set WindowCovering operationalStatus: ${status}`);
|
|
757
1476
|
}
|
|
1477
|
+
/**
|
|
1478
|
+
* Retrieves the status of the window covering.
|
|
1479
|
+
*
|
|
1480
|
+
* @returns {WindowCovering.MovementStatus | undefined} The movement status of the window covering, or undefined if not available.
|
|
1481
|
+
*/
|
|
758
1482
|
getWindowCoveringStatus() {
|
|
759
1483
|
const status = this.getAttribute(WindowCovering.Cluster.id, 'operationalStatus', this.log);
|
|
760
1484
|
if (isValidObject(status, 3) && 'global' in status && typeof status.global === 'number') {
|
|
@@ -762,6 +1486,12 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
762
1486
|
return status.global;
|
|
763
1487
|
}
|
|
764
1488
|
}
|
|
1489
|
+
/**
|
|
1490
|
+
* Sets the lift target and current position of the window covering.
|
|
1491
|
+
*
|
|
1492
|
+
* @param {number} liftPosition - The position to set, specified as a number.
|
|
1493
|
+
* @param {number} [tiltPosition] - The tilt position to set, specified as a number.
|
|
1494
|
+
*/
|
|
765
1495
|
async setWindowCoveringTargetAndCurrentPosition(liftPosition, tiltPosition) {
|
|
766
1496
|
await this.setAttribute(WindowCovering.Cluster.id, 'currentPositionLiftPercent100ths', liftPosition, this.log);
|
|
767
1497
|
await this.setAttribute(WindowCovering.Cluster.id, 'targetPositionLiftPercent100ths', liftPosition, this.log);
|
|
@@ -772,31 +1502,57 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
772
1502
|
this.log.debug(`Set WindowCovering currentPositionTiltPercent100ths: ${tiltPosition} and targetPositionTiltPercent100ths: ${tiltPosition}.`);
|
|
773
1503
|
}
|
|
774
1504
|
}
|
|
1505
|
+
/**
|
|
1506
|
+
* Creates a default thermostat cluster server with features Heating, Cooling and AutoMode.
|
|
1507
|
+
*
|
|
1508
|
+
* @param {number} [localTemperature] - The local temperature value in degrees Celsius. Defaults to 23°.
|
|
1509
|
+
* @param {number} [occupiedHeatingSetpoint] - The occupied heating setpoint value in degrees Celsius. Defaults to 21°.
|
|
1510
|
+
* @param {number} [occupiedCoolingSetpoint] - The occupied cooling setpoint value in degrees Celsius. Defaults to 25°.
|
|
1511
|
+
* @param {number} [minSetpointDeadBand] - The minimum setpoint dead band value. Defaults to 1°.
|
|
1512
|
+
* @param {number} [minHeatSetpointLimit] - The minimum heat setpoint limit value. Defaults to 0°.
|
|
1513
|
+
* @param {number} [maxHeatSetpointLimit] - The maximum heat setpoint limit value. Defaults to 50°.
|
|
1514
|
+
* @param {number} [minCoolSetpointLimit] - The minimum cool setpoint limit value. Defaults to 0°.
|
|
1515
|
+
* @param {number} [maxCoolSetpointLimit] - The maximum cool setpoint limit value. Defaults to 50°.
|
|
1516
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1517
|
+
*/
|
|
775
1518
|
createDefaultThermostatClusterServer(localTemperature = 23, occupiedHeatingSetpoint = 21, occupiedCoolingSetpoint = 25, minSetpointDeadBand = 1, minHeatSetpointLimit = 0, maxHeatSetpointLimit = 50, minCoolSetpointLimit = 0, maxCoolSetpointLimit = 50) {
|
|
776
1519
|
this.behaviors.require(MatterbridgeThermostatServer.with(Thermostat.Feature.Heating, Thermostat.Feature.Cooling, Thermostat.Feature.AutoMode), {
|
|
777
1520
|
localTemperature: localTemperature * 100,
|
|
778
1521
|
systemMode: Thermostat.SystemMode.Auto,
|
|
779
1522
|
controlSequenceOfOperation: Thermostat.ControlSequenceOfOperation.CoolingAndHeating,
|
|
1523
|
+
// Thermostat.Feature.Heating
|
|
780
1524
|
occupiedHeatingSetpoint: occupiedHeatingSetpoint * 100,
|
|
781
1525
|
minHeatSetpointLimit: minHeatSetpointLimit * 100,
|
|
782
1526
|
maxHeatSetpointLimit: maxHeatSetpointLimit * 100,
|
|
783
1527
|
absMinHeatSetpointLimit: minHeatSetpointLimit * 100,
|
|
784
1528
|
absMaxHeatSetpointLimit: maxHeatSetpointLimit * 100,
|
|
1529
|
+
// Thermostat.Feature.Cooling
|
|
785
1530
|
occupiedCoolingSetpoint: occupiedCoolingSetpoint * 100,
|
|
786
1531
|
minCoolSetpointLimit: minCoolSetpointLimit * 100,
|
|
787
1532
|
maxCoolSetpointLimit: maxCoolSetpointLimit * 100,
|
|
788
1533
|
absMinCoolSetpointLimit: minCoolSetpointLimit * 100,
|
|
789
1534
|
absMaxCoolSetpointLimit: maxCoolSetpointLimit * 100,
|
|
1535
|
+
// Thermostat.Feature.AutoMode
|
|
790
1536
|
minSetpointDeadBand: minSetpointDeadBand * 100,
|
|
791
1537
|
thermostatRunningMode: Thermostat.ThermostatRunningMode.Off,
|
|
792
1538
|
});
|
|
793
1539
|
return this;
|
|
794
1540
|
}
|
|
1541
|
+
/**
|
|
1542
|
+
* Creates a default heating thermostat cluster server with feature Heating.
|
|
1543
|
+
*
|
|
1544
|
+
* @param {number} [localTemperature] - The local temperature value in degrees Celsius. Defaults to 23°.
|
|
1545
|
+
* @param {number} [occupiedHeatingSetpoint] - The occupied heating setpoint value in degrees Celsius. Defaults to 21°.
|
|
1546
|
+
* @param {number} [minHeatSetpointLimit] - The minimum heat setpoint limit value. Defaults to 0°.
|
|
1547
|
+
* @param {number} [maxHeatSetpointLimit] - The maximum heat setpoint limit value. Defaults to 50°.
|
|
1548
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1549
|
+
*/
|
|
795
1550
|
createDefaultHeatingThermostatClusterServer(localTemperature = 23, occupiedHeatingSetpoint = 21, minHeatSetpointLimit = 0, maxHeatSetpointLimit = 50) {
|
|
796
1551
|
this.behaviors.require(MatterbridgeThermostatServer.with(Thermostat.Feature.Heating), {
|
|
797
1552
|
localTemperature: localTemperature * 100,
|
|
798
1553
|
systemMode: Thermostat.SystemMode.Heat,
|
|
799
1554
|
controlSequenceOfOperation: Thermostat.ControlSequenceOfOperation.HeatingOnly,
|
|
1555
|
+
// Thermostat.Feature.Heating
|
|
800
1556
|
occupiedHeatingSetpoint: occupiedHeatingSetpoint * 100,
|
|
801
1557
|
minHeatSetpointLimit: minHeatSetpointLimit * 100,
|
|
802
1558
|
maxHeatSetpointLimit: maxHeatSetpointLimit * 100,
|
|
@@ -805,11 +1561,21 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
805
1561
|
});
|
|
806
1562
|
return this;
|
|
807
1563
|
}
|
|
1564
|
+
/**
|
|
1565
|
+
* Creates a default cooling thermostat cluster server with feature Cooling.
|
|
1566
|
+
*
|
|
1567
|
+
* @param {number} [localTemperature] - The local temperature value in degrees Celsius. Defaults to 23°.
|
|
1568
|
+
* @param {number} [occupiedCoolingSetpoint] - The occupied cooling setpoint value in degrees Celsius. Defaults to 25°.
|
|
1569
|
+
* @param {number} [minCoolSetpointLimit] - The minimum cool setpoint limit value. Defaults to 0°.
|
|
1570
|
+
* @param {number} [maxCoolSetpointLimit] - The maximum cool setpoint limit value. Defaults to 50°.
|
|
1571
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1572
|
+
*/
|
|
808
1573
|
createDefaultCoolingThermostatClusterServer(localTemperature = 23, occupiedCoolingSetpoint = 25, minCoolSetpointLimit = 0, maxCoolSetpointLimit = 50) {
|
|
809
1574
|
this.behaviors.require(MatterbridgeThermostatServer.with(Thermostat.Feature.Cooling), {
|
|
810
1575
|
localTemperature: localTemperature * 100,
|
|
811
1576
|
systemMode: Thermostat.SystemMode.Cool,
|
|
812
1577
|
controlSequenceOfOperation: Thermostat.ControlSequenceOfOperation.CoolingOnly,
|
|
1578
|
+
// Thermostat.Feature.Cooling
|
|
813
1579
|
occupiedCoolingSetpoint: occupiedCoolingSetpoint * 100,
|
|
814
1580
|
minCoolSetpointLimit: minCoolSetpointLimit * 100,
|
|
815
1581
|
maxCoolSetpointLimit: maxCoolSetpointLimit * 100,
|
|
@@ -818,6 +1584,20 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
818
1584
|
});
|
|
819
1585
|
return this;
|
|
820
1586
|
}
|
|
1587
|
+
/**
|
|
1588
|
+
* Creates a default thermostat user interface configuration cluster server.
|
|
1589
|
+
*
|
|
1590
|
+
* @param {ThermostatUserInterfaceConfiguration.TemperatureDisplayMode} [temperatureDisplayMode] - The temperature display mode to set. Defaults to `ThermostatUserInterfaceConfiguration.TemperatureDisplayMode.Celsius`.
|
|
1591
|
+
* @param {ThermostatUserInterfaceConfiguration.KeypadLockout} [keypadLockout] - The keypad lockout mode. Defaults to `ThermostatUserInterfaceConfiguration.KeypadLockout.NoLockout`.
|
|
1592
|
+
* @param {ThermostatUserInterfaceConfiguration.ScheduleProgrammingVisibility} [scheduleProgrammingVisibility] - The schedule programming visibility. Defaults to `ThermostatUserInterfaceConfiguration.ScheduleProgrammingVisibility.ScheduleProgrammingPermitted`.
|
|
1593
|
+
*
|
|
1594
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1595
|
+
* @remarks
|
|
1596
|
+
* The default values are:
|
|
1597
|
+
* - temperatureDisplayMode: ThermostatUserInterfaceConfiguration.TemperatureDisplayMode.Celsius (writable).
|
|
1598
|
+
* - keypadLockout: ThermostatUserInterfaceConfiguration.KeypadLockout.NoLockout (writable).
|
|
1599
|
+
* - scheduleProgrammingVisibility: ThermostatUserInterfaceConfiguration.ScheduleProgrammingVisibility.ScheduleProgrammingPermitted (writable).
|
|
1600
|
+
*/
|
|
821
1601
|
createDefaultThermostatUserInterfaceConfigurationClusterServer(temperatureDisplayMode = ThermostatUserInterfaceConfiguration.TemperatureDisplayMode.Celsius, keypadLockout = ThermostatUserInterfaceConfiguration.KeypadLockout.NoLockout, scheduleProgrammingVisibility = ThermostatUserInterfaceConfiguration.ScheduleProgrammingVisibility.ScheduleProgrammingPermitted) {
|
|
822
1602
|
this.behaviors.require(ThermostatUserInterfaceConfigurationServer, {
|
|
823
1603
|
temperatureDisplayMode,
|
|
@@ -826,95 +1606,273 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
826
1606
|
});
|
|
827
1607
|
return this;
|
|
828
1608
|
}
|
|
1609
|
+
/**
|
|
1610
|
+
* Creates a default fan control cluster server with features Auto, and Step and mode Off Low Med High Auto.
|
|
1611
|
+
*
|
|
1612
|
+
* @param {FanControl.FanMode} [fanMode] - The fan mode to set. Defaults to `FanControl.FanMode.Off`.
|
|
1613
|
+
* @param {FanControl.FanModeSequence} [fanModeSequence] - The fan mode sequence to set. Defaults to `FanControl.FanModeSequence.OffLowMedHighAuto`.
|
|
1614
|
+
* @param {number} [percentSetting] - The initial percent setting. Defaults to 0.
|
|
1615
|
+
* @param {number} [percentCurrent] - The initial percent current. Defaults to 0.
|
|
1616
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1617
|
+
*
|
|
1618
|
+
* @remarks
|
|
1619
|
+
* - fanmode is writable and persists across reboots.
|
|
1620
|
+
* - fanModeSequence is fixed.
|
|
1621
|
+
* - percentSetting is writable.
|
|
1622
|
+
*/
|
|
829
1623
|
createDefaultFanControlClusterServer(fanMode = FanControl.FanMode.Off, fanModeSequence = FanControl.FanModeSequence.OffLowMedHighAuto, percentSetting = 0, percentCurrent = 0) {
|
|
830
1624
|
this.behaviors.require(MatterbridgeFanControlServer.with(FanControl.Feature.Auto, FanControl.Feature.Step), {
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
1625
|
+
// Base fan control attributes
|
|
1626
|
+
fanMode, // Writable and persistent attribute
|
|
1627
|
+
fanModeSequence, // Fixed attribute
|
|
1628
|
+
percentSetting, // Writable attribute
|
|
834
1629
|
percentCurrent,
|
|
835
1630
|
});
|
|
836
1631
|
return this;
|
|
837
1632
|
}
|
|
1633
|
+
/**
|
|
1634
|
+
* Creates an On Off fan control cluster server without features and mode Off High.
|
|
1635
|
+
*
|
|
1636
|
+
* @param {FanControl.FanMode} [fanMode] - The fan mode to set. Defaults to `FanControl.FanMode.Off`.
|
|
1637
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1638
|
+
*
|
|
1639
|
+
* @remarks
|
|
1640
|
+
* fanmode is writable and persists across reboots.
|
|
1641
|
+
* fanModeSequence is fixed.
|
|
1642
|
+
* percentSetting is writable.
|
|
1643
|
+
*/
|
|
838
1644
|
createOnOffFanControlClusterServer(fanMode = FanControl.FanMode.Off) {
|
|
839
1645
|
this.behaviors.require(FanControlServer, {
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
1646
|
+
// Base fan control attributes
|
|
1647
|
+
fanMode, // Writable and persistent attribute
|
|
1648
|
+
fanModeSequence: FanControl.FanModeSequence.OffHigh, // Fixed attribute
|
|
1649
|
+
percentSetting: 0, // Writable attribute
|
|
843
1650
|
percentCurrent: 0,
|
|
844
1651
|
});
|
|
845
1652
|
return this;
|
|
846
1653
|
}
|
|
1654
|
+
/**
|
|
1655
|
+
* Creates a base fan control cluster server without features and mode Off Low Med High.
|
|
1656
|
+
*
|
|
1657
|
+
* @param {FanControl.FanMode} [fanMode] - The fan mode to set. Defaults to `FanControl.FanMode.Off`.
|
|
1658
|
+
* @param {FanControl.FanModeSequence} [fanModeSequence] - The fan mode sequence to set. Defaults to `FanControl.FanModeSequence.OffLowMedHigh`.
|
|
1659
|
+
* @param {number} [percentSetting] - The initial percent setting. Defaults to 0.
|
|
1660
|
+
* @param {number} [percentCurrent] - The initial percent current. Defaults to 0.
|
|
1661
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1662
|
+
*
|
|
1663
|
+
* @remarks
|
|
1664
|
+
* fanmode is writable and persists across reboots.
|
|
1665
|
+
* fanModeSequence is fixed.
|
|
1666
|
+
* percentSetting is writable.
|
|
1667
|
+
*/
|
|
847
1668
|
createBaseFanControlClusterServer(fanMode = FanControl.FanMode.Off, fanModeSequence = FanControl.FanModeSequence.OffLowMedHigh, percentSetting = 0, percentCurrent = 0) {
|
|
848
1669
|
this.behaviors.require(FanControlServer, {
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
1670
|
+
// Base fan control attributes
|
|
1671
|
+
fanMode, // Writable and persistent attribute
|
|
1672
|
+
fanModeSequence, // Fixed attribute
|
|
1673
|
+
percentSetting, // Writable attribute
|
|
852
1674
|
percentCurrent,
|
|
853
1675
|
});
|
|
854
1676
|
return this;
|
|
855
1677
|
}
|
|
1678
|
+
/**
|
|
1679
|
+
* Creates a fan control cluster server with features MultiSpeed, Auto, and Step and mode Off Low Med High Auto.
|
|
1680
|
+
*
|
|
1681
|
+
* @param {FanControl.FanMode} [fanMode] - The fan mode to set. Defaults to `FanControl.FanMode.Off`.
|
|
1682
|
+
* @param {FanControl.FanModeSequence} [fanModeSequence] - The fan mode sequence to set. Defaults to `FanControl.FanModeSequence.OffLowMedHighAuto`.
|
|
1683
|
+
* @param {number} [percentSetting] - The initial percent setting. Defaults to 0.
|
|
1684
|
+
* @param {number} [percentCurrent] - The initial percent current. Defaults to 0.
|
|
1685
|
+
* @param {number} [speedMax] - The maximum speed setting. Defaults to 10.
|
|
1686
|
+
* @param {number} [speedSetting] - The initial speed setting. Defaults to 0.
|
|
1687
|
+
* @param {number} [speedCurrent] - The initial speed current. Defaults to 0.
|
|
1688
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1689
|
+
*
|
|
1690
|
+
* @remarks
|
|
1691
|
+
* - fanmode is writable and persists across reboots.
|
|
1692
|
+
* - fanModeSequence is fixed.
|
|
1693
|
+
* - percentSetting is writable.
|
|
1694
|
+
* - speedMax is fixed.
|
|
1695
|
+
* - speedSetting is writable.
|
|
1696
|
+
*/
|
|
856
1697
|
createMultiSpeedFanControlClusterServer(fanMode = FanControl.FanMode.Off, fanModeSequence = FanControl.FanModeSequence.OffLowMedHighAuto, percentSetting = 0, percentCurrent = 0, speedMax = 10, speedSetting = 0, speedCurrent = 0) {
|
|
857
1698
|
this.behaviors.require(MatterbridgeFanControlServer.with(FanControl.Feature.MultiSpeed, FanControl.Feature.Auto, FanControl.Feature.Step), {
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
1699
|
+
// Base fan control attributes
|
|
1700
|
+
fanMode, // Writable and persistent attribute
|
|
1701
|
+
fanModeSequence, // Fixed attribute
|
|
1702
|
+
percentSetting, // Writable attribute
|
|
861
1703
|
percentCurrent,
|
|
862
|
-
|
|
863
|
-
|
|
1704
|
+
// MultiSpeed feature
|
|
1705
|
+
speedMax, // Fixed attribute
|
|
1706
|
+
speedSetting, // Writable attribute
|
|
864
1707
|
speedCurrent,
|
|
865
1708
|
});
|
|
866
1709
|
return this;
|
|
867
1710
|
}
|
|
1711
|
+
/**
|
|
1712
|
+
* Creates a fan control cluster server with features MultiSpeed, Auto, Step, Rock, Wind and AirflowDirection and mode Off Low Med High Auto.
|
|
1713
|
+
*
|
|
1714
|
+
* @param {FanControl.FanMode} [fanMode] - The fan mode to set. Defaults to `FanControl.FanMode.Off`.
|
|
1715
|
+
* @param {FanControl.FanModeSequence} [fanModeSequence] - The fan mode sequence to set. Defaults to `FanControl.FanModeSequence.OffLowMedHighAuto`.
|
|
1716
|
+
* @param {number} [percentSetting] - The initial percent setting. Defaults to 0.
|
|
1717
|
+
* @param {number} [percentCurrent] - The initial percent current. Defaults to 0.
|
|
1718
|
+
* @param {number} [speedMax] - The maximum speed setting. Defaults to 10.
|
|
1719
|
+
* @param {number} [speedSetting] - The initial speed setting. Defaults to 0.
|
|
1720
|
+
* @param {number} [speedCurrent] - The initial speed current. Defaults to 0.
|
|
1721
|
+
* @param {object} [rockSupport] - The rock support configuration.
|
|
1722
|
+
* @param {boolean} rockSupport.rockLeftRight - Indicates support for rocking left to right. Defaults to true.
|
|
1723
|
+
* @param {boolean} rockSupport.rockUpDown - Indicates support for rocking up and down. Defaults to true.
|
|
1724
|
+
* @param {boolean} rockSupport.rockRound - Indicates support for round rocking. Defaults to true.
|
|
1725
|
+
* @param {object} [rockSetting] - The rock setting configuration.
|
|
1726
|
+
* @param {boolean} rockSetting.rockLeftRight - Indicates the current setting for rocking left to right. Defaults to true.
|
|
1727
|
+
* @param {boolean} rockSetting.rockUpDown - Indicates the current setting for rocking up and down. Defaults to true.
|
|
1728
|
+
* @param {boolean} rockSetting.rockRound - Indicates the current setting for round rocking. Defaults to true.
|
|
1729
|
+
* @param {object} [windSupport] - The wind support configuration.
|
|
1730
|
+
* @param {boolean} windSupport.sleepWind - Indicates support for sleep wind. Defaults to true.
|
|
1731
|
+
* @param {boolean} windSupport.naturalWind - Indicates support for natural wind. Defaults to true.
|
|
1732
|
+
* @param {object} [windSetting] - The wind setting configuration.
|
|
1733
|
+
* @param {boolean} windSetting.sleepWind - Indicates the current setting for sleep wind. Defaults to false.
|
|
1734
|
+
* @param {boolean} windSetting.naturalWind - Indicates the current setting for natural wind. Defaults to true.
|
|
1735
|
+
* @param {FanControl.AirflowDirection} [airflowDirection] - The airflow direction. Defaults to `FanControl.AirflowDirection.Forward`.
|
|
1736
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1737
|
+
*
|
|
1738
|
+
* @remarks
|
|
1739
|
+
* - fanmode is writable and persists across reboots.
|
|
1740
|
+
* - fanModeSequence is fixed.
|
|
1741
|
+
* - percentSetting is writable.
|
|
1742
|
+
* - speedMax is fixed.
|
|
1743
|
+
* - speedSetting is writable.
|
|
1744
|
+
* - rockSupport is fixed.
|
|
1745
|
+
* - rockSetting is writable.
|
|
1746
|
+
* - windSupport is fixed.
|
|
1747
|
+
* - windSetting is writable.
|
|
1748
|
+
* - airflowDirection is writable.
|
|
1749
|
+
*/
|
|
868
1750
|
createCompleteFanControlClusterServer(fanMode = FanControl.FanMode.Off, fanModeSequence = FanControl.FanModeSequence.OffLowMedHighAuto, percentSetting = 0, percentCurrent = 0, speedMax = 10, speedSetting = 0, speedCurrent = 0, rockSupport = { rockLeftRight: true, rockUpDown: true, rockRound: true }, rockSetting = { rockLeftRight: true, rockUpDown: false, rockRound: false }, windSupport = { sleepWind: true, naturalWind: true }, windSetting = { sleepWind: false, naturalWind: true }, airflowDirection = FanControl.AirflowDirection.Forward) {
|
|
869
1751
|
this.behaviors.require(MatterbridgeFanControlServer.with(FanControl.Feature.MultiSpeed, FanControl.Feature.Auto, FanControl.Feature.Step, FanControl.Feature.Rocking, FanControl.Feature.Wind, FanControl.Feature.AirflowDirection), {
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
1752
|
+
// Base fan control attributes
|
|
1753
|
+
fanMode, // Writable and persistent attribute
|
|
1754
|
+
fanModeSequence, // Fixed attribute
|
|
1755
|
+
percentSetting, // Writable attribute
|
|
873
1756
|
percentCurrent,
|
|
874
|
-
|
|
875
|
-
|
|
1757
|
+
// MultiSpeed feature
|
|
1758
|
+
speedMax, // Fixed attribute
|
|
1759
|
+
speedSetting, // Writable attribute
|
|
876
1760
|
speedCurrent,
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
1761
|
+
// Rocking feature
|
|
1762
|
+
rockSupport, // Fixed attribute
|
|
1763
|
+
rockSetting, // Writable attribute
|
|
1764
|
+
// Wind feature
|
|
1765
|
+
windSupport, // Fixed attribute
|
|
1766
|
+
windSetting, // Writable attribute
|
|
1767
|
+
// AirflowDirection feature
|
|
1768
|
+
airflowDirection, // Writable attribute
|
|
882
1769
|
});
|
|
883
1770
|
return this;
|
|
884
1771
|
}
|
|
1772
|
+
/**
|
|
1773
|
+
* Creates a default HEPA Filter Monitoring Cluster Server with features Condition and ReplacementProductList.
|
|
1774
|
+
* It supports ResourceMonitoring.Feature.Condition, ResourceMonitoring.Feature.Warning, and ResourceMonitoring.Feature.ReplacementProductList.
|
|
1775
|
+
*
|
|
1776
|
+
* @param {number} condition - The initial condition value (range 0-100). Default is 100.
|
|
1777
|
+
* @param {ResourceMonitoring.ChangeIndication} changeIndication - The initial change indication. Default is ResourceMonitoring.ChangeIndication.Ok.
|
|
1778
|
+
* @param {boolean | undefined} inPlaceIndicator - The in-place indicator. Default is true.
|
|
1779
|
+
* @param {number | undefined} lastChangedTime - The last changed time (EpochS). Default is null.
|
|
1780
|
+
* @param {ResourceMonitoring.ReplacementProduct[]} replacementProductList - The list of replacement products. Default is an empty array. It is a fixed attribute.
|
|
1781
|
+
*
|
|
1782
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1783
|
+
*
|
|
1784
|
+
* @remarks
|
|
1785
|
+
* The HEPA Filter Monitoring Cluster Server is used to monitor the status of HEPA filters.
|
|
1786
|
+
* It provides information about the condition of the filter, whether it is in place, and the last time it was changed.
|
|
1787
|
+
* The change indication can be used to indicate if the filter needs to be replaced or serviced.
|
|
1788
|
+
* The replacement product list can be used to provide a list of replacement products for the filter.
|
|
1789
|
+
* The condition attribute is fixed at 100, indicating a healthy filter.
|
|
1790
|
+
* The degradation direction is fixed at ResourceMonitoring.DegradationDirection.Down, indicating that a lower value indicates a worse condition.
|
|
1791
|
+
* The replacement product list is initialized as an empty array.
|
|
1792
|
+
*/
|
|
885
1793
|
createDefaultHepaFilterMonitoringClusterServer(condition = 100, changeIndication = ResourceMonitoring.ChangeIndication.Ok, inPlaceIndicator = true, lastChangedTime = null, replacementProductList = []) {
|
|
886
1794
|
this.behaviors.require(MatterbridgeHepaFilterMonitoringServer.with(ResourceMonitoring.Feature.Condition, ResourceMonitoring.Feature.Warning, ResourceMonitoring.Feature.ReplacementProductList), {
|
|
1795
|
+
// Feature.Condition
|
|
887
1796
|
condition,
|
|
888
|
-
degradationDirection: ResourceMonitoring.DegradationDirection.Down,
|
|
889
|
-
|
|
1797
|
+
degradationDirection: ResourceMonitoring.DegradationDirection.Down, // Fixed attribute
|
|
1798
|
+
// Feature.ReplacementProductList
|
|
1799
|
+
replacementProductList, // Fixed attribute
|
|
1800
|
+
// Base attributes
|
|
890
1801
|
changeIndication,
|
|
891
1802
|
inPlaceIndicator,
|
|
892
|
-
lastChangedTime,
|
|
1803
|
+
lastChangedTime, // Writable and persistent across restarts
|
|
893
1804
|
});
|
|
894
1805
|
return this;
|
|
895
1806
|
}
|
|
1807
|
+
/**
|
|
1808
|
+
* Creates a default Activated Carbon Filter Monitoring Cluster Server with features Condition and ReplacementProductList.
|
|
1809
|
+
* It supports ResourceMonitoring.Feature.Condition, ResourceMonitoring.Feature.Warning, and ResourceMonitoring.Feature.ReplacementProductList.
|
|
1810
|
+
*
|
|
1811
|
+
* @param {number} condition - The initial condition value (range 0-100). Default is 100.
|
|
1812
|
+
* @param {ResourceMonitoring.ChangeIndication} changeIndication - The initial change indication. Default is ResourceMonitoring.ChangeIndication.Ok.
|
|
1813
|
+
* @param {boolean | undefined} inPlaceIndicator - The in-place indicator. Default is undefined.
|
|
1814
|
+
* @param {number | undefined} lastChangedTime - The last changed time (EpochS). Default is undefined.
|
|
1815
|
+
* @param {ResourceMonitoring.ReplacementProduct[]} replacementProductList - The list of replacement products. Default is an empty array. It is a fixed attribute.
|
|
1816
|
+
*
|
|
1817
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1818
|
+
*
|
|
1819
|
+
* @remarks
|
|
1820
|
+
* The Activated Carbon Filter Monitoring Cluster Server is used to monitor the status of activated carbon filters.
|
|
1821
|
+
* It provides information about the condition of the filter, whether it is in place, and the last time it was changed.
|
|
1822
|
+
* The change indication can be used to indicate if the filter needs to be replaced or serviced.
|
|
1823
|
+
* The replacement product list can be used to provide a list of replacement products for the filter.
|
|
1824
|
+
* The condition attribute is fixed at 100, indicating a healthy filter.
|
|
1825
|
+
* The degradation direction is fixed at ResourceMonitoring.DegradationDirection.Down, indicating that a lower value indicates a worse condition.
|
|
1826
|
+
* The replacement product list is initialized as an empty array.
|
|
1827
|
+
*/
|
|
896
1828
|
createDefaultActivatedCarbonFilterMonitoringClusterServer(condition = 100, changeIndication = ResourceMonitoring.ChangeIndication.Ok, inPlaceIndicator = true, lastChangedTime = null, replacementProductList = []) {
|
|
897
1829
|
this.behaviors.require(MatterbridgeActivatedCarbonFilterMonitoringServer.with(ResourceMonitoring.Feature.Condition, ResourceMonitoring.Feature.Warning, ResourceMonitoring.Feature.ReplacementProductList), {
|
|
1830
|
+
// Feature.Condition
|
|
898
1831
|
condition,
|
|
899
1832
|
degradationDirection: ResourceMonitoring.DegradationDirection.Down,
|
|
900
|
-
|
|
1833
|
+
// Feature.ReplacementProductList
|
|
1834
|
+
replacementProductList, // Fixed attribute
|
|
1835
|
+
// Base attributes
|
|
901
1836
|
changeIndication,
|
|
902
1837
|
inPlaceIndicator,
|
|
903
|
-
lastChangedTime,
|
|
1838
|
+
lastChangedTime, // Writable and persistent across restarts
|
|
904
1839
|
});
|
|
905
1840
|
return this;
|
|
906
1841
|
}
|
|
1842
|
+
/**
|
|
1843
|
+
* Creates a default door lock cluster server.
|
|
1844
|
+
*
|
|
1845
|
+
* @param {DoorLock.LockState} [lockState] - The initial state of the lock (default: Locked).
|
|
1846
|
+
* @param {DoorLock.LockType} [lockType] - The type of the lock (default: DeadBolt).
|
|
1847
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1848
|
+
*
|
|
1849
|
+
* @remarks
|
|
1850
|
+
* All operating modes NOT supported by a lock SHALL be set to one. The value of the OperatingMode enumeration defines the related bit to be set.
|
|
1851
|
+
*/
|
|
907
1852
|
createDefaultDoorLockClusterServer(lockState = DoorLock.LockState.Locked, lockType = DoorLock.LockType.DeadBolt) {
|
|
908
1853
|
this.behaviors.require(MatterbridgeDoorLockServer.enable({ events: { doorLockAlarm: true, lockOperation: true, lockOperationError: true } }), {
|
|
909
1854
|
lockState,
|
|
910
1855
|
lockType,
|
|
911
1856
|
actuatorEnabled: false,
|
|
912
1857
|
operatingMode: DoorLock.OperatingMode.Normal,
|
|
1858
|
+
// Special case of inverted bitmap: add also alwaysSet = 2047
|
|
913
1859
|
supportedOperatingModes: { normal: false, vacation: true, privacy: true, noRemoteLockUnlock: true, passage: true, alwaysSet: 2047 },
|
|
914
1860
|
alarmMask: { lockJammed: false, lockFactoryReset: false, lockRadioPowerCycled: false, wrongCodeEntryLimit: false, frontEscutcheonRemoved: false, doorForcedOpen: false },
|
|
915
1861
|
});
|
|
916
1862
|
return this;
|
|
917
1863
|
}
|
|
1864
|
+
/**
|
|
1865
|
+
* Creates a default Mode Select cluster server.
|
|
1866
|
+
*
|
|
1867
|
+
* @param {string} description - The description of the mode select cluster.
|
|
1868
|
+
* @param {ModeSelect.ModeOption[]} supportedModes - The list of supported modes.
|
|
1869
|
+
* @param {number} [currentMode] - The current mode (default: 0).
|
|
1870
|
+
* @param {number} [startUpMode] - The startup mode (default: 0).
|
|
1871
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1872
|
+
*
|
|
1873
|
+
* @remarks
|
|
1874
|
+
* endpoint.createDefaultModeSelectClusterServer('Night mode', [{ label: 'Led ON', mode: 0, semanticTags: [] }, { label: 'Led OFF', mode: 1, semanticTags: [] }], 0, 0);
|
|
1875
|
+
*/
|
|
918
1876
|
createDefaultModeSelectClusterServer(description, supportedModes, currentMode = 0, startUpMode = 0) {
|
|
919
1877
|
this.behaviors.require(MatterbridgeModeSelectServer, {
|
|
920
1878
|
description: description,
|
|
@@ -925,21 +1883,35 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
925
1883
|
});
|
|
926
1884
|
return this;
|
|
927
1885
|
}
|
|
1886
|
+
/**
|
|
1887
|
+
* Creates the default Valve Configuration And Control cluster server with features Level.
|
|
1888
|
+
*
|
|
1889
|
+
* @param {ValveConfigurationAndControl.ValveState} [valveState] - The valve state to set. Defaults to `ValveConfigurationAndControl.ValveState.Closed`.
|
|
1890
|
+
* @param {number} [valveLevel] - The valve level to set. Defaults to 0.
|
|
1891
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1892
|
+
*/
|
|
928
1893
|
createDefaultValveConfigurationAndControlClusterServer(valveState = ValveConfigurationAndControl.ValveState.Closed, valveLevel = 0) {
|
|
929
1894
|
this.behaviors.require(MatterbridgeValveConfigurationAndControlServer.with(ValveConfigurationAndControl.Feature.Level), {
|
|
930
1895
|
currentState: valveState,
|
|
931
1896
|
targetState: valveState,
|
|
932
1897
|
openDuration: null,
|
|
933
|
-
defaultOpenDuration: null,
|
|
1898
|
+
defaultOpenDuration: null, // Writable and persistent across restarts
|
|
934
1899
|
remainingDuration: null,
|
|
935
1900
|
valveFault: { generalFault: false, blocked: false, leaking: false, notConnected: false, shortCircuit: false, currentExceeded: false },
|
|
1901
|
+
// Feature.Level
|
|
936
1902
|
currentLevel: valveLevel,
|
|
937
1903
|
targetLevel: valveLevel,
|
|
938
|
-
defaultOpenLevel: 100,
|
|
939
|
-
levelStep: 1,
|
|
1904
|
+
defaultOpenLevel: 100, // Writable and persistent across restarts
|
|
1905
|
+
levelStep: 1, // Fixed
|
|
940
1906
|
});
|
|
941
1907
|
return this;
|
|
942
1908
|
}
|
|
1909
|
+
/**
|
|
1910
|
+
* Creates the default PumpConfigurationAndControl cluster server with features ConstantSpeed.
|
|
1911
|
+
*
|
|
1912
|
+
* @param {PumpConfigurationAndControl.OperationMode} [pumpMode] - The pump mode to set. Defaults to `PumpConfigurationAndControl.OperationMode.Normal`.
|
|
1913
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1914
|
+
*/
|
|
943
1915
|
createDefaultPumpConfigurationAndControlClusterServer(pumpMode = PumpConfigurationAndControl.OperationMode.Normal) {
|
|
944
1916
|
this.behaviors.require(PumpConfigurationAndControlServer.with(PumpConfigurationAndControl.Feature.ConstantSpeed), {
|
|
945
1917
|
minConstSpeed: null,
|
|
@@ -954,6 +1926,13 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
954
1926
|
});
|
|
955
1927
|
return this;
|
|
956
1928
|
}
|
|
1929
|
+
/**
|
|
1930
|
+
* Creates the default SmokeCOAlarm Cluster Server with features SmokeAlarm and CoAlarm.
|
|
1931
|
+
*
|
|
1932
|
+
* @param {SmokeCoAlarm.AlarmState} smokeState - The state of the smoke alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
|
|
1933
|
+
* @param {SmokeCoAlarm.AlarmState} coState - The state of the CO alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
|
|
1934
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1935
|
+
*/
|
|
957
1936
|
createDefaultSmokeCOAlarmClusterServer(smokeState = SmokeCoAlarm.AlarmState.Normal, coState = SmokeCoAlarm.AlarmState.Normal) {
|
|
958
1937
|
this.behaviors.require(MatterbridgeSmokeCoAlarmServer.with(SmokeCoAlarm.Feature.SmokeAlarm, SmokeCoAlarm.Feature.CoAlarm).enable({
|
|
959
1938
|
events: { smokeAlarm: true, interconnectSmokeAlarm: false, coAlarm: true, interconnectCoAlarm: false, lowBattery: true, hardwareFault: true, endOfService: true, selfTestComplete: true, alarmMuted: true, muteEnded: true, allClear: true },
|
|
@@ -969,6 +1948,12 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
969
1948
|
});
|
|
970
1949
|
return this;
|
|
971
1950
|
}
|
|
1951
|
+
/**
|
|
1952
|
+
* Creates a smoke only SmokeCOAlarm Cluster Server with features SmokeAlarm.
|
|
1953
|
+
*
|
|
1954
|
+
* @param {SmokeCoAlarm.AlarmState} smokeState - The state of the smoke alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
|
|
1955
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1956
|
+
*/
|
|
972
1957
|
createSmokeOnlySmokeCOAlarmClusterServer(smokeState = SmokeCoAlarm.AlarmState.Normal) {
|
|
973
1958
|
this.behaviors.require(MatterbridgeSmokeCoAlarmServer.with(SmokeCoAlarm.Feature.SmokeAlarm).enable({
|
|
974
1959
|
events: { smokeAlarm: true, interconnectSmokeAlarm: false, coAlarm: false, interconnectCoAlarm: false, lowBattery: true, hardwareFault: true, endOfService: true, selfTestComplete: true, alarmMuted: true, muteEnded: true, allClear: true },
|
|
@@ -983,6 +1968,12 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
983
1968
|
});
|
|
984
1969
|
return this;
|
|
985
1970
|
}
|
|
1971
|
+
/**
|
|
1972
|
+
* Creates a co only SmokeCOAlarm Cluster Server with features CoAlarm.
|
|
1973
|
+
*
|
|
1974
|
+
* @param {SmokeCoAlarm.AlarmState} coState - The state of the CO alarm. Defaults to SmokeCoAlarm.AlarmState.Normal.
|
|
1975
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1976
|
+
*/
|
|
986
1977
|
createCoOnlySmokeCOAlarmClusterServer(coState = SmokeCoAlarm.AlarmState.Normal) {
|
|
987
1978
|
this.behaviors.require(MatterbridgeSmokeCoAlarmServer.with(SmokeCoAlarm.Feature.CoAlarm).enable({
|
|
988
1979
|
events: { smokeAlarm: false, interconnectSmokeAlarm: false, coAlarm: true, interconnectCoAlarm: false, lowBattery: true, hardwareFault: true, endOfService: true, selfTestComplete: true, alarmMuted: true, muteEnded: true, allClear: true },
|
|
@@ -997,6 +1988,15 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
997
1988
|
});
|
|
998
1989
|
return this;
|
|
999
1990
|
}
|
|
1991
|
+
/**
|
|
1992
|
+
* Creates a default momentary switch cluster server with features MomentarySwitch, MomentarySwitchRelease, MomentarySwitchLongPress and MomentarySwitchMultiPress
|
|
1993
|
+
* and events initialPress, longPress, shortRelease, longRelease, multiPressOngoing, multiPressComplete.
|
|
1994
|
+
*
|
|
1995
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
1996
|
+
*
|
|
1997
|
+
* @remarks
|
|
1998
|
+
* This method adds a cluster server with default momentary switch features and configuration suitable for (AppleHome) Single Double Long automations.
|
|
1999
|
+
*/
|
|
1000
2000
|
createDefaultSwitchClusterServer() {
|
|
1001
2001
|
this.behaviors.require(MatterbridgeSwitchServer.with(Switch.Feature.MomentarySwitch, Switch.Feature.MomentarySwitchRelease, Switch.Feature.MomentarySwitchLongPress, Switch.Feature.MomentarySwitchMultiPress).enable({
|
|
1002
2002
|
events: { initialPress: true, longPress: true, shortRelease: true, longRelease: true, multiPressOngoing: true, multiPressComplete: true },
|
|
@@ -1007,6 +2007,15 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1007
2007
|
});
|
|
1008
2008
|
return this;
|
|
1009
2009
|
}
|
|
2010
|
+
/**
|
|
2011
|
+
* Creates a default momentary switch cluster server with feature MomentarySwitch and event initialPress.
|
|
2012
|
+
*
|
|
2013
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
2014
|
+
*
|
|
2015
|
+
* @remarks
|
|
2016
|
+
* This method adds a cluster server with default momentary switch features and configuration suitable for a Single press automations.
|
|
2017
|
+
* It is supported by the Home app.
|
|
2018
|
+
*/
|
|
1010
2019
|
createDefaultMomentarySwitchClusterServer() {
|
|
1011
2020
|
this.behaviors.require(MatterbridgeSwitchServer.with(Switch.Feature.MomentarySwitch).enable({
|
|
1012
2021
|
events: { initialPress: true },
|
|
@@ -1016,6 +2025,14 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1016
2025
|
});
|
|
1017
2026
|
return this;
|
|
1018
2027
|
}
|
|
2028
|
+
/**
|
|
2029
|
+
* Creates a default latching switch cluster server with features LatchingSwitch.
|
|
2030
|
+
*
|
|
2031
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
2032
|
+
*
|
|
2033
|
+
* @remarks
|
|
2034
|
+
* This method adds a cluster server with default latching switch features and configuration suitable for a latching switch with 2 positions.
|
|
2035
|
+
*/
|
|
1019
2036
|
createDefaultLatchingSwitchClusterServer() {
|
|
1020
2037
|
this.behaviors.require(SwitchServer.with(Switch.Feature.LatchingSwitch).enable({
|
|
1021
2038
|
events: { switchLatched: true },
|
|
@@ -1025,6 +2042,15 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1025
2042
|
});
|
|
1026
2043
|
return this;
|
|
1027
2044
|
}
|
|
2045
|
+
/**
|
|
2046
|
+
* Triggers a switch event on the specified endpoint.
|
|
2047
|
+
* We usually use get from real devices something like 'single', 'double', 'long'.
|
|
2048
|
+
* Here we convert it to the Matter sequence of events (taken from Matter specs).
|
|
2049
|
+
*
|
|
2050
|
+
* @param {string} event - The type of event to trigger. Possible values are 'Single', 'Double', 'Long' for momentarySwitch and 'Press', 'Release' for latchingSwitch.
|
|
2051
|
+
* @param {AnsiLogger} log - Optional logger to log the event.
|
|
2052
|
+
* @returns {boolean} - A boolean indicating whether the event was successfully triggered.
|
|
2053
|
+
*/
|
|
1028
2054
|
async triggerSwitchEvent(event, log) {
|
|
1029
2055
|
if (this.maybeNumber === undefined) {
|
|
1030
2056
|
this.log.error(`triggerSwitchEvent ${event} error: Endpoint number not assigned on endpoint ${this.maybeId}:${this.maybeNumber}`);
|
|
@@ -1086,10 +2112,37 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1086
2112
|
}
|
|
1087
2113
|
return true;
|
|
1088
2114
|
}
|
|
2115
|
+
/**
|
|
2116
|
+
* Creates a default OperationalState Cluster Server.
|
|
2117
|
+
*
|
|
2118
|
+
* @param {OperationalState.OperationalStateEnum} operationalState - The initial operational state id.
|
|
2119
|
+
*
|
|
2120
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
2121
|
+
*
|
|
2122
|
+
* @remarks
|
|
2123
|
+
* This method adds a cluster server with a default operational state configuration:
|
|
2124
|
+
* - { operationalStateId: OperationalState.OperationalStateEnum.Stopped, operationalStateLabel: 'Stopped' },
|
|
2125
|
+
* - { operationalStateId: OperationalState.OperationalStateEnum.Running, operationalStateLabel: 'Running' },
|
|
2126
|
+
* - { operationalStateId: OperationalState.OperationalStateEnum.Paused, operationalStateLabel: 'Paused' },
|
|
2127
|
+
* - { operationalStateId: OperationalState.OperationalStateEnum.Error, operationalStateLabel: 'Error' },
|
|
2128
|
+
*/
|
|
1089
2129
|
createDefaultOperationalStateClusterServer(operationalState = OperationalState.OperationalStateEnum.Stopped) {
|
|
1090
2130
|
this.behaviors.require(MatterbridgeOperationalStateServer, getDefaultOperationalStateClusterServer(operationalState));
|
|
1091
2131
|
return this;
|
|
1092
2132
|
}
|
|
2133
|
+
/**
|
|
2134
|
+
* Creates a default boolean state cluster server.
|
|
2135
|
+
* The stateChange event is enabled.
|
|
2136
|
+
*
|
|
2137
|
+
* @param {boolean} contact - The state of the cluster. Defaults to true (true = contact).
|
|
2138
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
2139
|
+
*
|
|
2140
|
+
* @remarks
|
|
2141
|
+
* Water Leak Detector: true = leak, false = no leak
|
|
2142
|
+
* Water Freeze Detector: true = freeze, false = no freeze
|
|
2143
|
+
* Rain Sensor: true = rain, false = no rain
|
|
2144
|
+
* Contact Sensor: true = closed or contact, false = open or no contact
|
|
2145
|
+
*/
|
|
1093
2146
|
createDefaultBooleanStateClusterServer(contact) {
|
|
1094
2147
|
this.behaviors.require(BooleanStateServer.enable({
|
|
1095
2148
|
events: { stateChange: true },
|
|
@@ -1098,6 +2151,22 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1098
2151
|
});
|
|
1099
2152
|
return this;
|
|
1100
2153
|
}
|
|
2154
|
+
/**
|
|
2155
|
+
* Creates a default boolean state configuration cluster server to be used with the waterFreezeDetector, waterLeakDetector, and rainSensor device types.
|
|
2156
|
+
*
|
|
2157
|
+
* Features:
|
|
2158
|
+
* - Visual
|
|
2159
|
+
* - Audible
|
|
2160
|
+
* - SensitivityLevel
|
|
2161
|
+
*
|
|
2162
|
+
* @remarks Supports the enableDisableAlarm command.
|
|
2163
|
+
*
|
|
2164
|
+
* @param {boolean} [sensorFault] - Optional boolean value indicating the sensor fault state. Defaults to `false` if not provided.
|
|
2165
|
+
* @param {number} [currentSensitivityLevel] - The current sensitivity level. Defaults to `0` if not provided.
|
|
2166
|
+
* @param {number} [supportedSensitivityLevels] - The number of supported sensitivity levels. Defaults to `2` if not provided (min 2, max 10).
|
|
2167
|
+
* @param {number} [defaultSensitivityLevel] - The default sensitivity level. Defaults to `0` if not provided.
|
|
2168
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
2169
|
+
*/
|
|
1101
2170
|
createDefaultBooleanStateConfigurationClusterServer(sensorFault = false, currentSensitivityLevel = 0, supportedSensitivityLevels = 2, defaultSensitivityLevel = 0) {
|
|
1102
2171
|
this.behaviors.require(MatterbridgeBooleanStateConfigurationServer.with(BooleanStateConfiguration.Feature.Visual, BooleanStateConfiguration.Feature.Audible, BooleanStateConfiguration.Feature.SensitivityLevel).enable({
|
|
1103
2172
|
events: { alarmsStateChanged: true, sensorFault: true },
|
|
@@ -1112,18 +2181,51 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1112
2181
|
});
|
|
1113
2182
|
return this;
|
|
1114
2183
|
}
|
|
2184
|
+
/**
|
|
2185
|
+
* Creates a default Device Energy Management Cluster Server with feature PowerForecastReporting and with the specified ESA type, ESA canGenerate, ESA state, and power limits.
|
|
2186
|
+
*
|
|
2187
|
+
* @param {DeviceEnergyManagement.EsaType} [esaType] - The ESA type. Defaults to `DeviceEnergyManagement.EsaType.Other`.
|
|
2188
|
+
* @param {boolean} [esaCanGenerate] - Indicates if the ESA can generate energy. Defaults to `false`.
|
|
2189
|
+
* @param {DeviceEnergyManagement.EsaState} [esaState] - The ESA state. Defaults to `DeviceEnergyManagement.EsaState.Online`.
|
|
2190
|
+
* @param {number} [absMinPower] - Indicate the minimum electrical power in mw that the ESA can consume when switched on. Defaults to `0` if not provided.
|
|
2191
|
+
* @param {number} [absMaxPower] - Indicate the maximum electrical power in mw that the ESA can consume when switched on. Defaults to `0` if not provided.
|
|
2192
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
2193
|
+
*
|
|
2194
|
+
* @remarks
|
|
2195
|
+
* - The forecast attribute is set to null, indicating that there is no forecast currently available.
|
|
2196
|
+
* - The ESA type and canGenerate attributes are fixed and cannot be changed after creation.
|
|
2197
|
+
* - The ESA state is set to Online by default.
|
|
2198
|
+
* - The absolute minimum and maximum power attributes are set to 0 by default.
|
|
2199
|
+
* - For example, a battery storage inverter that can charge its battery at a maximum power of 2000W and can
|
|
2200
|
+
* discharge the battery at a maximum power of 3000W, would have a absMinPower: -3000W, absMaxPower: 2000W.
|
|
2201
|
+
*/
|
|
1115
2202
|
createDefaultDeviceEnergyManagementClusterServer(esaType = DeviceEnergyManagement.EsaType.Other, esaCanGenerate = false, esaState = DeviceEnergyManagement.EsaState.Online, absMinPower = 0, absMaxPower = 0) {
|
|
1116
2203
|
this.behaviors.require(MatterbridgeDeviceEnergyManagementServer.with(DeviceEnergyManagement.Feature.PowerForecastReporting, DeviceEnergyManagement.Feature.PowerAdjustment), {
|
|
1117
|
-
forecast: null,
|
|
1118
|
-
powerAdjustmentCapability: null,
|
|
1119
|
-
esaType,
|
|
1120
|
-
esaCanGenerate,
|
|
2204
|
+
forecast: null, // A null value indicates that there is no forecast currently available
|
|
2205
|
+
powerAdjustmentCapability: null, // A null value indicates that no power adjustment is currently possible, and nor is any adjustment currently active
|
|
2206
|
+
esaType, // Fixed attribute
|
|
2207
|
+
esaCanGenerate, // Fixed attribute
|
|
1121
2208
|
esaState,
|
|
1122
2209
|
absMinPower,
|
|
1123
2210
|
absMaxPower,
|
|
1124
2211
|
});
|
|
1125
2212
|
return this;
|
|
1126
2213
|
}
|
|
2214
|
+
/**
|
|
2215
|
+
* Creates a default EnergyManagementMode Cluster Server.
|
|
2216
|
+
*
|
|
2217
|
+
* @param {number} [currentMode] - The current mode of the EnergyManagementMode cluster. Defaults to mode 1 (DeviceEnergyManagementMode.ModeTag.NoOptimization).
|
|
2218
|
+
* @param {EnergyManagementMode.ModeOption[]} [supportedModes] - The supported modes for the DeviceEnergyManagementMode cluster. The attribute is fixed and defaults to a predefined set of cluster modes.
|
|
2219
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
2220
|
+
*
|
|
2221
|
+
* @remarks
|
|
2222
|
+
* A few examples of Device Energy Management modes and their mode tags are provided below.
|
|
2223
|
+
* - For the "No Energy Management (Forecast reporting only)" mode, tags: 0x4000 (NoOptimization).
|
|
2224
|
+
* - For the "Device Energy Management" mode, tags: 0x4001 (DeviceOptimization).
|
|
2225
|
+
* - For the "Home Energy Management" mode, tags: 0x4001 (DeviceOptimization), 0x4002 (LocalOptimization).
|
|
2226
|
+
* - For the "Grid Energy Management" mode, tags: 0x4003 (GridOptimization).
|
|
2227
|
+
* - For the "Full Energy Management" mode, tags: 0x4001 (DeviceOptimization), 0x4002 (LocalOptimization), 0x4003 (GridOptimization).
|
|
2228
|
+
*/
|
|
1127
2229
|
createDefaultDeviceEnergyManagementModeClusterServer(currentMode, supportedModes) {
|
|
1128
2230
|
this.behaviors.require(MatterbridgeDeviceEnergyManagementModeServer, {
|
|
1129
2231
|
supportedModes: supportedModes ?? [
|
|
@@ -1144,15 +2246,27 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1144
2246
|
mode: 5,
|
|
1145
2247
|
modeTags: [{ value: DeviceEnergyManagementMode.ModeTag.DeviceOptimization }, { value: DeviceEnergyManagementMode.ModeTag.LocalOptimization }, { value: DeviceEnergyManagementMode.ModeTag.GridOptimization }],
|
|
1146
2248
|
},
|
|
1147
|
-
],
|
|
2249
|
+
], // Fixed attribute
|
|
1148
2250
|
currentMode: currentMode ?? 1,
|
|
1149
2251
|
});
|
|
1150
2252
|
return this;
|
|
1151
2253
|
}
|
|
2254
|
+
/**
|
|
2255
|
+
* Creates a default Power Topology Cluster Server with feature TreeTopology (the endpoint provides or consumes power to/from itself and its child endpoints). Only needed for an electricalSensor device type.
|
|
2256
|
+
*
|
|
2257
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
2258
|
+
*/
|
|
1152
2259
|
createDefaultPowerTopologyClusterServer() {
|
|
1153
2260
|
this.behaviors.require(PowerTopologyServer.with(PowerTopology.Feature.TreeTopology));
|
|
1154
2261
|
return this;
|
|
1155
2262
|
}
|
|
2263
|
+
/**
|
|
2264
|
+
* Creates a default Electrical Energy Measurement Cluster Server with features ImportedEnergy, ExportedEnergy, and CumulativeEnergy.
|
|
2265
|
+
*
|
|
2266
|
+
* @param {number} energyImported - The total consumption value in mW/h.
|
|
2267
|
+
* @param {number} energyExported - The total production value in mW/h.
|
|
2268
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
2269
|
+
*/
|
|
1156
2270
|
createDefaultElectricalEnergyMeasurementClusterServer(energyImported = null, energyExported = null) {
|
|
1157
2271
|
this.behaviors.require(ElectricalEnergyMeasurementServer.with(ElectricalEnergyMeasurement.Feature.ImportedEnergy, ElectricalEnergyMeasurement.Feature.ExportedEnergy, ElectricalEnergyMeasurement.Feature.CumulativeEnergy), {
|
|
1158
2272
|
accuracy: {
|
|
@@ -1168,6 +2282,15 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1168
2282
|
});
|
|
1169
2283
|
return this;
|
|
1170
2284
|
}
|
|
2285
|
+
/**
|
|
2286
|
+
* Creates a default Electrical Power Measurement Cluster Server with features AlternatingCurrent.
|
|
2287
|
+
*
|
|
2288
|
+
* @param {number} voltage - The voltage value in millivolts.
|
|
2289
|
+
* @param {number} current - The current value in milliamperes.
|
|
2290
|
+
* @param {number} power - The power value in milliwatts.
|
|
2291
|
+
* @param {number} frequency - The frequency value in millihertz.
|
|
2292
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
2293
|
+
*/
|
|
1171
2294
|
createDefaultElectricalPowerMeasurementClusterServer(voltage = null, current = null, power = null, frequency = null) {
|
|
1172
2295
|
this.behaviors.require(ElectricalPowerMeasurementServer.with(ElectricalPowerMeasurement.Feature.AlternatingCurrent), {
|
|
1173
2296
|
powerMode: ElectricalPowerMeasurement.PowerMode.Ac,
|
|
@@ -1209,36 +2332,127 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1209
2332
|
});
|
|
1210
2333
|
return this;
|
|
1211
2334
|
}
|
|
2335
|
+
/**
|
|
2336
|
+
* Creates a default TemperatureMeasurement cluster server.
|
|
2337
|
+
*
|
|
2338
|
+
* @param {number | null} measuredValue - The measured value of the temperature x 100.
|
|
2339
|
+
* @param {number | null} minMeasuredValue - The minimum measured value of the temperature x 100.
|
|
2340
|
+
* @param {number | null} maxMeasuredValue - The maximum measured value of the temperature x 100.
|
|
2341
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
2342
|
+
*/
|
|
1212
2343
|
createDefaultTemperatureMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
1213
2344
|
this.behaviors.require(TemperatureMeasurementServer, getDefaultTemperatureMeasurementClusterServer(measuredValue, minMeasuredValue, maxMeasuredValue));
|
|
1214
2345
|
return this;
|
|
1215
2346
|
}
|
|
2347
|
+
/**
|
|
2348
|
+
* Creates a default RelativeHumidityMeasurement cluster server.
|
|
2349
|
+
*
|
|
2350
|
+
* @param {number | null} measuredValue - The measured value of the relative humidity x 100.
|
|
2351
|
+
* @param {number | null} minMeasuredValue - The minimum measured value of the relative humidity x 100.
|
|
2352
|
+
* @param {number | null} maxMeasuredValue - The maximum measured value of the relative humidity x 100.
|
|
2353
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
2354
|
+
*/
|
|
1216
2355
|
createDefaultRelativeHumidityMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
1217
2356
|
this.behaviors.require(RelativeHumidityMeasurementServer, getDefaultRelativeHumidityMeasurementClusterServer(measuredValue, minMeasuredValue, maxMeasuredValue));
|
|
1218
2357
|
return this;
|
|
1219
2358
|
}
|
|
2359
|
+
/**
|
|
2360
|
+
* Creates a default PressureMeasurement cluster server.
|
|
2361
|
+
*
|
|
2362
|
+
* @param {number | null} measuredValue - The measured value for the pressure in kPa x 10.
|
|
2363
|
+
* @param {number | null} minMeasuredValue - The minimum measured value for the pressure in kPa x 10.
|
|
2364
|
+
* @param {number | null} maxMeasuredValue - The maximum measured value for the pressure in kPa x 10.
|
|
2365
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
2366
|
+
*
|
|
2367
|
+
* @remarks
|
|
2368
|
+
* - MeasuredValue = 10 x Pressure in kPa
|
|
2369
|
+
* - MeasuredValue = 1 x Pressure in hPa
|
|
2370
|
+
* - MeasuredValue = 33.8639 x Pressure in inHg
|
|
2371
|
+
*
|
|
2372
|
+
* Conversion:
|
|
2373
|
+
* - 1 kPa = 10 hPa
|
|
2374
|
+
* - 1 inHg = 33.8639 hPa
|
|
2375
|
+
*/
|
|
1220
2376
|
createDefaultPressureMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
1221
2377
|
this.behaviors.require(PressureMeasurementServer, getDefaultPressureMeasurementClusterServer(measuredValue, minMeasuredValue, maxMeasuredValue));
|
|
1222
2378
|
return this;
|
|
1223
2379
|
}
|
|
2380
|
+
/**
|
|
2381
|
+
* Creates a default IlluminanceMeasurement cluster server.
|
|
2382
|
+
*
|
|
2383
|
+
* @param {number | null} measuredValue - The measured value of illuminance.
|
|
2384
|
+
* @param {number | null} minMeasuredValue - The minimum measured value of illuminance.
|
|
2385
|
+
* @param {number | null} maxMeasuredValue - The maximum measured value of illuminance.
|
|
2386
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
2387
|
+
*
|
|
2388
|
+
* @remarks
|
|
2389
|
+
*
|
|
2390
|
+
* The default value for the illuminance measurement is null.
|
|
2391
|
+
*
|
|
2392
|
+
* This attribute SHALL indicate the illuminance in Lux (symbol lx) as follows:
|
|
2393
|
+
* • MeasuredValue = 10,000 x log10(illuminance) + 1,
|
|
2394
|
+
* where 1 lx <= illuminance <= 3.576 Mlx, corresponding to a MeasuredValue in the range 1 to 0xFFFE.
|
|
2395
|
+
* • 0 indicates a value of illuminance that is too low to be measured
|
|
2396
|
+
* • null indicates that the illuminance measurement is invalid.
|
|
2397
|
+
*
|
|
2398
|
+
* - Lux to matter = Math.round(Math.max(Math.min(10000 * Math.log10(lux), 0xfffe), 0))
|
|
2399
|
+
* - Matter to Lux = Math.round(Math.max(Math.pow(10, value / 10000), 0))
|
|
2400
|
+
*/
|
|
1224
2401
|
createDefaultIlluminanceMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
1225
2402
|
this.behaviors.require(IlluminanceMeasurementServer, getDefaultIlluminanceMeasurementClusterServer(measuredValue, minMeasuredValue, maxMeasuredValue));
|
|
1226
2403
|
return this;
|
|
1227
2404
|
}
|
|
2405
|
+
/**
|
|
2406
|
+
* Creates a default FlowMeasurement cluster server.
|
|
2407
|
+
*
|
|
2408
|
+
* @param {number | null} measuredValue - The measured value of the flow in 10 x m3/h.
|
|
2409
|
+
* @param {number | null} minMeasuredValue - The minimum measured value of the flow in 10 x m3/h.
|
|
2410
|
+
* @param {number | null} maxMeasuredValue - The maximum measured value of the flow in 10 x m3/h.
|
|
2411
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
2412
|
+
*/
|
|
1228
2413
|
createDefaultFlowMeasurementClusterServer(measuredValue = null, minMeasuredValue = null, maxMeasuredValue = null) {
|
|
1229
2414
|
this.behaviors.require(FlowMeasurementServer, getDefaultFlowMeasurementClusterServer(measuredValue, minMeasuredValue, maxMeasuredValue));
|
|
1230
2415
|
return this;
|
|
1231
2416
|
}
|
|
2417
|
+
/**
|
|
2418
|
+
* Creates a default OccupancySensing cluster server with feature PassiveInfrared.
|
|
2419
|
+
*
|
|
2420
|
+
* @param {boolean} occupied - A boolean indicating whether the occupancy is occupied or not. Default is false.
|
|
2421
|
+
* @param {number} holdTime - The hold time in seconds. Default is 30.
|
|
2422
|
+
* @param {number} holdTimeMin - The minimum hold time in seconds. Default is 1.
|
|
2423
|
+
* @param {number} holdTimeMax - The maximum hold time in seconds. Default is 300.
|
|
2424
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
2425
|
+
*
|
|
2426
|
+
* @remarks The default value for the occupancy sensor type is PIR.
|
|
2427
|
+
*/
|
|
1232
2428
|
createDefaultOccupancySensingClusterServer(occupied = false, holdTime = 30, holdTimeMin = 1, holdTimeMax = 300) {
|
|
1233
2429
|
this.behaviors.require(OccupancySensingServer.with(OccupancySensing.Feature.PassiveInfrared), getDefaultOccupancySensingClusterServer(occupied, holdTime, holdTimeMin, holdTimeMax));
|
|
1234
2430
|
return this;
|
|
1235
2431
|
}
|
|
2432
|
+
/**
|
|
2433
|
+
* Creates a default AirQuality cluster server.
|
|
2434
|
+
*
|
|
2435
|
+
* @param {AirQuality.AirQualityEnum} airQuality The air quality level. Defaults to `AirQuality.AirQualityType.Unknown`.
|
|
2436
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
2437
|
+
*/
|
|
1236
2438
|
createDefaultAirQualityClusterServer(airQuality = AirQuality.AirQualityEnum.Unknown) {
|
|
1237
2439
|
this.behaviors.require(AirQualityServer.with(AirQuality.Feature.Fair, AirQuality.Feature.Moderate, AirQuality.Feature.VeryPoor, AirQuality.Feature.ExtremelyPoor), {
|
|
1238
2440
|
airQuality,
|
|
1239
2441
|
});
|
|
1240
2442
|
return this;
|
|
1241
2443
|
}
|
|
2444
|
+
/**
|
|
2445
|
+
* Creates a default TotalVolatileOrganicCompoundsConcentrationMeasurement cluster server with feature NumericMeasurement.
|
|
2446
|
+
*
|
|
2447
|
+
* @param {number | null} measuredValue - The measured value of the concentration.
|
|
2448
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
|
|
2449
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
|
|
2450
|
+
* @param {number} [uncertainty] - The uncertainty value (optional).
|
|
2451
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
2452
|
+
*
|
|
2453
|
+
* @remarks
|
|
2454
|
+
* The measurementUnit and the measurementMedium attributes are fixed and cannot be changed after creation.
|
|
2455
|
+
*/
|
|
1242
2456
|
createDefaultTvocMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air, uncertainty) {
|
|
1243
2457
|
this.behaviors.require(TotalVolatileOrganicCompoundsConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
|
|
1244
2458
|
measuredValue,
|
|
@@ -1250,6 +2464,16 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1250
2464
|
});
|
|
1251
2465
|
return this;
|
|
1252
2466
|
}
|
|
2467
|
+
/**
|
|
2468
|
+
* Creates a default TotalVolatileOrganicCompoundsConcentrationMeasurement cluster server with feature LevelIndication, MediumLevel and CriticalLevel.
|
|
2469
|
+
*
|
|
2470
|
+
* @param {ConcentrationMeasurement.LevelValue} levelValue - The level value of the measurement (default to ConcentrationMeasurement.LevelValue.Unknown).
|
|
2471
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The measurement medium (default to ConcentrationMeasurement.MeasurementMedium.Air).
|
|
2472
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
2473
|
+
*
|
|
2474
|
+
* @remarks
|
|
2475
|
+
* The measurementMedium attribute is fixed and cannot be changed after creation.
|
|
2476
|
+
*/
|
|
1253
2477
|
createLevelTvocMeasurementClusterServer(levelValue = ConcentrationMeasurement.LevelValue.Unknown, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1254
2478
|
this.behaviors.require(TotalVolatileOrganicCompoundsConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.LevelIndication, ConcentrationMeasurement.Feature.MediumLevel, ConcentrationMeasurement.Feature.CriticalLevel), {
|
|
1255
2479
|
levelValue,
|
|
@@ -1257,6 +2481,17 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1257
2481
|
});
|
|
1258
2482
|
return this;
|
|
1259
2483
|
}
|
|
2484
|
+
/**
|
|
2485
|
+
* Create a default CarbonMonoxideConcentrationMeasurement cluster server with feature NumericMeasurement.
|
|
2486
|
+
*
|
|
2487
|
+
* @param {number | null} measuredValue - The measured value of the concentration.
|
|
2488
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
|
|
2489
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
|
|
2490
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
2491
|
+
*
|
|
2492
|
+
* @remarks
|
|
2493
|
+
* The measurementUnit and the measurementMedium attributes are fixed and cannot be changed after creation.
|
|
2494
|
+
*/
|
|
1260
2495
|
createDefaultCarbonMonoxideConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1261
2496
|
this.behaviors.require(CarbonMonoxideConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
|
|
1262
2497
|
measuredValue,
|
|
@@ -1268,6 +2503,17 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1268
2503
|
});
|
|
1269
2504
|
return this;
|
|
1270
2505
|
}
|
|
2506
|
+
/**
|
|
2507
|
+
* Create a default CarbonDioxideConcentrationMeasurement cluster server with feature NumericMeasurement.
|
|
2508
|
+
*
|
|
2509
|
+
* @param {number | null} measuredValue - The measured value of the concentration.
|
|
2510
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
|
|
2511
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
|
|
2512
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
2513
|
+
*
|
|
2514
|
+
* @remarks
|
|
2515
|
+
* The measurementUnit and the measurementMedium attributes are fixed and cannot be changed after creation.
|
|
2516
|
+
*/
|
|
1271
2517
|
createDefaultCarbonDioxideConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1272
2518
|
this.behaviors.require(CarbonDioxideConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
|
|
1273
2519
|
measuredValue,
|
|
@@ -1279,6 +2525,17 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1279
2525
|
});
|
|
1280
2526
|
return this;
|
|
1281
2527
|
}
|
|
2528
|
+
/**
|
|
2529
|
+
* Create a default FormaldehydeConcentrationMeasurement cluster server with feature NumericMeasurement.
|
|
2530
|
+
*
|
|
2531
|
+
* @param {number | null} measuredValue - The measured value of the concentration.
|
|
2532
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
|
|
2533
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
|
|
2534
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
2535
|
+
*
|
|
2536
|
+
* @remarks
|
|
2537
|
+
* The measurementUnit and the measurementMedium attributes are fixed and cannot be changed after creation.
|
|
2538
|
+
*/
|
|
1282
2539
|
createDefaultFormaldehydeConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1283
2540
|
this.behaviors.require(FormaldehydeConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
|
|
1284
2541
|
measuredValue,
|
|
@@ -1290,6 +2547,17 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1290
2547
|
});
|
|
1291
2548
|
return this;
|
|
1292
2549
|
}
|
|
2550
|
+
/**
|
|
2551
|
+
* Create a default Pm1ConcentrationMeasurement cluster server with feature NumericMeasurement.
|
|
2552
|
+
*
|
|
2553
|
+
* @param {number | null} measuredValue - The measured value of the concentration.
|
|
2554
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
|
|
2555
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
|
|
2556
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
2557
|
+
*
|
|
2558
|
+
* @remarks
|
|
2559
|
+
* The measurementUnit and the measurementMedium attributes are fixed and cannot be changed after creation.
|
|
2560
|
+
*/
|
|
1293
2561
|
createDefaultPm1ConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1294
2562
|
this.behaviors.require(Pm1ConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
|
|
1295
2563
|
measuredValue,
|
|
@@ -1301,6 +2569,17 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1301
2569
|
});
|
|
1302
2570
|
return this;
|
|
1303
2571
|
}
|
|
2572
|
+
/**
|
|
2573
|
+
* Create a default Pm25ConcentrationMeasurement cluster server with feature NumericMeasurement.
|
|
2574
|
+
*
|
|
2575
|
+
* @param {number | null} measuredValue - The measured value of the concentration.
|
|
2576
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
|
|
2577
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
|
|
2578
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
2579
|
+
*
|
|
2580
|
+
* @remarks
|
|
2581
|
+
* The measurementUnit and the measurementMedium attributes are fixed and cannot be changed after creation.
|
|
2582
|
+
*/
|
|
1304
2583
|
createDefaultPm25ConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1305
2584
|
this.behaviors.require(Pm25ConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
|
|
1306
2585
|
measuredValue,
|
|
@@ -1312,6 +2591,17 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1312
2591
|
});
|
|
1313
2592
|
return this;
|
|
1314
2593
|
}
|
|
2594
|
+
/**
|
|
2595
|
+
* Create a default Pm10ConcentrationMeasurement cluster server with feature NumericMeasurement.
|
|
2596
|
+
*
|
|
2597
|
+
* @param {number | null} measuredValue - The measured value of the concentration.
|
|
2598
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
|
|
2599
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
|
|
2600
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
2601
|
+
*
|
|
2602
|
+
* @remarks
|
|
2603
|
+
* The measurementUnit and the measurementMedium attributes are fixed and cannot be changed after creation.
|
|
2604
|
+
*/
|
|
1315
2605
|
createDefaultPm10ConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1316
2606
|
this.behaviors.require(Pm10ConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
|
|
1317
2607
|
measuredValue,
|
|
@@ -1323,6 +2613,17 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1323
2613
|
});
|
|
1324
2614
|
return this;
|
|
1325
2615
|
}
|
|
2616
|
+
/**
|
|
2617
|
+
* Create a default OzoneConcentrationMeasurement cluster server with feature NumericMeasurement.
|
|
2618
|
+
*
|
|
2619
|
+
* @param {number | null} measuredValue - The measured value of the concentration.
|
|
2620
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ugm3).
|
|
2621
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
|
|
2622
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
2623
|
+
*
|
|
2624
|
+
* @remarks
|
|
2625
|
+
* The measurementUnit and the measurementMedium attributes are fixed and cannot be changed after creation.
|
|
2626
|
+
*/
|
|
1326
2627
|
createDefaultOzoneConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ugm3, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1327
2628
|
this.behaviors.require(OzoneConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
|
|
1328
2629
|
measuredValue,
|
|
@@ -1334,6 +2635,17 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1334
2635
|
});
|
|
1335
2636
|
return this;
|
|
1336
2637
|
}
|
|
2638
|
+
/**
|
|
2639
|
+
* Create a default RadonConcentrationMeasurement cluster server with feature NumericMeasurement.
|
|
2640
|
+
*
|
|
2641
|
+
* @param {number | null} measuredValue - The measured value of the concentration.
|
|
2642
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ppm).
|
|
2643
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
|
|
2644
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
2645
|
+
*
|
|
2646
|
+
* @remarks
|
|
2647
|
+
* The measurementUnit and the measurementMedium attributes are fixed and cannot be changed after creation.
|
|
2648
|
+
*/
|
|
1337
2649
|
createDefaultRadonConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ppm, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1338
2650
|
this.behaviors.require(RadonConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
|
|
1339
2651
|
measuredValue,
|
|
@@ -1345,6 +2657,17 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1345
2657
|
});
|
|
1346
2658
|
return this;
|
|
1347
2659
|
}
|
|
2660
|
+
/**
|
|
2661
|
+
* Create a default NitrogenDioxideConcentrationMeasurement cluster server with feature NumericMeasurement.
|
|
2662
|
+
*
|
|
2663
|
+
* @param {number | null} measuredValue - The measured value of the concentration.
|
|
2664
|
+
* @param {ConcentrationMeasurement.MeasurementUnit} measurementUnit - The unit of measurement (default to ConcentrationMeasurement.MeasurementUnit.Ugm3).
|
|
2665
|
+
* @param {ConcentrationMeasurement.MeasurementMedium} measurementMedium - The unit of measurement (default to ConcentrationMeasurement.MeasurementMedium.Air).
|
|
2666
|
+
* @returns {this} The current MatterbridgeEndpoint instance for chaining.
|
|
2667
|
+
*
|
|
2668
|
+
* @remarks
|
|
2669
|
+
* The measurementUnit and the measurementMedium attributes are fixed and cannot be changed after creation.
|
|
2670
|
+
*/
|
|
1348
2671
|
createDefaultNitrogenDioxideConcentrationMeasurementClusterServer(measuredValue = null, measurementUnit = ConcentrationMeasurement.MeasurementUnit.Ugm3, measurementMedium = ConcentrationMeasurement.MeasurementMedium.Air) {
|
|
1349
2672
|
this.behaviors.require(NitrogenDioxideConcentrationMeasurementServer.with(ConcentrationMeasurement.Feature.NumericMeasurement), {
|
|
1350
2673
|
measuredValue,
|
|
@@ -1357,3 +2680,4 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1357
2680
|
return this;
|
|
1358
2681
|
}
|
|
1359
2682
|
}
|
|
2683
|
+
//# sourceMappingURL=matterbridgeEndpoint.js.map
|