@homebridge-plugins/homebridge-smarthq 0.5.0-beta.32 → 0.5.0-beta.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/devices/airConditioner.d.ts.map +1 -1
- package/dist/devices/airConditioner.js +1 -0
- package/dist/devices/airConditioner.js.map +1 -1
- package/dist/devices/clothesDryer.d.ts.map +1 -1
- package/dist/devices/clothesDryer.js +1 -0
- package/dist/devices/clothesDryer.js.map +1 -1
- package/dist/devices/clothesWasher.d.ts.map +1 -1
- package/dist/devices/clothesWasher.js +1 -0
- package/dist/devices/clothesWasher.js.map +1 -1
- package/dist/devices/device.d.ts +1 -0
- package/dist/devices/device.d.ts.map +1 -1
- package/dist/devices/device.js +3 -2
- package/dist/devices/device.js.map +1 -1
- package/dist/devices/dishwasher.d.ts.map +1 -1
- package/dist/devices/dishwasher.js +1 -0
- package/dist/devices/dishwasher.js.map +1 -1
- package/dist/devices/hood.d.ts.map +1 -1
- package/dist/devices/hood.js +1 -0
- package/dist/devices/hood.js.map +1 -1
- package/dist/devices/microwave.d.ts.map +1 -1
- package/dist/devices/microwave.js +1 -0
- package/dist/devices/microwave.js.map +1 -1
- package/dist/devices/oven.d.ts.map +1 -1
- package/dist/devices/oven.js +1 -0
- package/dist/devices/oven.js.map +1 -1
- package/dist/devices/refrigerator.d.ts.map +1 -1
- package/dist/devices/refrigerator.js +1 -0
- package/dist/devices/refrigerator.js.map +1 -1
- package/dist/devices/waterHeater.d.ts.map +1 -1
- package/dist/devices/waterHeater.js +1 -0
- package/dist/devices/waterHeater.js.map +1 -1
- package/dist/platform.d.ts +7 -0
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +418 -193
- package/dist/platform.js.map +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/SmartHQPlatform.html +13 -10
- package/docs/interfaces/DeviceOptions.html +2 -2
- package/docs/interfaces/SmartHQPlatformConfig.html +2 -2
- package/docs/interfaces/SmartHqContext.html +2 -2
- package/docs/interfaces/SmartHqERDResponse.html +2 -2
- package/docs/interfaces/credentials.html +2 -2
- package/docs/interfaces/devicesConfig.html +2 -2
- package/docs/interfaces/options.html +2 -2
- package/docs/variables/API_URL.html +1 -1
- package/docs/variables/ERD_CODES.html +1 -1
- package/docs/variables/ERD_TYPES.html +1 -1
- package/docs/variables/KEEPALIVE_TIMEOUT.html +1 -1
- package/docs/variables/LOGIN_URL.html +1 -1
- package/docs/variables/OAUTH2_CLIENT_ID.html +1 -1
- package/docs/variables/OAUTH2_CLIENT_SECRET.html +1 -1
- package/docs/variables/OAUTH2_REDIRECT_URI.html +1 -1
- package/docs/variables/PLATFORM_NAME.html +1 -1
- package/docs/variables/PLUGIN_NAME.html +1 -1
- package/docs/variables/SECURE_URL.html +1 -1
- package/docs/variables/default.html +1 -1
- package/package.json +1 -1
package/dist/platform.js
CHANGED
|
@@ -339,14 +339,28 @@ export class SmartHQPlatform {
|
|
|
339
339
|
if (existingAccessory) {
|
|
340
340
|
// the accessory already exists
|
|
341
341
|
if (!deviceData.hide_device) {
|
|
342
|
-
|
|
343
|
-
existingAccessory
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
342
|
+
// Check if protocol changed to Matter - if so, remove from HAP bridge
|
|
343
|
+
if (this.shouldUnregisterForMatter(existingAccessory, deviceData)) {
|
|
344
|
+
// Device removed from HAP, will be registered as Matter accessory in device class
|
|
345
|
+
const accessory = new this.api.platformAccessory(deviceData.nickname, uuid);
|
|
346
|
+
accessory.context.device = deviceData;
|
|
347
|
+
accessory.context = { device: deviceData, userId };
|
|
348
|
+
accessory.displayName = await this.validateAndCleanDisplayName(deviceData.nickname, 'nickname', deviceData.nickname);
|
|
349
|
+
accessory.context.device.firmware = deviceData.firmware ?? await this.getVersion();
|
|
350
|
+
new SmartHQDishWasher(this, accessory, deviceData);
|
|
351
|
+
this.debugLog(`${deviceData.nickname} uuid: ${deviceData.applianceId}`);
|
|
352
|
+
}
|
|
353
|
+
else {
|
|
354
|
+
// Still using HAP, restore normally
|
|
355
|
+
existingAccessory.context.device = deviceData;
|
|
356
|
+
existingAccessory.context = { device: deviceData, userId };
|
|
357
|
+
existingAccessory.displayName = await this.validateAndCleanDisplayName(deviceData.nickname, 'nickname', deviceData.nickname);
|
|
358
|
+
existingAccessory.context.device.firmware = deviceData.firmware ?? await this.getVersion();
|
|
359
|
+
this.api.updatePlatformAccessories([existingAccessory]);
|
|
360
|
+
this.infoLog(`[${protocol}] Restoring existing accessory from cache: ${existingAccessory.displayName}`);
|
|
361
|
+
new SmartHQDishWasher(this, existingAccessory, deviceData);
|
|
362
|
+
await this.debugLog(`${deviceData.nickname} uuid: ${deviceData.applianceId}`);
|
|
363
|
+
}
|
|
350
364
|
}
|
|
351
365
|
else {
|
|
352
366
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
@@ -379,14 +393,26 @@ export class SmartHQPlatform {
|
|
|
379
393
|
if (existingAccessory) {
|
|
380
394
|
// the accessory already exists
|
|
381
395
|
if (!deviceData.hide_device) {
|
|
382
|
-
|
|
383
|
-
existingAccessory
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
396
|
+
// Check if protocol changed to Matter - if so, remove from HAP bridge
|
|
397
|
+
if (this.shouldUnregisterForMatter(existingAccessory, deviceData)) {
|
|
398
|
+
const accessory = new this.api.platformAccessory(deviceData.nickname, uuid);
|
|
399
|
+
accessory.context.device = deviceData;
|
|
400
|
+
accessory.context = { device: deviceData, userId };
|
|
401
|
+
accessory.displayName = await this.validateAndCleanDisplayName(deviceData.nickname, 'nickname', deviceData.nickname);
|
|
402
|
+
accessory.context.device.firmware = deviceData.firmware ?? await this.getVersion();
|
|
403
|
+
new SmartHQOven(this, accessory, deviceData);
|
|
404
|
+
this.debugLog(`${deviceData.nickname} uuid: ${deviceData.applianceId}`);
|
|
405
|
+
}
|
|
406
|
+
else {
|
|
407
|
+
existingAccessory.context.device = deviceData;
|
|
408
|
+
existingAccessory.context = { device: deviceData, userId };
|
|
409
|
+
existingAccessory.displayName = await this.validateAndCleanDisplayName(deviceData.nickname, 'nickname', deviceData.nickname);
|
|
410
|
+
existingAccessory.context.device.firmware = deviceData.firmware ?? await this.getVersion();
|
|
411
|
+
this.api.updatePlatformAccessories([existingAccessory]);
|
|
412
|
+
this.infoLog(`[${protocol}] Restoring existing accessory from cache: ${existingAccessory.displayName}`);
|
|
413
|
+
new SmartHQOven(this, existingAccessory, deviceData);
|
|
414
|
+
await this.debugLog(`${deviceData.nickname} uuid: ${deviceData.applianceId}`);
|
|
415
|
+
}
|
|
390
416
|
}
|
|
391
417
|
else {
|
|
392
418
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
@@ -409,49 +435,67 @@ export class SmartHQPlatform {
|
|
|
409
435
|
}
|
|
410
436
|
}
|
|
411
437
|
async createSmartHQIceMaker(userId, device, details, features) {
|
|
412
|
-
|
|
438
|
+
// Merge device data
|
|
439
|
+
const deviceData = { brand: 'GE', ...details, ...features, ...device };
|
|
440
|
+
// Determine protocol (Matter or HAP)
|
|
441
|
+
deviceData.useMatter = this.shouldUseMatter(deviceData);
|
|
442
|
+
const uuid = this.api.hap.uuid.generate(deviceData.applianceId);
|
|
413
443
|
// see if an accessory with the same uuid has already been registered and restored from
|
|
414
444
|
// the cached devices we stored in the `configureAccessory` method above
|
|
415
445
|
const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
|
|
446
|
+
const protocol = deviceData.useMatter ? 'Matter' : 'HAP';
|
|
416
447
|
if (existingAccessory) {
|
|
417
448
|
// the accessory already exists
|
|
418
|
-
if (!
|
|
419
|
-
// if
|
|
420
|
-
existingAccessory
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
449
|
+
if (!deviceData.hide_device) {
|
|
450
|
+
// Check if protocol changed to Matter - if so, remove from HAP bridge
|
|
451
|
+
if (this.shouldUnregisterForMatter(existingAccessory, deviceData)) {
|
|
452
|
+
const accessory = new this.api.platformAccessory(deviceData.nickname, uuid);
|
|
453
|
+
accessory.context.device = deviceData;
|
|
454
|
+
accessory.context = { device: deviceData, userId };
|
|
455
|
+
accessory.displayName = await this.validateAndCleanDisplayName(deviceData.nickname, 'nickname', deviceData.nickname);
|
|
456
|
+
accessory.context.device.firmware = deviceData.firmware ?? await this.getVersion();
|
|
457
|
+
new SmartHQIceMaker(this, accessory, deviceData);
|
|
458
|
+
this.debugLog(`${deviceData.nickname} uuid: ${deviceData.applianceId}`);
|
|
459
|
+
}
|
|
460
|
+
else {
|
|
461
|
+
// if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
|
|
462
|
+
existingAccessory.context.device = deviceData;
|
|
463
|
+
existingAccessory.context = { device: deviceData, userId };
|
|
464
|
+
existingAccessory.displayName = await this.validateAndCleanDisplayName(deviceData.nickname, 'nickname', deviceData.nickname);
|
|
465
|
+
existingAccessory.context.device.firmware = deviceData.firmware ?? await this.getVersion();
|
|
466
|
+
this.api.updatePlatformAccessories([existingAccessory]);
|
|
467
|
+
// Restore accessory
|
|
468
|
+
// create the accessory handler for the restored accessory
|
|
469
|
+
// this is imported from `platformAccessory.ts`
|
|
470
|
+
this.infoLog(`[${protocol}] Restoring existing accessory from cache: ${existingAccessory.displayName}`);
|
|
471
|
+
new SmartHQIceMaker(this, existingAccessory, deviceData);
|
|
472
|
+
this.debugLog(`${deviceData.nickname} uuid: ${deviceData.applianceId}`);
|
|
473
|
+
}
|
|
430
474
|
}
|
|
431
475
|
else {
|
|
432
476
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
433
477
|
}
|
|
434
478
|
}
|
|
435
|
-
else if (!
|
|
436
|
-
this.infoLog(`Adding new accessory: ${
|
|
437
|
-
const accessory = new this.api.platformAccessory(
|
|
479
|
+
else if (!deviceData.hide_device && !existingAccessory) {
|
|
480
|
+
this.infoLog(`[${protocol}] Adding new accessory: ${deviceData.nickname}`);
|
|
481
|
+
const accessory = new this.api.platformAccessory(deviceData.nickname, uuid);
|
|
438
482
|
// store a copy of the device object in the `accessory.context`
|
|
439
483
|
// the `context` property can be used to store any data about the accessory you may need
|
|
440
|
-
accessory.context.device =
|
|
441
|
-
accessory.context = { device:
|
|
442
|
-
accessory.displayName = await this.validateAndCleanDisplayName(
|
|
443
|
-
accessory.context.device.firmware =
|
|
484
|
+
accessory.context.device = deviceData;
|
|
485
|
+
accessory.context = { device: deviceData, userId };
|
|
486
|
+
accessory.displayName = await this.validateAndCleanDisplayName(deviceData.nickname, 'nickname', deviceData.nickname);
|
|
487
|
+
accessory.context.device.firmware = deviceData.firmware ?? await this.getVersion();
|
|
444
488
|
// the accessory does not yet exist, so we need to create it
|
|
445
489
|
// create the accessory handler for the newly create accessory
|
|
446
490
|
// this is imported from `platformAccessory.ts`
|
|
447
|
-
new SmartHQIceMaker(this, accessory,
|
|
448
|
-
this.debugLog(`${
|
|
491
|
+
new SmartHQIceMaker(this, accessory, deviceData);
|
|
492
|
+
this.debugLog(`${deviceData.nickname} uuid: ${deviceData.applianceId}`);
|
|
449
493
|
// link the accessory to your platform
|
|
450
494
|
this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory]);
|
|
451
495
|
this.accessories.push(accessory);
|
|
452
496
|
}
|
|
453
497
|
else {
|
|
454
|
-
this.debugErrorLog(`Unable to Register new device: ${JSON.stringify(
|
|
498
|
+
this.debugErrorLog(`Unable to Register new device: ${JSON.stringify(deviceData.nickname)}`);
|
|
455
499
|
}
|
|
456
500
|
}
|
|
457
501
|
/**
|
|
@@ -469,14 +513,26 @@ export class SmartHQPlatform {
|
|
|
469
513
|
if (existingAccessory) {
|
|
470
514
|
// the accessory already exists
|
|
471
515
|
if (!deviceData.hide_device) {
|
|
472
|
-
|
|
473
|
-
existingAccessory
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
516
|
+
// Check if protocol changed to Matter - if so, remove from HAP bridge
|
|
517
|
+
if (this.shouldUnregisterForMatter(existingAccessory, deviceData)) {
|
|
518
|
+
const accessory = new this.api.platformAccessory(deviceData.nickname, uuid);
|
|
519
|
+
accessory.context.device = deviceData;
|
|
520
|
+
accessory.context = { device: deviceData, userId };
|
|
521
|
+
accessory.displayName = await this.validateAndCleanDisplayName(deviceData.nickname, 'nickname', deviceData.nickname);
|
|
522
|
+
accessory.context.device.firmware = deviceData.firmware ?? await this.getVersion();
|
|
523
|
+
new SmartHQRefrigerator(this, accessory, deviceData);
|
|
524
|
+
this.debugLog(`${deviceData.nickname} uuid: ${deviceData.applianceId}`);
|
|
525
|
+
}
|
|
526
|
+
else {
|
|
527
|
+
existingAccessory.context.device = deviceData;
|
|
528
|
+
existingAccessory.context = { device: deviceData, userId };
|
|
529
|
+
existingAccessory.displayName = await this.validateAndCleanDisplayName(deviceData.nickname, 'nickname', deviceData.nickname);
|
|
530
|
+
existingAccessory.context.device.firmware = deviceData.firmware ?? await this.getVersion();
|
|
531
|
+
this.api.updatePlatformAccessories([existingAccessory]);
|
|
532
|
+
this.infoLog(`[${protocol}] Restoring existing accessory from cache: ${existingAccessory.displayName}`);
|
|
533
|
+
new SmartHQRefrigerator(this, existingAccessory, deviceData);
|
|
534
|
+
await this.debugLog(`${deviceData.nickname} uuid: ${deviceData.applianceId}`);
|
|
535
|
+
}
|
|
480
536
|
}
|
|
481
537
|
else {
|
|
482
538
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
@@ -509,14 +565,26 @@ export class SmartHQPlatform {
|
|
|
509
565
|
if (existingAccessory) {
|
|
510
566
|
// the accessory already exists
|
|
511
567
|
if (!deviceData.hide_device) {
|
|
512
|
-
|
|
513
|
-
existingAccessory
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
568
|
+
// Check if protocol changed to Matter - if so, remove from HAP bridge
|
|
569
|
+
if (this.shouldUnregisterForMatter(existingAccessory, deviceData)) {
|
|
570
|
+
const accessory = new this.api.platformAccessory(deviceData.nickname, uuid);
|
|
571
|
+
accessory.context.device = deviceData;
|
|
572
|
+
accessory.context = { device: deviceData, userId };
|
|
573
|
+
accessory.displayName = await this.validateAndCleanDisplayName(deviceData.nickname, 'nickname', deviceData.nickname);
|
|
574
|
+
accessory.context.device.firmware = deviceData.firmware ?? await this.getVersion();
|
|
575
|
+
new SmartHQAirConditioner(this, accessory, deviceData);
|
|
576
|
+
this.debugLog(`${deviceData.nickname} uuid: ${deviceData.applianceId}`);
|
|
577
|
+
}
|
|
578
|
+
else {
|
|
579
|
+
existingAccessory.context.device = deviceData;
|
|
580
|
+
existingAccessory.context = { device: deviceData, userId };
|
|
581
|
+
existingAccessory.displayName = await this.validateAndCleanDisplayName(deviceData.nickname, 'nickname', deviceData.nickname);
|
|
582
|
+
existingAccessory.context.device.firmware = deviceData.firmware ?? await this.getVersion();
|
|
583
|
+
this.api.updatePlatformAccessories([existingAccessory]);
|
|
584
|
+
this.infoLog(`[${protocol}] Restoring existing accessory from cache: ${existingAccessory.displayName}`);
|
|
585
|
+
new SmartHQAirConditioner(this, existingAccessory, deviceData);
|
|
586
|
+
this.debugLog(`${deviceData.nickname} uuid: ${deviceData.applianceId}`);
|
|
587
|
+
}
|
|
520
588
|
}
|
|
521
589
|
else {
|
|
522
590
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
@@ -548,14 +616,26 @@ export class SmartHQPlatform {
|
|
|
548
616
|
const protocol = deviceData.useMatter ? 'Matter' : 'HAP';
|
|
549
617
|
if (existingAccessory) {
|
|
550
618
|
if (!deviceData.hide_device) {
|
|
551
|
-
|
|
552
|
-
existingAccessory
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
619
|
+
// Check if protocol changed to Matter - if so, remove from HAP bridge
|
|
620
|
+
if (this.shouldUnregisterForMatter(existingAccessory, deviceData)) {
|
|
621
|
+
const accessory = new this.api.platformAccessory(deviceData.nickname, uuid);
|
|
622
|
+
accessory.context.device = deviceData;
|
|
623
|
+
accessory.context = { device: deviceData, userId };
|
|
624
|
+
accessory.displayName = await this.validateAndCleanDisplayName(deviceData.nickname, 'nickname', deviceData.nickname);
|
|
625
|
+
accessory.context.device.firmware = deviceData.firmware ?? await this.getVersion();
|
|
626
|
+
new SmartHQHood(this, accessory, deviceData);
|
|
627
|
+
this.debugLog(`${deviceData.nickname} uuid: ${deviceData.applianceId}`);
|
|
628
|
+
}
|
|
629
|
+
else {
|
|
630
|
+
existingAccessory.context.device = deviceData;
|
|
631
|
+
existingAccessory.context = { device: deviceData, userId };
|
|
632
|
+
existingAccessory.displayName = await this.validateAndCleanDisplayName(deviceData.nickname, 'nickname', deviceData.nickname);
|
|
633
|
+
existingAccessory.context.device.firmware = deviceData.firmware ?? await this.getVersion();
|
|
634
|
+
this.api.updatePlatformAccessories([existingAccessory]);
|
|
635
|
+
this.infoLog(`[${protocol}] Restoring existing accessory from cache: ${existingAccessory.displayName}`);
|
|
636
|
+
new SmartHQHood(this, existingAccessory, deviceData);
|
|
637
|
+
this.debugLog(`${deviceData.nickname} uuid: ${deviceData.applianceId}`);
|
|
638
|
+
}
|
|
559
639
|
}
|
|
560
640
|
else {
|
|
561
641
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
@@ -587,14 +667,26 @@ export class SmartHQPlatform {
|
|
|
587
667
|
const protocol = deviceData.useMatter ? 'Matter' : 'HAP';
|
|
588
668
|
if (existingAccessory) {
|
|
589
669
|
if (!deviceData.hide_device) {
|
|
590
|
-
|
|
591
|
-
existingAccessory
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
670
|
+
// Check if protocol changed to Matter - if so, remove from HAP bridge
|
|
671
|
+
if (this.shouldUnregisterForMatter(existingAccessory, deviceData)) {
|
|
672
|
+
const accessory = new this.api.platformAccessory(deviceData.nickname, uuid);
|
|
673
|
+
accessory.context.device = deviceData;
|
|
674
|
+
accessory.context = { device: deviceData, userId };
|
|
675
|
+
accessory.displayName = await this.validateAndCleanDisplayName(deviceData.nickname, 'nickname', deviceData.nickname);
|
|
676
|
+
accessory.context.device.firmware = deviceData.firmware ?? await this.getVersion();
|
|
677
|
+
new SmartHQClothesWasher(this, accessory, deviceData);
|
|
678
|
+
this.debugLog(`${deviceData.nickname} uuid: ${deviceData.applianceId}`);
|
|
679
|
+
}
|
|
680
|
+
else {
|
|
681
|
+
existingAccessory.context.device = deviceData;
|
|
682
|
+
existingAccessory.context = { device: deviceData, userId };
|
|
683
|
+
existingAccessory.displayName = await this.validateAndCleanDisplayName(deviceData.nickname, 'nickname', deviceData.nickname);
|
|
684
|
+
existingAccessory.context.device.firmware = deviceData.firmware ?? await this.getVersion();
|
|
685
|
+
this.api.updatePlatformAccessories([existingAccessory]);
|
|
686
|
+
this.infoLog(`[${protocol}] Restoring existing accessory from cache: ${existingAccessory.displayName}`);
|
|
687
|
+
new SmartHQClothesWasher(this, existingAccessory, deviceData);
|
|
688
|
+
this.debugLog(`${deviceData.nickname} uuid: ${deviceData.applianceId}`);
|
|
689
|
+
}
|
|
598
690
|
}
|
|
599
691
|
else {
|
|
600
692
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
@@ -626,14 +718,26 @@ export class SmartHQPlatform {
|
|
|
626
718
|
const protocol = deviceData.useMatter ? 'Matter' : 'HAP';
|
|
627
719
|
if (existingAccessory) {
|
|
628
720
|
if (!deviceData.hide_device) {
|
|
629
|
-
|
|
630
|
-
existingAccessory
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
721
|
+
// Check if protocol changed to Matter - if so, remove from HAP bridge
|
|
722
|
+
if (this.shouldUnregisterForMatter(existingAccessory, deviceData)) {
|
|
723
|
+
const accessory = new this.api.platformAccessory(deviceData.nickname, uuid);
|
|
724
|
+
accessory.context.device = deviceData;
|
|
725
|
+
accessory.context = { device: deviceData, userId };
|
|
726
|
+
accessory.displayName = await this.validateAndCleanDisplayName(deviceData.nickname, 'nickname', deviceData.nickname);
|
|
727
|
+
accessory.context.device.firmware = deviceData.firmware ?? await this.getVersion();
|
|
728
|
+
new SmartHQClothesDryer(this, accessory, deviceData);
|
|
729
|
+
this.debugLog(`${deviceData.nickname} uuid: ${deviceData.applianceId}`);
|
|
730
|
+
}
|
|
731
|
+
else {
|
|
732
|
+
existingAccessory.context.device = deviceData;
|
|
733
|
+
existingAccessory.context = { device: deviceData, userId };
|
|
734
|
+
existingAccessory.displayName = await this.validateAndCleanDisplayName(deviceData.nickname, 'nickname', deviceData.nickname);
|
|
735
|
+
existingAccessory.context.device.firmware = deviceData.firmware ?? await this.getVersion();
|
|
736
|
+
this.api.updatePlatformAccessories([existingAccessory]);
|
|
737
|
+
this.infoLog(`[${protocol}] Restoring existing accessory from cache: ${existingAccessory.displayName}`);
|
|
738
|
+
new SmartHQClothesDryer(this, existingAccessory, deviceData);
|
|
739
|
+
this.debugLog(`${deviceData.nickname} uuid: ${deviceData.applianceId}`);
|
|
740
|
+
}
|
|
637
741
|
}
|
|
638
742
|
else {
|
|
639
743
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
@@ -656,71 +760,105 @@ export class SmartHQPlatform {
|
|
|
656
760
|
}
|
|
657
761
|
}
|
|
658
762
|
async createSmartHQWaterFilter(userId, device, details, features) {
|
|
659
|
-
|
|
763
|
+
// Merge device data
|
|
764
|
+
const deviceData = { brand: 'GE', ...details, ...features, ...device };
|
|
765
|
+
// Determine protocol (Matter or HAP)
|
|
766
|
+
deviceData.useMatter = this.shouldUseMatter(deviceData);
|
|
767
|
+
const uuid = this.api.hap.uuid.generate(deviceData.applianceId);
|
|
660
768
|
const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
|
|
769
|
+
const protocol = deviceData.useMatter ? 'Matter' : 'HAP';
|
|
661
770
|
if (existingAccessory) {
|
|
662
|
-
if (!
|
|
663
|
-
|
|
664
|
-
existingAccessory
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
771
|
+
if (!deviceData.hide_device) {
|
|
772
|
+
// Check if protocol changed to Matter - if so, remove from HAP bridge
|
|
773
|
+
if (this.shouldUnregisterForMatter(existingAccessory, deviceData)) {
|
|
774
|
+
const accessory = new this.api.platformAccessory(deviceData.nickname, uuid);
|
|
775
|
+
accessory.context.device = deviceData;
|
|
776
|
+
accessory.context = { device: deviceData, userId };
|
|
777
|
+
accessory.displayName = await this.validateAndCleanDisplayName(deviceData.nickname, 'nickname', deviceData.nickname);
|
|
778
|
+
accessory.context.device.firmware = deviceData.firmware ?? await this.getVersion();
|
|
779
|
+
new SmartHQWaterFilter(this, accessory, deviceData);
|
|
780
|
+
this.debugLog(`${deviceData.nickname} uuid: ${deviceData.applianceId}`);
|
|
781
|
+
}
|
|
782
|
+
else {
|
|
783
|
+
existingAccessory.context.device = deviceData;
|
|
784
|
+
existingAccessory.context = { device: deviceData, userId };
|
|
785
|
+
existingAccessory.displayName = await this.validateAndCleanDisplayName(deviceData.nickname, 'nickname', deviceData.nickname);
|
|
786
|
+
existingAccessory.context.device.firmware = deviceData.firmware ?? await this.getVersion();
|
|
787
|
+
this.api.updatePlatformAccessories([existingAccessory]);
|
|
788
|
+
this.infoLog(`[${protocol}] Restoring existing accessory from cache: ${existingAccessory.displayName}`);
|
|
789
|
+
new SmartHQWaterFilter(this, existingAccessory, deviceData);
|
|
790
|
+
this.debugLog(`${deviceData.nickname} uuid: ${deviceData.applianceId}`);
|
|
791
|
+
}
|
|
671
792
|
}
|
|
672
793
|
else {
|
|
673
794
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
674
795
|
}
|
|
675
796
|
}
|
|
676
|
-
else if (!
|
|
677
|
-
this.infoLog(`Adding new accessory: ${
|
|
678
|
-
const accessory = new this.api.platformAccessory(
|
|
679
|
-
accessory.context.device =
|
|
680
|
-
accessory.context = { device:
|
|
681
|
-
accessory.displayName = await this.validateAndCleanDisplayName(
|
|
682
|
-
accessory.context.device.firmware =
|
|
683
|
-
new SmartHQWaterFilter(this, accessory,
|
|
684
|
-
this.debugLog(`${
|
|
797
|
+
else if (!deviceData.hide_device && !existingAccessory) {
|
|
798
|
+
this.infoLog(`[${protocol}] Adding new accessory: ${deviceData.nickname}`);
|
|
799
|
+
const accessory = new this.api.platformAccessory(deviceData.nickname, uuid);
|
|
800
|
+
accessory.context.device = deviceData;
|
|
801
|
+
accessory.context = { device: deviceData, userId };
|
|
802
|
+
accessory.displayName = await this.validateAndCleanDisplayName(deviceData.nickname, 'nickname', deviceData.nickname);
|
|
803
|
+
accessory.context.device.firmware = deviceData.firmware ?? await this.getVersion();
|
|
804
|
+
new SmartHQWaterFilter(this, accessory, deviceData);
|
|
805
|
+
this.debugLog(`${deviceData.nickname} uuid: ${deviceData.applianceId}`);
|
|
685
806
|
this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory]);
|
|
686
807
|
this.accessories.push(accessory);
|
|
687
808
|
}
|
|
688
809
|
else {
|
|
689
|
-
this.debugErrorLog(`Unable to Register new device: ${JSON.stringify(
|
|
810
|
+
this.debugErrorLog(`Unable to Register new device: ${JSON.stringify(deviceData.nickname)}`);
|
|
690
811
|
}
|
|
691
812
|
}
|
|
692
813
|
async createSmartHQWaterSoftener(userId, device, details, features) {
|
|
693
|
-
|
|
814
|
+
// Merge device data
|
|
815
|
+
const deviceData = { brand: 'GE', ...details, ...features, ...device };
|
|
816
|
+
// Determine protocol (Matter or HAP)
|
|
817
|
+
deviceData.useMatter = this.shouldUseMatter(deviceData);
|
|
818
|
+
const uuid = this.api.hap.uuid.generate(deviceData.applianceId);
|
|
694
819
|
const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
|
|
820
|
+
const protocol = deviceData.useMatter ? 'Matter' : 'HAP';
|
|
695
821
|
if (existingAccessory) {
|
|
696
|
-
if (!
|
|
697
|
-
|
|
698
|
-
existingAccessory
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
822
|
+
if (!deviceData.hide_device) {
|
|
823
|
+
// Check if protocol changed to Matter - if so, remove from HAP bridge
|
|
824
|
+
if (this.shouldUnregisterForMatter(existingAccessory, deviceData)) {
|
|
825
|
+
const accessory = new this.api.platformAccessory(deviceData.nickname, uuid);
|
|
826
|
+
accessory.context.device = deviceData;
|
|
827
|
+
accessory.context = { device: deviceData, userId };
|
|
828
|
+
accessory.displayName = await this.validateAndCleanDisplayName(deviceData.nickname, 'nickname', deviceData.nickname);
|
|
829
|
+
accessory.context.device.firmware = deviceData.firmware ?? await this.getVersion();
|
|
830
|
+
new SmartHQWaterSoftener(this, accessory, deviceData);
|
|
831
|
+
this.debugLog(`${deviceData.nickname} uuid: ${deviceData.applianceId}`);
|
|
832
|
+
}
|
|
833
|
+
else {
|
|
834
|
+
existingAccessory.context.device = deviceData;
|
|
835
|
+
existingAccessory.context = { device: deviceData, userId };
|
|
836
|
+
existingAccessory.displayName = await this.validateAndCleanDisplayName(deviceData.nickname, 'nickname', deviceData.nickname);
|
|
837
|
+
existingAccessory.context.device.firmware = deviceData.firmware ?? await this.getVersion();
|
|
838
|
+
this.api.updatePlatformAccessories([existingAccessory]);
|
|
839
|
+
this.infoLog(`[${protocol}] Restoring existing accessory from cache: ${existingAccessory.displayName}`);
|
|
840
|
+
new SmartHQWaterSoftener(this, existingAccessory, deviceData);
|
|
841
|
+
this.debugLog(`${deviceData.nickname} uuid: ${deviceData.applianceId}`);
|
|
842
|
+
}
|
|
705
843
|
}
|
|
706
844
|
else {
|
|
707
845
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
708
846
|
}
|
|
709
847
|
}
|
|
710
|
-
else if (!
|
|
711
|
-
this.infoLog(`Adding new accessory: ${
|
|
712
|
-
const accessory = new this.api.platformAccessory(
|
|
713
|
-
accessory.context.device =
|
|
714
|
-
accessory.context = { device:
|
|
715
|
-
accessory.displayName = await this.validateAndCleanDisplayName(
|
|
716
|
-
accessory.context.device.firmware =
|
|
717
|
-
new SmartHQWaterSoftener(this, accessory,
|
|
718
|
-
this.debugLog(`${
|
|
848
|
+
else if (!deviceData.hide_device && !existingAccessory) {
|
|
849
|
+
this.infoLog(`[${protocol}] Adding new accessory: ${deviceData.nickname}`);
|
|
850
|
+
const accessory = new this.api.platformAccessory(deviceData.nickname, uuid);
|
|
851
|
+
accessory.context.device = deviceData;
|
|
852
|
+
accessory.context = { device: deviceData, userId };
|
|
853
|
+
accessory.displayName = await this.validateAndCleanDisplayName(deviceData.nickname, 'nickname', deviceData.nickname);
|
|
854
|
+
accessory.context.device.firmware = deviceData.firmware ?? await this.getVersion();
|
|
855
|
+
new SmartHQWaterSoftener(this, accessory, deviceData);
|
|
856
|
+
this.debugLog(`${deviceData.nickname} uuid: ${deviceData.applianceId}`);
|
|
719
857
|
this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory]);
|
|
720
858
|
this.accessories.push(accessory);
|
|
721
859
|
}
|
|
722
860
|
else {
|
|
723
|
-
this.debugErrorLog(`Unable to Register new device: ${JSON.stringify(
|
|
861
|
+
this.debugErrorLog(`Unable to Register new device: ${JSON.stringify(deviceData.nickname)}`);
|
|
724
862
|
}
|
|
725
863
|
}
|
|
726
864
|
async createSmartHQWaterHeater(userId, device, details, features) {
|
|
@@ -733,14 +871,26 @@ export class SmartHQPlatform {
|
|
|
733
871
|
const protocol = deviceData.useMatter ? 'Matter' : 'HAP';
|
|
734
872
|
if (existingAccessory) {
|
|
735
873
|
if (!deviceData.hide_device) {
|
|
736
|
-
|
|
737
|
-
existingAccessory
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
874
|
+
// Check if protocol changed to Matter - if so, remove from HAP bridge
|
|
875
|
+
if (this.shouldUnregisterForMatter(existingAccessory, deviceData)) {
|
|
876
|
+
const accessory = new this.api.platformAccessory(deviceData.nickname, uuid);
|
|
877
|
+
accessory.context.device = deviceData;
|
|
878
|
+
accessory.context = { device: deviceData, userId };
|
|
879
|
+
accessory.displayName = await this.validateAndCleanDisplayName(deviceData.nickname, 'nickname', deviceData.nickname);
|
|
880
|
+
accessory.context.device.firmware = deviceData.firmware ?? await this.getVersion();
|
|
881
|
+
new SmartHQWaterHeater(this, accessory, deviceData);
|
|
882
|
+
this.debugLog(`${deviceData.nickname} uuid: ${deviceData.applianceId}`);
|
|
883
|
+
}
|
|
884
|
+
else {
|
|
885
|
+
existingAccessory.context.device = deviceData;
|
|
886
|
+
existingAccessory.context = { device: deviceData, userId };
|
|
887
|
+
existingAccessory.displayName = await this.validateAndCleanDisplayName(deviceData.nickname, 'nickname', deviceData.nickname);
|
|
888
|
+
existingAccessory.context.device.firmware = deviceData.firmware ?? await this.getVersion();
|
|
889
|
+
this.api.updatePlatformAccessories([existingAccessory]);
|
|
890
|
+
this.infoLog(`[${protocol}] Restoring existing accessory from cache: ${existingAccessory.displayName}`);
|
|
891
|
+
new SmartHQWaterHeater(this, existingAccessory, deviceData);
|
|
892
|
+
this.debugLog(`${deviceData.nickname} uuid: ${deviceData.applianceId}`);
|
|
893
|
+
}
|
|
744
894
|
}
|
|
745
895
|
else {
|
|
746
896
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
@@ -763,32 +913,49 @@ export class SmartHQPlatform {
|
|
|
763
913
|
}
|
|
764
914
|
}
|
|
765
915
|
async createSmartHQAdvantium(userId, device, details, features) {
|
|
766
|
-
|
|
916
|
+
// Merge device data
|
|
917
|
+
const deviceData = { brand: 'GE', ...details, ...features, ...device };
|
|
918
|
+
// Determine protocol (Matter or HAP)
|
|
919
|
+
deviceData.useMatter = this.shouldUseMatter(deviceData);
|
|
920
|
+
const uuid = this.api.hap.uuid.generate(deviceData.applianceId);
|
|
767
921
|
const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
|
|
922
|
+
const protocol = deviceData.useMatter ? 'Matter' : 'HAP';
|
|
768
923
|
if (existingAccessory) {
|
|
769
|
-
if (!
|
|
770
|
-
|
|
771
|
-
existingAccessory
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
924
|
+
if (!deviceData.hide_device) {
|
|
925
|
+
// Check if protocol changed to Matter - if so, remove from HAP bridge
|
|
926
|
+
if (this.shouldUnregisterForMatter(existingAccessory, deviceData)) {
|
|
927
|
+
const accessory = new this.api.platformAccessory(deviceData.nickname, uuid);
|
|
928
|
+
accessory.context.device = deviceData;
|
|
929
|
+
accessory.context = { device: deviceData, userId };
|
|
930
|
+
accessory.displayName = await this.validateAndCleanDisplayName(deviceData.nickname, 'nickname', deviceData.nickname);
|
|
931
|
+
accessory.context.device.firmware = deviceData.firmware ?? await this.getVersion();
|
|
932
|
+
new SmartHQAdvantium(this, accessory, deviceData);
|
|
933
|
+
this.debugLog(`${deviceData.nickname} uuid: ${deviceData.applianceId}`);
|
|
934
|
+
}
|
|
935
|
+
else {
|
|
936
|
+
existingAccessory.context.device = deviceData;
|
|
937
|
+
existingAccessory.context = { device: deviceData, userId };
|
|
938
|
+
existingAccessory.displayName = await this.validateAndCleanDisplayName(deviceData.nickname, 'nickname', deviceData.nickname);
|
|
939
|
+
existingAccessory.context.device.firmware = deviceData.firmware ?? await this.getVersion();
|
|
940
|
+
this.api.updatePlatformAccessories([existingAccessory]);
|
|
941
|
+
this.infoLog(`[${protocol}] Restoring existing accessory from cache: ${existingAccessory.displayName}`);
|
|
942
|
+
new SmartHQAdvantium(this, existingAccessory, deviceData);
|
|
943
|
+
this.debugLog(`${deviceData.nickname} uuid: ${deviceData.applianceId}`);
|
|
944
|
+
}
|
|
778
945
|
}
|
|
779
946
|
else {
|
|
780
947
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
781
948
|
}
|
|
782
949
|
}
|
|
783
|
-
else if (!
|
|
784
|
-
this.infoLog(`Adding new accessory: ${
|
|
785
|
-
const accessory = new this.api.platformAccessory(
|
|
786
|
-
accessory.context.device =
|
|
787
|
-
accessory.context = { device:
|
|
788
|
-
accessory.displayName = await this.validateAndCleanDisplayName(
|
|
789
|
-
accessory.context.device.firmware =
|
|
790
|
-
new SmartHQAdvantium(this, accessory,
|
|
791
|
-
this.debugLog(`${
|
|
950
|
+
else if (!deviceData.hide_device && !existingAccessory) {
|
|
951
|
+
this.infoLog(`[${protocol}] Adding new accessory: ${deviceData.nickname}`);
|
|
952
|
+
const accessory = new this.api.platformAccessory(deviceData.nickname, uuid);
|
|
953
|
+
accessory.context.device = deviceData;
|
|
954
|
+
accessory.context = { device: deviceData, userId };
|
|
955
|
+
accessory.displayName = await this.validateAndCleanDisplayName(deviceData.nickname, 'nickname', deviceData.nickname);
|
|
956
|
+
accessory.context.device.firmware = deviceData.firmware ?? await this.getVersion();
|
|
957
|
+
new SmartHQAdvantium(this, accessory, deviceData);
|
|
958
|
+
this.debugLog(`${deviceData.nickname} uuid: ${deviceData.applianceId}`);
|
|
792
959
|
this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory]);
|
|
793
960
|
this.accessories.push(accessory);
|
|
794
961
|
}
|
|
@@ -806,14 +973,26 @@ export class SmartHQPlatform {
|
|
|
806
973
|
const protocol = deviceData.useMatter ? 'Matter' : 'HAP';
|
|
807
974
|
if (existingAccessory) {
|
|
808
975
|
if (!deviceData.hide_device) {
|
|
809
|
-
|
|
810
|
-
existingAccessory
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
976
|
+
// Check if protocol changed to Matter - if so, remove from HAP bridge
|
|
977
|
+
if (this.shouldUnregisterForMatter(existingAccessory, deviceData)) {
|
|
978
|
+
const accessory = new this.api.platformAccessory(deviceData.nickname, uuid);
|
|
979
|
+
accessory.context.device = deviceData;
|
|
980
|
+
accessory.context = { device: deviceData, userId };
|
|
981
|
+
accessory.displayName = await this.validateAndCleanDisplayName(deviceData.nickname, 'nickname', deviceData.nickname);
|
|
982
|
+
accessory.context.device.firmware = deviceData.firmware ?? await this.getVersion();
|
|
983
|
+
new SmartHQMicrowave(this, accessory, deviceData);
|
|
984
|
+
this.debugLog(`${deviceData.nickname} uuid: ${deviceData.applianceId}`);
|
|
985
|
+
}
|
|
986
|
+
else {
|
|
987
|
+
existingAccessory.context.device = deviceData;
|
|
988
|
+
existingAccessory.context = { device: deviceData, userId };
|
|
989
|
+
existingAccessory.displayName = await this.validateAndCleanDisplayName(deviceData.nickname, 'nickname', deviceData.nickname);
|
|
990
|
+
existingAccessory.context.device.firmware = deviceData.firmware ?? await this.getVersion();
|
|
991
|
+
this.api.updatePlatformAccessories([existingAccessory]);
|
|
992
|
+
this.infoLog(`[${protocol}] Restoring existing accessory from cache: ${existingAccessory.displayName}`);
|
|
993
|
+
new SmartHQMicrowave(this, existingAccessory, deviceData);
|
|
994
|
+
this.debugLog(`${deviceData.nickname} uuid: ${deviceData.applianceId}`);
|
|
995
|
+
}
|
|
817
996
|
}
|
|
818
997
|
else {
|
|
819
998
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
@@ -836,66 +1015,100 @@ export class SmartHQPlatform {
|
|
|
836
1015
|
}
|
|
837
1016
|
}
|
|
838
1017
|
async createSmartHQCoffeeMaker(userId, device, details, features) {
|
|
839
|
-
|
|
1018
|
+
// Merge device data
|
|
1019
|
+
const deviceData = { brand: 'GE', ...details, ...features, ...device };
|
|
1020
|
+
// Determine protocol (Matter or HAP)
|
|
1021
|
+
deviceData.useMatter = this.shouldUseMatter(deviceData);
|
|
1022
|
+
const uuid = this.api.hap.uuid.generate(deviceData.applianceId);
|
|
840
1023
|
const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
|
|
1024
|
+
const protocol = deviceData.useMatter ? 'Matter' : 'HAP';
|
|
841
1025
|
if (existingAccessory) {
|
|
842
|
-
if (!
|
|
843
|
-
|
|
844
|
-
existingAccessory
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
1026
|
+
if (!deviceData.hide_device) {
|
|
1027
|
+
// Check if protocol changed to Matter - if so, remove from HAP bridge
|
|
1028
|
+
if (this.shouldUnregisterForMatter(existingAccessory, deviceData)) {
|
|
1029
|
+
const accessory = new this.api.platformAccessory(deviceData.nickname, uuid);
|
|
1030
|
+
accessory.context.device = deviceData;
|
|
1031
|
+
accessory.context = { device: deviceData, userId };
|
|
1032
|
+
accessory.displayName = await this.validateAndCleanDisplayName(deviceData.nickname, 'nickname', deviceData.nickname);
|
|
1033
|
+
accessory.context.device.firmware = deviceData.firmware ?? await this.getVersion();
|
|
1034
|
+
new SmartHQCoffeeMaker(this, accessory, deviceData);
|
|
1035
|
+
this.debugLog(`${deviceData.nickname} uuid: ${deviceData.applianceId}`);
|
|
1036
|
+
}
|
|
1037
|
+
else {
|
|
1038
|
+
existingAccessory.context.device = deviceData;
|
|
1039
|
+
existingAccessory.context = { device: deviceData, userId };
|
|
1040
|
+
existingAccessory.displayName = await this.validateAndCleanDisplayName(deviceData.nickname, 'nickname', deviceData.nickname);
|
|
1041
|
+
existingAccessory.context.device.firmware = deviceData.firmware ?? await this.getVersion();
|
|
1042
|
+
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1043
|
+
this.infoLog(`[${protocol}] Restoring existing accessory from cache: ${existingAccessory.displayName}`);
|
|
1044
|
+
new SmartHQCoffeeMaker(this, existingAccessory, deviceData);
|
|
1045
|
+
this.debugLog(`${deviceData.nickname} uuid: ${deviceData.applianceId}`);
|
|
1046
|
+
}
|
|
851
1047
|
}
|
|
852
1048
|
else {
|
|
853
1049
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
854
1050
|
}
|
|
855
1051
|
}
|
|
856
|
-
else if (!
|
|
857
|
-
this.infoLog(`Adding new accessory: ${
|
|
858
|
-
const accessory = new this.api.platformAccessory(
|
|
859
|
-
accessory.context.device =
|
|
860
|
-
accessory.context = { device:
|
|
861
|
-
accessory.displayName = await this.validateAndCleanDisplayName(
|
|
862
|
-
accessory.context.device.firmware =
|
|
863
|
-
new SmartHQCoffeeMaker(this, accessory,
|
|
864
|
-
this.debugLog(`${
|
|
1052
|
+
else if (!deviceData.hide_device && !existingAccessory) {
|
|
1053
|
+
this.infoLog(`[${protocol}] Adding new accessory: ${deviceData.nickname}`);
|
|
1054
|
+
const accessory = new this.api.platformAccessory(deviceData.nickname, uuid);
|
|
1055
|
+
accessory.context.device = deviceData;
|
|
1056
|
+
accessory.context = { device: deviceData, userId };
|
|
1057
|
+
accessory.displayName = await this.validateAndCleanDisplayName(deviceData.nickname, 'nickname', deviceData.nickname);
|
|
1058
|
+
accessory.context.device.firmware = deviceData.firmware ?? await this.getVersion();
|
|
1059
|
+
new SmartHQCoffeeMaker(this, accessory, deviceData);
|
|
1060
|
+
this.debugLog(`${deviceData.nickname} uuid: ${deviceData.applianceId}`);
|
|
865
1061
|
this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory]);
|
|
866
1062
|
this.accessories.push(accessory);
|
|
867
1063
|
}
|
|
868
1064
|
else {
|
|
869
|
-
this.debugErrorLog(`Unable to Register new device: ${JSON.stringify(
|
|
1065
|
+
this.debugErrorLog(`Unable to Register new device: ${JSON.stringify(deviceData.nickname)}`);
|
|
870
1066
|
}
|
|
871
1067
|
}
|
|
872
1068
|
async createSmartHQBeverageCenter(userId, device, details, features) {
|
|
873
|
-
|
|
1069
|
+
// Merge device data
|
|
1070
|
+
const deviceData = { brand: 'GE', ...details, ...features, ...device };
|
|
1071
|
+
// Determine protocol (Matter or HAP)
|
|
1072
|
+
deviceData.useMatter = this.shouldUseMatter(deviceData);
|
|
1073
|
+
const uuid = this.api.hap.uuid.generate(deviceData.applianceId);
|
|
874
1074
|
const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
|
|
1075
|
+
const protocol = deviceData.useMatter ? 'Matter' : 'HAP';
|
|
875
1076
|
if (existingAccessory) {
|
|
876
|
-
if (!
|
|
877
|
-
|
|
878
|
-
existingAccessory
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
1077
|
+
if (!deviceData.hide_device) {
|
|
1078
|
+
// Check if protocol changed to Matter - if so, remove from HAP bridge
|
|
1079
|
+
if (this.shouldUnregisterForMatter(existingAccessory, deviceData)) {
|
|
1080
|
+
const accessory = new this.api.platformAccessory(deviceData.nickname, uuid);
|
|
1081
|
+
accessory.context.device = deviceData;
|
|
1082
|
+
accessory.context = { device: deviceData, userId };
|
|
1083
|
+
accessory.displayName = await this.validateAndCleanDisplayName(deviceData.nickname, 'nickname', deviceData.nickname);
|
|
1084
|
+
accessory.context.device.firmware = deviceData.firmware ?? await this.getVersion();
|
|
1085
|
+
new SmartHQBeverageCenter(this, accessory, deviceData);
|
|
1086
|
+
this.debugLog(`${deviceData.nickname} uuid: ${deviceData.applianceId}`);
|
|
1087
|
+
}
|
|
1088
|
+
else {
|
|
1089
|
+
existingAccessory.context.device = deviceData;
|
|
1090
|
+
existingAccessory.context = { device: deviceData, userId };
|
|
1091
|
+
existingAccessory.displayName = await this.validateAndCleanDisplayName(deviceData.nickname, 'nickname', deviceData.nickname);
|
|
1092
|
+
existingAccessory.context.device.firmware = deviceData.firmware ?? await this.getVersion();
|
|
1093
|
+
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1094
|
+
this.infoLog(`[${protocol}] Restoring existing accessory from cache: ${existingAccessory.displayName}`);
|
|
1095
|
+
new SmartHQBeverageCenter(this, existingAccessory, deviceData);
|
|
1096
|
+
this.debugLog(`${deviceData.nickname} uuid: ${deviceData.applianceId}`);
|
|
1097
|
+
}
|
|
885
1098
|
}
|
|
886
1099
|
else {
|
|
887
1100
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
888
1101
|
}
|
|
889
1102
|
}
|
|
890
|
-
else if (!
|
|
891
|
-
this.infoLog(`Adding new accessory: ${
|
|
892
|
-
const accessory = new this.api.platformAccessory(
|
|
893
|
-
accessory.context.device =
|
|
894
|
-
accessory.context = { device:
|
|
895
|
-
accessory.displayName = await this.validateAndCleanDisplayName(
|
|
896
|
-
accessory.context.device.firmware =
|
|
897
|
-
new SmartHQBeverageCenter(this, accessory,
|
|
898
|
-
this.debugLog(`${
|
|
1103
|
+
else if (!deviceData.hide_device && !existingAccessory) {
|
|
1104
|
+
this.infoLog(`[${protocol}] Adding new accessory: ${deviceData.nickname}`);
|
|
1105
|
+
const accessory = new this.api.platformAccessory(deviceData.nickname, uuid);
|
|
1106
|
+
accessory.context.device = deviceData;
|
|
1107
|
+
accessory.context = { device: deviceData, userId };
|
|
1108
|
+
accessory.displayName = await this.validateAndCleanDisplayName(deviceData.nickname, 'nickname', deviceData.nickname);
|
|
1109
|
+
accessory.context.device.firmware = deviceData.firmware ?? await this.getVersion();
|
|
1110
|
+
new SmartHQBeverageCenter(this, accessory, deviceData);
|
|
1111
|
+
this.debugLog(`${deviceData.nickname} uuid: ${deviceData.applianceId}`);
|
|
899
1112
|
this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory]);
|
|
900
1113
|
this.accessories.push(accessory);
|
|
901
1114
|
}
|
|
@@ -1104,5 +1317,17 @@ export class SmartHQPlatform {
|
|
|
1104
1317
|
// Default: use Matter when available
|
|
1105
1318
|
return true;
|
|
1106
1319
|
}
|
|
1320
|
+
/**
|
|
1321
|
+
* Handle accessory that needs to switch from HAP to Matter
|
|
1322
|
+
* Returns true if accessory was unregistered and needs to be recreated
|
|
1323
|
+
*/
|
|
1324
|
+
shouldUnregisterForMatter(existingAccessory, deviceData) {
|
|
1325
|
+
if (deviceData.useMatter && existingAccessory) {
|
|
1326
|
+
this.infoLog(`Removing ${existingAccessory.displayName} from HAP bridge (switching to Matter)`);
|
|
1327
|
+
this.unregisterPlatformAccessories(existingAccessory);
|
|
1328
|
+
return true;
|
|
1329
|
+
}
|
|
1330
|
+
return false;
|
|
1331
|
+
}
|
|
1107
1332
|
}
|
|
1108
1333
|
//# sourceMappingURL=platform.js.map
|