matterbridge-example-dynamic-platform 1.3.4-dev-20250720-e338589 → 1.3.5-dev-20250722-a63fdf7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -23,11 +23,13 @@ If you like this project and find it useful, please consider giving it a star on
23
23
  <img src="bmc-button.svg" alt="Buy me a coffee" width="120">
24
24
  </a>
25
25
 
26
- ## [1.3.4] - 2025-07-22
26
+ ## [1.3.5] - 2025-07-22
27
27
 
28
28
  ### Added
29
29
 
30
30
  - [platform]: Changed to the new ExtratorHood() and Dishwasher() from Matterbridge.
31
+ - [platform]: Added a Fan with on Off Low Med High.
32
+ - [platform]: Added a Fan with complete set of features.
31
33
 
32
34
  ### Changed
33
35
 
package/README.md CHANGED
@@ -17,7 +17,7 @@
17
17
 
18
18
  Matterbridge dynamic platform example plugin is a template to develop your own plugin using the dynamic platform.
19
19
 
20
- It exposes 44 virtual devices:
20
+ It exposes 46 virtual devices:
21
21
 
22
22
  - a switch with onOff cluster
23
23
  - a light with onOff
@@ -34,7 +34,9 @@ It exposes 44 virtual devices:
34
34
  and relativeHumidityMeasurement cluster (to show how to create a composed device with sub endpoints)
35
35
  - a thermo heat only with two external temperature sensors (tagged like Indoor and Outdoor)
36
36
  - a thermo cool only
37
- - a fan with FanControl cluster
37
+ - a fan with Off Low Med High presets
38
+ - a fan with Off Low Med High Auto presets and step
39
+ - a fan with all the features
38
40
  - a rainSensor device
39
41
  - a waterFreezeDetector device
40
42
  - a waterLeakDetector device
package/dist/platform.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { MatterbridgeEndpoint, MatterbridgeDynamicPlatform, airQualitySensor, bridgedNode, colorTemperatureLight, coverDevice, dimmableLight, doorLockDevice, fanDevice, flowSensor, humiditySensor, onOffLight, onOffOutlet, onOffSwitch, powerSource, rainSensor, smokeCoAlarm, temperatureSensor, thermostatDevice, waterFreezeDetector, waterLeakDetector, airPurifier, pumpDevice, waterValve, genericSwitch, airConditioner, cooktop, microwaveOven, oven, refrigerator, onOffMountedSwitch, dimmableMountedSwitch, extendedColorLight, } from 'matterbridge';
2
2
  import { RoboticVacuumCleaner, LaundryWasher, WaterHeater, Evse, SolarPower, BatteryStorage, LaundryDryer, HeatPump, Dishwasher, ExtractorHood } from 'matterbridge/devices';
3
3
  import { isValidBoolean, isValidNumber } from 'matterbridge/utils';
4
+ import { debugStringify } from 'matterbridge/logger';
4
5
  import { AreaNamespaceTag, LocationTag, NumberTag, PositionTag } from 'matterbridge/matter';
5
6
  import { PowerSource, BooleanState, OnOff, LevelControl, AirQuality, CarbonDioxideConcentrationMeasurement, CarbonMonoxideConcentrationMeasurement, FlowMeasurement, ColorControl, DoorLock, FanControl, FormaldehydeConcentrationMeasurement, NitrogenDioxideConcentrationMeasurement, OzoneConcentrationMeasurement, Pm10ConcentrationMeasurement, Pm1ConcentrationMeasurement, Pm25ConcentrationMeasurement, RadonConcentrationMeasurement, RelativeHumidityMeasurement, RelativeHumidityMeasurementCluster, SmokeCoAlarm, TemperatureMeasurement, Thermostat, ThermostatCluster, TotalVolatileOrganicCompoundsConcentrationMeasurement, WindowCovering, EnergyEvseMode, EnergyEvse, RvcRunMode, RvcCleanMode, } from 'matterbridge/matter/clusters';
6
7
  import { Appliances } from './appliances.js';
@@ -22,6 +23,8 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
22
23
  thermoHeat;
23
24
  thermoCool;
24
25
  fan;
26
+ fanauto;
27
+ fanComplete;
25
28
  waterLeak;
26
29
  waterFreeze;
27
30
  rain;
@@ -36,6 +39,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
36
39
  momentarySwitch;
37
40
  latchingSwitch;
38
41
  vacuum;
42
+ roboticVacuum;
39
43
  waterHeater;
40
44
  evse;
41
45
  laundryWasher;
@@ -65,6 +69,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
65
69
  intervalColorTemperature = 147;
66
70
  bridgedDevices = new Map();
67
71
  fanModeLookup = ['Off', 'Low', 'Medium', 'High', 'On', 'Auto', 'Smart'];
72
+ fanDirectionLookup = ['Forward', 'Reverse'];
68
73
  constructor(matterbridge, log, config) {
69
74
  super(matterbridge, log, config);
70
75
  if (this.verifyMatterbridgeVersion === undefined || typeof this.verifyMatterbridgeVersion !== 'function' || !this.verifyMatterbridgeVersion('3.1.6')) {
@@ -90,14 +95,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
90
95
  .createDefaultBridgedDeviceBasicInformationClusterServer('Switch', '0x23452164', 0xfff1, 'Matterbridge', 'Matterbridge Switch', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
91
96
  .createDefaultOnOffClusterServer()
92
97
  .createDefaultPowerSourceRechargeableBatteryClusterServer(70);
93
- this.setSelectDevice(this.switch.serialNumber ?? '', this.switch.deviceName ?? '', undefined, 'hub');
94
- if (this.validateDevice(this.switch.deviceName ?? '')) {
95
- await this.registerDevice(this.switch);
96
- this.bridgedDevices.set(this.switch.deviceName ?? '', this.switch);
97
- }
98
- else {
99
- this.switch = undefined;
100
- }
98
+ this.switch = await this.addDevice(this.switch);
101
99
  this.switch?.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
102
100
  this.log.info(`Command identify called identifyTime:${identifyTime}`);
103
101
  });
@@ -115,14 +113,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
115
113
  .createDefaultBridgedDeviceBasicInformationClusterServer('OnOff Mounted Switch', '0x298242164', 0xfff1, 'Matterbridge', 'Matterbridge OnOff Mounted Switch', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
116
114
  .createDefaultOnOffClusterServer()
117
115
  .createDefaultPowerSourceRechargeableBatteryClusterServer(70);
118
- this.setSelectDevice(this.mountedOnOffSwitch.serialNumber ?? '', this.mountedOnOffSwitch.deviceName ?? '', undefined, 'hub');
119
- if (this.validateDevice(this.mountedOnOffSwitch.deviceName ?? '')) {
120
- await this.registerDevice(this.mountedOnOffSwitch);
121
- this.bridgedDevices.set(this.mountedOnOffSwitch.deviceName ?? '', this.mountedOnOffSwitch);
122
- }
123
- else {
124
- this.mountedOnOffSwitch = undefined;
125
- }
116
+ this.mountedOnOffSwitch = await this.addDevice(this.mountedOnOffSwitch);
126
117
  this.mountedOnOffSwitch?.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
127
118
  this.mountedOnOffSwitch?.log.info(`Command identify called identifyTime:${identifyTime}`);
128
119
  });
@@ -142,14 +133,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
142
133
  .createDefaultLevelControlClusterServer()
143
134
  .createDefaultPowerSourceWiredClusterServer()
144
135
  .addRequiredClusterServers();
145
- this.setSelectDevice(this.mountedDimmerSwitch.serialNumber ?? '', this.mountedDimmerSwitch.deviceName ?? '', undefined, 'hub');
146
- if (this.validateDevice(this.mountedDimmerSwitch.deviceName ?? '')) {
147
- await this.registerDevice(this.mountedDimmerSwitch);
148
- this.bridgedDevices.set(this.mountedDimmerSwitch.deviceName ?? '', this.mountedDimmerSwitch);
149
- }
150
- else {
151
- this.mountedDimmerSwitch = undefined;
152
- }
136
+ this.mountedDimmerSwitch = await this.addDevice(this.mountedDimmerSwitch);
153
137
  this.mountedDimmerSwitch?.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
154
138
  this.mountedDimmerSwitch?.log.info(`Command identify called identifyTime:${identifyTime}`);
155
139
  });
