matterbridge-example-dynamic-platform 2.0.19-dev-20260606-273db3d → 2.0.19-dev-20260614-df71f89
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/module.js +361 -361
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/dist/module.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { aggregator, airPurifier, airQualitySensor, bridgedNode, colorTemperatureLight, contactSensor,
|
|
1
|
+
import { aggregator, airPurifier, airQualitySensor, bridgedNode, colorTemperatureLight, contactSensor, windowCovering, dimmableLight, mountedDimmableLoadControl, dimmablePlugInUnit, doorLock, electricalSensor, extendedColorLight, fan, flowSensor, genericSwitch, getSemtag, humiditySensor, lightSensor, MatterbridgeDynamicPlatform, MatterbridgeEndpoint, modeSelect, occupancySensor, onOffLight, mountedOnOffControl, onOffPlugInUnit, onOffLightSwitch, powerSource, pressureSensor, pump, rainSensor, smokeCoAlarm, temperatureSensor, thermostat, waterFreezeDetector, waterLeakDetector, waterValve, } from 'matterbridge';
|
|
2
2
|
import { AirConditioner, BasicVideoPlayer, BatteryStorage, Cooktop, Dishwasher, Evse, ExtractorHood, HeatPump, IrrigationSystem, LaundryDryer, LaundryWasher, MicrowaveOven, Oven, Refrigerator, RoboticVacuumCleaner, SoilSensor, SolarPower, Speaker, WaterHeater, } from 'matterbridge/devices';
|
|
3
3
|
import { debugStringify } from 'matterbridge/logger';
|
|
4
4
|
import { AreaNamespaceTag, LocationTag, NumberTag, PositionTag, RefrigeratorTag, SwitchesTag, UINT16_MAX, UINT32_MAX } from 'matterbridge/matter';
|
|
5
|
-
import { AirQuality, BooleanState, BridgedDeviceBasicInformation, CarbonDioxideConcentrationMeasurement, CarbonMonoxideConcentrationMeasurement, ColorControl, Descriptor, DeviceEnergyManagement, DoorLock, ElectricalEnergyMeasurement, ElectricalPowerMeasurement, EnergyEvse, EnergyEvseMode, FanControl, FlowMeasurement, FormaldehydeConcentrationMeasurement, Identify, IlluminanceMeasurement, LevelControl, NitrogenDioxideConcentrationMeasurement, OccupancySensing, OnOff,
|
|
5
|
+
import { AirQuality, BooleanState, BridgedDeviceBasicInformation, CarbonDioxideConcentrationMeasurement, CarbonMonoxideConcentrationMeasurement, ColorControl, Descriptor, DeviceEnergyManagement, DoorLock, ElectricalEnergyMeasurement, ElectricalPowerMeasurement, EnergyEvse, EnergyEvseMode, FanControl, FlowMeasurement, FormaldehydeConcentrationMeasurement, Identify, IlluminanceMeasurement, LevelControl, NitrogenDioxideConcentrationMeasurement, OccupancySensing, OnOff, OperationalState, OvenMode, OzoneConcentrationMeasurement, Pm1ConcentrationMeasurement, Pm10ConcentrationMeasurement, Pm25ConcentrationMeasurement, PowerSource, PressureMeasurement, RadonConcentrationMeasurement, RelativeHumidityMeasurement, RvcCleanMode, RvcOperationalState, RvcRunMode, SmokeCoAlarm, TemperatureMeasurement, Thermostat, TotalVolatileOrganicCompoundsConcentrationMeasurement, WindowCovering, } from 'matterbridge/matter/clusters';
|
|
6
6
|
import { fireAndForget, getEnumDescription, isValidBoolean, isValidNumber, isValidObject, isValidString } from 'matterbridge/utils';
|
|
7
7
|
function luxToMatter(lux) {
|
|
8
8
|
if (!Number.isFinite(lux) || lux <= 0)
|
|
@@ -106,8 +106,8 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
106
106
|
constructor(matterbridge, log, config) {
|
|
107
107
|
super(matterbridge, log, config);
|
|
108
108
|
this.config = config;
|
|
109
|
-
if (typeof this.verifyMatterbridgeVersion !== 'function' || !this.verifyMatterbridgeVersion('3.
|
|
110
|
-
throw new Error(`This plugin requires Matterbridge version >= "3.
|
|
109
|
+
if (typeof this.verifyMatterbridgeVersion !== 'function' || !this.verifyMatterbridgeVersion('3.9.0')) {
|
|
110
|
+
throw new Error(`This plugin requires Matterbridge version >= "3.9.0". Please update Matterbridge from ${this.matterbridge.matterbridgeVersion} to the latest version in the frontend.`);
|
|
111
111
|
}
|
|
112
112
|
this.log.info('Initializing platform:', this.config.name);
|
|
113
113
|
}
|
|
@@ -195,7 +195,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
195
195
|
this.select?.addCommandHandler('changeToMode', ({ request: { newMode } }) => {
|
|
196
196
|
this.log.info(`Command changeToMode called newMode:${newMode}`);
|
|
197
197
|
});
|
|
198
|
-
this.switch = new MatterbridgeEndpoint([
|
|
198
|
+
this.switch = new MatterbridgeEndpoint([onOffLightSwitch, bridgedNode, powerSource], { id: 'Switch' }, this.config.debug)
|
|
199
199
|
.createDefaultIdentifyClusterServer()
|
|
200
200
|
.createDefaultBridgedDeviceBasicInformationClusterServer('Switch', 'SWI00010', 0xfff1, 'Matterbridge', 'Matterbridge Switch')
|
|
201
201
|
.createDefaultOnOffClusterServer()
|
|
@@ -211,7 +211,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
211
211
|
this.switch?.addCommandHandler('off', () => {
|
|
212
212
|
this.switch?.log.info('Command off called');
|
|
213
213
|
});
|
|
214
|
-
this.mountedOnOffSwitch = new MatterbridgeEndpoint([
|
|
214
|
+
this.mountedOnOffSwitch = new MatterbridgeEndpoint([mountedOnOffControl, bridgedNode, powerSource], { id: 'mountedOnOffControl' }, this.config.debug)
|
|
215
215
|
.createDefaultIdentifyClusterServer()
|
|
216
216
|
.createDefaultBridgedDeviceBasicInformationClusterServer('OnOff Mounted Switch', 'OMS00011', 0xfff1, 'Matterbridge', 'Matterbridge OnOff Mounted Switch')
|
|
217
217
|
.createDefaultOnOffClusterServer()
|
|
@@ -227,7 +227,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
227
227
|
this.mountedOnOffSwitch?.addCommandHandler('off', () => {
|
|
228
228
|
this.mountedOnOffSwitch?.log.info('Command off called');
|
|
229
229
|
});
|
|
230
|
-
this.mountedOnOffSwitchLegacy = new MatterbridgeEndpoint([
|
|
230
|
+
this.mountedOnOffSwitchLegacy = new MatterbridgeEndpoint([mountedOnOffControl, onOffPlugInUnit, bridgedNode, powerSource], { id: 'OnOffMountedSwitchLegacy' }, this.config.debug)
|
|
231
231
|
.createDefaultIdentifyClusterServer()
|
|
232
232
|
.createDefaultBridgedDeviceBasicInformationClusterServer('OnOff Mounted Switch Legacy', 'OMSL00011', 0xfff1, 'Matterbridge', 'Matterbridge OnOff Mounted Switch Legacy')
|
|
233
233
|
.createDefaultOnOffClusterServer()
|
|
@@ -243,7 +243,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
243
243
|
this.mountedOnOffSwitchLegacy?.addCommandHandler('off', () => {
|
|
244
244
|
this.mountedOnOffSwitchLegacy?.log.info('Command off called');
|
|
245
245
|
});
|
|
246
|
-
this.mountedDimmerSwitch = new MatterbridgeEndpoint([
|
|
246
|
+
this.mountedDimmerSwitch = new MatterbridgeEndpoint([mountedDimmableLoadControl, bridgedNode, powerSource], { id: 'DimmerMountedSwitch' }, this.config.debug)
|
|
247
247
|
.createDefaultIdentifyClusterServer()
|
|
248
248
|
.createDefaultBridgedDeviceBasicInformationClusterServer('Dimmer Mounted Switch', 'DMS00012', 0xfff1, 'Matterbridge', 'Matterbridge Dimmer Mounted Switch')
|
|
249
249
|
.createDefaultOnOffClusterServer()
|
|
@@ -266,7 +266,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
266
266
|
this.mountedDimmerSwitch?.addCommandHandler('moveToLevelWithOnOff', ({ request: { level } }) => {
|
|
267
267
|
this.mountedDimmerSwitch?.log.debug(`Command moveToLevelWithOnOff called request: ${level}`);
|
|
268
268
|
});
|
|
269
|
-
this.mountedDimmerSwitchLegacy = new MatterbridgeEndpoint([
|
|
269
|
+
this.mountedDimmerSwitchLegacy = new MatterbridgeEndpoint([mountedDimmableLoadControl, dimmablePlugInUnit, bridgedNode, powerSource], { id: 'DimmerMountedSwitchLegacy' }, this.config.debug)
|
|
270
270
|
.createDefaultIdentifyClusterServer()
|
|
271
271
|
.createDefaultBridgedDeviceBasicInformationClusterServer('Dimmer Mounted Switch Legacy', 'DMSL00012', 0xfff1, 'Matterbridge', 'Matterbridge Dimmer Mounted Switch Legacy')
|
|
272
272
|
.createDefaultOnOffClusterServer()
|
|
@@ -460,7 +460,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
460
460
|
this.lightCT?.addCommandHandler('moveToColorTemperature', ({ request: { colorTemperatureMireds } }) => {
|
|
461
461
|
this.lightCT?.log.debug(`Command moveToColorTemperature called request: ${colorTemperatureMireds}`);
|
|
462
462
|
});
|
|
463
|
-
this.outlet = new MatterbridgeEndpoint([
|
|
463
|
+
this.outlet = new MatterbridgeEndpoint([onOffPlugInUnit, bridgedNode, powerSource], { id: 'Outlet' }, this.config.debug)
|
|
464
464
|
.createDefaultIdentifyClusterServer()
|
|
465
465
|
.createDefaultBridgedDeviceBasicInformationClusterServer('Outlet', 'OUT00019', 0xfff1, 'Matterbridge', 'Matterbridge Outlet')
|
|
466
466
|
.createDefaultOnOffClusterServer()
|
|
@@ -476,7 +476,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
476
476
|
this.outlet?.addCommandHandler('off', () => {
|
|
477
477
|
this.outlet?.log.info('Command off called');
|
|
478
478
|
});
|
|
479
|
-
this.outletEnergy = new MatterbridgeEndpoint([
|
|
479
|
+
this.outletEnergy = new MatterbridgeEndpoint([onOffPlugInUnit, electricalSensor, bridgedNode, powerSource], { id: 'OutletEnergy' }, this.config.debug)
|
|
480
480
|
.createDefaultIdentifyClusterServer()
|
|
481
481
|
.createDefaultElectricalEnergyMeasurementClusterServer(0, 0)
|
|
482
482
|
.createDefaultElectricalPowerMeasurementClusterServer(220_000, 0, 0, 50_000)
|
|
@@ -494,7 +494,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
494
494
|
this.outletEnergy?.addCommandHandler('off', () => {
|
|
495
495
|
this.outletEnergy?.log.info('Command off called');
|
|
496
496
|
});
|
|
497
|
-
this.outletEnergyApparent = new MatterbridgeEndpoint([
|
|
497
|
+
this.outletEnergyApparent = new MatterbridgeEndpoint([onOffPlugInUnit, electricalSensor, bridgedNode, powerSource], { id: 'OutletEnergyApparent' }, this.config.debug)
|
|
498
498
|
.createDefaultIdentifyClusterServer()
|
|
499
499
|
.createDefaultElectricalEnergyMeasurementClusterServer(0, 0)
|
|
500
500
|
.createApparentElectricalPowerMeasurementClusterServer(220_000, 0, 0, 50_000)
|
|
@@ -520,25 +520,25 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
520
520
|
.addRequiredClusterServers();
|
|
521
521
|
fireAndForget(this.smartOutlet.addFixedLabel('composed', 'Compound device'), this.log, `Failed to add fixed label`);
|
|
522
522
|
this.smartOutlet
|
|
523
|
-
.addChildDeviceTypeWithClusterServer('Socket 1',
|
|
523
|
+
.addChildDeviceTypeWithClusterServer('Socket 1', onOffPlugInUnit, [OnOff.id], {
|
|
524
524
|
id: 'Socket1',
|
|
525
525
|
tagList: [getSemtag(NumberTag.One)],
|
|
526
526
|
})
|
|
527
527
|
.addRequiredClusterServers();
|
|
528
528
|
this.smartOutlet
|
|
529
|
-
.addChildDeviceTypeWithClusterServer('Socket 2',
|
|
529
|
+
.addChildDeviceTypeWithClusterServer('Socket 2', onOffPlugInUnit, [OnOff.id], {
|
|
530
530
|
id: 'Socket2',
|
|
531
531
|
tagList: [getSemtag(NumberTag.Two)],
|
|
532
532
|
})
|
|
533
533
|
.addRequiredClusterServers();
|
|
534
534
|
this.smartOutlet
|
|
535
|
-
.addChildDeviceTypeWithClusterServer('Socket 3',
|
|
535
|
+
.addChildDeviceTypeWithClusterServer('Socket 3', onOffPlugInUnit, [OnOff.id], {
|
|
536
536
|
id: 'Socket3',
|
|
537
537
|
tagList: [getSemtag(NumberTag.Three)],
|
|
538
538
|
})
|
|
539
539
|
.addRequiredClusterServers();
|
|
540
540
|
this.smartOutlet
|
|
541
|
-
.addChildDeviceTypeWithClusterServer('Socket 4',
|
|
541
|
+
.addChildDeviceTypeWithClusterServer('Socket 4', onOffPlugInUnit, [OnOff.id], {
|
|
542
542
|
id: 'Socket4',
|
|
543
543
|
tagList: [getSemtag(NumberTag.Four)],
|
|
544
544
|
})
|
|
@@ -550,35 +550,35 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
550
550
|
.addRequiredClusterServers();
|
|
551
551
|
fireAndForget(this.smartBridgedOutlet.addFixedLabel('composed', 'Bridged device'), this.log, `Failed to add fixed label`);
|
|
552
552
|
this.smartBridgedOutlet
|
|
553
|
-
.addChildDeviceTypeWithClusterServer('Plug 1', [
|
|
553
|
+
.addChildDeviceTypeWithClusterServer('Plug 1', [onOffPlugInUnit, bridgedNode], [OnOff.id], {
|
|
554
554
|
id: 'Plug1',
|
|
555
555
|
tagList: [getSemtag(NumberTag.One)],
|
|
556
556
|
})
|
|
557
557
|
.createDefaultBridgedDeviceBasicInformationClusterServer('Plug 1', 'BOU00064-1', 0xfff1, 'Matterbridge', 'Matterbridge Bridged Outlet')
|
|
558
558
|
.addRequiredClusterServers();
|
|
559
559
|
this.smartBridgedOutlet
|
|
560
|
-
.addChildDeviceTypeWithClusterServer('Plug 2', [
|
|
560
|
+
.addChildDeviceTypeWithClusterServer('Plug 2', [onOffPlugInUnit, bridgedNode], [OnOff.id], {
|
|
561
561
|
id: 'Plug2',
|
|
562
562
|
tagList: [getSemtag(NumberTag.Two)],
|
|
563
563
|
})
|
|
564
564
|
.createDefaultBridgedDeviceBasicInformationClusterServer('Plug 2', 'BOU00064-2', 0xfff1, 'Matterbridge', 'Matterbridge Bridged Outlet')
|
|
565
565
|
.addRequiredClusterServers();
|
|
566
566
|
this.smartBridgedOutlet
|
|
567
|
-
.addChildDeviceTypeWithClusterServer('Plug 3', [
|
|
567
|
+
.addChildDeviceTypeWithClusterServer('Plug 3', [onOffPlugInUnit, bridgedNode], [OnOff.id], {
|
|
568
568
|
id: 'Plug3',
|
|
569
569
|
tagList: [getSemtag(NumberTag.Three)],
|
|
570
570
|
})
|
|
571
571
|
.createDefaultBridgedDeviceBasicInformationClusterServer('Plug 3', 'BOU00064-3', 0xfff1, 'Matterbridge', 'Matterbridge Bridged Outlet')
|
|
572
572
|
.addRequiredClusterServers();
|
|
573
573
|
this.smartBridgedOutlet
|
|
574
|
-
.addChildDeviceTypeWithClusterServer('Plug 4', [
|
|
574
|
+
.addChildDeviceTypeWithClusterServer('Plug 4', [onOffPlugInUnit, bridgedNode], [OnOff.id], {
|
|
575
575
|
id: 'Plug4',
|
|
576
576
|
tagList: [getSemtag(NumberTag.Four)],
|
|
577
577
|
})
|
|
578
578
|
.createDefaultBridgedDeviceBasicInformationClusterServer('Plug 4', 'BOU00064-4', 0xfff1, 'Matterbridge', 'Matterbridge Bridged Outlet')
|
|
579
579
|
.addRequiredClusterServers();
|
|
580
580
|
this.smartBridgedOutlet = await this.addDevice(this.smartBridgedOutlet);
|
|
581
|
-
this.coverLift = new MatterbridgeEndpoint([
|
|
581
|
+
this.coverLift = new MatterbridgeEndpoint([windowCovering, bridgedNode, powerSource], { id: 'CoverLift' }, this.config.debug)
|
|
582
582
|
.createDefaultIdentifyClusterServer()
|
|
583
583
|
.createDefaultBridgedDeviceBasicInformationClusterServer('Cover lift', 'COV00020', 0xfff1, 'Matterbridge', 'Matterbridge Cover')
|
|
584
584
|
.createDefaultWindowCoveringClusterServer()
|
|
@@ -630,7 +630,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
630
630
|
};
|
|
631
631
|
this.coverLift?.log.info(`Command goToLiftPercentage with ${liftPercent100thsValue} executed`);
|
|
632
632
|
});
|
|
633
|
-
this.coverLiftTilt = new MatterbridgeEndpoint([
|
|
633
|
+
this.coverLiftTilt = new MatterbridgeEndpoint([windowCovering, bridgedNode, powerSource], { id: 'CoverLiftTilt' }, this.config.debug)
|
|
634
634
|
.createDefaultIdentifyClusterServer()
|
|
635
635
|
.createDefaultBridgedDeviceBasicInformationClusterServer('Cover lift and tilt', 'CLT00021', 0xfff1, 'Matterbridge', 'Matterbridge Cover')
|
|
636
636
|
.createDefaultLiftTiltWindowCoveringClusterServer()
|
|
@@ -695,7 +695,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
695
695
|
};
|
|
696
696
|
this.coverLiftTilt?.log.info(`Command goToTiltPercentage with ${tiltPercent100thsValue} executed`);
|
|
697
697
|
});
|
|
698
|
-
this.lock = new MatterbridgeEndpoint([
|
|
698
|
+
this.lock = new MatterbridgeEndpoint([doorLock, bridgedNode, powerSource], { id: 'Lock' }, this.config.debug)
|
|
699
699
|
.createDefaultIdentifyClusterServer()
|
|
700
700
|
.createDefaultBridgedDeviceBasicInformationClusterServer('Lock', 'LOC00022', 0xfff1, 'Matterbridge', 'Matterbridge Lock')
|
|
701
701
|
.createDefaultDoorLockClusterServer()
|
|
@@ -711,17 +711,17 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
711
711
|
this.lock?.addCommandHandler('DoorLock.unlockDoor', () => {
|
|
712
712
|
this.lock?.log.info('Command unlockDoor called');
|
|
713
713
|
});
|
|
714
|
-
|
|
714
|
+
this.lock?.subscribeAttribute(DoorLock.id, 'operatingMode', (value) => {
|
|
715
715
|
this.lock?.log.info(`Subscribe operatingMode called with: ${getEnumDescription(DoorLock.OperatingMode, value)}`);
|
|
716
716
|
}, this.lock.log);
|
|
717
|
-
this.userPinLock = new MatterbridgeEndpoint([
|
|
717
|
+
this.userPinLock = new MatterbridgeEndpoint([doorLock, bridgedNode, powerSource], { id: 'UserPinLock' }, this.config.debug)
|
|
718
718
|
.createDefaultIdentifyClusterServer()
|
|
719
719
|
.createDefaultBridgedDeviceBasicInformationClusterServer('Lock with User and Pin', 'LUP00070', 0xfff1, 'Matterbridge', 'Matterbridge Lock')
|
|
720
720
|
.createUserPinDoorLockClusterServer()
|
|
721
721
|
.createDefaultPowerSourceRechargeableBatteryClusterServer(95)
|
|
722
722
|
.addRequiredClusterServers();
|
|
723
723
|
this.userPinLock = await this.addDevice(this.userPinLock);
|
|
724
|
-
await this.userPinLock?.setAttribute(PowerSource
|
|
724
|
+
await this.userPinLock?.setAttribute(PowerSource, 'batChargeState', PowerSource.BatChargeState.IsCharging);
|
|
725
725
|
this.userPinLock?.addCommandHandler('Identify.identify', ({ request: { identifyTime } }) => {
|
|
726
726
|
this.userPinLock?.log.info(`Command identify called identifyTime:${identifyTime}`);
|
|
727
727
|
});
|
|
@@ -731,16 +731,16 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
731
731
|
this.userPinLock?.addCommandHandler('DoorLock.unlockDoor', () => {
|
|
732
732
|
this.userPinLock?.log.info('Command unlockDoor called');
|
|
733
733
|
});
|
|
734
|
-
|
|
734
|
+
this.userPinLock?.subscribeAttribute(DoorLock, 'operatingMode', (value) => {
|
|
735
735
|
this.userPinLock?.log.info(`Subscribe operatingMode called with: ${getEnumDescription(DoorLock.OperatingMode, value)}`);
|
|
736
736
|
}, this.userPinLock.log);
|
|
737
|
-
|
|
737
|
+
this.userPinLock?.subscribeAttribute(DoorLock, 'wrongCodeEntryLimit', (value) => {
|
|
738
738
|
this.userPinLock?.log.info(`Subscribe wrongCodeEntryLimit called with: ${value}`);
|
|
739
739
|
}, this.userPinLock.log);
|
|
740
|
-
|
|
740
|
+
this.userPinLock?.subscribeAttribute(DoorLock, 'userCodeTemporaryDisableTime', (value) => {
|
|
741
741
|
this.userPinLock?.log.info(`Subscribe userCodeTemporaryDisableTime called with: ${value}`);
|
|
742
742
|
}, this.userPinLock.log);
|
|
743
|
-
this.thermoAuto = new MatterbridgeEndpoint([
|
|
743
|
+
this.thermoAuto = new MatterbridgeEndpoint([thermostat, bridgedNode, powerSource], { id: 'Thermostat (AutoMode)' }, this.config.debug)
|
|
744
744
|
.createDefaultIdentifyClusterServer()
|
|
745
745
|
.createDefaultBridgedDeviceBasicInformationClusterServer('Thermostat (Auto)', 'TAU00023', 0xfff1, 'Matterbridge', 'Matterbridge Thermostat')
|
|
746
746
|
.createDefaultThermostatClusterServer(20, 18, 22)
|
|
@@ -769,37 +769,37 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
769
769
|
const lookupSetpointAdjustMode = ['Heat', 'Cool', 'Both'];
|
|
770
770
|
this.thermoAuto?.log.info(`Command setpointRaiseLower called with mode: ${lookupSetpointAdjustMode[mode]} amount: ${amount / 10}`);
|
|
771
771
|
});
|
|
772
|
-
|
|
772
|
+
this.thermoAuto?.subscribeAttribute(Thermostat, 'systemMode', (value) => {
|
|
773
773
|
const lookupSystemMode = ['Off', 'Auto', '', 'Cool', 'Heat', 'EmergencyHeat', 'Precooling', 'FanOnly', 'Dry', 'Sleep'];
|
|
774
774
|
this.thermoAuto?.log.info('Subscribe systemMode called with:', lookupSystemMode[value]);
|
|
775
775
|
}, this.thermoAuto.log);
|
|
776
|
-
|
|
776
|
+
this.thermoAuto?.subscribeAttribute(Thermostat.id, 'occupiedHeatingSetpoint', (value) => {
|
|
777
777
|
this.thermoAuto?.log.info('Subscribe occupiedHeatingSetpoint called with:', value / 100);
|
|
778
778
|
}, this.thermoAuto.log);
|
|
779
|
-
|
|
779
|
+
this.thermoAuto?.subscribeAttribute(Thermostat.id, 'occupiedCoolingSetpoint', (value) => {
|
|
780
780
|
this.thermoAuto?.log.info('Subscribe occupiedCoolingSetpoint called with:', value / 100);
|
|
781
781
|
}, this.thermoAuto.log);
|
|
782
|
-
this.thermoAutoOccupancy = new MatterbridgeEndpoint([
|
|
782
|
+
this.thermoAutoOccupancy = new MatterbridgeEndpoint([thermostat, bridgedNode, powerSource], { id: 'Thermostat (AutoModeOccupancy)' }, this.config.debug)
|
|
783
783
|
.createDefaultIdentifyClusterServer()
|
|
784
784
|
.createDefaultBridgedDeviceBasicInformationClusterServer('Thermostat (AutoOccupancy)', 'TAO00058', 0xfff1, 'Matterbridge', 'Matterbridge Thermostat Presets')
|
|
785
785
|
.createDefaultThermostatClusterServer(20, 18, 22, 1, 0, 35, 15, 50, 10, 30, false, 20.5)
|
|
786
786
|
.createDefaultPowerSourceWiredClusterServer()
|
|
787
787
|
.addRequiredClusterServers();
|
|
788
788
|
this.thermoAutoOccupancy = await this.addDevice(this.thermoAutoOccupancy);
|
|
789
|
-
|
|
789
|
+
this.thermoAutoOccupancy?.subscribeAttribute(Thermostat, 'systemMode', (value) => {
|
|
790
790
|
const lookupSystemMode = ['Off', 'Auto', '', 'Cool', 'Heat', 'EmergencyHeat', 'Precooling', 'FanOnly', 'Dry', 'Sleep'];
|
|
791
791
|
this.thermoAutoOccupancy?.log.info('Subscribe systemMode called with:', lookupSystemMode[value]);
|
|
792
792
|
}, this.thermoAutoOccupancy.log);
|
|
793
|
-
|
|
793
|
+
this.thermoAutoOccupancy?.subscribeAttribute(Thermostat.id, 'occupiedHeatingSetpoint', (value) => {
|
|
794
794
|
this.thermoAutoOccupancy?.log.info('Subscribe occupiedHeatingSetpoint called with:', value / 100);
|
|
795
795
|
}, this.thermoAutoOccupancy.log);
|
|
796
|
-
|
|
796
|
+
this.thermoAutoOccupancy?.subscribeAttribute(Thermostat.id, 'occupiedCoolingSetpoint', (value) => {
|
|
797
797
|
this.thermoAutoOccupancy?.log.info('Subscribe occupiedCoolingSetpoint called with:', value / 100);
|
|
798
798
|
}, this.thermoAutoOccupancy.log);
|
|
799
|
-
|
|
799
|
+
this.thermoAutoOccupancy?.subscribeAttribute(Thermostat.id, 'unoccupiedHeatingSetpoint', (value) => {
|
|
800
800
|
this.thermoAutoOccupancy?.log.info('Subscribe unoccupiedHeatingSetpoint called with:', value / 100);
|
|
801
801
|
}, this.thermoAutoOccupancy.log);
|
|
802
|
-
|
|
802
|
+
this.thermoAutoOccupancy?.subscribeAttribute(Thermostat.id, 'unoccupiedCoolingSetpoint', (value) => {
|
|
803
803
|
this.thermoAutoOccupancy?.log.info('Subscribe unoccupiedCoolingSetpoint called with:', value / 100);
|
|
804
804
|
}, this.thermoAutoOccupancy.log);
|
|
805
805
|
const presets_List = [
|
|
@@ -902,7 +902,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
902
902
|
},
|
|
903
903
|
},
|
|
904
904
|
];
|
|
905
|
-
this.thermoAutoPresets = new MatterbridgeEndpoint([
|
|
905
|
+
this.thermoAutoPresets = new MatterbridgeEndpoint([thermostat, bridgedNode, powerSource], { id: 'Thermostat (AutoModePresets)' }, this.config.debug)
|
|
906
906
|
.createDefaultIdentifyClusterServer()
|
|
907
907
|
.createDefaultBridgedDeviceBasicInformationClusterServer('Thermostat (AutoModePresets)', 'TAP00058', 0xfff1, 'Matterbridge', 'Matterbridge Thermostat With Presets')
|
|
908
908
|
.createDefaultPresetsThermostatClusterServer(20, 18, 22, 1, 0, 35, 15, 50, 10, 30, false, 20.5, undefined, presets_List, presetTypeDefinitions)
|
|
@@ -932,23 +932,23 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
932
932
|
this.thermoAutoPresets?.addCommandHandler('setActivePresetRequest', ({ request: { presetHandle } }) => {
|
|
933
933
|
this.thermoAutoPresets?.log.info(`Command setActivePresetRequest called with presetHandle: ${presetHandle ? `0x${Buffer.from(presetHandle).toString('hex')}` : 'null'}`);
|
|
934
934
|
});
|
|
935
|
-
|
|
935
|
+
this.thermoAutoPresets?.subscribeAttribute(Thermostat, 'systemMode', (newValue, oldValue) => {
|
|
936
936
|
const lookupSystemMode = ['Off', 'Auto', '', 'Cool', 'Heat', 'EmergencyHeat', 'Precooling', 'FanOnly', 'Dry', 'Sleep'];
|
|
937
937
|
this.thermoAutoPresets?.log.info(`Subscribe systemMode called with: ${lookupSystemMode[newValue]} (old value: ${lookupSystemMode[oldValue]})`);
|
|
938
938
|
}, this.thermoAutoPresets.log);
|
|
939
|
-
|
|
939
|
+
this.thermoAutoPresets?.subscribeAttribute(Thermostat.id, 'occupiedHeatingSetpoint', (newValue, oldValue) => {
|
|
940
940
|
this.thermoAutoPresets?.log.info(`Subscribe occupiedHeatingSetpoint called with: ${newValue / 100} (old value: ${oldValue / 100})`);
|
|
941
941
|
}, this.thermoAutoPresets.log);
|
|
942
|
-
|
|
942
|
+
this.thermoAutoPresets?.subscribeAttribute(Thermostat.id, 'occupiedCoolingSetpoint', (newValue, oldValue) => {
|
|
943
943
|
this.thermoAutoPresets?.log.info(`Subscribe occupiedCoolingSetpoint called with: ${newValue / 100} (old value: ${oldValue / 100})`);
|
|
944
944
|
}, this.thermoAutoPresets.log);
|
|
945
|
-
|
|
945
|
+
this.thermoAutoPresets?.subscribeAttribute(Thermostat.id, 'activePresetHandle', (newValue, oldValue) => {
|
|
946
946
|
this.thermoAutoPresets?.log.info(`Subscribe activePresetHandle called with: ${newValue ? `0x${Buffer.from(newValue).toString('hex')}` : 'null'} (old value: ${oldValue ? `0x${Buffer.from(oldValue).toString('hex')}` : 'null'})`);
|
|
947
947
|
}, this.thermoAutoPresets.log);
|
|
948
|
-
|
|
948
|
+
this.thermoAutoPresets?.subscribeAttribute(Thermostat.id, 'presets', (newValue, oldValue) => {
|
|
949
949
|
this.thermoAutoPresets?.log.info(`Subscribe presets called with: ${debugStringify(newValue)} (old value: ${debugStringify(oldValue)})`);
|
|
950
950
|
}, this.thermoAutoPresets.log);
|
|
951
|
-
this.thermoHeat = new MatterbridgeEndpoint([
|
|
951
|
+
this.thermoHeat = new MatterbridgeEndpoint([thermostat, bridgedNode, powerSource], { id: 'Thermostat (Heat)' }, this.config.debug)
|
|
952
952
|
.createDefaultIdentifyClusterServer()
|
|
953
953
|
.createDefaultBridgedDeviceBasicInformationClusterServer('Thermostat (Heat)', 'THE00024', 0xfff1, 'Matterbridge', 'Matterbridge Thermostat')
|
|
954
954
|
.createDefaultHeatingThermostatClusterServer(20, 18, 5, 35)
|
|
@@ -979,14 +979,14 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
979
979
|
this.thermoHeat?.addCommandHandler('triggerEffect', ({ request: { effectIdentifier, effectVariant } }) => {
|
|
980
980
|
this.thermoHeat?.log.info(`Command identify called effectIdentifier ${effectIdentifier} effectVariant ${effectVariant}`);
|
|
981
981
|
});
|
|
982
|
-
|
|
982
|
+
this.thermoHeat?.subscribeAttribute(Thermostat, 'systemMode', (value) => {
|
|
983
983
|
const lookupSystemMode = ['Off', 'Auto', '', 'Cool', 'Heat', 'EmergencyHeat', 'Precooling', 'FanOnly', 'Dry', 'Sleep'];
|
|
984
984
|
this.thermoHeat?.log.info('Subscribe systemMode called with:', lookupSystemMode[value]);
|
|
985
985
|
}, this.thermoHeat.log);
|
|
986
|
-
|
|
986
|
+
this.thermoHeat?.subscribeAttribute(Thermostat.id, 'occupiedHeatingSetpoint', (value) => {
|
|
987
987
|
this.thermoHeat?.log.info('Subscribe occupiedHeatingSetpoint called with:', value / 100);
|
|
988
988
|
}, this.thermoHeat.log);
|
|
989
|
-
this.thermoCool = new MatterbridgeEndpoint([
|
|
989
|
+
this.thermoCool = new MatterbridgeEndpoint([thermostat, bridgedNode, powerSource], { id: 'Thermostat (Cool)' }, this.config.debug)
|
|
990
990
|
.createDefaultIdentifyClusterServer()
|
|
991
991
|
.createDefaultBridgedDeviceBasicInformationClusterServer('Thermostat (Cool)', 'TCO00025', 0xfff1, 'Matterbridge', 'Matterbridge Thermostat')
|
|
992
992
|
.createDefaultCoolingThermostatClusterServer(20, 18, 5, 35)
|
|
@@ -999,11 +999,11 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
999
999
|
this.thermoCool?.addCommandHandler('triggerEffect', ({ request: { effectIdentifier, effectVariant } }) => {
|
|
1000
1000
|
this.thermoCool?.log.info(`Command identify called effectIdentifier ${effectIdentifier} effectVariant ${effectVariant}`);
|
|
1001
1001
|
});
|
|
1002
|
-
|
|
1002
|
+
this.thermoCool?.subscribeAttribute(Thermostat, 'systemMode', (value) => {
|
|
1003
1003
|
const lookupSystemMode = ['Off', 'Auto', '', 'Cool', 'Heat', 'EmergencyHeat', 'Precooling', 'FanOnly', 'Dry', 'Sleep'];
|
|
1004
1004
|
this.thermoCool?.log.info('Subscribe systemMode called with:', lookupSystemMode[value]);
|
|
1005
1005
|
}, this.thermoCool.log);
|
|
1006
|
-
|
|
1006
|
+
this.thermoCool?.subscribeAttribute(Thermostat.id, 'occupiedCoolingSetpoint', (value) => {
|
|
1007
1007
|
this.thermoCool?.log.info('Subscribe occupiedCoolingSetpoint called with:', value / 100);
|
|
1008
1008
|
}, this.thermoCool.log);
|
|
1009
1009
|
this.airPurifier = new MatterbridgeEndpoint([airPurifier, bridgedNode, powerSource], { id: 'Air purifier' }, this.config.debug)
|
|
@@ -1028,35 +1028,35 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
1028
1028
|
this.airPurifier?.addCommandHandler('identify', ({ request: { identifyTime } }) => {
|
|
1029
1029
|
this.airPurifier?.log.info(`Command identify called identifyTime:${identifyTime}`);
|
|
1030
1030
|
});
|
|
1031
|
-
|
|
1032
|
-
this.airPurifier?.log.info(`Fan mode changed from ${this.fanModeLookup[oldValue]} to ${this.fanModeLookup[newValue]} context: ${context.
|
|
1033
|
-
if (context.
|
|
1031
|
+
this.airPurifier?.subscribeAttribute(FanControl.id, 'fanMode', (newValue, oldValue, context) => void (async () => {
|
|
1032
|
+
this.airPurifier?.log.info(`Fan mode changed from ${this.fanModeLookup[oldValue]} to ${this.fanModeLookup[newValue]} context: ${context.fabric === undefined ? 'offline' : 'online'}`);
|
|
1033
|
+
if (context.fabric === undefined)
|
|
1034
1034
|
return;
|
|
1035
1035
|
if (newValue === FanControl.FanMode.Off) {
|
|
1036
|
-
await this.airPurifier?.setAttribute(FanControl.
|
|
1037
|
-
await this.airPurifier?.setAttribute(FanControl.
|
|
1036
|
+
await this.airPurifier?.setAttribute(FanControl.id, 'percentSetting', 0, this.airPurifier?.log);
|
|
1037
|
+
await this.airPurifier?.setAttribute(FanControl.id, 'percentCurrent', 0, this.airPurifier?.log);
|
|
1038
1038
|
}
|
|
1039
1039
|
else if (newValue === FanControl.FanMode.Low) {
|
|
1040
|
-
await this.airPurifier?.setAttribute(FanControl.
|
|
1041
|
-
await this.airPurifier?.setAttribute(FanControl.
|
|
1040
|
+
await this.airPurifier?.setAttribute(FanControl.id, 'percentSetting', 33, this.airPurifier?.log);
|
|
1041
|
+
await this.airPurifier?.setAttribute(FanControl.id, 'percentCurrent', 33, this.airPurifier?.log);
|
|
1042
1042
|
}
|
|
1043
1043
|
else if (newValue === FanControl.FanMode.Medium) {
|
|
1044
|
-
await this.airPurifier?.setAttribute(FanControl.
|
|
1045
|
-
await this.airPurifier?.setAttribute(FanControl.
|
|
1044
|
+
await this.airPurifier?.setAttribute(FanControl.id, 'percentSetting', 66, this.airPurifier?.log);
|
|
1045
|
+
await this.airPurifier?.setAttribute(FanControl.id, 'percentCurrent', 66, this.airPurifier?.log);
|
|
1046
1046
|
}
|
|
1047
1047
|
else if (newValue === FanControl.FanMode.High || newValue === FanControl.FanMode.On || newValue === FanControl.FanMode.Auto) {
|
|
1048
|
-
await this.airPurifier?.setAttribute(FanControl.
|
|
1049
|
-
await this.airPurifier?.setAttribute(FanControl.
|
|
1048
|
+
await this.airPurifier?.setAttribute(FanControl.id, 'percentSetting', 100, this.airPurifier?.log);
|
|
1049
|
+
await this.airPurifier?.setAttribute(FanControl.id, 'percentCurrent', 100, this.airPurifier?.log);
|
|
1050
1050
|
}
|
|
1051
1051
|
})(), this.airPurifier.log);
|
|
1052
|
-
|
|
1053
|
-
this.airPurifier?.log.info(`Percent setting changed from ${oldValue} to ${newValue} context: ${context.
|
|
1054
|
-
if (context.
|
|
1052
|
+
this.airPurifier?.subscribeAttribute(FanControl.id, 'percentSetting', (newValue, oldValue, context) => void (async () => {
|
|
1053
|
+
this.airPurifier?.log.info(`Percent setting changed from ${oldValue} to ${newValue} context: ${context.fabric === undefined ? 'offline' : 'online'}`);
|
|
1054
|
+
if (context.fabric === undefined)
|
|
1055
1055
|
return;
|
|
1056
1056
|
if (isValidNumber(newValue, 0, 100))
|
|
1057
|
-
await this.airPurifier?.setAttribute(FanControl.
|
|
1057
|
+
await this.airPurifier?.setAttribute(FanControl.id, 'percentCurrent', newValue, this.airPurifier?.log);
|
|
1058
1058
|
})(), this.airPurifier.log);
|
|
1059
|
-
this.pump = new MatterbridgeEndpoint([
|
|
1059
|
+
this.pump = new MatterbridgeEndpoint([pump, bridgedNode, powerSource], { id: 'Pump' }, this.config.debug)
|
|
1060
1060
|
.createDefaultBridgedDeviceBasicInformationClusterServer('Pump', 'PUM00028', 0xfff1, 'Matterbridge', 'Matterbridge Pump')
|
|
1061
1061
|
.createDefaultIdentifyClusterServer()
|
|
1062
1062
|
.createOnOffClusterServer()
|
|
@@ -1090,13 +1090,13 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
1090
1090
|
this.valve?.addCommandHandler('identify', ({ request: { identifyTime } }) => {
|
|
1091
1091
|
this.valve?.log.info(`Command identify called identifyTime:${identifyTime}`);
|
|
1092
1092
|
});
|
|
1093
|
-
this.fanDefault = new MatterbridgeEndpoint([
|
|
1093
|
+
this.fanDefault = new MatterbridgeEndpoint([fan, bridgedNode, powerSource], { id: 'Fan off low medium high auto' }, this.config.debug)
|
|
1094
1094
|
.createDefaultBridgedDeviceBasicInformationClusterServer('Fan', 'FAN00030', 0xfff1, 'Matterbridge', 'Matterbridge Fan')
|
|
1095
1095
|
.createDefaultPowerSourceWiredClusterServer()
|
|
1096
1096
|
.createDefaultFanControlClusterServer()
|
|
1097
1097
|
.addRequiredClusterServers();
|
|
1098
1098
|
this.fanDefault = await this.addDevice(this.fanDefault);
|
|
1099
|
-
|
|
1099
|
+
this.fanDefault?.subscribeAttribute(FanControl, 'fanMode', (newValue, oldValue, context) => void (async () => {
|
|
1100
1100
|
this.fanDefault?.log.info(`Fan mode changed from ${this.fanModeLookup[oldValue]} to ${this.fanModeLookup[newValue]} context: ${context.fabric === undefined ? 'offline' : 'online'}`);
|
|
1101
1101
|
if (context.fabric === undefined)
|
|
1102
1102
|
return;
|
|
@@ -1126,7 +1126,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
1126
1126
|
await this.fanDefault?.setAttribute(FanControl, 'percentCurrent', 50, this.fanDefault?.log);
|
|
1127
1127
|
}
|
|
1128
1128
|
})(), this.fanDefault.log);
|
|
1129
|
-
|
|
1129
|
+
this.fanDefault?.subscribeAttribute(FanControl, 'percentSetting', (newValue, oldValue, context) => void (async () => {
|
|
1130
1130
|
this.fanDefault?.log.info(`Percent setting changed from ${oldValue} to ${newValue} context: ${context.fabric === undefined ? 'offline' : 'online'}`);
|
|
1131
1131
|
if (context.fabric === undefined)
|
|
1132
1132
|
return;
|
|
@@ -1143,13 +1143,13 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
1143
1143
|
if (newValue === null)
|
|
1144
1144
|
await this.fanDefault?.setAttribute(FanControl, 'fanMode', FanControl.FanMode.Auto, this.fanDefault?.log);
|
|
1145
1145
|
})(), this.fanDefault.log);
|
|
1146
|
-
this.fanBase = new MatterbridgeEndpoint([
|
|
1146
|
+
this.fanBase = new MatterbridgeEndpoint([fan, bridgedNode, powerSource], { id: 'Fan off low medium high' }, this.config.debug)
|
|
1147
1147
|
.createDefaultBridgedDeviceBasicInformationClusterServer('Fan base', 'FBA00031', 0xfff1, 'Matterbridge', 'Matterbridge Fan')
|
|
1148
1148
|
.createDefaultPowerSourceWiredClusterServer()
|
|
1149
1149
|
.createBaseFanControlClusterServer()
|
|
1150
1150
|
.addRequiredClusterServers();
|
|
1151
1151
|
this.fanBase = await this.addDevice(this.fanBase);
|
|
1152
|
-
|
|
1152
|
+
this.fanBase?.subscribeAttribute(FanControl, 'fanMode', (newValue, oldValue, context) => void (async () => {
|
|
1153
1153
|
this.fanBase?.log.info(`Fan mode changed from ${this.fanModeLookup[oldValue]} to ${this.fanModeLookup[newValue]} context: ${context.fabric === undefined ? 'offline' : 'online'}`);
|
|
1154
1154
|
if (context.fabric === undefined)
|
|
1155
1155
|
return;
|
|
@@ -1179,7 +1179,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
1179
1179
|
await this.fanBase?.setAttribute(FanControl, 'percentCurrent', 50, this.fanBase?.log);
|
|
1180
1180
|
}
|
|
1181
1181
|
})(), this.fanBase.log);
|
|
1182
|
-
|
|
1182
|
+
this.fanBase?.subscribeAttribute(FanControl, 'percentSetting', (newValue, oldValue, context) => void (async () => {
|
|
1183
1183
|
this.fanBase?.log.info(`Percent setting changed from ${oldValue} to ${newValue} context: ${context.fabric === undefined ? 'offline' : 'online'}`);
|
|
1184
1184
|
if (context.fabric === undefined)
|
|
1185
1185
|
return;
|
|
@@ -1194,13 +1194,13 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
1194
1194
|
if (isValidNumber(newValue, 67, 100))
|
|
1195
1195
|
await this.fanBase?.setAttribute(FanControl, 'fanMode', FanControl.FanMode.High, this.fanBase?.log);
|
|
1196
1196
|
})(), this.fanBase.log);
|
|
1197
|
-
this.fanOnHigh = new MatterbridgeEndpoint([
|
|
1197
|
+
this.fanOnHigh = new MatterbridgeEndpoint([fan, bridgedNode, powerSource], { id: 'Fan off high' }, this.config.debug)
|
|
1198
1198
|
.createDefaultBridgedDeviceBasicInformationClusterServer('Fan off high', 'FOH00032', 0xfff1, 'Matterbridge', 'Matterbridge Fan')
|
|
1199
1199
|
.createDefaultPowerSourceWiredClusterServer()
|
|
1200
1200
|
.createOnOffFanControlClusterServer()
|
|
1201
1201
|
.addRequiredClusterServers();
|
|
1202
1202
|
this.fanOnHigh = await this.addDevice(this.fanOnHigh);
|
|
1203
|
-
|
|
1203
|
+
this.fanOnHigh?.subscribeAttribute(FanControl, 'fanMode', (newValue, oldValue, context) => void (async () => {
|
|
1204
1204
|
this.fanOnHigh?.log.info(`Fan mode changed from ${this.fanModeLookup[oldValue]} to ${this.fanModeLookup[newValue]} context: ${context.fabric === undefined ? 'offline' : 'online'}`);
|
|
1205
1205
|
if (context.fabric === undefined)
|
|
1206
1206
|
return;
|
|
@@ -1218,7 +1218,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
1218
1218
|
await this.fanOnHigh?.setAttribute(FanControl, 'percentCurrent', 100, this.fanOnHigh?.log);
|
|
1219
1219
|
}
|
|
1220
1220
|
})(), this.fanOnHigh.log);
|
|
1221
|
-
|
|
1221
|
+
this.fanOnHigh?.subscribeAttribute(FanControl, 'percentSetting', (newValue, oldValue, context) => void (async () => {
|
|
1222
1222
|
this.fanOnHigh?.log.info(`Percent setting changed from ${oldValue} to ${newValue} context: ${context.fabric === undefined ? 'offline' : 'online'}`);
|
|
1223
1223
|
if (context.fabric === undefined)
|
|
1224
1224
|
return;
|
|
@@ -1230,13 +1230,13 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
1230
1230
|
await this.fanOnHigh?.setAttribute(FanControl, 'fanMode', newValue === 0 ? FanControl.FanMode.Off : FanControl.FanMode.High, this.fanOnHigh?.log);
|
|
1231
1231
|
}
|
|
1232
1232
|
})(), this.fanOnHigh.log);
|
|
1233
|
-
this.fanComplete = new MatterbridgeEndpoint([
|
|
1233
|
+
this.fanComplete = new MatterbridgeEndpoint([fan, bridgedNode, powerSource], { id: 'Fan complete' }, this.config.debug)
|
|
1234
1234
|
.createDefaultBridgedDeviceBasicInformationClusterServer('Fan complete', 'FCO00033', 0xfff1, 'Matterbridge', 'Matterbridge Fan')
|
|
1235
1235
|
.createDefaultPowerSourceWiredClusterServer()
|
|
1236
1236
|
.createCompleteFanControlClusterServer()
|
|
1237
1237
|
.addRequiredClusterServers();
|
|
1238
1238
|
this.fanComplete = await this.addDevice(this.fanComplete);
|
|
1239
|
-
|
|
1239
|
+
this.fanComplete?.subscribeAttribute(FanControl, 'fanMode', (newValue, oldValue, context) => void (async () => {
|
|
1240
1240
|
this.fanComplete?.log.info(`Fan mode changed from ${this.fanModeLookup[oldValue]} to ${this.fanModeLookup[newValue]} context: ${context.fabric === undefined ? 'offline' : 'online'}`);
|
|
1241
1241
|
if (context.fabric === undefined)
|
|
1242
1242
|
return;
|
|
@@ -1266,7 +1266,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
1266
1266
|
await this.fanComplete?.setAttribute(FanControl, 'percentCurrent', 50, this.fanComplete?.log);
|
|
1267
1267
|
}
|
|
1268
1268
|
})(), this.fanComplete?.log);
|
|
1269
|
-
|
|
1269
|
+
this.fanComplete?.subscribeAttribute(FanControl, 'percentSetting', (newValue, oldValue, context) => void (async () => {
|
|
1270
1270
|
this.fanComplete?.log.info(`Percent setting changed from ${oldValue} to ${newValue} context: ${context.fabric === undefined ? 'offline' : 'online'}`);
|
|
1271
1271
|
if (context.fabric === undefined)
|
|
1272
1272
|
return;
|
|
@@ -1283,13 +1283,13 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
1283
1283
|
if (newValue === null)
|
|
1284
1284
|
await this.fanComplete?.setAttribute(FanControl, 'fanMode', FanControl.FanMode.Auto, this.fanComplete?.log);
|
|
1285
1285
|
})(), this.fanComplete?.log);
|
|
1286
|
-
|
|
1286
|
+
this.fanComplete?.subscribeAttribute(FanControl, 'rockSetting', (newValue, oldValue, context) => {
|
|
1287
1287
|
this.fanComplete?.log.info(`Rock setting changed from ${debugStringify(oldValue)} to ${debugStringify(newValue)} context: ${context.fabric === undefined ? 'offline' : 'online'}`);
|
|
1288
1288
|
}, this.fanComplete?.log);
|
|
1289
|
-
|
|
1289
|
+
this.fanComplete?.subscribeAttribute(FanControl, 'windSetting', (newValue, oldValue, context) => {
|
|
1290
1290
|
this.fanComplete?.log.info(`Wind setting changed from ${debugStringify(oldValue)} to ${debugStringify(newValue)} context: ${context.fabric === undefined ? 'offline' : 'online'}`);
|
|
1291
1291
|
}, this.fanComplete?.log);
|
|
1292
|
-
|
|
1292
|
+
this.fanComplete?.subscribeAttribute(FanControl, 'airflowDirection', (newValue, oldValue, context) => {
|
|
1293
1293
|
this.fanComplete?.log.info(`Airflow direction changed from ${this.fanDirectionLookup[oldValue]} to ${this.fanDirectionLookup[newValue]} context: ${context.fabric === undefined ? 'offline' : 'online'}`);
|
|
1294
1294
|
}, this.fanComplete?.log);
|
|
1295
1295
|
this.waterLeak = new MatterbridgeEndpoint([waterLeakDetector, bridgedNode, powerSource], { id: 'Water leak detector' }, this.config.debug)
|
|
@@ -1338,7 +1338,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
1338
1338
|
.createDefaultBridgedDeviceBasicInformationClusterServer('Air quality sensor', 'AQS00040', 0xfff1, 'Matterbridge', 'Matterbridge Air Quality Sensor')
|
|
1339
1339
|
.createDefaultPowerSourceReplaceableBatteryClusterServer(50, PowerSource.BatChargeLevel.Warning, 2900, 'CR2450', 1)
|
|
1340
1340
|
.addRequiredClusterServers()
|
|
1341
|
-
.addClusterServers([TemperatureMeasurement.
|
|
1341
|
+
.addClusterServers([TemperatureMeasurement.id, RelativeHumidityMeasurement.id])
|
|
1342
1342
|
.createDefaultAirQualityClusterServer(AirQuality.AirQualityEnum.Good)
|
|
1343
1343
|
.createDefaultCarbonMonoxideConcentrationMeasurementClusterServer(10)
|
|
1344
1344
|
.createDefaultCarbonDioxideConcentrationMeasurementClusterServer(400)
|
|
@@ -1485,7 +1485,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
1485
1485
|
name: 'First floor',
|
|
1486
1486
|
},
|
|
1487
1487
|
]);
|
|
1488
|
-
if (this.config.enableServerRvc
|
|
1488
|
+
if (this.config.enableServerRvc) {
|
|
1489
1489
|
this.log.notice('RVC is in server mode so it has its own QR code (it shows in the "Devices" panel of the Home page)');
|
|
1490
1490
|
}
|
|
1491
1491
|
this.roboticVacuum = await this.addDevice(this.roboticVacuum);
|
|
@@ -1580,53 +1580,53 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
1580
1580
|
});
|
|
1581
1581
|
this.airConditioner?.addCommandHandler('on', async () => {
|
|
1582
1582
|
this.airConditioner?.log.info('Command on called');
|
|
1583
|
-
await this.airConditioner?.setAttribute(
|
|
1584
|
-
await this.airConditioner?.setAttribute(TemperatureMeasurement.
|
|
1585
|
-
await this.airConditioner?.setAttribute(
|
|
1586
|
-
await this.airConditioner?.setAttribute(FanControl.
|
|
1583
|
+
await this.airConditioner?.setAttribute(Thermostat.id, 'localTemperature', 20 * 100, this.airConditioner?.log);
|
|
1584
|
+
await this.airConditioner?.setAttribute(TemperatureMeasurement.id, 'measuredValue', 20 * 100, this.airConditioner?.log);
|
|
1585
|
+
await this.airConditioner?.setAttribute(RelativeHumidityMeasurement.id, 'measuredValue', 50 * 100, this.airConditioner?.log);
|
|
1586
|
+
await this.airConditioner?.setAttribute(FanControl.id, 'percentSetting', 50, this.airConditioner?.log);
|
|
1587
1587
|
});
|
|
1588
1588
|
this.airConditioner?.addCommandHandler('off', async () => {
|
|
1589
1589
|
this.airConditioner?.log.info('Command off called');
|
|
1590
|
-
await this.airConditioner?.setAttribute(
|
|
1591
|
-
await this.airConditioner?.setAttribute(TemperatureMeasurement.
|
|
1592
|
-
await this.airConditioner?.setAttribute(
|
|
1593
|
-
await this.airConditioner?.setAttribute(FanControl.
|
|
1594
|
-
});
|
|
1595
|
-
|
|
1596
|
-
this.airConditioner?.log.info(`Fan mode changed from ${this.fanModeLookup[oldValue]} to ${this.fanModeLookup[newValue]} context: ${context.
|
|
1597
|
-
if (context.
|
|
1590
|
+
await this.airConditioner?.setAttribute(Thermostat.id, 'localTemperature', null, this.airConditioner?.log);
|
|
1591
|
+
await this.airConditioner?.setAttribute(TemperatureMeasurement.id, 'measuredValue', null, this.airConditioner?.log);
|
|
1592
|
+
await this.airConditioner?.setAttribute(RelativeHumidityMeasurement.id, 'measuredValue', null, this.airConditioner?.log);
|
|
1593
|
+
await this.airConditioner?.setAttribute(FanControl.id, 'percentSetting', null, this.airConditioner?.log);
|
|
1594
|
+
});
|
|
1595
|
+
this.airConditioner?.subscribeAttribute(FanControl.id, 'fanMode', (newValue, oldValue, context) => void (async () => {
|
|
1596
|
+
this.airConditioner?.log.info(`Fan mode changed from ${this.fanModeLookup[oldValue]} to ${this.fanModeLookup[newValue]} context: ${context.fabric === undefined ? 'offline' : 'online'}`);
|
|
1597
|
+
if (context.fabric === undefined)
|
|
1598
1598
|
return;
|
|
1599
1599
|
if (newValue === FanControl.FanMode.Off) {
|
|
1600
|
-
await this.airConditioner?.setAttribute(FanControl.
|
|
1601
|
-
await this.airConditioner?.setAttribute(FanControl.
|
|
1600
|
+
await this.airConditioner?.setAttribute(FanControl.id, 'percentSetting', 0, this.airConditioner?.log);
|
|
1601
|
+
await this.airConditioner?.setAttribute(FanControl.id, 'percentCurrent', 0, this.airConditioner?.log);
|
|
1602
1602
|
}
|
|
1603
1603
|
else if (newValue === FanControl.FanMode.Low) {
|
|
1604
|
-
await this.airConditioner?.setAttribute(FanControl.
|
|
1605
|
-
await this.airConditioner?.setAttribute(FanControl.
|
|
1604
|
+
await this.airConditioner?.setAttribute(FanControl.id, 'percentSetting', 33, this.airConditioner?.log);
|
|
1605
|
+
await this.airConditioner?.setAttribute(FanControl.id, 'percentCurrent', 33, this.airConditioner?.log);
|
|
1606
1606
|
}
|
|
1607
1607
|
else if (newValue === FanControl.FanMode.Medium) {
|
|
1608
|
-
await this.airConditioner?.setAttribute(FanControl.
|
|
1609
|
-
await this.airConditioner?.setAttribute(FanControl.
|
|
1608
|
+
await this.airConditioner?.setAttribute(FanControl.id, 'percentSetting', 66, this.airConditioner?.log);
|
|
1609
|
+
await this.airConditioner?.setAttribute(FanControl.id, 'percentCurrent', 66, this.airConditioner?.log);
|
|
1610
1610
|
}
|
|
1611
1611
|
else if (newValue === FanControl.FanMode.High) {
|
|
1612
|
-
await this.airConditioner?.setAttribute(FanControl.
|
|
1613
|
-
await this.airConditioner?.setAttribute(FanControl.
|
|
1612
|
+
await this.airConditioner?.setAttribute(FanControl.id, 'percentSetting', 100, this.airConditioner?.log);
|
|
1613
|
+
await this.airConditioner?.setAttribute(FanControl.id, 'percentCurrent', 100, this.airConditioner?.log);
|
|
1614
1614
|
}
|
|
1615
1615
|
else if (newValue === FanControl.FanMode.On) {
|
|
1616
|
-
await this.airConditioner?.setAttribute(FanControl.
|
|
1617
|
-
await this.airConditioner?.setAttribute(FanControl.
|
|
1616
|
+
await this.airConditioner?.setAttribute(FanControl.id, 'percentSetting', 100, this.airConditioner?.log);
|
|
1617
|
+
await this.airConditioner?.setAttribute(FanControl.id, 'percentCurrent', 100, this.airConditioner?.log);
|
|
1618
1618
|
}
|
|
1619
1619
|
else if (newValue === FanControl.FanMode.Auto) {
|
|
1620
|
-
await this.airConditioner?.setAttribute(FanControl.
|
|
1621
|
-
await this.airConditioner?.setAttribute(FanControl.
|
|
1620
|
+
await this.airConditioner?.setAttribute(FanControl.id, 'percentSetting', 50, this.airConditioner?.log);
|
|
1621
|
+
await this.airConditioner?.setAttribute(FanControl.id, 'percentCurrent', 50, this.airConditioner?.log);
|
|
1622
1622
|
}
|
|
1623
1623
|
})(), this.airConditioner?.log);
|
|
1624
|
-
|
|
1625
|
-
this.airConditioner?.log.info(`Percent setting changed from ${oldValue} to ${newValue} context: ${context.
|
|
1626
|
-
if (context.
|
|
1624
|
+
this.airConditioner?.subscribeAttribute(FanControl.id, 'percentSetting', (newValue, oldValue, context) => void (async () => {
|
|
1625
|
+
this.airConditioner?.log.info(`Percent setting changed from ${oldValue} to ${newValue} context: ${context.fabric === undefined ? 'offline' : 'online'}`);
|
|
1626
|
+
if (context.fabric === undefined)
|
|
1627
1627
|
return;
|
|
1628
1628
|
if (isValidNumber(newValue, 0, 100))
|
|
1629
|
-
await this.airConditioner?.setAttribute(FanControl.
|
|
1629
|
+
await this.airConditioner?.setAttribute(FanControl.id, 'percentCurrent', newValue, this.airConditioner?.log);
|
|
1630
1630
|
})(), this.airConditioner?.log);
|
|
1631
1631
|
this.basicVideoPlayer = new BasicVideoPlayer('BasicVideoPlayer', 'BVP00062');
|
|
1632
1632
|
this.basicVideoPlayer = (await this.addDevice(this.basicVideoPlayer));
|
|
@@ -1665,7 +1665,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
1665
1665
|
return interval;
|
|
1666
1666
|
}
|
|
1667
1667
|
async executeIntervals(times, pauseTime = 100) {
|
|
1668
|
-
for (let i = 0; i < times; i
|
|
1668
|
+
for (let i = 0; i < times; i += 1) {
|
|
1669
1669
|
for (const { callback } of this.intervals) {
|
|
1670
1670
|
await callback();
|
|
1671
1671
|
}
|
|
@@ -1687,14 +1687,14 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
1687
1687
|
if (this.phase === 0) {
|
|
1688
1688
|
if (this.airConditioner || this.laundryWasher || this.laundryDryer || this.dishwasher)
|
|
1689
1689
|
this.log.info(`Set appliances dead front OnOff to true`);
|
|
1690
|
-
await this.airConditioner?.setAttribute(OnOff.
|
|
1691
|
-
await this.laundryWasher?.setAttribute(OnOff.
|
|
1692
|
-
await this.laundryDryer?.setAttribute(OnOff.
|
|
1693
|
-
await this.dishwasher?.setAttribute(OnOff.
|
|
1690
|
+
await this.airConditioner?.setAttribute(OnOff.id, 'onOff', true, this.airConditioner.log);
|
|
1691
|
+
await this.laundryWasher?.setAttribute(OnOff.id, 'onOff', true, this.laundryWasher.log);
|
|
1692
|
+
await this.laundryDryer?.setAttribute(OnOff.id, 'onOff', true, this.laundryDryer.log);
|
|
1693
|
+
await this.dishwasher?.setAttribute(OnOff.id, 'onOff', true, this.dishwasher.log);
|
|
1694
1694
|
this.cooktop?.log.info(`Set Cooktop offOnly onOff clusters to true`);
|
|
1695
|
-
await this.cooktop?.setAttribute(OnOff.
|
|
1696
|
-
await this.cooktop?.
|
|
1697
|
-
await this.cooktop?.
|
|
1695
|
+
await this.cooktop?.setAttribute(OnOff.id, 'onOff', true, this.cooktop.log);
|
|
1696
|
+
await this.cooktop?.getChildEndpointById('SurfaceTopLeft')?.setAttribute(OnOff.id, 'onOff', true, this.cooktop?.log);
|
|
1697
|
+
await this.cooktop?.getChildEndpointById('SurfaceTopRight')?.setAttribute(OnOff.id, 'onOff', true, this.cooktop?.log);
|
|
1698
1698
|
}
|
|
1699
1699
|
if (this.roboticVacuum) {
|
|
1700
1700
|
if (this.phase === 0) {
|
|
@@ -1783,8 +1783,8 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
1783
1783
|
}
|
|
1784
1784
|
}
|
|
1785
1785
|
if (this.oven) {
|
|
1786
|
-
const upperCabinet = this.oven.
|
|
1787
|
-
const lowerCabinet = this.oven.
|
|
1786
|
+
const upperCabinet = this.oven.getChildEndpointById('UpperCabinet');
|
|
1787
|
+
const lowerCabinet = this.oven.getChildEndpointById('LowerCabinet');
|
|
1788
1788
|
if (this.phase === 0) {
|
|
1789
1789
|
await upperCabinet?.setAttribute('OvenMode', 'currentMode', 3, upperCabinet.log);
|
|
1790
1790
|
await upperCabinet?.setAttribute('OvenCavityOperationalState', 'operationalState', OperationalState.OperationalStateEnum.Stopped, upperCabinet.log);
|
|
@@ -1852,7 +1852,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
1852
1852
|
if (this.refrigerator) {
|
|
1853
1853
|
if (this.phase === 0) {
|
|
1854
1854
|
let mode;
|
|
1855
|
-
const refrigerator = this.refrigerator.
|
|
1855
|
+
const refrigerator = this.refrigerator.getChildEndpointById('RefrigeratorTop');
|
|
1856
1856
|
mode = this.refrigerator.getAttribute('RefrigeratorAndTemperatureControlledCabinetMode', 'currentMode', this.refrigerator.log);
|
|
1857
1857
|
mode = mode === 1 ? 2 : 1;
|
|
1858
1858
|
await this.refrigerator.setAttribute('RefrigeratorAndTemperatureControlledCabinetMode', 'currentMode', mode, this.refrigerator.log);
|
|
@@ -1864,7 +1864,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
1864
1864
|
await refrigerator?.setAttribute('TemperatureControl', 'temperatureSetpoint', 10 * 100, refrigerator.log);
|
|
1865
1865
|
if (mode === 2)
|
|
1866
1866
|
await refrigerator?.setAttribute('TemperatureMeasurement', 'measuredValue', 1000, refrigerator.log);
|
|
1867
|
-
const freezer = this.refrigerator.
|
|
1867
|
+
const freezer = this.refrigerator.getChildEndpointById('FreezerBottom');
|
|
1868
1868
|
mode = this.refrigerator.getAttribute('RefrigeratorAndTemperatureControlledCabinetMode', 'currentMode', this.refrigerator.log);
|
|
1869
1869
|
mode = mode === 1 ? 2 : 1;
|
|
1870
1870
|
await this.refrigerator.setAttribute('RefrigeratorAndTemperatureControlledCabinetMode', 'currentMode', mode, this.refrigerator.log);
|
|
@@ -1894,103 +1894,103 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
1894
1894
|
if (this.phase === 9)
|
|
1895
1895
|
await this.refrigerator.triggerDoorOpenState(false);
|
|
1896
1896
|
}
|
|
1897
|
-
this.phase
|
|
1897
|
+
this.phase += 1;
|
|
1898
1898
|
this.phase = this.phase >= 10 ? 0 : this.phase;
|
|
1899
1899
|
}, 10 * 1000);
|
|
1900
1900
|
}
|
|
1901
1901
|
if (this.config.useInterval) {
|
|
1902
1902
|
this.addInterval(async () => {
|
|
1903
|
-
let value = this.door?.getAttribute(BooleanState.
|
|
1903
|
+
let value = this.door?.getAttribute(BooleanState.id, 'stateValue', this.door.log);
|
|
1904
1904
|
if (isValidBoolean(value)) {
|
|
1905
1905
|
value = !value;
|
|
1906
|
-
await this.door?.setAttribute(BooleanState.
|
|
1906
|
+
await this.door?.setAttribute(BooleanState.id, 'stateValue', value, this.door.log);
|
|
1907
1907
|
this.door?.log.info(`Set door stateValue to ${value}`);
|
|
1908
1908
|
}
|
|
1909
|
-
const occupancyValue = this.occupancy?.getAttribute(OccupancySensing
|
|
1909
|
+
const occupancyValue = this.occupancy?.getAttribute(OccupancySensing, 'occupancy', this.occupancy.log);
|
|
1910
1910
|
if (isValidObject(occupancyValue, 1)) {
|
|
1911
1911
|
occupancyValue.occupied = !occupancyValue.occupied;
|
|
1912
|
-
await this.occupancy?.setAttribute(OccupancySensing.
|
|
1912
|
+
await this.occupancy?.setAttribute(OccupancySensing.id, 'occupancy', occupancyValue, this.occupancy.log);
|
|
1913
1913
|
this.occupancy?.log.info(`Set occupancy to ${occupancyValue.occupied}`);
|
|
1914
1914
|
}
|
|
1915
|
-
value = this.illuminance?.getAttribute(IlluminanceMeasurement.
|
|
1915
|
+
value = this.illuminance?.getAttribute(IlluminanceMeasurement.id, 'measuredValue', this.illuminance.log);
|
|
1916
1916
|
if (isValidNumber(value, 0, 0xfffe)) {
|
|
1917
1917
|
value = matterToLux(value);
|
|
1918
1918
|
value = value + 10 < 500 ? value + 10 : 1;
|
|
1919
|
-
await this.illuminance?.setAttribute(IlluminanceMeasurement.
|
|
1919
|
+
await this.illuminance?.setAttribute(IlluminanceMeasurement.id, 'measuredValue', luxToMatter(value), this.illuminance.log);
|
|
1920
1920
|
this.illuminance?.log.info(`Set illuminance measuredValue to ${value}`);
|
|
1921
1921
|
}
|
|
1922
|
-
value = this.temperature?.getAttribute(TemperatureMeasurement.
|
|
1922
|
+
value = this.temperature?.getAttribute(TemperatureMeasurement.id, 'measuredValue', this.temperature.log);
|
|
1923
1923
|
if (isValidNumber(value, 0, 0xfffe)) {
|
|
1924
1924
|
value = value + 100 < 3000 ? value + 100 : 1000;
|
|
1925
|
-
await this.temperature?.setAttribute(TemperatureMeasurement.
|
|
1926
|
-
await this.climate?.getChildEndpointById('Temperature')?.setAttribute(TemperatureMeasurement.
|
|
1925
|
+
await this.temperature?.setAttribute(TemperatureMeasurement.id, 'measuredValue', value, this.temperature.log);
|
|
1926
|
+
await this.climate?.getChildEndpointById('Temperature')?.setAttribute(TemperatureMeasurement.id, 'measuredValue', value, this.climate.log);
|
|
1927
1927
|
this.temperature?.log.info(`Set temperature measuredValue to ${value}`);
|
|
1928
1928
|
}
|
|
1929
|
-
value = this.humidity?.getAttribute(RelativeHumidityMeasurement.
|
|
1929
|
+
value = this.humidity?.getAttribute(RelativeHumidityMeasurement.id, 'measuredValue', this.humidity.log);
|
|
1930
1930
|
if (isValidNumber(value, 0, 0xfffe)) {
|
|
1931
1931
|
value = value + 100 < 10000 ? value + 100 : 100;
|
|
1932
|
-
await this.humidity?.setAttribute(RelativeHumidityMeasurement.
|
|
1933
|
-
await this.climate?.getChildEndpointById('Humidity')?.setAttribute(RelativeHumidityMeasurement.
|
|
1932
|
+
await this.humidity?.setAttribute(RelativeHumidityMeasurement.id, 'measuredValue', value, this.humidity.log);
|
|
1933
|
+
await this.climate?.getChildEndpointById('Humidity')?.setAttribute(RelativeHumidityMeasurement.id, 'measuredValue', value, this.climate.log);
|
|
1934
1934
|
this.humidity?.log.info(`Set humidity measuredValue to ${value}`);
|
|
1935
1935
|
}
|
|
1936
|
-
value = this.pressure?.getAttribute(PressureMeasurement.
|
|
1936
|
+
value = this.pressure?.getAttribute(PressureMeasurement.id, 'measuredValue', this.pressure.log);
|
|
1937
1937
|
if (isValidNumber(value, 0, 0xfffe)) {
|
|
1938
1938
|
value = value + 10 < 9900 ? value + 10 : 8600;
|
|
1939
|
-
await this.pressure?.setAttribute(PressureMeasurement.
|
|
1940
|
-
await this.climate?.getChildEndpointById('Pressure')?.setAttribute(PressureMeasurement.
|
|
1939
|
+
await this.pressure?.setAttribute(PressureMeasurement.id, 'measuredValue', value, this.pressure.log);
|
|
1940
|
+
await this.climate?.getChildEndpointById('Pressure')?.setAttribute(PressureMeasurement.id, 'measuredValue', value, this.climate.log);
|
|
1941
1941
|
this.pressure?.log.info(`Set pressure measuredValue to ${value}`);
|
|
1942
1942
|
}
|
|
1943
|
-
value = this.flow?.getAttribute(FlowMeasurement.
|
|
1943
|
+
value = this.flow?.getAttribute(FlowMeasurement.id, 'measuredValue', this.flow.log);
|
|
1944
1944
|
if (isValidNumber(value, 0, 0xfffe)) {
|
|
1945
1945
|
value = value + 1 < 50 ? value + 1 : 1;
|
|
1946
|
-
await this.flow?.setAttribute(FlowMeasurement.
|
|
1946
|
+
await this.flow?.setAttribute(FlowMeasurement.id, 'measuredValue', value, this.flow.log);
|
|
1947
1947
|
this.flow?.log.info(`Set flow measuredValue to ${value}`);
|
|
1948
1948
|
}
|
|
1949
1949
|
}, 60 * 1000 + 900);
|
|
1950
1950
|
}
|
|
1951
|
-
await this.switch?.setAttribute(OnOff.
|
|
1952
|
-
await this.mountedOnOffSwitch?.setAttribute(OnOff.
|
|
1953
|
-
await this.mountedOnOffSwitchLegacy?.setAttribute(OnOff.
|
|
1951
|
+
await this.switch?.setAttribute(OnOff.id, 'onOff', this.intervalOnOff, this.switch.log);
|
|
1952
|
+
await this.mountedOnOffSwitch?.setAttribute(OnOff.id, 'onOff', this.intervalOnOff, this.mountedOnOffSwitch.log);
|
|
1953
|
+
await this.mountedOnOffSwitchLegacy?.setAttribute(OnOff.id, 'onOff', this.intervalOnOff, this.mountedOnOffSwitchLegacy.log);
|
|
1954
1954
|
this.switch?.log.info(`Set switch initial onOff to ${this.intervalOnOff}`);
|
|
1955
1955
|
if (this.config.useInterval) {
|
|
1956
1956
|
this.addInterval(async () => {
|
|
1957
|
-
await this.switch?.setAttribute(OnOff.
|
|
1958
|
-
await this.mountedOnOffSwitch?.setAttribute(OnOff.
|
|
1959
|
-
await this.mountedOnOffSwitchLegacy?.setAttribute(OnOff.
|
|
1957
|
+
await this.switch?.setAttribute(OnOff.id, 'onOff', this.intervalOnOff, this.switch.log);
|
|
1958
|
+
await this.mountedOnOffSwitch?.setAttribute(OnOff.id, 'onOff', this.intervalOnOff, this.mountedOnOffSwitch.log);
|
|
1959
|
+
await this.mountedOnOffSwitchLegacy?.setAttribute(OnOff.id, 'onOff', this.intervalOnOff, this.mountedOnOffSwitchLegacy.log);
|
|
1960
1960
|
this.log.info(`Set switches onOff to ${this.intervalOnOff}`);
|
|
1961
1961
|
this.intervalOnOff = !this.intervalOnOff;
|
|
1962
1962
|
}, 60 * 1000 + 100);
|
|
1963
1963
|
}
|
|
1964
|
-
await this.lightOnOff?.setAttribute(OnOff.
|
|
1964
|
+
await this.lightOnOff?.setAttribute(OnOff.id, 'onOff', false, this.lightOnOff.log);
|
|
1965
1965
|
this.lightOnOff?.log.info('Set light initial onOff to false.');
|
|
1966
|
-
await this.dimmer?.setAttribute(OnOff.
|
|
1967
|
-
await this.dimmer?.setAttribute(LevelControl.
|
|
1968
|
-
await this.mountedDimmerSwitch?.setAttribute(OnOff.
|
|
1969
|
-
await this.mountedDimmerSwitch?.setAttribute(LevelControl.
|
|
1970
|
-
await this.mountedDimmerSwitchLegacy?.setAttribute(OnOff.
|
|
1971
|
-
await this.mountedDimmerSwitchLegacy?.setAttribute(LevelControl.
|
|
1966
|
+
await this.dimmer?.setAttribute(OnOff.id, 'onOff', false, this.dimmer.log);
|
|
1967
|
+
await this.dimmer?.setAttribute(LevelControl.id, 'currentLevel', 1, this.dimmer.log);
|
|
1968
|
+
await this.mountedDimmerSwitch?.setAttribute(OnOff.id, 'onOff', false, this.mountedDimmerSwitch.log);
|
|
1969
|
+
await this.mountedDimmerSwitch?.setAttribute(LevelControl.id, 'currentLevel', 1, this.mountedDimmerSwitch.log);
|
|
1970
|
+
await this.mountedDimmerSwitchLegacy?.setAttribute(OnOff.id, 'onOff', false, this.mountedDimmerSwitchLegacy.log);
|
|
1971
|
+
await this.mountedDimmerSwitchLegacy?.setAttribute(LevelControl.id, 'currentLevel', 1, this.mountedDimmerSwitchLegacy.log);
|
|
1972
1972
|
this.dimmer?.log.info(`Set dimmer initial onOff to false, currentLevel to 1.`);
|
|
1973
|
-
await this.light?.setAttribute(OnOff.
|
|
1974
|
-
await this.light?.setAttribute(LevelControl.
|
|
1975
|
-
await this.light?.setAttribute(ColorControl.
|
|
1976
|
-
await this.light?.setAttribute(ColorControl.
|
|
1973
|
+
await this.light?.setAttribute(OnOff.id, 'onOff', false, this.light.log);
|
|
1974
|
+
await this.light?.setAttribute(LevelControl.id, 'currentLevel', 200, this.light.log);
|
|
1975
|
+
await this.light?.setAttribute(ColorControl.id, 'currentHue', 0, this.light.log);
|
|
1976
|
+
await this.light?.setAttribute(ColorControl.id, 'currentSaturation', 128, this.light.log);
|
|
1977
1977
|
await this.light?.configureColorControlMode(ColorControl.ColorMode.CurrentHueAndCurrentSaturation);
|
|
1978
1978
|
this.light?.log.info('Set light initial onOff to false, currentLevel to 1, hue to 0 and saturation to 50%.');
|
|
1979
|
-
await this.lightXY?.setAttribute(OnOff.
|
|
1980
|
-
await this.lightXY?.setAttribute(LevelControl.
|
|
1981
|
-
await this.lightXY?.setAttribute(ColorControl.
|
|
1982
|
-
await this.lightXY?.setAttribute(ColorControl.
|
|
1979
|
+
await this.lightXY?.setAttribute(OnOff.id, 'onOff', true, this.lightXY.log);
|
|
1980
|
+
await this.lightXY?.setAttribute(LevelControl.id, 'currentLevel', 254, this.lightXY.log);
|
|
1981
|
+
await this.lightXY?.setAttribute(ColorControl.id, 'currentX', 0.7006 * 65536, this.lightXY.log);
|
|
1982
|
+
await this.lightXY?.setAttribute(ColorControl.id, 'currentY', 0.2993 * 65536, this.lightXY.log);
|
|
1983
1983
|
await this.lightXY?.configureColorControlMode(ColorControl.ColorMode.CurrentXAndCurrentY);
|
|
1984
1984
|
this.lightXY?.log.info('Set light XY initial onOff to true, currentLevel to 254, X to 0.7006 and Y to 0.2993.');
|
|
1985
|
-
await this.lightHS?.setAttribute(OnOff.
|
|
1986
|
-
await this.lightHS?.setAttribute(LevelControl.
|
|
1987
|
-
await this.lightHS?.setAttribute(ColorControl.
|
|
1988
|
-
await this.lightHS?.setAttribute(ColorControl.
|
|
1985
|
+
await this.lightHS?.setAttribute(OnOff.id, 'onOff', false, this.lightHS.log);
|
|
1986
|
+
await this.lightHS?.setAttribute(LevelControl.id, 'currentLevel', 1, this.lightHS.log);
|
|
1987
|
+
await this.lightHS?.setAttribute(ColorControl.id, 'currentHue', 0, this.lightHS.log);
|
|
1988
|
+
await this.lightHS?.setAttribute(ColorControl.id, 'currentSaturation', 128, this.lightHS.log);
|
|
1989
1989
|
await this.lightHS?.configureColorControlMode(ColorControl.ColorMode.CurrentHueAndCurrentSaturation);
|
|
1990
1990
|
this.lightHS?.log.info('Set light HS initial onOff to false, currentLevel to 1, hue to 0 and saturation to 50%.');
|
|
1991
|
-
await this.lightCT?.setAttribute(OnOff.
|
|
1992
|
-
await this.lightCT?.setAttribute(LevelControl.
|
|
1993
|
-
await this.lightCT?.setAttribute(ColorControl.
|
|
1991
|
+
await this.lightCT?.setAttribute(OnOff.id, 'onOff', true, this.lightCT.log);
|
|
1992
|
+
await this.lightCT?.setAttribute(LevelControl.id, 'currentLevel', 128, this.lightCT.log);
|
|
1993
|
+
await this.lightCT?.setAttribute(ColorControl.id, 'colorTemperatureMireds', 250, this.lightCT.log);
|
|
1994
1994
|
await this.lightCT?.configureColorControlMode(ColorControl.ColorMode.ColorTemperatureMireds);
|
|
1995
1995
|
this.lightCT?.log.info('Set light CT initial onOff to true, currentLevel to 128, colorTemperatureMireds to 250.');
|
|
1996
1996
|
if (this.config.useInterval) {
|
|
@@ -1998,43 +1998,43 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
1998
1998
|
this.intervalLevel += 10;
|
|
1999
1999
|
if (this.intervalLevel >= 250) {
|
|
2000
2000
|
this.intervalLevel = 1;
|
|
2001
|
-
await this.lightOnOff?.setAttribute(OnOff.
|
|
2002
|
-
await this.dimmer?.setAttribute(OnOff.
|
|
2003
|
-
await this.mountedDimmerSwitch?.setAttribute(OnOff.
|
|
2004
|
-
await this.mountedDimmerSwitchLegacy?.setAttribute(OnOff.
|
|
2005
|
-
await this.light?.setAttribute(OnOff.
|
|
2006
|
-
await this.lightXY?.setAttribute(OnOff.
|
|
2007
|
-
await this.lightHS?.setAttribute(OnOff.
|
|
2008
|
-
await this.lightCT?.setAttribute(OnOff.
|
|
2001
|
+
await this.lightOnOff?.setAttribute(OnOff.id, 'onOff', false, this.lightOnOff.log);
|
|
2002
|
+
await this.dimmer?.setAttribute(OnOff.id, 'onOff', false, this.dimmer.log);
|
|
2003
|
+
await this.mountedDimmerSwitch?.setAttribute(OnOff.id, 'onOff', false, this.mountedDimmerSwitch.log);
|
|
2004
|
+
await this.mountedDimmerSwitchLegacy?.setAttribute(OnOff.id, 'onOff', false, this.mountedDimmerSwitchLegacy.log);
|
|
2005
|
+
await this.light?.setAttribute(OnOff.id, 'onOff', false, this.light.log);
|
|
2006
|
+
await this.lightXY?.setAttribute(OnOff.id, 'onOff', false, this.lightXY.log);
|
|
2007
|
+
await this.lightHS?.setAttribute(OnOff.id, 'onOff', false, this.lightHS.log);
|
|
2008
|
+
await this.lightCT?.setAttribute(OnOff.id, 'onOff', false, this.lightCT.log);
|
|
2009
2009
|
this.log.info('Set lights onOff to false');
|
|
2010
2010
|
}
|
|
2011
2011
|
else {
|
|
2012
|
-
await this.lightOnOff?.setAttribute(OnOff.
|
|
2013
|
-
await this.dimmer?.setAttribute(OnOff.
|
|
2014
|
-
await this.mountedDimmerSwitch?.setAttribute(OnOff.
|
|
2015
|
-
await this.mountedDimmerSwitchLegacy?.setAttribute(OnOff.
|
|
2016
|
-
await this.light?.setAttribute(OnOff.
|
|
2017
|
-
await this.lightXY?.setAttribute(OnOff.
|
|
2018
|
-
await this.lightHS?.setAttribute(OnOff.
|
|
2019
|
-
await this.lightCT?.setAttribute(OnOff.
|
|
2012
|
+
await this.lightOnOff?.setAttribute(OnOff.id, 'onOff', true, this.lightOnOff?.log);
|
|
2013
|
+
await this.dimmer?.setAttribute(OnOff.id, 'onOff', true, this.dimmer.log);
|
|
2014
|
+
await this.mountedDimmerSwitch?.setAttribute(OnOff.id, 'onOff', true, this.mountedDimmerSwitch.log);
|
|
2015
|
+
await this.mountedDimmerSwitchLegacy?.setAttribute(OnOff.id, 'onOff', true, this.mountedDimmerSwitchLegacy.log);
|
|
2016
|
+
await this.light?.setAttribute(OnOff.id, 'onOff', true, this.light.log);
|
|
2017
|
+
await this.lightXY?.setAttribute(OnOff.id, 'onOff', true, this.lightXY.log);
|
|
2018
|
+
await this.lightHS?.setAttribute(OnOff.id, 'onOff', true, this.lightHS.log);
|
|
2019
|
+
await this.lightCT?.setAttribute(OnOff.id, 'onOff', true, this.lightCT.log);
|
|
2020
2020
|
this.log.info('Set lights onOff to true');
|
|
2021
|
-
await this.dimmer?.setAttribute(LevelControl.
|
|
2022
|
-
await this.mountedDimmerSwitch?.setAttribute(LevelControl.
|
|
2023
|
-
await this.mountedDimmerSwitchLegacy?.setAttribute(LevelControl.
|
|
2024
|
-
await this.light?.setAttribute(LevelControl.
|
|
2025
|
-
await this.lightXY?.setAttribute(LevelControl.
|
|
2026
|
-
await this.lightHS?.setAttribute(LevelControl.
|
|
2027
|
-
await this.lightCT?.setAttribute(LevelControl.
|
|
2021
|
+
await this.dimmer?.setAttribute(LevelControl.id, 'currentLevel', this.intervalLevel, this.dimmer.log);
|
|
2022
|
+
await this.mountedDimmerSwitch?.setAttribute(LevelControl.id, 'currentLevel', this.intervalLevel, this.mountedDimmerSwitch.log);
|
|
2023
|
+
await this.mountedDimmerSwitchLegacy?.setAttribute(LevelControl.id, 'currentLevel', this.intervalLevel, this.mountedDimmerSwitchLegacy.log);
|
|
2024
|
+
await this.light?.setAttribute(LevelControl.id, 'currentLevel', this.intervalLevel, this.light.log);
|
|
2025
|
+
await this.lightXY?.setAttribute(LevelControl.id, 'currentLevel', this.intervalLevel, this.lightXY.log);
|
|
2026
|
+
await this.lightHS?.setAttribute(LevelControl.id, 'currentLevel', this.intervalLevel, this.lightHS.log);
|
|
2027
|
+
await this.lightCT?.setAttribute(LevelControl.id, 'currentLevel', this.intervalLevel, this.lightCT.log);
|
|
2028
2028
|
this.log.info(`Set lights currentLevel to ${this.intervalLevel}`);
|
|
2029
2029
|
}
|
|
2030
2030
|
this.intervalColorTemperature += 50;
|
|
2031
2031
|
if (this.intervalColorTemperature > 500) {
|
|
2032
2032
|
this.intervalColorTemperature = 147;
|
|
2033
2033
|
}
|
|
2034
|
-
await this.light?.setAttribute(ColorControl.
|
|
2035
|
-
await this.lightHS?.setAttribute(ColorControl.
|
|
2036
|
-
await this.lightXY?.setAttribute(ColorControl.
|
|
2037
|
-
await this.lightCT?.setAttribute(ColorControl.
|
|
2034
|
+
await this.light?.setAttribute(ColorControl.id, 'colorTemperatureMireds', this.intervalColorTemperature, this.light.log);
|
|
2035
|
+
await this.lightHS?.setAttribute(ColorControl.id, 'colorTemperatureMireds', this.intervalColorTemperature, this.lightHS.log);
|
|
2036
|
+
await this.lightXY?.setAttribute(ColorControl.id, 'colorTemperatureMireds', this.intervalColorTemperature, this.lightXY.log);
|
|
2037
|
+
await this.lightCT?.setAttribute(ColorControl.id, 'colorTemperatureMireds', this.intervalColorTemperature, this.lightCT.log);
|
|
2038
2038
|
await this.light?.configureColorControlMode(ColorControl.ColorMode.ColorTemperatureMireds);
|
|
2039
2039
|
await this.lightHS?.configureColorControlMode(ColorControl.ColorMode.ColorTemperatureMireds);
|
|
2040
2040
|
await this.lightXY?.configureColorControlMode(ColorControl.ColorMode.ColorTemperatureMireds);
|
|
@@ -2043,76 +2043,76 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
2043
2043
|
}, 60 * 1000 + 200);
|
|
2044
2044
|
}
|
|
2045
2045
|
this.outlet?.log.info('Set outlet initial onOff to false');
|
|
2046
|
-
await this.outlet?.setAttribute(OnOff.
|
|
2046
|
+
await this.outlet?.setAttribute(OnOff.id, 'onOff', false, this.outlet.log);
|
|
2047
2047
|
this.outletEnergy?.log.info('Set outlet initial onOff to false and energy/power to 0');
|
|
2048
|
-
await this.outletEnergy?.setAttribute(OnOff.
|
|
2049
|
-
await this.outletEnergy?.setAttribute(ElectricalEnergyMeasurement.
|
|
2050
|
-
await this.outletEnergy?.setAttribute(ElectricalPowerMeasurement.
|
|
2051
|
-
await this.outletEnergy?.setAttribute(ElectricalPowerMeasurement.
|
|
2052
|
-
await this.outletEnergy?.setAttribute(ElectricalPowerMeasurement.
|
|
2048
|
+
await this.outletEnergy?.setAttribute(OnOff.id, 'onOff', false, this.outletEnergy.log);
|
|
2049
|
+
await this.outletEnergy?.setAttribute(ElectricalEnergyMeasurement.id, 'cumulativeEnergyImported', { energy: 0 }, this.outletEnergy.log);
|
|
2050
|
+
await this.outletEnergy?.setAttribute(ElectricalPowerMeasurement.id, 'voltage', 220_000, this.outletEnergy.log);
|
|
2051
|
+
await this.outletEnergy?.setAttribute(ElectricalPowerMeasurement.id, 'activeCurrent', 0, this.outletEnergy.log);
|
|
2052
|
+
await this.outletEnergy?.setAttribute(ElectricalPowerMeasurement.id, 'activePower', 0, this.outletEnergy.log);
|
|
2053
2053
|
this.outletEnergyApparent?.log.info('Set outlet initial onOff to false and apparent energy/power to 0');
|
|
2054
|
-
await this.outletEnergyApparent?.setAttribute(OnOff.
|
|
2055
|
-
await this.outletEnergyApparent?.setAttribute(ElectricalEnergyMeasurement.
|
|
2056
|
-
await this.outletEnergyApparent?.setAttribute(ElectricalPowerMeasurement.
|
|
2057
|
-
await this.outletEnergyApparent?.setAttribute(ElectricalPowerMeasurement.
|
|
2058
|
-
await this.outletEnergyApparent?.setAttribute(ElectricalPowerMeasurement.
|
|
2054
|
+
await this.outletEnergyApparent?.setAttribute(OnOff.id, 'onOff', false, this.outletEnergyApparent.log);
|
|
2055
|
+
await this.outletEnergyApparent?.setAttribute(ElectricalEnergyMeasurement.id, 'cumulativeEnergyImported', { energy: 0 }, this.outletEnergyApparent.log);
|
|
2056
|
+
await this.outletEnergyApparent?.setAttribute(ElectricalPowerMeasurement.id, 'voltage', 220_000, this.outletEnergyApparent.log);
|
|
2057
|
+
await this.outletEnergyApparent?.setAttribute(ElectricalPowerMeasurement.id, 'apparentCurrent', 0, this.outletEnergyApparent.log);
|
|
2058
|
+
await this.outletEnergyApparent?.setAttribute(ElectricalPowerMeasurement.id, 'apparentPower', 0, this.outletEnergyApparent.log);
|
|
2059
2059
|
if (this.config.useInterval) {
|
|
2060
2060
|
this.addInterval(async () => {
|
|
2061
|
-
let state = this.outlet?.getAttribute(OnOff.
|
|
2061
|
+
let state = this.outlet?.getAttribute(OnOff.id, 'onOff', this.outlet.log);
|
|
2062
2062
|
if (isValidBoolean(state)) {
|
|
2063
2063
|
this.outlet?.log.info(`Set outlet onOff to ${!state}`);
|
|
2064
|
-
await this.outlet?.setAttribute(OnOff.
|
|
2064
|
+
await this.outlet?.setAttribute(OnOff.id, 'onOff', !state, this.outlet.log);
|
|
2065
2065
|
}
|
|
2066
|
-
state = this.outletEnergy?.getAttribute(OnOff.
|
|
2066
|
+
state = this.outletEnergy?.getAttribute(OnOff.id, 'onOff', this.outletEnergy.log);
|
|
2067
2067
|
if (isValidBoolean(state)) {
|
|
2068
2068
|
this.outletEnergy?.log.info(`Set outlet onOff to ${!state}`);
|
|
2069
|
-
await this.outletEnergy?.setAttribute(OnOff.
|
|
2070
|
-
if (
|
|
2071
|
-
await this.outletEnergy?.setAttribute(ElectricalPowerMeasurement.
|
|
2072
|
-
await this.outletEnergy?.setAttribute(ElectricalPowerMeasurement.
|
|
2073
|
-
|
|
2069
|
+
await this.outletEnergy?.setAttribute(OnOff.id, 'onOff', !state, this.outletEnergy.log);
|
|
2070
|
+
if (state) {
|
|
2071
|
+
await this.outletEnergy?.setAttribute(ElectricalPowerMeasurement.id, 'activeCurrent', 0, this.outletEnergy.log);
|
|
2072
|
+
await this.outletEnergy?.setAttribute(ElectricalPowerMeasurement.id, 'activePower', 0, this.outletEnergy.log);
|
|
2073
|
+
}
|
|
2074
|
+
else {
|
|
2075
|
+
await this.outletEnergy?.setAttribute(ElectricalPowerMeasurement.id, 'activeCurrent', 100_000, this.outletEnergy.log);
|
|
2076
|
+
await this.outletEnergy?.setAttribute(ElectricalPowerMeasurement.id, 'activePower', 220_000_000, this.outletEnergy.log);
|
|
2077
|
+
const energy = this.outletEnergy?.getAttribute(ElectricalEnergyMeasurement, 'cumulativeEnergyImported', this.outletEnergy.log);
|
|
2074
2078
|
if (isValidObject(energy, 1)) {
|
|
2075
2079
|
if (typeof energy.energy === 'bigint')
|
|
2076
2080
|
energy.energy += 5000n;
|
|
2077
2081
|
else
|
|
2078
2082
|
energy.energy += 5000;
|
|
2079
|
-
await this.outletEnergy?.setAttribute(ElectricalEnergyMeasurement.
|
|
2083
|
+
await this.outletEnergy?.setAttribute(ElectricalEnergyMeasurement.id, 'cumulativeEnergyImported', energy, this.outletEnergy.log);
|
|
2080
2084
|
}
|
|
2081
|
-
await this.outletEnergy?.setAttribute(ElectricalEnergyMeasurement.
|
|
2082
|
-
}
|
|
2083
|
-
else {
|
|
2084
|
-
await this.outletEnergy?.setAttribute(ElectricalPowerMeasurement.Cluster.id, 'activeCurrent', 0, this.outletEnergy.log);
|
|
2085
|
-
await this.outletEnergy?.setAttribute(ElectricalPowerMeasurement.Cluster.id, 'activePower', 0, this.outletEnergy.log);
|
|
2085
|
+
await this.outletEnergy?.setAttribute(ElectricalEnergyMeasurement.id, 'cumulativeEnergyImported', { energy: 0 }, this.outletEnergy.log);
|
|
2086
2086
|
}
|
|
2087
2087
|
}
|
|
2088
|
-
state = this.outletEnergyApparent?.getAttribute(OnOff.
|
|
2088
|
+
state = this.outletEnergyApparent?.getAttribute(OnOff.id, 'onOff', this.outletEnergyApparent.log);
|
|
2089
2089
|
if (isValidBoolean(state)) {
|
|
2090
2090
|
this.outletEnergyApparent?.log.info(`Set outlet onOff to ${!state}`);
|
|
2091
|
-
await this.outletEnergyApparent?.setAttribute(OnOff.
|
|
2092
|
-
if (
|
|
2093
|
-
await this.outletEnergyApparent?.setAttribute(ElectricalPowerMeasurement.
|
|
2094
|
-
await this.outletEnergyApparent?.setAttribute(ElectricalPowerMeasurement.
|
|
2095
|
-
|
|
2091
|
+
await this.outletEnergyApparent?.setAttribute(OnOff.id, 'onOff', !state, this.outletEnergyApparent.log);
|
|
2092
|
+
if (state) {
|
|
2093
|
+
await this.outletEnergyApparent?.setAttribute(ElectricalPowerMeasurement.id, 'apparentCurrent', 0, this.outletEnergyApparent.log);
|
|
2094
|
+
await this.outletEnergyApparent?.setAttribute(ElectricalPowerMeasurement.id, 'apparentPower', 0, this.outletEnergyApparent.log);
|
|
2095
|
+
}
|
|
2096
|
+
else {
|
|
2097
|
+
await this.outletEnergyApparent?.setAttribute(ElectricalPowerMeasurement.id, 'apparentCurrent', 100_000, this.outletEnergyApparent.log);
|
|
2098
|
+
await this.outletEnergyApparent?.setAttribute(ElectricalPowerMeasurement.id, 'apparentPower', 220_000_000, this.outletEnergyApparent.log);
|
|
2099
|
+
const energy = this.outletEnergyApparent?.getAttribute(ElectricalEnergyMeasurement, 'cumulativeEnergyImported', this.outletEnergyApparent.log);
|
|
2096
2100
|
if (isValidObject(energy, 1)) {
|
|
2097
2101
|
if (typeof energy.energy === 'bigint')
|
|
2098
2102
|
energy.energy += 5000n;
|
|
2099
2103
|
else
|
|
2100
2104
|
energy.energy += 5000;
|
|
2101
|
-
await this.outletEnergyApparent?.setAttribute(ElectricalEnergyMeasurement.
|
|
2105
|
+
await this.outletEnergyApparent?.setAttribute(ElectricalEnergyMeasurement.id, 'cumulativeEnergyImported', energy, this.outletEnergyApparent.log);
|
|
2102
2106
|
}
|
|
2103
2107
|
}
|
|
2104
|
-
else {
|
|
2105
|
-
await this.outletEnergyApparent?.setAttribute(ElectricalPowerMeasurement.Cluster.id, 'apparentCurrent', 0, this.outletEnergyApparent.log);
|
|
2106
|
-
await this.outletEnergyApparent?.setAttribute(ElectricalPowerMeasurement.Cluster.id, 'apparentPower', 0, this.outletEnergyApparent.log);
|
|
2107
|
-
}
|
|
2108
2108
|
}
|
|
2109
|
-
state = this.smartOutlet?.getChildEndpointById('Socket1')?.getAttribute(OnOff.
|
|
2109
|
+
state = this.smartOutlet?.getChildEndpointById('Socket1')?.getAttribute(OnOff.id, 'onOff', this.smartOutlet.log);
|
|
2110
2110
|
if (isValidBoolean(state)) {
|
|
2111
2111
|
this.smartOutlet?.log.info(`Set smart outlets onOff`);
|
|
2112
|
-
await this.smartOutlet?.getChildEndpointById('Socket1')?.setAttribute(OnOff.
|
|
2113
|
-
await this.smartOutlet?.getChildEndpointById('Socket2')?.setAttribute(OnOff.
|
|
2114
|
-
await this.smartOutlet?.getChildEndpointById('Socket3')?.setAttribute(OnOff.
|
|
2115
|
-
await this.smartOutlet?.getChildEndpointById('Socket4')?.setAttribute(OnOff.
|
|
2112
|
+
await this.smartOutlet?.getChildEndpointById('Socket1')?.setAttribute(OnOff.id, 'onOff', !state, this.smartOutlet.log);
|
|
2113
|
+
await this.smartOutlet?.getChildEndpointById('Socket2')?.setAttribute(OnOff.id, 'onOff', state, this.smartOutlet.log);
|
|
2114
|
+
await this.smartOutlet?.getChildEndpointById('Socket3')?.setAttribute(OnOff.id, 'onOff', !state, this.smartOutlet.log);
|
|
2115
|
+
await this.smartOutlet?.getChildEndpointById('Socket4')?.setAttribute(OnOff.id, 'onOff', state, this.smartOutlet.log);
|
|
2116
2116
|
}
|
|
2117
2117
|
}, 60 * 1000 + 300);
|
|
2118
2118
|
}
|
|
@@ -2120,201 +2120,201 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
2120
2120
|
this.coverLift?.log.info('Set cover initial targetPositionLiftPercent100ths = currentPositionLiftPercent100ths and operationalStatus to Stopped.');
|
|
2121
2121
|
if (this.config.useInterval) {
|
|
2122
2122
|
this.addInterval(async () => {
|
|
2123
|
-
let position = this.coverLift?.getAttribute(WindowCovering.
|
|
2123
|
+
let position = this.coverLift?.getAttribute(WindowCovering.id, 'currentPositionLiftPercent100ths', this.coverLift.log);
|
|
2124
2124
|
if (isValidNumber(position, 0, 10000)) {
|
|
2125
2125
|
position = position > 9000 ? 0 : position + 1000;
|
|
2126
|
-
await this.coverLift?.setAttribute(WindowCovering.
|
|
2127
|
-
await this.coverLift?.setAttribute(WindowCovering.
|
|
2128
|
-
await this.coverLift?.setAttribute(WindowCovering.
|
|
2126
|
+
await this.coverLift?.setAttribute(WindowCovering.id, 'targetPositionLiftPercent100ths', position, this.coverLift.log);
|
|
2127
|
+
await this.coverLift?.setAttribute(WindowCovering.id, 'currentPositionLiftPercent100ths', position, this.coverLift.log);
|
|
2128
|
+
await this.coverLift?.setAttribute(WindowCovering.id, 'operationalStatus', { global: WindowCovering.MovementStatus.Stopped, lift: WindowCovering.MovementStatus.Stopped, tilt: WindowCovering.MovementStatus.Stopped }, this.coverLift.log);
|
|
2129
2129
|
this.coverLift?.log.info(`Set cover current and target positionLiftPercent100ths to ${position} and operationalStatus to Stopped`);
|
|
2130
2130
|
}
|
|
2131
2131
|
}, 60 * 1000 + 400);
|
|
2132
2132
|
}
|
|
2133
|
-
await this.lock?.setAttribute(DoorLock.
|
|
2133
|
+
await this.lock?.setAttribute(DoorLock.id, 'lockState', DoorLock.LockState.Locked, this.lock.log);
|
|
2134
2134
|
this.lock?.log.info('Set lock initial lockState to Locked');
|
|
2135
2135
|
if (this.config.useInterval) {
|
|
2136
2136
|
this.addInterval(async () => {
|
|
2137
|
-
const status = this.lock?.getAttribute(DoorLock
|
|
2137
|
+
const status = this.lock?.getAttribute(DoorLock, 'lockState', this.lock.log);
|
|
2138
2138
|
if (isValidNumber(status, DoorLock.LockState.Locked, DoorLock.LockState.Unlocked)) {
|
|
2139
|
-
await this.lock?.setAttribute(DoorLock.
|
|
2139
|
+
await this.lock?.setAttribute(DoorLock.id, 'lockState', status === DoorLock.LockState.Locked ? DoorLock.LockState.Unlocked : DoorLock.LockState.Locked, this.lock.log);
|
|
2140
2140
|
this.lock?.log.info(`Set lock lockState to ${status === DoorLock.LockState.Locked ? 'Locked' : 'Unlocked'}`);
|
|
2141
2141
|
}
|
|
2142
2142
|
}, 60 * 1000 + 500);
|
|
2143
2143
|
}
|
|
2144
|
-
await this.thermoAuto?.setAttribute(
|
|
2145
|
-
await this.thermoAuto?.setAttribute(
|
|
2146
|
-
if (this.thermoAuto?.hasAttributeServer(
|
|
2147
|
-
const runningState = this.thermoAuto?.getAttribute(
|
|
2148
|
-
await this.thermoAuto?.setAttribute(
|
|
2144
|
+
await this.thermoAuto?.setAttribute(Thermostat.id, 'localTemperature', 16 * 100, this.thermoAuto.log);
|
|
2145
|
+
await this.thermoAuto?.setAttribute(Thermostat.id, 'systemMode', Thermostat.SystemMode.Auto, this.thermoAuto.log);
|
|
2146
|
+
if (this.thermoAuto?.hasAttributeServer(Thermostat.id, 'thermostatRunningState')) {
|
|
2147
|
+
const runningState = this.thermoAuto?.getAttribute(Thermostat.id, 'thermostatRunningState', this.thermoAuto.log);
|
|
2148
|
+
await this.thermoAuto?.setAttribute(Thermostat.id, 'thermostatRunningState', { ...runningState, heat: true }, this.thermoAuto.log);
|
|
2149
2149
|
}
|
|
2150
2150
|
this.thermoAuto?.log.info('Set thermostat initial localTemperature to 16°C, mode Auto and heat runningState to true');
|
|
2151
|
-
const temperature = this.thermoAuto?.
|
|
2152
|
-
await temperature?.setAttribute(TemperatureMeasurement.
|
|
2153
|
-
const humidity = this.thermoAuto?.
|
|
2154
|
-
await humidity?.setAttribute(
|
|
2155
|
-
const flow = this.thermoAuto?.
|
|
2156
|
-
await flow?.setAttribute(FlowMeasurement.
|
|
2151
|
+
const temperature = this.thermoAuto?.getChildEndpointById('Temperature');
|
|
2152
|
+
await temperature?.setAttribute(TemperatureMeasurement.id, 'measuredValue', 16 * 100, this.thermoAuto?.log);
|
|
2153
|
+
const humidity = this.thermoAuto?.getChildEndpointById('Humidity');
|
|
2154
|
+
await humidity?.setAttribute(RelativeHumidityMeasurement.id, 'measuredValue', 50 * 100, this.thermoAuto?.log);
|
|
2155
|
+
const flow = this.thermoAuto?.getChildEndpointById('Flow');
|
|
2156
|
+
await flow?.setAttribute(FlowMeasurement.id, 'measuredValue', 10, this.thermoAuto?.log);
|
|
2157
2157
|
this.thermoAuto?.log.info('Set thermostat ext temperature to 16°C, ext humidity to 50% and ext valve flow to 10');
|
|
2158
|
-
await this.thermoAutoOccupancy?.setAttribute(
|
|
2159
|
-
await this.thermoAutoOccupancy?.setAttribute(
|
|
2158
|
+
await this.thermoAutoOccupancy?.setAttribute(Thermostat.id, 'occupancy', { occupied: true }, this.thermoAutoOccupancy.log);
|
|
2159
|
+
await this.thermoAutoOccupancy?.setAttribute(Thermostat.id, 'systemMode', Thermostat.SystemMode.Auto, this.thermoAutoOccupancy.log);
|
|
2160
2160
|
this.thermoAutoOccupancy?.log.info('Set thermostat occupancy to true and mode Auto');
|
|
2161
2161
|
if (this.config.useInterval) {
|
|
2162
2162
|
this.addInterval(async () => {
|
|
2163
|
-
let temperature = this.thermoAuto?.getAttribute(
|
|
2163
|
+
let temperature = this.thermoAuto?.getAttribute(Thermostat.id, 'localTemperature', this.thermoAuto.log);
|
|
2164
2164
|
if (isValidNumber(temperature, 1600, 2400)) {
|
|
2165
2165
|
temperature = temperature + 100 > 2400 ? 1600 : temperature + 100;
|
|
2166
|
-
await this.thermoAuto?.setAttribute(
|
|
2167
|
-
await this.thermoHeat?.setAttribute(
|
|
2168
|
-
const tempIn = this.thermoHeat?.
|
|
2169
|
-
await tempIn?.setAttribute(TemperatureMeasurement.
|
|
2170
|
-
const tempOut = this.thermoHeat?.
|
|
2171
|
-
await tempOut?.setAttribute(TemperatureMeasurement.
|
|
2172
|
-
await this.thermoCool?.setAttribute(
|
|
2173
|
-
const temp = this.thermoCool?.
|
|
2174
|
-
await temp?.setAttribute(TemperatureMeasurement.
|
|
2175
|
-
const humidity = this.thermoCool?.
|
|
2176
|
-
await humidity?.setAttribute(
|
|
2177
|
-
const flow = this.thermoCool?.
|
|
2178
|
-
await flow?.setAttribute(FlowMeasurement.
|
|
2166
|
+
await this.thermoAuto?.setAttribute(Thermostat.id, 'localTemperature', temperature, this.thermoAuto.log);
|
|
2167
|
+
await this.thermoHeat?.setAttribute(Thermostat.id, 'localTemperature', temperature, this.thermoHeat.log);
|
|
2168
|
+
const tempIn = this.thermoHeat?.getChildEndpointById('TemperatureIN');
|
|
2169
|
+
await tempIn?.setAttribute(TemperatureMeasurement.id, 'measuredValue', temperature - 50, this.thermoHeat?.log);
|
|
2170
|
+
const tempOut = this.thermoHeat?.getChildEndpointById('TemperatureOUT');
|
|
2171
|
+
await tempOut?.setAttribute(TemperatureMeasurement.id, 'measuredValue', temperature - 400, this.thermoHeat?.log);
|
|
2172
|
+
await this.thermoCool?.setAttribute(Thermostat.id, 'localTemperature', temperature, this.thermoCool.log);
|
|
2173
|
+
const temp = this.thermoCool?.getChildEndpointById('Temperature');
|
|
2174
|
+
await temp?.setAttribute(TemperatureMeasurement.id, 'measuredValue', temperature, this.thermoCool?.log);
|
|
2175
|
+
const humidity = this.thermoCool?.getChildEndpointById('Humidity');
|
|
2176
|
+
await humidity?.setAttribute(RelativeHumidityMeasurement.id, 'measuredValue', 50 * 100, this.thermoCool?.log);
|
|
2177
|
+
const flow = this.thermoCool?.getChildEndpointById('Flow');
|
|
2178
|
+
await flow?.setAttribute(FlowMeasurement.id, 'measuredValue', 10, this.thermoCool?.log);
|
|
2179
2179
|
this.thermoAuto?.log.info(`Set thermostat localTemperature to ${temperature / 100}°C`);
|
|
2180
2180
|
this.thermoHeat?.log.info(`Set thermostat localTemperature to ${temperature / 100}°C`);
|
|
2181
2181
|
this.thermoCool?.log.info(`Set thermostat localTemperature to ${temperature / 100}°C`);
|
|
2182
2182
|
}
|
|
2183
|
-
let temperatureOccupancy = this.thermoAutoOccupancy?.getAttribute(
|
|
2183
|
+
let temperatureOccupancy = this.thermoAutoOccupancy?.getAttribute(Thermostat.id, 'localTemperature', this.thermoAutoOccupancy.log);
|
|
2184
2184
|
if (isValidNumber(temperatureOccupancy, 1600, 2400)) {
|
|
2185
2185
|
temperatureOccupancy = temperatureOccupancy + 100 > 2400 ? 1600 : temperatureOccupancy + 100;
|
|
2186
|
-
await this.thermoAutoOccupancy?.setAttribute(
|
|
2187
|
-
await this.thermoAutoOccupancy?.setAttribute(
|
|
2188
|
-
const occupancyValue = this.thermoAutoOccupancy?.getAttribute(Thermostat
|
|
2186
|
+
await this.thermoAutoOccupancy?.setAttribute(Thermostat.id, 'localTemperature', temperatureOccupancy, this.thermoAutoOccupancy.log);
|
|
2187
|
+
await this.thermoAutoOccupancy?.setAttribute(Thermostat.id, 'outdoorTemperature', temperatureOccupancy + 100, this.thermoAutoOccupancy.log);
|
|
2188
|
+
const occupancyValue = this.thermoAutoOccupancy?.getAttribute(Thermostat, 'occupancy', this.thermoAutoOccupancy.log);
|
|
2189
2189
|
if (isValidObject(occupancyValue, 1)) {
|
|
2190
2190
|
occupancyValue.occupied = !occupancyValue.occupied;
|
|
2191
|
-
await this.thermoAutoOccupancy?.setAttribute(Thermostat.
|
|
2191
|
+
await this.thermoAutoOccupancy?.setAttribute(Thermostat.id, 'occupancy', occupancyValue, this.thermoAutoOccupancy.log);
|
|
2192
2192
|
this.thermoAutoOccupancy?.log.info(`Set thermostat occupancy to ${occupancyValue.occupied}`);
|
|
2193
2193
|
}
|
|
2194
2194
|
}
|
|
2195
|
-
if (this.thermoAuto?.hasAttributeServer(
|
|
2196
|
-
const runningState = this.thermoAuto?.getAttribute(
|
|
2195
|
+
if (this.thermoAuto?.hasAttributeServer(Thermostat.id, 'thermostatRunningState')) {
|
|
2196
|
+
const runningState = this.thermoAuto?.getAttribute(Thermostat.id, 'thermostatRunningState', this.thermoAuto.log);
|
|
2197
2197
|
runningState.heat = !runningState?.heat;
|
|
2198
2198
|
runningState.cool = !runningState?.cool;
|
|
2199
|
-
await this.thermoAuto?.setAttribute(
|
|
2199
|
+
await this.thermoAuto?.setAttribute(Thermostat.id, 'thermostatRunningState', runningState, this.thermoAuto.log);
|
|
2200
2200
|
}
|
|
2201
2201
|
}, 60 * 1000 + 600);
|
|
2202
2202
|
}
|
|
2203
|
-
await this.airConditioner?.setAttribute(OnOff.
|
|
2204
|
-
await this.airConditioner?.setAttribute(
|
|
2203
|
+
await this.airConditioner?.setAttribute(OnOff.id, 'onOff', true, this.airConditioner.log);
|
|
2204
|
+
await this.airConditioner?.setAttribute(Thermostat.id, 'localTemperature', 2000, this.airConditioner.log);
|
|
2205
2205
|
if (this.config.useInterval) {
|
|
2206
2206
|
this.addInterval(async () => {
|
|
2207
|
-
let temperature = this.airConditioner?.getAttribute(
|
|
2207
|
+
let temperature = this.airConditioner?.getAttribute(Thermostat.id, 'localTemperature', this.airConditioner.log);
|
|
2208
2208
|
if (isValidNumber(temperature, 1600, 2400)) {
|
|
2209
2209
|
temperature = temperature + 100 > 2400 ? 1600 : temperature + 100;
|
|
2210
|
-
await this.airConditioner?.setAttribute(
|
|
2211
|
-
await this.airConditioner?.setAttribute(TemperatureMeasurement.
|
|
2212
|
-
await this.airConditioner?.setAttribute(
|
|
2210
|
+
await this.airConditioner?.setAttribute(Thermostat.id, 'localTemperature', temperature, this.airConditioner.log);
|
|
2211
|
+
await this.airConditioner?.setAttribute(TemperatureMeasurement.id, 'measuredValue', temperature, this.airConditioner.log);
|
|
2212
|
+
await this.airConditioner?.setAttribute(RelativeHumidityMeasurement.id, 'measuredValue', 50 * 100, this.airConditioner.log);
|
|
2213
2213
|
this.airConditioner?.log.info(`Set airConditioner localTemperature to ${temperature / 100}°C`);
|
|
2214
2214
|
}
|
|
2215
2215
|
}, 60 * 1000 + 550);
|
|
2216
2216
|
}
|
|
2217
2217
|
this.fanBase?.log.info('Set fan initial fanMode to Off, percentCurrent and percentSetting to 0');
|
|
2218
|
-
await this.fanBase?.setAttribute(FanControl.
|
|
2219
|
-
await this.fanBase?.setAttribute(FanControl.
|
|
2220
|
-
await this.fanBase?.setAttribute(FanControl.
|
|
2221
|
-
await this.fanDefault?.setAttribute(FanControl.
|
|
2222
|
-
await this.fanDefault?.setAttribute(FanControl.
|
|
2223
|
-
await this.fanDefault?.setAttribute(FanControl.
|
|
2224
|
-
await this.fanComplete?.setAttribute(FanControl.
|
|
2225
|
-
await this.fanComplete?.setAttribute(FanControl.
|
|
2226
|
-
await this.fanComplete?.setAttribute(FanControl.
|
|
2218
|
+
await this.fanBase?.setAttribute(FanControl.id, 'fanMode', FanControl.FanMode.Off, this.fanBase.log);
|
|
2219
|
+
await this.fanBase?.setAttribute(FanControl.id, 'percentCurrent', 0, this.fanBase.log);
|
|
2220
|
+
await this.fanBase?.setAttribute(FanControl.id, 'percentSetting', 0, this.fanBase.log);
|
|
2221
|
+
await this.fanDefault?.setAttribute(FanControl.id, 'fanMode', FanControl.FanMode.Auto, this.fanDefault.log);
|
|
2222
|
+
await this.fanDefault?.setAttribute(FanControl.id, 'percentCurrent', 0, this.fanDefault.log);
|
|
2223
|
+
await this.fanDefault?.setAttribute(FanControl.id, 'percentSetting', 0, this.fanDefault.log);
|
|
2224
|
+
await this.fanComplete?.setAttribute(FanControl.id, 'fanMode', FanControl.FanMode.Auto, this.fanComplete.log);
|
|
2225
|
+
await this.fanComplete?.setAttribute(FanControl.id, 'percentCurrent', 0, this.fanComplete.log);
|
|
2226
|
+
await this.fanComplete?.setAttribute(FanControl.id, 'percentSetting', 0, this.fanComplete.log);
|
|
2227
2227
|
if (this.config.useInterval) {
|
|
2228
2228
|
this.addInterval(async () => {
|
|
2229
|
-
let mode = this.fanBase?.getAttribute(FanControl
|
|
2230
|
-
let value = this.fanBase?.getAttribute(FanControl
|
|
2231
|
-
mode = this.fanDefault?.getAttribute(FanControl
|
|
2232
|
-
value = this.fanDefault?.getAttribute(FanControl
|
|
2229
|
+
let mode = this.fanBase?.getAttribute(FanControl, 'fanMode', this.fanBase.log);
|
|
2230
|
+
let value = this.fanBase?.getAttribute(FanControl, 'percentCurrent', this.fanBase.log);
|
|
2231
|
+
mode = this.fanDefault?.getAttribute(FanControl, 'fanMode', this.fanDefault.log);
|
|
2232
|
+
value = this.fanDefault?.getAttribute(FanControl, 'percentCurrent', this.fanDefault.log);
|
|
2233
2233
|
if (isValidNumber(mode, FanControl.FanMode.Off, FanControl.FanMode.Auto) && mode === FanControl.FanMode.Auto && isValidNumber(value, 0, 100)) {
|
|
2234
2234
|
value = value + 10 >= 100 ? 0 : value + 10;
|
|
2235
|
-
await this.fanDefault?.setAttribute(FanControl
|
|
2236
|
-
await this.fanDefault?.setAttribute(FanControl
|
|
2235
|
+
await this.fanDefault?.setAttribute(FanControl, 'percentCurrent', value, this.fanDefault.log);
|
|
2236
|
+
await this.fanDefault?.setAttribute(FanControl, 'percentSetting', value, this.fanDefault.log);
|
|
2237
2237
|
this.fanDefault?.log.info(`Set fan percentCurrent and percentSetting to ${value}`);
|
|
2238
2238
|
}
|
|
2239
|
-
mode = this.fanComplete?.getAttribute(FanControl
|
|
2240
|
-
value = this.fanComplete?.getAttribute(FanControl
|
|
2239
|
+
mode = this.fanComplete?.getAttribute(FanControl, 'fanMode', this.fanComplete.log);
|
|
2240
|
+
value = this.fanComplete?.getAttribute(FanControl, 'percentCurrent', this.fanComplete.log);
|
|
2241
2241
|
if (isValidNumber(mode, FanControl.FanMode.Off, FanControl.FanMode.Auto) && mode === FanControl.FanMode.Auto && isValidNumber(value, 0, 100)) {
|
|
2242
2242
|
value = value + 10 >= 100 ? 0 : value + 10;
|
|
2243
|
-
await this.fanComplete?.setAttribute(FanControl
|
|
2244
|
-
await this.fanComplete?.setAttribute(FanControl
|
|
2243
|
+
await this.fanComplete?.setAttribute(FanControl, 'percentCurrent', value, this.fanComplete.log);
|
|
2244
|
+
await this.fanComplete?.setAttribute(FanControl, 'percentSetting', value, this.fanComplete.log);
|
|
2245
2245
|
this.fanComplete?.log.info(`Set fan percentCurrent and percentSetting to ${value}`);
|
|
2246
2246
|
}
|
|
2247
2247
|
}, 60 * 1000 + 700);
|
|
2248
2248
|
}
|
|
2249
|
-
await this.waterLeak?.setAttribute(BooleanState.
|
|
2249
|
+
await this.waterLeak?.setAttribute(BooleanState.id, 'stateValue', false, this.waterLeak.log);
|
|
2250
2250
|
if (this.config.useInterval) {
|
|
2251
2251
|
this.addInterval(async () => {
|
|
2252
|
-
let value = this.waterLeak?.getAttribute(BooleanState.
|
|
2252
|
+
let value = this.waterLeak?.getAttribute(BooleanState.id, 'stateValue', this.waterLeak.log);
|
|
2253
2253
|
if (isValidBoolean(value)) {
|
|
2254
2254
|
value = !value;
|
|
2255
|
-
await this.waterLeak?.setAttribute(BooleanState.
|
|
2255
|
+
await this.waterLeak?.setAttribute(BooleanState.id, 'stateValue', value, this.waterLeak.log);
|
|
2256
2256
|
this.waterLeak?.log.info(`Set waterLeak stateValue to ${value}`);
|
|
2257
2257
|
}
|
|
2258
2258
|
}, 60 * 1000 + 800);
|
|
2259
2259
|
}
|
|
2260
|
-
await this.waterFreeze?.setAttribute(BooleanState.
|
|
2260
|
+
await this.waterFreeze?.setAttribute(BooleanState.id, 'stateValue', false, this.waterFreeze.log);
|
|
2261
2261
|
if (this.config.useInterval) {
|
|
2262
2262
|
this.addInterval(async () => {
|
|
2263
|
-
let value = this.waterFreeze?.getAttribute(BooleanState.
|
|
2263
|
+
let value = this.waterFreeze?.getAttribute(BooleanState.id, 'stateValue', this.waterFreeze.log);
|
|
2264
2264
|
if (isValidBoolean(value)) {
|
|
2265
2265
|
value = !value;
|
|
2266
|
-
await this.waterFreeze?.setAttribute(BooleanState.
|
|
2266
|
+
await this.waterFreeze?.setAttribute(BooleanState.id, 'stateValue', value, this.waterFreeze.log);
|
|
2267
2267
|
this.waterFreeze?.log.info(`Set waterFreeze stateValue to ${value}`);
|
|
2268
2268
|
}
|
|
2269
2269
|
}, 60 * 1000 + 900);
|
|
2270
2270
|
}
|
|
2271
|
-
await this.rain?.setAttribute(BooleanState.
|
|
2271
|
+
await this.rain?.setAttribute(BooleanState.id, 'stateValue', false, this.rain.log);
|
|
2272
2272
|
if (this.config.useInterval) {
|
|
2273
2273
|
this.addInterval(async () => {
|
|
2274
|
-
let value = this.rain?.getAttribute(BooleanState.
|
|
2274
|
+
let value = this.rain?.getAttribute(BooleanState.id, 'stateValue', this.rain.log);
|
|
2275
2275
|
if (isValidBoolean(value)) {
|
|
2276
2276
|
value = !value;
|
|
2277
|
-
await this.rain?.setAttribute(BooleanState.
|
|
2277
|
+
await this.rain?.setAttribute(BooleanState.id, 'stateValue', value, this.rain.log);
|
|
2278
2278
|
this.rain?.log.info(`Set rain stateValue to ${value}`);
|
|
2279
2279
|
}
|
|
2280
2280
|
}, 60 * 1000 + 1000);
|
|
2281
2281
|
}
|
|
2282
|
-
await this.smokeCo?.setAttribute(SmokeCoAlarm.
|
|
2283
|
-
await this.smokeCo?.setAttribute(SmokeCoAlarm.
|
|
2284
|
-
await this.smokeOnly?.setAttribute(SmokeCoAlarm.
|
|
2285
|
-
await this.coOnly?.setAttribute(SmokeCoAlarm.
|
|
2282
|
+
await this.smokeCo?.setAttribute(SmokeCoAlarm.id, 'smokeState', SmokeCoAlarm.AlarmState.Normal, this.smokeCo.log);
|
|
2283
|
+
await this.smokeCo?.setAttribute(SmokeCoAlarm.id, 'coState', SmokeCoAlarm.AlarmState.Normal, this.smokeCo.log);
|
|
2284
|
+
await this.smokeOnly?.setAttribute(SmokeCoAlarm.id, 'smokeState', SmokeCoAlarm.AlarmState.Normal, this.smokeOnly.log);
|
|
2285
|
+
await this.coOnly?.setAttribute(SmokeCoAlarm.id, 'coState', SmokeCoAlarm.AlarmState.Normal, this.coOnly.log);
|
|
2286
2286
|
if (this.config.useInterval) {
|
|
2287
2287
|
this.addInterval(async () => {
|
|
2288
|
-
let value = this.smokeCo?.getAttribute(SmokeCoAlarm
|
|
2288
|
+
let value = this.smokeCo?.getAttribute(SmokeCoAlarm, 'smokeState', this.smokeCo.log);
|
|
2289
2289
|
if (isValidNumber(value, SmokeCoAlarm.AlarmState.Normal, SmokeCoAlarm.AlarmState.Critical)) {
|
|
2290
2290
|
value = value === SmokeCoAlarm.AlarmState.Normal ? SmokeCoAlarm.AlarmState.Critical : SmokeCoAlarm.AlarmState.Normal;
|
|
2291
|
-
await this.smokeCo?.setAttribute(SmokeCoAlarm
|
|
2292
|
-
await this.smokeCo?.setAttribute(SmokeCoAlarm
|
|
2293
|
-
await this.smokeOnly?.setAttribute(SmokeCoAlarm
|
|
2294
|
-
await this.coOnly?.setAttribute(SmokeCoAlarm
|
|
2291
|
+
await this.smokeCo?.setAttribute(SmokeCoAlarm, 'smokeState', value, this.smokeCo.log);
|
|
2292
|
+
await this.smokeCo?.setAttribute(SmokeCoAlarm, 'coState', value, this.smokeCo.log);
|
|
2293
|
+
await this.smokeOnly?.setAttribute(SmokeCoAlarm, 'smokeState', value, this.smokeOnly.log);
|
|
2294
|
+
await this.coOnly?.setAttribute(SmokeCoAlarm, 'coState', value, this.coOnly.log);
|
|
2295
2295
|
this.smokeCo?.log.info(`Set smoke smokeState and coState to ${value}`);
|
|
2296
2296
|
}
|
|
2297
2297
|
}, 60 * 1000 + 1100);
|
|
2298
2298
|
}
|
|
2299
|
-
await this.airQuality?.setAttribute(AirQuality
|
|
2300
|
-
await this.airQuality?.setAttribute(TemperatureMeasurement
|
|
2301
|
-
await this.airQuality?.setAttribute(RelativeHumidityMeasurement.
|
|
2302
|
-
await this.airQuality?.setAttribute(CarbonMonoxideConcentrationMeasurement.
|
|
2303
|
-
await this.airQuality?.setAttribute(CarbonDioxideConcentrationMeasurement.
|
|
2304
|
-
await this.airQuality?.setAttribute(NitrogenDioxideConcentrationMeasurement.
|
|
2305
|
-
await this.airQuality?.setAttribute(OzoneConcentrationMeasurement.
|
|
2306
|
-
await this.airQuality?.setAttribute(FormaldehydeConcentrationMeasurement.
|
|
2307
|
-
await this.airQuality?.setAttribute(Pm1ConcentrationMeasurement.
|
|
2308
|
-
await this.airQuality?.setAttribute(Pm25ConcentrationMeasurement.
|
|
2309
|
-
await this.airQuality?.setAttribute(Pm10ConcentrationMeasurement.
|
|
2310
|
-
await this.airQuality?.setAttribute(RadonConcentrationMeasurement.
|
|
2311
|
-
await this.airQuality?.setAttribute(TotalVolatileOrganicCompoundsConcentrationMeasurement.
|
|
2299
|
+
await this.airQuality?.setAttribute(AirQuality, 'airQuality', AirQuality.AirQualityEnum.Good, this.airQuality.log);
|
|
2300
|
+
await this.airQuality?.setAttribute(TemperatureMeasurement, 'measuredValue', 2150, this.airQuality.log);
|
|
2301
|
+
await this.airQuality?.setAttribute(RelativeHumidityMeasurement.id, 'measuredValue', 5500, this.airQuality.log);
|
|
2302
|
+
await this.airQuality?.setAttribute(CarbonMonoxideConcentrationMeasurement.id, 'measuredValue', 10, this.airQuality.log);
|
|
2303
|
+
await this.airQuality?.setAttribute(CarbonDioxideConcentrationMeasurement.id, 'measuredValue', 400, this.airQuality.log);
|
|
2304
|
+
await this.airQuality?.setAttribute(NitrogenDioxideConcentrationMeasurement.id, 'measuredValue', 1, this.airQuality.log);
|
|
2305
|
+
await this.airQuality?.setAttribute(OzoneConcentrationMeasurement.id, 'measuredValue', 1, this.airQuality.log);
|
|
2306
|
+
await this.airQuality?.setAttribute(FormaldehydeConcentrationMeasurement.id, 'measuredValue', 1, this.airQuality.log);
|
|
2307
|
+
await this.airQuality?.setAttribute(Pm1ConcentrationMeasurement.id, 'measuredValue', 100, this.airQuality.log);
|
|
2308
|
+
await this.airQuality?.setAttribute(Pm25ConcentrationMeasurement.id, 'measuredValue', 100, this.airQuality.log);
|
|
2309
|
+
await this.airQuality?.setAttribute(Pm10ConcentrationMeasurement.id, 'measuredValue', 100, this.airQuality.log);
|
|
2310
|
+
await this.airQuality?.setAttribute(RadonConcentrationMeasurement.id, 'measuredValue', 100, this.airQuality.log);
|
|
2311
|
+
await this.airQuality?.setAttribute(TotalVolatileOrganicCompoundsConcentrationMeasurement.id, 'measuredValue', 100, this.airQuality.log);
|
|
2312
2312
|
if (this.config.useInterval) {
|
|
2313
2313
|
this.addInterval(async () => {
|
|
2314
|
-
let value = this.airQuality?.getAttribute(AirQuality
|
|
2314
|
+
let value = this.airQuality?.getAttribute(AirQuality, 'airQuality', this.airQuality?.log);
|
|
2315
2315
|
if (isValidNumber(value, AirQuality.AirQualityEnum.Good, AirQuality.AirQualityEnum.ExtremelyPoor)) {
|
|
2316
2316
|
value = value >= AirQuality.AirQualityEnum.ExtremelyPoor ? AirQuality.AirQualityEnum.Good : value + 1;
|
|
2317
|
-
await this.airQuality?.setAttribute(AirQuality
|
|
2317
|
+
await this.airQuality?.setAttribute(AirQuality, 'airQuality', value, this.airQuality.log);
|
|
2318
2318
|
this.airQuality?.log.info(`Set air quality to ${value}`);
|
|
2319
2319
|
}
|
|
2320
2320
|
}, 60 * 1000 + 1100);
|
|
@@ -2324,24 +2324,24 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
2324
2324
|
this.addInterval(async () => {
|
|
2325
2325
|
if (this.genericSwitchLastEvent === 'Release') {
|
|
2326
2326
|
this.genericSwitchLastEvent = 'Single';
|
|
2327
|
-
await this.momentarySwitch?.
|
|
2328
|
-
await this.momentarySwitch?.
|
|
2329
|
-
await this.momentarySwitch?.
|
|
2330
|
-
await this.momentarySwitch?.
|
|
2331
|
-
await this.momentarySwitch?.
|
|
2332
|
-
await this.momentarySwitch?.
|
|
2327
|
+
await this.momentarySwitch?.getChildEndpointById('Momentaryswitch1')?.triggerSwitchEvent('Single', this.momentarySwitch?.log);
|
|
2328
|
+
await this.momentarySwitch?.getChildEndpointById('Momentaryswitch2')?.triggerSwitchEvent('Double', this.momentarySwitch?.log);
|
|
2329
|
+
await this.momentarySwitch?.getChildEndpointById('Momentaryswitch3')?.triggerSwitchEvent('Long', this.momentarySwitch?.log);
|
|
2330
|
+
await this.momentarySwitch?.getChildEndpointById('Momentaryswitch4')?.triggerSwitchEvent('Single', this.momentarySwitch?.log);
|
|
2331
|
+
await this.momentarySwitch?.getChildEndpointById('Momentaryswitch5')?.triggerSwitchEvent('Single', this.momentarySwitch?.log);
|
|
2332
|
+
await this.momentarySwitch?.getChildEndpointById('Momentaryswitch6')?.triggerSwitchEvent('Single', this.momentarySwitch?.log);
|
|
2333
2333
|
}
|
|
2334
2334
|
else if (this.genericSwitchLastEvent === 'Single') {
|
|
2335
2335
|
this.genericSwitchLastEvent = 'Double';
|
|
2336
|
-
await this.momentarySwitch?.
|
|
2337
|
-
await this.momentarySwitch?.
|
|
2338
|
-
await this.momentarySwitch?.
|
|
2336
|
+
await this.momentarySwitch?.getChildEndpointById('Momentaryswitch1')?.triggerSwitchEvent('Double', this.momentarySwitch?.log);
|
|
2337
|
+
await this.momentarySwitch?.getChildEndpointById('Momentaryswitch2')?.triggerSwitchEvent('Long', this.momentarySwitch?.log);
|
|
2338
|
+
await this.momentarySwitch?.getChildEndpointById('Momentaryswitch3')?.triggerSwitchEvent('Single', this.momentarySwitch?.log);
|
|
2339
2339
|
}
|
|
2340
2340
|
else if (this.genericSwitchLastEvent === 'Double') {
|
|
2341
2341
|
this.genericSwitchLastEvent = 'Long';
|
|
2342
|
-
await this.momentarySwitch?.
|
|
2343
|
-
await this.momentarySwitch?.
|
|
2344
|
-
await this.momentarySwitch?.
|
|
2342
|
+
await this.momentarySwitch?.getChildEndpointById('Momentaryswitch1')?.triggerSwitchEvent('Long', this.momentarySwitch?.log);
|
|
2343
|
+
await this.momentarySwitch?.getChildEndpointById('Momentaryswitch2')?.triggerSwitchEvent('Single', this.momentarySwitch?.log);
|
|
2344
|
+
await this.momentarySwitch?.getChildEndpointById('Momentaryswitch3')?.triggerSwitchEvent('Double', this.momentarySwitch?.log);
|
|
2345
2345
|
}
|
|
2346
2346
|
else if (this.genericSwitchLastEvent === 'Long') {
|
|
2347
2347
|
this.genericSwitchLastEvent = 'Press';
|
|
@@ -2358,33 +2358,33 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
2358
2358
|
this.clearIntervals();
|
|
2359
2359
|
await super.onShutdown(reason);
|
|
2360
2360
|
this.log.info('onShutdown called with reason:', reason ?? 'none');
|
|
2361
|
-
if (this.config.unregisterOnShutdown
|
|
2361
|
+
if (this.config.unregisterOnShutdown)
|
|
2362
2362
|
await this.unregisterAllDevices(500);
|
|
2363
2363
|
}
|
|
2364
2364
|
async addDevice(device) {
|
|
2365
2365
|
if (!device.serialNumber || !device.deviceName)
|
|
2366
|
-
return;
|
|
2366
|
+
return undefined;
|
|
2367
2367
|
this.setSelectDevice(device.serialNumber, device.deviceName, undefined, 'hub');
|
|
2368
2368
|
if (this.validateDevice(device.deviceName)) {
|
|
2369
|
-
device.softwareVersion = parseInt(this.version.replace(/\D/g, ''));
|
|
2369
|
+
device.softwareVersion = Number.parseInt(this.version.replace(/\D/g, ''));
|
|
2370
2370
|
device.softwareVersionString = this.version === '' ? 'Unknown' : this.version;
|
|
2371
|
-
device.hardwareVersion = parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, ''));
|
|
2371
|
+
device.hardwareVersion = Number.parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, ''));
|
|
2372
2372
|
device.hardwareVersionString = this.matterbridge.matterbridgeVersion;
|
|
2373
2373
|
device.softwareVersion = isValidNumber(device.softwareVersion, 0, UINT32_MAX) ? device.softwareVersion : undefined;
|
|
2374
2374
|
device.softwareVersionString = isValidString(device.softwareVersionString) ? device.softwareVersionString.slice(0, 64) : undefined;
|
|
2375
2375
|
device.hardwareVersion = isValidNumber(device.hardwareVersion, 0, UINT16_MAX) ? device.hardwareVersion : undefined;
|
|
2376
2376
|
device.hardwareVersionString = isValidString(device.hardwareVersionString) ? device.hardwareVersionString.slice(0, 64) : undefined;
|
|
2377
|
-
const options = device.getClusterServerOptions(BridgedDeviceBasicInformation.
|
|
2377
|
+
const options = device.getClusterServerOptions(BridgedDeviceBasicInformation.id);
|
|
2378
2378
|
if (options) {
|
|
2379
|
-
options.softwareVersion = device.softwareVersion
|
|
2380
|
-
options.softwareVersionString = device.softwareVersionString
|
|
2381
|
-
options.hardwareVersion = device.hardwareVersion
|
|
2382
|
-
options.hardwareVersionString = device.hardwareVersionString
|
|
2379
|
+
options.softwareVersion = device.softwareVersion ?? 1;
|
|
2380
|
+
options.softwareVersionString = device.softwareVersionString ?? '1.0.0';
|
|
2381
|
+
options.hardwareVersion = device.hardwareVersion ?? 1;
|
|
2382
|
+
options.hardwareVersionString = device.hardwareVersionString ?? '1.0.0';
|
|
2383
2383
|
}
|
|
2384
2384
|
if (device.mode === undefined && !device.deviceTypes.has(bridgedNode.code)) {
|
|
2385
2385
|
device.deviceTypes.set(bridgedNode.code, bridgedNode);
|
|
2386
|
-
const options = device.getClusterServerOptions(Descriptor
|
|
2387
|
-
if (options) {
|
|
2386
|
+
const options = device.getClusterServerOptions(Descriptor);
|
|
2387
|
+
if (options?.deviceTypeList) {
|
|
2388
2388
|
const deviceTypeList = options.deviceTypeList;
|
|
2389
2389
|
if (!deviceTypeList.find((dt) => dt.deviceType === bridgedNode.code)) {
|
|
2390
2390
|
deviceTypeList.push({ deviceType: bridgedNode.code, revision: bridgedNode.revision });
|