@switchbot/homebridge-switchbot 1.3.1-beta.1 → 1.3.1-beta.13

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 (94) hide show
  1. package/CHANGELOG.md +12 -1
  2. package/config.schema.json +12 -25
  3. package/dist/devices/bots.d.ts +2 -0
  4. package/dist/devices/bots.d.ts.map +1 -1
  5. package/dist/devices/bots.js +136 -95
  6. package/dist/devices/bots.js.map +1 -1
  7. package/dist/devices/colorbulb.d.ts +1 -0
  8. package/dist/devices/colorbulb.d.ts.map +1 -1
  9. package/dist/devices/colorbulb.js +18 -4
  10. package/dist/devices/colorbulb.js.map +1 -1
  11. package/dist/devices/contact.js +1 -1
  12. package/dist/devices/contact.js.map +1 -1
  13. package/dist/devices/curtains.d.ts.map +1 -1
  14. package/dist/devices/curtains.js +6 -1
  15. package/dist/devices/curtains.js.map +1 -1
  16. package/dist/devices/humidifiers.d.ts +1 -0
  17. package/dist/devices/humidifiers.d.ts.map +1 -1
  18. package/dist/devices/humidifiers.js +15 -2
  19. package/dist/devices/humidifiers.js.map +1 -1
  20. package/dist/devices/indoorcam.d.ts.map +1 -1
  21. package/dist/devices/indoorcam.js +12 -1
  22. package/dist/devices/indoorcam.js.map +1 -1
  23. package/dist/devices/meters.d.ts +5 -11
  24. package/dist/devices/meters.d.ts.map +1 -1
  25. package/dist/devices/meters.js +49 -47
  26. package/dist/devices/meters.js.map +1 -1
  27. package/dist/devices/plugs.d.ts +2 -0
  28. package/dist/devices/plugs.d.ts.map +1 -1
  29. package/dist/devices/plugs.js +41 -16
  30. package/dist/devices/plugs.js.map +1 -1
  31. package/dist/irdevices/airconditioners.d.ts +2 -0
  32. package/dist/irdevices/airconditioners.d.ts.map +1 -1
  33. package/dist/irdevices/airconditioners.js +17 -1
  34. package/dist/irdevices/airconditioners.js.map +1 -1
  35. package/dist/irdevices/airpurifiers.d.ts +2 -0
  36. package/dist/irdevices/airpurifiers.d.ts.map +1 -1
  37. package/dist/irdevices/airpurifiers.js +17 -0
  38. package/dist/irdevices/airpurifiers.js.map +1 -1
  39. package/dist/irdevices/cameras.d.ts +1 -0
  40. package/dist/irdevices/cameras.d.ts.map +1 -1
  41. package/dist/irdevices/cameras.js +9 -0
  42. package/dist/irdevices/cameras.js.map +1 -1
  43. package/dist/irdevices/fans.d.ts +1 -0
  44. package/dist/irdevices/fans.d.ts.map +1 -1
  45. package/dist/irdevices/fans.js +9 -0
  46. package/dist/irdevices/fans.js.map +1 -1
  47. package/dist/irdevices/lights.d.ts +1 -0
  48. package/dist/irdevices/lights.d.ts.map +1 -1
  49. package/dist/irdevices/lights.js +9 -0
  50. package/dist/irdevices/lights.js.map +1 -1
  51. package/dist/irdevices/others.d.ts +1 -0
  52. package/dist/irdevices/others.d.ts.map +1 -1
  53. package/dist/irdevices/others.js +9 -0
  54. package/dist/irdevices/others.js.map +1 -1
  55. package/dist/irdevices/tvs.d.ts +1 -0
  56. package/dist/irdevices/tvs.d.ts.map +1 -1
  57. package/dist/irdevices/tvs.js +9 -0
  58. package/dist/irdevices/tvs.js.map +1 -1
  59. package/dist/irdevices/vacuumcleaners.d.ts +1 -0
  60. package/dist/irdevices/vacuumcleaners.d.ts.map +1 -1
  61. package/dist/irdevices/vacuumcleaners.js +9 -0
  62. package/dist/irdevices/vacuumcleaners.js.map +1 -1
  63. package/dist/irdevices/waterheaters.d.ts +1 -0
  64. package/dist/irdevices/waterheaters.d.ts.map +1 -1
  65. package/dist/irdevices/waterheaters.js +9 -0
  66. package/dist/irdevices/waterheaters.js.map +1 -1
  67. package/dist/platform.d.ts +2 -0
  68. package/dist/platform.d.ts.map +1 -1
  69. package/dist/platform.js +106 -20
  70. package/dist/platform.js.map +1 -1
  71. package/dist/settings.d.ts +6 -5
  72. package/dist/settings.d.ts.map +1 -1
  73. package/dist/settings.js.map +1 -1
  74. package/homebridge-ui/public/index.html +5 -1
  75. package/package.json +7 -7
  76. package/src/devices/bots.ts +124 -85
  77. package/src/devices/colorbulb.ts +18 -4
  78. package/src/devices/contact.ts +1 -1
  79. package/src/devices/curtains.ts +7 -2
  80. package/src/devices/humidifiers.ts +17 -3
  81. package/src/devices/indoorcam.ts +13 -2
  82. package/src/devices/meters.ts +50 -48
  83. package/src/devices/plugs.ts +45 -18
  84. package/src/irdevices/airconditioners.ts +17 -1
  85. package/src/irdevices/airpurifiers.ts +18 -0
  86. package/src/irdevices/cameras.ts +10 -0
  87. package/src/irdevices/fans.ts +10 -0
  88. package/src/irdevices/lights.ts +10 -0
  89. package/src/irdevices/others.ts +10 -0
  90. package/src/irdevices/tvs.ts +10 -0
  91. package/src/irdevices/vacuumcleaners.ts +10 -0
  92. package/src/irdevices/waterheaters.ts +10 -0
  93. package/src/platform.ts +104 -20
  94. package/src/settings.ts +7 -5
