@switchbot/homebridge-switchbot 2.1.2-beta.4 → 2.1.2-beta.6

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 (58) hide show
  1. package/dist/device/bot.d.ts +1 -1
  2. package/dist/device/bot.d.ts.map +1 -1
  3. package/dist/device/bot.js +14 -10
  4. package/dist/device/bot.js.map +1 -1
  5. package/dist/device/ceilinglight.d.ts +1 -1
  6. package/dist/device/ceilinglight.d.ts.map +1 -1
  7. package/dist/device/ceilinglight.js +9 -5
  8. package/dist/device/ceilinglight.js.map +1 -1
  9. package/dist/device/colorbulb.d.ts +1 -1
  10. package/dist/device/colorbulb.d.ts.map +1 -1
  11. package/dist/device/colorbulb.js +9 -5
  12. package/dist/device/colorbulb.js.map +1 -1
  13. package/dist/device/contact.d.ts.map +1 -1
  14. package/dist/device/contact.js +7 -4
  15. package/dist/device/contact.js.map +1 -1
  16. package/dist/device/curtain.d.ts.map +1 -1
  17. package/dist/device/curtain.js +8 -2
  18. package/dist/device/curtain.js.map +1 -1
  19. package/dist/device/humidifier.d.ts.map +1 -1
  20. package/dist/device/humidifier.js +9 -8
  21. package/dist/device/humidifier.js.map +1 -1
  22. package/dist/device/lock.d.ts +1 -1
  23. package/dist/device/lock.d.ts.map +1 -1
  24. package/dist/device/lock.js +9 -5
  25. package/dist/device/lock.js.map +1 -1
  26. package/dist/device/meter.d.ts.map +1 -1
  27. package/dist/device/meter.js +16 -9
  28. package/dist/device/meter.js.map +1 -1
  29. package/dist/device/meterplus.d.ts +1 -1
  30. package/dist/device/meterplus.d.ts.map +1 -1
  31. package/dist/device/meterplus.js +17 -10
  32. package/dist/device/meterplus.js.map +1 -1
  33. package/dist/device/motion.d.ts.map +1 -1
  34. package/dist/device/motion.js +7 -4
  35. package/dist/device/motion.js.map +1 -1
  36. package/dist/device/plug.d.ts.map +1 -1
  37. package/dist/device/plug.js +8 -4
  38. package/dist/device/plug.js.map +1 -1
  39. package/dist/device/striplight.d.ts.map +1 -1
  40. package/dist/device/striplight.js +8 -4
  41. package/dist/device/striplight.js.map +1 -1
  42. package/dist/platform.d.ts.map +1 -1
  43. package/dist/platform.js +3 -5
  44. package/dist/platform.js.map +1 -1
  45. package/package.json +1 -1
  46. package/src/device/bot.ts +14 -9
  47. package/src/device/ceilinglight.ts +9 -5
  48. package/src/device/colorbulb.ts +9 -5
  49. package/src/device/contact.ts +7 -4
  50. package/src/device/curtain.ts +8 -2
  51. package/src/device/humidifier.ts +9 -8
  52. package/src/device/lock.ts +9 -5
  53. package/src/device/meter.ts +16 -10
  54. package/src/device/meterplus.ts +17 -11
  55. package/src/device/motion.ts +7 -4
  56. package/src/device/plug.ts +8 -4
  57. package/src/device/striplight.ts +8 -4
  58. package/src/platform.ts +5 -7
@@ -221,6 +221,7 @@ export class Curtain {
221
221
  } else if (this.OpenAPI && this.platform.config.credentials?.token) {
222
222
  await this.openAPIparseStatus();
223
223
  } else {
224
+ await this.offlineOff();
224
225
  this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
225
226
  + ` ${this.device.connectionType}, parseStatus will not happen.`);
226
227
  }
@@ -395,6 +396,7 @@ export class Curtain {
395
396
  } else if (this.OpenAPI && this.platform.config.credentials?.token) {
396
397
  await this.openAPIRefreshStatus();
397
398
  } else {
399
+ await this.offlineOff();
398
400
  this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
399
401
  + ` ${this.device.connectionType}, refreshStatus will not happen.`);
