@homebridge-plugins/homebridge-smarthq 0.5.0-beta.26 → 0.5.0-beta.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/dist/devices/airConditioner.d.ts +11 -2
  2. package/dist/devices/airConditioner.d.ts.map +1 -1
  3. package/dist/devices/airConditioner.js +110 -9
  4. package/dist/devices/airConditioner.js.map +1 -1
  5. package/dist/devices/clothesDryer.d.ts +9 -0
  6. package/dist/devices/clothesDryer.d.ts.map +1 -1
  7. package/dist/devices/clothesDryer.js +112 -8
  8. package/dist/devices/clothesDryer.js.map +1 -1
  9. package/dist/devices/clothesWasher.d.ts +9 -0
  10. package/dist/devices/clothesWasher.d.ts.map +1 -1
  11. package/dist/devices/clothesWasher.js +106 -8
  12. package/dist/devices/clothesWasher.js.map +1 -1
  13. package/dist/devices/device.d.ts.map +1 -1
  14. package/dist/devices/device.js +15 -0
  15. package/dist/devices/device.js.map +1 -1
  16. package/dist/devices/dishwasher.d.ts +9 -0
  17. package/dist/devices/dishwasher.d.ts.map +1 -1
  18. package/dist/devices/dishwasher.js +102 -0
  19. package/dist/devices/dishwasher.js.map +1 -1
  20. package/dist/devices/hood.d.ts +11 -2
  21. package/dist/devices/hood.d.ts.map +1 -1
  22. package/dist/devices/hood.js +70 -2
  23. package/dist/devices/hood.js.map +1 -1
  24. package/dist/devices/microwave.d.ts +9 -0
  25. package/dist/devices/microwave.d.ts.map +1 -1
  26. package/dist/devices/microwave.js +65 -0
  27. package/dist/devices/microwave.js.map +1 -1
  28. package/dist/devices/oven.d.ts +9 -0
  29. package/dist/devices/oven.d.ts.map +1 -1
  30. package/dist/devices/oven.js +110 -0
  31. package/dist/devices/oven.js.map +1 -1
  32. package/dist/devices/waterHeater.d.ts +9 -0
  33. package/dist/devices/waterHeater.d.ts.map +1 -1
  34. package/dist/devices/waterHeater.js +68 -0
  35. package/dist/devices/waterHeater.js.map +1 -1
  36. package/dist/platform.d.ts.map +1 -1
  37. package/dist/platform.js +192 -190
  38. package/dist/platform.js.map +1 -1
  39. package/docs/classes/SmartHQPlatform.html +10 -10
  40. package/docs/interfaces/DeviceOptions.html +2 -2
  41. package/docs/interfaces/SmartHQPlatformConfig.html +2 -2
  42. package/docs/interfaces/SmartHqContext.html +2 -2
  43. package/docs/interfaces/SmartHqERDResponse.html +2 -2
  44. package/docs/interfaces/credentials.html +2 -2
  45. package/docs/interfaces/devicesConfig.html +2 -2
  46. package/docs/interfaces/options.html +2 -2
  47. package/docs/variables/API_URL.html +1 -1
  48. package/docs/variables/ERD_CODES.html +1 -1
  49. package/docs/variables/ERD_TYPES.html +1 -1
  50. package/docs/variables/KEEPALIVE_TIMEOUT.html +1 -1
  51. package/docs/variables/LOGIN_URL.html +1 -1
  52. package/docs/variables/OAUTH2_CLIENT_ID.html +1 -1
  53. package/docs/variables/OAUTH2_CLIENT_SECRET.html +1 -1
  54. package/docs/variables/OAUTH2_REDIRECT_URI.html +1 -1
  55. package/docs/variables/PLATFORM_NAME.html +1 -1
  56. package/docs/variables/PLUGIN_NAME.html +1 -1
  57. package/docs/variables/SECURE_URL.html +1 -1
  58. package/docs/variables/default.html +1 -1
  59. package/package.json +3 -3
package/dist/platform.js CHANGED
@@ -329,97 +329,83 @@ export class SmartHQPlatform {
329
329
  }
330
330
  }
