@switchbot/homebridge-switchbot 2.6.0 → 2.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.
Files changed (98) hide show
  1. package/.github/npm-version-script.js +81 -0
  2. package/CHANGELOG.md +9 -1
  3. package/dist/device/blindtilt.d.ts.map +1 -1
  4. package/dist/device/blindtilt.js +7 -6
  5. package/dist/device/blindtilt.js.map +1 -1
  6. package/dist/device/bot.d.ts.map +1 -1
  7. package/dist/device/bot.js +4 -3
  8. package/dist/device/bot.js.map +1 -1
  9. package/dist/device/ceilinglight.d.ts.map +1 -1
  10. package/dist/device/ceilinglight.js +13 -9
  11. package/dist/device/ceilinglight.js.map +1 -1
  12. package/dist/device/colorbulb.d.ts.map +1 -1
  13. package/dist/device/colorbulb.js +12 -8
  14. package/dist/device/colorbulb.js.map +1 -1
  15. package/dist/device/curtain.d.ts.map +1 -1
  16. package/dist/device/curtain.js +4 -3
  17. package/dist/device/curtain.js.map +1 -1
  18. package/dist/device/humidifier.d.ts.map +1 -1
  19. package/dist/device/humidifier.js +9 -6
  20. package/dist/device/humidifier.js.map +1 -1
  21. package/dist/device/lightstrip.d.ts.map +1 -1
  22. package/dist/device/lightstrip.js +9 -6
  23. package/dist/device/lightstrip.js.map +1 -1
  24. package/dist/device/lock.d.ts.map +1 -1
  25. package/dist/device/lock.js +3 -2
  26. package/dist/device/lock.js.map +1 -1
  27. package/dist/device/plug.d.ts.map +1 -1
  28. package/dist/device/plug.js +3 -2
  29. package/dist/device/plug.js.map +1 -1
  30. package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
  31. package/dist/device/robotvacuumcleaner.js +3 -2
  32. package/dist/device/robotvacuumcleaner.js.map +1 -1
  33. package/dist/irdevice/airconditioner.d.ts +1 -1
  34. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  35. package/dist/irdevice/airconditioner.js +9 -8
  36. package/dist/irdevice/airconditioner.js.map +1 -1
  37. package/dist/irdevice/airpurifier.d.ts +1 -1
  38. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  39. package/dist/irdevice/airpurifier.js +9 -8
  40. package/dist/irdevice/airpurifier.js.map +1 -1
  41. package/dist/irdevice/camera.d.ts +1 -1
  42. package/dist/irdevice/camera.d.ts.map +1 -1
  43. package/dist/irdevice/camera.js +7 -6
  44. package/dist/irdevice/camera.js.map +1 -1
  45. package/dist/irdevice/fan.d.ts +1 -1
  46. package/dist/irdevice/fan.d.ts.map +1 -1
  47. package/dist/irdevice/fan.js +13 -12
  48. package/dist/irdevice/fan.js.map +1 -1
  49. package/dist/irdevice/light.d.ts +1 -1
  50. package/dist/irdevice/light.d.ts.map +1 -1
  51. package/dist/irdevice/light.js +11 -10
  52. package/dist/irdevice/light.js.map +1 -1
  53. package/dist/irdevice/other.d.ts +1 -1
  54. package/dist/irdevice/other.d.ts.map +1 -1
  55. package/dist/irdevice/other.js +7 -6
  56. package/dist/irdevice/other.js.map +1 -1
  57. package/dist/irdevice/tv.d.ts +1 -1
  58. package/dist/irdevice/tv.d.ts.map +1 -1
  59. package/dist/irdevice/tv.js +25 -24
  60. package/dist/irdevice/tv.js.map +1 -1
  61. package/dist/irdevice/vacuumcleaner.d.ts +1 -1
  62. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  63. package/dist/irdevice/vacuumcleaner.js +7 -6
  64. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  65. package/dist/irdevice/waterheater.d.ts +1 -1
  66. package/dist/irdevice/waterheater.d.ts.map +1 -1
  67. package/dist/irdevice/waterheater.js +7 -6
  68. package/dist/irdevice/waterheater.js.map +1 -1
  69. package/dist/platform.d.ts.map +1 -1
  70. package/dist/platform.js +1 -0
  71. package/dist/platform.js.map +1 -1
  72. package/dist/settings.d.ts +0 -8
  73. package/dist/settings.d.ts.map +1 -1
  74. package/dist/settings.js +1 -9
  75. package/dist/settings.js.map +1 -1
  76. package/nodemon.json +1 -1
  77. package/package.json +1 -1
  78. package/src/device/blindtilt.ts +7 -6
  79. package/src/device/bot.ts +4 -3
  80. package/src/device/ceilinglight.ts +13 -9
  81. package/src/device/colorbulb.ts +12 -8
  82. package/src/device/curtain.ts +4 -3
  83. package/src/device/humidifier.ts +9 -6
  84. package/src/device/lightstrip.ts +9 -6
  85. package/src/device/lock.ts +3 -2
  86. package/src/device/plug.ts +3 -2
  87. package/src/device/robotvacuumcleaner.ts +3 -2
  88. package/src/irdevice/airconditioner.ts +9 -8
  89. package/src/irdevice/airpurifier.ts +9 -8
  90. package/src/irdevice/camera.ts +7 -6
  91. package/src/irdevice/fan.ts +13 -12
  92. package/src/irdevice/light.ts +11 -10
  93. package/src/irdevice/other.ts +7 -6
  94. package/src/irdevice/tv.ts +25 -24
  95. package/src/irdevice/vacuumcleaner.ts +7 -6
  96. package/src/irdevice/waterheater.ts +7 -6
  97. package/src/platform.ts +1 -0
  98. package/src/settings.ts +0 -10
