@switchbot/homebridge-switchbot 2.1.2-beta.1 → 2.1.2-beta.10

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 (61) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/config.schema.json +8 -0
  3. package/dist/device/bot.d.ts +1 -1
  4. package/dist/device/bot.d.ts.map +1 -1
  5. package/dist/device/bot.js +10 -10
  6. package/dist/device/bot.js.map +1 -1
  7. package/dist/device/ceilinglight.d.ts +1 -1
  8. package/dist/device/ceilinglight.d.ts.map +1 -1
  9. package/dist/device/ceilinglight.js +10 -5
  10. package/dist/device/ceilinglight.js.map +1 -1
  11. package/dist/device/colorbulb.d.ts +1 -1
  12. package/dist/device/colorbulb.d.ts.map +1 -1
  13. package/dist/device/colorbulb.js +10 -5
  14. package/dist/device/colorbulb.js.map +1 -1
  15. package/dist/device/contact.d.ts.map +1 -1
  16. package/dist/device/contact.js +8 -4
  17. package/dist/device/contact.js.map +1 -1
  18. package/dist/device/curtain.d.ts.map +1 -1
  19. package/dist/device/curtain.js +7 -2
  20. package/dist/device/curtain.js.map +1 -1
  21. package/dist/device/humidifier.d.ts.map +1 -1
  22. package/dist/device/humidifier.js +18 -12
  23. package/dist/device/humidifier.js.map +1 -1
  24. package/dist/device/lock.d.ts +1 -1
  25. package/dist/device/lock.d.ts.map +1 -1
  26. package/dist/device/lock.js +11 -6
  27. package/dist/device/lock.js.map +1 -1
  28. package/dist/device/meter.d.ts.map +1 -1
  29. package/dist/device/meter.js +8 -12
  30. package/dist/device/meter.js.map +1 -1
  31. package/dist/device/meterplus.d.ts +1 -1
  32. package/dist/device/meterplus.d.ts.map +1 -1
  33. package/dist/device/meterplus.js +9 -13
  34. package/dist/device/meterplus.js.map +1 -1
  35. package/dist/device/motion.d.ts.map +1 -1
  36. package/dist/device/motion.js +8 -4
  37. package/dist/device/motion.js.map +1 -1
  38. package/dist/device/plug.d.ts.map +1 -1
  39. package/dist/device/plug.js +9 -4
  40. package/dist/device/plug.js.map +1 -1
  41. package/dist/device/striplight.d.ts.map +1 -1
  42. package/dist/device/striplight.js +9 -4
  43. package/dist/device/striplight.js.map +1 -1
  44. package/dist/platform.d.ts +3 -1
  45. package/dist/platform.d.ts.map +1 -1
  46. package/dist/platform.js +53 -32
  47. package/dist/platform.js.map +1 -1
  48. package/package.json +2 -2
  49. package/src/device/bot.ts +10 -9
  50. package/src/device/ceilinglight.ts +10 -5
  51. package/src/device/colorbulb.ts +10 -5
  52. package/src/device/contact.ts +8 -4
  53. package/src/device/curtain.ts +7 -2
  54. package/src/device/humidifier.ts +19 -14
  55. package/src/device/lock.ts +11 -6
  56. package/src/device/meter.ts +8 -13
  57. package/src/device/meterplus.ts +9 -14
  58. package/src/device/motion.ts +8 -4
  59. package/src/device/plug.ts +9 -4
  60. package/src/device/striplight.ts +9 -4
  61. package/src/platform.ts +56 -35
@@ -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,11 @@ 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();
967
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} offline context: ${superStringify(this.context)}`);
965
968
  await this.updateHomeKitCharacteristics();
969
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} `
970
+ + `offline updateHomeKitCharacteristics: ${superStringify(this.updateHomeKitCharacteristics)}`);
966
971
  }
967
972
  }
968
973
 
@@ -199,6 +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
+ await this.offlineOff();
202
203
  this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
203
204
  + ` ${this.device.connectionType}, parseStatus will not happen.`);
204
205
  }
@@ -288,6 +289,7 @@ export class Humidifier {
288
289
  } else if (this.OpenAPI && this.platform.config.credentials?.token) {
289
290
  await this.openAPIRefreshStatus();
290
291
  } else {
292
+ await this.offlineOff();
291
293
  this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
292
294
  + ` ${this.device.connectionType}, refreshStatus will not happen.`);
293
295
  }
@@ -426,6 +428,7 @@ export class Humidifier {
426
428
  } else*/ if (this.OpenAPI && this.platform.config.credentials?.token) {
427
429
  await this.openAPIpushChanges();
428
430
  } else {
431
+ await this.offlineOff();
429
432
  this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
430
433
  + ` ${this.device.connectionType}, pushChanges will not happen.`);
431
434
  }
