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