@switchbot/homebridge-switchbot 2.0.0-beta.0 → 2.0.0-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 (46) hide show
  1. package/.github/workflows/{label.yml → labeler.yml} +4 -6
  2. package/CHANGELOG.md +2 -1
  3. package/config.schema.json +17 -1
  4. package/dist/device/bot.d.ts +0 -1
  5. package/dist/device/bot.d.ts.map +1 -1
  6. package/dist/device/bot.js +14 -29
  7. package/dist/device/bot.js.map +1 -1
  8. package/dist/device/colorbulb.d.ts +1 -6
  9. package/dist/device/colorbulb.d.ts.map +1 -1
  10. package/dist/device/colorbulb.js +19 -19
  11. package/dist/device/colorbulb.js.map +1 -1
  12. package/dist/device/curtain.d.ts.map +1 -1
  13. package/dist/device/curtain.js +0 -1
  14. package/dist/device/curtain.js.map +1 -1
  15. package/dist/device/meter.d.ts +0 -4
  16. package/dist/device/meter.d.ts.map +1 -1
  17. package/dist/device/meter.js.map +1 -1
  18. package/dist/device/meterplus.d.ts +0 -4
  19. package/dist/device/meterplus.d.ts.map +1 -1
  20. package/dist/device/meterplus.js.map +1 -1
  21. package/dist/device/plug.d.ts +0 -1
  22. package/dist/device/plug.d.ts.map +1 -1
  23. package/dist/device/plug.js +3 -8
  24. package/dist/device/plug.js.map +1 -1
  25. package/dist/device/striplight.d.ts +16 -5
  26. package/dist/device/striplight.d.ts.map +1 -1
  27. package/dist/device/striplight.js +167 -10
  28. package/dist/device/striplight.js.map +1 -1
  29. package/dist/platform.d.ts +3 -1
  30. package/dist/platform.d.ts.map +1 -1
  31. package/dist/platform.js +93 -79
  32. package/dist/platform.js.map +1 -1
  33. package/dist/settings.d.ts +2 -0
  34. package/dist/settings.d.ts.map +1 -1
  35. package/dist/settings.js.map +1 -1
  36. package/package.json +9 -9
  37. package/src/device/bot.ts +14 -30
  38. package/src/device/colorbulb.ts +21 -25
  39. package/src/device/curtain.ts +0 -1
  40. package/src/device/meter.ts +0 -4
  41. package/src/device/meterplus.ts +0 -4
  42. package/src/device/plug.ts +3 -9
  43. package/src/device/striplight.ts +180 -15
  44. package/src/platform.ts +88 -73
  45. package/src/settings.ts +2 -0
  46. package/.github/labeler.yml +0 -13