331
331
  async createSmartHQDishWasher(userId, device, details, features) {
332
- const uuid = this.api.hap.uuid.generate(device.applianceId);
333
- // see if an accessory with the same uuid has already been registered and restored from
334
- // the cached devices we stored in the `configureAccessory` method above
332
+ // Merge device data
333
+ const deviceData = { brand: 'GE', ...details, ...features, ...device };
334
+ // Determine protocol (Matter or HAP)
335
+ deviceData.useMatter = this.shouldUseMatter(deviceData);
336
+ const uuid = this.api.hap.uuid.generate(deviceData.applianceId);
335
337
  const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
338
+ const protocol = deviceData.useMatter ? 'Matter' : 'HAP';
336
339
  if (existingAccessory) {
337
340
  // the accessory already exists
338
- if (!device.hide_device) {
339
- // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
340
- existingAccessory.context.device = device;
341
- existingAccessory.context = { device: { brand: 'GE', ...details, ...features }, userId };
342
- existingAccessory.displayName = await this.validateAndCleanDisplayName(device.nickname, 'nickname', device.nickname);
343
- existingAccessory.context.device.firmware = device.firmware ?? await this.getVersion();
341
+ if (!deviceData.hide_device) {
342
+ existingAccessory.context.device = deviceData;
343
+ existingAccessory.context = { device: deviceData, userId };
344
+ existingAccessory.displayName = await this.validateAndCleanDisplayName(deviceData.nickname, 'nickname', deviceData.nickname);
345
+ existingAccessory.context.device.firmware = deviceData.firmware ?? await this.getVersion();
344
346
  this.api.updatePlatformAccessories([existingAccessory]);
345
- // Restore accessory
346
- this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName}`);
347
- // create the accessory handler for the restored accessory
348
- // this is imported from `platformAccessory.ts`
349
- new SmartHQDishWasher(this, existingAccessory, device);
350
- this.debugLog(`${device.nickname} uuid: ${device.applianceId}`);
347
+ this.infoLog(`[${protocol}] Restoring existing accessory from cache: ${existingAccessory.displayName}`);
348
+ new SmartHQDishWasher(this, existingAccessory, deviceData);
349
+ await this.debugLog(`${deviceData.nickname} uuid: ${deviceData.applianceId}`);
351
350
  }
352
351
  else {
353
352
  this.unregisterPlatformAccessories(existingAccessory);
354
353
  }
355
354
  }
356
- else if (!device.hide_device && !existingAccessory) {
357
- this.infoLog(`Adding new accessory: ${device.nickname}`);
358
- const accessory = new this.api.platformAccessory(device.nickname, uuid);
359
- // store a copy of the device object in the `accessory.context`
360
- // the `context` property can be used to store any data about the accessory you may need
361
- accessory.context.device = device;
362
- accessory.context = { device: { brand: 'GE', ...details, ...features }, userId };
363
- accessory.displayName = await this.validateAndCleanDisplayName(device.nickname, 'nickname', device.nickname);
364
- accessory.context.device.firmware = device.firmware ?? await this.getVersion();
365
- // the accessory does not yet exist, so we need to create it
366
- // create the accessory handler for the newly create accessory
367
- // this is imported from `platformAccessory.ts`
368
- new SmartHQDishWasher(this, accessory, device);
369
- this.debugLog(`${device.nickname} uuid: ${device.applianceId}`);
370
- // link the accessory to your platform
355
+ else if (!deviceData.hide_device && !existingAccessory) {
356
+ this.infoLog(`[${protocol}] Adding new accessory: ${deviceData.nickname}`);
357
+ const accessory = new this.api.platformAccessory(deviceData.nickname, uuid);
358
+ accessory.context.device = deviceData;
359
+ accessory.context = { device: deviceData, userId };
360
+ accessory.displayName = await this.validateAndCleanDisplayName(deviceData.nickname, 'nickname', deviceData.nickname);
361
+ accessory.context.device.firmware = deviceData.firmware ?? await this.getVersion();
362
+ new SmartHQDishWasher(this, accessory, deviceData);
363
+ this.debugLog(`${deviceData.nickname} uuid: ${deviceData.applianceId}`);
371
364
  this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory]);
372
365
  this.accessories.push(accessory);
373
366
  }
374
367
  else {
375
- this.debugErrorLog(`Unable to Register new device: ${JSON.stringify(device.nickname)}`);
368
+ this.debugErrorLog(`Unable to Register new device: ${JSON.stringify(deviceData.nickname)}`);
376
369
  }
377
370
  }
378
371
  async createSmartHQOven(userId, device, details, features) {
379
- const uuid = this.api.hap.uuid.generate(device.applianceId);
380
- // see if an accessory with the same uuid has already been registered and restored from
381
- // the cached devices we stored in the `configureAccessory` method above
372
+ // Merge device data
373
+ const deviceData = { brand: 'GE', ...details, ...features, ...device };
374
+ // Determine protocol (Matter or HAP)
375
+ deviceData.useMatter = this.shouldUseMatter(deviceData);
376
+ const uuid = this.api.hap.uuid.generate(deviceData.applianceId);
382
377
  const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
378
+ const protocol = deviceData.useMatter ? 'Matter' : 'HAP';
383
379
  if (existingAccessory) {
384
380
  // the accessory already exists
385
- if (!device.hide_device) {
386
- // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
387
- existingAccessory.context.device = device;
388
- existingAccessory.context = { device: { brand: 'GE Appliances', ...details, ...features }, userId };
389
- existingAccessory.displayName = await this.validateAndCleanDisplayName(device.nickname, 'nickname', device.nickname);
390
- existingAccessory.context.device.firmware = device.firmware ?? await this.getVersion();
381
+ if (!deviceData.hide_device) {
382
+ existingAccessory.context.device = deviceData;
383
+ existingAccessory.context = { device: deviceData, userId };
384
+ existingAccessory.displayName = await this.validateAndCleanDisplayName(deviceData.nickname, 'nickname', deviceData.nickname);
385
+ existingAccessory.context.device.firmware = deviceData.firmware ?? await this.getVersion();
391
386
  this.api.updatePlatformAccessories([existingAccessory]);
392
- // Restore accessory
393
- this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName}`);
394
- // create the accessory handler for the restored accessory
395
- // this is imported from `platformAccessory.ts`
396
- new SmartHQOven(this, existingAccessory, device);
397
- await this.debugLog(`${device.nickname} uuid: ${device.applianceId}`);
387
+ this.infoLog(`[${protocol}] Restoring existing accessory from cache: ${existingAccessory.displayName}`);
388
+ new SmartHQOven(this, existingAccessory, deviceData);
389
+ await this.debugLog(`${deviceData.nickname} uuid: ${deviceData.applianceId}`);
398
390
  }
399
391
  else {
400
392
  this.unregisterPlatformAccessories(existingAccessory);
401
393
  }
402
394
  }
