@switchbot/homebridge-switchbot 2.6.1 → 2.6.2

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 (93) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/device/blindtilt.d.ts.map +1 -1
  3. package/dist/device/blindtilt.js +7 -6
  4. package/dist/device/blindtilt.js.map +1 -1
  5. package/dist/device/bot.d.ts.map +1 -1
  6. package/dist/device/bot.js +4 -3
  7. package/dist/device/bot.js.map +1 -1
  8. package/dist/device/ceilinglight.d.ts.map +1 -1
  9. package/dist/device/ceilinglight.js +13 -9
  10. package/dist/device/ceilinglight.js.map +1 -1
  11. package/dist/device/colorbulb.d.ts.map +1 -1
  12. package/dist/device/colorbulb.js +12 -8
  13. package/dist/device/colorbulb.js.map +1 -1
  14. package/dist/device/curtain.d.ts.map +1 -1
  15. package/dist/device/curtain.js +4 -3
  16. package/dist/device/curtain.js.map +1 -1
  17. package/dist/device/humidifier.d.ts.map +1 -1
  18. package/dist/device/humidifier.js +9 -6
  19. package/dist/device/humidifier.js.map +1 -1
  20. package/dist/device/lightstrip.d.ts.map +1 -1
  21. package/dist/device/lightstrip.js +9 -6
  22. package/dist/device/lightstrip.js.map +1 -1
  23. package/dist/device/lock.d.ts.map +1 -1
  24. package/dist/device/lock.js +3 -2
  25. package/dist/device/lock.js.map +1 -1
  26. package/dist/device/plug.d.ts.map +1 -1
  27. package/dist/device/plug.js +3 -2
  28. package/dist/device/plug.js.map +1 -1
  29. package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
  30. package/dist/device/robotvacuumcleaner.js +3 -2
  31. package/dist/device/robotvacuumcleaner.js.map +1 -1
  32. package/dist/irdevice/airconditioner.d.ts +1 -1
  33. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  34. package/dist/irdevice/airconditioner.js +9 -8
  35. package/dist/irdevice/airconditioner.js.map +1 -1
  36. package/dist/irdevice/airpurifier.d.ts +1 -1
  37. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  38. package/dist/irdevice/airpurifier.js +9 -8
  39. package/dist/irdevice/airpurifier.js.map +1 -1
  40. package/dist/irdevice/camera.d.ts +1 -1
  41. package/dist/irdevice/camera.d.ts.map +1 -1
  42. package/dist/irdevice/camera.js +7 -6
  43. package/dist/irdevice/camera.js.map +1 -1
  44. package/dist/irdevice/fan.d.ts +1 -1
  45. package/dist/irdevice/fan.d.ts.map +1 -1
  46. package/dist/irdevice/fan.js +13 -12
  47. package/dist/irdevice/fan.js.map +1 -1
  48. package/dist/irdevice/light.d.ts +1 -1
  49. package/dist/irdevice/light.d.ts.map +1 -1
  50. package/dist/irdevice/light.js +11 -10
  51. package/dist/irdevice/light.js.map +1 -1
  52. package/dist/irdevice/other.d.ts +1 -1
  53. package/dist/irdevice/other.d.ts.map +1 -1
  54. package/dist/irdevice/other.js +7 -6
  55. package/dist/irdevice/other.js.map +1 -1
  56. package/dist/irdevice/tv.d.ts +1 -1
  57. package/dist/irdevice/tv.d.ts.map +1 -1
  58. package/dist/irdevice/tv.js +25 -24
  59. package/dist/irdevice/tv.js.map +1 -1
  60. package/dist/irdevice/vacuumcleaner.d.ts +1 -1
  61. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  62. package/dist/irdevice/vacuumcleaner.js +7 -6
  63. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  64. package/dist/irdevice/waterheater.d.ts +1 -1
  65. package/dist/irdevice/waterheater.d.ts.map +1 -1
  66. package/dist/irdevice/waterheater.js +7 -6
  67. package/dist/irdevice/waterheater.js.map +1 -1
  68. package/dist/settings.d.ts +0 -8
  69. package/dist/settings.d.ts.map +1 -1
  70. package/dist/settings.js +1 -9
  71. package/dist/settings.js.map +1 -1
  72. package/nodemon.json +1 -1
  73. package/package.json +1 -1
  74. package/src/device/blindtilt.ts +7 -6
  75. package/src/device/bot.ts +4 -3
  76. package/src/device/ceilinglight.ts +13 -9
  77. package/src/device/colorbulb.ts +12 -8
  78. package/src/device/curtain.ts +4 -3
  79. package/src/device/humidifier.ts +9 -6
  80. package/src/device/lightstrip.ts +9 -6
  81. package/src/device/lock.ts +3 -2
  82. package/src/device/plug.ts +3 -2
  83. package/src/device/robotvacuumcleaner.ts +3 -2
  84. package/src/irdevice/airconditioner.ts +9 -8
  85. package/src/irdevice/airpurifier.ts +9 -8
  86. package/src/irdevice/camera.ts +7 -6
  87. package/src/irdevice/fan.ts +13 -12
  88. package/src/irdevice/light.ts +11 -10
  89. package/src/irdevice/other.ts +7 -6
  90. package/src/irdevice/tv.ts +25 -24
  91. package/src/irdevice/vacuumcleaner.ts +7 -6
  92. package/src/irdevice/waterheater.ts +7 -6
  93. package/src/settings.ts +0 -10