package/src/device/bot.ts CHANGED
@@ -29,7 +29,6 @@ export class Bot {
29
29
 
30
30
  // Characteristic Values
31
31
  On!: CharacteristicValue;
32
- OnCached!: CharacteristicValue;
33
32
  BatteryLevel!: CharacteristicValue;
34
33
  StatusLowBattery!: CharacteristicValue;
35
34
 
@@ -388,16 +387,14 @@ export class Bot {
388
387
  this.debugLog(`Bot: ${this.accessory.displayName} BLE parseStatus`);
389
388
  // BLEmode (true if Switch Mode) | (false if Press Mode)
390
389
  if (this.mode) {
391
- this.OnCached = this.On;
392
- this.accessory.context.On = this.OnCached;
390
+ this.accessory.context.On = this.On;
393
391
  if (this.On === undefined) {
394
392
  this.On = Boolean(this.state);
395
393
  }
396
394
  this.debugLog(`Bot: ${this.accessory.displayName} Switch Mode, mode: ${this.mode}, On: ${this.On}`);
397
395
  } else {
398
396
  this.On = false;
399
- this.OnCached = this.On;
400
- this.accessory.context.On = this.OnCached;
397
+ this.accessory.context.On = this.On;
401
398
  this.debugLog(`Bot: ${this.accessory.displayName} Press Mode, mode: ${this.mode}, On: ${this.On}`);
402
399
  }
403
400
 
@@ -421,20 +418,9 @@ export class Bot {
421
418
  this.debugLog(`Bot: ${this.accessory.displayName} OpenAPI parseStatus`);
422
419
  if (this.botMode === 'press') {
423
420
  this.On = false;
424
- this.OnCached = this.On;
425
- this.accessory.context.On = this.OnCached;
421
+ this.accessory.context.On = this.On;
426
422
  } else {
427
- /*if (this.power === 'on') {
428
- this.On = true;
429
- this.OnCached = this.On;
430
- this.accessory.context.On = this.OnCached;
431
- } else {
432
- this.On = false;
433
- this.OnCached = this.On;
434
- this.accessory.context.On = this.OnCached;
435
- }*/
436
- this.OnCached = this.On;
437
- this.accessory.context.On = this.OnCached;
423
+ this.accessory.context.On = this.On;
438
424
  if (this.On === undefined) {
439
425
  this.On = false;
440
426
  }
@@ -635,8 +621,8 @@ export class Bot {
635
621
  }
636
622
 
637
623
  async BLEpushChanges(): Promise<void> {
638
- this.debugLog(`Bot: ${this.accessory.displayName} BLE pushChanges On: ${this.On} OnCached: ${this.OnCached}`);
639
- if (this.On !== this.OnCached || this.allowPush) {
624
+ this.debugLog(`Bot: ${this.accessory.displayName} BLE pushChanges On: ${this.On} OnCached: ${this.accessory.context.On}`);
625
+ if (this.On !== this.accessory.context.On || this.allowPush) {
640
626
  this.debugLog(`Bot: ${this.accessory.displayName} BLE pushChanges`);
641
627
  const switchbot = await this.platform.connectBLE();
642
628
  // Convert to BLE Address
@@ -656,9 +642,7 @@ export class Bot {
656
642
  })
657
643
  .then(() => {
658
644
  this.debugLog(`Bot: ${this.accessory.displayName} Done.`);
659
- this.On = false;
660
- this.OnCached = this.On;
661
- this.accessory.context.On = this.OnCached;
645
+ this.accessory.context.On = this.On;
662
646
  setTimeout(() => {
663
647
  if (this.device.bot?.deviceType === 'switch') {
664
648
  this.switchService?.getCharacteristic(this.platform.Characteristic.On).updateValue(this.On);
@@ -694,8 +678,7 @@ export class Bot {
694
678
  })
695
679
  .then(() => {
696
680
  this.debugLog(`Bot: ${this.accessory.displayName} Done.`);
697
- this.OnCached = this.On;
698
- this.accessory.context.On = this.OnCached;
681
+ this.accessory.context.On = this.On;
699
682
  })
700
683
  .catch(async (e: any) => {
701
684
  this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges with BLE Connection`);
@@ -717,8 +700,7 @@ export class Bot {
717
700
  throw new Error(`Bot: ${this.accessory.displayName} Bot Mode: ${this.botMode}`);
718
701
  }
719
702
  }
720
- this.OnCached = this.On;
721
- this.accessory.context.On = this.OnCached;
703
+ this.accessory.context.On = this.On;
722
704
  }
723
705
 
724
706
  async turnOnOff(device_list: any): Promise<any> {
@@ -737,7 +719,7 @@ export class Bot {
737
719
  async openAPIpushChanges(): Promise<void> {
738
720
  if (this.platform.config.credentials?.token) {
739
721
  try {
740
- if (this.On !== this.OnCached || this.allowPush) {
722
+ if (this.On !== this.accessory.context.On || this.allowPush) {
741
723
  this.debugLog(`Bot: ${this.accessory.displayName} OpenAPI pushChanges`);
742
724
  // Make Push On request to the API
743
725
  const t = Date.now();
@@ -797,8 +779,7 @@ export class Bot {
797
779
  req.write(body);
798
780
  req.end();
799
781
  this.debugLog(`Bot: ${this.accessory.displayName} openAPIpushChanges: ${JSON.stringify(req)}`);
800
- this.OnCached = this.On;
801
- this.accessory.context.On = this.OnCached;
782
+ this.accessory.context.On = this.On;
802
783
  }
803
784
  } catch (e: any) {
804
785
  this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
@@ -989,16 +970,19 @@ export class Bot {
989
970
  this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
990
971
  }
991
972
  }
973
+ this.accessory.context.On = this.On;
992
974
  if (this.device.ble) {
993
975
  if (this.BatteryLevel === undefined) {
994
976
  this.debugLog(`Bot: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}`);
995
977
  } else {
978
+ this.accessory.context.BatteryLevel = this.BatteryLevel;
996
979
  this.batteryService?.updateCharacteristic(this.platform.Characteristic.BatteryLevel, this.BatteryLevel);
997
980
  this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic BatteryLevel: ${this.BatteryLevel}`);
998
981
  }
999
982
  if (this.StatusLowBattery === undefined) {
1000
983
  this.debugLog(`Bot: ${this.accessory.displayName} StatusLowBattery: ${this.StatusLowBattery}`);
1001
984
  } else {
985
+ this.accessory.context.StatusLowBattery = this.StatusLowBattery;
1002
986
  this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, this.StatusLowBattery);
1003
987
  this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic StatusLowBattery: ${this.StatusLowBattery}`);
1004
988
  }
@@ -19,15 +19,10 @@ export class ColorBulb {
19
19
 
20
20
  // Characteristic Values
21
21
  On!: CharacteristicValue;
22
- OnCached!: CharacteristicValue;
23
22
  Hue!: CharacteristicValue;
24
- HueCached!: CharacteristicValue;
25
23
  Saturation!: CharacteristicValue;
26
- SaturationCached!: CharacteristicValue;
27
24
  Brightness!: CharacteristicValue;
28
- BrightnessCached!: CharacteristicValue;
29
25
  ColorTemperature?: CharacteristicValue;
30
- ColorTemperatureCached?: CharacteristicValue;
31
26
 
32
27
  // OpenAPI Others
33
28
  power: deviceStatus['power'];
@@ -317,10 +312,7 @@ export class ColorBulb {
317
312
  })
318
313
  .then(() => {
319
314
  // Set an event hander
320
- this.errorLog(`Color Bulb: ${this.accessory.displayName} then switchbot: ${JSON.stringify(switchbot)}`);
321
315
  switchbot.onadvertisement = (ad: any) => {
322
- this.errorLog(`Color Bulb: ${this.accessory.displayName} switchbot: ${JSON.stringify(switchbot.onadvertisement)}`);
323
- this.errorLog(`Color Bulb: ${this.accessory.displayName} ad: ${JSON.stringify(ad)}`);
324
316
  this.address = ad.address;
325
317
  if (this.deviceLogging.includes('debug')) {
326
318
  this.infoLog(this.address);
@@ -328,6 +320,7 @@ export class ColorBulb {
328
320
  this.infoLog(`Color Bulb: ${this.accessory.displayName} BLE Address Found: ${this.address}`);
329
321
  this.infoLog(`Color Bulb: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac}`);
330
322
  }
323
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} serviceData: ${JSON.stringify(ad.serviceData)}`);
331
324
  this.serviceData = ad.serviceData;
332
325
  //this.state = ad.serviceData.state;
333
326
  //this.delay = ad.serviceData.delay;
@@ -416,7 +409,7 @@ export class ColorBulb {
416
409
  }
417
410
  }
418
411
 
419
- private async openAPIRefreshStatus() {
412
+ async openAPIRefreshStatus() {
420
413
  try {
421
414
  const t = Date.now();
422
415
  const nonce = 'requestID';
@@ -487,7 +480,7 @@ export class ColorBulb {
487
480
  */
488
481
  async pushChanges(): Promise<void> {
489
482
  try {
490
- if (this.On !== this.OnCached) {
483
+ if (this.On !== this.accessory.context.On) {
491
484
  // Make Push On request to the API
492
485
  const t = Date.now();
493
486
  const nonce = 'requestID';
@@ -537,17 +530,15 @@ export class ColorBulb {
537
530
  req.write(body);
538
531
  req.end();
539
532
  this.debugLog(`Color Bulb: ${this.accessory.displayName} pushChanges: ${JSON.stringify(req)}`);
540
- this.OnCached = this.On;
541
- this.accessory.context.On = this.OnCached;
542
533
  }
543
534
  // Push Brightness Update
544
535
  if (this.On) {
545
- //await this.pushBrightnessChanges();
536
+ await this.pushBrightnessChanges();
546
537
  }
547
538
 
548
539
  // Push ColorTemperature Update
549
540
  if (this.On) {
550
- //await this.pushColorTemperatureChanges();
541
+ await this.pushColorTemperatureChanges();
551
542
  }
552
543
 
553
544
  // Push Hue & Saturation Update
@@ -567,7 +558,7 @@ export class ColorBulb {
567
558
 
568
559
  async pushHueSaturationChanges(): Promise<void> {
569
560
  try {
570
- if (this.Hue !== this.HueCached || this.Saturation !== this.SaturationCached) {
561
+ if (this.Hue !== this.accessory.context.Hue || this.Saturation !== this.accessory.context.Saturation) {
571
562
  this.debugLog(`Color Bulb: ${this.accessory.displayName} Hue: ${JSON.stringify(this.Hue)}`);
572
563
  this.debugLog(`Color Bulb: ${this.accessory.displayName} Saturation: ${JSON.stringify(this.Saturation)}`);
573
564
 
@@ -615,12 +606,11 @@ export class ColorBulb {
615
606
  req.write(body);
616
607
  req.end();
617
608
  this.debugLog(`Color Bulb: ${this.accessory.displayName} pushHueSaturationChanges: ${JSON.stringify(req)}`);
618
- this.HueCached = this.Hue;
619
- this.SaturationCached = this.Saturation;
620
609
  } else {
621
610
  this.debugLog(
622
611
  `Color Bulb: ${this.accessory.displayName} No Changes.` +
623
- `Hue: ${this.Hue}, HueCached: ${this.HueCached}, Saturation: ${this.Saturation}, SaturationCached: ${this.SaturationCached}`,
612
+ `Hue: ${this.Hue}, HueCached: ${this.accessory.context.Hue}, Saturation: ${this.Saturation},`
613
+ +` SaturationCached: ${this.accessory.context.Saturation}`,
624
614
  );
625
615
  }
626
616
  } catch (e: any) {
@@ -636,7 +626,7 @@ export class ColorBulb {
636
626
 
637
627
  async pushColorTemperatureChanges(): Promise<void> {
638
628
  try {
639
- if (this.ColorTemperature !== this.ColorTemperatureCached) {
629
+ if (this.ColorTemperature !== this.accessory.context.ColorTemperature) {
640
630
  const kelvin = Math.round(1000000 / Number(this.ColorTemperature));
641
631
  this.cacheKelvin = kelvin;
642
632
 
@@ -682,11 +672,11 @@ export class ColorBulb {
682
672
  req.end();
683
673
 
684
674
  this.debugLog(`Color Bulb: ${this.accessory.displayName} pushColorTemperatureChanges: ${JSON.stringify(req)}`);
685
- this.ColorTemperatureCached = this.ColorTemperature;
675
+ this.accessory.context.ColorTemperature = this.ColorTemperature;
686
676
  } else {
687
677
  this.debugLog(
688
678
  `Color Bulb: ${this.accessory.displayName} No Changes.` +
689
- `ColorTemperature: ${this.ColorTemperature}, ColorTemperatureCached: ${this.ColorTemperatureCached}`,
679
+ `ColorTemperature: ${this.ColorTemperature}, ColorTemperatureCached: ${this.accessory.context.ColorTemperature}`,
690
680
  );
691
681
  }
692
682
  } catch (e: any) {
@@ -702,7 +692,7 @@ export class ColorBulb {
702
692
 
703
693
  async pushBrightnessChanges(): Promise<void> {
704
694
  try {
705
- if (this.Brightness !== this.BrightnessCached) {
695
+ if (this.Brightness !== this.accessory.context.Brightness) {
706
696
  // Make Push On request to the API
707
697
  const t = Date.now();
708
698
  const nonce = 'requestID';
@@ -744,10 +734,10 @@ export class ColorBulb {
744
734
  req.write(body);
745
735
  req.end();
746
736
  this.debugLog(`Color Bulb: ${this.accessory.displayName} pushBrightnessChanges: ${JSON.stringify(req)}`);
747
- this.BrightnessCached = this.Brightness;
748
737
  } else {
749
738
  this.debugLog(
750
- `Color Bulb: ${this.accessory.displayName} No Changes.` + `Brightness: ${this.Brightness}, BrightnessCached: ${this.BrightnessCached}`,
739
+ `Color Bulb: ${this.accessory.displayName} No Changes.` + `Brightness: ${this.Brightness}, `
740
+ +`BrightnessCached: ${this.accessory.context.Brightness}`,
751
741
  );
752
742
  }
753
743
  } catch (e: any) {
@@ -765,30 +755,36 @@ export class ColorBulb {
765
755
  if (this.On === undefined) {
766
756
  this.debugLog(`Color Bulb: ${this.accessory.displayName} On: ${this.On}`);
767
757
  } else {
758
+ this.accessory.context.On = this.On;
768
759
  this.lightBulbService.updateCharacteristic(this.platform.Characteristic.On, this.On);
769
760
  this.debugLog(`Color Bulb: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
770
761
  }
771
762
  if (this.Brightness === undefined) {
772
763
  this.debugLog(`Color Bulb: ${this.accessory.displayName} Brightness: ${this.Brightness}`);
773
764
  } else {
765
+ this.accessory.context.Brightness = this.Brightness;
774
766
  this.lightBulbService.updateCharacteristic(this.platform.Characteristic.Brightness, this.Brightness);
775
767
  this.debugLog(`Color Bulb: ${this.accessory.displayName} updateCharacteristic Brightness: ${this.Brightness}`);
776
768
  }
777
769
  if (this.ColorTemperature === undefined) {
778
770
  this.debugLog(`Color Bulb: ${this.accessory.displayName} ColorTemperature: ${this.ColorTemperature}`);
779
771
  } else {
772
+
773
+ this.accessory.context.ColorTemperature = this.ColorTemperature;
780
774
  this.lightBulbService.updateCharacteristic(this.platform.Characteristic.ColorTemperature, this.ColorTemperature);
781
775
  this.debugLog(`Color Bulb: ${this.accessory.displayName} updateCharacteristic ColorTemperature: ${this.ColorTemperature}`);
782
776
  }
783
777
  if (this.Hue === undefined) {
784
778
  this.debugLog(`Color Bulb: ${this.accessory.displayName} Hue: ${this.Hue}`);
785
779
  } else {
780
+ this.accessory.context.Hue = this.Hue;
786
781
  this.lightBulbService.updateCharacteristic(this.platform.Characteristic.Hue, this.Hue);
787
782
  this.debugLog(`Color Bulb: ${this.accessory.displayName} updateCharacteristic Hue: ${this.Hue}`);
788
783
  }
789
784
  if (this.Saturation === undefined) {
790
785
  this.debugLog(`Color Bulb: ${this.accessory.displayName} Saturation: ${this.Saturation}`);
791
786
  } else {
787
+ this.accessory.context.Saturation = this.Saturation;
792
788
  this.lightBulbService.updateCharacteristic(this.platform.Characteristic.Saturation, this.Saturation);
793
789
  this.debugLog(`Color Bulb: ${this.accessory.displayName} updateCharacteristic Saturation: ${this.Saturation}`);
794
790
  }
@@ -879,7 +875,7 @@ export class ColorBulb {
879
875
  // Check and increase/decrease kelvin to range of device
880
876
  const k = Math.min(Math.max(kelvin, this.minKelvin), this.maxKelvin);
881
877
 
882
- if (!this.OnCached || this.cacheKelvin === k) {
878
+ if (!this.accessory.context.On || this.cacheKelvin === k) {
883
879
  return;
884
880
  }
885
881
 
@@ -436,7 +436,6 @@ export class Curtain {
436
436
  this.debugLog(`Curtain: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
437
437
  this.getCustomBLEAddress(switchbot);
438
438
  // Start to monitor advertisement packets
439
- this.errorLog(`Color Bulb: ${this.accessory.displayName} switchbot: ${JSON.stringify(switchbot)}`);
440
439
  if (switchbot !== false) {
441
440
  switchbot
442
441
  .startScan({
@@ -23,14 +23,10 @@ export class Meter {
23
23
 
24
24
  // Characteristic Values
25
25
  CurrentRelativeHumidity!: CharacteristicValue;
26
- CurrentRelativeHumidityCached!: CharacteristicValue;
27
26
  CurrentTemperature?: CharacteristicValue;
28
- CurrentTemperatureCached?: CharacteristicValue;
29
27
  BatteryLevel?: CharacteristicValue;
30
28
  ChargingState?: CharacteristicValue;
31
29
  StatusLowBattery?: CharacteristicValue;
32
- Active!: CharacteristicValue;
33
- WaterLevel!: CharacteristicValue;
34
30
 
35
31
  // OpenAPI Others
36
32
  Temperature: deviceStatus['temperature'];
@@ -20,14 +20,10 @@ export class MeterPlus {
20
20
 
21
21
  // Characteristic Values
22
22
  CurrentRelativeHumidity!: CharacteristicValue;
23
- CurrentRelativeHumidityCached!: CharacteristicValue;
24
23
  CurrentTemperature?: CharacteristicValue;
25
- CurrentTemperatureCached?: CharacteristicValue;
26
24
  BatteryLevel?: CharacteristicValue;
27
25
  ChargingState?: CharacteristicValue;
28
26
  StatusLowBattery?: CharacteristicValue;
29
- Active!: CharacteristicValue;
30
- WaterLevel!: CharacteristicValue;
31
27
 
32
28
  // OpenAPI Others
33
29
  Temperature: deviceStatus['temperature'];
@@ -14,7 +14,6 @@ export class Plug {
14
14
 
15
15
  // Characteristic Values
16
16
  On!: CharacteristicValue;
17
- OnCached!: CharacteristicValue;
18
17
 
19
18
  // OpenAPI Others
20
19
  power: deviceStatus['power'];
@@ -355,7 +354,7 @@ export class Plug {
355
354
  }
356
355
 
357
356
  async BLEpushChanges(): Promise<void> {
358
- this.debugLog(`Plug: ${this.accessory.displayName} BLE pushChanges On: ${this.On} OnCached: ${this.OnCached}`);
357
+ this.debugLog(`Plug: ${this.accessory.displayName} BLE pushChanges On: ${this.On} OnCached: ${this.accessory.context.On}`);
359
358
  this.debugLog(`Plug: ${this.accessory.displayName} BLE pushChanges`);
360
359
  const switchbot = await this.platform.connectBLE();
361
360
  // Convert to BLE Address
@@ -376,8 +375,6 @@ export class Plug {
376
375
  .then(() => {
377
376
  this.debugLog(`Plug: ${this.accessory.displayName} Done.`);
378
377
  this.On = false;
379
- this.OnCached = this.On;
380
- this.accessory.context.On = this.OnCached;
381
378
  })
382
379
  .catch(async (e: any) => {
383
380
  this.errorLog(`Plug: ${this.accessory.displayName} failed pushChanges with BLE Connection`);
@@ -395,8 +392,6 @@ export class Plug {
395
392
  }
396
393
  this.apiError(e);
397
394
  });
398
- this.OnCached = this.On;
399
- this.accessory.context.On = this.OnCached;
400
395
  }
401
396
 
402
397
  async turnOnOff(device_list: any): Promise<any> {
@@ -414,7 +409,7 @@ export class Plug {
414
409
 
415
410
  async openAPIpushChanges() {
416
411
  if (this.platform.config.credentials?.token) {
417
- if (this.On !== this.OnCached) {
412
+ if (this.On !== this.accessory.context.On) {
418
413
  // Make Push On request to the API
419
414
  this.debugLog(`Plug: ${this.accessory.displayName} OpenAPI pushChanges`);
420
415
  const t = Date.now();
@@ -465,8 +460,6 @@ export class Plug {
465
460
  req.write(body);
466
461
  req.end();
467
462
  this.debugLog(`Plug: ${this.accessory.displayName} openAPIpushChanges: ${JSON.stringify(req)}`);
468
- this.OnCached = this.On;
469
- this.accessory.context.On = this.OnCached;
470
463
  }
471
464
  interval(5000)
472
465
  .pipe(take(1))
@@ -480,6 +473,7 @@ export class Plug {
480
473
  if (this.On === undefined) {
481
474
  this.debugLog(`Plug: ${this.accessory.displayName} On: ${this.On}`);
482
475
  } else {
476
+ this.accessory.context.On = this.On;
483
477
  this.outletService.updateCharacteristic(this.platform.Characteristic.On, this.On);
484
478
  this.debugLog(`Plug: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
485
479
  }