matterbridge 1.2.4 → 1.2.6

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.
Files changed (50) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +106 -8
  3. package/TODO.md +7 -0
  4. package/dist/AirQualityCluster.d.ts +2 -13
  5. package/dist/AirQualityCluster.d.ts.map +1 -1
  6. package/dist/AirQualityCluster.js +6 -6
  7. package/dist/AirQualityCluster.js.map +1 -1
  8. package/dist/EveHistoryCluster.d.ts +6 -26
  9. package/dist/EveHistoryCluster.d.ts.map +1 -1
  10. package/dist/EveHistoryCluster.js +6 -14
  11. package/dist/EveHistoryCluster.js.map +1 -1
  12. package/dist/TvocCluster.d.ts +2 -15
  13. package/dist/TvocCluster.d.ts.map +1 -1
  14. package/dist/TvocCluster.js +6 -6
  15. package/dist/TvocCluster.js.map +1 -1
  16. package/dist/cli.js +6 -1
  17. package/dist/cli.js.map +1 -1
  18. package/dist/index.d.ts +2 -0
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +2 -0
  21. package/dist/index.js.map +1 -1
  22. package/dist/matterbridge.d.ts +15 -0
  23. package/dist/matterbridge.d.ts.map +1 -1
  24. package/dist/matterbridge.js +367 -174
  25. package/dist/matterbridge.js.map +1 -1
  26. package/dist/matterbridgeController.d.ts.map +1 -1
  27. package/dist/matterbridgeController.js +9 -0
  28. package/dist/matterbridgeController.js.map +1 -1
  29. package/dist/matterbridgeDevice.d.ts +1241 -9
  30. package/dist/matterbridgeDevice.d.ts.map +1 -1
  31. package/dist/matterbridgeDevice.js +315 -92
  32. package/dist/matterbridgeDevice.js.map +1 -1
  33. package/frontend/build/asset-manifest.json +14 -14
  34. package/frontend/build/index.html +1 -1
  35. package/frontend/build/matterbridge 32x32.png +0 -0
  36. package/frontend/build/matterbridge 64x64.png +0 -0
  37. package/frontend/build/static/css/main.61f6cf42.css +1 -1
  38. package/frontend/build/static/css/main.61f6cf42.css.map +1 -1
  39. package/frontend/build/static/js/main.6b861489.js +3 -0
  40. package/frontend/build/static/js/{main.e3553a4d.js.LICENSE.txt → main.6b861489.js.LICENSE.txt} +99 -99
  41. package/frontend/build/static/js/main.6b861489.js.map +1 -0
  42. package/matterbridge.service +17 -0
  43. package/package.json +6 -5
  44. package/dist/matterbridgeComposed.d.ts +0 -43
  45. package/dist/matterbridgeComposed.d.ts.map +0 -1
  46. package/dist/matterbridgeComposed.js +0 -58
  47. package/dist/matterbridgeComposed.js.map +0 -1
  48. package/frontend/build/Matterbridge.jpg +0 -0
  49. package/frontend/build/static/js/main.e3553a4d.js +0 -3
  50. package/frontend/build/static/js/main.e3553a4d.js.map +0 -1
@@ -24,7 +24,7 @@ import { BasicInformationCluster, BooleanStateCluster, BridgedDeviceBasicInforma
24
24
  import { EndpointNumber, VendorId } from '@project-chip/matter-node.js/datatype';
25
25
  import { Device, DeviceClasses, DeviceTypeDefinition } from '@project-chip/matter-node.js/device';
26
26
  import { extendPublicHandlerMethods } from '@project-chip/matter-node.js/util';
27
- import { EveHistory, EveHistoryCluster } from './EveHistoryCluster.js';
27
+ import { EveHistory, EveHistoryCluster } from 'matter-history'; //'./EveHistoryCluster.js';
28
28
  import { AirQuality, AirQualityCluster } from './AirQualityCluster.js';
29
29
  import { createHash } from 'crypto';
30
30
  import { TvocMeasurement, TvocMeasurementCluster } from './TvocCluster.js';
@@ -109,6 +109,36 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
109
109
  });
110
110
  return serialized;
111
111
  }
112
+ /**
113
+ * Returns a default static EveHistoryClusterServer object with the specified voltage, current, power, and consumption values.
114
+ * This shows up in HA as a static sensor!
115
+ * @param voltage - The voltage value (default: 0).
116
+ * @param current - The current value (default: 0).
117
+ * @param power - The power value (default: 0).
118
+ * @param consumption - The consumption value (default: 0).
119
+ * @returns The default static EveHistoryClusterServer object.
120
+ */
121
+ getDefaultStaticEveHistoryClusterServer(voltage = 0, current = 0, power = 0, consumption = 0) {
122
+ return ClusterServer(EveHistoryCluster.with(EveHistory.Feature.EveEnergy), {
123
+ // Dynamic attributes
124
+ ConfigDataGet: Uint8Array.fromHex(''),
125
+ ConfigDataSet: Uint8Array.fromHex(''),
126
+ HistoryStatus: Uint8Array.fromHex(''),
127
+ HistoryEntries: Uint8Array.fromHex(''),
128
+ HistoryRequest: Uint8Array.fromHex(''),
129
+ HistorySetTime: Uint8Array.fromHex(''),
130
+ LastEvent: 0,
131
+ ResetTotal: 0,
132
+ // Normal attributes
133
+ Voltage: voltage,
134
+ Current: current,
135
+ Consumption: power,
136
+ TotalConsumption: consumption,
137
+ EnergyUnknown: 1,
138
+ ChildLock: false,
139
+ RLoc: 46080,
140
+ }, {}, {});
141
+ }
112
142
  /**
113
143
  * Creates a room Eve History Cluster Server.
114
144
  *
@@ -445,10 +475,10 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
445
475
  }, {}));
446
476
  }
447
477
  /**
448
- * Creates a default IdentifyCluster server.
478
+ * Get a default IdentifyCluster server.
449
479
  */
