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