@@ -175,14 +159,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
175
159
  .createDefaultBridgedDeviceBasicInformationClusterServer('Light (on/off)', '0x2342375564', 0xfff1, 'Matterbridge', 'Matterbridge Light on/off', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
176
160
  .createDefaultOnOffClusterServer()
177
161
  .createDefaultPowerSourceWiredClusterServer();
178
- this.setSelectDevice(this.lightOnOff.serialNumber ?? '', this.lightOnOff.deviceName ?? '', undefined, 'hub');
179
- if (this.validateDevice(this.lightOnOff.deviceName ?? '')) {
180
- await this.registerDevice(this.lightOnOff);
181
- this.bridgedDevices.set(this.lightOnOff.deviceName ?? '', this.lightOnOff);
182
- }
183
- else {
184
- this.lightOnOff = undefined;
185
- }
162
+ this.lightOnOff = await this.addDevice(this.lightOnOff);
186
163
  this.lightOnOff?.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
187
164
  this.lightOnOff?.log.info(`Command identify called identifyTime:${identifyTime}`);
188
165
  });
@@ -201,14 +178,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
201
178
  .createDefaultOnOffClusterServer()
202
179
  .createDefaultLevelControlClusterServer()
203
180
  .createDefaultPowerSourceReplaceableBatteryClusterServer(70, PowerSource.BatChargeLevel.Ok, 2990, '2 x AA', 2);
204
- this.setSelectDevice(this.dimmer.serialNumber ?? '', this.dimmer.deviceName ?? '', undefined, 'hub');
205
- if (this.validateDevice(this.dimmer.deviceName ?? '')) {
206
- await this.registerDevice(this.dimmer);
207
- this.bridgedDevices.set(this.dimmer.deviceName ?? '', this.dimmer);
208
- }
209
- else {
210
- this.dimmer = undefined;
211
- }
181
+ this.dimmer = await this.addDevice(this.dimmer);
212
182
  this.dimmer?.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
213
183
  this.dimmer?.log.info(`Command identify called identifyTime:${identifyTime}`);
214
184
  });
@@ -236,14 +206,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
236
206
  .createDefaultLevelControlClusterServer()
237
207
  .createDefaultColorControlClusterServer()
238
208
  .createDefaultPowerSourceReplaceableBatteryClusterServer(70);
239
- this.setSelectDevice(this.light.serialNumber ?? '', this.light.deviceName ?? '', undefined, 'hub');
240
- if (this.validateDevice(this.light.deviceName ?? '')) {
241
- await this.registerDevice(this.light);
242
- this.bridgedDevices.set(this.light.deviceName ?? '', this.light);
243
- }
244
- else {
245
- this.light = undefined;
246
- }
209
+ this.light = await this.addDevice(this.light);
247
210
  this.light?.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
248
211
  this.light?.log.info(`Command identify called identifyTime:${identifyTime}`);
249
212
  });
@@ -293,14 +256,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
293
256
  .createDefaultLevelControlClusterServer()
294
257
  .createHsColorControlClusterServer()
295
258
  .createDefaultPowerSourceWiredClusterServer();
296
- this.setSelectDevice(this.lightHS.serialNumber ?? '', this.lightHS.deviceName ?? '', undefined, 'hub');
297
- if (this.validateDevice(this.lightHS.deviceName ?? '')) {
298
- await this.registerDevice(this.lightHS);
299
- this.bridgedDevices.set(this.lightHS.deviceName ?? '', this.lightHS);
300
- }
301
- else {
302
- this.lightHS = undefined;
303
- }
259
+ this.lightHS = await this.addDevice(this.lightHS);
304
260
  this.lightHS?.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
305
261
  this.lightHS?.log.info(`Command identify called identifyTime:${identifyTime}`);
306
262
  });
@@ -345,14 +301,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
345
301
  .createDefaultLevelControlClusterServer()
346
302
  .createXyColorControlClusterServer()
347
303
  .createDefaultPowerSourceWiredClusterServer();
348
- this.setSelectDevice(this.lightXY.serialNumber ?? '', this.lightXY.deviceName ?? '', undefined, 'hub');
349
- if (this.validateDevice(this.lightXY.deviceName ?? '')) {
350
- await this.registerDevice(this.lightXY);
351
- this.bridgedDevices.set(this.lightXY.deviceName ?? '', this.lightXY);
352
- }
353
- else {
354
- this.lightXY = undefined;
355
- }
304
+ this.lightXY = await this.addDevice(this.lightXY);
356
305
  this.lightXY?.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
357
306
  this.lightXY?.log.info(`Command identify called identifyTime:${identifyTime}`);
358
307
  });
@@ -389,14 +338,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
389
338
  .createDefaultLevelControlClusterServer()
390
339
  .createCtColorControlClusterServer()
391
340
  .createDefaultPowerSourceReplaceableBatteryClusterServer(70);
392
- this.setSelectDevice(this.lightCT.serialNumber ?? '', this.lightCT.deviceName ?? '', undefined, 'hub');
393
- if (this.validateDevice(this.lightCT.deviceName ?? '')) {
394
- await this.registerDevice(this.lightCT);
395
- this.bridgedDevices.set(this.lightCT.deviceName ?? '', this.lightCT);
396
- }
397
- else {
398
- this.lightCT = undefined;
399
- }
341
+ this.lightCT = await this.addDevice(this.lightCT);
400
342
  this.lightCT?.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
401
343
  this.lightCT?.log.info(`Command identify called identifyTime:${identifyTime}`);
402
344
  });
@@ -426,14 +368,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
426
368
  .createDefaultBridgedDeviceBasicInformationClusterServer('Outlet', '0x29252164', 0xfff1, 'Matterbridge', 'Matterbridge Outlet', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
427
369
  .createDefaultOnOffClusterServer()
428
370
  .createDefaultPowerSourceWiredClusterServer();
429
- this.setSelectDevice(this.outlet.serialNumber ?? '', this.outlet.deviceName ?? '', undefined, 'hub');
430
- if (this.validateDevice(this.outlet.deviceName ?? '')) {
431
- await this.registerDevice(this.outlet);
432
- this.bridgedDevices.set(this.outlet.deviceName ?? '', this.outlet);
433
- }
434
- else {
435
- this.outlet = undefined;
436
- }
371
+ this.outlet = await this.addDevice(this.outlet);
437
372
  this.outlet?.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
438
373
  this.outlet?.log.info(`Command identify called identifyTime:${identifyTime}`);
439
374
  });
@@ -451,14 +386,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
451
386
  .createDefaultBridgedDeviceBasicInformationClusterServer('Cover lift', 'CL01020564', 0xfff1, 'Matterbridge', 'Matterbridge Cover', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
452
387
  .createDefaultWindowCoveringClusterServer()
453
388
  .createDefaultPowerSourceRechargeableBatteryClusterServer(86);
454
- this.setSelectDevice(this.coverLift.serialNumber ?? '', this.coverLift.deviceName ?? '', undefined, 'hub');
455
- if (this.validateDevice(this.coverLift.deviceName ?? '')) {
456
- await this.registerDevice(this.coverLift);
457
- this.bridgedDevices.set(this.coverLift.deviceName ?? '', this.coverLift);
458
- }
459
- else {
460
- this.coverLift = undefined;
461
- }
389
+ this.coverLift = await this.addDevice(this.coverLift);
462
390
  this.coverLift?.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
463
391
  this.coverLift?.log.info(`Command identify called identifyTime:${identifyTime}`);
464
392
  });
@@ -484,14 +412,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
484
412
  .createDefaultBridgedDeviceBasicInformationClusterServer('Cover lift and tilt', 'CLT01020554', 0xfff1, 'Matterbridge', 'Matterbridge Cover', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
485
413
  .createDefaultLiftTiltWindowCoveringClusterServer()
486
414
  .createDefaultPowerSourceRechargeableBatteryClusterServer(86);
487
- this.setSelectDevice(this.coverLiftTilt.serialNumber ?? '', this.coverLiftTilt.deviceName ?? '', undefined, 'hub');
488
- if (this.validateDevice(this.coverLiftTilt.deviceName ?? '')) {
489
- await this.registerDevice(this.coverLiftTilt);
490
- this.bridgedDevices.set(this.coverLiftTilt.deviceName ?? '', this.coverLiftTilt);
491
- }
492
- else {
493
- this.coverLiftTilt = undefined;
494
- }
415
+ this.coverLiftTilt = await this.addDevice(this.coverLiftTilt);
495
416
  this.coverLiftTilt?.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
496
417
  this.coverLiftTilt?.log.info(`Command identify called identifyTime:${identifyTime}`);
497
418
  });
