@switchbot/homebridge-switchbot 4.3.2-beta.0 → 4.3.2-beta.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.
- package/config.schema.json +1 -1
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +2 -4
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +2 -4
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +5 -10
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +5 -10
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +1 -2
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +2 -4
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/device.d.ts +7 -5
- package/dist/device/device.d.ts.map +1 -1
- package/dist/device/device.js.map +1 -1
- package/dist/device/fan.d.ts.map +1 -1
- package/dist/device/fan.js +4 -8
- package/dist/device/fan.js.map +1 -1
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +1 -2
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +4 -8
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +1 -2
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +4 -8
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +2 -4
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +1 -2
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +1 -2
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/meterpro.d.ts.map +1 -1
- package/dist/device/meterpro.js +1 -2
- package/dist/device/meterpro.js.map +1 -1
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +1 -2
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +2 -4
- package/dist/device/plug.js.map +1 -1
- package/dist/device/relayswitch.d.ts.map +1 -1
- package/dist/device/relayswitch.js +2 -4
- package/dist/device/relayswitch.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +3 -6
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/device/waterdetector.d.ts.map +1 -1
- package/dist/device/waterdetector.js +1 -2
- package/dist/device/waterdetector.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +1 -2
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +1 -2
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +1 -2
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +1 -2
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/irdevice.d.ts +6 -2
- package/dist/irdevice/irdevice.d.ts.map +1 -1
- package/dist/irdevice/irdevice.js.map +1 -1
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +1 -2
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +1 -2
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +1 -2
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +1 -2
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +1 -2
- package/dist/irdevice/waterheater.js.map +1 -1
- package/docs/functions/default.html +1 -1
- package/eslint.config.js +0 -1
- package/package.json +18 -17
- package/src/device/blindtilt.ts +2 -4
- package/src/device/bot.ts +2 -4
- package/src/device/ceilinglight.ts +5 -10
- package/src/device/colorbulb.ts +5 -10
- package/src/device/contact.ts +1 -2
- package/src/device/curtain.ts +4 -6
- package/src/device/device.ts +3 -3
- package/src/device/fan.ts +4 -8
- package/src/device/hub.ts +1 -2
- package/src/device/humidifier.ts +4 -8
- package/src/device/iosensor.ts +1 -2
- package/src/device/lightstrip.ts +4 -8
- package/src/device/lock.ts +2 -4
- package/src/device/meter.ts +1 -2
- package/src/device/meterplus.ts +1 -2
- package/src/device/meterpro.ts +2 -3
- package/src/device/motion.ts +1 -2
- package/src/device/plug.ts +2 -4
- package/src/device/relayswitch.ts +2 -4
- package/src/device/robotvacuumcleaner.ts +3 -6
- package/src/device/waterdetector.ts +1 -2
- package/src/irdevice/airconditioner.ts +1 -2
- package/src/irdevice/airpurifier.ts +1 -2
- package/src/irdevice/camera.ts +1 -2
- package/src/irdevice/fan.ts +1 -2
- package/src/irdevice/irdevice.ts +2 -2
- package/src/irdevice/light.ts +1 -2
- package/src/irdevice/other.ts +1 -2
- package/src/irdevice/tv.ts +1 -2
- package/src/irdevice/vacuumcleaner.ts +1 -2
- package/src/irdevice/waterheater.ts +1 -2
package/src/device/curtain.ts
CHANGED
|
@@ -332,8 +332,8 @@ export class Curtain extends deviceBase {
|
|
|
332
332
|
filename: `${hostname().split('.')[0]}_${this.device.bleMac}_persist.json`,
|
|
333
333
|
})
|
|
334
334
|
const motion: Service
|
|
335
|
-
|
|
336
|
-
|
|
335
|
+
= this.accessory.getService(this.hap.Service.MotionSensor)
|
|
336
|
+
|| this.accessory.addService(this.hap.Service.MotionSensor, 'Motion')
|
|
337
337
|
motion.addOptionalCharacteristic(this.platform.eve.Characteristics.LastActivation)
|
|
338
338
|
motion.getCharacteristic(this.platform.eve.Characteristics.LastActivation).onGet(() => {
|
|
339
339
|
const lastActivation = this.accessory.context.lastActivation
|
|
@@ -512,8 +512,7 @@ export class Curtain extends deviceBase {
|
|
|
512
512
|
async openAPIRefreshStatus(): Promise<void> {
|
|
513
513
|
this.debugLog('openAPIRefreshStatus')
|
|
514
514
|
try {
|
|
515
|
-
const
|
|
516
|
-
const deviceStatus: any = body
|
|
515
|
+
const deviceStatus = await this.deviceRefreshStatus<curtainStatus>()
|
|
517
516
|
this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
518
517
|
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
519
518
|
this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
@@ -673,8 +672,7 @@ export class Curtain extends deviceBase {
|
|
|
673
672
|
}
|
|
674
673
|
this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
|
|
675
674
|
try {
|
|
676
|
-
const
|
|
677
|
-
const deviceStatus: any = response.body
|
|
675
|
+
const deviceStatus = await this.pushChangeRequest(bodyChange)
|
|
678
676
|
this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
679
677
|
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
680
678
|
this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
package/src/device/device.ts
CHANGED
|
@@ -367,17 +367,17 @@ export abstract class deviceBase {
|
|
|
367
367
|
}
|
|
368
368
|
}
|
|
369
369
|
|
|
370
|
-
async pushChangeRequest(bodyChange: bodyChange): Promise<{ body:
|
|
370
|
+
async pushChangeRequest<T extends pushResponse['body']>(bodyChange: bodyChange): Promise<{ body: T, statusCode: pushResponse['statusCode'] }> {
|
|
371
371
|
const { response, statusCode } = await this.platform.retryCommand(this.device, bodyChange, this.deviceMaxRetries, this.deviceDelayBetweenRetries)
|
|
372
372
|
return { body: response, statusCode }
|
|
373
373
|
}
|
|
374
374
|
|
|
375
|
-
async deviceRefreshStatus(): Promise<{ body:
|
|
375
|
+
async deviceRefreshStatus<T extends deviceStatus>(): Promise<{ body: T, statusCode: deviceStatusRequest['statusCode'] }> {
|
|
376
376
|
const { response, statusCode } = await this.platform.retryRequest(this.device, this.deviceMaxRetries, this.deviceDelayBetweenRetries)
|
|
377
377
|
return { body: response, statusCode }
|
|
378
378
|
}
|
|
379
379
|
|
|
380
|
-
async successfulStatusCodes(deviceStatus:
|
|
380
|
+
async successfulStatusCodes<T extends { statusCode: number }>(deviceStatus: T) {
|
|
381
381
|
return (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)
|
|
382
382
|
}
|
|
383
383
|
|
package/src/device/fan.ts
CHANGED
|
@@ -380,8 +380,7 @@ export class Fan extends deviceBase {
|
|
|
380
380
|
async openAPIRefreshStatus(): Promise<void> {
|
|
381
381
|
this.debugLog('openAPIRefreshStatus')
|
|
382
382
|
try {
|
|
383
|
-
const
|
|
384
|
-
const deviceStatus: any = response.body
|
|
383
|
+
const deviceStatus = await this.deviceRefreshStatus<batteryCirculatorFanStatus>()
|
|
385
384
|
this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
386
385
|
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
387
386
|
this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
@@ -516,8 +515,7 @@ export class Fan extends deviceBase {
|
|
|
516
515
|
}
|
|
517
516
|
this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
|
|
518
517
|
try {
|
|
519
|
-
const
|
|
520
|
-
const deviceStatus: any = response.body
|
|
518
|
+
const deviceStatus = await this.pushChangeRequest(bodyChange)
|
|
521
519
|
this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
522
520
|
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
523
521
|
this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
@@ -544,8 +542,7 @@ export class Fan extends deviceBase {
|
|
|
544
542
|
}
|
|
545
543
|
this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
|
|
546
544
|
try {
|
|
547
|
-
const
|
|
548
|
-
const deviceStatus: any = response.body
|
|
545
|
+
const deviceStatus = await this.pushChangeRequest(bodyChange)
|
|
549
546
|
this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
550
547
|
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
551
548
|
this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
@@ -573,8 +570,7 @@ export class Fan extends deviceBase {
|
|
|
573
570
|
}
|
|
574
571
|
this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
|
|
575
572
|
try {
|
|
576
|
-
const
|
|
577
|
-
const deviceStatus: any = response.body
|
|
573
|
+
const deviceStatus = await this.pushChangeRequest(bodyChange)
|
|
578
574
|
this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
579
575
|
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
580
576
|
this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
package/src/device/hub.ts
CHANGED
|
@@ -347,8 +347,7 @@ export class Hub extends deviceBase {
|
|
|
347
347
|
async openAPIRefreshStatus(): Promise<void> {
|
|
348
348
|
this.debugLog('openAPIRefreshStatus')
|
|
349
349
|
try {
|
|
350
|
-
const
|
|
351
|
-
const deviceStatus: any = response.body
|
|
350
|
+
const deviceStatus = await this.deviceRefreshStatus<hub2Status>()
|
|
352
351
|
this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
353
352
|
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
354
353
|
this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
package/src/device/humidifier.ts
CHANGED
|
@@ -377,8 +377,7 @@ export class Humidifier extends deviceBase {
|
|
|
377
377
|
async openAPIRefreshStatus(): Promise<void> {
|
|
378
378
|
this.debugLog('openAPIRefreshStatus')
|
|
379
379
|
try {
|
|
380
|
-
const
|
|
381
|
-
const deviceStatus: any = response.body
|
|
380
|
+
const deviceStatus = await this.deviceRefreshStatus<humidifierStatus | humidifier2Status>()
|
|
382
381
|
this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
383
382
|
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
384
383
|
this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
@@ -487,8 +486,7 @@ export class Humidifier extends deviceBase {
|
|
|
487
486
|
}
|
|
488
487
|
this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
|
|
489
488
|
try {
|
|
490
|
-
const
|
|
491
|
-
const deviceStatus: any = response.body
|
|
489
|
+
const deviceStatus = await this.pushChangeRequest(bodyChange)
|
|
492
490
|
this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
493
491
|
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
494
492
|
this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
@@ -521,8 +519,7 @@ export class Humidifier extends deviceBase {
|
|
|
521
519
|
}
|
|
522
520
|
this.debugLog(`pushAutoChanges, SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
|
|
523
521
|
try {
|
|
524
|
-
const
|
|
525
|
-
const deviceStatus: any = response.body
|
|
522
|
+
const deviceStatus = await this.pushChangeRequest(bodyChange)
|
|
526
523
|
this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
527
524
|
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
528
525
|
this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
@@ -553,8 +550,7 @@ export class Humidifier extends deviceBase {
|
|
|
553
550
|
}
|
|
554
551
|
this.debugLog(`pushActiveChanges, SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
|
|
555
552
|
try {
|
|
556
|
-
const
|
|
557
|
-
const deviceStatus: any = response.body
|
|
553
|
+
const deviceStatus = await this.pushChangeRequest(bodyChange)
|
|
558
554
|
this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
559
555
|
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
560
556
|
this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
package/src/device/iosensor.ts
CHANGED
|
@@ -341,8 +341,7 @@ export class IOSensor extends deviceBase {
|
|
|
341
341
|
async openAPIRefreshStatus(): Promise<void> {
|
|
342
342
|
this.debugLog('openAPIRefreshStatus')
|
|
343
343
|
try {
|
|
344
|
-
const
|
|
345
|
-
const deviceStatus: any = response.body
|
|
344
|
+
const deviceStatus = await this.deviceRefreshStatus<outdoorMeterStatus>()
|
|
346
345
|
this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
347
346
|
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
348
347
|
this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
package/src/device/lightstrip.ts
CHANGED
|
@@ -379,8 +379,7 @@ export class StripLight extends deviceBase {
|
|
|
379
379
|
async openAPIRefreshStatus(): Promise<void> {
|
|
380
380
|
this.debugLog('openAPIRefreshStatus')
|
|
381
381
|
try {
|
|
382
|
-
const
|
|
383
|
-
const deviceStatus: any = response.body
|
|
382
|
+
const deviceStatus = await this.deviceRefreshStatus<stripLightStatus>()
|
|
384
383
|
this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
385
384
|
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
386
385
|
this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
@@ -608,8 +607,7 @@ export class StripLight extends deviceBase {
|
|
|
608
607
|
}
|
|
609
608
|
this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
|
|
610
609
|
try {
|
|
611
|
-
const
|
|
612
|
-
const deviceStatus: any = response.body
|
|
610
|
+
const deviceStatus = await this.pushChangeRequest(bodyChange)
|
|
613
611
|
this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
614
612
|
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
615
613
|
this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
@@ -639,8 +637,7 @@ export class StripLight extends deviceBase {
|
|
|
639
637
|
}
|
|
640
638
|
this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
|
|
641
639
|
try {
|
|
642
|
-
const
|
|
643
|
-
const deviceStatus: any = response.body
|
|
640
|
+
const deviceStatus = await this.pushChangeRequest(bodyChange)
|
|
644
641
|
this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
645
642
|
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
646
643
|
this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
@@ -667,8 +664,7 @@ export class StripLight extends deviceBase {
|
|
|
667
664
|
}
|
|
668
665
|
this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
|
|
669
666
|
try {
|
|
670
|
-
const
|
|
671
|
-
const deviceStatus: any = response.body
|
|
667
|
+
const deviceStatus = await this.pushChangeRequest(bodyChange)
|
|
672
668
|
this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
673
669
|
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
674
670
|
this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
package/src/device/lock.ts
CHANGED
|
@@ -383,8 +383,7 @@ export class Lock extends deviceBase {
|
|
|
383
383
|
async openAPIRefreshStatus(): Promise<void> {
|
|
384
384
|
this.debugLog('openAPIRefreshStatus')
|
|
385
385
|
try {
|
|
386
|
-
const
|
|
387
|
-
const deviceStatus: any = response.body
|
|
386
|
+
const deviceStatus = await this.deviceRefreshStatus<lockStatus | lockProStatus>()
|
|
388
387
|
this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
389
388
|
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
390
389
|
this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
@@ -504,8 +503,7 @@ export class Lock extends deviceBase {
|
|
|
504
503
|
}
|
|
505
504
|
this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
|
|
506
505
|
try {
|
|
507
|
-
const
|
|
508
|
-
const deviceStatus: any = response.body
|
|
506
|
+
const deviceStatus = await this.pushChangeRequest(bodyChange)
|
|
509
507
|
this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
510
508
|
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
511
509
|
this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
package/src/device/meter.ts
CHANGED
|
@@ -338,8 +338,7 @@ export class Meter extends deviceBase {
|
|
|
338
338
|
async openAPIRefreshStatus(): Promise<void> {
|
|
339
339
|
this.debugLog('openAPIRefreshStatus')
|
|
340
340
|
try {
|
|
341
|
-
const
|
|
342
|
-
const deviceStatus: any = response.body
|
|
341
|
+
const deviceStatus = await this.deviceRefreshStatus<meterStatus>()
|
|
343
342
|
this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
344
343
|
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
345
344
|
this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
package/src/device/meterplus.ts
CHANGED
|
@@ -342,8 +342,7 @@ export class MeterPlus extends deviceBase {
|
|
|
342
342
|
async openAPIRefreshStatus(): Promise<void> {
|
|
343
343
|
this.debugLog('openAPIRefreshStatus')
|
|
344
344
|
try {
|
|
345
|
-
const
|
|
346
|
-
const deviceStatus: any = response.body
|
|
345
|
+
const deviceStatus = await this.deviceRefreshStatus<meterPlusStatus>()
|
|
347
346
|
this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
348
347
|
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
349
348
|
this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
package/src/device/meterpro.ts
CHANGED
|
@@ -282,7 +282,7 @@ export class MeterPro extends deviceBase {
|
|
|
282
282
|
|
|
283
283
|
// Battery Info
|
|
284
284
|
if ('battery' in this.deviceStatus) {
|
|
285
|
-
|
|
285
|
+
// BatteryLevel
|
|
286
286
|
this.Battery.BatteryLevel = this.deviceStatus.battery
|
|
287
287
|
this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
|
|
288
288
|
|
|
@@ -420,8 +420,7 @@ export class MeterPro extends deviceBase {
|
|
|
420
420
|
async openAPIRefreshStatus(): Promise<void> {
|
|
421
421
|
this.debugLog('openAPIRefreshStatus')
|
|
422
422
|
try {
|
|
423
|
-
const
|
|
424
|
-
const deviceStatus: any = response.body
|
|
423
|
+
const deviceStatus = await this.deviceRefreshStatus<meterProStatus>()
|
|
425
424
|
this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
426
425
|
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
427
426
|
this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
package/src/device/motion.ts
CHANGED
|
@@ -313,8 +313,7 @@ export class Motion extends deviceBase {
|
|
|
313
313
|
async openAPIRefreshStatus(): Promise<void> {
|
|
314
314
|
this.debugLog('openAPIRefreshStatus')
|
|
315
315
|
try {
|
|
316
|
-
const
|
|
317
|
-
const deviceStatus: any = response.body
|
|
316
|
+
const deviceStatus = await this.deviceRefreshStatus<motionSensorStatus>()
|
|
318
317
|
this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
319
318
|
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
320
319
|
this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
package/src/device/plug.ts
CHANGED
|
@@ -238,8 +238,7 @@ export class Plug extends deviceBase {
|
|
|
238
238
|
async openAPIRefreshStatus(): Promise<void> {
|
|
239
239
|
this.debugLog('openAPIRefreshStatus')
|
|
240
240
|
try {
|
|
241
|
-
const
|
|
242
|
-
const deviceStatus: any = response.body
|
|
241
|
+
const deviceStatus = await this.deviceRefreshStatus<plugStatus | plugMiniStatus>()
|
|
243
242
|
this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
244
243
|
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
245
244
|
this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
@@ -365,8 +364,7 @@ export class Plug extends deviceBase {
|
|
|
365
364
|
}
|
|
366
365
|
this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
|
|
367
366
|
try {
|
|
368
|
-
const
|
|
369
|
-
const deviceStatus: any = response.body
|
|
367
|
+
const deviceStatus = await this.pushChangeRequest(bodyChange)
|
|
370
368
|
this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
371
369
|
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
372
370
|
this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
@@ -366,8 +366,7 @@ export class RelaySwitch extends deviceBase {
|
|
|
366
366
|
async openAPIRefreshStatus(): Promise<void> {
|
|
367
367
|
this.debugLog('openAPIRefreshStatus')
|
|
368
368
|
try {
|
|
369
|
-
const
|
|
370
|
-
const deviceStatus: any = response.body
|
|
369
|
+
const deviceStatus = await this.deviceRefreshStatus<relaySwitch1Status | relaySwitch1PMStatus>()
|
|
371
370
|
this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
372
371
|
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
373
372
|
this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
@@ -488,8 +487,7 @@ export class RelaySwitch extends deviceBase {
|
|
|
488
487
|
}
|
|
489
488
|
this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
|
|
490
489
|
try {
|
|
491
|
-
const
|
|
492
|
-
const deviceStatus: any = response.body
|
|
490
|
+
const deviceStatus = await this.pushChangeRequest(bodyChange)
|
|
493
491
|
this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
494
492
|
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
495
493
|
this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
@@ -326,8 +326,7 @@ export class RobotVacuumCleaner extends deviceBase {
|
|
|
326
326
|
async openAPIRefreshStatus(): Promise<void> {
|
|
327
327
|
this.debugLog('openAPIRefreshStatus')
|
|
328
328
|
try {
|
|
329
|
-
const
|
|
330
|
-
const deviceStatus: any = response.body
|
|
329
|
+
const deviceStatus = await this.deviceRefreshStatus<robotVacuumCleanerS1Status | robotVacuumCleanerS1PlusStatus | floorCleaningRobotS10Status>()
|
|
331
330
|
this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
332
331
|
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
333
332
|
this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
@@ -449,8 +448,7 @@ export class RobotVacuumCleaner extends deviceBase {
|
|
|
449
448
|
}
|
|
450
449
|
this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
|
|
451
450
|
try {
|
|
452
|
-
const
|
|
453
|
-
const deviceStatus: any = response.body
|
|
451
|
+
const deviceStatus = await this.pushChangeRequest(bodyChange)
|
|
454
452
|
this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
455
453
|
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
456
454
|
this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
@@ -485,8 +483,7 @@ export class RobotVacuumCleaner extends deviceBase {
|
|
|
485
483
|
}
|
|
486
484
|
this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
|
|
487
485
|
try {
|
|
488
|
-
const
|
|
489
|
-
const deviceStatus: any = response.body
|
|
486
|
+
const deviceStatus = await this.pushChangeRequest(bodyChange)
|
|
490
487
|
this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
491
488
|
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
492
489
|
this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
@@ -320,8 +320,7 @@ export class WaterDetector extends deviceBase {
|
|
|
320
320
|
async openAPIRefreshStatus(): Promise<void> {
|
|
321
321
|
this.debugLog('openAPIRefreshStatus')
|
|
322
322
|
try {
|
|
323
|
-
const
|
|
324
|
-
const deviceStatus: any = response.body
|
|
323
|
+
const deviceStatus = await this.deviceRefreshStatus<waterLeakDetectorStatus>()
|
|
325
324
|
this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
326
325
|
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
327
326
|
this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
@@ -316,8 +316,7 @@ export class AirConditioner extends irdeviceBase {
|
|
|
316
316
|
if (this.device.connectionType === 'OpenAPI' && !this.deviceDisablePushDetail) {
|
|
317
317
|
this.infoLog(`Sending request to SwitchBot API, body: ${JSON.stringify(bodyChange)}`)
|
|
318
318
|
try {
|
|
319
|
-
const
|
|
320
|
-
const deviceStatus: any = response.body
|
|
319
|
+
const deviceStatus = await this.pushChangeRequest(bodyChange)
|
|
321
320
|
await this.pushStatusCodes(deviceStatus)
|
|
322
321
|
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
323
322
|
await this.successfulPushChange(deviceStatus, bodyChange)
|
|
@@ -213,8 +213,7 @@ export class AirPurifier extends irdeviceBase {
|
|
|
213
213
|
if (this.device.connectionType === 'OpenAPI') {
|
|
214
214
|
this.infoLog(`Sending request to SwitchBot API, body: ${JSON.stringify(bodyChange)}`)
|
|
215
215
|
try {
|
|
216
|
-
const
|
|
217
|
-
const deviceStatus: any = response.body
|
|
216
|
+
const deviceStatus = await this.pushChangeRequest(bodyChange)
|
|
218
217
|
await this.pushStatusCodes(deviceStatus)
|
|
219
218
|
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
220
219
|
await this.successfulPushChange(deviceStatus, bodyChange)
|
package/src/irdevice/camera.ts
CHANGED
|
@@ -100,8 +100,7 @@ export class Camera extends irdeviceBase {
|
|
|
100
100
|
if (this.device.connectionType === 'OpenAPI') {
|
|
101
101
|
this.infoLog(`Sending request to SwitchBot API, body: ${JSON.stringify(bodyChange)}`)
|
|
102
102
|
try {
|
|
103
|
-
const
|
|
104
|
-
const deviceStatus: any = response.body
|
|
103
|
+
const deviceStatus = await this.pushChangeRequest(bodyChange)
|
|
105
104
|
await this.pushStatusCodes(deviceStatus)
|
|
106
105
|
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
107
106
|
await this.successfulPushChange(deviceStatus, bodyChange)
|
package/src/irdevice/fan.ts
CHANGED
|
@@ -191,8 +191,7 @@ export class IRFan extends irdeviceBase {
|
|
|
191
191
|
if (this.device.connectionType === 'OpenAPI') {
|
|
192
192
|
this.infoLog(`Sending request to SwitchBot API, body: ${JSON.stringify(bodyChange)}`)
|
|
193
193
|
try {
|
|
194
|
-
const
|
|
195
|
-
const deviceStatus: any = response.body
|
|
194
|
+
const deviceStatus = await this.pushChangeRequest(bodyChange)
|
|
196
195
|
await this.pushStatusCodes(deviceStatus)
|
|
197
196
|
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
198
197
|
await this.successfulPushChange(deviceStatus, bodyChange)
|
package/src/irdevice/irdevice.ts
CHANGED
|
@@ -198,12 +198,12 @@ export abstract class irdeviceBase {
|
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
200
|
|
|
201
|
-
async pushStatusCodes(deviceStatus:
|
|
201
|
+
async pushStatusCodes<T extends { statusCode: number }>(deviceStatus: T) {
|
|
202
202
|
this.debugWarnLog(`deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
203
203
|
this.debugWarnLog(`deviceStatus statusCode: ${deviceStatus.statusCode}`)
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
-
async successfulPushChange(deviceStatus:
|
|
206
|
+
async successfulPushChange<T extends { statusCode: number }>(deviceStatus: T, bodyChange: any) {
|
|
207
207
|
this.debugSuccessLog(`deviceStatus StatusCode: ${deviceStatus.statusCode}`)
|
|
208
208
|
this.successLog(`request to SwitchBot API, body: ${JSON.stringify(bodyChange)} sent successfully`)
|
|
209
209
|
}
|
package/src/irdevice/light.ts
CHANGED
|
@@ -198,8 +198,7 @@ export class Light extends irdeviceBase {
|
|
|
198
198
|
if (this.device.connectionType === 'OpenAPI') {
|
|
199
199
|
this.infoLog(`Sending request to SwitchBot API, body: ${JSON.stringify(bodyChange)}`)
|
|
200
200
|
try {
|
|
201
|
-
const
|
|
202
|
-
const deviceStatus: any = response.body
|
|
201
|
+
const deviceStatus = await this.pushChangeRequest(bodyChange)
|
|
203
202
|
await this.pushStatusCodes(deviceStatus)
|
|
204
203
|
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
205
204
|
await this.successfulPushChange(deviceStatus, bodyChange)
|
package/src/irdevice/other.ts
CHANGED
|
@@ -447,8 +447,7 @@ export class Others extends irdeviceBase {
|
|
|
447
447
|
if (this.device.connectionType === 'OpenAPI') {
|
|
448
448
|
this.infoLog(`Sending request to SwitchBot API, body: ${JSON.stringify(bodyChange)}`)
|
|
449
449
|
try {
|
|
450
|
-
const
|
|
451
|
-
const deviceStatus: any = response.body
|
|
450
|
+
const deviceStatus = await this.pushChangeRequest(bodyChange)
|
|
452
451
|
await this.pushStatusCodes(deviceStatus)
|
|
453
452
|
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
454
453
|
await this.successfulPushChange(deviceStatus, bodyChange)
|
package/src/irdevice/tv.ts
CHANGED
|
@@ -346,8 +346,7 @@ export class TV extends irdeviceBase {
|
|
|
346
346
|
if (this.device.connectionType === 'OpenAPI') {
|
|
347
347
|
this.infoLog(`Sending request to SwitchBot API, body: ${JSON.stringify(bodyChange)}`)
|
|
348
348
|
try {
|
|
349
|
-
const
|
|
350
|
-
const deviceStatus: any = response.body
|
|
349
|
+
const deviceStatus = await this.pushChangeRequest(bodyChange)
|
|
351
350
|
await this.pushStatusCodes(deviceStatus)
|
|
352
351
|
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
353
352
|
await this.successfulPushChange(deviceStatus, bodyChange)
|
|
@@ -97,8 +97,7 @@ export class VacuumCleaner extends irdeviceBase {
|
|
|
97
97
|
if (this.device.connectionType === 'OpenAPI') {
|
|
98
98
|
this.infoLog(`Sending request to SwitchBot API, body: ${JSON.stringify(bodyChange)}`)
|
|
99
99
|
try {
|
|
100
|
-
const
|
|
101
|
-
const deviceStatus: any = response.body
|
|
100
|
+
const deviceStatus = await this.pushChangeRequest(bodyChange)
|
|
102
101
|
await this.pushStatusCodes(deviceStatus)
|
|
103
102
|
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
104
103
|
await this.successfulPushChange(deviceStatus, bodyChange)
|
|
@@ -98,8 +98,7 @@ export class WaterHeater extends irdeviceBase {
|
|
|
98
98
|
if (this.device.connectionType === 'OpenAPI') {
|
|
99
99
|
this.infoLog(`Sending request to SwitchBot API, body: ${JSON.stringify(bodyChange)}`)
|
|
100
100
|
try {
|
|
101
|
-
const
|
|
102
|
-
const deviceStatus: any = response.body
|
|
101
|
+
const deviceStatus = await this.pushChangeRequest(bodyChange)
|
|
103
102
|
await this.pushStatusCodes(deviceStatus)
|
|
104
103
|
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
105
104
|
await this.successfulPushChange(deviceStatus, bodyChange)
|