450
- createDefaultIdentifyClusterServer() {
451
- this.addClusterServer(ClusterServer(IdentifyCluster, {
480
+ getDefaultIdentifyClusterServer() {
481
+ return ClusterServer(IdentifyCluster, {
452
482
  identifyTime: 0,
453
483
  identifyType: Identify.IdentifyType.None,
454
484
  }, {
@@ -457,19 +487,37 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
457
487
  console.log('Identify');
458
488
  await this.commandHandler.executeHandler('identify', data);
459
489
  },
460
- }));
490
+ });
491
+ }
492
+ /**
493
+ * Creates a default IdentifyCluster server.
494
+ */
495
+ createDefaultIdentifyClusterServer() {
496
+ this.addClusterServer(this.getDefaultIdentifyClusterServer());
497
+ }
498
+ /**
499
+ * Get a default IdentifyCluster server.
500
+ */
501
+ getDefaultGroupsClusterServer() {
502
+ return createDefaultGroupsClusterServer();
461
503
  }
462
504
  /**
463
505
  * Creates a default groups cluster server and adds it to the device.
464
506
  */
465
507
  createDefaultGroupsClusterServer() {
466
- this.addClusterServer(createDefaultGroupsClusterServer());
508
+ this.addClusterServer(this.getDefaultGroupsClusterServer());
509
+ }
510
+ /**
511
+ * Get a default scenes cluster server and adds it to the current instance.
512
+ */
513
+ getDefaultScenesClusterServer() {
514
+ return createDefaultScenesClusterServer();
467
515
  }
468
516
  /**
469
517
  * Creates a default scenes cluster server and adds it to the current instance.
470
518
  */
471
519
  createDefaultScenesClusterServer() {
472
- this.addClusterServer(createDefaultScenesClusterServer());
520
+ this.addClusterServer(this.getDefaultScenesClusterServer());
473
521
  }
474
522
  /**
475
523
  * Creates a unique identifier based on the provided parameters.
@@ -485,7 +533,7 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
485
533
  return hash.digest('hex');
486
534
  }
487
535
  /**
488
- * Creates a default Basic Information Cluster Server.
536
+ * Get a default Basic Information Cluster Server.
489
537
  *
490
538
  * @param deviceName - The name of the device.
491
539
  * @param serialNumber - The serial number of the device.
@@ -498,15 +546,8 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
498
546
  * @param hardwareVersion - The hardware version of the device. Default is 1.
499
547
  * @param hardwareVersionString - The hardware version string of the device. Default is 'v.1.0.0'.
500
548
  */