@@ -705,65 +708,64 @@ export class Humidifier {
705
708
  if (this.CurrentRelativeHumidity === undefined) {
706
709
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
707
710
  } else {
708
- this.accessory.context.CurrentRelativeHumidity = this.CurrentRelativeHumidity;
709
711
  this.humidifierService.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, this.CurrentRelativeHumidity);
710
712
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
711
713
  + ` updateCharacteristic CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
714
+ this.accessory.context.CurrentRelativeHumidity = this.CurrentRelativeHumidity;
712
715
  }
713
716
  if (this.OpenAPI) {
714
717
  if (this.WaterLevel === undefined) {
715
718
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} WaterLevel: ${this.WaterLevel}`);
716
719
  } else {
717
- this.accessory.context.WaterLevel = this.WaterLevel;
718
720
  this.humidifierService.updateCharacteristic(this.platform.Characteristic.WaterLevel, this.WaterLevel);
719
721
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic WaterLevel: ${this.WaterLevel}`);
722
+ this.accessory.context.WaterLevel = this.WaterLevel;
720
723
  }
721
724
  }
722
725
  if (this.CurrentHumidifierDehumidifierState === undefined) {
723
726
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
724
727
  + ` CurrentHumidifierDehumidifierState: ${this.CurrentHumidifierDehumidifierState}`);
725
728
  } else {
726
- this.accessory.context.CurrentHumidifierDehumidifierState = this.CurrentHumidifierDehumidifierState;
727
729
  this.humidifierService.updateCharacteristic(this.platform.Characteristic.CurrentHumidifierDehumidifierState,
728
730
  this.CurrentHumidifierDehumidifierState);
729
731
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}` +
730
732
  ` updateCharacteristic CurrentHumidifierDehumidifierState: ${this.CurrentHumidifierDehumidifierState}`);
733
+ this.accessory.context.CurrentHumidifierDehumidifierState = this.CurrentHumidifierDehumidifierState;
731
734
  }
732
735
  if (this.TargetHumidifierDehumidifierState === undefined) {
733
736
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
734
737
  +` TargetHumidifierDehumidifierState: ${this.TargetHumidifierDehumidifierState}`);
735
738
  } else {
736
- this.accessory.context.TargetHumidifierDehumidifierState = this.TargetHumidifierDehumidifierState;
737
739
  this.humidifierService.updateCharacteristic(this.platform.Characteristic.TargetHumidifierDehumidifierState,
738
740
  this.TargetHumidifierDehumidifierState);
739
741
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}` +
740
- ` updateCharacteristic TargetHumidifierDehumidifierState: ${this.TargetHumidifierDehumidifierState}`,
741
- );
742
+ ` updateCharacteristic TargetHumidifierDehumidifierState: ${this.TargetHumidifierDehumidifierState}`);
743
+ this.accessory.context.TargetHumidifierDehumidifierState = this.TargetHumidifierDehumidifierState;
742
744
  }
743
745
  if (this.Active === undefined) {
744
746
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Active: ${this.Active}`);
745
747
  } else {
746
- this.accessory.context.Active = this.Active;
747
748
  this.humidifierService.updateCharacteristic(this.platform.Characteristic.Active, this.Active);
748
749
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`);
750
+ this.accessory.context.Active = this.Active;
749
751
  }
750
752
  if (this.RelativeHumidityHumidifierThreshold === undefined) {
751
753
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
752
754
  + ` RelativeHumidityHumidifierThreshold: ${this.RelativeHumidityHumidifierThreshold}`);
753
755
  } else {
754
- this.accessory.context.RelativeHumidityHumidifierThreshold = this.RelativeHumidityHumidifierThreshold;
755
756
  this.humidifierService.updateCharacteristic(this.platform.Characteristic.RelativeHumidityHumidifierThreshold,
756
757
  this.RelativeHumidityHumidifierThreshold);
757
758
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}` +
758
759
  ` updateCharacteristic RelativeHumidityHumidifierThreshold: ${this.RelativeHumidityHumidifierThreshold}`);
760
+ this.accessory.context.RelativeHumidityHumidifierThreshold = this.RelativeHumidityHumidifierThreshold;
759
761
  }
760
762
  if (!this.device.humidifier?.hide_temperature && !this.BLE) {
761
763
  if (this.CurrentTemperature === undefined) {
762
764
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature}`);
763
765
  } else {
764
- this.accessory.context.CurrentTemperature = this.CurrentTemperature;
765
766
  this.temperatureservice?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, this.CurrentTemperature);
766
767
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic CurrentTemperature: ${this.CurrentTemperature}`);
768
+ this.accessory.context.CurrentTemperature = this.CurrentTemperature;
767
769
  }
768
770
  }
769
771
  }