@@ -521,14 +442,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
521
442
  .createDefaultBridgedDeviceBasicInformationClusterServer('Lock', '0x96352164', 0xfff1, 'Matterbridge', 'Matterbridge Lock', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
522
443
  .createDefaultDoorLockClusterServer()
523
444
  .createDefaultPowerSourceRechargeableBatteryClusterServer(30);
524
- this.setSelectDevice(this.lock.serialNumber ?? '', this.lock.deviceName ?? '', undefined, 'hub');
525
- if (this.validateDevice(this.lock.deviceName ?? '')) {
526
- await this.registerDevice(this.lock);
527
- this.bridgedDevices.set(this.lock.deviceName ?? '', this.lock);
528
- }
529
- else {
530
- this.lock = undefined;
531
- }
445
+ this.lock = await this.addDevice(this.lock);
532
446
  this.lock?.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
533
447
  this.lock?.log.info(`Command identify called identifyTime:${identifyTime}`);
534
448
  });
@@ -558,14 +472,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
558
472
  .addChildDeviceType('Humidity', humiditySensor)
559
473
  .createDefaultRelativeHumidityMeasurementClusterServer(50 * 100)
560
474
  .addRequiredClusterServers();
561
- this.setSelectDevice(this.thermoAuto.serialNumber ?? '', this.thermoAuto.deviceName ?? '', undefined, 'hub');
562
- if (this.validateDevice(this.thermoAuto.deviceName ?? '')) {
563
- await this.registerDevice(this.thermoAuto);
564
- this.bridgedDevices.set(this.thermoAuto.deviceName ?? '', this.thermoAuto);
565
- }
566
- else {
567
- this.thermoAuto = undefined;
568
- }
475
+ this.thermoAuto = await this.addDevice(this.thermoAuto);
569
476
  this.thermoAuto?.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
570
477
  this.thermoAuto?.log.info(`Command identify called identifyTime ${identifyTime}`);
571
478
  });
@@ -614,14 +521,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
614
521
  })
615
522
  .createDefaultIdentifyClusterServer()
616
523
  .createDefaultTemperatureMeasurementClusterServer(15 * 100);
617
- this.setSelectDevice(this.thermoHeat.serialNumber ?? '', this.thermoHeat.deviceName ?? '', undefined, 'hub');
618
- if (this.validateDevice(this.thermoHeat.deviceName ?? '')) {
619
- await this.registerDevice(this.thermoHeat);
620
- this.bridgedDevices.set(this.thermoHeat.deviceName ?? '', this.thermoHeat);
621
- }
622
- else {
623
- this.thermoHeat = undefined;
624
- }
524
+ this.thermoHeat = await this.addDevice(this.thermoHeat);
625
525
  this.thermoHeat?.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
626
526
  this.thermoHeat?.log.info(`Command identify called identifyTime ${identifyTime}`);
627
527
  });
@@ -641,14 +541,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
641
541
  .createDefaultBridgedDeviceBasicInformationClusterServer('Thermostat (Cool)', '0x96382164C', 0xfff1, 'Matterbridge', 'Matterbridge Thermostat', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
642
542
  .createDefaultCoolingThermostatClusterServer(20, 18, 5, 35)
643
543
  .createDefaultPowerSourceReplaceableBatteryClusterServer(40, PowerSource.BatChargeLevel.Ok, 5080, 'AA 1.5V', 4);
644
- this.setSelectDevice(this.thermoCool.serialNumber ?? '', this.thermoCool.deviceName ?? '', undefined, 'hub');
645
- if (this.validateDevice(this.thermoCool.deviceName ?? '')) {
646
- await this.registerDevice(this.thermoCool);
647
- this.bridgedDevices.set(this.thermoCool.deviceName ?? '', this.thermoCool);
648
- }
649
- else {
650
- this.thermoCool = undefined;
651
- }
544
+ this.thermoCool = await this.addDevice(this.thermoCool);
652
545
  this.thermoCool?.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
653
546
  this.thermoCool?.log.info(`Command identify called identifyTime ${identifyTime}`);
654
547
  });
@@ -671,14 +564,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
671
564
  .createDefaultPowerSourceWiredClusterServer()
672
565
  .createDefaultActivatedCarbonFilterMonitoringClusterServer()
673
566
  .createDefaultHepaFilterMonitoringClusterServer();
674
- this.setSelectDevice(this.airPurifier.serialNumber ?? '', this.airPurifier.deviceName ?? '', undefined, 'hub');
675
- if (this.validateDevice(this.airPurifier.deviceName ?? '')) {
676
- await this.registerDevice(this.airPurifier);
677
- this.bridgedDevices.set(this.airPurifier.deviceName ?? '', this.airPurifier);
678
- }
679
- else {
680
- this.airPurifier = undefined;
681
- }
567
+ this.airPurifier = await this.addDevice(this.airPurifier);
682
568
  this.airPurifier?.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
683
569
  this.airPurifier?.log.info(`Command identify called identifyTime:${identifyTime}`);
684
570
  });
@@ -725,14 +611,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
725
611
  .createDefaultRelativeHumidityMeasurementClusterServer(50 * 100)
726
612
  .createDefaultPowerSourceWiredClusterServer()
727
613
  .addRequiredClusterServers();
728
- this.setSelectDevice(this.airConditioner.serialNumber ?? '', this.airConditioner.deviceName ?? '', undefined, 'hub');
729
- if (this.validateDevice(this.airConditioner.deviceName ?? '')) {
730
- await this.registerDevice(this.airConditioner);
731
- this.bridgedDevices.set(this.airConditioner.deviceName ?? '', this.airConditioner);
732
- }
733
- else {
734
- this.airConditioner = undefined;
735
- }
614
+ this.airConditioner = await this.addDevice(this.airConditioner);
736
615
  this.airConditioner?.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
737
616
  this.airConditioner?.log.info(`Command identify called identifyTime:${identifyTime}`);
738
617
  });
@@ -757,14 +636,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
757
636
  .createLevelControlClusterServer()
758
637
  .createDefaultPumpConfigurationAndControlClusterServer()
759
638
  .createDefaultPowerSourceWiredClusterServer();
760
- this.setSelectDevice(this.pump.serialNumber ?? '', this.pump.deviceName ?? '', undefined, 'hub');
761
- if (this.validateDevice(this.pump.deviceName ?? '')) {
762
- await this.registerDevice(this.pump);
763
- this.bridgedDevices.set(this.pump.deviceName ?? '', this.pump);
764
- }
765
- else {
766
- this.pump = undefined;
767
- }
639
+ this.pump = await this.addDevice(this.pump);
768
640
  this.pump?.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
769
641
  this.pump?.log.info(`Command identify called identifyTime:${identifyTime}`);
770
642
  });
@@ -785,29 +657,16 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
785
657
  .createDefaultIdentifyClusterServer()
786
658
  .createDefaultValveConfigurationAndControlClusterServer()
787
659
  .createDefaultPowerSourceWiredClusterServer();
788
- this.setSelectDevice(this.valve.serialNumber ?? '', this.valve.deviceName ?? '', undefined, 'hub');
789
- if (this.validateDevice(this.valve.deviceName ?? '')) {
790
- await this.registerDevice(this.valve);
791
- this.bridgedDevices.set(this.valve.deviceName ?? '', this.valve);
792
- }
793
- else {
794
- this.valve = undefined;
795
- }
660
+ this.valve = await this.addDevice(this.valve);
796
661
  this.valve?.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
797
662
  this.valve?.log.info(`Command identify called identifyTime:${identifyTime}`);
798
663
  });