package/src/platform.ts CHANGED
@@ -267,8 +267,43 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
267
267
  this.log.error('Neither SwitchBot OpenToken or Device Config are not set.');
268
268
  }
269
269
  } catch (e: any) {
270
- this.log.error('Failed to Discover Devices.', JSON.stringify(e.message));
271
- this.debug(JSON.stringify(e));
270
+ if (e.message.includes('400')) {
271
+ this.log.error('Failed to Discover Devices: Bad Request');
272
+ this.debug('The client has issued an invalid request. This is commonly used to specify validation errors in a request payload.');
273
+ } else if (e.message.includes('401')) {
274
+ this.log.error('Failed to Discover Devices: Unauthorized Request');
275
+ this.debug('Authorization for the API is required, but the request has not been authenticated.');
276
+ } else if (e.message.includes('403')) {
277
+ this.log.error('Failed to Discover Devices: Forbidden Request');
278
+ this.debug('The request has been authenticated but does not have appropriate permissions, or a requested resource is not found.');
279
+ } else if (e.message.includes('404')) {
280
+ this.log.error('Failed to Discover Devices: Requst Not Found');
281
+ this.debug('Specifies the requested path does not exist.');
282
+ } else if (e.message.includes('406')) {
283
+ this.log.error('Failed to Discover Devices: Request Not Acceptable');
284
+ this.debug('The client has requested a MIME type via the Accept header for a value not supported by the server.');
285
+ } else if (e.message.includes('415')) {
286
+ this.log.error('Failed to Discover Devices: Unsupported Requst Header');
287
+ this.debug('The client has defined a contentType header that is not supported by the server.');
288
+ } else if (e.message.includes('422')) {
289
+ this.log.error('Failed to Discover Devices: Unprocessable Entity');
290
+ this.debug('The client has made a valid request, but the server cannot process it.'
291
+ + ' This is often used for APIs for which certain limits have been exceeded.');
292
+ } else if (e.message.includes('429')) {
293
+ this.log.error('Failed to Discover Devices: Too Many Requests');
294
+ this.debug('The client has exceeded the number of requests allowed for a given time window.');
295
+ } else if (e.message.includes('500')) {
296
+ this.log.error('Failed to Discover Devices: Internal Server Error');
297
+ this.debug('An unexpected error on the SmartThings servers has occurred. These errors should be rare.');
298
+ } else {
299
+ this.log.error('Failed to Discover Devices');
300
+ }
301
+ if (this.config.options?.debug === 'device') {
302
+ this.log.error(`Failed to Discover Devices, Error Message: ${JSON.stringify(e.message)}`);
303
+ }
304
+ if (this.config.options?.debug === 'debug' || this.debugMode) {
305
+ this.log.error(`Failed to Discover Devices, Error: ${JSON.stringify(e)}`);
306
+ }
272
307
  }