@@ -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
  });
@@ -175,12 +175,12 @@ export class Fan {
175
175
  if (this.Active === this.platform.Characteristic.Active.ACTIVE && !this.disablePushOn) {
176
176
  const commandType: string = await this.commandType();
177
177
  const command: string = await this.commandOn();
178
- const body = JSON.stringify({
178
+ const bodyChange = JSON.stringify({
179
179
  'command': command,
180
180
  'parameter': 'default',
181
181
  'commandType': commandType,
182
182
  });
183
- await this.pushChanges(body);
183
+ await this.pushChanges(bodyChange);
184
184
  }
185
185
  }
186
186
 
@@ -190,48 +190,49 @@ export class Fan {
190
190
  if (this.Active === this.platform.Characteristic.Active.INACTIVE && !this.disablePushOff) {
191
191
  const commandType: string = await this.commandType();
192
192
  const command: string = await this.commandOff();
193
- const body = JSON.stringify({
193
+ const bodyChange = JSON.stringify({
194
194
  'command': command,
195
195
  'parameter': 'default',
196
196
  'commandType': commandType,
197
197
  });
198
- await this.pushChanges(body);
198
+ await this.pushChanges(bodyChange);
199
199
  }
200
200
  }
201
201
 
202
202
  async pushFanSpeedUpChanges(): Promise<void> {
203
- const body = JSON.stringify({
203
+ const bodyChange = JSON.stringify({
204
204
  'command': 'highSpeed',
205
205
  'parameter': 'default',
206
206
  'commandType': 'command',
207
207
  });
208
- await this.pushChanges(body);
208
+ await this.pushChanges(bodyChange);
209
209
  }
210
210
 
211
211
  async pushFanSpeedDownChanges(): Promise<void> {
212
- const body = JSON.stringify({
212
+ const bodyChange = JSON.stringify({
213
213
  'command': 'lowSpeed',
214
214
  'parameter': 'default',
215
215
  'commandType': 'command',
216
216
  });
217
- await this.pushChanges(body);
217
+ await this.pushChanges(bodyChange);
218
218
  }
219
219
 
220
220
  async pushFanSwingChanges(): Promise<void> {
221
- const body = JSON.stringify({
221
+ const bodyChange = JSON.stringify({
222
222
  'command': 'swing',
223
223
  'parameter': 'default',
224
224
  'commandType': 'command',
225
225
  });
226
- await this.pushChanges(body);
226
+ await this.pushChanges(bodyChange);
227
227
  }
228
228
 
229
- async pushChanges(body: any): Promise<void> {
229
+ async pushChanges(bodyChange: any): Promise<void> {
230
230
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushChanges`);
231
231
  if (this.device.connectionType === 'OpenAPI') {
232
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
232
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
233
233
  try {
234
234
  const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
235
+ body: bodyChange,
235
236
  method: 'POST',
236
237
  headers: this.platform.generateHeaders(),
237
238
  });
@@ -89,12 +89,12 @@ export class Light {
89
89
  if (this.On && !this.disablePushOn) {
90
90
  const commandType: string = await this.commandType();
91
91
  const command: string = await this.commandOn();
92
- const body = JSON.stringify({
92
+ const bodyChange = JSON.stringify({
93
93
  'command': command,
94
94
  'parameter': 'default',
95
95
  'commandType': commandType,
96
96
  });
97
- await this.pushChanges(body);
97
+ await this.pushChanges(bodyChange);
98
98
  }
99
99
  }
100
100
 
@@ -104,39 +104,40 @@ export class Light {
104
104
  if (!this.On && !this.disablePushOff) {
105
105
  const commandType: string = await this.commandType();
106
106
  const command: string = await this.commandOff();
107
- const body = JSON.stringify({
107
+ const bodyChange = JSON.stringify({
108
108
  'command': command,
109
109
  'parameter': 'default',
110
110
  'commandType': commandType,
111
111
  });
112
- await this.pushChanges(body);
112
+ await this.pushChanges(bodyChange);
113
113
  }
114
114
  }
115
115
 
116
116
  async pushLightBrightnessUpChanges(): Promise<void> {
117
- const body = JSON.stringify({
117
+ const bodyChange = JSON.stringify({
118
118
  'command': 'brightnessUp',
119
119
  'parameter': 'default',
120
120
  'commandType': 'command',
121
121
  });
122
- await this.pushChanges(body);
122
+ await this.pushChanges(bodyChange);
123
123
  }
124
124
 
125
125
  async pushLightBrightnessDownChanges(): Promise<void> {
126
- const body = JSON.stringify({
126
+ const bodyChange = JSON.stringify({
127
127
  'command': 'brightnessDown',
128
128
  'parameter': 'default',
129
129
  'commandType': 'command',
130
130
  });
131
- await this.pushChanges(body);
131
+ await this.pushChanges(bodyChange);
132
132
  }
133
133
 
134
- async pushChanges(body: any): Promise<void> {
134
+ async pushChanges(bodyChange: any): Promise<void> {
135
135
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushChanges`);
136
136
  if (this.device.connectionType === 'OpenAPI') {
137
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
137
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
138
138
  try {
139
139
  const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
140
+ body: bodyChange,
140
141
  method: 'POST',
141
142
  headers: this.platform.generateHeaders(),
142
143
  });
@@ -93,12 +93,12 @@ export class Others {
93
93
  if (this.Active === this.platform.Characteristic.Active.ACTIVE && !this.disablePushOn) {
94
94
  const commandType: string = await this.commandType();
95
95
  const command: string = await this.commandOn();
96
- const body = JSON.stringify({
96
+ const bodyChange = JSON.stringify({
97
97
  'command': command,
98
98
  'parameter': 'default',
99
99
  'commandType': commandType,
100
100
  });
101
- await this.pushChanges(body);
101
+ await this.pushChanges(bodyChange);
102
102
  }
103
103
  } else {
104
104
  this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} On Command not set`);
@@ -112,24 +112,25 @@ export class Others {
112
112
  if (this.Active === this.platform.Characteristic.Active.INACTIVE && !this.disablePushOff) {
113
113
  const commandType: string = await this.commandType();
114
114
  const command: string = await this.commandOff();
115
- const body = JSON.stringify({
115
+ const bodyChange = JSON.stringify({
116
116
  'command': command,
117
117
  'parameter': 'default',
118
118
  'commandType': commandType,
119
119
  });
120
- await this.pushChanges(body);
120
+ await this.pushChanges(bodyChange);
121
121
  }
122
122
  } else {
123
123
  this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Off Command not set.`);
124
124
  }
125
125
  }
126
126
 
127
- async pushChanges(body: any): Promise<void> {
127
+ async pushChanges(bodyChange: any): Promise<void> {
128
128
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushChanges`);
129
129
  if (this.device.connectionType === 'OpenAPI') {
130
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
130
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
131
131
  try {
132
132
  const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
133
+ body: bodyChange,
133
134
  method: 'POST',
134
135
  headers: this.platform.generateHeaders(),
135
136
  });