@switchbot/homebridge-switchbot 3.5.0-beta.25 → 3.5.0-beta.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +17 -14
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.js +13 -13
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.js +3 -3
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.js +3 -3
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.js +5 -5
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +12 -12
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +6 -6
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.js +4 -4
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.js +5 -5
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.js +3 -3
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.js +6 -6
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.js +5 -5
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.js +5 -5
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.js +5 -6
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.js +3 -3
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.js +4 -4
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/device/waterdetector.d.ts.map +1 -1
- package/dist/device/waterdetector.js +9 -16
- package/dist/device/waterdetector.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts +4 -14
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +226 -234
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +3 -6
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +65 -56
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts +2 -3
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +24 -27
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +2 -7
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +57 -61
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/irdevice.js +1 -1
- package/dist/irdevice/irdevice.js.map +1 -1
- package/dist/irdevice/light.d.ts +1 -1
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +13 -15
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.js +51 -50
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.js +2 -2
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +1 -1
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.js +1 -1
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +22 -2
- package/dist/platform.js.map +1 -1
- package/package.json +2 -2
- package/src/custom.d.ts +1 -0
- package/src/device/blindtilt.ts +20 -18
- package/src/device/bot.ts +14 -14
- package/src/device/ceilinglight.ts +4 -4
- package/src/device/colorbulb.ts +4 -4
- package/src/device/contact.ts +6 -6
- package/src/device/curtain.ts +14 -13
- package/src/device/hub.ts +7 -6
- package/src/device/humidifier.ts +5 -5
- package/src/device/iosensor.ts +6 -6
- package/src/device/lightstrip.ts +4 -4
- package/src/device/lock.ts +7 -7
- package/src/device/meter.ts +6 -6
- package/src/device/meterplus.ts +6 -6
- package/src/device/motion.ts +6 -6
- package/src/device/plug.ts +4 -4
- package/src/device/robotvacuumcleaner.ts +5 -5
- package/src/device/waterdetector.ts +9 -17
- package/src/irdevice/airconditioner.ts +239 -238
- package/src/irdevice/airpurifier.ts +75 -56
- package/src/irdevice/camera.ts +27 -27
- package/src/irdevice/fan.ts +63 -63
- package/src/irdevice/irdevice.ts +1 -1
- package/src/irdevice/light.ts +17 -15
- package/src/irdevice/other.ts +51 -51
- package/src/irdevice/tv.ts +2 -2
- package/src/irdevice/vacuumcleaner.ts +1 -1
- package/src/irdevice/waterheater.ts +1 -1
- package/src/platform.ts +21 -5
package/src/irdevice/other.ts
CHANGED
|
@@ -14,7 +14,7 @@ import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
|
14
14
|
* Each accessory may expose multiple services of different service types.
|
|
15
15
|
*/
|
|
16
16
|
export class Others extends irdeviceBase {
|
|
17
|
-
|
|
17
|
+
// Services
|
|
18
18
|
private Switch?: {
|
|
19
19
|
Service: Service;
|
|
20
20
|
On: CharacteristicValue;
|
|
@@ -82,8 +82,8 @@ export class Others extends irdeviceBase {
|
|
|
82
82
|
if (this.otherDeviceType === 'switch') {
|
|
83
83
|
// Initialize Switch property
|
|
84
84
|
this.Switch = {
|
|
85
|
-
Service: accessory.
|
|
86
|
-
On: accessory.context.On ||
|
|
85
|
+
Service: accessory.getService(this.hap.Service.Switch)!,
|
|
86
|
+
On: accessory.context.On || false,
|
|
87
87
|
};
|
|
88
88
|
this.removeFanService(accessory);
|
|
89
89
|
this.removeLockService(accessory);
|
|
@@ -106,8 +106,8 @@ export class Others extends irdeviceBase {
|
|
|
106
106
|
} else if (this.otherDeviceType === 'garagedoor') {
|
|
107
107
|
// Initialize Garage Door property
|
|
108
108
|
this.GarageDoor = {
|
|
109
|
-
Service: accessory.
|
|
110
|
-
On: accessory.context.On ||
|
|
109
|
+
Service: accessory.getService(this.hap.Service.GarageDoorOpener)!,
|
|
110
|
+
On: accessory.context.On || false,
|
|
111
111
|
};
|
|
112
112
|
this.removeFanService(accessory);
|
|
113
113
|
this.removeLockService(accessory);
|
|
@@ -131,8 +131,8 @@ export class Others extends irdeviceBase {
|
|
|
131
131
|
} else if (this.otherDeviceType === 'door') {
|
|
132
132
|
// Initialize Door property
|
|
133
133
|
this.Door = {
|
|
134
|
-
Service: accessory.
|
|
135
|
-
On: accessory.context.On ||
|
|
134
|
+
Service: accessory.getService(this.hap.Service.Door)!,
|
|
135
|
+
On: accessory.context.On || false,
|
|
136
136
|
};
|
|
137
137
|
this.removeFanService(accessory);
|
|
138
138
|
this.removeLockService(accessory);
|
|
@@ -164,8 +164,8 @@ export class Others extends irdeviceBase {
|
|
|
164
164
|
} else if (this.otherDeviceType === 'window') {
|
|
165
165
|
// Initialize Window property
|
|
166
166
|
this.Window = {
|
|
167
|
-
Service: accessory.
|
|
168
|
-
On: accessory.context.On ||
|
|
167
|
+
Service: accessory.getService(this.hap.Service.Window)!,
|
|
168
|
+
On: accessory.context.On || false,
|
|
169
169
|
};
|
|
170
170
|
this.removeFanService(accessory);
|
|
171
171
|
this.removeLockService(accessory);
|
|
@@ -197,8 +197,8 @@ export class Others extends irdeviceBase {
|
|
|
197
197
|
} else if (this.otherDeviceType === 'windowcovering') {
|
|
198
198
|
// Initialize WindowCovering property
|
|
199
199
|
this.WindowCovering = {
|
|
200
|
-
Service: accessory.
|
|
201
|
-
On: accessory.context.On ||
|
|
200
|
+
Service: accessory.getService(this.hap.Service.WindowCovering)!,
|
|
201
|
+
On: accessory.context.On || false,
|
|
202
202
|
};
|
|
203
203
|
this.removeFanService(accessory);
|
|
204
204
|
this.removeLockService(accessory);
|
|
@@ -230,8 +230,8 @@ export class Others extends irdeviceBase {
|
|
|
230
230
|
} else if (this.otherDeviceType === 'lock') {
|
|
231
231
|
// Initialize Lock property
|
|
232
232
|
this.Lock = {
|
|
233
|
-
Service: accessory.
|
|
234
|
-
On: accessory.context.On ||
|
|
233
|
+
Service: accessory.getService(this.hap.Service.LockMechanism)!,
|
|
234
|
+
On: accessory.context.On || false,
|
|
235
235
|
};
|
|
236
236
|
this.removeFanService(accessory);
|
|
237
237
|
this.removeDoorService(accessory);
|
|
@@ -254,8 +254,8 @@ export class Others extends irdeviceBase {
|
|
|
254
254
|
} else if (this.otherDeviceType === 'faucet') {
|
|
255
255
|
// Initialize Faucet property
|
|
256
256
|
this.Faucet = {
|
|
257
|
-
Service: accessory.
|
|
258
|
-
On: accessory.context.On ||
|
|
257
|
+
Service: accessory.getService(this.hap.Service.Faucet)!,
|
|
258
|
+
On: accessory.context.On || false,
|
|
259
259
|
};
|
|
260
260
|
this.removeFanService(accessory);
|
|
261
261
|
this.removeLockService(accessory);
|
|
@@ -278,8 +278,8 @@ export class Others extends irdeviceBase {
|
|
|
278
278
|
} else if (this.otherDeviceType === 'fan') {
|
|
279
279
|
// Initialize Fan property
|
|
280
280
|
this.Fan = {
|
|
281
|
-
Service: accessory.
|
|
282
|
-
On: accessory.context.On ||
|
|
281
|
+
Service: accessory.getService(this.hap.Service.Fanv2)!,
|
|
282
|
+
On: accessory.context.On || false,
|
|
283
283
|
};
|
|
284
284
|
this.removeLockService(accessory);
|
|
285
285
|
this.removeDoorService(accessory);
|
|
@@ -302,8 +302,8 @@ export class Others extends irdeviceBase {
|
|
|
302
302
|
} else if (this.otherDeviceType === 'stateful') {
|
|
303
303
|
// Initialize StatefulProgrammableSwitch property
|
|
304
304
|
this.StatefulProgrammableSwitch = {
|
|
305
|
-
Service: accessory.
|
|
306
|
-
On: accessory.context.On ||
|
|
305
|
+
Service: accessory.getService(this.hap.Service.StatefulProgrammableSwitch)!,
|
|
306
|
+
On: accessory.context.On || false,
|
|
307
307
|
};
|
|
308
308
|
this.removeFanService(accessory);
|
|
309
309
|
this.removeLockService(accessory);
|
|
@@ -328,8 +328,8 @@ export class Others extends irdeviceBase {
|
|
|
328
328
|
} else {
|
|
329
329
|
// Initialize Outlet property
|
|
330
330
|
this.Outlet = {
|
|
331
|
-
Service: accessory.
|
|
332
|
-
On: accessory.context.On ||
|
|
331
|
+
Service: accessory.getService(this.hap.Service.Outlet)!,
|
|
332
|
+
On: accessory.context.On || false,
|
|
333
333
|
};
|
|
334
334
|
this.removeFanService(accessory);
|
|
335
335
|
this.removeLockService(accessory);
|
|
@@ -700,92 +700,92 @@ export class Others extends irdeviceBase {
|
|
|
700
700
|
|
|
701
701
|
async removeOutletService(accessory: PlatformAccessory): Promise<void> {
|
|
702
702
|
// If Outlet.Service still present, then remove first
|
|
703
|
+
if (this.Outlet?.Service) {
|
|
703
704
|
this.Outlet!.Service = this.accessory.getService(this.hap.Service.Outlet) as Service;
|
|
704
|
-
|
|
705
|
-
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Outlet Service`);
|
|
706
|
-
}
|
|
705
|
+
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Outlet Service`);
|
|
707
706
|
accessory.removeService(this.Outlet!.Service);
|
|
707
|
+
}
|
|
708
708
|
}
|
|
709
709
|
|
|
710
710
|
async removeGarageDoorService(accessory: PlatformAccessory): Promise<void> {
|
|
711
711
|
// If GarageDoor.Service still present, then remove first
|
|
712
|
+
if (this.GarageDoor?.Service) {
|
|
712
713
|
this.GarageDoor!.Service = this.accessory.getService(this.hap.Service.GarageDoorOpener) as Service;
|
|
713
|
-
|
|
714
|
-
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Garage Door Service`);
|
|
715
|
-
}
|
|
714
|
+
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Garage Door Service`);
|
|
716
715
|
accessory.removeService(this.GarageDoor!.Service);
|
|
716
|
+
}
|
|
717
717
|
}
|
|
718
718
|
|
|
719
719
|
async removeDoorService(accessory: PlatformAccessory): Promise<void> {
|
|
720
720
|
// If Door.Service still present, then remove first
|
|
721
|
+
if (this.Door?.Service) {
|
|
721
722
|
this.Door!.Service = this.accessory.getService(this.hap.Service.Door) as Service;
|
|
722
|
-
|
|
723
|
-
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Door Service`);
|
|
724
|
-
}
|
|
723
|
+
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Door Service`);
|
|
725
724
|
accessory.removeService(this.Door!.Service);
|
|
725
|
+
}
|
|
726
726
|
}
|
|
727
727
|
|
|
728
728
|
async removeLockService(accessory: PlatformAccessory): Promise<void> {
|
|
729
729
|
// If Lock.Service still present, then remove first
|
|
730
|
+
if (this.Lock?.Service) {
|
|
730
731
|
this.Lock!.Service = this.accessory.getService(this.hap.Service.LockMechanism) as Service;
|
|
731
|
-
|
|
732
|
-
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Lock Service`);
|
|
733
|
-
}
|
|
732
|
+
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Lock Service`);
|
|
734
733
|
accessory.removeService(this.Lock!.Service);
|
|
734
|
+
}
|
|
735
735
|
}
|
|
736
736
|
|
|
737
737
|
async removeFaucetService(accessory: PlatformAccessory): Promise<void> {
|
|
738
738
|
// If Faucet.Service still present, then remove first
|
|
739
|
+
if (this.Faucet?.Service) {
|
|
739
740
|
this.Faucet!.Service = this.accessory.getService(this.hap.Service.Faucet) as Service;
|
|
740
|
-
|
|
741
|
-
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Faucet Service`);
|
|
742
|
-
}
|
|
741
|
+
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Faucet Service`);
|
|
743
742
|
accessory.removeService(this.Faucet!.Service);
|
|
743
|
+
}
|
|
744
744
|
}
|
|
745
745
|
|
|
746
746
|
async removeFanService(accessory: PlatformAccessory): Promise<void> {
|
|
747
747
|
// If Fan Service still present, then remove first
|
|
748
|
+
if (this.Fan?.Service) {
|
|
748
749
|
this.Fan!.Service = this.accessory.getService(this.hap.Service.Fan) as Service;
|
|
749
|
-
|
|
750
|
-
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Fan Service`);
|
|
751
|
-
}
|
|
750
|
+
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Fan Service`);
|
|
752
751
|
accessory.removeService(this.Fan!.Service);
|
|
752
|
+
}
|
|
753
753
|
}
|
|
754
754
|
|
|
755
755
|
async removeWindowService(accessory: PlatformAccessory): Promise<void> {
|
|
756
756
|
// If Window.Service still present, then remove first
|
|
757
|
+
if (this.Window?.Service) {
|
|
757
758
|
this.Window!.Service = this.accessory.getService(this.hap.Service.Window) as Service;
|
|
758
|
-
|
|
759
|
-
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Window Service`);
|
|
760
|
-
}
|
|
759
|
+
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Window Service`);
|
|
761
760
|
accessory.removeService(this.Window!.Service);
|
|
761
|
+
}
|
|
762
762
|
}
|
|
763
763
|
|
|
764
764
|
async removeWindowCoveringService(accessory: PlatformAccessory): Promise<void> {
|
|
765
765
|
// If WindowCovering.Service still present, then remove first
|
|
766
|
+
if (this.WindowCovering?.Service) {
|
|
766
767
|
this.WindowCovering!.Service = this.accessory.getService(this.hap.Service.WindowCovering) as Service;
|
|
767
|
-
|
|
768
|
-
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Window Covering Service`);
|
|
769
|
-
}
|
|
768
|
+
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Window Covering Service`);
|
|
770
769
|
accessory.removeService(this.WindowCovering!.Service);
|
|
770
|
+
}
|
|
771
771
|
}
|
|
772
772
|
|
|
773
773
|
async removeStatefulProgrammableSwitchService(accessory: PlatformAccessory): Promise<void> {
|
|
774
774
|
// If StatefulProgrammableSwitch.Service still present, then remove first
|
|
775
|
+
if (this.StatefulProgrammableSwitch?.Service) {
|
|
775
776
|
this.StatefulProgrammableSwitch!.Service = this.accessory.getService(this.hap.Service.StatefulProgrammableSwitch) as Service;
|
|
776
|
-
|
|
777
|
-
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Stateful Programmable Switch Service`);
|
|
778
|
-
}
|
|
777
|
+
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Stateful Programmable Switch Service`);
|
|
779
778
|
accessory.removeService(this.StatefulProgrammableSwitch!.Service);
|
|
779
|
+
}
|
|
780
780
|
}
|
|
781
781
|
|
|
782
782
|
async removeSwitchService(accessory: PlatformAccessory): Promise<void> {
|
|
783
783
|
// If Switch.Service still present, then remove first
|
|
784
|
+
if (this.Switch?.Service) {
|
|
784
785
|
this.Switch!.Service = this.accessory.getService(this.hap.Service.Switch) as Service;
|
|
785
|
-
|
|
786
|
-
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Switch Service`);
|
|
787
|
-
}
|
|
786
|
+
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Switch Service`);
|
|
788
787
|
accessory.removeService(this.Switch!.Service);
|
|
788
|
+
}
|
|
789
789
|
}
|
|
790
790
|
|
|
791
791
|
async getOtherConfigSettings(device: irdevice & irDevicesConfig): Promise<void> {
|
package/src/irdevice/tv.ts
CHANGED
|
@@ -41,7 +41,7 @@ export class TV extends irdeviceBase {
|
|
|
41
41
|
|
|
42
42
|
// Initialize Television property
|
|
43
43
|
this.Television = {
|
|
44
|
-
Service: accessory.
|
|
44
|
+
Service: accessory.getService(this.hap.Service.Television)!,
|
|
45
45
|
Active: accessory.context.Active || this.hap.Characteristic.Active.INACTIVE,
|
|
46
46
|
ActiveIdentifier: accessory.context.ActiveIdentifier || 1,
|
|
47
47
|
SleepDiscoveryMode: accessory.context.SleepDiscoveryMode || this.hap.Characteristic.SleepDiscoveryMode.ALWAYS_DISCOVERABLE,
|
|
@@ -50,7 +50,7 @@ export class TV extends irdeviceBase {
|
|
|
50
50
|
|
|
51
51
|
// Initialize TelevisionSpeaker property
|
|
52
52
|
this.TelevisionSpeaker = {
|
|
53
|
-
Service: accessory.
|
|
53
|
+
Service: accessory.getService(this.hap.Service.TelevisionSpeaker)!,
|
|
54
54
|
Active: accessory.context.Active || false,
|
|
55
55
|
VolumeControlType: accessory.context.VolumeControlType || this.hap.Characteristic.VolumeControlType.ABSOLUTE,
|
|
56
56
|
VolumeSelector: accessory.context.VolumeSelector || this.hap.Characteristic.VolumeSelector.INCREMENT,
|
|
@@ -29,7 +29,7 @@ export class VacuumCleaner extends irdeviceBase {
|
|
|
29
29
|
|
|
30
30
|
// Initialize Switch property
|
|
31
31
|
this.Switch = {
|
|
32
|
-
Service: accessory.
|
|
32
|
+
Service: accessory.getService(this.hap.Service.Switch)!,
|
|
33
33
|
On: accessory.context.On || false,
|
|
34
34
|
};
|
|
35
35
|
|
|
@@ -29,7 +29,7 @@ export class WaterHeater extends irdeviceBase {
|
|
|
29
29
|
|
|
30
30
|
// Initialize Valve property
|
|
31
31
|
this.Valve = {
|
|
32
|
-
Service: accessory.
|
|
32
|
+
Service: accessory.getService(this.hap.Service.Valve)!,
|
|
33
33
|
Active: accessory.context.Active || this.hap.Characteristic.Active.INACTIVE,
|
|
34
34
|
};
|
|
35
35
|
|
package/src/platform.ts
CHANGED
|
@@ -39,12 +39,10 @@ import fakegato from 'fakegato-history';
|
|
|
39
39
|
import asyncmqtt from 'async-mqtt';
|
|
40
40
|
import crypto, { randomUUID } from 'crypto';
|
|
41
41
|
import { readFileSync, writeFileSync } from 'fs';
|
|
42
|
-
import
|
|
42
|
+
import { EveHomeKitTypes } from 'homebridge-lib/EveHomeKitTypes';
|
|
43
43
|
import { UrlObject } from 'url';
|
|
44
44
|
import { sleep } from './utils.js';
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
48
46
|
/**
|
|
49
47
|
* HomebridgePlatform
|
|
50
48
|
* This class is the main constructor for your plugin, this is where you should
|
|
@@ -108,7 +106,6 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
108
106
|
}
|
|
109
107
|
|
|
110
108
|
// import fakegato-history module and EVE characteristics
|
|
111
|
-
const { EveHomeKitTypes } = hbLib;
|
|
112
109
|
this.fakegatoAPI = fakegato(api);
|
|
113
110
|
this.eve = new EveHomeKitTypes(api);
|
|
114
111
|
|
|
@@ -388,7 +385,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
388
385
|
}
|
|
389
386
|
|
|
390
387
|
if (!this.config.options.maxRetries) {
|
|
391
|
-
this.config.options
|
|
388
|
+
this.config.options.maxRetries = 5;
|
|
392
389
|
this.debugWarnLog('Using Default Max Retries.');
|
|
393
390
|
} else {
|
|
394
391
|
this.maxRetries = this.config.options.maxRetries;
|
|
@@ -514,6 +511,9 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
514
511
|
let retryCount = 0;
|
|
515
512
|
const maxRetries = this.maxRetries; // Maximum number of retries
|
|
516
513
|
const delayBetweenRetries = this.delayBetweenRetries; // Delay between retries in milliseconds
|
|
514
|
+
this.debugWarnLog(`Retry Count: ${retryCount}`);
|
|
515
|
+
this.debugWarnLog(`Max Retries: ${maxRetries}`);
|
|
516
|
+
this.debugWarnLog(`Delay Between Retries: ${delayBetweenRetries}`);
|
|
517
517
|
while (retryCount < maxRetries) {
|
|
518
518
|
try {
|
|
519
519
|
const { body, statusCode } = await request(Devices, {
|
|
@@ -2719,6 +2719,22 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2719
2719
|
if (this.config.options.pushRate) {
|
|
2720
2720
|
platformConfig.pushRate = this.config.options.pushRate;
|
|
2721
2721
|
}
|
|
2722
|
+
if (this.config.options.maxRetries) {
|
|
2723
|
+
this.maxRetries = this.config.options.maxRetries;
|
|
2724
|
+
platformConfig.maxRetries = this.config.options.maxRetries;
|
|
2725
|
+
} else {
|
|
2726
|
+
this.maxRetries = 3;
|
|
2727
|
+
this.debugWarnLog('Using Default Max Retries');
|
|
2728
|
+
platformConfig.maxRetries = this.maxRetries;
|
|
2729
|
+
}
|
|
2730
|
+
if (this.config.options.delayBetweenRetries) {
|
|
2731
|
+
this.delayBetweenRetries = this.config.options.delayBetweenRetries * 1000;
|
|
2732
|
+
platformConfig.delayBetweenRetries = this.config.options.delayBetweenRetries;
|
|
2733
|
+
} else {
|
|
2734
|
+
this.delayBetweenRetries = 3000;
|
|
2735
|
+
this.debugWarnLog('Using Default Delay Between Retries');
|
|
2736
|
+
platformConfig.delayBetweenRetries = this.delayBetweenRetries / 1000;
|
|
2737
|
+
}
|
|
2722
2738
|
if (Object.entries(platformConfig).length !== 0) {
|
|
2723
2739
|
this.debugLog(`Platform Config: ${JSON.stringify(platformConfig)}`);
|
|
2724
2740
|
}
|