273
308
  }
274
309
 
@@ -422,6 +457,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
422
457
  existingAccessory.context.deviceID = device.deviceId;
423
458
  existingAccessory.displayName = device.deviceName;
424
459
  existingAccessory.context.firmwareRevision = this.version;
460
+ existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
425
461
  await this.connectionTypeExistingAccessory(device, existingAccessory);
426
462
  this.api.updatePlatformAccessories([existingAccessory]);
427
463
  // create the accessory handler for the restored accessory
@@ -444,6 +480,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
444
480
  accessory.context.model = device.deviceType;
445
481
  accessory.context.deviceID = device.deviceId;
446
482
  accessory.context.firmwareRevision = this.version;
483
+ accessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
447
484
  await this.connectionTypeNewAccessory(device, accessory);
448
485
  // create the accessory handler for the newly create accessory
449
486
  // this is imported from `platformAccessory.ts`
@@ -477,6 +514,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
477
514
  existingAccessory.context.deviceID = device.deviceId;
478
515
  existingAccessory.displayName = device.deviceName;
479
516
  existingAccessory.context.firmwareRevision = this.version;
517
+ existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
480
518
  await this.connectionTypeExistingAccessory(device, existingAccessory);
481
519
  this.api.updatePlatformAccessories([existingAccessory]);
482
520
  // create the accessory handler for the restored accessory
@@ -501,6 +539,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
501
539
  accessory.context.model = device.deviceType;
502
540
  accessory.context.deviceID = device.deviceId;
503
541
  accessory.context.firmwareRevision = this.version;
542
+ accessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
504
543
  await this.connectionTypeNewAccessory(device, accessory);
505
544
  // accessory.context.firmwareRevision = findaccessories.accessoryAttribute.softwareRevision;
506
545
  // create the accessory handler for the newly create accessory
@@ -533,6 +572,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
533
572
  existingAccessory.context.deviceID = device.deviceId;
534
573
  existingAccessory.displayName = device.deviceName;
535
574
  existingAccessory.context.firmwareRevision = this.version;
575
+ existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
536
576
  await this.connectionTypeExistingAccessory(device, existingAccessory);
537
577
  this.api.updatePlatformAccessories([existingAccessory]);
538
578
  // create the accessory handler for the restored accessory
@@ -555,6 +595,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
555
595
  accessory.context.model = device.deviceType;
556
596
  accessory.context.deviceID = device.deviceId;
557
597
  accessory.context.firmwareRevision = this.version;
598
+ accessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
558
599
  await this.connectionTypeNewAccessory(device, accessory);
559
600
  // create the accessory handler for the newly create accessory
560
601
  // this is imported from `platformAccessory.ts`
@@ -586,6 +627,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
586
627
  existingAccessory.context.deviceID = device.deviceId;
587
628
  existingAccessory.displayName = device.deviceName;
588
629
  existingAccessory.context.firmwareRevision = this.version;
630
+ existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
589
631
  await this.connectionTypeExistingAccessory(device, existingAccessory);
590
632
  this.api.updatePlatformAccessories([existingAccessory]);
591
633
  // create the accessory handler for the restored accessory
@@ -608,6 +650,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
608
650
  accessory.context.model = device.deviceType;
609
651
  accessory.context.deviceID = device.deviceId;
610
652
  accessory.context.firmwareRevision = this.version;
653
+ accessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
611
654
  await this.connectionTypeNewAccessory(device, accessory);
612
655
  // create the accessory handler for the newly create accessory
613
656
  // this is imported from `platformAccessory.ts`
@@ -639,6 +682,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
639
682
  existingAccessory.context.deviceID = device.deviceId;
640
683
  existingAccessory.displayName = device.deviceName;
641
684
  existingAccessory.context.firmwareRevision = this.version;
685
+ existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
642
686
  await this.connectionTypeExistingAccessory(device, existingAccessory);
643
687
  this.api.updatePlatformAccessories([existingAccessory]);
644
688
  // create the accessory handler for the restored accessory
@@ -661,6 +705,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
661
705
  accessory.context.model = device.deviceType;
