@switchbot/homebridge-switchbot 1.15.1-beta.0 → 1.15.1-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 (117) hide show
  1. package/.github/ISSUE_TEMPLATE/bug-report.yml +1 -0
  2. package/.github/ISSUE_TEMPLATE/feature-request.yml +1 -0
  3. package/.github/ISSUE_TEMPLATE/support-request.yml +1 -0
  4. package/.prettierrc +1 -1
  5. package/CHANGELOG.md +9 -0
  6. package/config.schema.json +11 -4
  7. package/dist/device/bot.d.ts +8 -7
  8. package/dist/device/bot.d.ts.map +1 -1
  9. package/dist/device/bot.js +104 -28
  10. package/dist/device/bot.js.map +1 -1
  11. package/dist/device/colorbulb.d.ts +8 -7
  12. package/dist/device/colorbulb.d.ts.map +1 -1
  13. package/dist/device/colorbulb.js +223 -58
  14. package/dist/device/colorbulb.js.map +1 -1
  15. package/dist/device/contact.d.ts +3 -3
  16. package/dist/device/contact.d.ts.map +1 -1
  17. package/dist/device/contact.js +54 -11
  18. package/dist/device/contact.js.map +1 -1
  19. package/dist/device/curtain.d.ts +9 -8
  20. package/dist/device/curtain.d.ts.map +1 -1
  21. package/dist/device/curtain.js +102 -28
  22. package/dist/device/curtain.js.map +1 -1
  23. package/dist/device/humidifier.d.ts +8 -7
  24. package/dist/device/humidifier.d.ts.map +1 -1
  25. package/dist/device/humidifier.js +187 -66
  26. package/dist/device/humidifier.js.map +1 -1
  27. package/dist/device/lock.d.ts +8 -7
  28. package/dist/device/lock.d.ts.map +1 -1
  29. package/dist/device/lock.js +98 -22
  30. package/dist/device/lock.js.map +1 -1
  31. package/dist/device/meter.d.ts +4 -4
  32. package/dist/device/meter.d.ts.map +1 -1
  33. package/dist/device/meter.js +55 -12
  34. package/dist/device/meter.js.map +1 -1
  35. package/dist/device/meterplus.d.ts +3 -3
  36. package/dist/device/meterplus.d.ts.map +1 -1
  37. package/dist/device/meterplus.js +53 -10
  38. package/dist/device/meterplus.js.map +1 -1
  39. package/dist/device/motion.d.ts +3 -3
  40. package/dist/device/motion.d.ts.map +1 -1
  41. package/dist/device/motion.js +53 -13
  42. package/dist/device/motion.js.map +1 -1
  43. package/dist/device/plug.d.ts +8 -7
  44. package/dist/device/plug.d.ts.map +1 -1
  45. package/dist/device/plug.js +100 -24
  46. package/dist/device/plug.js.map +1 -1
  47. package/dist/device/striplight.d.ts +8 -7
  48. package/dist/device/striplight.d.ts.map +1 -1
  49. package/dist/device/striplight.js +186 -47
  50. package/dist/device/striplight.js.map +1 -1
  51. package/dist/irdevice/airconditioner.d.ts +7 -6
  52. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  53. package/dist/irdevice/airconditioner.js +40 -6
  54. package/dist/irdevice/airconditioner.js.map +1 -1
  55. package/dist/irdevice/airpurifier.d.ts +7 -6
  56. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  57. package/dist/irdevice/airpurifier.js +46 -11
  58. package/dist/irdevice/airpurifier.js.map +1 -1
  59. package/dist/irdevice/camera.d.ts +7 -6
  60. package/dist/irdevice/camera.d.ts.map +1 -1
  61. package/dist/irdevice/camera.js +40 -6
  62. package/dist/irdevice/camera.js.map +1 -1
  63. package/dist/irdevice/fan.d.ts +8 -7
  64. package/dist/irdevice/fan.d.ts.map +1 -1
  65. package/dist/irdevice/fan.js +40 -6
  66. package/dist/irdevice/fan.js.map +1 -1
  67. package/dist/irdevice/light.d.ts +7 -6
  68. package/dist/irdevice/light.d.ts.map +1 -1
  69. package/dist/irdevice/light.js +40 -6
  70. package/dist/irdevice/light.js.map +1 -1
  71. package/dist/irdevice/other.d.ts +7 -6
  72. package/dist/irdevice/other.d.ts.map +1 -1
  73. package/dist/irdevice/other.js +40 -6
  74. package/dist/irdevice/other.js.map +1 -1
  75. package/dist/irdevice/tv.d.ts +8 -7
  76. package/dist/irdevice/tv.d.ts.map +1 -1
  77. package/dist/irdevice/tv.js +40 -6
  78. package/dist/irdevice/tv.js.map +1 -1
  79. package/dist/irdevice/vacuumcleaner.d.ts +7 -6
  80. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  81. package/dist/irdevice/vacuumcleaner.js +40 -6
  82. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  83. package/dist/irdevice/waterheater.d.ts +7 -6
  84. package/dist/irdevice/waterheater.d.ts.map +1 -1
  85. package/dist/irdevice/waterheater.js +40 -6
  86. package/dist/irdevice/waterheater.js.map +1 -1
  87. package/dist/platform.d.ts +10 -6
  88. package/dist/platform.d.ts.map +1 -1
  89. package/dist/platform.js +211 -93
  90. package/dist/platform.js.map +1 -1
  91. package/dist/settings.d.ts +4 -21
  92. package/dist/settings.d.ts.map +1 -1
  93. package/dist/settings.js +3 -3
  94. package/dist/settings.js.map +1 -1
  95. package/package.json +12 -12
  96. package/src/device/bot.ts +104 -37
  97. package/src/device/colorbulb.ts +227 -95
  98. package/src/device/contact.ts +53 -14
  99. package/src/device/curtain.ts +105 -38
  100. package/src/device/humidifier.ts +189 -84
  101. package/src/device/lock.ts +97 -30
  102. package/src/device/meter.ts +55 -16
  103. package/src/device/meterplus.ts +52 -13
  104. package/src/device/motion.ts +52 -16
  105. package/src/device/plug.ts +101 -33
  106. package/src/device/striplight.ts +189 -68
  107. package/src/irdevice/airconditioner.ts +44 -9
  108. package/src/irdevice/airpurifier.ts +52 -17
  109. package/src/irdevice/camera.ts +46 -11
  110. package/src/irdevice/fan.ts +50 -15
  111. package/src/irdevice/light.ts +48 -13
  112. package/src/irdevice/other.ts +46 -11
  113. package/src/irdevice/tv.ts +56 -21
  114. package/src/irdevice/vacuumcleaner.ts +46 -11
  115. package/src/irdevice/waterheater.ts +46 -11
  116. package/src/platform.ts +232 -107
  117. package/src/settings.ts +4 -25