799
- this.fan = new MatterbridgeEndpoint([fanDevice, bridgedNode, powerSource], { uniqueStorageKey: 'Fan off low medium high auto' }, this.config.debug)
800
- .createDefaultBridgedDeviceBasicInformationClusterServer('Fan auto', 'serial_980545631228', 0xfff1, 'Matterbridge', 'Matterbridge Fan', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
664
+ this.fan = new MatterbridgeEndpoint([fanDevice, bridgedNode, powerSource], { uniqueStorageKey: 'Fan off low medium high' }, this.config.debug)
665
+ .createDefaultBridgedDeviceBasicInformationClusterServer('Fan', 'FNB_980545631228', 0xfff1, 'Matterbridge', 'Matterbridge Fan', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
801
666
  .createDefaultPowerSourceWiredClusterServer()
667
+ .createBaseFanControlClusterServer()
802
668
  .addRequiredClusterServers();
803
- this.setSelectDevice(this.fan.serialNumber ?? '', this.fan.deviceName ?? '', undefined, 'hub');
804
- if (this.validateDevice(this.fan.deviceName ?? '')) {
805
- await this.registerDevice(this.fan);
806
- this.bridgedDevices.set(this.fan.deviceName ?? '', this.fan);
807
- }
808
- else {
809
- this.fan = undefined;
810
- }
669
+ this.fan = await this.addDevice(this.fan);
811
670
  await this.fan?.subscribeAttribute(FanControl.Cluster.id, 'fanMode', (newValue, oldValue, context) => {
812
671
  this.fan?.log.info(`Fan mode changed from ${this.fanModeLookup[oldValue]} to ${this.fanModeLookup[newValue]} context: ${context.offline === true ? 'offline' : 'online'}`);
813
672
  if (context.offline === true)
@@ -844,89 +703,139 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
844
703
  if (isValidNumber(newValue, 0, 100))
845
704
  this.fan?.setAttribute(FanControl.Cluster.id, 'percentCurrent', newValue, this.fan?.log);
846
705
  }, this.fan.log);
706
+ this.fanauto = new MatterbridgeEndpoint([fanDevice, bridgedNode, powerSource], { uniqueStorageKey: 'Fan off low medium high auto' }, this.config.debug)
707
+ .createDefaultBridgedDeviceBasicInformationClusterServer('Fan auto', 'FNA_980545631228', 0xfff1, 'Matterbridge', 'Matterbridge Fan', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
708
+ .createDefaultPowerSourceWiredClusterServer()
709
+ .addRequiredClusterServers();
710
+ this.fanauto = await this.addDevice(this.fanauto);
711
+ await this.fanauto?.subscribeAttribute(FanControl.Cluster.id, 'fanMode', (newValue, oldValue, context) => {
712
+ this.fanauto?.log.info(`Fan mode changed from ${this.fanModeLookup[oldValue]} to ${this.fanModeLookup[newValue]} context: ${context.offline === true ? 'offline' : 'online'}`);
713
+ if (context.offline === true)
714
+ return;
715
+ if (newValue === FanControl.FanMode.Off) {
716
+ this.fanauto?.setAttribute(FanControl.Cluster.id, 'percentSetting', 0, this.fanauto?.log);
717
+ this.fanauto?.setAttribute(FanControl.Cluster.id, 'percentCurrent', 0, this.fanauto?.log);
718
+ }
719
+ else if (newValue === FanControl.FanMode.Low) {
720
+ this.fanauto?.setAttribute(FanControl.Cluster.id, 'percentSetting', 33, this.fanauto?.log);
721
+ this.fanauto?.setAttribute(FanControl.Cluster.id, 'percentCurrent', 33, this.fanauto?.log);
722
+ }
723
+ else if (newValue === FanControl.FanMode.Medium) {
724
+ this.fanauto?.setAttribute(FanControl.Cluster.id, 'percentSetting', 66, this.fanauto?.log);
725
+ this.fanauto?.setAttribute(FanControl.Cluster.id, 'percentCurrent', 66, this.fanauto?.log);
726
+ }
727
+ else if (newValue === FanControl.FanMode.High) {
728
+ this.fanauto?.setAttribute(FanControl.Cluster.id, 'percentSetting', 100, this.fanauto?.log);
729
+ this.fanauto?.setAttribute(FanControl.Cluster.id, 'percentCurrent', 100, this.fanauto?.log);
730
+ }
731
+ else if (newValue === FanControl.FanMode.On) {
732
+ this.fanauto?.setAttribute(FanControl.Cluster.id, 'percentSetting', 100, this.fanauto?.log);
733
+ this.fanauto?.setAttribute(FanControl.Cluster.id, 'percentCurrent', 100, this.fanauto?.log);
734
+ }
735
+ else if (newValue === FanControl.FanMode.Auto) {
736
+ this.fanauto?.setAttribute(FanControl.Cluster.id, 'percentSetting', 50, this.fanauto?.log);
737
+ this.fanauto?.setAttribute(FanControl.Cluster.id, 'percentCurrent', 50, this.fanauto?.log);
738
+ }
739
+ }, this.fanauto.log);
740
+ await this.fanauto?.subscribeAttribute(FanControl.Cluster.id, 'percentSetting', (newValue, oldValue, context) => {
741
+ this.fanauto?.log.info(`Percent setting changed from ${oldValue} to ${newValue} context: ${context.offline === true ? 'offline' : 'online'}`);
742
+ if (context.offline === true)
743
+ return;
744
+ if (isValidNumber(newValue, 0, 100))
745
+ this.fanauto?.setAttribute(FanControl.Cluster.id, 'percentCurrent', newValue, this.fanauto?.log);
746
+ }, this.fanauto.log);
747
+ this.fanComplete = new MatterbridgeEndpoint([fanDevice, bridgedNode, powerSource], { uniqueStorageKey: 'Fan complete' }, this.config.debug)
748
+ .createDefaultBridgedDeviceBasicInformationClusterServer('Fan complete', 'FNC_980995631228', 0xfff1, 'Matterbridge', 'Matterbridge Fan', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
749
+ .createDefaultPowerSourceWiredClusterServer()
750
+ .createCompleteFanControlClusterServer()
751
+ .addRequiredClusterServers();
752
+ this.fanComplete = await this.addDevice(this.fanComplete);
753
+ await this.fanComplete?.subscribeAttribute(FanControl.Cluster.id, 'fanMode', (newValue, oldValue, context) => {
754
+ this.fanComplete?.log.info(`Fan mode changed from ${this.fanModeLookup[oldValue]} to ${this.fanModeLookup[newValue]} context: ${context.offline === true ? 'offline' : 'online'}`);
755
+ if (context.offline === true)
756
+ return;
757
+ if (newValue === FanControl.FanMode.Off) {
758
+ this.fanComplete?.setAttribute(FanControl.Cluster.id, 'percentSetting', 0, this.fanComplete?.log);
759
+ this.fanComplete?.setAttribute(FanControl.Cluster.id, 'percentCurrent', 0, this.fanComplete?.log);
760
+ }
761
+ else if (newValue === FanControl.FanMode.Low) {
762
+ this.fanComplete?.setAttribute(FanControl.Cluster.id, 'percentSetting', 33, this.fanComplete?.log);
763
+ this.fanComplete?.setAttribute(FanControl.Cluster.id, 'percentCurrent', 33, this.fanComplete?.log);
764
+ }
765
+ else if (newValue === FanControl.FanMode.Medium) {
766
+ this.fanComplete?.setAttribute(FanControl.Cluster.id, 'percentSetting', 66, this.fanComplete?.log);
767
+ this.fanComplete?.setAttribute(FanControl.Cluster.id, 'percentCurrent', 66, this.fanComplete?.log);
768
+ }
769
+ else if (newValue === FanControl.FanMode.High) {
770
+ this.fanComplete?.setAttribute(FanControl.Cluster.id, 'percentSetting', 100, this.fanComplete?.log);
771
+ this.fanComplete?.setAttribute(FanControl.Cluster.id, 'percentCurrent', 100, this.fanComplete?.log);
772
+ }
773
+ else if (newValue === FanControl.FanMode.On) {
774
+ this.fanComplete?.setAttribute(FanControl.Cluster.id, 'percentSetting', 100, this.fanComplete?.log);
775
+ this.fanComplete?.setAttribute(FanControl.Cluster.id, 'percentCurrent', 100, this.fanComplete?.log);
776
+ }
777
+ else if (newValue === FanControl.FanMode.Auto) {
778
+ this.fanComplete?.setAttribute(FanControl.Cluster.id, 'percentSetting', 50, this.fanComplete?.log);
779
+ this.fanComplete?.setAttribute(FanControl.Cluster.id, 'percentCurrent', 50, this.fanComplete?.log);
780
+ }
781
+ }, this.fanComplete?.log);
782
+ await this.fanComplete?.subscribeAttribute(FanControl.Cluster.id, 'percentSetting', (newValue, oldValue, context) => {
783
+ this.fanComplete?.log.info(`Percent setting changed from ${oldValue} to ${newValue} context: ${context.offline === true ? 'offline' : 'online'}`);
784
+ if (context.offline === true)
785
+ return;
786
+ if (isValidNumber(newValue, 0, 100))
787
+ this.fanComplete?.setAttribute(FanControl.Cluster.id, 'percentCurrent', newValue, this.fanComplete?.log);
788
+ }, this.fanComplete?.log);
789
+ await this.fanComplete?.subscribeAttribute(FanControl.Cluster.id, 'rockSetting', (newValue, oldValue, context) => {
790
+ this.fanComplete?.log.info(`Rock setting changed from ${debugStringify(oldValue)} to ${debugStringify(newValue)} context: ${context.offline === true ? 'offline' : 'online'}`);
791
+ }, this.fanComplete?.log);
792
+ await this.fanComplete?.subscribeAttribute(FanControl.Cluster.id, 'windSetting', (newValue, oldValue, context) => {
793
+ this.fanComplete?.log.info(`Wind setting changed from ${debugStringify(oldValue)} to ${debugStringify(newValue)} context: ${context.offline === true ? 'offline' : 'online'}`);
794
+ }, this.fanComplete?.log);
795
+ await this.fanComplete?.subscribeAttribute(FanControl.Cluster.id, 'airflowDirection', (newValue, oldValue, context) => {
796
+ this.fanComplete?.log.info(`Airflow direction changed from ${this.fanDirectionLookup[oldValue]} to ${this.fanDirectionLookup[newValue]} context: ${context.offline === true ? 'offline' : 'online'}`);
797
+ }, this.fanComplete?.log);
847
798
  this.waterLeak = new MatterbridgeEndpoint([waterLeakDetector, bridgedNode, powerSource], { uniqueStorageKey: 'Water leak detector' }, this.config.debug)
848
799
  .createDefaultBridgedDeviceBasicInformationClusterServer('Water leak detector', 'serial_98745631222', 0xfff1, 'Matterbridge', 'Matterbridge WaterLeakDetector', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
849
800
  .createDefaultPowerSourceRechargeableBatteryClusterServer()
850
801
  .createDefaultBooleanStateClusterServer(false)
851
802
  .addRequiredClusterServers()
852
803
  .addOptionalClusterServers();
853
- this.setSelectDevice(this.waterLeak.serialNumber ?? '', this.waterLeak.deviceName ?? '', undefined, 'hub');
854
- if (this.validateDevice(this.waterLeak.deviceName ?? '')) {
855
- await this.registerDevice(this.waterLeak);
856
- this.bridgedDevices.set(this.waterLeak.deviceName ?? '', this.waterLeak);
857
- }
858
- else {
859
- this.waterLeak = undefined;
860
- }
804
+ this.waterLeak = await this.addDevice(this.waterLeak);
861
805
  this.waterFreeze = new MatterbridgeEndpoint([waterFreezeDetector, bridgedNode, powerSource], { uniqueStorageKey: 'Water freeze detector' }, this.config.debug)
862
806
  .createDefaultBridgedDeviceBasicInformationClusterServer('Water freeze detector', 'serial_98745631223', 0xfff1, 'Matterbridge', 'Matterbridge WaterFreezeDetector', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
863
807
  .createDefaultPowerSourceRechargeableBatteryClusterServer()
864
808
  .createDefaultBooleanStateClusterServer(false)
865
809
  .addRequiredClusterServers()
866
810
  .addOptionalClusterServers();
867
- this.setSelectDevice(this.waterFreeze.serialNumber ?? '', this.waterFreeze.deviceName ?? '', undefined, 'hub');
868
- if (this.validateDevice(this.waterFreeze.deviceName ?? '')) {
869
- await this.registerDevice(this.waterFreeze);
870
- this.bridgedDevices.set(this.waterFreeze.deviceName ?? '', this.waterFreeze);
871
- }
872
- else {
873
- this.waterFreeze = undefined;
874
- }
811
+ this.waterFreeze = await this.addDevice(this.waterFreeze);
875
812
  this.rain = new MatterbridgeEndpoint([rainSensor, bridgedNode, powerSource], { uniqueStorageKey: 'Rain sensor' }, this.config.debug)
876
813
  .createDefaultBridgedDeviceBasicInformationClusterServer('Rain sensor', 'serial_98745631224', 0xfff1, 'Matterbridge', 'Matterbridge RainSensor', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
877
814
  .createDefaultPowerSourceRechargeableBatteryClusterServer()
878
815
  .createDefaultIdentifyClusterServer()
879
816
  .createDefaultBooleanStateClusterServer(false)
880
817
  .createDefaultBooleanStateConfigurationClusterServer();
881
- this.setSelectDevice(this.rain.serialNumber ?? '', this.rain.deviceName ?? '', undefined, 'hub');
882
- if (this.validateDevice(this.rain.deviceName ?? '')) {
883
- await this.registerDevice(this.rain);
884
- this.bridgedDevices.set(this.rain.deviceName ?? '', this.rain);
885
- }
886
- else {
887
- this.rain = undefined;
888
- }
818
+ this.rain = await this.addDevice(this.rain);
889
819
  this.smokeCo = new MatterbridgeEndpoint([smokeCoAlarm, bridgedNode, powerSource], { uniqueStorageKey: 'SmokeCo alarm sensor' }, this.config.debug)
890
820
  .createDefaultBridgedDeviceBasicInformationClusterServer('SmokeCo alarm sensor', 'serial_94745631225', 0xfff1, 'Matterbridge', 'Matterbridge SmokeCoAlarm', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
891
821
  .createDefaultIdentifyClusterServer()
892
822
  .createDefaultSmokeCOAlarmClusterServer(SmokeCoAlarm.AlarmState.Normal, SmokeCoAlarm.AlarmState.Normal)
893
823
  .createDefaultPowerSourceReplaceableBatteryClusterServer()
894
824
  .createDefaultCarbonMonoxideConcentrationMeasurementClusterServer(100);
895
- this.setSelectDevice(this.smokeCo.serialNumber ?? '', this.smokeCo.deviceName ?? '', undefined, 'hub');
896
- if (this.validateDevice(this.smokeCo.deviceName ?? '')) {
897
- await this.registerDevice(this.smokeCo);
898
- this.bridgedDevices.set(this.smokeCo.deviceName ?? '', this.smokeCo);
899
- }
900
- else {
901
- this.smokeCo = undefined;
902
- }
825
+ this.smokeCo = await this.addDevice(this.smokeCo);
903
826
  this.smokeOnly = new MatterbridgeEndpoint([smokeCoAlarm, bridgedNode, powerSource], { uniqueStorageKey: 'Smoke alarm sensor' }, this.config.debug)
904
827
  .createDefaultBridgedDeviceBasicInformationClusterServer('Smoke alarm sensor', 'serial_94755661225', 0xfff1, 'Matterbridge', 'Matterbridge SmokeCoAlarm', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
905
828
  .createDefaultIdentifyClusterServer()
906
829
  .createSmokeOnlySmokeCOAlarmClusterServer(SmokeCoAlarm.AlarmState.Normal)
907
830
  .createDefaultPowerSourceReplaceableBatteryClusterServer();
908
- this.setSelectDevice(this.smokeOnly.serialNumber ?? '', this.smokeOnly.deviceName ?? '', undefined, 'hub');
909
- if (this.validateDevice(this.smokeOnly.deviceName ?? '')) {
910
- await this.registerDevice(this.smokeOnly);
911
- this.bridgedDevices.set(this.smokeOnly.deviceName ?? '', this.smokeOnly);
912
- }
913
- else {
914
- this.smokeOnly = undefined;
915
- }
831
+ this.smokeOnly = await this.addDevice(this.smokeOnly);
916
832
  this.coOnly = new MatterbridgeEndpoint([smokeCoAlarm, bridgedNode, powerSource], { uniqueStorageKey: 'Co alarm sensor' }, this.config.debug)
917
833
  .createDefaultBridgedDeviceBasicInformationClusterServer('Co alarm sensor', 'serial_947456317488', 0xfff1, 'Matterbridge', 'Matterbridge SmokeCoAlarm', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
918
834
  .createDefaultIdentifyClusterServer()
919
835
  .createCoOnlySmokeCOAlarmClusterServer(SmokeCoAlarm.AlarmState.Normal)
920
836
  .createDefaultPowerSourceReplaceableBatteryClusterServer()
921
837
  .createDefaultCarbonMonoxideConcentrationMeasurementClusterServer(100);
922
- this.setSelectDevice(this.coOnly.serialNumber ?? '', this.coOnly.deviceName ?? '', undefined, 'hub');
923
- if (this.validateDevice(this.coOnly.deviceName ?? '')) {
924
- await this.registerDevice(this.coOnly);
925
- this.bridgedDevices.set(this.coOnly.deviceName ?? '', this.coOnly);
926
- }
927
- else {
928
- this.coOnly = undefined;
929
- }
838
+ this.coOnly = await this.addDevice(this.coOnly);
930
839
  this.airQuality = new MatterbridgeEndpoint([airQualitySensor, bridgedNode, powerSource], { uniqueStorageKey: 'Air quality sensor' }, this.config.debug)
931
840
  .createDefaultBridgedDeviceBasicInformationClusterServer('Air quality sensor', 'serial_987484318322', 0xfff1, 'Matterbridge', 'Matterbridge Air Quality Sensor', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
932
841
  .createDefaultPowerSourceReplaceableBatteryClusterServer(50, PowerSource.BatChargeLevel.Warning, 2900, 'CR2450', 1)
@@ -942,14 +851,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
942
851
  .createDefaultPm10ConcentrationMeasurementClusterServer(100)
943
852
  .createDefaultRadonConcentrationMeasurementClusterServer(100)
944
853
  .createDefaultTvocMeasurementClusterServer(100);
945
- this.setSelectDevice(this.airQuality.serialNumber ?? '', this.airQuality.deviceName ?? '', undefined, 'hub');
946
- if (this.validateDevice(this.airQuality.deviceName ?? '')) {
947
- await this.registerDevice(this.airQuality);
948
- this.bridgedDevices.set(this.airQuality.deviceName ?? '', this.airQuality);
949
- }
950
- else {
951
- this.airQuality = undefined;
952
- }
854
+ this.airQuality = await this.addDevice(this.airQuality);
953
855
  this.momentarySwitch = new MatterbridgeEndpoint([bridgedNode, powerSource], { uniqueStorageKey: 'Momentary switch composed' }, this.config.debug)
954
856
  .createDefaultBridgedDeviceBasicInformationClusterServer('Momentary switch (Top-1 Middle-2 Bottom-3)', 'serial_947942331225', 0xfff1, 'Matterbridge', 'Matterbridge MomentarySwitch', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
955
857
  .createDefaultIdentifyClusterServer()
@@ -981,28 +883,14 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
981
883
  })
982
884
  .createDefaultIdentifyClusterServer()
983
885
  .createDefaultSwitchClusterServer();
984
- this.setSelectDevice(this.momentarySwitch.serialNumber ?? '', this.momentarySwitch.deviceName ?? '', undefined, 'hub');
985
- if (this.validateDevice(this.momentarySwitch.deviceName ?? '')) {
986
- await this.registerDevice(this.momentarySwitch);
987
- this.bridgedDevices.set(this.momentarySwitch.deviceName ?? '', this.momentarySwitch);
988
- }
989
- else {
990
- this.momentarySwitch = undefined;
991
- }
886
+ this.momentarySwitch = await this.addDevice(this.momentarySwitch);
992
887
  this.latchingSwitch = new MatterbridgeEndpoint([genericSwitch, bridgedNode, powerSource], { uniqueStorageKey: 'Latching switch' }, this.config.debug)
993
888
  .createDefaultBridgedDeviceBasicInformationClusterServer('Latching switch', 'serial_947442331225', 0xfff1, 'Matterbridge', 'Matterbridge LatchingSwitch', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
994
889
  .createDefaultIdentifyClusterServer()
995
890
  .createDefaultLatchingSwitchClusterServer()
996
891
  .createDefaultPowerSourceReplaceableBatteryClusterServer(10, PowerSource.BatChargeLevel.Critical, 2850, 'CR2032', 1);
997
- this.setSelectDevice(this.latchingSwitch.serialNumber ?? '', this.latchingSwitch.deviceName ?? '', undefined, 'hub');
998
- if (this.validateDevice(this.latchingSwitch.deviceName ?? '')) {
999
- await this.registerDevice(this.latchingSwitch);
1000
- this.bridgedDevices.set(this.latchingSwitch.deviceName ?? '', this.latchingSwitch);
1001
- }
1002
- else {
1003
- this.latchingSwitch = undefined;
1004
- }
1005
- const robot = new RoboticVacuumCleaner('Robot Vacuum', 'RVC1238777820', this.config.enableServerRvc === true ? 'server' : undefined, 1, [
892
+ this.latchingSwitch = await this.addDevice(this.latchingSwitch);
893
+ this.roboticVacuum = new RoboticVacuumCleaner('Robot Vacuum', 'RVC1238777820', this.config.enableServerRvc === true ? 'server' : undefined, 1, [
1006
894
  { label: 'Idle', mode: 1, modeTags: [{ value: RvcRunMode.ModeTag.Idle }] },
1007
895
  { label: 'Cleaning', mode: 2, modeTags: [{ value: RvcRunMode.ModeTag.Cleaning }] },
1008
896
  { label: 'Mapping', mode: 3, modeTags: [{ value: RvcRunMode.ModeTag.Mapping }] },
@@ -1053,96 +941,40 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
1053
941
  if (this.config.enableServerRvc === true) {
1054
942
  this.log.notice('RVC is in server mode');
1055
943
  }
1056
- this.setSelectDevice(robot.serialNumber ?? '', robot.deviceName ?? '', undefined, 'hub');
1057
- if (this.validateDevice(robot.deviceName ?? '')) {
1058
- await this.registerDevice(robot);
1059
- this.bridgedDevices.set(robot.deviceName ?? '', robot);
1060
- }
944
+ this.roboticVacuum = await this.addDevice(this.roboticVacuum);
1061
945
  this.waterHeater = new WaterHeater('Water Heater', 'WH3456177820', 50, 60, 20, 80, undefined, 85, 220_000, 1_000, 220_000, 12_000_000, 500_000, 3_000_000);
1062
- this.setSelectDevice(this.waterHeater.serialNumber ?? '', this.waterHeater.deviceName ?? '', undefined, 'hub');
1063
- if (this.validateDevice(this.waterHeater.deviceName ?? '')) {
1064
- await this.registerDevice(this.waterHeater);
1065
- this.bridgedDevices.set(this.waterHeater.deviceName ?? '', this.waterHeater);
1066
- }
946
+ this.waterHeater = await this.addDevice(this.waterHeater);
1067
947
  this.evse = new Evse('Evse', 'EV3456127820', 1, [
1068
948
  { label: 'On demand', mode: 1, modeTags: [{ value: EnergyEvseMode.ModeTag.Manual }] },
1069
949
  { label: 'Scheduled', mode: 2, modeTags: [{ value: EnergyEvseMode.ModeTag.TimeOfUse }] },
1070
950
  { label: 'Solar Charging', mode: 3, modeTags: [{ value: EnergyEvseMode.ModeTag.SolarCharging }] },
1071
951
  { label: 'Solar Charging Scheduled', mode: 4, modeTags: [{ value: EnergyEvseMode.ModeTag.SolarCharging }, { value: EnergyEvseMode.ModeTag.TimeOfUse }] },
1072
952
  ], EnergyEvse.State.PluggedInCharging, EnergyEvse.SupplyState.ChargingEnabled, EnergyEvse.FaultState.NoError, 220_000, 10_000, 2_200_000, 1_000_000, 500_000, 32_000_000);
1073
- this.setSelectDevice(this.evse.serialNumber ?? '', this.evse.deviceName ?? '', undefined, 'hub');
1074
- if (this.validateDevice(this.evse.deviceName ?? '')) {
1075
- await this.registerDevice(this.evse);
1076
- this.bridgedDevices.set(this.evse.deviceName ?? '', this.evse);
1077
- }
953
+ this.evse = await this.addDevice(this.evse);
1078
954
  this.solarPower = new SolarPower('Solar Power', 'SP3456127821', 220_000, 10_000, 2200_000, 2_200_000, -10_000_000, 500_000);
1079
- this.setSelectDevice(this.solarPower.serialNumber ?? '', this.solarPower.deviceName ?? '', undefined, 'hub');
1080
- if (this.validateDevice(this.solarPower.deviceName ?? '')) {
1081
- await this.registerDevice(this.solarPower);
1082
- this.bridgedDevices.set(this.solarPower.deviceName ?? '', this.solarPower);
1083
- }
955
+ this.solarPower = await this.addDevice(this.solarPower);
1084
956
  this.batteryStorage = new BatteryStorage('Battery Storage', 'BS3456127822', 75, PowerSource.BatChargeLevel.Ok, 220_000, 10_000, 2_200_000, 1_000_000, 2_000_000, -2_000_000, 3_000_000);
1085
- this.setSelectDevice(this.batteryStorage.serialNumber ?? '', this.batteryStorage.deviceName ?? '', undefined, 'hub');
1086
- if (this.validateDevice(this.batteryStorage.deviceName ?? '')) {
1087
- await this.registerDevice(this.batteryStorage);
1088
- this.bridgedDevices.set(this.batteryStorage.deviceName ?? '', this.batteryStorage);
1089
- }
957
+ this.batteryStorage = await this.addDevice(this.batteryStorage);
1090
958
  this.heatPump = new HeatPump('Heat Pump', 'HP1234567890', 220_000, 10_000, 2_200_000, 1_000_000, 500_000, 3_000_000);
1091
- this.setSelectDevice(this.heatPump.serialNumber ?? '', this.heatPump.deviceName ?? '', undefined, 'hub');
1092
- if (this.validateDevice(this.heatPump.deviceName ?? '')) {
1093
- await this.registerDevice(this.heatPump);
1094
- this.bridgedDevices.set(this.heatPump.deviceName ?? '', this.heatPump);
1095
- }
959
+ this.heatPump = await this.addDevice(this.heatPump);
1096
960
  this.laundryWasher = new LaundryWasher('Laundry Washer', 'LW1234567890');
1097
- this.setSelectDevice(this.laundryWasher.serialNumber ?? '', this.laundryWasher.deviceName ?? '', undefined, 'hub');
1098
- if (this.validateDevice(this.laundryWasher.deviceName ?? '')) {
1099
- await this.registerDevice(this.laundryWasher);
1100
- this.bridgedDevices.set(this.laundryWasher.deviceName ?? '', this.laundryWasher);
1101
- }
961
+ this.laundryWasher = await this.addDevice(this.laundryWasher);
1102
962
  this.laundryDryer = new LaundryDryer('Laundry Dryer', 'LDW1235227890');
1103
- this.setSelectDevice(this.laundryDryer.serialNumber ?? '', this.laundryDryer.deviceName ?? '', undefined, 'hub');
1104
- if (this.validateDevice(this.laundryDryer.deviceName ?? '')) {
1105
- await this.registerDevice(this.laundryDryer);
1106
- this.bridgedDevices.set(this.laundryDryer.deviceName ?? '', this.laundryDryer);
1107
- }
963
+ this.laundryDryer = await this.addDevice(this.laundryDryer);
1108
964
  this.dishwasher = new Dishwasher('Dishwasher', 'DW1234567890');
1109
- this.setSelectDevice(this.dishwasher.serialNumber ?? '', this.dishwasher.deviceName ?? '', undefined, 'hub');
1110
- if (this.validateDevice(this.dishwasher.deviceName ?? '')) {
1111
- await this.registerDevice(this.dishwasher);
1112
- this.bridgedDevices.set(this.dishwasher.deviceName ?? '', this.dishwasher);
1113
- }
965
+ this.dishwasher = await this.addDevice(this.dishwasher);
1114
966
  this.extractorHood = new ExtractorHood('Extractor Hood', 'EH1234567893');
1115
- this.setSelectDevice(this.extractorHood.serialNumber ?? '', this.extractorHood.deviceName ?? '', undefined, 'hub');
1116
- if (this.validateDevice(this.extractorHood.deviceName ?? '')) {
1117
- await this.registerDevice(this.extractorHood);
1118
- this.bridgedDevices.set(this.extractorHood.deviceName ?? '', this.extractorHood);
1119
- }
967
+ this.extractorHood = await this.addDevice(this.extractorHood);
1120
968
  const refrigeratorDevice = new Appliances(refrigerator, 'Refrigerator', 'RE9987654322');
1121
969
  refrigeratorDevice.addFixedLabel('composed', 'Refrigerator');
1122
- this.setSelectDevice(refrigeratorDevice.serialNumber ?? '', refrigeratorDevice.deviceName ?? '', undefined, 'hub');
1123
- if (this.validateDevice(refrigeratorDevice.deviceName ?? '')) {
1124
- await this.registerDevice(refrigeratorDevice);
1125
- this.bridgedDevices.set(refrigeratorDevice.deviceName ?? '', refrigeratorDevice);
1126
- }
970
+ await this.addDevice(refrigeratorDevice);
1127
971
  const ovenDevice = new Appliances(oven, 'Oven', 'OV1298867891');
1128
972
  ovenDevice.addFixedLabel('composed', 'Oven');
1129
- this.setSelectDevice(ovenDevice.serialNumber ?? '', ovenDevice.deviceName ?? '', undefined, 'hub');
1130
- if (this.validateDevice(ovenDevice.deviceName ?? '')) {
1131
- await this.registerDevice(ovenDevice);
1132
- this.bridgedDevices.set(ovenDevice.deviceName ?? '', ovenDevice);
1133
- }
973
+ await this.addDevice(ovenDevice);
1134
974
  const microwaveOvenDevice = new Appliances(microwaveOven, 'Microwave Oven', 'MO1234567892');
1135
- this.setSelectDevice(microwaveOvenDevice.serialNumber ?? '', microwaveOvenDevice.deviceName ?? '', undefined, 'hub');
1136
- if (this.validateDevice(microwaveOvenDevice.deviceName ?? '')) {
1137
- await this.registerDevice(microwaveOvenDevice);
1138
- this.bridgedDevices.set(microwaveOvenDevice.deviceName ?? '', microwaveOvenDevice);
1139
- }
975
+ await this.addDevice(microwaveOvenDevice);
1140
976
  const cooktopDevice = new Appliances(cooktop, 'Cooktop', 'CT1255887894');
1141
- this.setSelectDevice(cooktopDevice.serialNumber ?? '', cooktopDevice.deviceName ?? '', undefined, 'hub');
1142
- if (this.validateDevice(cooktopDevice.deviceName ?? '')) {
1143
- await this.registerDevice(cooktopDevice);
1144
- this.bridgedDevices.set(cooktopDevice.deviceName ?? '', cooktopDevice);
1145
- }
977
+ await this.addDevice(cooktopDevice);
1146
978
  }
1147
979
  async onConfigure() {
1148
980
  await super.onConfigure();
@@ -1266,7 +1098,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
1266
1098
  const status = this.lock?.getAttribute(DoorLock.Cluster.id, 'lockState', this.lock.log);
1267
1099
  if (isValidNumber(status, DoorLock.LockState.Locked, DoorLock.LockState.Unlocked)) {
1268
1100
  await this.lock?.setAttribute(DoorLock.Cluster.id, 'lockState', status === DoorLock.LockState.Locked ? DoorLock.LockState.Unlocked : DoorLock.LockState.Locked, this.lock.log);
1269
- this.lock?.log.info(`Set lock lockState to ${status === DoorLock.LockState.Locked ? 'Unlocked' : 'Locked'}`);
1101
+ this.lock?.log.info(`Set lock lockState to ${status === DoorLock.LockState.Locked ? 'Locked' : 'Unlocked'}`);
1270
1102
  }
1271
1103
  }, 60 * 1000 + 500);
1272
1104
  }
@@ -1318,19 +1150,35 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
1318
1150
  }
1319
1151
  }, 60 * 1000 + 550);
1320
1152
  }
1321
- this.fan?.log.info('Set fan initial fanMode to Auto, percentCurrent and percentSetting to 50');
1322
- await this.fan?.setAttribute(FanControl.Cluster.id, 'fanMode', FanControl.FanMode.Auto, this.fan.log);
1323
- await this.fan?.setAttribute(FanControl.Cluster.id, 'percentCurrent', 50, this.fan.log);
1324
- await this.fan?.setAttribute(FanControl.Cluster.id, 'percentSetting', 50, this.fan.log);
1153
+ this.fan?.log.info('Set fan initial fanMode to Off, percentCurrent and percentSetting to 0');
1154
+ await this.fan?.setAttribute(FanControl.Cluster.id, 'fanMode', FanControl.FanMode.Off, this.fan.log);
1155
+ await this.fan?.setAttribute(FanControl.Cluster.id, 'percentCurrent', 0, this.fan.log);
1156
+ await this.fan?.setAttribute(FanControl.Cluster.id, 'percentSetting', 0, this.fan.log);
1157
+ await this.fanauto?.setAttribute(FanControl.Cluster.id, 'fanMode', FanControl.FanMode.Auto, this.fanauto.log);
1158
+ await this.fanauto?.setAttribute(FanControl.Cluster.id, 'percentCurrent', 0, this.fanauto.log);
1159
+ await this.fanauto?.setAttribute(FanControl.Cluster.id, 'percentSetting', 0, this.fanauto.log);
1160
+ await this.fanComplete?.setAttribute(FanControl.Cluster.id, 'fanMode', FanControl.FanMode.Auto, this.fanComplete.log);
1161
+ await this.fanComplete?.setAttribute(FanControl.Cluster.id, 'percentCurrent', 0, this.fanComplete.log);
1162
+ await this.fanComplete?.setAttribute(FanControl.Cluster.id, 'percentSetting', 0, this.fanComplete.log);
1325
1163
  if (this.config.useInterval) {
1326
1164
  this.fanInterval = setInterval(async () => {
1327
- const mode = this.fan?.getAttribute(FanControl.Cluster.id, 'fanMode', this.fan.log);
1165
+ let mode = this.fan?.getAttribute(FanControl.Cluster.id, 'fanMode', this.fan.log);
1328
1166
  let value = this.fan?.getAttribute(FanControl.Cluster.id, 'percentCurrent', this.fan.log);
1167
+ mode = this.fanauto?.getAttribute(FanControl.Cluster.id, 'fanMode', this.fanauto.log);
1168
+ value = this.fanauto?.getAttribute(FanControl.Cluster.id, 'percentCurrent', this.fanauto.log);
1329
1169
  if (isValidNumber(mode, FanControl.FanMode.Off, FanControl.FanMode.Auto) && mode === FanControl.FanMode.Auto && isValidNumber(value, 0, 100)) {
1330
1170
  value = value + 10 >= 100 ? 0 : value + 10;
1331
- await this.fan?.setAttribute(FanControl.Cluster.id, 'percentCurrent', value, this.fan.log);
1332
- await this.fan?.setAttribute(FanControl.Cluster.id, 'percentSetting', value, this.fan.log);
1333
- this.fan?.log.info(`Set fan percentCurrent and percentSetting to ${value}`);
1171
+ await this.fanauto?.setAttribute(FanControl.Cluster.id, 'percentCurrent', value, this.fanauto.log);
1172
+ await this.fanauto?.setAttribute(FanControl.Cluster.id, 'percentSetting', value, this.fanauto.log);
1173
+ this.fanauto?.log.info(`Set fan percentCurrent and percentSetting to ${value}`);
1174
+ }
1175
+ mode = this.fanComplete?.getAttribute(FanControl.Cluster.id, 'fanMode', this.fanComplete.log);
1176
+ value = this.fanComplete?.getAttribute(FanControl.Cluster.id, 'percentCurrent', this.fanComplete.log);
1177
+ if (isValidNumber(mode, FanControl.FanMode.Off, FanControl.FanMode.Auto) && mode === FanControl.FanMode.Auto && isValidNumber(value, 0, 100)) {
1178
+ value = value + 10 >= 100 ? 0 : value + 10;
1179
+ await this.fanComplete?.setAttribute(FanControl.Cluster.id, 'percentCurrent', value, this.fanComplete.log);
1180
+ await this.fanComplete?.setAttribute(FanControl.Cluster.id, 'percentSetting', value, this.fanComplete.log);
1181
+ this.fanComplete?.log.info(`Set fan percentCurrent and percentSetting to ${value}`);
1334
1182
  }
1335
1183
  }, 60 * 1000 + 700);
1336
1184
  }
@@ -1387,18 +1235,16 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
1387
1235
  await this.airQuality?.setAttribute(AirQuality.Cluster.id, 'airQuality', AirQuality.AirQualityEnum.Good, this.airQuality.log);
1388
1236
  await this.airQuality?.setAttribute(TemperatureMeasurement.Cluster.id, 'measuredValue', 2150, this.airQuality.log);
1389
1237
  await this.airQuality?.setAttribute(RelativeHumidityMeasurement.Cluster.id, 'measuredValue', 5500, this.airQuality.log);
1390
- if (this.config.enableConcentrationMeasurements === true) {
1391
- await this.airQuality?.setAttribute(CarbonMonoxideConcentrationMeasurement.Cluster.id, 'measuredValue', 10, this.airQuality.log);
1392
- await this.airQuality?.setAttribute(CarbonDioxideConcentrationMeasurement.Cluster.id, 'measuredValue', 400, this.airQuality.log);
1393
- await this.airQuality?.setAttribute(NitrogenDioxideConcentrationMeasurement.Cluster.id, 'measuredValue', 1, this.airQuality.log);
1394
- await this.airQuality?.setAttribute(OzoneConcentrationMeasurement.Cluster.id, 'measuredValue', 1, this.airQuality.log);
1395
- await this.airQuality?.setAttribute(FormaldehydeConcentrationMeasurement.Cluster.id, 'measuredValue', 1, this.airQuality.log);
1396
- await this.airQuality?.setAttribute(Pm1ConcentrationMeasurement.Cluster.id, 'measuredValue', 100, this.airQuality.log);
1397
- await this.airQuality?.setAttribute(Pm25ConcentrationMeasurement.Cluster.id, 'measuredValue', 100, this.airQuality.log);
1398
- await this.airQuality?.setAttribute(Pm10ConcentrationMeasurement.Cluster.id, 'measuredValue', 100, this.airQuality.log);
1399
- await this.airQuality?.setAttribute(RadonConcentrationMeasurement.Cluster.id, 'measuredValue', 100, this.airQuality.log);
1400
- await this.airQuality?.setAttribute(TotalVolatileOrganicCompoundsConcentrationMeasurement.Cluster.id, 'measuredValue', 100, this.airQuality.log);
1401
- }
1238
+ await this.airQuality?.setAttribute(CarbonMonoxideConcentrationMeasurement.Cluster.id, 'measuredValue', 10, this.airQuality.log);
1239
+ await this.airQuality?.setAttribute(CarbonDioxideConcentrationMeasurement.Cluster.id, 'measuredValue', 400, this.airQuality.log);
1240
+ await this.airQuality?.setAttribute(NitrogenDioxideConcentrationMeasurement.Cluster.id, 'measuredValue', 1, this.airQuality.log);
1241
+ await this.airQuality?.setAttribute(OzoneConcentrationMeasurement.Cluster.id, 'measuredValue', 1, this.airQuality.log);
1242
+ await this.airQuality?.setAttribute(FormaldehydeConcentrationMeasurement.Cluster.id, 'measuredValue', 1, this.airQuality.log);
1243
+ await this.airQuality?.setAttribute(Pm1ConcentrationMeasurement.Cluster.id, 'measuredValue', 100, this.airQuality.log);
1244
+ await this.airQuality?.setAttribute(Pm25ConcentrationMeasurement.Cluster.id, 'measuredValue', 100, this.airQuality.log);
1245
+ await this.airQuality?.setAttribute(Pm10ConcentrationMeasurement.Cluster.id, 'measuredValue', 100, this.airQuality.log);
1246
+ await this.airQuality?.setAttribute(RadonConcentrationMeasurement.Cluster.id, 'measuredValue', 100, this.airQuality.log);
1247
+ await this.airQuality?.setAttribute(TotalVolatileOrganicCompoundsConcentrationMeasurement.Cluster.id, 'measuredValue', 100, this.airQuality.log);
1402
1248
  if (this.config.useInterval) {
1403
1249
  this.airQualityInterval = setInterval(async () => {
1404
1250
  let value = this.airQuality?.getAttribute(AirQuality.Cluster.id, 'airQuality', this.airQuality?.log);
@@ -1479,4 +1325,17 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
1479
1325
  if (this.config.unregisterOnShutdown === true)
1480
1326
  await this.unregisterAllDevices(500);
1481
1327
  }
1328
+ async addDevice(device) {
1329
+ if (!device.serialNumber || !device.deviceName)
1330
+ return;
1331
+ this.setSelectDevice(device.serialNumber, device.deviceName, undefined, 'hub');
1332
+ if (this.validateDevice(device.deviceName)) {
1333
+ await this.registerDevice(device);
1334
+ this.bridgedDevices.set(device.deviceName, device);
1335
+ return device;
1336
+ }
1337
+ else {
1338
+ return undefined;
1339
+ }
1340
+ }
1482
1341
  }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "matterbridge-example-dynamic-platform",
3
- "version": "1.3.4-dev-20250720-e338589",
3
+ "version": "1.3.5-dev-20250722-a63fdf7",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "matterbridge-example-dynamic-platform",
9
- "version": "1.3.4-dev-20250720-e338589",
9
+ "version": "1.3.5-dev-20250722-a63fdf7",
10
10
  "license": "Apache-2.0",
11
11
  "dependencies": {
12
12
  "node-ansi-logger": "3.1.1",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "matterbridge-example-dynamic-platform",
3
- "version": "1.3.4-dev-20250720-e338589",
3
+ "version": "1.3.5-dev-20250722-a63fdf7",
4
4
  "description": "Matterbridge dynamic plugin",
5
5
  "author": "https://github.com/Luligu",
6
6
  "license": "Apache-2.0",