package/nodemon.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "watch": ["src"],
3
3
  "ext": "ts",
4
4
  "ignore": [],
5
- "exec": "DEBUG= tsc && homebridge -T -D -P ..",
5
+ "exec": "DEBUG= tsc && homebridge -T -D -P -I ..",
6
6
  "signal": "SIGTERM",
7
7
  "env": {
8
8
  "NODE_OPTIONS": "--trace-warnings"
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "Homebridge SwitchBot",
3
3
  "name": "@switchbot/homebridge-switchbot",
4
- "version": "2.6.0",
4
+ "version": "2.6.2-beta.0",
5
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
6
  "author": "SwitchBot <support@wondertechlabs.com> (https://github.com/SwitchBot)",
7
7
  "license": "ISC",
@@ -629,7 +629,7 @@ export class BlindTilt {
629
629
  }
630
630
 
631
631
  async openAPIpushChanges(): Promise<void> {
632
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} OpenAPI pushChanges`);
632
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIpushChanges`);
633
633
  const hasDifferentAndRelevantHorizontalTiltAngle = (
634
634
  this.mappingMode === BlindTiltMappingMode.UseTiltForDirection
635
635
  && this.TargetHorizontalTiltAngle !== this.CurrentHorizontalTiltAngle);
@@ -637,27 +637,28 @@ export class BlindTilt {
637
637
  const [direction, position] = this.mapHomekitValuesToDeviceValues(Number(this.TargetPosition), Number(this.TargetHorizontalTiltAngle));
638
638
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Pushing ${this.TargetPosition} (device = ${direction};${position})`);
639
639
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Mode: ${this.Mode}`);
640
- let body = '';
640
+ let bodyChange = '';
641
641
  if (position === 100) {
642
- body = JSON.stringify({
642
+ bodyChange = JSON.stringify({
643
643
  'command': 'fullyOpen',
644
644
  'commandType': 'command',
645
645
  });
646
646
  } else if (position === 0) {
647
- body = JSON.stringify({
647
+ bodyChange = JSON.stringify({
648
648
  'command': direction === 'up' ? 'closeUp' : 'closeDown',
649
649
  'commandType': 'command',
650
650
  });
651
651
  } else {
652
- body = JSON.stringify({
652
+ bodyChange = JSON.stringify({
653
653
  'command': 'setPosition',
654
654
  'parameter': `${direction};${position}`,
655
655
  'commandType': 'command',
656
656
  });
657
657
  }
658
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
658
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
659
659
  try {
660
660
  const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
661
+ body: bodyChange,
661
662
  method: 'POST',
662
663
  headers: this.platform.generateHeaders(),
663
664
  });
package/src/device/bot.ts CHANGED
@@ -659,7 +659,7 @@ export class Bot {
659
659
  }
660
660
 
661
661
  async openAPIpushChanges(): Promise<void> {
662
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} OpenAPI pushChanges`);
662
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIpushChanges`);
663
663
  if (this.multiPressCount > 0) {
664
664
  this.debugLog(`${this.device.deviceType}: ${this.multiPressCount} request(s) queued.`);
665
665
  this.On = true;
@@ -681,14 +681,15 @@ export class Bot {
681
681
  } else {
682
682
  throw new Error(`${this.device.deviceType}: ${this.accessory.displayName} Device Paramters not set for this Bot.`);
683
683
  }
684
- const body = JSON.stringify({
684
+ const bodyChange = JSON.stringify({
685
685
  'command': `${command}`,
686
686
  'parameter': 'default',
687
687
  'commandType': 'command',
688
688
  });
689
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
689
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
690
690
  try {
691
691
  const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
692
+ body: bodyChange,
692
693
  method: 'POST',
693
694
  headers: this.platform.generateHeaders(),
694
695
  });
@@ -489,7 +489,7 @@ export class CeilingLight {
489
489
  }
490
490
 
491
491
  async openAPIpushChanges(): Promise<void> {
492
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} OpenAPI pushChanges`);
492
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIpushChanges`);
493
493
  if (this.On !== this.accessory.context.On) {
494
494
  let command = '';
495
495
  if (this.On) {
@@ -497,14 +497,15 @@ export class CeilingLight {
497
497
  } else {
498
498
  command = 'turnOff';
499
499
  }
500
- const body = JSON.stringify({
500
+ const bodyChange = JSON.stringify({
501
501
  'command': `${command}`,
502
502
  'parameter': 'default',
503
503
  'commandType': 'command',
504
504
  });
505
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
505
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
506
506
  try {
507
507
  const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
508
+ body: bodyChange,
508
509
  method: 'POST',
509
510
  headers: this.platform.generateHeaders(),
510
511
  });
@@ -543,14 +544,15 @@ export class CeilingLight {
543
544
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Saturation: ${JSON.stringify(this.Saturation)}`);
544
545
  const [red, green, blue] = hs2rgb(Number(this.Hue), Number(this.Saturation));
545
546
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} rgb: ${JSON.stringify([red, green, blue])}`);
546
- const body = JSON.stringify({
547
+ const bodyChange = JSON.stringify({
547
548
  'command': 'setColor',
548
549
  'parameter': `${red}:${green}:${blue}`,
549
550
  'commandType': 'command',
550
551
  });
551
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
552
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
552
553
  try {
553
554
  const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
555
+ body: bodyChange,
554
556
  method: 'POST',
555
557
  headers: this.platform.generateHeaders(),
556
558
  });
@@ -575,14 +577,15 @@ export class CeilingLight {
575
577
  if (this.ColorTemperature !== this.accessory.context.ColorTemperature) {
576
578
  const kelvin = Math.round(1000000 / Number(this.ColorTemperature));
577
579
  this.cacheKelvin = kelvin;
578
- const body = JSON.stringify({
580
+ const bodyChange = JSON.stringify({
579
581
  'command': 'setColorTemperature',
580
582
  'parameter': `${kelvin}`,
581
583
  'commandType': 'command',
582
584
  });
583
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
585
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
584
586
  try {
585
587
  const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
588
+ body: bodyChange,
586
589
  method: 'POST',
587
590
  headers: this.platform.generateHeaders(),
588
591
  });
@@ -605,14 +608,15 @@ export class CeilingLight {
605
608
  async pushBrightnessChanges(): Promise<void> {
606
609
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} pushBrightnessChanges`);
607
610
  if (this.Brightness !== this.accessory.context.Brightness) {
608
- const body = JSON.stringify({
611
+ const bodyChange = JSON.stringify({
609
612
  'command': 'setBrightness',
610
613
  'parameter': `${this.Brightness}`,
611
614
  'commandType': 'command',
612
615
  });
613
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
616
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
614
617
  try {
615
618
  const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
619
+ body: bodyChange,
616
620
  method: 'POST',
617
621
  headers: this.platform.generateHeaders(),
618
622
  });
@@ -651,14 +651,15 @@ export class ColorBulb {
651
651
  } else {
652
652
  command = 'turnOff';
653
653
  }
654
- const body = JSON.stringify({
654
+ const bodyChange = JSON.stringify({
655
655
  'command': `${command}`,
656
656
  'parameter': 'default',
657
657
  'commandType': 'command',
658
658
  });
659
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
659
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
660
660
  try {
661
661
  const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
662
+ body: bodyChange,
662
663
  method: 'POST',
663
664
  headers: this.platform.generateHeaders(),
664
665
  });
@@ -697,14 +698,15 @@ export class ColorBulb {
697
698
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Saturation: ${JSON.stringify(this.Saturation)}`);
698
699
  const [red, green, blue] = hs2rgb(Number(this.Hue), Number(this.Saturation));
699
700
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} rgb: ${JSON.stringify([red, green, blue])}`);
700
- const body = JSON.stringify({
701
+ const bodyChange = JSON.stringify({
701
702
  'command': 'setColor',
702
703
  'parameter': `${red}:${green}:${blue}`,
703
704
  'commandType': 'command',
704
705
  });
705
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
706
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
706
707
  try {
707
708
  const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
709
+ body: bodyChange,
708
710
  method: 'POST',
709
711
  headers: this.platform.generateHeaders(),
710
712
  });
@@ -729,14 +731,15 @@ export class ColorBulb {
729
731
  if (this.ColorTemperature !== this.accessory.context.ColorTemperature) {
730
732
  const kelvin = Math.round(1000000 / Number(this.ColorTemperature));
731
733
  this.cacheKelvin = kelvin;
732
- const body = JSON.stringify({
734
+ const bodyChange = JSON.stringify({
733
735
  'command': 'setColorTemperature',
734
736
  'parameter': `${kelvin}`,
735
737
  'commandType': 'command',
736
738
  });
737
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
739
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
738
740
  try {
739
741
  const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
742
+ body: bodyChange,
740
743
  method: 'POST',
741
744
  headers: this.platform.generateHeaders(),
742
745
  });
@@ -759,14 +762,15 @@ export class ColorBulb {
759
762
  async pushBrightnessChanges(): Promise<void> {
760
763
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} pushBrightnessChanges`);
761
764
  if (this.Brightness !== this.accessory.context.Brightness) {
762
- const body = JSON.stringify({
765
+ const bodyChange = JSON.stringify({
763
766
  'command': 'setBrightness',
764
767
  'parameter': `${this.Brightness}`,
765
768
  'commandType': 'command',
766
769
  });
767
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
770
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
768
771
  try {
769
772
  const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
773
+ body: bodyChange,
770
774
  method: 'POST',
771
775
  headers: this.platform.generateHeaders(),
772
776
  });
@@ -588,7 +588,7 @@ export class Curtain {
588
588
  }
589
589
 
590
590
  async openAPIpushChanges(): Promise<void> {
591
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} OpenAPI pushChanges`);
591
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIpushChanges`);
592
592
  if ((this.TargetPosition !== this.CurrentPosition) || this.device.disableCaching) {
593
593
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Pushing ${this.TargetPosition}`);
594
594
  const adjustedTargetPosition = 100 - Number(this.TargetPosition);
@@ -606,14 +606,15 @@ export class Curtain {
606
606
  }
607
607
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Mode: ${this.Mode}`);
608
608
  const adjustedMode = this.setPositionMode || 'ff';
609
- const body = JSON.stringify({
609
+ const bodyChange = JSON.stringify({
610
610
  'command': 'setPosition',
611
611
  'parameter': `0,${adjustedMode},${adjustedTargetPosition}`,
612
612
  'commandType': 'command',
613
613
  });
614
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
614
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
615
615
  try {
616
616
  const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
617
+ body: bodyChange,
617
618
  method: 'POST',
618
619
  headers: this.platform.generateHeaders(),
619
620
  });
@@ -444,14 +444,15 @@ export class Humidifier {
444
444
  if (this.TargetHumidifierDehumidifierState === this.platform.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER &&
445
445
  this.Active === this.platform.Characteristic.Active.ACTIVE) {
446
446
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Pushing Manual: ${this.RelativeHumidityHumidifierThreshold}!`);
447
- const body = JSON.stringify({
447
+ const bodyChange = JSON.stringify({
448
448
  'command': 'setMode',
449
449
  'parameter': `${this.RelativeHumidityHumidifierThreshold}`,
450
450
  'commandType': 'command',
451
451
  });
452
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
452
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
453
453
  try {
454
454
  const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
455
+ body: bodyChange,
455
456
  method: 'POST',
456
457
  headers: this.platform.generateHeaders(),
457
458
  });
@@ -483,14 +484,15 @@ export class Humidifier {
483
484
  if (this.TargetHumidifierDehumidifierState === this.platform.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER_OR_DEHUMIDIFIER &&
484
485
  this.Active === this.platform.Characteristic.Active.ACTIVE) {
485
486
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Pushing Auto`);
486
- const body = JSON.stringify({
487
+ const bodyChange = JSON.stringify({
487
488
  'command': 'setMode',
488
489
  'parameter': 'auto',
489
490
  'commandType': 'command',
490
491
  });
491
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
492
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
492
493
  try {
493
494
  const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
495
+ body: bodyChange,
494
496
  method: 'POST',
495
497
  headers: this.platform.generateHeaders(),
496
498
  });
@@ -517,14 +519,15 @@ export class Humidifier {
517
519
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} pushActiveChanges`);
518
520
  if (this.Active === this.platform.Characteristic.Active.INACTIVE) {
519
521
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Pushing Off`);
520
- const body = JSON.stringify({
522
+ const bodyChange = JSON.stringify({
521
523
  'command': 'turnOff',
522
524
  'parameter': 'default',
523
525
  'commandType': 'command',
524
526
  });
525
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
527
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
526
528
  try {
527
529
  const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
530
+ body: bodyChange,
528
531
  method: 'POST',
529
532
  headers: this.platform.generateHeaders(),
530
533
  });
@@ -554,14 +554,15 @@ export class StripLight {
554
554
  } else {
555
555
  command = 'turnOff';
556
556
  }*/
557
- const body = JSON.stringify({
557
+ const bodyChange = JSON.stringify({
558
558
  'command': `${command}`,
559
559
  'parameter': 'default',
560
560
  'commandType': 'command',
561
561
  });
562
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
562
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
563
563
  try {
564
564
  const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
565
+ body: bodyChange,
565
566
  method: 'POST',
566
567
  headers: this.platform.generateHeaders(),
567
568
  });
@@ -597,14 +598,15 @@ export class StripLight {
597
598
  const [red, green, blue] = hs2rgb(Number(this.Hue), Number(this.Saturation));
598
599
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} rgb: ${JSON.stringify([red, green, blue])}`);
599
600
  // Make Push On request to the API
600
- const body = JSON.stringify({
601
+ const bodyChange = JSON.stringify({
601
602
  'command': 'setColor',
602
603
  'parameter': `${red}:${green}:${blue}`,
603
604
  'commandType': 'command',
604
605
  });
605
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
606
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
606
607
  try {
607
608
  const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
609
+ body: bodyChange,
608
610
  method: 'POST',
609
611
  headers: this.platform.generateHeaders(),
610
612
  });
@@ -627,14 +629,15 @@ export class StripLight {
627
629
  async pushBrightnessChanges(): Promise<void> {
628
630
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} pushBrightnessChanges`);
629
631
  if (this.Brightness !== this.accessory.context.Brightness) {
630
- const body = JSON.stringify({
632
+ const bodyChange = JSON.stringify({
631
633
  'command': 'setBrightness',
632
634
  'parameter': `${this.Brightness}`,
633
635
  'commandType': 'command',
634
636
  });
635
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
637
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
636
638
  try {
637
639
  const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
640
+ body: bodyChange,
638
641
  method: 'POST',
639
642
  headers: this.platform.generateHeaders(),
640
643
  });
@@ -385,14 +385,15 @@ export class Lock {
385
385
  } else {
386
386
  command = 'unlock';
387
387
  }
388
- const body = JSON.stringify({
388
+ const bodyChange = JSON.stringify({
389
389
  'command': `${command}`,
390
390
  'parameter': 'default',
391
391
  'commandType': 'command',
392
392
  });
393
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
393
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
394
394
  try {
395
395
  const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
396
+ body: bodyChange,
396
397
  method: 'POST',
397
398
  headers: this.platform.generateHeaders(),
398
399
  });
@@ -356,14 +356,15 @@ export class Plug {
356
356
  } else {
357
357
  command = 'turnOff';
358
358
  }
359
- const body = JSON.stringify({
359
+ const bodyChange = JSON.stringify({
360
360
  'command': `${command}`,
361
361
  'parameter': 'default',
362
362
  'commandType': 'command',
363
363
  });
364
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
364
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
365
365
  try {
366
366
  const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
367
+ body: bodyChange,
367
368
  method: 'POST',
368
369
  headers: this.platform.generateHeaders(),
369
370
  });
@@ -367,14 +367,15 @@ export class RobotVacuumCleaner {
367
367
  } else {
368
368
  command = 'turnOff';
369
369
  }
370
- const body = JSON.stringify({
370
+ const bodyChange = JSON.stringify({
371
371
  'command': `${command}`,
372
372
  'parameter': 'default',
373
373
  'commandType': 'command',
374
374
  });
375
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
375
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
376
376
  try {
377
377
  const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
378
+ body: bodyChange,
378
379
  method: 'POST',
379
380
  headers: this.platform.generateHeaders(),
380
381
  });
@@ -172,12 +172,12 @@ export class AirConditioner {
172
172
  if (this.Active === this.platform.Characteristic.Active.ACTIVE && !this.disablePushOn) {
173
173
  const commandType: string = await this.commandType();
174
174
  const command: string = await this.commandOn();
175
- const body = JSON.stringify({
175
+ const bodyChange = JSON.stringify({
176
176
  'command': command,
177
177
  'parameter': 'default',
178
178
  'commandType': commandType,
179
179
  });
180
- await this.pushChanges(body);
180
+ await this.pushChanges(bodyChange);
181
181
  }
182
182
  }
183
183
 
@@ -187,12 +187,12 @@ export class AirConditioner {
187
187
  if (this.Active === this.platform.Characteristic.Active.INACTIVE && !this.disablePushOff) {
188
188
  const commandType: string = await this.commandType();
189
189
  const command: string = await this.commandOff();
190
- const body = JSON.stringify({
190
+ const bodyChange = JSON.stringify({
191
191
  'command': command,
192
192
  'parameter': 'default',
193
193
  'commandType': commandType,
194
194
  });
195
- await this.pushChanges(body);
195
+ await this.pushChanges(bodyChange);
196
196
  }
197
197
  }
198
198
 
@@ -243,21 +243,22 @@ export class AirConditioner {
243
243
  } else {
244
244
  this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.INACTIVE;
245
245
  }
246
- const body = JSON.stringify({
246
+ const bodyChange = JSON.stringify({
247
247
  'command': 'setAll',
248
248
  'parameter': `${parameter}`,
249
249
  'commandType': 'command',
250
250
  });
251
251
 
252
- await this.pushChanges(body);
252
+ await this.pushChanges(bodyChange);
253
253
  }
254
254
 
255
- async pushChanges(body: any): Promise<void> {
255
+ async pushChanges(bodyChange: any): Promise<void> {
256
256
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushChanges`);
257
257
  if (this.device.connectionType === 'OpenAPI' && !this.disablePushDetail) {
258
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
258
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
259
259
  try {
260
260
  const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
261
+ body: bodyChange,
261
262
  method: 'POST',
262
263
  headers: this.platform.generateHeaders(),
263
264
  });
@@ -134,12 +134,12 @@ export class AirPurifier {
134
134
  if (this.Active === this.platform.Characteristic.Active.ACTIVE && !this.disablePushOn) {
135
135
  const commandType: string = await this.commandType();
136
136
  const command: string = await this.commandOn();
137
- const body = JSON.stringify({
137
+ const bodyChange = JSON.stringify({
138
138
  'command': command,
139
139
  'parameter': 'default',
140
140
  'commandType': commandType,
141
141
  });
142
- await this.pushChanges(body);
142
+ await this.pushChanges(bodyChange);
143
143
  }
144
144
  }
145
145
 
@@ -149,12 +149,12 @@ export class AirPurifier {
149
149
  if (this.Active === this.platform.Characteristic.Active.INACTIVE && !this.disablePushOn) {
150
150
  const commandType: string = await this.commandType();
151
151
  const command: string = await this.commandOff();
152
- const body = JSON.stringify({
152
+ const bodyChange = JSON.stringify({
153
153
  'command': command,
154
154
  'parameter': 'default',
155
155
  'commandType': commandType,
156
156
  });
157
- await this.pushChanges(body);
157
+ await this.pushChanges(bodyChange);
158
158
  }
159
159
  }
160
160
 
@@ -179,7 +179,7 @@ export class AirPurifier {
179
179
  this.CurrentAPFanSpeed = this.CurrentFanSpeed || 1;
180
180
  this.APActive = this.Active === 1 ? 'on' : 'off';
181
181
  const parameter = `${this.CurrentAPTemp},${this.CurrentAPMode},${this.CurrentAPFanSpeed},${this.APActive}`;
182
- const body = JSON.stringify({
182
+ const bodyChange = JSON.stringify({
183
183
  'command': 'setAll',
184
184
  'parameter': `${parameter}`,
185
185
  'commandType': 'command',
@@ -193,15 +193,16 @@ export class AirPurifier {
193
193
  } else {
194
194
  this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.INACTIVE;
195
195
  }
196
- await this.pushChanges(body);
196
+ await this.pushChanges(bodyChange);
197
197
  }
198
198
 
199
- async pushChanges(body: any): Promise<void> {
199
+ async pushChanges(bodyChange: any): Promise<void> {
200
200
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushChanges`);
201
201
  if (this.device.connectionType === 'OpenAPI') {
202
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
202
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
203
203
  try {
204
204
  const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
205
+ body: bodyChange,
205
206
  method: 'POST',
206
207
  headers: this.platform.generateHeaders(),
207
208
  });
@@ -85,12 +85,12 @@ export class Camera {
85
85
  if (this.On && !this.disablePushOn) {
86
86
  const commandType: string = await this.commandType();
87
87
  const command: string = await this.commandOn();
88
- const body = JSON.stringify({
88
+ const bodyChange = JSON.stringify({
89
89
  'command': command,
90
90
  'parameter': 'default',
91
91
  'commandType': commandType,
92
92
  });
93
- await this.pushChanges(body);
93
+ await this.pushChanges(bodyChange);
94
94
  }
95
95
  }
96
96
 
@@ -100,21 +100,22 @@ export class Camera {
100
100
  if (!this.On && !this.disablePushOff) {
101
101
  const commandType: string = await this.commandType();
102
102
  const command: string = await this.commandOff();
103
- const body = JSON.stringify({
103
+ const bodyChange = JSON.stringify({
104
104
  'command': command,
105
105
  'parameter': 'default',
106
106
  'commandType': commandType,
107
107
  });
108
- await this.pushChanges(body);
108
+ await this.pushChanges(bodyChange);
109
109
  }
110
110
  }
111
111
 
112
- async pushChanges(body: any): Promise<void> {
112
+ async pushChanges(bodyChange: any): Promise<void> {
113
113
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushChanges`);
114
114
  if (this.device.connectionType === 'OpenAPI') {
115
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
115
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
116
116
  try {
117
117
  const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
118
+ body: bodyChange,
118
119
  method: 'POST',
119
120
  headers: this.platform.generateHeaders(),
120
121
  });