400
402
  }
@@ -528,6 +530,7 @@ export class Curtain {
528
530
  } else if (this.OpenAPI && this.platform.config.credentials?.token) {
529
531
  await this.openAPIpushChanges();
530
532
  } else {
533
+ await this.offlineOff();
531
534
  this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
532
535
  + ` ${this.device.connectionType}, pushChanges will not happen.`);
533
536
  }
@@ -960,9 +963,12 @@ export class Curtain {
960
963
 
961
964
  async offlineOff(): Promise<void> {
962
965
  if (this.device.offline) {
963
- this.CurrentPosition = 100;
964
- this.windowCoveringService.getCharacteristic(this.platform.Characteristic.On).updateValue(this.CurrentPosition);
966
+ await this.context();
965
967
  await this.updateHomeKitCharacteristics();
968
+ /* this.windowCoveringService.setCharacteristic(this.platform.Characteristic.PositionState, this.PositionState)
969
+ .getCharacteristic(this.platform.Characteristic.PositionState).updateValue(this.PositionState);
970
+ this.windowCoveringService.setCharacteristic(this.platform.Characteristic.CurrentPosition, this.CurrentPosition)
971
+ .getCharacteristic(this.platform.Characteristic.CurrentPosition).updateValue(this.CurrentPosition);*/
966
972
  }
967
973
  }
968
974
 
@@ -199,7 +199,7 @@ export class Humidifier {
199
199
  } else if (this.OpenAPI && this.platform.config.credentials?.token) {
200
200
  await this.openAPIparseStatus();
201
201
  } else {
202
- this.offlineOff();
202
+ await this.offlineOff();
203
203
  this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
204
204
  + ` ${this.device.connectionType}, parseStatus will not happen.`);
205
205
  }
@@ -289,7 +289,7 @@ export class Humidifier {
289
289
  } else if (this.OpenAPI && this.platform.config.credentials?.token) {
290
290
  await this.openAPIRefreshStatus();
291
291
  } else {
292
- this.offlineOff();
292
+ await this.offlineOff();
293
293
  this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
294
294
  + ` ${this.device.connectionType}, refreshStatus will not happen.`);
295
295
  }
@@ -428,7 +428,7 @@ export class Humidifier {
428
428
  } else*/ if (this.OpenAPI && this.platform.config.credentials?.token) {
429
429
  await this.openAPIpushChanges();
430
430
  } else {
431
- this.offlineOff();
431
+ await this.offlineOff();
432
432
  this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
433
433
  + ` ${this.device.connectionType}, pushChanges will not happen.`);
434
434
  }
@@ -840,11 +840,11 @@ export class Humidifier {
840
840
  break;
841
841
  case 161:
842
842
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Device is offline.`);
843
- this.offlineOff();
843
+ await this.offlineOff();
844
844
  break;
845
845
  case 171:
846
846
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
847
- this.offlineOff();
847
+ await this.offlineOff();
848
848
  break;
849
849
  case 190:
850
850
  this.errorLog(
@@ -862,9 +862,10 @@ export class Humidifier {
862
862
 
863
863
  async offlineOff(): Promise<void> {
864
864
  if (this.device.offline) {
865
- this.Active = this.platform.Characteristic.Active.INACTIVE;
866
- this.humidifierService.getCharacteristic(this.platform.Characteristic.Active).updateValue(this.Active);
867
- //await this.updateHomeKitCharacteristics();
865
+ await this.context();
866
+ await this.updateHomeKitCharacteristics();
867
+ /*this.humidifierService.setCharacteristic(this.platform.Characteristic.Active, this.Active)
868
+ .getCharacteristic(this.platform.Characteristic.Active).updateValue(this.Active);*/
868
869
  }
869
870
  }
870
871
 
@@ -139,6 +139,7 @@ export class Lock {
139
139
  } else*/ if (this.OpenAPI && this.platform.config.credentials?.token) {
140
140
  await this.openAPIparseStatus();
141
141
  } else {
142
+ await this.offlineOff();
142
143
  this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
143
144
  + ` ${this.device.connectionType}, parseStatus will not happen.`);
144
145
  }
@@ -199,6 +200,7 @@ export class Lock {
199
200
  } else*/ if (this.OpenAPI && this.platform.config.credentials?.token) {
200
201
  await this.openAPIRefreshStatus();
201
202
  } else {
203
+ await this.offlineOff();
202
204
  this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
203
205
  + ` ${this.device.connectionType}, refreshStatus will not happen.`);
204
206
  }
@@ -271,6 +273,7 @@ export class Lock {
271
273
  } else*/ if (this.OpenAPI && this.platform.config.credentials?.token) {
272
274
  await this.openAPIpushChanges();
273
275
  } else {
276
+ await this.offlineOff();
274
277
  this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
275
278
  + ` ${this.device.connectionType}, pushChanges will not happen.`);
276
279
  }
@@ -466,11 +469,11 @@ export class Lock {
466
469
  break;
467
470
  case 161:
468
471
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Device is offline.`);
469
- this.offlineOff();
472
+ await this.offlineOff();
470
473
  break;
471
474
  case 171:
472
475
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
473
- this.offlineOff();
476
+ await this.offlineOff();
474
477
  break;
475
478
  case 190:
476
479
  this.errorLog(
@@ -488,9 +491,10 @@ export class Lock {
488
491
 
489
492
  async offlineOff(): Promise<void> {
490
493
  if (this.device.offline) {
491
- this.LockCurrentState = this.platform.Characteristic.LockCurrentState.SECURED;
492
- this.lockService.getCharacteristic(this.platform.Characteristic.LockCurrentState).updateValue(this.LockCurrentState);
494
+ await this.conext();
493
495
  await this.updateHomeKitCharacteristics();
496
+ /*this.lockService.setCharacteristic(this.platform.Characteristic.LockCurrentState, this.LockCurrentState)
497
+ .getCharacteristic(this.platform.Characteristic.LockCurrentState).updateValue(this.LockCurrentState);*/
494
498
  }
495
499
  }
496
500
 
@@ -518,7 +522,7 @@ export class Lock {
518
522
  return FirmwareRevision;
519
523
  }
520
524
 
521
- private conext() {
525
+ async conext() {
522
526
  if (this.LockTargetState === undefined) {
523
527
  this.LockTargetState = false;
524
528
  } else {
@@ -183,6 +183,7 @@ export class Meter {
183
183
  } else if (this.OpenAPI && this.platform.config.credentials?.token) {
184
184
  await this.openAPIparseStatus();
185
185
  } else {
186
+ await this.offlineOff();
186
187
  this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
187
188
  + ` ${this.device.connectionType}, parseStatus will not happen.`);
188
189
  }
@@ -240,6 +241,7 @@ export class Meter {
240
241
  } else if (this.OpenAPI && this.platform.config.credentials?.token) {
241
242
  await this.openAPIRefreshStatus();
242
243
  } else {
244
+ await this.offlineOff();
243
245
  this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
244
246
  + ` ${this.device.connectionType}, refreshStatus will not happen.`);
245
247
  }
@@ -540,11 +542,11 @@ export class Meter {
540
542
  break;
541
543
  case 161:
542
544
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Device is offline.`);
543
- this.offlineOff();
545
+ await this.offlineOff();
544
546
  break;
545
547
  case 171:
546
548
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} is offline. Hub: ${this.device.hubDeviceId}`);
547
- this.offlineOff();
549
+ await this.offlineOff();
548
550
  break;
549
551
  case 190:
550
552
  this.errorLog(
@@ -566,18 +568,22 @@ export class Meter {
566
568
 
567
569
  async offlineOff(): Promise<void> {
568
570
  if (this.device.offline) {
569
- if (!this.device.meter?.hide_humidity) {
570
- this.humidityservice?.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity,
571
- this.accessory.context.CurrentRelativeHumidity);
571
+ await this.context();
572
+ await this.updateHomeKitCharacteristics();
573
+ /*if (!this.device.meter?.hide_humidity) {
574
+ this.humidityservice!.setCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, this.CurrentRelativeHumidity)
575
+ .getCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity).updateValue(this.CurrentRelativeHumidity);
572
576
  }
573
577
  if (!this.device.meter?.hide_temperature) {
574
- this.temperatureservice?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, this.accessory.context.CurrentTemperature);
578
+ this.temperatureservice!.setCharacteristic(this.platform.Characteristic.CurrentTemperature, this.CurrentTemperature!)
579
+ .getCharacteristic(this.platform.Characteristic.CurrentTemperature).updateValue(this.CurrentTemperature!);
575
580
  }
576
581
  if (this.BLE) {
577
- this.batteryService?.updateCharacteristic(this.platform.Characteristic.BatteryLevel, this.accessory.context.BatteryLevel);
578
- this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, this.accessory.context.StatusLowBattery);
579
- }
580
- await this.updateHomeKitCharacteristics();
582
+ this.batteryService!.setCharacteristic(this.platform.Characteristic.BatteryLevel, this.BatteryLevel!)
583
+ .getCharacteristic(this.platform.Characteristic.BatteryLevel).updateValue(this.BatteryLevel!);
584
+ this.batteryService!.setCharacteristic(this.platform.Characteristic.StatusLowBattery, this.StatusLowBattery!)
585
+ .getCharacteristic(this.platform.Characteristic.StatusLowBattery).updateValue(this.StatusLowBattery!);
586
+ }*/
581
587
  }
582
588
  }
583
589
 
@@ -183,6 +183,7 @@ export class MeterPlus {
183
183
  } else if (this.OpenAPI && this.platform.config.credentials?.token) {
184
184
  await this.openAPIparseStatus();
185
185
  } else {
186
+ await this.offlineOff();
186
187
  this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
187
188
  + ` ${this.device.connectionType}, parseStatus will not happen.`);
188
189
  }
@@ -240,6 +241,7 @@ export class MeterPlus {
240
241
  } else if (this.OpenAPI && this.platform.config.credentials?.token) {
241
242
  await this.openAPIRefreshStatus();
242
243
  } else {
244
+ await this.offlineOff();
243
245
  this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
244
246
  + ` ${this.device.connectionType}, refreshStatus will not happen.`);
245
247
  }
@@ -549,11 +551,11 @@ export class MeterPlus {
549
551
  break;
550
552
  case 161:
551
553
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Device is offline.`);
552
- this.offlineOff();
554
+ await this.offlineOff();
553
555
  break;
554
556
  case 171:
555
557
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} is offline. Hub: ${this.device.hubDeviceId}`);
556
- this.offlineOff();
558
+ await this.offlineOff();
557
559
  break;
558
560
  case 190:
559
561
  this.errorLog(
@@ -575,18 +577,22 @@ export class MeterPlus {
575
577
 
576
578
  async offlineOff(): Promise<void> {
577
579
  if (this.device.offline) {
578
- if (!this.device.meter?.hide_humidity) {
579
- this.humidityservice?.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity,
580
- this.accessory.context.CurrentRelativeHumidity);
580
+ await this.context();
581
+ await this.updateHomeKitCharacteristics();
582
+ /*if (!this.device.meter?.hide_humidity) {
583
+ this.humidityservice!.setCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, this.CurrentRelativeHumidity)
584
+ .getCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity).updateValue(this.CurrentRelativeHumidity);
581
585
  }
582
586
  if (!this.device.meter?.hide_temperature) {
583
- this.temperatureservice?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, this.accessory.context.CurrentTemperature);
587
+ this.temperatureservice!.setCharacteristic(this.platform.Characteristic.CurrentTemperature, this.CurrentTemperature!)
588
+ .getCharacteristic(this.platform.Characteristic.CurrentTemperature).updateValue(this.CurrentTemperature!);
584
589
  }
585
590
  if (this.BLE) {
586
- this.batteryService?.updateCharacteristic(this.platform.Characteristic.BatteryLevel, this.accessory.context.BatteryLevel);
587
- this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, this.accessory.context.StatusLowBattery);
588
- }
589
- await this.updateHomeKitCharacteristics();
591
+ this.batteryService!.setCharacteristic(this.platform.Characteristic.BatteryLevel, this.BatteryLevel!)
592
+ .getCharacteristic(this.platform.Characteristic.BatteryLevel).updateValue(this.BatteryLevel!);
593
+ this.batteryService!.setCharacteristic(this.platform.Characteristic.StatusLowBattery, this.StatusLowBattery!)
594
+ .getCharacteristic(this.platform.Characteristic.StatusLowBattery).updateValue(this.StatusLowBattery!);
595
+ }*/
590
596
  }
591
597
  }
592
598
 
@@ -619,7 +625,7 @@ export class MeterPlus {
619
625
  return FirmwareRevision;
620
626
  }
621
627
 
622
- private context() {
628
+ async context() {
623
629
  if (this.CurrentRelativeHumidity === undefined) {
624
630
  this.CurrentRelativeHumidity = 0;
625
631
  } else {
@@ -149,6 +149,7 @@ export class Motion {
149
149
  } else if (this.OpenAPI && this.platform.config.credentials?.token) {
150
150
  await this.openAPIparseStatus();
151
151
  } else {
152
+ await this.offlineOff();
152
153
  this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
153
154
  + ` ${this.device.connectionType}, parseStatus will not happen.`);
154
155
  }
@@ -222,6 +223,7 @@ export class Motion {
222
223
  } else if (this.OpenAPI && this.platform.config.credentials?.token) {
223
224
  await this.openAPIRefreshStatus();
224
225
  } else {
226
+ await this.offlineOff();
225
227
  this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
226
228
  + ` ${this.device.connectionType}, refreshStatus will not happen.`);
227
229
  }
@@ -458,11 +460,11 @@ export class Motion {
458
460
  break;
459
461
  case 161:
460
462
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Device is offline.`);
461
- this.offlineOff();
463
+ await this.offlineOff();
462
464
  break;
463
465
  case 171:
464
466
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} is offline. Hub: ${this.device.hubDeviceId}`);
465
- this.offlineOff();
467
+ await this.offlineOff();
466
468
  break;
467
469
  case 190:
468
470
  this.errorLog(
@@ -484,9 +486,10 @@ export class Motion {
484
486
 
485
487
  async offlineOff(): Promise<void> {
486
488
  if (this.device.offline) {
487
- this.MotionDetected = false;
488
- this.motionSensorService.getCharacteristic(this.platform.Characteristic.MotionDetected).updateValue(this.MotionDetected);
489
+ await this.context();
489
490
  await this.updateHomeKitCharacteristics();
491
+ /*this.motionSensorService.setCharacteristic(this.platform.Characteristic.MotionDetected, this.MotionDetected)
492
+ .getCharacteristic(this.platform.Characteristic.MotionDetected).updateValue(this.MotionDetected);*/
490
493
  }
491
494
  }
492
495
 
@@ -132,6 +132,7 @@ export class Plug {
132
132
  } else if (this.OpenAPI && this.platform.config.credentials?.token) {
133
133
  await this.openAPIparseStatus();
134
134
  } else {
135
+ await this.offlineOff();
135
136
  this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
136
137
  + ` ${this.device.connectionType}, parseStatus will not happen.`);
137
138
  }
@@ -173,6 +174,7 @@ export class Plug {
173
174
  } else if (this.OpenAPI && this.platform.config.credentials?.token) {
174
175
  await this.openAPIRefreshStatus();
175
176
  } else {
177
+ await this.offlineOff();
176
178
  this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
177
179
  + ` ${this.device.connectionType}, refreshStatus will not happen.`);
178
180
  }
@@ -319,6 +321,7 @@ export class Plug {
319
321
  } else if (this.OpenAPI && this.platform.config.credentials?.token) {
320
322
  await this.openAPIpushChanges();
321
323
  } else {
324
+ await this.offlineOff();
322
325
  this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
323
326
  + ` ${this.device.connectionType}, pushChanges will not happen.`);
324
327
  }
@@ -575,11 +578,11 @@ export class Plug {
575
578
  break;
576
579
  case 161:
577
580
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Device is offline.`);
578
- this.offlineOff();
581
+ await this.offlineOff();
579
582
  break;
580
583
  case 171:
581
584
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
582
- this.offlineOff();
585
+ await this.offlineOff();
583
586
  break;
584
587
  case 190:
585
588
  this.errorLog(
@@ -597,9 +600,10 @@ export class Plug {
597
600
 
598
601
  async offlineOff(): Promise<void> {
599
602
  if (this.device.offline) {
600
- this.On = false;
601
- this.outletService.getCharacteristic(this.platform.Characteristic.On).updateValue(this.On);
603
+ await this.context();
602
604
  await this.updateHomeKitCharacteristics();
605
+ /*this.outletService.setCharacteristic(this.platform.Characteristic.On, this.On)
606
+ .getCharacteristic(this.platform.Characteristic.On).updateValue(this.On);*/
603
607
  }
604
608
  }
605
609
 
@@ -219,6 +219,7 @@ export class StripLight {
219
219
  } else*/ if (this.OpenAPI && this.platform.config.credentials?.token) {
220
220
  await this.openAPIparseStatus();
221
221
  } else {
222
+ await this.offlineOff();
222
223
  this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
223
224
  + ` ${this.device.connectionType}, parseStatus will not happen.`);
224
225
  }
@@ -285,6 +286,7 @@ export class StripLight {
285
286
  } else*/ if (this.OpenAPI && this.platform.config.credentials?.token) {
286
287
  await this.openAPIRefreshStatus();
287
288
  } else {
289
+ await this.offlineOff();
288
290
  this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
289
291
  + ` ${this.device.connectionType}, refreshStatus will not happen.`);
290
292
  }
@@ -434,6 +436,7 @@ export class StripLight {
434
436
  } else*/ if (this.OpenAPI && this.platform.config.credentials?.token) {
435
437
  await this.openAPIpushChanges();
436
438
  } else {
439
+ await this.offlineOff();
437
440
  this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
438
441
  + ` ${this.device.connectionType}, pushChanges will not happen.`);
439
442
  }
@@ -926,11 +929,11 @@ export class StripLight {
926
929
  break;
927
930
  case 161:
928
931
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Device is offline.`);
929
- this.offlineOff();
932
+ await this.offlineOff();
930
933
  break;
931
934
  case 171:
932
935
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} is offline. Hub: ${this.device.hubDeviceId}`);
933
- this.offlineOff();
936
+ await this.offlineOff();
934
937
  break;
935
938
  case 190:
936
939
  this.errorLog(
@@ -952,9 +955,10 @@ export class StripLight {
952
955
 
953
956
  async offlineOff(): Promise<void> {
954
957
  if (this.device.offline) {
955
- this.On = false;
956
- this.lightBulbService.getCharacteristic(this.platform.Characteristic.On).updateValue(this.On);
958
+ await this.context();
957
959
  await this.updateHomeKitCharacteristics();
960
+ /*this.lightBulbService.setCharacteristic(this.platform.Characteristic.On, this.On)
961
+ .getCharacteristic(this.platform.Characteristic.On).updateValue(this.On);*/
958
962
  }
959
963
  }
960
964
 
package/src/platform.ts CHANGED
@@ -42,7 +42,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
42
42
  // this is used to track restored cached accessories
43
43
  public readonly accessories: PlatformAccessory[] = [];
44
44
 
45
- version = process.env.npm_package_version || '0.0.0';
45
+ version = process.env.npm_package_version || '2.1.1';
46
46
  debugMode!: boolean;
47
47
  platformLogging?: string;
48
48
 
@@ -1888,12 +1888,10 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1888
1888
  let Switchbot: new () => any;
1889
1889
  let switchbot: any;
1890
1890
  try {
1891
- Switchbot = require('node-switchbot'),
1892
- queueScheduler.schedule(() => {
1893
- queueScheduler.schedule(() =>
1894
- switchbot = new Switchbot(),
1895
- );
1896
- });
1891
+ Switchbot = require('node-switchbot');
1892
+ queueScheduler.schedule(() =>
1893
+ switchbot = new Switchbot(),
1894
+ );
1897
1895
  } catch (e: any) {
1898
1896
  switchbot = false;
1899
1897
  this.errorLog(`Was 'node-switchbot' found: ${switchbot}`);