403
- else if (!device.hide_device && !existingAccessory) {
404
- this.infoLog(`Adding new accessory: ${device.nickname}`);
405
- const accessory = new this.api.platformAccessory(device.nickname, uuid);
406
- // store a copy of the device object in the `accessory.context`
407
- // the `context` property can be used to store any data about the accessory you may need
408
- accessory.context.device = device;
409
- accessory.context = { device: { brand: 'GE', ...details, ...features }, userId };
410
- accessory.displayName = await this.validateAndCleanDisplayName(device.nickname, 'nickname', device.nickname);
411
- accessory.context.device.firmware = device.firmware ?? await this.getVersion();
412
- // the accessory does not yet exist, so we need to create it
413
- // create the accessory handler for the newly create accessory
414
- // this is imported from `platformAccessory.ts`
415
- new SmartHQOven(this, accessory, device);
416
- this.debugLog(`${device.nickname} uuid: ${device.applianceId}`);
417
- // link the accessory to your platform
395
+ else if (!deviceData.hide_device && !existingAccessory) {
396
+ this.infoLog(`[${protocol}] Adding new accessory: ${deviceData.nickname}`);
397
+ const accessory = new this.api.platformAccessory(deviceData.nickname, uuid);
398
+ accessory.context.device = deviceData;
399
+ accessory.context = { device: deviceData, userId };
400
+ accessory.displayName = await this.validateAndCleanDisplayName(deviceData.nickname, 'nickname', deviceData.nickname);
401
+ accessory.context.device.firmware = deviceData.firmware ?? await this.getVersion();
402
+ new SmartHQOven(this, accessory, deviceData);
403
+ this.debugLog(`${deviceData.nickname} uuid: ${deviceData.applianceId}`);
418
404
  this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory]);
419
405
  this.accessories.push(accessory);
420
406
  }
421
407
  else {
422
- this.debugErrorLog(`Unable to Register new device: ${JSON.stringify(device.nickname)}`);
408
+ this.debugErrorLog(`Unable to Register new device: ${JSON.stringify(deviceData.nickname)}`);
423
409
  }
424
410
  }
425
411
  async createSmartHQIceMaker(userId, device, details, features) {
@@ -513,154 +499,160 @@ export class SmartHQPlatform {
513
499
  }
514
500
  }