662
706
  accessory.context.deviceID = device.deviceId;
663
707
  accessory.context.firmwareRevision = this.version;
708
+ accessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
664
709
  await this.connectionTypeNewAccessory(device, accessory);
665
710
  // create the accessory handler for the newly create accessory
666
711
  // this is imported from `platformAccessory.ts`
@@ -692,6 +737,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
692
737
  existingAccessory.context.deviceID = device.deviceId;
693
738
  existingAccessory.displayName = device.deviceName;
694
739
  existingAccessory.context.firmwareRevision = this.version;
740
+ existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
695
741
  await this.connectionTypeExistingAccessory(device, existingAccessory);
696
742
  this.api.updatePlatformAccessories([existingAccessory]);
697
743
  // create the accessory handler for the restored accessory
@@ -724,6 +770,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
724
770
  accessory.context.model = device.deviceType;
725
771
  accessory.context.deviceID = device.deviceId;
726
772
  accessory.context.firmwareRevision = this.version;
773
+ accessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
727
774
  await this.connectionTypeNewAccessory(device, accessory);
728
775
  // create the accessory handler for the newly create accessory
729
776
  // this is imported from `platformAccessory.ts`
@@ -768,6 +815,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
768
815
  existingAccessory.context.deviceID = device.deviceId;
769
816
  existingAccessory.displayName = device.deviceName;
770
817
  existingAccessory.context.firmwareRevision = this.version;
818
+ existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
771
819
  await this.connectionTypeExistingAccessory(device, existingAccessory);
772
820
  this.api.updatePlatformAccessories([existingAccessory]);
773
821
  // create the accessory handler for the restored accessory
@@ -790,6 +838,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
790
838
  accessory.context.model = device.deviceType;
791
839
  accessory.context.deviceID = device.deviceId;
792
840
  accessory.context.firmwareRevision = this.version;
841
+ accessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
793
842
  await this.connectionTypeNewAccessory(device, accessory);
794
843
  // create the accessory handler for the newly create accessory
795
844
  // this is imported from `platformAccessory.ts`
@@ -821,6 +870,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
821
870
  existingAccessory.context.deviceID = device.deviceId;
822
871
  existingAccessory.displayName = device.deviceName;
823
872
  existingAccessory.context.firmwareRevision = this.version;
873
+ existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
824
874
  await this.connectionTypeExistingAccessory(device, existingAccessory);
825
875
  this.api.updatePlatformAccessories([existingAccessory]);
826
876
  // create the accessory handler for the restored accessory
@@ -843,6 +893,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
843
893
  accessory.context.model = device.deviceType;
844
894
  accessory.context.deviceID = device.deviceId;
845
895
  accessory.context.firmwareRevision = this.version;
896
+ accessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
846
897
  await this.connectionTypeNewAccessory(device, accessory);
847
898
  // create the accessory handler for the newly create accessory
848
899
  // this is imported from `platformAccessory.ts`
@@ -874,6 +925,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
874
925
  existingAccessory.context.deviceID = device.deviceId;
875
926
  existingAccessory.displayName = device.deviceName;
876
927
  existingAccessory.context.firmwareRevision = this.version;
928
+ existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
877
929
  await this.connectionTypeExistingAccessory(device, existingAccessory);
878
930
  this.api.updatePlatformAccessories([existingAccessory]);
879
931
  // create the accessory handler for the restored accessory
@@ -896,6 +948,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
896
948
  accessory.context.model = device.deviceType;
897
949
  accessory.context.deviceID = device.deviceId;
898
950
  accessory.context.firmwareRevision = this.version;
951
+ accessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
899
952
  await this.connectionTypeNewAccessory(device, accessory);
900
953
  // create the accessory handler for the newly create accessory
901
954
  // this is imported from `platformAccessory.ts`
@@ -925,7 +978,8 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
925
978
  existingAccessory.context.deviceID = device.deviceId;
926
979
  existingAccessory.displayName = device.deviceName;
927
980
  existingAccessory.context.firmwareRevision = this.version;
928
- await this.connectionTypeExistingAccessory(device, existingAccessory);
981
+ existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
982
+ await this.connectionTypeExistingIRAccessory(device, existingAccessory);
929
983
  this.api.updatePlatformAccessories([existingAccessory]);
930
984
  // create the accessory handler for the restored accessory
931
985
  // this is imported from `platformAccessory.ts`
@@ -944,7 +998,8 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
944
998
  accessory.context.model = device.remoteType;
945
999
  accessory.context.deviceID = device.deviceId;
946
1000
  accessory.context.firmwareRevision = this.version;
947
- await this.connectionTypeNewAccessory(device, accessory);
1001
+ accessory.context.deviceType = `IR: ${device.remoteType}`;
1002
+ await this.connectionTypeNewIRAccessory(device, accessory);
948
1003
  // create the accessory handler for the newly create accessory
949
1004
  // this is imported from `platformAccessory.ts`
950
1005
  new TV(this, accessory, device);
@@ -980,7 +1035,8 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
980
1035
  existingAccessory.context.deviceID = device.deviceId;
981
1036
  existingAccessory.displayName = device.deviceName;
982
1037
  existingAccessory.context.firmwareRevision = this.version;
983
- await this.connectionTypeExistingAccessory(device, existingAccessory);
1038
+ existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1039
+ await this.connectionTypeExistingIRAccessory(device, existingAccessory);
984
1040
  this.api.updatePlatformAccessories([existingAccessory]);
985
1041
  // create the accessory handler for the restored accessory
986
1042
  // this is imported from `platformAccessory.ts`
@@ -1002,7 +1058,8 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1002
1058
  accessory.context.model = device.remoteType;
1003
1059
  accessory.context.deviceID = device.deviceId;
1004
1060
  accessory.context.firmwareRevision = this.version;
1005
- await this.connectionTypeNewAccessory(device, accessory);
1061
+ accessory.context.deviceType = `IR: ${device.remoteType}`;
1062
+ await this.connectionTypeNewIRAccessory(device, accessory);
1006
1063
  // create the accessory handler for the newly create accessory
1007
1064
  // this is imported from `platformAccessory.ts`
1008
1065
  new Fan(this, accessory, device);
@@ -1033,7 +1090,8 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1033
1090
  existingAccessory.context.deviceID = device.deviceId;
1034
1091
  existingAccessory.displayName = device.deviceName;
1035
1092
  existingAccessory.context.firmwareRevision = this.version;
1036
- await this.connectionTypeExistingAccessory(device, existingAccessory);
1093
+ existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1094
+ await this.connectionTypeExistingIRAccessory(device, existingAccessory);
1037
1095
  this.api.updatePlatformAccessories([existingAccessory]);
1038
1096
  // create the accessory handler for the restored accessory
1039
1097
  // this is imported from `platformAccessory.ts`
@@ -1055,7 +1113,8 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1055
1113
  accessory.context.model = device.remoteType;
1056
1114
  accessory.context.deviceID = device.deviceId;
1057
1115
  accessory.context.firmwareRevision = this.version;
1058
- await this.connectionTypeNewAccessory(device, accessory);
1116
+ accessory.context.deviceType = `IR: ${device.remoteType}`;
1117
+ await this.connectionTypeNewIRAccessory(device, accessory);
1059
1118
  // create the accessory handler for the newly create accessory
1060
1119
  // this is imported from `platformAccessory.ts`
1061
1120
  new Light(this, accessory, device);
@@ -1086,7 +1145,8 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1086
1145
  existingAccessory.context.deviceID = device.deviceId;
1087
1146
  existingAccessory.displayName = device.deviceName;
1088
1147
  existingAccessory.context.firmwareRevision = this.version;
1089
- await this.connectionTypeExistingAccessory(device, existingAccessory);
1148
+ existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1149
+ await this.connectionTypeExistingIRAccessory(device, existingAccessory);
1090
1150
  this.api.updatePlatformAccessories([existingAccessory]);
1091
1151
  // create the accessory handler for the restored accessory
1092
1152
  // this is imported from `platformAccessory.ts`
@@ -1108,7 +1168,8 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1108
1168
  accessory.context.model = device.remoteType;
1109
1169
  accessory.context.deviceID = device.deviceId;
1110
1170
  accessory.context.firmwareRevision = this.version;
1111
- await this.connectionTypeNewAccessory(device, accessory);
1171
+ accessory.context.deviceType = `IR: ${device.remoteType}`;
1172
+ await this.connectionTypeNewIRAccessory(device, accessory);
1112
1173
  // create the accessory handler for the newly create accessory