501
- createDefaultBasicInformationClusterServer(deviceName, serialNumber, vendorId, vendorName, productId, productName, softwareVersion = 1, softwareVersionString = '1.0.0', hardwareVersion = 1, hardwareVersionString = '1.0.0') {
502
- this.deviceName = deviceName;
503
- this.serialNumber = serialNumber;
504
- this.uniqueId = this.createUniqueId(deviceName, serialNumber, vendorName, productName);
505
- if (MatterbridgeDevice.bridgeMode === 'bridge') {
506
- this.createDefaultBridgedDeviceBasicInformationClusterServer(deviceName, serialNumber, vendorId, vendorName, productName, softwareVersion, softwareVersionString, hardwareVersion, hardwareVersionString);
507
- return;
508
- }
509
- this.addClusterServer(ClusterServer(BasicInformationCluster, {
549
+ getDefaultBasicInformationClusterServer(deviceName, serialNumber, vendorId, vendorName, productId, productName, softwareVersion = 1, softwareVersionString = '1.0.0', hardwareVersion = 1, hardwareVersionString = '1.0.0') {
550
+ return ClusterServer(BasicInformationCluster, {
510
551
  dataModelRevision: 1,
511
552
  location: 'XX',
512
553
  vendorId: VendorId(vendorId),
@@ -528,26 +569,47 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
528
569
  shutDown: true,
529
570
  leave: true,
530
571
  reachableChanged: true,
531
- }));
572
+ });
532
573
  }
533
574
  /**
534
- * Creates a default BridgedDeviceBasicInformationClusterServer.
575
+ * Creates a default Basic Information Cluster Server.
535
576
  *
536
577
  * @param deviceName - The name of the device.
537
578
  * @param serialNumber - The serial number of the device.
538
579
  * @param vendorId - The vendor ID of the device.
539
- * @param vendorName - The name of the vendor.
540
- * @param productName - The name of the product.
580
+ * @param vendorName - The vendor name of the device.
581
+ * @param productId - The product ID of the device.
582
+ * @param productName - The product name of the device.
541
583
  * @param softwareVersion - The software version of the device. Default is 1.
542
584
  * @param softwareVersionString - The software version string of the device. Default is 'v.1.0.0'.
543
585
  * @param hardwareVersion - The hardware version of the device. Default is 1.
544
586
  * @param hardwareVersionString - The hardware version string of the device. Default is 'v.1.0.0'.
545
587
  */
546
- createDefaultBridgedDeviceBasicInformationClusterServer(deviceName, serialNumber, vendorId, vendorName, productName, softwareVersion = 1, softwareVersionString = '1.0.0', hardwareVersion = 1, hardwareVersionString = '1.0.0') {
588
+ createDefaultBasicInformationClusterServer(deviceName, serialNumber, vendorId, vendorName, productId, productName, softwareVersion = 1, softwareVersionString = '1.0.0', hardwareVersion = 1, hardwareVersionString = '1.0.0') {
547
589
  this.deviceName = deviceName;
548
590
  this.serialNumber = serialNumber;
549
591
  this.uniqueId = this.createUniqueId(deviceName, serialNumber, vendorName, productName);
550
- this.addClusterServer(ClusterServer(BridgedDeviceBasicInformationCluster, {
592
+ if (MatterbridgeDevice.bridgeMode === 'bridge') {
593
+ this.createDefaultBridgedDeviceBasicInformationClusterServer(deviceName, serialNumber, vendorId, vendorName, productName, softwareVersion, softwareVersionString, hardwareVersion, hardwareVersionString);
594
+ return;
595
+ }
596
+ this.addClusterServer(this.getDefaultBasicInformationClusterServer(deviceName, serialNumber, vendorId, vendorName, productId, productName, softwareVersion, softwareVersionString, hardwareVersion, hardwareVersionString));
597
+ }
598
+ /**
599
+ * Get a default BridgedDeviceBasicInformationClusterServer.
600
+ *
601
+ * @param deviceName - The name of the device.
602
+ * @param serialNumber - The serial number of the device.
603
+ * @param vendorId - The vendor ID of the device.
604
+ * @param vendorName - The name of the vendor.
605
+ * @param productName - The name of the product.
606
+ * @param softwareVersion - The software version of the device. Default is 1.
607
+ * @param softwareVersionString - The software version string of the device. Default is 'v.1.0.0'.
608
+ * @param hardwareVersion - The hardware version of the device. Default is 1.
609
+ * @param hardwareVersionString - The hardware version string of the device. Default is 'v.1.0.0'.
610
+ */
611
+ getDefaultBridgedDeviceBasicInformationClusterServer(deviceName, serialNumber, vendorId, vendorName, productName, softwareVersion = 1, softwareVersionString = '1.0.0', hardwareVersion = 1, hardwareVersionString = '1.0.0') {
612
+ return ClusterServer(BridgedDeviceBasicInformationCluster, {
551
613
  vendorId: vendorId !== undefined ? VendorId(vendorId) : undefined, // 4874
552
614
  vendorName: vendorName,
553
615
  productName: productName,
@@ -562,23 +624,53 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
562
624
  reachable: true,
563
625
  }, {}, {
564
626
  reachableChanged: true,
565
- }));
627
+ });
566
628
  }
567
629
  /**
568
- * Creates a default Electrical Measurement Cluster Server.
630
+ * Creates a default BridgedDeviceBasicInformationClusterServer.
631
+ *
632
+ * @param deviceName - The name of the device.
633
+ * @param serialNumber - The serial number of the device.
634
+ * @param vendorId - The vendor ID of the device.
635
+ * @param vendorName - The name of the vendor.
636
+ * @param productName - The name of the product.
637
+ * @param softwareVersion - The software version of the device. Default is 1.
638
+ * @param softwareVersionString - The software version string of the device. Default is 'v.1.0.0'.
639
+ * @param hardwareVersion - The hardware version of the device. Default is 1.
640
+ * @param hardwareVersionString - The hardware version string of the device. Default is 'v.1.0.0'.
641
+ */
642
+ createDefaultBridgedDeviceBasicInformationClusterServer(deviceName, serialNumber, vendorId, vendorName, productName, softwareVersion = 1, softwareVersionString = '1.0.0', hardwareVersion = 1, hardwareVersionString = '1.0.0') {
643
+ this.deviceName = deviceName;
644
+ this.serialNumber = serialNumber;
645
+ this.uniqueId = this.createUniqueId(deviceName, serialNumber, vendorName, productName);
646
+ this.addClusterServer(this.getDefaultBridgedDeviceBasicInformationClusterServer(deviceName, serialNumber, vendorId, vendorName, productName, softwareVersion, softwareVersionString, hardwareVersion, hardwareVersionString));
647
+ }
648
+ /**
649
+ * Get a default Electrical Measurement Cluster Server.
569
650
  *
570
651
  * @param voltage - The RMS voltage value.
571
652
  * @param current - The RMS current value.
572
653
  * @param power - The active power value.
573
654
  * @param consumption - The total active power consumption value.
574
655
  */
575
- createDefaultElectricalMeasurementClusterServer(voltage = 0, current = 0, power = 0, consumption = 0) {
576
- this.addClusterServer(ClusterServer(ElectricalMeasurementCluster, {
656
+ getDefaultElectricalMeasurementClusterServer(voltage = 0, current = 0, power = 0, consumption = 0) {
657
+ return ClusterServer(ElectricalMeasurementCluster, {
577
658
  rmsVoltage: voltage,
578
659
  rmsCurrent: current,
579
660
  activePower: power,
580
661
  totalActivePower: consumption,
581
- }, {}, {}));
662
+ }, {}, {});
663
+ }
664
+ /**
665
+ * Creates a default Electrical Measurement Cluster Server.
666
+ *
667
+ * @param voltage - The RMS voltage value.
668
+ * @param current - The RMS current value.
669
+ * @param power - The active power value.
670
+ * @param consumption - The total active power consumption value.
671
+ */
672
+ createDefaultElectricalMeasurementClusterServer(voltage = 0, current = 0, power = 0, consumption = 0) {
673
+ this.addClusterServer(this.getDefaultElectricalMeasurementClusterServer(voltage, current, power, consumption));
582
674
  }
583
675
  /**
584
676
  * Creates a default Thread Network Diagnostics Cluster server.
@@ -588,7 +680,7 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
588
680
  *
589
681
  * @returns void
590
682
  */
591
- createDefaultThreadNetworkDiagnosticsClusterServer() {
683
+ createDefaultDummyThreadNetworkDiagnosticsClusterServer() {
592
684
  this.addClusterServer(ClusterServer(ThreadNetworkDiagnosticsCluster.with(ThreadNetworkDiagnostics.Feature.PacketCounts, ThreadNetworkDiagnostics.Feature.ErrorCounts), {
593
685
  channel: 1,
594
686
  routingRole: ThreadNetworkDiagnostics.RoutingRole.Router,
@@ -617,12 +709,12 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
617
709
  }, {}));
618
710
  }
619
711
  /**
620
- * Creates a default OnOff cluster server.
712
+ * Get a default OnOff cluster server.
621
713
  *
622
714
  * @param onOff - The initial state of the OnOff cluster (default: false).
623
715
  */
624
- createDefaultOnOffClusterServer(onOff = false) {
625
- this.addClusterServer(ClusterServer(OnOffCluster, {
716
+ getDefaultOnOffClusterServer(onOff = false) {
717
+ return ClusterServer(OnOffCluster, {
626
718
  onOff,
627
719
  }, {
628
720
  on: async (data) => {
@@ -640,15 +732,23 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
640
732
  console.log('toggle onOff:', data.attributes.onOff.getLocal());
641
733
  await this.commandHandler.executeHandler('toggle', data);
642
734
  },
643
- }, {}));
735
+ }, {});
644
736
  }
645
737
  /**
646
- * Creates a default level control cluster server.
738
+ * Creates a default OnOff cluster server.
739
+ *
740
+ * @param onOff - The initial state of the OnOff cluster (default: false).
741
+ */
742
+ createDefaultOnOffClusterServer(onOff = false) {
743
+ this.addClusterServer(this.getDefaultOnOffClusterServer(onOff));
744
+ }
745
+ /**
746
+ * Get a default level control cluster server.
647
747
  *
648
748
  * @param currentLevel - The current level (default: 0).
649
749
  */
650
- createDefaultLevelControlClusterServer(currentLevel = 0) {
651
- this.addClusterServer(ClusterServer(LevelControlCluster.with(LevelControl.Feature.OnOff), {
750
+ getDefaultLevelControlClusterServer(currentLevel = 0) {
751
+ return ClusterServer(LevelControlCluster.with(LevelControl.Feature.OnOff), {
652
752
  currentLevel,
653
753
  onLevel: 0,
654
754
  options: {
@@ -692,10 +792,18 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
692
792
  // eslint-disable-next-line no-console
693
793
  console.error('Not implemented');
694
794
  },
695
- }));
795
+ });
696
796
  }
697
797
  /**
698
- * Creates a default color control cluster server.
798
+ * Creates a default level control cluster server.
799
+ *
800
+ * @param currentLevel - The current level (default: 0).
801
+ */
802
+ createDefaultLevelControlClusterServer(currentLevel = 0) {
803
+ this.addClusterServer(this.getDefaultLevelControlClusterServer(currentLevel));
804
+ }
805
+ /**
806
+ * Get a default color control cluster server.
699
807
  *
700
808
  * @param currentHue - The current hue value.
701
809
  * @param currentSaturation - The current saturation value.
@@ -703,8 +811,8 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
703
811
  * @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds.
704
812
  * @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds.
705
813
  */
706
- createDefaultColorControlClusterServer(currentHue = 0, currentSaturation = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
707
- this.addClusterServer(ClusterServer(ColorControlCluster.with(ColorControl.Feature.HueSaturation, ColorControl.Feature.ColorTemperature), {
814
+ getDefaultColorControlClusterServer(currentHue = 0, currentSaturation = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
815
+ return ClusterServer(ColorControlCluster.with(ColorControl.Feature.HueSaturation, ColorControl.Feature.ColorTemperature), {
708
816
  colorMode: ColorControl.ColorMode.CurrentHueAndCurrentSaturation,
709
817
  options: {
710
818
  executeIfOff: false,
@@ -771,15 +879,27 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
771
879
  // eslint-disable-next-line no-console
772
880
  console.error('Not implemented');
773
881
  },
774
- }, {}));
882
+ }, {});
775
883
  }
776
884
  /**
777
- * Creates a default window covering cluster server.
885
+ * Creates a default color control cluster server.
886
+ *
887
+ * @param currentHue - The current hue value.
888
+ * @param currentSaturation - The current saturation value.
889
+ * @param colorTemperatureMireds - The color temperature in mireds.
890
+ * @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds.
891
+ * @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds.
892
+ */
893
+ createDefaultColorControlClusterServer(currentHue = 0, currentSaturation = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
894
+ this.addClusterServer(this.getDefaultColorControlClusterServer(currentHue, currentSaturation, colorTemperatureMireds, colorTempPhysicalMinMireds, colorTempPhysicalMaxMireds));
895
+ }
896
+ /**
897
+ * Get a default window covering cluster server.
778
898
  *
779
899
  * @param positionPercent100ths - The position percentage in 100ths (0-10000). Defaults to 0.
780
900
  */
781
- createDefaultWindowCoveringClusterServer(positionPercent100ths) {
782
- this.addClusterServer(ClusterServer(WindowCoveringCluster.with(WindowCovering.Feature.Lift, WindowCovering.Feature.PositionAwareLift, WindowCovering.Feature.AbsolutePosition), {
901
+ getDefaultWindowCoveringClusterServer(positionPercent100ths) {
902
+ return ClusterServer(WindowCoveringCluster.with(WindowCovering.Feature.Lift, WindowCovering.Feature.PositionAwareLift, WindowCovering.Feature.AbsolutePosition), {
783
903
  type: WindowCovering.WindowCoveringType.Rollershade,
784
904
  configStatus: {
785
905
  operational: true,
@@ -819,7 +939,15 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
819
939
  `target: ${data.attributes.targetPositionLiftPercent100ths?.getLocal()} status: ${data.attributes.operationalStatus.getLocal().lift}`);
820
940
  await this.commandHandler.executeHandler('goToLiftPercentage', data);
821
941
  },
822
- }, {}));
942
+ }, {});
943
+ }
944
+ /**
945
+ * Creates a default window covering cluster server.
946
+ *
947
+ * @param positionPercent100ths - The position percentage in 100ths (0-10000). Defaults to 0.
948
+ */
949
+ createDefaultWindowCoveringClusterServer(positionPercent100ths) {
950
+ this.addClusterServer(this.getDefaultWindowCoveringClusterServer(positionPercent100ths));
823
951
  }
824
952
  /**
825
953
  * Sets the window covering target position as the current position and stops the movement.
@@ -900,18 +1028,14 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
900
1028
  console.log(`Set WindowCovering currentPositionLiftPercent100ths: ${position} and targetPositionLiftPercent100ths: ${position}.`);
901
1029
  }
902
1030
  /**
903
- * Creates a default door lock cluster server.
1031
+ * Get a default door lock cluster server.
904
1032
  *
905
1033
  * @remarks
906
1034
  * This method adds a cluster server for a door lock cluster with default settings.
907
1035
  *
908
- * @example
909
- * ```typescript
910
- * createDefaultDoorLockClusterServer();
911
- * ```
912
1036
  */
913
- createDefaultDoorLockClusterServer() {
914
- this.addClusterServer(ClusterServer(DoorLockCluster, {
1037
+ getDefaultDoorLockClusterServer() {
1038
+ return ClusterServer(DoorLockCluster, {
915
1039
  operatingMode: DoorLock.OperatingMode.Normal,
916
1040
  lockState: DoorLock.LockState.Locked,
917
1041
  lockType: DoorLock.LockType.Deadbolt,
@@ -932,16 +1056,26 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
932
1056
  doorLockAlarm: true,
933
1057
  lockOperation: true,
934
1058
  lockOperationError: true,
935
- }));
1059
+ });
936
1060
  }
937
1061
  /**
938
- * Creates a default switch cluster server.
1062
+ * Creates a default door lock cluster server.
1063
+ *
1064
+ * @remarks
1065
+ * This method adds a cluster server for a door lock cluster with default settings.
1066
+ *
1067
+ */
1068
+ createDefaultDoorLockClusterServer() {
1069
+ this.addClusterServer(this.getDefaultDoorLockClusterServer());
1070
+ }
1071
+ /**
1072
+ * Get a default switch cluster server.
939
1073
  *
940
1074
  * @remarks
941
1075
  * This method adds a cluster server with default switch features and configurations.
942
1076
  */
943
- createDefaultSwitchClusterServer() {
944
- this.addClusterServer(ClusterServer(SwitchCluster.with(Switch.Feature.MomentarySwitch, Switch.Feature.MomentarySwitchRelease, Switch.Feature.MomentarySwitchLongPress, Switch.Feature.MomentarySwitchMultiPress), {
1077
+ getDefaultSwitchClusterServer() {
1078
+ return ClusterServer(SwitchCluster.with(Switch.Feature.MomentarySwitch, Switch.Feature.MomentarySwitchRelease, Switch.Feature.MomentarySwitchLongPress, Switch.Feature.MomentarySwitchMultiPress), {
945
1079
  numberOfPositions: 2,
946
1080
  currentPosition: 0,
947
1081
  multiPressMax: 2,
@@ -952,22 +1086,52 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
952
1086
  longRelease: true,
953
1087
  multiPressOngoing: true,
954
1088
  multiPressComplete: true,
955
- }));
1089
+ });
1090
+ }
1091
+ /**
1092
+ * Creates a default switch cluster server.
1093
+ *
1094
+ * @remarks
1095
+ * This method adds a cluster server with default switch features and configurations.
1096
+ */
1097
+ createDefaultSwitchClusterServer() {
1098
+ this.addClusterServer(this.getDefaultSwitchClusterServer());
956
1099
  this.addFixedLabel('orientation', 'Switch');
957
1100
  this.addFixedLabel('label', 'Switch');
958
1101
  }
959
1102
  /**
960
- * Creates a default occupancy sensing cluster server.
1103
+ * Get a default occupancy sensing cluster server.
961
1104
  *
962
1105
  * @param occupied - A boolean indicating whether the occupancy is occupied or not. Default is false.
963
1106
  */
964
- createDefaultOccupancySensingClusterServer(occupied = false) {
965
- this.addClusterServer(ClusterServer(OccupancySensingCluster, {
1107
+ getDefaultOccupancySensingClusterServer(occupied = false) {
1108
+ return ClusterServer(OccupancySensingCluster, {
966
1109
  occupancy: { occupied },
967
1110
  occupancySensorType: OccupancySensing.OccupancySensorType.Pir,
968
1111
  occupancySensorTypeBitmap: { pir: true, ultrasonic: false, physicalContact: false },
969
1112
  pirOccupiedToUnoccupiedDelay: 30,
970
- }, {}));
1113
+ }, {});
1114
+ }
1115
+ /**
1116
+ * Creates a default occupancy sensing cluster server.
1117
+ *
1118
+ * @param occupied - A boolean indicating whether the occupancy is occupied or not. Default is false.
1119
+ */
1120
+ createDefaultOccupancySensingClusterServer(occupied = false) {
1121
+ this.addClusterServer(this.getDefaultOccupancySensingClusterServer(occupied));
1122
+ }
1123
+ /**
1124
+ * Get a default Illuminance Measurement Cluster Server.
1125
+ *
1126
+ * @param measuredValue - The measured value of illuminance.
1127
+ */
1128
+ getDefaultIlluminanceMeasurementClusterServer(measuredValue = 0) {
1129
+ return ClusterServer(IlluminanceMeasurementCluster, {
1130
+ measuredValue,
1131
+ minMeasuredValue: null,
1132
+ maxMeasuredValue: null,
1133
+ tolerance: 0,
1134
+ }, {}, {});
971
1135
  }
972
1136
  /**
973
1137
  * Creates a default Illuminance Measurement Cluster Server.
@@ -975,12 +1139,20 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
975
1139
  * @param measuredValue - The measured value of illuminance.
976
1140
  */
977
1141
  createDefaultIlluminanceMeasurementClusterServer(measuredValue = 0) {
978
- this.addClusterServer(ClusterServer(IlluminanceMeasurementCluster, {
1142
+ this.addClusterServer(this.getDefaultIlluminanceMeasurementClusterServer(measuredValue));
1143
+ }
1144
+ /**
1145
+ * Get a default temperature measurement cluster server.
1146
+ *
1147
+ * @param measuredValue - The measured value of the temperature.
1148
+ */
1149
+ getDefaultTemperatureMeasurementClusterServer(measuredValue = 0) {
1150
+ return ClusterServer(TemperatureMeasurementCluster, {
979
1151
  measuredValue,
980
1152
  minMeasuredValue: null,
981
1153
  maxMeasuredValue: null,
982
1154
  tolerance: 0,
983
- }, {}, {}));
1155
+ }, {}, {});
984
1156
  }
985
1157
  /**
986
1158
  * Creates a default temperature measurement cluster server.
@@ -988,12 +1160,20 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
988
1160
  * @param measuredValue - The measured value of the temperature.
989
1161
  */
990
1162
  createDefaultTemperatureMeasurementClusterServer(measuredValue = 0) {
991
- this.addClusterServer(ClusterServer(TemperatureMeasurementCluster, {
1163
+ this.addClusterServer(this.getDefaultTemperatureMeasurementClusterServer(measuredValue));
1164
+ }
1165
+ /**
1166
+ * Get a default RelativeHumidityMeasurementCluster server.
1167
+ *
1168
+ * @param measuredValue - The measured value of the relative humidity.
1169
+ */
1170
+ getDefaultRelativeHumidityMeasurementClusterServer(measuredValue = 0) {
1171
+ return ClusterServer(RelativeHumidityMeasurementCluster, {
992
1172
  measuredValue,
993
1173
  minMeasuredValue: null,
994
1174
  maxMeasuredValue: null,
995
1175
  tolerance: 0,
996
- }, {}, {}));
1176
+ }, {}, {});
997
1177
  }
998
1178
  /**
999
1179
  * Creates a default RelativeHumidityMeasurementCluster server.
@@ -1001,12 +1181,20 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
1001
1181
  * @param measuredValue - The measured value of the relative humidity.
1002
1182
  */
1003
1183
  createDefaultRelativeHumidityMeasurementClusterServer(measuredValue = 0) {
1004
- this.addClusterServer(ClusterServer(RelativeHumidityMeasurementCluster, {
1184
+ this.addClusterServer(this.getDefaultRelativeHumidityMeasurementClusterServer(measuredValue));
1185
+ }
1186
+ /**
1187
+ * Get a default Pressure Measurement Cluster Server.
1188
+ *
1189
+ * @param measuredValue - The measured value for the pressure.
1190
+ */
1191
+ getDefaultPressureMeasurementClusterServer(measuredValue = 1000) {
1192
+ return ClusterServer(PressureMeasurementCluster, {
1005
1193
  measuredValue,
1006
1194
  minMeasuredValue: null,
1007
1195
  maxMeasuredValue: null,
1008
1196
  tolerance: 0,
1009
- }, {}, {}));
1197
+ }, {}, {});
1010
1198
  }
1011
1199
  /**
1012
1200
  * Creates a default Pressure Measurement Cluster Server.
@@ -1014,24 +1202,27 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
1014
1202
  * @param measuredValue - The measured value for the pressure.
1015
1203
  */
1016
1204
  createDefaultPressureMeasurementClusterServer(measuredValue = 1000) {
1017
- this.addClusterServer(ClusterServer(PressureMeasurementCluster, {
1018
- measuredValue,
1019
- minMeasuredValue: null,
1020
- maxMeasuredValue: null,
1021
- tolerance: 0,
1022
- }, {}, {}));
1205
+ this.addClusterServer(this.getDefaultPressureMeasurementClusterServer(measuredValue));
1023
1206
  }
1024
1207
  /**
1025
- * Creates a default boolean state cluster server.
1208
+ * Get a default boolean state cluster server.
1026
1209
  *
1027
1210
  * @param contact - Optional boolean value indicating the contact state. Defaults to `true` if not provided.
1028
1211
  */
1029
- createDefaultBooleanStateClusterServer(contact) {
1030
- this.addClusterServer(ClusterServer(BooleanStateCluster, {
1212
+ getDefaultBooleanStateClusterServer(contact) {
1213
+ return ClusterServer(BooleanStateCluster, {
1031
1214
  stateValue: contact ?? true, // true=contact false=no_contact
1032
1215
  }, {}, {
1033
1216
  stateChange: true,
1034
- }));
1217
+ });
1218
+ }
1219
+ /**
1220
+ * Creates a default boolean state cluster server.
1221
+ *
1222
+ * @param contact - Optional boolean value indicating the contact state. Defaults to `true` if not provided.
1223
+ */
1224
+ createDefaultBooleanStateClusterServer(contact) {
1225
+ this.addClusterServer(this.getDefaultBooleanStateClusterServer(contact));
1035
1226
  }
1036
1227
  /**
1037
1228
  * Creates a default power source replaceable battery cluster server.
@@ -1108,37 +1299,53 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
1108
1299
  sources: endpointNumber ? [EndpointNumber(endpointNumber)] : [],
1109
1300
  }, {}, {}));
1110
1301
  }
1302
+ /**
1303
+ * Get a default air quality cluster server.
1304
+ *
1305
+ * @param airQuality The air quality type. Defaults to `AirQuality.AirQualityType.Unknown`.
1306
+ */
1307
+ getDefaultAirQualityClusterServer(airQuality = AirQuality.AirQualityType.Unknown) {
1308
+ return ClusterServer(AirQualityCluster.with(AirQuality.Feature.FairAirQuality, AirQuality.Feature.ModerateAirQuality, AirQuality.Feature.VeryPoorAirQuality), {
1309
+ airQuality,
1310
+ }, {}, {});
1311
+ }
1111
1312
  /**
1112
1313
  * Creates a default air quality cluster server.
1113
1314
  *
1114
1315
  * @param airQuality The air quality type. Defaults to `AirQuality.AirQualityType.Unknown`.
1115
1316
  */
1116
1317
  createDefaultAirQualityClusterServer(airQuality = AirQuality.AirQualityType.Unknown) {
1117
- this.addClusterServer(ClusterServer(AirQualityCluster.with(AirQuality.Feature.FairAirQuality, AirQuality.Feature.ModerateAirQuality, AirQuality.Feature.VeryPoorAirQuality), {
1118
- airQuality,
1119
- }, {}, {}));
1318
+ this.addClusterServer(this.getDefaultAirQualityClusterServer(airQuality));
1120
1319
  }
1121
1320
  /**
1122
- * Creates a default TVOC measurement cluster server.
1321
+ * Get a default TVOC measurement cluster server.
1123
1322
  *
1124
1323
  * @param measuredValue - The measured value for TVOC.
1125
1324
  */
1126
- createDefaultTvocMeasurementClusterServer(measuredValue = 0) {
1127
- this.addClusterServer(ClusterServer(TvocMeasurementCluster.with(TvocMeasurement.Feature.NumericMeasurement), {
1325
+ getDefaultTvocMeasurementClusterServer(measuredValue = 0) {
1326
+ return ClusterServer(TvocMeasurementCluster.with(TvocMeasurement.Feature.NumericMeasurement), {
1128
1327
  measuredValue,
1129
1328
  minMeasuredValue: null,
1130
1329
  maxMeasuredValue: null,
1131
- }, {}, {}));
1330
+ }, {}, {});
1132
1331
  }
1133
1332
  /**
1134
- * Creates a default thermostat cluster server with the specified parameters.
1333
+ * Creates a default TVOC measurement cluster server.
1334
+ *
1335
+ * @param measuredValue - The measured value for TVOC.
1336
+ */
1337
+ createDefaultTvocMeasurementClusterServer(measuredValue = 0) {
1338
+ this.addClusterServer(this.getDefaultTvocMeasurementClusterServer(measuredValue));
1339
+ }
1340
+ /**
1341
+ * Get a default thermostat cluster server with the specified parameters.
1135
1342
  *
1136
1343
  * @param localTemperature - The local temperature value in degrees Celsius. Defaults to 23.
1137
1344
  * @param occupiedHeatingSetpoint - The occupied heating setpoint value in degrees Celsius. Defaults to 21.
1138
1345
  * @param occupiedCoolingSetpoint - The occupied cooling setpoint value in degrees Celsius. Defaults to 25.
1139
1346
  */
1140
- createDefaultThermostatClusterServer(localTemperature = 23, occupiedHeatingSetpoint = 21, occupiedCoolingSetpoint = 25) {
1141
- this.addClusterServer(ClusterServer(ThermostatCluster.with(Thermostat.Feature.Heating, Thermostat.Feature.Cooling /*, Thermostat.Feature.AutoMode*/), {
1347
+ getDefaultThermostatClusterServer(localTemperature = 23, occupiedHeatingSetpoint = 21, occupiedCoolingSetpoint = 25) {
1348
+ return ClusterServer(ThermostatCluster.with(Thermostat.Feature.Heating, Thermostat.Feature.Cooling /*, Thermostat.Feature.AutoMode*/), {
1142
1349
  localTemperature: localTemperature * 100,
1143
1350
  occupiedHeatingSetpoint: occupiedHeatingSetpoint * 100,
1144
1351
  occupiedCoolingSetpoint: occupiedCoolingSetpoint * 100,
@@ -1160,13 +1367,23 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
1160
1367
  console.log('setpointRaiseLower', request);
1161
1368
  await this.commandHandler.executeHandler('setpointRaiseLower', { request, attributes });
1162
1369
  },
1163
- }, {}));
1370
+ }, {});
1164
1371
  }
1165
1372
  /**
1166
- * Creates a default dummy time sync cluster server. Only needed to create a thermostat.
1373
+ * Creates a default thermostat cluster server with the specified parameters.
1374
+ *
1375
+ * @param localTemperature - The local temperature value in degrees Celsius. Defaults to 23.
1376
+ * @param occupiedHeatingSetpoint - The occupied heating setpoint value in degrees Celsius. Defaults to 21.
1377
+ * @param occupiedCoolingSetpoint - The occupied cooling setpoint value in degrees Celsius. Defaults to 25.
1167
1378
  */
1168
- createDefaultDummyTimeSyncClusterServer() {
1169
- this.addClusterServer(ClusterServer(TimeSyncCluster.with(TimeSync.Feature.TimeZone), {
1379
+ createDefaultThermostatClusterServer(localTemperature = 23, occupiedHeatingSetpoint = 21, occupiedCoolingSetpoint = 25) {
1380
+ this.addClusterServer(this.getDefaultThermostatClusterServer(localTemperature, occupiedHeatingSetpoint, occupiedCoolingSetpoint));
1381
+ }
1382
+ /**
1383
+ * Get a default time sync cluster server. Only needed to create a thermostat.
1384
+ */
1385
+ getDefaultTimeSyncClusterServer() {
1386
+ return ClusterServer(TimeSyncCluster.with(TimeSync.Feature.TimeZone), {
1170
1387
  utcTime: null,
1171
1388
  granularity: TimeSync.Granularity.NoTimeGranularity,
1172
1389
  timeZone: [{ offset: 0, validAt: 0 }],
@@ -1184,7 +1401,13 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
1184
1401
  dstTableEmpty: true,
1185
1402
  dstStatus: true,
1186
1403
  timeZoneStatus: true,
1187
- }));
1404
+ });
1405
+ }
1406
+ /**
1407
+ * Creates a default time sync cluster server. Only needed to create a thermostat.
1408
+ */
1409
+ createDefaultTimeSyncClusterServer() {
1410
+ this.addClusterServer(this.getDefaultTimeSyncClusterServer());
1188
1411
  }
1189
1412
  }
1190
1413
  //# sourceMappingURL=matterbridgeDevice.js.map