515
501
  async createSmartHQAirConditioner(userId, device, details, features) {
516
- const uuid = this.api.hap.uuid.generate(device.applianceId);
517
- // see if an accessory with the same uuid has already been registered and restored from
518
- // the cached devices we stored in the `configureAccessory` method above
502
+ // Merge device data
503
+ const deviceData = { brand: 'GE', ...details, ...features, ...device };
504
+ // Determine protocol (Matter or HAP)
505
+ deviceData.useMatter = this.shouldUseMatter(deviceData);
506
+ const uuid = this.api.hap.uuid.generate(deviceData.applianceId);
519
507
  const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
508
+ const protocol = deviceData.useMatter ? 'Matter' : 'HAP';
520
509
  if (existingAccessory) {
521
510
  // the accessory already exists
522
- if (!device.hide_device) {
523
- // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
524
- existingAccessory.context.device = device;
525
- existingAccessory.context = { device: { brand: 'GE', ...details, ...features }, userId };
526
- existingAccessory.displayName = await this.validateAndCleanDisplayName(device.nickname, 'nickname', device.nickname);
527
- existingAccessory.context.device.firmware = device.firmware ?? await this.getVersion();
511
+ if (!deviceData.hide_device) {
512
+ existingAccessory.context.device = deviceData;
513
+ existingAccessory.context = { device: deviceData, userId };
514
+ existingAccessory.displayName = await this.validateAndCleanDisplayName(deviceData.nickname, 'nickname', deviceData.nickname);
515
+ existingAccessory.context.device.firmware = deviceData.firmware ?? await this.getVersion();
528
516
  this.api.updatePlatformAccessories([existingAccessory]);
529
- // Restore accessory
530
- this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName}`);
531
- // create the accessory handler for the restored accessory
532
- // this is imported from `platformAccessory.ts`
533
- new SmartHQAirConditioner(this, existingAccessory, device);
534
- this.debugLog(`${device.nickname} uuid: ${device.applianceId}`);
517
+ this.infoLog(`[${protocol}] Restoring existing accessory from cache: ${existingAccessory.displayName}`);
518
+ new SmartHQAirConditioner(this, existingAccessory, deviceData);
519
+ this.debugLog(`${deviceData.nickname} uuid: ${deviceData.applianceId}`);
535
520
  }
536
521
  else {
537
522
  this.unregisterPlatformAccessories(existingAccessory);
538
523
  }
539
524
  }
540
- else if (!device.hide_device && !existingAccessory) {
541
- this.infoLog(`Adding new accessory: ${device.nickname}`);
542
- const accessory = new this.api.platformAccessory(device.nickname, uuid);
543
- // store a copy of the device object in the `accessory.context`
544
- // the `context` property can be used to store any data about the accessory you may need
545
- accessory.context.device = device;
546
- accessory.context = { device: { brand: 'GE', ...details, ...features }, userId };
547
- accessory.displayName = await this.validateAndCleanDisplayName(device.nickname, 'nickname', device.nickname);
548
- accessory.context.device.firmware = device.firmware ?? await this.getVersion();
549
- // the accessory does not yet exist, so we need to create it
550
- // create the accessory handler for the newly create accessory
551
- // this is imported from `platformAccessory.ts`
552
- new SmartHQAirConditioner(this, accessory, device);
553
- this.debugLog(`${device.nickname} uuid: ${device.applianceId}`);
554
- // link the accessory to your platform
525
+ else if (!deviceData.hide_device && !existingAccessory) {
526
+ this.infoLog(`[${protocol}] Adding new accessory: ${deviceData.nickname}`);
527
+ const accessory = new this.api.platformAccessory(deviceData.nickname, uuid);
528
+ accessory.context.device = deviceData;
529
+ accessory.context = { device: deviceData, userId };
530
+ accessory.displayName = await this.validateAndCleanDisplayName(deviceData.nickname, 'nickname', deviceData.nickname);
531
+ accessory.context.device.firmware = deviceData.firmware ?? await this.getVersion();
532
+ new SmartHQAirConditioner(this, accessory, deviceData);
533
+ this.debugLog(`${deviceData.nickname} uuid: ${deviceData.applianceId}`);
555
534
  this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory]);
556
535
  this.accessories.push(accessory);
557
536
  }
558
537
  else {
559
- this.debugErrorLog(`Unable to Register new device: ${JSON.stringify(device.nickname)}`);
538
+ this.debugErrorLog(`Unable to Register new device: ${JSON.stringify(deviceData.nickname)}`);
560
539
  }
561
540
  }
562
541
  async createSmartHQHood(userId, device, details, features) {
563
- const uuid = this.api.hap.uuid.generate(device.applianceId);
542
+ // Merge device data
543
+ const deviceData = { brand: 'GE', ...details, ...features, ...device };
544
+ // Determine protocol (Matter or HAP)
545
+ deviceData.useMatter = this.shouldUseMatter(deviceData);
546
+ const uuid = this.api.hap.uuid.generate(deviceData.applianceId);
564
547
  const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
548
+ const protocol = deviceData.useMatter ? 'Matter' : 'HAP';
565
549
  if (existingAccessory) {
566
- if (!device.hide_device) {
567
- existingAccessory.context.device = device;
568
- existingAccessory.context = { device: { brand: 'GE', ...details, ...features }, userId };
569
- existingAccessory.displayName = await this.validateAndCleanDisplayName(device.nickname, 'nickname', device.nickname);
570
- existingAccessory.context.device.firmware = device.firmware ?? await this.getVersion();
550
+ if (!deviceData.hide_device) {
551
+ existingAccessory.context.device = deviceData;
552
+ existingAccessory.context = { device: deviceData, userId };
553
+ existingAccessory.displayName = await this.validateAndCleanDisplayName(deviceData.nickname, 'nickname', deviceData.nickname);
554
+ existingAccessory.context.device.firmware = deviceData.firmware ?? await this.getVersion();
571
555
  this.api.updatePlatformAccessories([existingAccessory]);
572
- this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName}`);
573
- new SmartHQHood(this, existingAccessory, device);
574
- this.debugLog(`${device.nickname} uuid: ${device.applianceId}`);
556
+ this.infoLog(`[${protocol}] Restoring existing accessory from cache: ${existingAccessory.displayName}`);
557
+ new SmartHQHood(this, existingAccessory, deviceData);
558
+ this.debugLog(`${deviceData.nickname} uuid: ${deviceData.applianceId}`);
575
559
  }
576
560
  else {
577
561
  this.unregisterPlatformAccessories(existingAccessory);
578
562
  }
579
563
  }
580
- else if (!device.hide_device && !existingAccessory) {
581
- this.infoLog(`Adding new accessory: ${device.nickname}`);
582
- const accessory = new this.api.platformAccessory(device.nickname, uuid);
583
- accessory.context.device = device;
584
- accessory.context = { device: { brand: 'GE', ...details, ...features }, userId };
585
- accessory.displayName = await this.validateAndCleanDisplayName(device.nickname, 'nickname', device.nickname);
586
- accessory.context.device.firmware = device.firmware ?? await this.getVersion();
587
- new SmartHQHood(this, accessory, device);
588
- this.debugLog(`${device.nickname} uuid: ${device.applianceId}`);
564
+ else if (!deviceData.hide_device && !existingAccessory) {
565
+ this.infoLog(`[${protocol}] Adding new accessory: ${deviceData.nickname}`);
566
+ const accessory = new this.api.platformAccessory(deviceData.nickname, uuid);
567
+ accessory.context.device = deviceData;
568
+ accessory.context = { device: deviceData, userId };
569
+ accessory.displayName = await this.validateAndCleanDisplayName(deviceData.nickname, 'nickname', deviceData.nickname);
570
+ accessory.context.device.firmware = deviceData.firmware ?? await this.getVersion();
571
+ new SmartHQHood(this, accessory, deviceData);
572
+ this.debugLog(`${deviceData.nickname} uuid: ${deviceData.applianceId}`);
589
573
  this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory]);
590
574
  this.accessories.push(accessory);
591
575
  }
592
576
  else {
593
- this.debugErrorLog(`Unable to Register new device: ${JSON.stringify(device.nickname)}`);
577
+ this.debugErrorLog(`Unable to Register new device: ${JSON.stringify(deviceData.nickname)}`);
594
578
  }
595
579
  }