1113
1174
  // this is imported from `platformAccessory.ts`
1114
1175
  new AirConditioner(this, accessory, device);
@@ -1139,7 +1200,8 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1139
1200
  existingAccessory.context.deviceID = device.deviceId;
1140
1201
  existingAccessory.displayName = device.deviceName;
1141
1202
  existingAccessory.context.firmwareRevision = this.version;
1142
- await this.connectionTypeExistingAccessory(device, existingAccessory);
1203
+ existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1204
+ await this.connectionTypeExistingIRAccessory(device, existingAccessory);
1143
1205
  this.api.updatePlatformAccessories([existingAccessory]);
1144
1206
  // create the accessory handler for the restored accessory
1145
1207
  // this is imported from `platformAccessory.ts`
@@ -1161,7 +1223,8 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1161
1223
  accessory.context.model = device.remoteType;
1162
1224
  accessory.context.deviceID = device.deviceId;
1163
1225
  accessory.context.firmwareRevision = this.version;
1164
- await this.connectionTypeNewAccessory(device, accessory);
1226
+ accessory.context.deviceType = `IR: ${device.remoteType}`;
1227
+ await this.connectionTypeNewIRAccessory(device, accessory);
1165
1228
  // create the accessory handler for the newly create accessory
1166
1229
  // this is imported from `platformAccessory.ts`
1167
1230
  new AirPurifier(this, accessory, device);
@@ -1192,7 +1255,8 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1192
1255
  existingAccessory.context.deviceID = device.deviceId;
1193
1256
  existingAccessory.displayName = device.deviceName;
1194
1257
  existingAccessory.context.firmwareRevision = this.version;
1195
- await this.connectionTypeExistingAccessory(device, existingAccessory);
1258
+ existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1259
+ await this.connectionTypeExistingIRAccessory(device, existingAccessory);
1196
1260
  this.api.updatePlatformAccessories([existingAccessory]);
1197
1261
  // create the accessory handler for the restored accessory
1198
1262
  // this is imported from `platformAccessory.ts`
@@ -1214,7 +1278,8 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1214
1278
  accessory.context.model = device.remoteType;
1215
1279
  accessory.context.deviceID = device.deviceId;
1216
1280
  accessory.context.firmwareRevision = this.version;
1217
- await this.connectionTypeNewAccessory(device, accessory);
1281
+ accessory.context.deviceType = `IR: ${device.remoteType}`;
1282
+ await this.connectionTypeNewIRAccessory(device, accessory);
1218
1283
  // create the accessory handler for the newly create accessory
1219
1284
  // this is imported from `platformAccessory.ts`
1220
1285
  new WaterHeater(this, accessory, device);
@@ -1245,7 +1310,8 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1245
1310
  existingAccessory.context.deviceID = device.deviceId;
1246
1311
  existingAccessory.displayName = device.deviceName;
1247
1312
  existingAccessory.context.firmwareRevision = this.version;
1248
- await this.connectionTypeExistingAccessory(device, existingAccessory);
1313
+ existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1314
+ await this.connectionTypeExistingIRAccessory(device, existingAccessory);
1249
1315
  this.api.updatePlatformAccessories([existingAccessory]);
1250
1316
  // create the accessory handler for the restored accessory
1251
1317
  // this is imported from `platformAccessory.ts`
@@ -1267,7 +1333,8 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1267
1333
  accessory.context.model = device.remoteType;
1268
1334
  accessory.context.deviceID = device.deviceId;
1269
1335
  accessory.context.firmwareRevision = this.version;
1270
- await this.connectionTypeNewAccessory(device, accessory);
1336
+ accessory.context.deviceType = `IR: ${device.remoteType}`;
1337
+ await this.connectionTypeNewIRAccessory(device, accessory);
1271
1338
  // create the accessory handler for the newly create accessory
1272
1339
  // this is imported from `platformAccessory.ts`
1273
1340
  new VacuumCleaner(this, accessory, device);
@@ -1298,7 +1365,8 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1298
1365
  existingAccessory.context.deviceID = device.deviceId;
1299
1366
  existingAccessory.displayName = device.deviceName;
1300
1367
  existingAccessory.context.firmwareRevision = this.version;
