@switchbot/homebridge-switchbot 1.6.2 → 1.6.4-beta.2

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/package.json CHANGED
@@ -1,74 +1,74 @@
1
1
  {
2
- "displayName": "Homebridge SwitchBot",
3
- "name": "@switchbot/homebridge-switchbot",
4
- "version": "1.6.2",
5
- "description": "The [Homebridge](https://homebridge.io) SwitchBot plugin allows you to access your [SwitchBot](https://www.switch-bot.com) device(s) from HomeKit.",
6
- "author": "SwitchBot <support@wondertechlabs.com> (https://github.com/SwitchBot)",
7
- "license": "ISC",
8
- "repository": {
9
- "type": "git",
10
- "url": "git://github.com/OpenWonderLabs/homebridge-switchbot.git"
11
- },
12
- "bugs": {
13
- "url": "https://github.com/OpenWonderLabs/homebridge-switchbot/issues"
14
- },
15
- "engines": {
16
- "homebridge": "^1.3.9",
17
- "node": "^14.18.2 || ^16.13.1"
18
- },
19
- "main": "dist/index.js",
20
- "scripts": {
21
- "check": "npm install && npm outdated",
22
- "update": "ncu -u && npm update && npm install",
23
- "lint": "eslint src/**.ts",
24
- "watch": "npm run build && npm link && nodemon",
25
- "build": "rimraf ./dist && tsc",
26
- "prepublishOnly": "npm run lint && npm run build"
27
- },
28
- "funding": [
29
- {
30
- "type": "Paypal",
31
- "url": "https://paypal.me/donavanbecker"
2
+ "displayName": "Homebridge SwitchBot",
3
+ "name": "@switchbot/homebridge-switchbot",
4
+ "version": "1.6.4-beta.2",
5
+ "description": "The [Homebridge](https://homebridge.io) SwitchBot plugin allows you to access your [SwitchBot](https://www.switch-bot.com) device(s) from HomeKit.",
6
+ "author": "SwitchBot <support@wondertechlabs.com> (https://github.com/SwitchBot)",
7
+ "license": "ISC",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git://github.com/OpenWonderLabs/homebridge-switchbot.git"
32
11
  },
33
- {
34
- "type": "GitHub",
35
- "url": "https://github.com/sponsors/donavanbecker"
12
+ "bugs": {
13
+ "url": "https://github.com/OpenWonderLabs/homebridge-switchbot/issues"
14
+ },
15
+ "engines": {
16
+ "homebridge": "^1.3.9",
17
+ "node": "^14.18.2 || ^16.13.1"
18
+ },
19
+ "main": "dist/index.js",
20
+ "scripts": {
21
+ "check": "npm install && npm outdated",
22
+ "update": "ncu -u && npm update && npm install",
23
+ "lint": "eslint src/**.ts",
24
+ "watch": "npm run build && npm link && nodemon",
25
+ "build": "rimraf ./dist && tsc",
26
+ "prepublishOnly": "npm run lint && npm run build"
27
+ },
28
+ "funding": [
29
+ {
30
+ "type": "Paypal",
31
+ "url": "https://paypal.me/donavanbecker"
32
+ },
33
+ {
34
+ "type": "GitHub",
35
+ "url": "https://github.com/sponsors/donavanbecker"
36
+ }
37
+ ],
38
+ "publishConfig": {
39
+ "access": "public"
40
+ },
41
+ "keywords": [
42
+ "homebridge-plugin",
43
+ "switchbot",
44
+ "humidifier",
45
+ "humidity",
46
+ "temperature",
47
+ "bot",
48
+ "curtains",
49
+ "windows",
50
+ "ble",
51
+ "ir"
52
+ ],
53
+ "dependencies": {
54
+ "@homebridge/plugin-ui-utils": "^0.0.19",
55
+ "axios": "^0.24.0",
56
+ "rxjs": "^7.5.1"
57
+ },
58
+ "devDependencies": {
59
+ "@types/node": "^17.0.7",
60
+ "@typescript-eslint/eslint-plugin": "^5.9.0",
61
+ "@typescript-eslint/parser": "^5.9.0",
62
+ "eslint": "^8.6.0",
63
+ "homebridge": "^1.3.9",
64
+ "nodemon": "^2.0.15",
65
+ "npm-check-updates": "^12.1.0",
66
+ "rimraf": "^3.0.2",
67
+ "ts-node": "^10.4.0",
68
+ "typescript": "^4.5.4",
69
+ "typescript-axios-wb": "^1.0.3"
70
+ },
71
+ "optionalDependencies": {
72
+ "node-switchbot": "^1.1.2"
36
73
  }
37
- ],
38
- "publishConfig": {
39
- "access": "public"
40
- },
41
- "keywords": [
42
- "homebridge-plugin",
43
- "switchbot",
44
- "humidifier",
45
- "humidity",
46
- "temperature",
47
- "bot",
48
- "curtains",
49
- "windows",
50
- "ble",
51
- "ir"
52
- ],
53
- "dependencies": {
54
- "@homebridge/plugin-ui-utils": "^0.0.19",
55
- "axios": "^0.24.0",
56
- "rxjs": "^7.5.1"
57
- },
58
- "devDependencies": {
59
- "@types/node": "^17.0.7",
60
- "@typescript-eslint/eslint-plugin": "^5.9.0",
61
- "@typescript-eslint/parser": "^5.9.0",
62
- "eslint": "^8.6.0",
63
- "homebridge": "^1.3.9",
64
- "nodemon": "^2.0.15",
65
- "npm-check-updates": "^12.1.0",
66
- "rimraf": "^3.0.2",
67
- "ts-node": "^10.4.0",
68
- "typescript": "^4.5.4",
69
- "typescript-axios-wb": "^1.0.3"
70
- },
71
- "optionalDependencies": {
72
- "node-switchbot": "^1.1.2"
73
- }
74
- }
74
+ }
@@ -13,10 +13,13 @@ import { DeviceURL, device, devicesConfig, serviceData, ad, switchbot, deviceSta
13
13
  */
14
14
  export class Bot {
15
15
  // Services
16
- private outletService?: Service;
17
16
  private switchService?: Service;
17
+ private doorService?: Service;
18
+ private garageDoorService?: Service;
19
+ private outletService?: Service;
18
20
  private batteryService?: Service;
19
21
 
22
+
20
23
  // Characteristic Values
21
24
  On!: CharacteristicValue;
22
25
  OnCached!: CharacteristicValue;
@@ -94,29 +97,56 @@ export class Bot {
94
97
  // get the LightBulb service if it exists, otherwise create a new LightBulb service
95
98
  // you can create multiple services for each accessory
96
99
  if (device.bot?.deviceType === 'switch') {
97
- // If outletService still pressent, then remove first
98
- if (this.outletService) {
99
- this.debugLog(`Bot: ${accessory.displayName} Removing Leftover outletService first`);
100
- }
101
- this.outletService = this.accessory.getService(this.platform.Service.Outlet);
102
- accessory.removeService(this.outletService!);
100
+ this.removeDoorService(accessory);
101
+ this.removeOutletService(accessory);
102
+ this.removeGarageDoorService(accessory);
103
103
 
104
104
  // Add switchService
105
105
  (this.switchService =
106
106
  accessory.getService(this.platform.Service.Switch) ||
107
107
  accessory.addService(this.platform.Service.Switch)), `${accessory.displayName} Switch`;
108
- if (this.deviceLogging !== 'none') {
109
- this.infoLog(`Bot: ${accessory.displayName} Displaying as Switch`);
110
- }
108
+ this.infoLog(`Bot: ${accessory.displayName} Displaying as Switch`);
109
+
110
+ this.switchService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
111
+ this.switchService.getCharacteristic(this.platform.Characteristic.On).onSet(this.handleOnSet.bind(this));
112
+ } else if (device.bot?.deviceType === 'garagedoor') {
113
+ this.removeDoorService(accessory);
114
+ this.removeOutletService(accessory);
115
+ this.removeSwitchService(accessory);
116
+
117
+ // Add switchService
118
+ (this.garageDoorService =
119
+ accessory.getService(this.platform.Service.GarageDoorOpener) ||
120
+ accessory.addService(this.platform.Service.GarageDoorOpener)), `${accessory.displayName} Garage Door Opener`;
121
+ this.infoLog(`Bot: ${accessory.displayName} Displaying as Garage Door Opener`);
122
+
123
+ this.garageDoorService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
124
+ this.garageDoorService.getCharacteristic(this.platform.Characteristic.TargetDoorState).onSet(this.handleOnSet.bind(this));
125
+ this.garageDoorService.setCharacteristic(this.platform.Characteristic.ObstructionDetected, false);
126
+ } else if (device.bot?.deviceType === 'door') {
127
+ this.removeOutletService(accessory);
128
+ this.removeSwitchService(accessory);
129
+ this.removeGarageDoorService(accessory);
111
130
 
112
- this.switchService?.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
131
+ // Add switchService
132
+ (this.doorService =
133
+ accessory.getService(this.platform.Service.Door) ||
134
+ accessory.addService(this.platform.Service.Door)), `${accessory.displayName} Door`;
135
+ this.infoLog(`Bot: ${accessory.displayName} Displaying as Garage Door Opener`);
136
+
137
+ this.doorService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
138
+ this.doorService.getCharacteristic(this.platform.Characteristic.TargetPosition)
139
+ .setProps({
140
+ validValues: [0, 100],
141
+ minValue: 0,
142
+ maxValue: 100,
143
+ minStep: 100,
144
+ }).onSet(this.handleOnSet.bind(this));
145
+ this.doorService.setCharacteristic(this.platform.Characteristic.PositionState, this.platform.Characteristic.PositionState.STOPPED);
113
146
  } else {
114
- // If switchService still pressent, then remove first
115
- if (this.switchService) {
116
- this.debugLog(`Bot: ${accessory.displayName} Removing Leftover switchService first`);
117
- }
118
- this.switchService = this.accessory.getService(this.platform.Service.Switch);
119
- accessory.removeService(this.switchService!);
147
+ this.removeDoorService(accessory);
148
+ this.removeSwitchService(accessory);
149
+ this.removeGarageDoorService(accessory);
120
150
 
121
151
  // Add outletService
122
152
  (this.outletService =
@@ -124,7 +154,8 @@ export class Bot {
124
154
  accessory.addService(this.platform.Service.Outlet)), `${accessory.displayName} Outlet`;
125
155
  this.infoLog(`Bot: ${accessory.displayName} Displaying as Outlet`);
126
156
 
127
- this.outletService?.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
157
+ this.outletService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
158
+ this.outletService.getCharacteristic(this.platform.Characteristic.On).onSet(this.handleOnSet.bind(this));
128
159
  }
129
160
 
130
161
  if (device.ble) {
@@ -135,15 +166,6 @@ export class Bot {
135
166
  this.batteryService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Battery`);
136
167
  }
137
168
 
138
- // each service must implement at-minimum the "required characteristics" for the given service type
139
- // see https://developers.homebridge.io/#/service/Outlet
140
-
141
- if (device.bot?.deviceType === 'switch') {
142
- this.switchService!.getCharacteristic(this.platform.Characteristic.On).onSet(this.handleOnSet.bind(this));
143
- } else {
144
- this.outletService!.getCharacteristic(this.platform.Characteristic.On).onSet(this.handleOnSet.bind(this));
145
- }
146
-
147
169
  // Retrieve initial values and updateHomekit
148
170
  this.updateHomeKitCharacteristics();
149
171
 
@@ -185,6 +207,42 @@ export class Bot {
185
207
  });
186
208
  }
187
209
 
210
+ private removeOutletService(accessory: PlatformAccessory) {
211
+ // If outletService still pressent, then remove first
212
+ if (this.outletService) {
213
+ this.debugLog(`Bot: ${accessory.displayName} Removing Leftover outletService first`);
214
+ }
215
+ this.outletService = this.accessory.getService(this.platform.Service.Outlet);
216
+ accessory.removeService(this.outletService!);
217
+ }
218
+
219
+ private removeGarageDoorService(accessory: PlatformAccessory) {
220
+ // If garageDoorService still pressent, then remove first
221
+ if (this.garageDoorService) {
222
+ this.debugLog(`Bot: ${accessory.displayName} Removing Leftover garageDoorService first`);
223
+ }
224
+ this.garageDoorService = this.accessory.getService(this.platform.Service.GarageDoorOpener);
225
+ accessory.removeService(this.garageDoorService!);
226
+ }
227
+
228
+ private removeDoorService(accessory: PlatformAccessory) {
229
+ // If doorService still pressent, then remove first
230
+ if (this.doorService) {
231
+ this.debugLog(`Bot: ${accessory.displayName} Removing Leftover doorService first`);
232
+ }
233
+ this.doorService = this.accessory.getService(this.platform.Service.Door);
234
+ accessory.removeService(this.doorService!);
235
+ }
236
+
237
+ private removeSwitchService(accessory: PlatformAccessory) {
238
+ // If switchService still pressent, then remove first
239
+ if (this.switchService) {
240
+ this.debugLog(`Bot: ${accessory.displayName} Removing Leftover switchService first`);
241
+ }
242
+ this.switchService = this.accessory.getService(this.platform.Service.Switch);
243
+ accessory.removeService(this.switchService!);
244
+ }
245
+
188
246
  refreshRate() {
189
247
  if (this.device.refreshRate) {
190
248
  this.deviceRefreshRate = this.accessory.context.refreshRate = this.device.refreshRate;
@@ -335,8 +393,7 @@ export class Bot {
335
393
  // Convert to BLE Address
336
394
  const switchbot = this.connectBLE();
337
395
  // Start to monitor advertisement packets
338
- this.debugLog(`Bot: ${this.accessory.displayName} platform.Switchbot: ${JSON.stringify(switchbot)}`);
339
- if (switchbot) {
396
+ if (switchbot !== false) {
340
397
  switchbot.startScan({
341
398
  model: 'H',
342
399
  id: this.device.bleMac,
@@ -447,8 +504,7 @@ export class Bot {
447
504
  if (this.On !== this.OnCached) {
448
505
  this.debugLog(`Bot: ${this.accessory.displayName} BLE pushChanges`);
449
506
  const switchbot = this.connectBLE();
450
- this.debugLog(`Bot: ${this.accessory.displayName} platform.Switchbot: ${JSON.stringify(switchbot)}`);
451
- if (switchbot) {
507
+ if (switchbot !== false) {
452
508
  if (this.botMode === 'press') {
453
509
  this.debugLog(`Bot: ${this.accessory.displayName} Bot Mode: ${this.botMode}`);
454
510
  switchbot.discover({ model: 'H', quick: true, id: this.device.bleMac })
@@ -587,16 +643,61 @@ export class Bot {
587
643
  * Updates the status for each of the HomeKit Characteristics
588
644
  */
589
645
  updateHomeKitCharacteristics() {
590
- if (this.On === undefined) {
591
- this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
592
- } else {
593
- if (this.device.bot?.deviceType === 'switch') {
646
+ if (this.device.bot?.deviceType === 'garagedoor') {
647
+ if (this.On === undefined) {
648
+ this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
649
+ } else {
650
+ if (this.On) {
651
+ this.garageDoorService?.updateCharacteristic(this.platform.Characteristic.TargetDoorState,
652
+ this.platform.Characteristic.TargetDoorState.OPEN);
653
+ this.garageDoorService?.updateCharacteristic(this.platform.Characteristic.CurrentDoorState,
654
+ this.platform.Characteristic.CurrentDoorState.OPEN);
655
+ this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic TargetDoorState: Open, CurrentDoorState: Open`);
656
+ } else {
657
+ this.garageDoorService?.updateCharacteristic(this.platform.Characteristic.TargetDoorState,
658
+ this.platform.Characteristic.TargetDoorState.CLOSED);
659
+ this.garageDoorService?.updateCharacteristic(this.platform.Characteristic.CurrentDoorState,
660
+ this.platform.Characteristic.CurrentDoorState.CLOSED);
661
+ this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic TargetDoorState: Open, CurrentDoorState: Open`);
662
+ }
663
+ }
664
+ this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
665
+ } else if (this.device.bot?.deviceType === 'door') {
666
+ if (this.On === undefined) {
667
+ this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
668
+ } else {
669
+ if (this.On) {
670
+ this.doorService?.updateCharacteristic(this.platform.Characteristic.TargetPosition, 100);
671
+ this.doorService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, 100);
672
+ this.doorService?.updateCharacteristic(this.platform.Characteristic.PositionState,
673
+ this.platform.Characteristic.PositionState.STOPPED);
674
+ this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic TargetPosition: 100, CurrentPosition: 100`);
675
+ } else {
676
+ this.doorService?.updateCharacteristic(this.platform.Characteristic.TargetPosition, 0);
677
+ this.doorService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, 0);
678
+ this.doorService?.updateCharacteristic(this.platform.Characteristic.PositionState,
679
+ this.platform.Characteristic.PositionState.STOPPED);
680
+ this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic TargetPosition: 0, CurrentPosition: 0`);
681
+ }
682
+ }
683
+ this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
684
+ } else if (this.device.bot?.deviceType === 'switch') {
685
+ if (this.On === undefined) {
686
+ this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
687
+ } else {
594
688
  this.switchService?.updateCharacteristic(this.platform.Characteristic.On, this.On);
689
+ this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
690
+ }
691
+ } else {
692
+ if (this.On === undefined) {
693
+ this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
595
694
  } else {
596
695
  this.outletService?.updateCharacteristic(this.platform.Characteristic.On, this.On);
696
+ this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
597
697
  }
598
- this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
599
698
  }
699
+
700
+
600
701
  if (this.device.ble) {
601
702
  if (this.BatteryLevel === undefined) {
602
703
  this.debugLog(`Bot: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}`);
@@ -614,7 +715,15 @@ export class Bot {
614
715
  }
615
716
 
616
717
  public apiError(e: any) {
617
- if (this.device.bot?.deviceType === 'switch') {
718
+ if (this.device.bot?.deviceType === 'garagedoor') {
719
+ this.garageDoorService?.updateCharacteristic(this.platform.Characteristic.TargetDoorState, e);
720
+ this.garageDoorService?.updateCharacteristic(this.platform.Characteristic.CurrentDoorState, e);
721
+ this.garageDoorService?.updateCharacteristic(this.platform.Characteristic.ObstructionDetected, e);
722
+ } else if (this.device.bot?.deviceType === 'door') {
723
+ this.doorService?.updateCharacteristic(this.platform.Characteristic.TargetPosition, e);
724
+ this.doorService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, e);
725
+ this.doorService?.updateCharacteristic(this.platform.Characteristic.PositionState, e);
726
+ } else if (this.device.bot?.deviceType === 'switch') {
618
727
  this.switchService?.updateCharacteristic(this.platform.Characteristic.On, e);
619
728
  } else {
620
729
  this.outletService?.updateCharacteristic(this.platform.Characteristic.On, e);
@@ -672,8 +781,24 @@ export class Bot {
672
781
  * Handle requests to set the "On" characteristic
673
782
  */
674
783
  private handleOnSet(value: CharacteristicValue) {
675
- this.debugLog(`Bot: ${this.accessory.displayName} On: ${value}`);
676
- this.On = value;
784
+ if (this.device.bot?.deviceType === 'garagedoor') {
785
+ this.debugLog(`Bot: ${this.accessory.displayName} TargetDoorState: ${value}`);
786
+ if (value === this.platform.Characteristic.TargetDoorState.CLOSED) {
787
+ this.On = false;
788
+ } else {
789
+ this.On = true;
790
+ }
791
+ } else if (this.device.bot?.deviceType === 'door') {
792
+ this.debugLog(`Bot: ${this.accessory.displayName} TargetPosition: ${value}`);
793
+ if (value === 100) {
794
+ this.On = false;
795
+ } else {
796
+ this.On = true;
797
+ }
798
+ } else {
799
+ this.debugLog(`Bot: ${this.accessory.displayName} On: ${value}`);
800
+ this.On = value;
801
+ }
677
802
  this.doBotUpdate.next();
678
803
  }
679
804
 
@@ -286,8 +286,7 @@ export class Contact {
286
286
  // eslint-disable-next-line @typescript-eslint/no-var-requires
287
287
  const switchbot = this.connectBLE();
288
288
  // Start to monitor advertisement packets
289
- this.debugLog(`Contact Sensor: ${this.accessory.displayName} platform.Switchbot: ${JSON.stringify(switchbot)}`);
290
- if (switchbot) {
289
+ if (switchbot !== false) {
291
290
  switchbot.startScan({
292
291
  model: 'd',
293
292
  id: this.device.bleMac,
@@ -454,8 +454,7 @@ export class Curtain {
454
454
  // eslint-disable-next-line @typescript-eslint/no-var-requires
455
455
  const switchbot = this.connectBLE();
456
456
  // Start to monitor advertisement packets
457
- this.debugLog(`Curtain: ${this.accessory.displayName} platform.Switchbot: ${JSON.stringify(switchbot)}`);
458
- if (switchbot) {
457
+ if (switchbot !== false) {
459
458
  switchbot.startScan({
460
459
  model: 'c',
461
460
  id: this.device.bleMac,
@@ -564,8 +563,7 @@ export class Curtain {
564
563
  if (this.TargetPosition !== this.CurrentPosition) {
565
564
  this.debugLog(`Curtain: ${this.accessory.displayName} BLE pushChanges`);
566
565
  const switchbot = this.connectBLE();
567
- this.debugLog(`Curtain: ${this.accessory.displayName} platform.Switchbot: ${JSON.stringify(switchbot)}`);
568
- if (switchbot) {
566
+ if (switchbot !== false) {
569
567
  switchbot.discover({ model: 'c', quick: true, id: this.device.bleMac }).then((device_list) => {
570
568
  this.infoLog(`${this.accessory.displayName} Target Position: ${this.TargetPosition}`);
571
569
  return device_list[0].runToPos(100 - Number(this.TargetPosition));
@@ -352,8 +352,7 @@ export class Humidifier {
352
352
  // eslint-disable-next-line @typescript-eslint/no-var-requires
353
353
  const switchbot = this.connectBLE();
354
354
  // Start to monitor advertisement packets
355
- this.debugLog(`Humidifier: ${this.accessory.displayName} platform.Switchbot: ${JSON.stringify(switchbot)}`);
356
- if (switchbot) {
355
+ if (switchbot !== false) {
357
356
  switchbot.startScan({
358
357
  model: 'e',
359
358
  id: this.device.bleMac,
@@ -463,8 +462,7 @@ export class Humidifier {
463
462
  private async BLEpushChanges() {
464
463
  this.debugLog(`Humidifier: ${this.accessory.displayName} BLE pushChanges`);
465
464
  const switchbot = this.connectBLE();
466
- this.debugLog(`Humidifier: ${this.accessory.displayName} platform.Switchbot: ${JSON.stringify(switchbot)}`);
467
- if (switchbot) {
465
+ if (switchbot !== false) {
468
466
  switchbot.discover({ model: 'e', quick: true, id: this.device.bleMac }).then((device_list) => {
469
467
  this.infoLog(`${this.accessory.displayName} Target Position: ${this.Active}`);
470
468
  return device_list[0].percentage(this.RelativeHumidityHumidifierThreshold);
@@ -317,8 +317,7 @@ export class Meter {
317
317
  // eslint-disable-next-line @typescript-eslint/no-var-requires
318
318
  const switchbot = this.connectBLE();
319
319
  // Start to monitor advertisement packets
320
- this.debugLog(`Meter: ${this.accessory.displayName} platform.Switchbot: ${JSON.stringify(switchbot)}`);
321
- if (switchbot) {
320
+ if (switchbot !== false) {
322
321
  switchbot.startScan({
323
322
  model: 'T',
324
323
  id: this.device.bleMac,
@@ -239,8 +239,7 @@ export class Motion {
239
239
  // eslint-disable-next-line @typescript-eslint/no-var-requires
240
240
  const switchbot = this.connectBLE();
241
241
  // Start to monitor advertisement packets
242
- this.debugLog(`Motion Sensor: ${this.accessory.displayName} platform.Switchbot: ${JSON.stringify(switchbot)}`);
243
- if (switchbot) {
242
+ if (switchbot !== false) {
244
243
  switchbot.startScan({
245
244
  model: 's',
246
245
  id: this.device.bleMac,