596
580
  async createSmartHQClothesWasher(userId, device, details, features) {
597
- const uuid = this.api.hap.uuid.generate(device.applianceId);
581
+ // Merge device data
582
+ const deviceData = { brand: 'GE', ...details, ...features, ...device };
583
+ // Determine protocol (Matter or HAP)
584
+ deviceData.useMatter = this.shouldUseMatter(deviceData);
585
+ const uuid = this.api.hap.uuid.generate(deviceData.applianceId);
598
586
  const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
587
+ const protocol = deviceData.useMatter ? 'Matter' : 'HAP';
599
588
  if (existingAccessory) {
600
- if (!device.hide_device) {
601
- existingAccessory.context.device = device;
602
- existingAccessory.context = { device: { brand: 'GE', ...details, ...features }, userId };
603
- existingAccessory.displayName = await this.validateAndCleanDisplayName(device.nickname, 'nickname', device.nickname);
604
- existingAccessory.context.device.firmware = device.firmware ?? await this.getVersion();
589
+ if (!deviceData.hide_device) {
590
+ existingAccessory.context.device = deviceData;
591
+ existingAccessory.context = { device: deviceData, userId };
592
+ existingAccessory.displayName = await this.validateAndCleanDisplayName(deviceData.nickname, 'nickname', deviceData.nickname);
593
+ existingAccessory.context.device.firmware = deviceData.firmware ?? await this.getVersion();
605
594
  this.api.updatePlatformAccessories([existingAccessory]);
606
- this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName}`);
607
- // create the accessory handler for the restored accessory
608
- new SmartHQClothesWasher(this, existingAccessory, device);
609
- this.debugLog(`${device.nickname} uuid: ${device.applianceId}`);
595
+ this.infoLog(`[${protocol}] Restoring existing accessory from cache: ${existingAccessory.displayName}`);
596
+ new SmartHQClothesWasher(this, existingAccessory, deviceData);
597
+ this.debugLog(`${deviceData.nickname} uuid: ${deviceData.applianceId}`);
610
598
  }
611
599
  else {
612
600
  this.unregisterPlatformAccessories(existingAccessory);
613
601
  }
614
602
  }
615
- else if (!device.hide_device && !existingAccessory) {
616
- this.infoLog(`Adding new accessory: ${device.nickname}`);
617
- const accessory = new this.api.platformAccessory(device.nickname, uuid);
618
- accessory.context.device = device;
619
- accessory.context = { device: { brand: 'GE', ...details, ...features }, userId };
620
- accessory.displayName = await this.validateAndCleanDisplayName(device.nickname, 'nickname', device.nickname);
621
- accessory.context.device.firmware = device.firmware ?? await this.getVersion();
622
- new SmartHQClothesWasher(this, accessory, device);
623
- this.debugLog(`${device.nickname} uuid: ${device.applianceId}`);
603
+ else if (!deviceData.hide_device && !existingAccessory) {
604
+ this.infoLog(`[${protocol}] Adding new accessory: ${deviceData.nickname}`);
605
+ const accessory = new this.api.platformAccessory(deviceData.nickname, uuid);
606
+ accessory.context.device = deviceData;
607
+ accessory.context = { device: deviceData, userId };
608
+ accessory.displayName = await this.validateAndCleanDisplayName(deviceData.nickname, 'nickname', deviceData.nickname);
609
+ accessory.context.device.firmware = deviceData.firmware ?? await this.getVersion();
610
+ new SmartHQClothesWasher(this, accessory, deviceData);
611
+ this.debugLog(`${deviceData.nickname} uuid: ${deviceData.applianceId}`);
624
612
  this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory]);
625
613
  this.accessories.push(accessory);
626
614
  }
627
615
  else {
628
- this.debugErrorLog(`Unable to Register new device: ${JSON.stringify(device.nickname)}`);
616
+ this.debugErrorLog(`Unable to Register new device: ${JSON.stringify(deviceData.nickname)}`);
629
617
  }
630
618
  }
631
619
  async createSmartHQClothesDryer(userId, device, details, features) {
632
- const uuid = this.api.hap.uuid.generate(device.applianceId);
620
+ // Merge device data
621
+ const deviceData = { brand: 'GE', ...details, ...features, ...device };
622
+ // Determine protocol (Matter or HAP)
623
+ deviceData.useMatter = this.shouldUseMatter(deviceData);
624
+ const uuid = this.api.hap.uuid.generate(deviceData.applianceId);
633
625
  const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
626
+ const protocol = deviceData.useMatter ? 'Matter' : 'HAP';
634
627
  if (existingAccessory) {
635
- if (!device.hide_device) {
636
- existingAccessory.context.device = device;
637
- existingAccessory.context = { device: { brand: 'GE', ...details, ...features }, userId };
638
- existingAccessory.displayName = await this.validateAndCleanDisplayName(device.nickname, 'nickname', device.nickname);
639
- existingAccessory.context.device.firmware = device.firmware ?? await this.getVersion();
628
+ if (!deviceData.hide_device) {
629
+ existingAccessory.context.device = deviceData;
630
+ existingAccessory.context = { device: deviceData, userId };
631
+ existingAccessory.displayName = await this.validateAndCleanDisplayName(deviceData.nickname, 'nickname', deviceData.nickname);
632
+ existingAccessory.context.device.firmware = deviceData.firmware ?? await this.getVersion();
640
633
  this.api.updatePlatformAccessories([existingAccessory]);
641
- this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName}`);
642
- // create the accessory handler for the restored accessory
643
- new SmartHQClothesDryer(this, existingAccessory, device);
644
- this.debugLog(`${device.nickname} uuid: ${device.applianceId}`);
634
+ this.infoLog(`[${protocol}] Restoring existing accessory from cache: ${existingAccessory.displayName}`);
635
+ new SmartHQClothesDryer(this, existingAccessory, deviceData);
636
+ this.debugLog(`${deviceData.nickname} uuid: ${deviceData.applianceId}`);
645
637
  }
646
638
  else {
647
639
  this.unregisterPlatformAccessories(existingAccessory);
648
640
  }
649
641
  }