1301
- await this.connectionTypeExistingAccessory(device, existingAccessory);
1368
+ existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1369
+ await this.connectionTypeExistingIRAccessory(device, existingAccessory);
1302
1370
  this.api.updatePlatformAccessories([existingAccessory]);
1303
1371
  // create the accessory handler for the restored accessory
1304
1372
  // this is imported from `platformAccessory.ts`
@@ -1320,7 +1388,8 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1320
1388
  accessory.context.model = device.remoteType;
1321
1389
  accessory.context.deviceID = device.deviceId;
1322
1390
  accessory.context.firmwareRevision = this.version;
1323
- await this.connectionTypeNewAccessory(device, accessory);
1391
+ accessory.context.deviceType = `IR: ${device.remoteType}`;
1392
+ await this.connectionTypeNewIRAccessory(device, accessory);
1324
1393
  // create the accessory handler for the newly create accessory
1325
1394
  // this is imported from `platformAccessory.ts`
1326
1395
  new Camera(this, accessory, device);
@@ -1351,7 +1420,8 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1351
1420
  existingAccessory.context.deviceID = device.deviceId;
1352
1421
  existingAccessory.displayName = device.deviceName;
1353
1422
  existingAccessory.context.firmwareRevision = this.version;
1354
- await this.connectionTypeExistingAccessory(device, existingAccessory);
1423
+ existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1424
+ await this.connectionTypeExistingIRAccessory(device, existingAccessory);
1355
1425
  this.api.updatePlatformAccessories([existingAccessory]);
1356
1426
  // create the accessory handler for the restored accessory
1357
1427
  // this is imported from `platformAccessory.ts`
@@ -1373,7 +1443,8 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1373
1443
  accessory.context.model = device.remoteType;
1374
1444
  accessory.context.deviceID = device.deviceId;
1375
1445
  accessory.context.firmwareRevision = this.version;
1376
- await this.connectionTypeNewAccessory(device, accessory);
1446
+ accessory.context.deviceType = `IR: ${device.remoteType}`;
1447
+ await this.connectionTypeNewIRAccessory(device, accessory);
1377
1448
  // create the accessory handler for the newly create accessory
1378
1449
  // this is imported from `platformAccessory.ts`
1379
1450
  new Others(this, accessory, device);
@@ -1408,6 +1479,19 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1408
1479
  }
1409
1480
  }
1410
1481
 
1482
+ public async connectionTypeNewIRAccessory(
1483
+ device: irdevice & devicesConfig,
1484
+ accessory: PlatformAccessory) {
1485
+ accessory.context.connectionType = 'IR wirth OpenAPI';
1486
+ }
1487
+
1488
+ public async connectionTypeExistingIRAccessory(
1489
+ device: irdevice & devicesConfig,
1490
+ existingAccessory: PlatformAccessory,
1491
+ ) {
1492
+ existingAccessory.context.connectionType = 'IR with OpenAPI';
1493
+ }
1494
+
1411
1495
  public unregisterPlatformAccessories(existingAccessory: PlatformAccessory) {
1412
1496
  // remove platform accessories when no longer present
1413
1497
  this.api.unregisterPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [existingAccessory]);
package/src/settings.ts CHANGED
@@ -49,10 +49,10 @@ export interface devicesConfig extends device {
49
49
  colorbulb?: colorbulb;
50
50
  ble?: string;
51
51
  hide_device?: boolean;
52
+ offline?: boolean;
52
53
  }
53
54
 
54
55
  export type meter = {
55
- unit?: number;
56
56
  hide_temperature?: boolean;
57
57
  hide_humidity?: boolean;
58
58
  };
@@ -280,10 +280,7 @@ export type serviceData = {
280
280
  //Humidifier's AutoMode
281
281
  autoMode?: boolean;
282
282
  //Meter Temperature Levels
283
- temperature?: {
284
- c: number,
285
- f: number
286
- };
283
+ temperature?: temperature;
287
284
  // Fahrenheit enabled for Meter
288
285
  fahrenheit: boolean;
289
286
  // Humidity level for Meter
@@ -303,6 +300,11 @@ export type serviceData = {
303
300
  position?: number;
304
301
  };
305
302
 
303
+ export type temperature = {
304
+ c: number;
305
+ f: number;
306
+ };
307
+
306
308
  export type switchbot = {
307
309
  discover: (
308
310
  arg0: