@switchbot/homebridge-switchbot 1.2.1-beta.3 → 1.2.1

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 (84) hide show
  1. package/CHANGELOG.md +4 -2
  2. package/config.schema.json +1 -1
  3. package/dist/devices/bots.d.ts +2 -2
  4. package/dist/devices/bots.d.ts.map +1 -1
  5. package/dist/devices/bots.js +11 -9
  6. package/dist/devices/bots.js.map +1 -1
  7. package/dist/devices/colorbulb.d.ts +2 -2
  8. package/dist/devices/colorbulb.d.ts.map +1 -1
  9. package/dist/devices/colorbulb.js.map +1 -1
  10. package/dist/devices/contact.d.ts +2 -2
  11. package/dist/devices/contact.d.ts.map +1 -1
  12. package/dist/devices/contact.js +6 -6
  13. package/dist/devices/contact.js.map +1 -1
  14. package/dist/devices/curtains.d.ts +2 -2
  15. package/dist/devices/curtains.d.ts.map +1 -1
  16. package/dist/devices/curtains.js +6 -6
  17. package/dist/devices/curtains.js.map +1 -1
  18. package/dist/devices/humidifiers.d.ts +2 -2
  19. package/dist/devices/humidifiers.d.ts.map +1 -1
  20. package/dist/devices/humidifiers.js +6 -6
  21. package/dist/devices/humidifiers.js.map +1 -1
  22. package/dist/devices/indoorcam.d.ts +2 -2
  23. package/dist/devices/indoorcam.d.ts.map +1 -1
  24. package/dist/devices/indoorcam.js.map +1 -1
  25. package/dist/devices/meters.d.ts +2 -2
  26. package/dist/devices/meters.d.ts.map +1 -1
  27. package/dist/devices/meters.js +24 -10
  28. package/dist/devices/meters.js.map +1 -1
  29. package/dist/devices/motion.d.ts +2 -2
  30. package/dist/devices/motion.d.ts.map +1 -1
  31. package/dist/devices/motion.js +6 -6
  32. package/dist/devices/motion.js.map +1 -1
  33. package/dist/devices/plugs.d.ts +2 -2
  34. package/dist/devices/plugs.d.ts.map +1 -1
  35. package/dist/devices/plugs.js.map +1 -1
  36. package/dist/irdevices/airconditioners.d.ts +1 -1
  37. package/dist/irdevices/airconditioners.d.ts.map +1 -1
  38. package/dist/irdevices/airconditioners.js.map +1 -1
  39. package/dist/irdevices/airpurifiers.d.ts +1 -1
  40. package/dist/irdevices/airpurifiers.d.ts.map +1 -1
  41. package/dist/irdevices/airpurifiers.js.map +1 -1
  42. package/dist/irdevices/cameras.d.ts +1 -1
  43. package/dist/irdevices/cameras.d.ts.map +1 -1
  44. package/dist/irdevices/cameras.js.map +1 -1
  45. package/dist/irdevices/fans.d.ts +1 -1
  46. package/dist/irdevices/fans.d.ts.map +1 -1
  47. package/dist/irdevices/lights.d.ts +1 -1
  48. package/dist/irdevices/lights.d.ts.map +1 -1
  49. package/dist/irdevices/lights.js.map +1 -1
  50. package/dist/irdevices/others.d.ts +1 -1
  51. package/dist/irdevices/others.d.ts.map +1 -1
  52. package/dist/irdevices/others.js.map +1 -1
  53. package/dist/irdevices/tvs.d.ts +1 -1
  54. package/dist/irdevices/tvs.d.ts.map +1 -1
  55. package/dist/irdevices/vacuumcleaners.d.ts +1 -1
  56. package/dist/irdevices/vacuumcleaners.d.ts.map +1 -1
  57. package/dist/irdevices/vacuumcleaners.js.map +1 -1
  58. package/dist/irdevices/waterheaters.d.ts +1 -1
  59. package/dist/irdevices/waterheaters.d.ts.map +1 -1
  60. package/dist/irdevices/waterheaters.js.map +1 -1
  61. package/dist/platform.d.ts +1 -1
  62. package/dist/platform.d.ts.map +1 -1
  63. package/dist/platform.js +31 -27
  64. package/dist/platform.js.map +1 -1
  65. package/package.json +66 -66
  66. package/src/devices/bots.ts +10 -11
  67. package/src/devices/colorbulb.ts +3 -3
  68. package/src/devices/contact.ts +4 -7
  69. package/src/devices/curtains.ts +6 -8
  70. package/src/devices/humidifiers.ts +5 -8
  71. package/src/devices/indoorcam.ts +3 -3
  72. package/src/devices/meters.ts +20 -11
  73. package/src/devices/motion.ts +4 -7
  74. package/src/devices/plugs.ts +4 -3
  75. package/src/irdevices/airconditioners.ts +1 -1
  76. package/src/irdevices/airpurifiers.ts +1 -1
  77. package/src/irdevices/cameras.ts +1 -1
  78. package/src/irdevices/fans.ts +1 -1
  79. package/src/irdevices/lights.ts +1 -1
  80. package/src/irdevices/others.ts +1 -1
  81. package/src/irdevices/tvs.ts +1 -1
  82. package/src/irdevices/vacuumcleaners.ts +1 -1
  83. package/src/irdevices/waterheaters.ts +1 -1
  84. package/src/platform.ts +33 -37