650
- else if (!device.hide_device && !existingAccessory) {
651
- this.infoLog(`Adding new accessory: ${device.nickname}`);
652
- const accessory = new this.api.platformAccessory(device.nickname, uuid);
653
- accessory.context.device = device;
654
- accessory.context = { device: { brand: 'GE', ...details, ...features }, userId };
655
- accessory.displayName = await this.validateAndCleanDisplayName(device.nickname, 'nickname', device.nickname);
656
- accessory.context.device.firmware = device.firmware ?? await this.getVersion();
657
- new SmartHQClothesDryer(this, accessory, device);
658
- this.debugLog(`${device.nickname} uuid: ${device.applianceId}`);
642
+ else if (!deviceData.hide_device && !existingAccessory) {
643
+ this.infoLog(`[${protocol}] Adding new accessory: ${deviceData.nickname}`);
644
+ const accessory = new this.api.platformAccessory(deviceData.nickname, uuid);
645
+ accessory.context.device = deviceData;
646
+ accessory.context = { device: deviceData, userId };
647
+ accessory.displayName = await this.validateAndCleanDisplayName(deviceData.nickname, 'nickname', deviceData.nickname);
648
+ accessory.context.device.firmware = deviceData.firmware ?? await this.getVersion();
649
+ new SmartHQClothesDryer(this, accessory, deviceData);
650
+ this.debugLog(`${deviceData.nickname} uuid: ${deviceData.applianceId}`);
659
651
  this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory]);
660
652
  this.accessories.push(accessory);
661
653
  }
662
654
  else {
663
- this.debugErrorLog(`Unable to Register new device: ${JSON.stringify(device.nickname)}`);
655
+ this.debugErrorLog(`Unable to Register new device: ${JSON.stringify(deviceData.nickname)}`);
664
656
  }
665
657
  }
666
658
  async createSmartHQWaterFilter(userId, device, details, features) {
@@ -732,37 +724,42 @@ export class SmartHQPlatform {
732
724
  }
733
725
  }
734
726
  async createSmartHQWaterHeater(userId, device, details, features) {
735
- const uuid = this.api.hap.uuid.generate(device.applianceId);
727
+ // Merge device data
728
+ const deviceData = { brand: 'GE', ...details, ...features, ...device };
729
+ // Determine protocol (Matter or HAP)
730
+ deviceData.useMatter = this.shouldUseMatter(deviceData);
731
+ const uuid = this.api.hap.uuid.generate(deviceData.applianceId);
736
732
  const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
733
+ const protocol = deviceData.useMatter ? 'Matter' : 'HAP';
737
734
  if (existingAccessory) {
738
- if (!device.hide_device) {
739
- existingAccessory.context.device = device;
740
- existingAccessory.context = { device: { brand: 'GE', ...details, ...features }, userId };
741
- existingAccessory.displayName = await this.validateAndCleanDisplayName(device.nickname, 'nickname', device.nickname);
742
- existingAccessory.context.device.firmware = device.firmware ?? await this.getVersion();
735
+ if (!deviceData.hide_device) {
736
+ existingAccessory.context.device = deviceData;
737
+ existingAccessory.context = { device: deviceData, userId };
738
+ existingAccessory.displayName = await this.validateAndCleanDisplayName(deviceData.nickname, 'nickname', deviceData.nickname);
739
+ existingAccessory.context.device.firmware = deviceData.firmware ?? await this.getVersion();
743
740
  this.api.updatePlatformAccessories([existingAccessory]);
744
- this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName}`);
745
- new SmartHQWaterHeater(this, existingAccessory, device);
746
- this.debugLog(`${device.nickname} uuid: ${device.applianceId}`);
741
+ this.infoLog(`[${protocol}] Restoring existing accessory from cache: ${existingAccessory.displayName}`);
742
+ new SmartHQWaterHeater(this, existingAccessory, deviceData);
743
+ this.debugLog(`${deviceData.nickname} uuid: ${deviceData.applianceId}`);
747
744
  }
748
745
  else {
749
746
  this.unregisterPlatformAccessories(existingAccessory);
750
747
  }
751
748
  }
752
- else if (!device.hide_device && !existingAccessory) {
753
- this.infoLog(`Adding new accessory: ${device.nickname}`);
754
- const accessory = new this.api.platformAccessory(device.nickname, uuid);
755
- accessory.context.device = device;
756
- accessory.context = { device: { brand: 'GE', ...details, ...features }, userId };
757
- accessory.displayName = await this.validateAndCleanDisplayName(device.nickname, 'nickname', device.nickname);
758
- accessory.context.device.firmware = device.firmware ?? await this.getVersion();
759
- new SmartHQWaterHeater(this, accessory, device);
760
- this.debugLog(`${device.nickname} uuid: ${device.applianceId}`);
749
+ else if (!deviceData.hide_device && !existingAccessory) {
750
+ this.infoLog(`[${protocol}] Adding new accessory: ${deviceData.nickname}`);
751
+ const accessory = new this.api.platformAccessory(deviceData.nickname, uuid);
752
+ accessory.context.device = deviceData;
753
+ accessory.context = { device: deviceData, userId };
754
+ accessory.displayName = await this.validateAndCleanDisplayName(deviceData.nickname, 'nickname', deviceData.nickname);
755
+ accessory.context.device.firmware = deviceData.firmware ?? await this.getVersion();
756
+ new SmartHQWaterHeater(this, accessory, deviceData);
757
+ this.debugLog(`${deviceData.nickname} uuid: ${deviceData.applianceId}`);
761
758
  this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory]);
762
759
  this.accessories.push(accessory);
763
760
  }
764
761
  else {
765
- this.debugErrorLog(`Unable to Register new device: ${JSON.stringify(device.nickname)}`);
762
+ this.debugErrorLog(`Unable to Register new device: ${JSON.stringify(deviceData.nickname)}`);
766
763
  }
767
764
  }
768
765
  async createSmartHQAdvantium(userId, device, details, features) {
@@ -800,37 +797,42 @@ export class SmartHQPlatform {
800
797
  }
801
798
  }
802
799
  async createSmartHQMicrowave(userId, device, details, features) {
803
- const uuid = this.api.hap.uuid.generate(device.applianceId);
800
+ // Merge device data
801
+ const deviceData = { brand: 'GE', ...details, ...features, ...device };
802
+ // Determine protocol (Matter or HAP)
803
+ deviceData.useMatter = this.shouldUseMatter(deviceData);
804
+ const uuid = this.api.hap.uuid.generate(deviceData.applianceId);
804
805
  const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
806
+ const protocol = deviceData.useMatter ? 'Matter' : 'HAP';
805
807
  if (existingAccessory) {
806
- if (!device.hide_device) {
807
- existingAccessory.context.device = device;
808
- existingAccessory.context = { device: { brand: 'GE', ...details, ...features }, userId };
809
- existingAccessory.displayName = await this.validateAndCleanDisplayName(device.nickname, 'nickname', device.nickname);
810
- existingAccessory.context.device.firmware = device.firmware ?? await this.getVersion();
808
+ if (!deviceData.hide_device) {
809
+ existingAccessory.context.device = deviceData;
810
+ existingAccessory.context = { device: deviceData, userId };
811
+ existingAccessory.displayName = await this.validateAndCleanDisplayName(deviceData.nickname, 'nickname', deviceData.nickname);
812
+ existingAccessory.context.device.firmware = deviceData.firmware ?? await this.getVersion();
811
813
  this.api.updatePlatformAccessories([existingAccessory]);
812
- this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName}`);
813
- new SmartHQMicrowave(this, existingAccessory, device);
814
- this.debugLog(`${device.nickname} uuid: ${device.applianceId}`);
814
+ this.infoLog(`[${protocol}] Restoring existing accessory from cache: ${existingAccessory.displayName}`);
815
+ new SmartHQMicrowave(this, existingAccessory, deviceData);
816
+ this.debugLog(`${deviceData.nickname} uuid: ${deviceData.applianceId}`);
815
817
  }
816
818
  else {
817
819
  this.unregisterPlatformAccessories(existingAccessory);
818
820
  }
819
821
  }
820
- else if (!device.hide_device && !existingAccessory) {
821
- this.infoLog(`Adding new accessory: ${device.nickname}`);
822
- const accessory = new this.api.platformAccessory(device.nickname, uuid);
823
- accessory.context.device = device;
824
- accessory.context = { device: { brand: 'GE', ...details, ...features }, userId };
825
- accessory.displayName = await this.validateAndCleanDisplayName(device.nickname, 'nickname', device.nickname);
826
- accessory.context.device.firmware = device.firmware ?? await this.getVersion();
827
- new SmartHQMicrowave(this, accessory, device);
828
- this.debugLog(`${device.nickname} uuid: ${device.applianceId}`);
822
+ else if (!deviceData.hide_device && !existingAccessory) {
823
+ this.infoLog(`[${protocol}] Adding new accessory: ${deviceData.nickname}`);
824
+ const accessory = new this.api.platformAccessory(deviceData.nickname, uuid);
825
+ accessory.context.device = deviceData;
826
+ accessory.context = { device: deviceData, userId };
827
+ accessory.displayName = await this.validateAndCleanDisplayName(deviceData.nickname, 'nickname', deviceData.nickname);
828
+ accessory.context.device.firmware = deviceData.firmware ?? await this.getVersion();
829
+ new SmartHQMicrowave(this, accessory, deviceData);
830
+ this.debugLog(`${deviceData.nickname} uuid: ${deviceData.applianceId}`);
829
831
  this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory]);
830
832
  this.accessories.push(accessory);
831
833
  }
832
834
  else {
833
- this.debugErrorLog(`Unable to Register new device: ${JSON.stringify(device.nickname)}`);
835
+ this.debugErrorLog(`Unable to Register new device: ${JSON.stringify(deviceData.nickname)}`);
834
836
  }
835
837
  }
836
838
  async createSmartHQCoffeeMaker(userId, device, details, features) {