@switchbot/homebridge-switchbot 3.8.3-beta.16 → 3.8.3-beta.17
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.
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +12 -13
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +12 -13
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +27 -31
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +27 -31
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.js +7 -7
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +12 -13
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/device.d.ts +1 -3
- package/dist/device/device.d.ts.map +1 -1
- package/dist/device/device.js +2 -2
- package/dist/device/device.js.map +1 -1
- package/dist/device/fan.d.ts.map +1 -1
- package/dist/device/fan.js +22 -25
- package/dist/device/fan.js.map +1 -1
- package/dist/device/hub.js +7 -7
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +22 -25
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.js +7 -7
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +22 -25
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +12 -13
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.js +7 -7
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.js +7 -7
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.js +7 -7
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +12 -13
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +17 -19
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/device/waterdetector.js +7 -7
- package/dist/device/waterdetector.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +5 -6
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +5 -6
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +5 -6
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +5 -6
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/irdevice.d.ts +3 -4
- package/dist/irdevice/irdevice.d.ts.map +1 -1
- package/dist/irdevice/irdevice.js +5 -6
- package/dist/irdevice/irdevice.js.map +1 -1
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +5 -6
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +5 -6
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +5 -6
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +5 -6
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +5 -6
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts +0 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +7 -12
- package/dist/platform.js.map +1 -1
- package/package.json +2 -2
- package/src/device/blindtilt.ts +12 -13
- package/src/device/bot.ts +12 -13
- package/src/device/ceilinglight.ts +27 -31
- package/src/device/colorbulb.ts +27 -31
- package/src/device/contact.ts +7 -7
- package/src/device/curtain.ts +12 -13
- package/src/device/device.ts +4 -4
- package/src/device/fan.ts +22 -25
- package/src/device/hub.ts +7 -7
- package/src/device/humidifier.ts +22 -25
- package/src/device/iosensor.ts +7 -7
- package/src/device/lightstrip.ts +22 -25
- package/src/device/lock.ts +12 -13
- package/src/device/meter.ts +7 -7
- package/src/device/meterplus.ts +7 -7
- package/src/device/motion.ts +7 -7
- package/src/device/plug.ts +12 -13
- package/src/device/robotvacuumcleaner.ts +17 -19
- package/src/device/waterdetector.ts +7 -7
- package/src/irdevice/airconditioner.ts +5 -6
- package/src/irdevice/airpurifier.ts +5 -6
- package/src/irdevice/camera.ts +5 -6
- package/src/irdevice/fan.ts +5 -6
- package/src/irdevice/irdevice.ts +6 -7
- package/src/irdevice/light.ts +5 -6
- package/src/irdevice/other.ts +5 -6
- package/src/irdevice/tv.ts +5 -6
- package/src/irdevice/vacuumcleaner.ts +5 -6
- package/src/irdevice/waterheater.ts +5 -6
- package/src/platform.ts +8 -12
package/src/device/blindtilt.ts
CHANGED
|
@@ -504,17 +504,17 @@ export class BlindTilt extends deviceBase {
|
|
|
504
504
|
async openAPIRefreshStatus(): Promise<void> {
|
|
505
505
|
await this.debugLog('openAPIRefreshStatus')
|
|
506
506
|
try {
|
|
507
|
-
const { body
|
|
508
|
-
const deviceStatus: any = await body
|
|
509
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
510
|
-
if (await this.successfulStatusCodes(
|
|
511
|
-
await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
507
|
+
const { body } = await this.deviceRefreshStatus()
|
|
508
|
+
const deviceStatus: any = await body
|
|
509
|
+
await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
510
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
511
|
+
await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
512
512
|
this.deviceStatus = deviceStatus.body
|
|
513
513
|
await this.openAPIparseStatus()
|
|
514
514
|
await this.updateHomeKitCharacteristics()
|
|
515
515
|
} else {
|
|
516
|
-
await this.debugWarnLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
517
|
-
await this.debugWarnLog(
|
|
516
|
+
await this.debugWarnLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
517
|
+
await this.debugWarnLog(deviceStatus)
|
|
518
518
|
}
|
|
519
519
|
} catch (e: any) {
|
|
520
520
|
await this.apiError(e)
|
|
@@ -636,14 +636,13 @@ export class BlindTilt extends deviceBase {
|
|
|
636
636
|
}
|
|
637
637
|
await this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
|
|
638
638
|
try {
|
|
639
|
-
const { body
|
|
640
|
-
const deviceStatus: any = await body
|
|
641
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
642
|
-
if (await this.successfulStatusCodes(
|
|
643
|
-
await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
639
|
+
const { body } = await this.pushChangeRequest(bodyChange)
|
|
640
|
+
const deviceStatus: any = await body
|
|
641
|
+
await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
642
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
643
|
+
await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
644
644
|
await this.updateHomeKitCharacteristics()
|
|
645
645
|
} else {
|
|
646
|
-
await this.statusCode(statusCode)
|
|
647
646
|
await this.statusCode(deviceStatus.statusCode)
|
|
648
647
|
}
|
|
649
648
|
} catch (e: any) {
|
package/src/device/bot.ts
CHANGED
|
@@ -598,17 +598,17 @@ export class Bot extends deviceBase {
|
|
|
598
598
|
async openAPIRefreshStatus(): Promise<void> {
|
|
599
599
|
await this.debugLog('openAPIRefreshStatus')
|
|
600
600
|
try {
|
|
601
|
-
const { body
|
|
602
|
-
const deviceStatus: any = await body
|
|
603
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
604
|
-
if (await this.successfulStatusCodes(
|
|
605
|
-
await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
601
|
+
const { body } = await this.deviceRefreshStatus()
|
|
602
|
+
const deviceStatus: any = await body
|
|
603
|
+
await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
604
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
605
|
+
await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
606
606
|
this.deviceStatus = deviceStatus.body
|
|
607
607
|
await this.openAPIparseStatus()
|
|
608
608
|
await this.updateHomeKitCharacteristics()
|
|
609
609
|
} else {
|
|
610
|
-
await this.debugWarnLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
611
|
-
await this.debugWarnLog(
|
|
610
|
+
await this.debugWarnLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
611
|
+
await this.debugWarnLog(deviceStatus)
|
|
612
612
|
}
|
|
613
613
|
} catch (e: any) {
|
|
614
614
|
await this.apiError(e)
|
|
@@ -753,14 +753,13 @@ export class Bot extends deviceBase {
|
|
|
753
753
|
}
|
|
754
754
|
this.debugLog(`Sending request to SwitchBot API, body: ${JSON.stringify(bodyChange)},`)
|
|
755
755
|
try {
|
|
756
|
-
const { body
|
|
757
|
-
const deviceStatus: any = await body
|
|
758
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
759
|
-
if (await this.successfulStatusCodes(
|
|
760
|
-
await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
756
|
+
const { body } = await this.pushChangeRequest(bodyChange)
|
|
757
|
+
const deviceStatus: any = await body
|
|
758
|
+
await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
759
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
760
|
+
await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
761
761
|
await this.updateHomeKitCharacteristics()
|
|
762
762
|
} else {
|
|
763
|
-
await this.statusCode(statusCode)
|
|
764
763
|
await this.statusCode(deviceStatus.statusCode)
|
|
765
764
|
}
|
|
766
765
|
if (this.device.bot?.mode === 'multipress') {
|
|
@@ -332,17 +332,17 @@ export class CeilingLight extends deviceBase {
|
|
|
332
332
|
async openAPIRefreshStatus(): Promise<void> {
|
|
333
333
|
await this.debugLog('openAPIRefreshStatus')
|
|
334
334
|
try {
|
|
335
|
-
const { body
|
|
336
|
-
const deviceStatus: any = await body
|
|
337
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
338
|
-
if (await this.successfulStatusCodes(
|
|
339
|
-
await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
335
|
+
const { body } = await this.deviceRefreshStatus()
|
|
336
|
+
const deviceStatus: any = await body
|
|
337
|
+
await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
338
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
339
|
+
await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
340
340
|
this.deviceStatus = deviceStatus.body
|
|
341
341
|
await this.openAPIparseStatus()
|
|
342
342
|
await this.updateHomeKitCharacteristics()
|
|
343
343
|
} else {
|
|
344
|
-
await this.debugWarnLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
345
|
-
await this.debugWarnLog(
|
|
344
|
+
await this.debugWarnLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
345
|
+
await this.debugWarnLog(deviceStatus)
|
|
346
346
|
}
|
|
347
347
|
} catch (e: any) {
|
|
348
348
|
await this.apiError(e)
|
|
@@ -470,14 +470,13 @@ export class CeilingLight extends deviceBase {
|
|
|
470
470
|
}
|
|
471
471
|
await this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
|
|
472
472
|
try {
|
|
473
|
-
const { body
|
|
474
|
-
const deviceStatus: any = await body
|
|
475
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
476
|
-
if (await this.successfulStatusCodes(
|
|
477
|
-
await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
473
|
+
const { body } = await this.pushChangeRequest(bodyChange)
|
|
474
|
+
const deviceStatus: any = await body
|
|
475
|
+
await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
476
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
477
|
+
await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
478
478
|
await this.updateHomeKitCharacteristics()
|
|
479
479
|
} else {
|
|
480
|
-
await this.statusCode(statusCode)
|
|
481
480
|
await this.statusCode(deviceStatus.statusCode)
|
|
482
481
|
}
|
|
483
482
|
} catch (e: any) {
|
|
@@ -503,14 +502,13 @@ export class CeilingLight extends deviceBase {
|
|
|
503
502
|
}
|
|
504
503
|
await this.debugLog(`(pushHueSaturationChanges) SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
|
|
505
504
|
try {
|
|
506
|
-
const { body
|
|
507
|
-
const deviceStatus: any = await body
|
|
508
|
-
await this.debugLog(`(pushHueSaturationChanges) statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
509
|
-
if (await this.successfulStatusCodes(
|
|
510
|
-
await this.debugSuccessLog(`(pushHueSaturationChanges) statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
505
|
+
const { body } = await this.pushChangeRequest(bodyChange)
|
|
506
|
+
const deviceStatus: any = await body
|
|
507
|
+
await this.debugLog(`(pushHueSaturationChanges) statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
508
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
509
|
+
await this.debugSuccessLog(`(pushHueSaturationChanges) statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
511
510
|
await this.updateHomeKitCharacteristics()
|
|
512
511
|
} else {
|
|
513
|
-
await this.statusCode(statusCode)
|
|
514
512
|
await this.statusCode(deviceStatus.statusCode)
|
|
515
513
|
}
|
|
516
514
|
} catch (e: any) {
|
|
@@ -534,14 +532,13 @@ export class CeilingLight extends deviceBase {
|
|
|
534
532
|
}
|
|
535
533
|
await this.debugLog(`(pushColorTemperatureChanges) SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
|
|
536
534
|
try {
|
|
537
|
-
const { body
|
|
538
|
-
const deviceStatus: any = await body
|
|
539
|
-
await this.debugLog(`(pushColorTemperatureChanges) statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
540
|
-
if (await this.successfulStatusCodes(
|
|
541
|
-
await this.debugSuccessLog(`(pushColorTemperatureChanges) statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
535
|
+
const { body } = await this.pushChangeRequest(bodyChange)
|
|
536
|
+
const deviceStatus: any = await body
|
|
537
|
+
await this.debugLog(`(pushColorTemperatureChanges) statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
538
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
539
|
+
await this.debugSuccessLog(`(pushColorTemperatureChanges) statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
542
540
|
await this.updateHomeKitCharacteristics()
|
|
543
541
|
} else {
|
|
544
|
-
await this.statusCode(statusCode)
|
|
545
542
|
await this.statusCode(deviceStatus.statusCode)
|
|
546
543
|
}
|
|
547
544
|
} catch (e: any) {
|
|
@@ -563,14 +560,13 @@ export class CeilingLight extends deviceBase {
|
|
|
563
560
|
}
|
|
564
561
|
await this.debugLog(`(pushBrightnessChanges) SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
|
|
565
562
|
try {
|
|
566
|
-
const { body
|
|
567
|
-
const deviceStatus: any = await body
|
|
568
|
-
await this.debugLog(`(pushBrightnessChanges) statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
569
|
-
if (await this.successfulStatusCodes(
|
|
570
|
-
await this.debugSuccessLog(`(pushBrightnessChanges) statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
563
|
+
const { body } = await this.pushChangeRequest(bodyChange)
|
|
564
|
+
const deviceStatus: any = await body
|
|
565
|
+
await this.debugLog(`(pushBrightnessChanges) statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
566
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
567
|
+
await this.debugSuccessLog(`(pushBrightnessChanges) statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
571
568
|
await this.updateHomeKitCharacteristics()
|
|
572
569
|
} else {
|
|
573
|
-
await this.statusCode(statusCode)
|
|
574
570
|
await this.statusCode(deviceStatus.statusCode)
|
|
575
571
|
}
|
|
576
572
|
} catch (e: any) {
|
package/src/device/colorbulb.ts
CHANGED
|
@@ -355,17 +355,17 @@ export class ColorBulb extends deviceBase {
|
|
|
355
355
|
async openAPIRefreshStatus(): Promise<void> {
|
|
356
356
|
await this.debugLog('openAPIRefreshStatus')
|
|
357
357
|
try {
|
|
358
|
-
const { body
|
|
359
|
-
const deviceStatus: any = await body
|
|
360
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
361
|
-
if (await this.successfulStatusCodes(
|
|
362
|
-
await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
358
|
+
const { body } = await this.deviceRefreshStatus()
|
|
359
|
+
const deviceStatus: any = await body
|
|
360
|
+
await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
361
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
362
|
+
await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
363
363
|
this.deviceStatus = deviceStatus.body
|
|
364
364
|
await this.openAPIparseStatus()
|
|
365
365
|
await this.updateHomeKitCharacteristics()
|
|
366
366
|
} else {
|
|
367
|
-
await this.debugWarnLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
368
|
-
await this.debugWarnLog(
|
|
367
|
+
await this.debugWarnLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
368
|
+
await this.debugWarnLog(deviceStatus)
|
|
369
369
|
}
|
|
370
370
|
} catch (e: any) {
|
|
371
371
|
await this.apiError(e)
|
|
@@ -618,14 +618,13 @@ export class ColorBulb extends deviceBase {
|
|
|
618
618
|
}
|
|
619
619
|
await this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
|
|
620
620
|
try {
|
|
621
|
-
const { body
|
|
622
|
-
const deviceStatus: any = await body
|
|
623
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
624
|
-
if (await this.successfulStatusCodes(
|
|
625
|
-
await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
621
|
+
const { body } = await this.pushChangeRequest(bodyChange)
|
|
622
|
+
const deviceStatus: any = await body
|
|
623
|
+
await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
624
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
625
|
+
await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
626
626
|
await this.updateHomeKitCharacteristics()
|
|
627
627
|
} else {
|
|
628
|
-
await this.statusCode(statusCode)
|
|
629
628
|
await this.statusCode(deviceStatus.statusCode)
|
|
630
629
|
}
|
|
631
630
|
} catch (e: any) {
|
|
@@ -650,14 +649,13 @@ export class ColorBulb extends deviceBase {
|
|
|
650
649
|
}
|
|
651
650
|
await this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
|
|
652
651
|
try {
|
|
653
|
-
const { body
|
|
654
|
-
const deviceStatus: any = await body
|
|
655
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
656
|
-
if (await this.successfulStatusCodes(
|
|
657
|
-
await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
652
|
+
const { body } = await this.pushChangeRequest(bodyChange)
|
|
653
|
+
const deviceStatus: any = await body
|
|
654
|
+
await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
655
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
656
|
+
await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
658
657
|
await this.updateHomeKitCharacteristics()
|
|
659
658
|
} else {
|
|
660
|
-
await this.statusCode(statusCode)
|
|
661
659
|
await this.statusCode(deviceStatus.statusCode)
|
|
662
660
|
}
|
|
663
661
|
} catch (e: any) {
|
|
@@ -681,14 +679,13 @@ export class ColorBulb extends deviceBase {
|
|
|
681
679
|
}
|
|
682
680
|
await this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
|
|
683
681
|
try {
|
|
684
|
-
const { body
|
|
685
|
-
const deviceStatus: any = await body
|
|
686
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
687
|
-
if (await this.successfulStatusCodes(
|
|
688
|
-
await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
682
|
+
const { body } = await this.pushChangeRequest(bodyChange)
|
|
683
|
+
const deviceStatus: any = await body
|
|
684
|
+
await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
685
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
686
|
+
await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
689
687
|
await this.updateHomeKitCharacteristics()
|
|
690
688
|
} else {
|
|
691
|
-
await this.statusCode(statusCode)
|
|
692
689
|
await this.statusCode(deviceStatus.statusCode)
|
|
693
690
|
}
|
|
694
691
|
} catch (e: any) {
|
|
@@ -710,14 +707,13 @@ export class ColorBulb extends deviceBase {
|
|
|
710
707
|
}
|
|
711
708
|
await this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
|
|
712
709
|
try {
|
|
713
|
-
const { body
|
|
714
|
-
const deviceStatus: any = await body
|
|
715
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
716
|
-
if (await this.successfulStatusCodes(
|
|
717
|
-
await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
710
|
+
const { body } = await this.pushChangeRequest(bodyChange)
|
|
711
|
+
const deviceStatus: any = await body
|
|
712
|
+
await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
713
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
714
|
+
await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
718
715
|
await this.updateHomeKitCharacteristics()
|
|
719
716
|
} else {
|
|
720
|
-
await this.statusCode(statusCode)
|
|
721
717
|
await this.statusCode(deviceStatus.statusCode)
|
|
722
718
|
}
|
|
723
719
|
} catch (e: any) {
|
package/src/device/contact.ts
CHANGED
|
@@ -345,17 +345,17 @@ export class Contact extends deviceBase {
|
|
|
345
345
|
async openAPIRefreshStatus(): Promise<void> {
|
|
346
346
|
await this.debugLog('openAPIRefreshStatus')
|
|
347
347
|
try {
|
|
348
|
-
const { body
|
|
349
|
-
const deviceStatus: any = await body
|
|
350
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
351
|
-
if (await this.successfulStatusCodes(
|
|
352
|
-
await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
348
|
+
const { body } = await this.deviceRefreshStatus()
|
|
349
|
+
const deviceStatus: any = await body
|
|
350
|
+
await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
351
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
352
|
+
await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
353
353
|
this.deviceStatus = deviceStatus.body
|
|
354
354
|
await this.openAPIparseStatus()
|
|
355
355
|
await this.updateHomeKitCharacteristics()
|
|
356
356
|
} else {
|
|
357
|
-
await this.debugWarnLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
358
|
-
await this.debugWarnLog(
|
|
357
|
+
await this.debugWarnLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
358
|
+
await this.debugWarnLog(deviceStatus)
|
|
359
359
|
}
|
|
360
360
|
} catch (e: any) {
|
|
361
361
|
await this.apiError(e)
|
package/src/device/curtain.ts
CHANGED
|
@@ -502,17 +502,17 @@ export class Curtain extends deviceBase {
|
|
|
502
502
|
async openAPIRefreshStatus(): Promise<void> {
|
|
503
503
|
await this.debugLog('openAPIRefreshStatus')
|
|
504
504
|
try {
|
|
505
|
-
const { body
|
|
506
|
-
const deviceStatus: any = await body
|
|
507
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
508
|
-
if (await this.successfulStatusCodes(
|
|
509
|
-
await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
505
|
+
const { body } = await this.deviceRefreshStatus()
|
|
506
|
+
const deviceStatus: any = await body
|
|
507
|
+
await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
508
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
509
|
+
await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
510
510
|
this.deviceStatus = deviceStatus.body
|
|
511
511
|
await this.openAPIparseStatus()
|
|
512
512
|
await this.updateHomeKitCharacteristics()
|
|
513
513
|
} else {
|
|
514
|
-
await this.debugWarnLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
515
|
-
await this.debugWarnLog(
|
|
514
|
+
await this.debugWarnLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
515
|
+
await this.debugWarnLog(deviceStatus)
|
|
516
516
|
}
|
|
517
517
|
} catch (e: any) {
|
|
518
518
|
await this.apiError(e)
|
|
@@ -654,14 +654,13 @@ export class Curtain extends deviceBase {
|
|
|
654
654
|
}
|
|
655
655
|
await this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
|
|
656
656
|
try {
|
|
657
|
-
const { body
|
|
658
|
-
const deviceStatus: any = await body
|
|
659
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
660
|
-
if (await this.successfulStatusCodes(
|
|
661
|
-
await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
657
|
+
const { body } = await this.pushChangeRequest(bodyChange)
|
|
658
|
+
const deviceStatus: any = await body
|
|
659
|
+
await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
660
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
661
|
+
await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
662
662
|
await this.updateHomeKitCharacteristics()
|
|
663
663
|
} else {
|
|
664
|
-
await this.statusCode(statusCode)
|
|
665
664
|
await this.statusCode(deviceStatus.statusCode)
|
|
666
665
|
}
|
|
667
666
|
} catch (e: any) {
|
package/src/device/device.ts
CHANGED
|
@@ -344,16 +344,16 @@ export abstract class deviceBase {
|
|
|
344
344
|
}
|
|
345
345
|
}
|
|
346
346
|
|
|
347
|
-
async pushChangeRequest(bodyChange: bodyChange): Promise<{ body: any
|
|
347
|
+
async pushChangeRequest(bodyChange: bodyChange): Promise<{ body: any }> {
|
|
348
348
|
return this.platform.switchBotAPI.controlDevice(this.device.deviceId, bodyChange.command, bodyChange.parameter, bodyChange.commandType)
|
|
349
349
|
}
|
|
350
350
|
|
|
351
|
-
async deviceRefreshStatus(): Promise<{ body: any
|
|
351
|
+
async deviceRefreshStatus(): Promise<{ body: any }> {
|
|
352
352
|
return await this.platform.retryRequest(this.device.deviceId, this.deviceMaxRetries, this.deviceDelayBetweenRetries)
|
|
353
353
|
}
|
|
354
354
|
|
|
355
|
-
async successfulStatusCodes(
|
|
356
|
-
return (
|
|
355
|
+
async successfulStatusCodes(deviceStatus: any) {
|
|
356
|
+
return (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)
|
|
357
357
|
}
|
|
358
358
|
|
|
359
359
|
/**
|
package/src/device/fan.ts
CHANGED
|
@@ -369,17 +369,17 @@ export class Fan extends deviceBase {
|
|
|
369
369
|
async openAPIRefreshStatus(): Promise<void> {
|
|
370
370
|
await this.debugLog('openAPIRefreshStatus')
|
|
371
371
|
try {
|
|
372
|
-
const { body
|
|
373
|
-
const deviceStatus: any = await body
|
|
374
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
375
|
-
if (await this.successfulStatusCodes(
|
|
376
|
-
await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
372
|
+
const { body } = await this.deviceRefreshStatus()
|
|
373
|
+
const deviceStatus: any = await body
|
|
374
|
+
await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
375
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
376
|
+
await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
377
377
|
this.deviceStatus = deviceStatus.body
|
|
378
378
|
await this.openAPIparseStatus()
|
|
379
379
|
await this.updateHomeKitCharacteristics()
|
|
380
380
|
} else {
|
|
381
|
-
await this.debugWarnLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
382
|
-
await this.debugWarnLog(
|
|
381
|
+
await this.debugWarnLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
382
|
+
await this.debugWarnLog(deviceStatus)
|
|
383
383
|
}
|
|
384
384
|
} catch (e: any) {
|
|
385
385
|
await this.apiError(e)
|
|
@@ -502,14 +502,13 @@ export class Fan extends deviceBase {
|
|
|
502
502
|
}
|
|
503
503
|
await this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
|
|
504
504
|
try {
|
|
505
|
-
const { body
|
|
506
|
-
const deviceStatus: any = await body
|
|
507
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
508
|
-
if (await this.successfulStatusCodes(
|
|
509
|
-
await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
505
|
+
const { body } = await this.pushChangeRequest(bodyChange)
|
|
506
|
+
const deviceStatus: any = await body
|
|
507
|
+
await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
508
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
509
|
+
await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
510
510
|
await this.updateHomeKitCharacteristics()
|
|
511
511
|
} else {
|
|
512
|
-
await this.statusCode(statusCode)
|
|
513
512
|
await this.statusCode(deviceStatus.statusCode)
|
|
514
513
|
}
|
|
515
514
|
} catch (e: any) {
|
|
@@ -531,14 +530,13 @@ export class Fan extends deviceBase {
|
|
|
531
530
|
}
|
|
532
531
|
await this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
|
|
533
532
|
try {
|
|
534
|
-
const { body
|
|
535
|
-
const deviceStatus: any = await body
|
|
536
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
537
|
-
if (await this.successfulStatusCodes(
|
|
538
|
-
await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
533
|
+
const { body } = await this.pushChangeRequest(bodyChange)
|
|
534
|
+
const deviceStatus: any = await body
|
|
535
|
+
await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
536
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
537
|
+
await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
539
538
|
await this.updateHomeKitCharacteristics()
|
|
540
539
|
} else {
|
|
541
|
-
await this.statusCode(statusCode)
|
|
542
540
|
await this.statusCode(deviceStatus.statusCode)
|
|
543
541
|
}
|
|
544
542
|
} catch (e: any) {
|
|
@@ -561,14 +559,13 @@ export class Fan extends deviceBase {
|
|
|
561
559
|
}
|
|
562
560
|
await this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
|
|
563
561
|
try {
|
|
564
|
-
const { body
|
|
565
|
-
const deviceStatus: any = await body
|
|
566
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
567
|
-
if (await this.successfulStatusCodes(
|
|
568
|
-
await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
562
|
+
const { body } = await this.pushChangeRequest(bodyChange)
|
|
563
|
+
const deviceStatus: any = await body
|
|
564
|
+
await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
565
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
566
|
+
await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
569
567
|
await this.updateHomeKitCharacteristics()
|
|
570
568
|
} else {
|
|
571
|
-
await this.statusCode(statusCode)
|
|
572
569
|
await this.statusCode(deviceStatus.statusCode)
|
|
573
570
|
}
|
|
574
571
|
} catch (e: any) {
|
package/src/device/hub.ts
CHANGED
|
@@ -337,17 +337,17 @@ export class Hub extends deviceBase {
|
|
|
337
337
|
async openAPIRefreshStatus(): Promise<void> {
|
|
338
338
|
await this.debugLog('openAPIRefreshStatus')
|
|
339
339
|
try {
|
|
340
|
-
const { body
|
|
341
|
-
const deviceStatus: any = await body
|
|
342
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
343
|
-
if (await this.successfulStatusCodes(
|
|
344
|
-
await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
340
|
+
const { body } = await this.deviceRefreshStatus()
|
|
341
|
+
const deviceStatus: any = await body
|
|
342
|
+
await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
343
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
344
|
+
await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
345
345
|
this.deviceStatus = deviceStatus.body
|
|
346
346
|
await this.openAPIparseStatus()
|
|
347
347
|
await this.updateHomeKitCharacteristics()
|
|
348
348
|
} else {
|
|
349
|
-
await this.debugWarnLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
350
|
-
await this.debugWarnLog(
|
|
349
|
+
await this.debugWarnLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
350
|
+
await this.debugWarnLog(deviceStatus)
|
|
351
351
|
}
|
|
352
352
|
} catch (e: any) {
|
|
353
353
|
await this.apiError(e)
|
package/src/device/humidifier.ts
CHANGED
|
@@ -367,17 +367,17 @@ export class Humidifier extends deviceBase {
|
|
|
367
367
|
async openAPIRefreshStatus(): Promise<void> {
|
|
368
368
|
await this.debugLog('openAPIRefreshStatus')
|
|
369
369
|
try {
|
|
370
|
-
const { body
|
|
371
|
-
const deviceStatus: any = await body
|
|
372
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
373
|
-
if (await this.successfulStatusCodes(
|
|
374
|
-
await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
370
|
+
const { body } = await this.deviceRefreshStatus()
|
|
371
|
+
const deviceStatus: any = await body
|
|
372
|
+
await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
373
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
374
|
+
await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
375
375
|
this.deviceStatus = deviceStatus.body
|
|
376
376
|
await this.openAPIparseStatus()
|
|
377
377
|
await this.updateHomeKitCharacteristics()
|
|
378
378
|
} else {
|
|
379
|
-
await this.debugWarnLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
380
|
-
await this.debugWarnLog(
|
|
379
|
+
await this.debugWarnLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
380
|
+
await this.debugWarnLog(deviceStatus)
|
|
381
381
|
}
|
|
382
382
|
} catch (e: any) {
|
|
383
383
|
await this.apiError(e)
|
|
@@ -474,14 +474,13 @@ export class Humidifier extends deviceBase {
|
|
|
474
474
|
}
|
|
475
475
|
await this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
|
|
476
476
|
try {
|
|
477
|
-
const { body
|
|
478
|
-
const deviceStatus: any = await body
|
|
479
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
480
|
-
if (await this.successfulStatusCodes(
|
|
481
|
-
await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
477
|
+
const { body } = await this.pushChangeRequest(bodyChange)
|
|
478
|
+
const deviceStatus: any = await body
|
|
479
|
+
await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
480
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
481
|
+
await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
482
482
|
await this.updateHomeKitCharacteristics()
|
|
483
483
|
} else {
|
|
484
|
-
await this.statusCode(statusCode)
|
|
485
484
|
await this.statusCode(deviceStatus.statusCode)
|
|
486
485
|
}
|
|
487
486
|
} catch (e: any) {
|
|
@@ -511,14 +510,13 @@ export class Humidifier extends deviceBase {
|
|
|
511
510
|
}
|
|
512
511
|
await this.debugLog(`pushAutoChanges, SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
|
|
513
512
|
try {
|
|
514
|
-
const { body
|
|
515
|
-
const deviceStatus: any = await body
|
|
516
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
517
|
-
if (await this.successfulStatusCodes(
|
|
518
|
-
await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
513
|
+
const { body } = await this.pushChangeRequest(bodyChange)
|
|
514
|
+
const deviceStatus: any = await body
|
|
515
|
+
await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
516
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
517
|
+
await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
519
518
|
await this.updateHomeKitCharacteristics()
|
|
520
519
|
} else {
|
|
521
|
-
await this.statusCode(statusCode)
|
|
522
520
|
await this.statusCode(deviceStatus.statusCode)
|
|
523
521
|
}
|
|
524
522
|
} catch (e: any) {
|
|
@@ -544,14 +542,13 @@ export class Humidifier extends deviceBase {
|
|
|
544
542
|
}
|
|
545
543
|
await this.debugLog(`pushActiveChanges, SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
|
|
546
544
|
try {
|
|
547
|
-
const { body
|
|
548
|
-
const deviceStatus: any = await body
|
|
549
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
550
|
-
if (await this.successfulStatusCodes(
|
|
551
|
-
await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
545
|
+
const { body } = await this.pushChangeRequest(bodyChange)
|
|
546
|
+
const deviceStatus: any = await body
|
|
547
|
+
await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
548
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
549
|
+
await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
552
550
|
await this.updateHomeKitCharacteristics()
|
|
553
551
|
} else {
|
|
554
|
-
await this.statusCode(statusCode)
|
|
555
552
|
await this.statusCode(deviceStatus.statusCode)
|
|
556
553
|
}
|
|
557
554
|
} catch (e: any) {
|
package/src/device/iosensor.ts
CHANGED
|
@@ -332,17 +332,17 @@ export class IOSensor extends deviceBase {
|
|
|
332
332
|
async openAPIRefreshStatus(): Promise<void> {
|
|
333
333
|
await this.debugLog('openAPIRefreshStatus')
|
|
334
334
|
try {
|
|
335
|
-
const { body
|
|
336
|
-
const deviceStatus: any = await body
|
|
337
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
338
|
-
if (await this.successfulStatusCodes(
|
|
339
|
-
await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
335
|
+
const { body } = await this.deviceRefreshStatus()
|
|
336
|
+
const deviceStatus: any = await body
|
|
337
|
+
await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
338
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
339
|
+
await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
340
340
|
this.deviceStatus = deviceStatus.body
|
|
341
341
|
await this.openAPIparseStatus()
|
|
342
342
|
await this.updateHomeKitCharacteristics()
|
|
343
343
|
} else {
|
|
344
|
-
await this.debugWarnLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
345
|
-
await this.debugWarnLog(
|
|
344
|
+
await this.debugWarnLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
345
|
+
await this.debugWarnLog(deviceStatus)
|
|
346
346
|
}
|
|
347
347
|
} catch (e: any) {
|
|
348
348
|
await this.apiError(e)
|