@@ -1,7 +1,8 @@
1
- import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge';
2
- import { SwitchBotPlatform } from '../platform';
1
+ import Switchbot from 'node-switchbot';
3
2
  import { interval, Subject } from 'rxjs';
4
3
  import { skipWhile } from 'rxjs/operators';
4
+ import { SwitchBotPlatform } from '../platform';
5
+ import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge';
5
6
  import { DeviceURL, device, devicesConfig, serviceData, switchbot, deviceStatusResponse } from '../settings';
6
7
 
7
8
  /**
@@ -160,12 +161,8 @@ export class Motion {
160
161
  }
161
162
 
162
163
  private connectBLE() {
163
- // eslint-disable-next-line @typescript-eslint/no-var-requires
164
- const Switchbot = require('node-switchbot');
165
164
  const switchbot = new Switchbot();
166
- const colon = this.device.deviceId!.match(/.{1,2}/g);
167
- const bleMac = colon!.join(':'); //returns 1A:23:B4:56:78:9A;
168
- this.device.bleMac = bleMac.toLowerCase();
165
+ this.device.bleMac = ((this.device.deviceId!.match(/.{1,2}/g))!.join(':')).toLowerCase();
169
166
  this.platform.device(`Motion Sensor: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
170
167
  return switchbot;
171
168
  }
@@ -1,9 +1,10 @@
1
- import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge';
2
- import { SwitchBotPlatform } from '../platform';
1
+
2
+ import { AxiosResponse } from 'axios';
3
3
  import { interval, Subject } from 'rxjs';
4
+ import { SwitchBotPlatform } from '../platform';
4
5
  import { debounceTime, skipWhile, tap } from 'rxjs/operators';
6
+ import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge';
5
7
  import { DeviceURL, device, devicesConfig, deviceStatusResponse, payload } from '../settings';
6
- import { AxiosResponse } from 'axios';
7
8
 
8
9
  export class Plug {
9
10
  // Services
@@ -1,7 +1,7 @@
1
1
  import { AxiosResponse } from 'axios';
2
- import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
3
2
  import { SwitchBotPlatform } from '../platform';
4
3
  import { irDevicesConfig, DeviceURL, irdevice, payload } from '../settings';
4
+ import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
5
5
 
6
6
  /**
7
7
  * Platform Accessory
@@ -1,7 +1,7 @@
1
1
  import { AxiosResponse } from 'axios';
2
- import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
3
2
  import { SwitchBotPlatform } from '../platform';
4
3
  import { irDevicesConfig, DeviceURL, irdevice, payload } from '../settings';
4
+ import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
5
5
 
6
6
  /**
7
7
  * Platform Accessory
@@ -1,7 +1,7 @@
1
1
  import { AxiosResponse } from 'axios';
2
- import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
3
2
  import { SwitchBotPlatform } from '../platform';
4
3
  import { irDevicesConfig, DeviceURL, irdevice, payload } from '../settings';
4
+ import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
5
5
 
6
6
  /**
7
7
  * Platform Accessory
@@ -1,6 +1,6 @@
1
1
  import { AxiosResponse } from 'axios';
2
- import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
3
2
  import { SwitchBotPlatform } from '../platform';
3
+ import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
4
4
  import { DeviceURL, irdevice, deviceStatusResponse, irDevicesConfig, payload } from '../settings';
5
5
 
6
6
  /**
@@ -1,7 +1,7 @@
1
1
  import { AxiosResponse } from 'axios';
2
- import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
3
2
  import { SwitchBotPlatform } from '../platform';
4
3
  import { irDevicesConfig, DeviceURL, irdevice, payload } from '../settings';
4
+ import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
5
5
 
6
6
  /**
7
7
  * Platform Accessory
@@ -1,7 +1,7 @@
1
1
  import { AxiosResponse } from 'axios';
2
- import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
3
2
  import { SwitchBotPlatform } from '../platform';
4
3
  import { irDevicesConfig, DeviceURL, irdevice, payload } from '../settings';
4
+ import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
5
5
 
6
6
  /**
7
7
  * Platform Accessory
@@ -1,6 +1,6 @@
1
1
  import { AxiosResponse } from 'axios';
2
- import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
3
2
  import { SwitchBotPlatform } from '../platform';
3
+ import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
4
4
  import { DeviceURL, irdevice, deviceStatusResponse, irDevicesConfig, payload } from '../settings';
5
5
 
6
6
  /**
@@ -1,7 +1,7 @@
1
1
  import { AxiosResponse } from 'axios';
2
- import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
3
2
  import { SwitchBotPlatform } from '../platform';
4
3
  import { irDevicesConfig, DeviceURL, irdevice, payload } from '../settings';
4
+ import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
5
5
 
6
6
  /**
7
7
  * Platform Accessory
@@ -1,7 +1,7 @@
1
1
  import { AxiosResponse } from 'axios';
2
- import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
3
2
  import { SwitchBotPlatform } from '../platform';
4
3
  import { irDevicesConfig, DeviceURL, irdevice, payload } from '../settings';
4
+ import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
5
5
 
6
6
  /**
7
7
  * Platform Accessory
package/src/platform.ts CHANGED
@@ -1,15 +1,4 @@
1
- import { API, DynamicPlatformPlugin, Logger, PlatformAccessory, Service, Characteristic } from 'homebridge';
2
- import axios, { AxiosInstance, AxiosRequestConfig } from 'axios';
3
- import {
4
- PLATFORM_NAME,
5
- PLUGIN_NAME,
6
- DeviceURL,
7
- irdevice,
8
- device,
9
- SwitchBotPlatformConfig,
10
- deviceResponses,
11
- devicesConfig,
12
- } from './settings';
1
+
13
2
  import { Bot } from './devices/bots';
14
3
  import { Plug } from './devices/plugs';
15
4
  import { Meter } from './devices/meters';
@@ -28,6 +17,9 @@ import { AirPurifier } from './irdevices/airpurifiers';
28
17
  import { WaterHeater } from './irdevices/waterheaters';
29
18
  import { VacuumCleaner } from './irdevices/vacuumcleaners';
30
19
  import { AirConditioner } from './irdevices/airconditioners';
20
+ import axios, { AxiosInstance, AxiosRequestConfig } from 'axios';
21
+ import { API, DynamicPlatformPlugin, Logger, PlatformAccessory, Service, Characteristic } from 'homebridge';
22
+ import { PLATFORM_NAME, PLUGIN_NAME, DeviceURL, irdevice, device, SwitchBotPlatformConfig, deviceResponses, devicesConfig } from './settings';
31
23
 
32
24
  /**
33
25
  * HomebridgePlatform
@@ -444,7 +436,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
444
436
  accessory.context.model = device.deviceType;
445
437
  accessory.context.deviceID = device.deviceId;
446
438
  accessory.context.firmwareRevision = this.version;
447
- await this.connectionTypeExistingAccessory(device, accessory);
439
+ await this.connectionTypeNewAccessory(device, accessory);
448
440
  // create the accessory handler for the newly create accessory
449
441
  // this is imported from `platformAccessory.ts`
450
442
  new Humidifier(this, accessory, device);
@@ -501,7 +493,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
501
493
  accessory.context.model = device.deviceType;
502
494
  accessory.context.deviceID = device.deviceId;
503
495
  accessory.context.firmwareRevision = this.version;
504
- await this.connectionTypeExistingAccessory(device, accessory);
496
+ await this.connectionTypeNewAccessory(device, accessory);
505
497
  // accessory.context.firmwareRevision = findaccessories.accessoryAttribute.softwareRevision;
506
498
  // create the accessory handler for the newly create accessory
507
499
  // this is imported from `platformAccessory.ts`
@@ -555,7 +547,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
555
547
  accessory.context.model = device.deviceType;
556
548
  accessory.context.deviceID = device.deviceId;
557
549
  accessory.context.firmwareRevision = this.version;
558
- await this.connectionTypeExistingAccessory(device, accessory);
550
+ await this.connectionTypeNewAccessory(device, accessory);
559
551
  // create the accessory handler for the newly create accessory
560
552
  // this is imported from `platformAccessory.ts`
561
553
  new Meter(this, accessory, device);
@@ -586,6 +578,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
586
578
  existingAccessory.context.deviceID = device.deviceId;
587
579
  existingAccessory.displayName = device.deviceName;
588
580
  existingAccessory.context.firmwareRevision = this.version;
581
+ await this.connectionTypeExistingAccessory(device, existingAccessory);
589
582
  this.api.updatePlatformAccessories([existingAccessory]);
590
583
  // create the accessory handler for the restored accessory
591
584
  // this is imported from `platformAccessory.ts`
@@ -607,6 +600,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
607
600
  accessory.context.model = device.deviceType;
608
601
  accessory.context.deviceID = device.deviceId;
609
602
  accessory.context.firmwareRevision = this.version;
603
+ await this.connectionTypeNewAccessory(device, accessory);
610
604
  // create the accessory handler for the newly create accessory
611
605
  // this is imported from `platformAccessory.ts`
612
606
  new Motion(this, accessory, device);
@@ -637,6 +631,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
637
631
  existingAccessory.context.deviceID = device.deviceId;
638
632
  existingAccessory.displayName = device.deviceName;
639
633
  existingAccessory.context.firmwareRevision = this.version;
634
+ await this.connectionTypeExistingAccessory(device, existingAccessory);
640
635
  this.api.updatePlatformAccessories([existingAccessory]);
641
636
  // create the accessory handler for the restored accessory
642
637
  // this is imported from `platformAccessory.ts`
@@ -658,6 +653,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
658
653
  accessory.context.model = device.deviceType;
659
654
  accessory.context.deviceID = device.deviceId;
660
655
  accessory.context.firmwareRevision = this.version;
656
+ await this.connectionTypeNewAccessory(device, accessory);
661
657
  // create the accessory handler for the newly create accessory
662
658
  // this is imported from `platformAccessory.ts`
663
659
  new Contact(this, accessory, device);
@@ -720,7 +716,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
720
716
  accessory.context.model = device.deviceType;
721
717
  accessory.context.deviceID = device.deviceId;
722
718
  accessory.context.firmwareRevision = this.version;
723
- await this.connectionTypeExistingAccessory(device, accessory);
719
+ await this.connectionTypeNewAccessory(device, accessory);
724
720
  // create the accessory handler for the newly create accessory
725
721
  // this is imported from `platformAccessory.ts`
726
722
  new Curtain(this, accessory, device);
@@ -786,7 +782,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
786
782
  accessory.context.model = device.deviceType;
787
783
  accessory.context.deviceID = device.deviceId;
788
784
  accessory.context.firmwareRevision = this.version;
789
- await this.connectionTypeExistingAccessory(device, accessory);
785
+ await this.connectionTypeNewAccessory(device, accessory);
790
786
  // create the accessory handler for the newly create accessory
791
787
  // this is imported from `platformAccessory.ts`
792
788
  new Plug(this, accessory, device);
@@ -839,7 +835,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
839
835
  accessory.context.model = device.deviceType;
840
836
  accessory.context.deviceID = device.deviceId;
841
837
  accessory.context.firmwareRevision = this.version;
842
- await this.connectionTypeExistingAccessory(device, accessory);
838
+ await this.connectionTypeNewAccessory(device, accessory);
843
839
  // create the accessory handler for the newly create accessory
844
840
  // this is imported from `platformAccessory.ts`
845
841
  new ColorBulb(this, accessory, device);
@@ -892,7 +888,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
892
888
  accessory.context.model = device.deviceType;
893
889
  accessory.context.deviceID = device.deviceId;
894
890
  accessory.context.firmwareRevision = this.version;
895
- await this.connectionTypeExistingAccessory(device, accessory);
891
+ await this.connectionTypeNewAccessory(device, accessory);
896
892
  // create the accessory handler for the newly create accessory
897
893
  // this is imported from `platformAccessory.ts`
898
894
  new IndoorCam(this, accessory, device);
@@ -921,7 +917,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
921
917
  existingAccessory.context.deviceID = device.deviceId;
922
918
  existingAccessory.displayName = device.deviceName;
923
919
  existingAccessory.context.firmwareRevision = this.version;
924
- existingAccessory.context.connectionType = 'OpenAPI';
920
+ await this.connectionTypeExistingAccessory(device, existingAccessory);
925
921
  this.api.updatePlatformAccessories([existingAccessory]);
926
922
  // create the accessory handler for the restored accessory
927
923
  // this is imported from `platformAccessory.ts`
@@ -940,7 +936,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
940
936
  accessory.context.model = device.remoteType;
941
937
  accessory.context.deviceID = device.deviceId;
942
938
  accessory.context.firmwareRevision = this.version;
943
- accessory.context.connectionType = 'OpenAPI';
939
+ await this.connectionTypeNewAccessory(device, accessory);
944
940
  // create the accessory handler for the newly create accessory
945
941
  // this is imported from `platformAccessory.ts`
946
942
  new TV(this, accessory, device);
@@ -976,7 +972,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
976
972
  existingAccessory.context.deviceID = device.deviceId;
977
973
  existingAccessory.displayName = device.deviceName;
978
974
  existingAccessory.context.firmwareRevision = this.version;
979
- existingAccessory.context.connectionType = 'OpenAPI';
975
+ await this.connectionTypeExistingAccessory(device, existingAccessory);
980
976
  this.api.updatePlatformAccessories([existingAccessory]);
981
977
  // create the accessory handler for the restored accessory
982
978
  // this is imported from `platformAccessory.ts`
@@ -998,7 +994,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
998
994
  accessory.context.model = device.remoteType;
999
995
  accessory.context.deviceID = device.deviceId;
1000
996
  accessory.context.firmwareRevision = this.version;
1001
- accessory.context.connectionType = 'OpenAPI';
997
+ await this.connectionTypeNewAccessory(device, accessory);
1002
998
  // create the accessory handler for the newly create accessory
1003
999
  // this is imported from `platformAccessory.ts`
1004
1000
  new Fan(this, accessory, device);
@@ -1029,7 +1025,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1029
1025
  existingAccessory.context.deviceID = device.deviceId;
1030
1026
  existingAccessory.displayName = device.deviceName;
1031
1027
  existingAccessory.context.firmwareRevision = this.version;
1032
- existingAccessory.context.connectionType = 'OpenAPI';
1028
+ await this.connectionTypeExistingAccessory(device, existingAccessory);
1033
1029
  this.api.updatePlatformAccessories([existingAccessory]);
1034
1030
  // create the accessory handler for the restored accessory
1035
1031
  // this is imported from `platformAccessory.ts`
@@ -1051,7 +1047,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1051
1047
  accessory.context.model = device.remoteType;
1052
1048
  accessory.context.deviceID = device.deviceId;
1053
1049
  accessory.context.firmwareRevision = this.version;
1054
- accessory.context.connectionType = 'OpenAPI';
1050
+ await this.connectionTypeNewAccessory(device, accessory);
1055
1051
  // create the accessory handler for the newly create accessory
1056
1052
  // this is imported from `platformAccessory.ts`
1057
1053
  new Light(this, accessory, device);
@@ -1082,7 +1078,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1082
1078
  existingAccessory.context.deviceID = device.deviceId;
1083
1079
  existingAccessory.displayName = device.deviceName;
1084
1080
  existingAccessory.context.firmwareRevision = this.version;
1085
- existingAccessory.context.connectionType = 'OpenAPI';
1081
+ await this.connectionTypeExistingAccessory(device, existingAccessory);
1086
1082
  this.api.updatePlatformAccessories([existingAccessory]);
1087
1083
  // create the accessory handler for the restored accessory
1088
1084
  // this is imported from `platformAccessory.ts`
@@ -1104,7 +1100,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1104
1100
  accessory.context.model = device.remoteType;
1105
1101
  accessory.context.deviceID = device.deviceId;
1106
1102
  accessory.context.firmwareRevision = this.version;
1107
- accessory.context.connectionType = 'OpenAPI';
1103
+ await this.connectionTypeNewAccessory(device, accessory);
1108
1104
  // create the accessory handler for the newly create accessory
1109
1105
  // this is imported from `platformAccessory.ts`
1110
1106
  new AirConditioner(this, accessory, device);
@@ -1135,7 +1131,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1135
1131
  existingAccessory.context.deviceID = device.deviceId;
1136
1132
  existingAccessory.displayName = device.deviceName;
1137
1133
  existingAccessory.context.firmwareRevision = this.version;
1138
- existingAccessory.context.connectionType = 'OpenAPI';
1134
+ await this.connectionTypeExistingAccessory(device, existingAccessory);
1139
1135
  this.api.updatePlatformAccessories([existingAccessory]);
1140
1136
  // create the accessory handler for the restored accessory
1141
1137
  // this is imported from `platformAccessory.ts`
@@ -1157,7 +1153,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1157
1153
  accessory.context.model = device.remoteType;
1158
1154
  accessory.context.deviceID = device.deviceId;
1159
1155
  accessory.context.firmwareRevision = this.version;
1160
- accessory.context.connectionType = 'OpenAPI';
1156
+ await this.connectionTypeNewAccessory(device, accessory);
1161
1157
  // create the accessory handler for the newly create accessory
1162
1158
  // this is imported from `platformAccessory.ts`
1163
1159
  new AirPurifier(this, accessory, device);
@@ -1188,7 +1184,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1188
1184
  existingAccessory.context.deviceID = device.deviceId;
1189
1185
  existingAccessory.displayName = device.deviceName;
1190
1186
  existingAccessory.context.firmwareRevision = this.version;
1191
- existingAccessory.context.connectionType = 'OpenAPI';
1187
+ await this.connectionTypeExistingAccessory(device, existingAccessory);
1192
1188
  this.api.updatePlatformAccessories([existingAccessory]);
1193
1189
  // create the accessory handler for the restored accessory
1194
1190
  // this is imported from `platformAccessory.ts`
@@ -1210,7 +1206,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1210
1206
  accessory.context.model = device.remoteType;
1211
1207
  accessory.context.deviceID = device.deviceId;
1212
1208
  accessory.context.firmwareRevision = this.version;
1213
- accessory.context.connectionType = 'OpenAPI';
1209
+ await this.connectionTypeNewAccessory(device, accessory);
1214
1210
  // create the accessory handler for the newly create accessory
1215
1211
  // this is imported from `platformAccessory.ts`
1216
1212
  new WaterHeater(this, accessory, device);
@@ -1241,7 +1237,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1241
1237
  existingAccessory.context.deviceID = device.deviceId;
1242
1238
  existingAccessory.displayName = device.deviceName;
1243
1239
  existingAccessory.context.firmwareRevision = this.version;
1244
- existingAccessory.context.connectionType = 'OpenAPI';
1240
+ await this.connectionTypeExistingAccessory(device, existingAccessory);
1245
1241
  this.api.updatePlatformAccessories([existingAccessory]);
1246
1242
  // create the accessory handler for the restored accessory
1247
1243
  // this is imported from `platformAccessory.ts`
@@ -1263,7 +1259,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1263
1259
  accessory.context.model = device.remoteType;
1264
1260
  accessory.context.deviceID = device.deviceId;
1265
1261
  accessory.context.firmwareRevision = this.version;
1266
- accessory.context.connectionType = 'OpenAPI';
1262
+ await this.connectionTypeNewAccessory(device, accessory);
1267
1263
  // create the accessory handler for the newly create accessory
1268
1264
  // this is imported from `platformAccessory.ts`
1269
1265
  new VacuumCleaner(this, accessory, device);
@@ -1294,7 +1290,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1294
1290
  existingAccessory.context.deviceID = device.deviceId;
1295
1291
  existingAccessory.displayName = device.deviceName;
1296
1292
  existingAccessory.context.firmwareRevision = this.version;
1297
- existingAccessory.context.connectionType = 'OpenAPI';
1293
+ await this.connectionTypeExistingAccessory(device, existingAccessory);
1298
1294
  this.api.updatePlatformAccessories([existingAccessory]);
1299
1295
  // create the accessory handler for the restored accessory
1300
1296
  // this is imported from `platformAccessory.ts`
@@ -1316,7 +1312,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1316
1312
  accessory.context.model = device.remoteType;
1317
1313
  accessory.context.deviceID = device.deviceId;
1318
1314
  accessory.context.firmwareRevision = this.version;
1319
- accessory.context.connectionType = 'OpenAPI';
1315
+ await this.connectionTypeNewAccessory(device, accessory);
1320
1316
  // create the accessory handler for the newly create accessory
1321
1317
  // this is imported from `platformAccessory.ts`
1322
1318
  new Camera(this, accessory, device);
@@ -1347,7 +1343,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1347
1343
  existingAccessory.context.deviceID = device.deviceId;
1348
1344
  existingAccessory.displayName = device.deviceName;
1349
1345
  existingAccessory.context.firmwareRevision = this.version;
1350
- existingAccessory.context.connectionType = 'OpenAPI';
1346
+ await this.connectionTypeExistingAccessory(device, existingAccessory);
1351
1347
  this.api.updatePlatformAccessories([existingAccessory]);
1352
1348
  // create the accessory handler for the restored accessory
1353
1349
  // this is imported from `platformAccessory.ts`
@@ -1369,7 +1365,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1369
1365
  accessory.context.model = device.remoteType;
1370
1366
  accessory.context.deviceID = device.deviceId;
1371
1367
  accessory.context.firmwareRevision = this.version;
1372
- accessory.context.connectionType = 'OpenAPI';
1368
+ await this.connectionTypeNewAccessory(device, accessory);
1373
1369
  // create the accessory handler for the newly create accessory
1374
1370
  // this is imported from `platformAccessory.ts`
1375
1371
  new Others(this, accessory, device);