@@ -837,11 +839,11 @@ export class Humidifier {
837
839
  break;
838
840
  case 161:
839
841
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Device is offline.`);
840
- this.offlineOff();
842
+ await this.offlineOff();
841
843
  break;
842
844
  case 171:
843
845
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
844
- this.offlineOff();
846
+ await this.offlineOff();
845
847
  break;
846
848
  case 190:
847
849
  this.errorLog(
@@ -858,10 +860,13 @@ export class Humidifier {
858
860
  }
859
861
 
860
862
  async offlineOff(): Promise<void> {
863
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} offline: ${this.device.offline}`);
861
864
  if (this.device.offline) {
862
- this.Active = this.platform.Characteristic.Active.INACTIVE;
863
- this.humidifierService.getCharacteristic(this.platform.Characteristic.Active).updateValue(this.Active);
865
+ await this.context();
866
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} offline context: ${superStringify(this.context)}`);
864
867
  await this.updateHomeKitCharacteristics();
868
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} `
869
+ + `offline updateHomeKitCharacteristics: ${superStringify(this.updateHomeKitCharacteristics)}`);
865
870
  }
866
871
  }
867
872
 
@@ -902,7 +907,7 @@ export class Humidifier {
902
907
  this.Active = this.accessory.context.Active;
903
908
  }
904
909
  if (this.CurrentTemperature === undefined) {
905
- this.CurrentTemperature = 0;
910
+ this.CurrentTemperature = 30;
906
911
  } else {
907
912
  this.CurrentTemperature = this.accessory.context.CurrentTemperature;
908
913
  }
@@ -43,7 +43,7 @@ export class Lock {
43
43
  this.scan(device);
44
44
  this.refreshRate(device);
45
45
  this.config(device);
46
- this.conext();
46
+ this.context();
47
47
 
48
48
  // this is subject we use to track when we need to POST changes to the SwitchBot API
49
49
  this.doLockUpdate = new Subject();
@@ -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,11 @@ 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.context();
495
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} offline context: ${superStringify(this.context)}`);
493
496
  await this.updateHomeKitCharacteristics();
497
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} `
498
+ + `offline updateHomeKitCharacteristics: ${superStringify(this.updateHomeKitCharacteristics)}`);
494
499
  }
495
500
  }
496
501
 
@@ -518,7 +523,7 @@ export class Lock {
518
523
  return FirmwareRevision;
519
524
  }
520
525
 
521
- private conext() {
526
+ async context() {
522
527
  if (this.LockTargetState === undefined) {
523
528
  this.LockTargetState = false;
524
529
  } 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,11 @@ 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);
572
- }
573
- if (!this.device.meter?.hide_temperature) {
574
- this.temperatureservice?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, this.accessory.context.CurrentTemperature);
575
- }
576
- 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
- }
571
+ await this.context();
572
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} offline context: ${superStringify(this.context)}`);
580
573
  await this.updateHomeKitCharacteristics();
574
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} `
575
+ + `offline updateHomeKitCharacteristics: ${superStringify(this.updateHomeKitCharacteristics)}`);
581
576
  }
582
577
  }
583
578
 
@@ -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,11 @@ 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);
581
- }
582
- if (!this.device.meter?.hide_temperature) {
583
- this.temperatureservice?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, this.accessory.context.CurrentTemperature);
584
- }
585
- 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
- }
580
+ await this.context();
581
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} offline context: ${superStringify(this.context)}`);
589
582
  await this.updateHomeKitCharacteristics();
583
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} `
584
+ + `offline updateHomeKitCharacteristics: ${superStringify(this.updateHomeKitCharacteristics)}`);
590
585
  }
591
586
  }
592
587
 
@@ -619,7 +614,7 @@ export class MeterPlus {
619
614
  return FirmwareRevision;
620
615
  }
621
616
 
622
- private context() {
617
+ async context() {
623
618
  if (this.CurrentRelativeHumidity === undefined) {
624
619
  this.CurrentRelativeHumidity = 0;
625
620
  } 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,11 @@ 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();
490
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} offline context: ${superStringify(this.context)}`);
489
491
  await this.updateHomeKitCharacteristics();
492
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} `
493
+ + `offline updateHomeKitCharacteristics: ${superStringify(this.updateHomeKitCharacteristics)}`);
490
494
  }
491
495
  }
492
496
 
@@ -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,11 @@ 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();
604
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} offline context: ${superStringify(this.context)}`);
602
605
  await this.updateHomeKitCharacteristics();
606
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} `
607
+ + `offline updateHomeKitCharacteristics: ${superStringify(this.updateHomeKitCharacteristics)}`);
603
608
  }
604
609
  }
605
610
 
@@ -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,11 @@ 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();
959
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} offline context: ${superStringify(this.context)}`);
957
960
  await this.updateHomeKitCharacteristics();
961
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} `
962
+ + `offline updateHomeKitCharacteristics: ${superStringify(this.updateHomeKitCharacteristics)}`);
958
963
  }
959
964
  }
960
965