@switchbot/homebridge-switchbot 1.6.1 → 1.6.2-beta.0

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.
@@ -1,4 +1,3 @@
1
- import Switchbot from 'node-switchbot';
2
1
  import { interval, Subject } from 'rxjs';
3
2
  import { skipWhile } from 'rxjs/operators';
4
3
  import { SwitchBotPlatform } from '../platform';
@@ -305,12 +304,19 @@ export class Meter {
305
304
  }
306
305
 
307
306
  private connectBLE() {
308
- const switchbot = new Switchbot();
309
- this.device.bleMac = ((this.device.deviceId!.match(/.{1,2}/g))!.join(':')).toLowerCase();
310
- this.debugLog(`Meter: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
311
- return switchbot;
307
+ let Switchbot: any;
308
+ try {
309
+ Switchbot = require('node-switchbot');
310
+ const switchbot = new Switchbot();
311
+ this.device.bleMac = ((this.device.deviceId!.match(/.{1,2}/g))!.join(':')).toLowerCase();
312
+ this.debugLog(`Bot: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
313
+ return switchbot;
314
+ } catch (e) {
315
+ Switchbot = false;
316
+ }
312
317
  }
313
318
 
319
+
314
320
  private BLErefreshStatus() {
315
321
  this.debugLog(`Meter: ${this.accessory.displayName} BLE RefreshStatus`);
316
322
  // eslint-disable-next-line @typescript-eslint/no-var-requires
@@ -1,4 +1,3 @@
1
- import Switchbot from 'node-switchbot';
2
1
  import { interval, Subject } from 'rxjs';
3
2
  import { skipWhile } from 'rxjs/operators';
4
3
  import { SwitchBotPlatform } from '../platform';
@@ -228,10 +227,16 @@ export class Motion {
228
227
  }
229
228
 
230
229
  private connectBLE() {
231
- const switchbot = new Switchbot();
232
- this.device.bleMac = ((this.device.deviceId!.match(/.{1,2}/g))!.join(':')).toLowerCase();
233
- this.debugLog(`Motion Sensor: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
234
- return switchbot;
230
+ let Switchbot: any;
231
+ try {
232
+ Switchbot = require('node-switchbot');
233
+ const switchbot = new Switchbot();
234
+ this.device.bleMac = ((this.device.deviceId!.match(/.{1,2}/g))!.join(':')).toLowerCase();
235
+ this.debugLog(`Bot: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
236
+ return switchbot;
237
+ } catch (e) {
238
+ Switchbot = false;
239
+ }
235
240
  }
236
241
 
237
242
  private async BLERefreshStatus() {