@@ -1,9 +1,11 @@
1
+ import https from 'https';
2
+ import crypto from 'crypto';
3
+ import { Context } from 'vm';
1
4
  import { interval, Subject } from 'rxjs';
2
5
  import { skipWhile } from 'rxjs/operators';
3
6
  import { SwitchBotPlatform } from '../platform';
4
7
  import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge';
5
- import { DeviceURL, device, devicesConfig, serviceData, switchbot, deviceStatusResponse, deviceStatus, ad } from '../settings';
6
- import { Context } from 'vm';
8
+ import { device, devicesConfig, serviceData, switchbot, deviceStatus, ad, HostDomain, DevicePath } from '../settings';
7
9
 
8
10
  /**
9
11
  * Platform Accessory
@@ -28,7 +30,7 @@ export class Contact {
28
30
  openState: deviceStatus['openState'];
29
31
  moveDetected: deviceStatus['moveDetected'];
30
32
  brightness: deviceStatus['brightness'];
31
- deviceStatus!: deviceStatusResponse;
33
+ deviceStatus!: any; //deviceStatusResponse;
32
34
 
33
35
  // BLE Others
34
36
  connected?: boolean;
@@ -217,7 +219,7 @@ export class Contact {
217
219
  if (this.device.ble) {
218
220
  this.SwitchToOpenAPI = false;
219
221
  }
220
- if (this.platform.config.credentials?.openToken) {
222
+ if (this.platform.config.credentials?.token) {
221
223
  this.debugLog(`Contact Sensor: ${this.accessory.displayName} OpenAPI parseStatus`);
222
224
  // Contact State
223
225
  if (this.openState === 'open') {
@@ -331,7 +333,7 @@ export class Contact {
331
333
  ` Error Message: ${JSON.stringify(e.message)}`,
332
334
  );
333
335
  }
334
- if (this.platform.config.credentials?.openToken) {
336
+ if (this.platform.config.credentials?.token) {
335
337
  this.warnLog(`Contact Sensor: ${this.accessory.displayName} Using OpenAPI Connection`);
336
338
  this.SwitchToOpenAPI = true;
337
339
  await this.openAPIRefreshStatus();
@@ -363,7 +365,7 @@ export class Contact {
363
365
 
364
366
  async BLEconnection(switchbot: any): Promise<void> {
365
367
  this.errorLog(`Contact Sensor: ${this.accessory.displayName} wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`);
366
- if (this.platform.config.credentials?.openToken) {
368
+ if (this.platform.config.credentials?.token) {
367
369
  this.warnLog(`Contact Sensor: ${this.accessory.displayName} Using OpenAPI Connection`);
368
370
  this.SwitchToOpenAPI = true;
369
371
  await this.openAPIRefreshStatus();
@@ -371,16 +373,53 @@ export class Contact {
371
373
  }
372
374
 
373
375
  async openAPIRefreshStatus(): Promise<void> {
374
- if (this.platform.config.credentials?.openToken) {
376
+ if (this.platform.config.credentials?.token) {
375
377
  this.debugLog(`Contact Sensor: ${this.accessory.displayName} OpenAPI refreshStatus`);
376
378
  try {
377
- this.deviceStatus = (await this.platform.axios.get(`${DeviceURL}/${this.device.deviceId}/status`)).data;
378
- this.debugLog(`Contact Sensor: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(this.deviceStatus)}`);
379
- this.openState = this.deviceStatus.body.openState;
380
- this.moveDetected = this.deviceStatus.body.moveDetected;
381
- this.brightness = this.deviceStatus.body.brightness;
382
- this.parseStatus();
383
- this.updateHomeKitCharacteristics();
379
+ const t = Date.now();
380
+ const nonce = 'requestID';
381
+ const data = this.platform.config.credentials?.token + t + nonce;
382
+ const signTerm = crypto.createHmac('sha256', this.platform.config.credentials?.secret).update(Buffer.from(data, 'utf-8')).digest();
383
+ const sign = signTerm.toString('base64');
384
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} sign: ${sign}`);
385
+ const options = {
386
+ hostname: HostDomain,
387
+ port: 443,
388
+ path: `${DevicePath}/${this.device.deviceId}/status`,
389
+ method: 'GET',
390
+ headers: {
391
+ Authorization: this.platform.config.credentials?.token,
392
+ sign: sign,
393
+ nonce: nonce,
394
+ t: t,
395
+ 'Content-Type': 'application/json',
396
+ },
397
+ };
398
+ const req = https.request(options, (res) => {
399
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} statusCode: ${res.statusCode}`);
400
+ let rawData = '';
401
+ res.on('data', (d) => {
402
+ rawData += d;
403
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} d: ${d}`);
404
+ });
405
+ res.on('end', () => {
406
+ try {
407
+ this.deviceStatus = JSON.parse(rawData);
408
+ this.debugLog(`Contact Sensor: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(this.deviceStatus)}`);
409
+ this.openState = this.deviceStatus.body.openState;
410
+ this.moveDetected = this.deviceStatus.body.moveDetected;
411
+ this.brightness = this.deviceStatus.body.brightness;
412
+ this.parseStatus();
413
+ this.updateHomeKitCharacteristics();
414
+ } catch (e: any) {
415
+ this.errorLog(`Contact Sensor: ${this.accessory.displayName} error message: ${e.message}`);
416
+ }
417
+ });
418
+ });
419
+ req.on('error', (e: any) => {
420
+ this.errorLog(`Contact Sensor: ${this.accessory.displayName} error message: ${e.message}`);
421
+ });
422
+ req.end();
384
423
  } catch (e: any) {
385
424
  this.errorLog(`Contact Sensor: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection`);
386
425
  if (this.deviceLogging.includes('debug')) {
@@ -1,12 +1,14 @@
1
- import { AxiosResponse } from 'axios';
1
+ import https from 'https';
2
+ import crypto from 'crypto';
3
+ import { Context } from 'vm';
4
+ import { MqttClient } from 'mqtt';
5
+ import { IncomingMessage } from 'http';
2
6
  import { interval, Subject } from 'rxjs';
7
+ import { connectAsync } from 'async-mqtt';
3
8
  import { SwitchBotPlatform } from '../platform';
4
9
  import { debounceTime, skipWhile, take, tap } from 'rxjs/operators';
5
10
  import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge';
6
- import { DeviceURL, device, devicesConfig, serviceData, switchbot, deviceStatusResponse, payload, deviceStatus, ad } from '../settings';
7
- import { Context } from 'vm';
8
- import { MqttClient } from 'mqtt';
9
- import { connectAsync } from 'async-mqtt';
11
+ import { device, devicesConfig, serviceData, switchbot, deviceStatus, ad, HostDomain, DevicePath } from '../settings';
10
12
 
11
13
  export class Curtain {
12
14
  // Services
@@ -23,7 +25,7 @@ export class Curtain {
23
25
  StatusLowBattery?: CharacteristicValue;
24
26
 
25
27
  // OpenAPI Others
26
- deviceStatus!: deviceStatusResponse;
28
+ deviceStatus!: any; //deviceStatusResponse;
27
29
  slidePosition: deviceStatus['slidePosition'];
28
30
  moving: deviceStatus['moving'];
29
31
  brightness: deviceStatus['brightness'];
@@ -359,7 +361,7 @@ export class Curtain {
359
361
  if (this.device.ble) {
360
362
  this.SwitchToOpenAPI = false;
361
363
  }
362
- if (this.platform.config.credentials?.openToken) {
364
+ if (this.platform.config.credentials?.token) {
363
365
  this.debugLog(`Curtain: ${this.accessory.displayName} OpenAPI parseStatus`);
364
366
  // CurrentPosition
365
367
  this.CurrentPosition = 100 - Number(this.slidePosition);
@@ -489,7 +491,7 @@ export class Curtain {
489
491
  `Curtain: ${this.accessory.displayName} failed refreshStatus with BLE Connection,` + ` Error Message: ${JSON.stringify(e.message)}`,
490
492
  );
491
493
  }
492
- if (this.platform.config.credentials?.openToken) {
494
+ if (this.platform.config.credentials?.token) {
493
495
  this.warnLog(`Curtain: ${this.accessory.displayName} Using OpenAPI Connection`);
494
496
  this.SwitchToOpenAPI = true;
495
497
  await this.openAPIRefreshStatus();
@@ -521,7 +523,7 @@ export class Curtain {
521
523
 
522
524
  async BLEconnection(switchbot: any): Promise<void> {
523
525
  this.errorLog(`Curtain: ${this.accessory.displayName} wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`);
524
- if (this.platform.config.credentials?.openToken) {
526
+ if (this.platform.config.credentials?.token) {
525
527
  this.warnLog(`Curtain: ${this.accessory.displayName} Using OpenAPI Connection`);
526
528
  this.SwitchToOpenAPI = true;
527
529
  await this.openAPIRefreshStatus();
@@ -529,16 +531,54 @@ export class Curtain {
529
531
  }
530
532
 
531
533
  async openAPIRefreshStatus(): Promise<void> {
532
- if (this.platform.config.credentials?.openToken) {
534
+ if (this.platform.config.credentials?.token) {
533
535
  this.debugLog(`Curtain: ${this.accessory.displayName} OpenAPI refreshStatus`);
534
536
  try {
535
- this.deviceStatus = (await this.platform.axios.get(`${DeviceURL}/${this.device.deviceId}/status`)).data;
536
- this.debugLog(`Curtain: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(this.deviceStatus)}`);
537
- this.slidePosition = this.deviceStatus.body.slidePosition;
538
- this.moving = this.deviceStatus.body.moving;
539
- this.brightness = this.deviceStatus.body.brightness;
540
- this.parseStatus();
541
- this.updateHomeKitCharacteristics();
537
+ const t = Date.now();
538
+ const nonce = 'requestID';
539
+ const data = this.platform.config.credentials?.token + t + nonce;
540
+ const signTerm = crypto.createHmac('sha256', this.platform.config.credentials?.secret).update(Buffer.from(data, 'utf-8')).digest();
541
+ const sign = signTerm.toString('base64');
542
+ this.debugLog(`Curtain: ${this.accessory.displayName} sign: ${sign}`);
543
+ const options = {
544
+ hostname: HostDomain,
545
+ port: 443,
546
+ path: `${DevicePath}/${this.device.deviceId}/status`,
547
+ method: 'GET',
548
+ headers: {
549
+ Authorization: this.platform.config.credentials?.token,
550
+ sign: sign,
551
+ nonce: nonce,
552
+ t: t,
553
+ 'Content-Type': 'application/json',
554
+ },
555
+ };
556
+ const req = https.request(options, (res) => {
557
+ this.debugLog(`Curtain: ${this.accessory.displayName} statusCode: ${res.statusCode}`);
558
+ let rawData = '';
559
+ res.on('data', (d) => {
560
+ rawData += d;
561
+ this.debugLog(`Curtain: ${this.accessory.displayName} d: ${d}`);
562
+ });
563
+
564
+ res.on('end', () => {
565
+ try {
566
+ this.deviceStatus = JSON.parse(rawData);
567
+ this.debugLog(`Curtain: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(this.deviceStatus)}`);
568
+ this.slidePosition = this.deviceStatus.body.slidePosition;
569
+ this.moving = this.deviceStatus.body.moving;
570
+ this.brightness = this.deviceStatus.body.brightness;
571
+ this.parseStatus();
572
+ this.updateHomeKitCharacteristics();
573
+ } catch (e: any) {
574
+ this.errorLog(`Curtain: ${this.accessory.displayName} error message: ${e.message}`);
575
+ }
576
+ });
577
+ });
578
+ req.on('error', (e: any) => {
579
+ this.errorLog(`Curtain: ${this.accessory.displayName} error message: ${e.message}`);
580
+ });
581
+ req.end();
542
582
  } catch (e: any) {
543
583
  this.errorLog(`Curtain: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection`);
544
584
  if (this.deviceLogging.includes('debug')) {
@@ -613,7 +653,7 @@ export class Curtain {
613
653
  `Curtain: ${this.accessory.displayName} failed pushChanges with BLE Connection,` + ` Error Message: ${JSON.stringify(e.message)}`,
614
654
  );
615
655
  }
616
- if (this.platform.config.credentials?.openToken) {
656
+ if (this.platform.config.credentials?.token) {
617
657
  this.warnLog(`Curtain: ${this.accessory.displayName} Using OpenAPI Connection`);
618
658
  await this.openAPIpushChanges();
619
659
  }
@@ -621,7 +661,7 @@ export class Curtain {
621
661
  });
622
662
  } else {
623
663
  this.errorLog(`Curtain: ${this.accessory.displayName} wasn't able to establish BLE Connection`);
624
- if (this.platform.config.credentials?.openToken) {
664
+ if (this.platform.config.credentials?.token) {
625
665
  this.warnLog(`Curtain: ${this.accessory.displayName} Using OpenAPI Connection`);
626
666
  await this.openAPIpushChanges();
627
667
  }
@@ -635,10 +675,19 @@ export class Curtain {
635
675
  }
636
676
 
637
677
  async openAPIpushChanges(): Promise<void> {
638
- if (this.platform.config.credentials?.openToken) {
678
+ if (this.platform.config.credentials?.token) {
639
679
  try {
640
680
  this.debugLog(`Curtain: ${this.accessory.displayName} OpenAPI pushChanges`);
641
681
  if (this.TargetPosition !== this.CurrentPosition) {
682
+ // Make Push On request to the API
683
+ const t = Date.now();
684
+ const nonce = 'requestID';
685
+ const data = this.platform.config.credentials?.token + t + nonce;
686
+ const signTerm = crypto.createHmac('sha256', this.platform.config.credentials?.secret)
687
+ .update(Buffer.from(data, 'utf-8'))
688
+ .digest();
689
+ const sign = signTerm.toString('base64');
690
+ this.debugLog(`Curtain: ${this.accessory.displayName} sign: ${sign}`);
642
691
  this.debugLog(`Pushing ${this.TargetPosition}`);
643
692
  const adjustedTargetPosition = 100 - Number(this.TargetPosition);
644
693
  if (this.TargetPosition > 50) {
@@ -655,21 +704,39 @@ export class Curtain {
655
704
  }
656
705
  this.debugLog(`${this.accessory.displayName} Mode: ${this.Mode}`);
657
706
  const adjustedMode = this.setPositionMode || 'ff';
658
- const payload = {
659
- commandType: 'command',
660
- command: 'setPosition',
661
- parameter: `0,${adjustedMode},${adjustedTargetPosition}`,
662
- } as payload;
663
-
664
- this.infoLog(
665
- `Curtain: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},` +
666
- ` parameter: ${payload.parameter}, commandType: ${payload.commandType}`,
667
- );
668
-
669
- // Make the API request
670
- const push: any = await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId!}/commands`, payload);
671
- this.debugLog(`Curtain: ${this.accessory.displayName} pushchanges: ${JSON.stringify(push.data)}`);
672
- this.statusCode(push);
707
+ const body = JSON.stringify({
708
+ 'command': 'setPosition',
709
+ 'parameter': `0,${adjustedMode},${adjustedTargetPosition}`,
710
+ 'commandType': 'command',
711
+ });
712
+ this.infoLog(`Curtain: ${this.accessory.displayName} Sending request to SwitchBot API. body: ${body},`);
713
+ const options = {
714
+ hostname: HostDomain,
715
+ port: 443,
716
+ path: `${DevicePath}/${this.device.deviceId}/commands`,
717
+ method: 'POST',
718
+ headers: {
719
+ 'Authorization': this.platform.config.credentials?.token,
720
+ 'sign': sign,
721
+ 'nonce': nonce,
722
+ 't': t,
723
+ 'Content-Type': 'application/json',
724
+ 'Content-Length': body.length,
725
+ },
726
+ };
727
+ const req = https.request(options, res => {
728
+ this.debugLog(`Curtain: ${this.accessory.displayName} statusCode: ${res.statusCode}`);
729
+ this.statusCode({ res });
730
+ res.on('data', d => {
731
+ this.debugLog(`Curtain: ${this.accessory.displayName} d: ${d}`);
732
+ });
733
+ });
734
+ req.on('error', (e: any) => {
735
+ this.errorLog(`Curtain: ${this.accessory.displayName} error message: ${e.message}`);
736
+ });
737
+ req.write(body);
738
+ req.end();
739
+ this.debugLog(`Curtain: ${this.accessory.displayName} openAPIpushChanges: ${JSON.stringify(req)}`);
673
740
  } else {
674
741
  this.debugLog(
675
742
  `Curtain: ${this.accessory.displayName} No OpenAPI Changes, CurrentPosition & TargetPosition Are the Same.` +
@@ -752,8 +819,8 @@ export class Curtain {
752
819
  //throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
753
820
  }
754
821
 
755
- async statusCode(push: AxiosResponse<{ statusCode: number }>): Promise<void> {
756
- switch (push.data.statusCode) {
822
+ async statusCode({ res }: { res: IncomingMessage }): Promise<void> {
823
+ switch (res.statusCode) {
757
824
  case 151:
758
825
  this.errorLog(`Curtain: ${this.accessory.displayName} Command not supported by this device type.`);
759
826
  break;
@@ -772,7 +839,7 @@ export class Curtain {
772
839
  case 190:
773
840
  this.errorLog(
774
841
  `Curtain: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,` +
775
- ` Or command: ${JSON.stringify(push.data)} format is invalid`,
842
+ ` Or command: ${JSON.stringify(res)} format is invalid`,
776
843
  );
777
844
  break;
778
845
  case 100: