@switchbot/homebridge-switchbot 3.8.3-beta.15 → 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 +18 -25
- 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 +19 -25
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)
|
package/src/device/lightstrip.ts
CHANGED
|
@@ -359,17 +359,17 @@ export class StripLight extends deviceBase {
|
|
|
359
359
|
async openAPIRefreshStatus(): Promise<void> {
|
|
360
360
|
await this.debugLog('openAPIRefreshStatus')
|
|
361
361
|
try {
|
|
362
|
-
const { body
|
|
363
|
-
const deviceStatus: any = await body
|
|
364
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
365
|
-
if (await this.successfulStatusCodes(
|
|
366
|
-
await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
362
|
+
const { body } = await this.deviceRefreshStatus()
|
|
363
|
+
const deviceStatus: any = await body
|
|
364
|
+
await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
365
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
366
|
+
await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
367
367
|
this.deviceStatus = deviceStatus.body
|
|
368
368
|
await this.openAPIparseStatus()
|
|
369
369
|
await this.updateHomeKitCharacteristics()
|
|
370
370
|
} else {
|
|
371
|
-
await this.debugWarnLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
372
|
-
await this.debugWarnLog(
|
|
371
|
+
await this.debugWarnLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
372
|
+
await this.debugWarnLog(deviceStatus)
|
|
373
373
|
}
|
|
374
374
|
} catch (e: any) {
|
|
375
375
|
await this.apiError(e)
|
|
@@ -584,14 +584,13 @@ export class StripLight extends deviceBase {
|
|
|
584
584
|
}
|
|
585
585
|
await this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
|
|
586
586
|
try {
|
|
587
|
-
const { body
|
|
588
|
-
const deviceStatus: any = await body
|
|
589
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
590
|
-
if (await this.successfulStatusCodes(
|
|
591
|
-
await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
587
|
+
const { body } = await this.pushChangeRequest(bodyChange)
|
|
588
|
+
const deviceStatus: any = await body
|
|
589
|
+
await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
590
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
591
|
+
await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
592
592
|
await this.updateHomeKitCharacteristics()
|
|
593
593
|
} else {
|
|
594
|
-
await this.statusCode(statusCode)
|
|
595
594
|
await this.statusCode(deviceStatus.statusCode)
|
|
596
595
|
}
|
|
597
596
|
} catch (e: any) {
|
|
@@ -616,14 +615,13 @@ export class StripLight extends deviceBase {
|
|
|
616
615
|
}
|
|
617
616
|
await this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
|
|
618
617
|
try {
|
|
619
|
-
const { body
|
|
620
|
-
const deviceStatus: any = await body
|
|
621
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
622
|
-
if (await this.successfulStatusCodes(
|
|
623
|
-
await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
618
|
+
const { body } = await this.pushChangeRequest(bodyChange)
|
|
619
|
+
const deviceStatus: any = await body
|
|
620
|
+
await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
621
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
622
|
+
await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
624
623
|
await this.updateHomeKitCharacteristics()
|
|
625
624
|
} else {
|
|
626
|
-
await this.statusCode(statusCode)
|
|
627
625
|
await this.statusCode(deviceStatus.statusCode)
|
|
628
626
|
}
|
|
629
627
|
} catch (e: any) {
|
|
@@ -645,14 +643,13 @@ export class StripLight extends deviceBase {
|
|
|
645
643
|
}
|
|
646
644
|
await this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
|
|
647
645
|
try {
|
|
648
|
-
const { body
|
|
649
|
-
const deviceStatus: any = await body
|
|
650
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
651
|
-
if (await this.successfulStatusCodes(
|
|
652
|
-
await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
646
|
+
const { body } = await this.pushChangeRequest(bodyChange)
|
|
647
|
+
const deviceStatus: any = await body
|
|
648
|
+
await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
649
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
650
|
+
await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
653
651
|
await this.updateHomeKitCharacteristics()
|
|
654
652
|
} else {
|
|
655
|
-
await this.statusCode(statusCode)
|
|
656
653
|
await this.statusCode(deviceStatus.statusCode)
|
|
657
654
|
}
|
|
658
655
|
} catch (e: any) {
|
package/src/device/lock.ts
CHANGED
|
@@ -372,17 +372,17 @@ export class Lock extends deviceBase {
|
|
|
372
372
|
async openAPIRefreshStatus(): Promise<void> {
|
|
373
373
|
await this.debugLog('openAPIRefreshStatus')
|
|
374
374
|
try {
|
|
375
|
-
const { body
|
|
376
|
-
const deviceStatus: any = await body
|
|
377
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
378
|
-
if (await this.successfulStatusCodes(
|
|
379
|
-
await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
375
|
+
const { body } = await this.deviceRefreshStatus()
|
|
376
|
+
const deviceStatus: any = await body
|
|
377
|
+
await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
378
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
379
|
+
await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
380
380
|
this.deviceStatus = deviceStatus.body
|
|
381
381
|
await this.openAPIparseStatus()
|
|
382
382
|
await this.updateHomeKitCharacteristics()
|
|
383
383
|
} else {
|
|
384
|
-
await this.debugWarnLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
385
|
-
await this.debugWarnLog(
|
|
384
|
+
await this.debugWarnLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
385
|
+
await this.debugWarnLog(deviceStatus)
|
|
386
386
|
}
|
|
387
387
|
} catch (e: any) {
|
|
388
388
|
await this.apiError(e)
|
|
@@ -490,14 +490,13 @@ export class Lock extends deviceBase {
|
|
|
490
490
|
}
|
|
491
491
|
await this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
|
|
492
492
|
try {
|
|
493
|
-
const { body
|
|
494
|
-
const deviceStatus: any = await body
|
|
495
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
496
|
-
if (await this.successfulStatusCodes(
|
|
497
|
-
await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
493
|
+
const { body } = await this.pushChangeRequest(bodyChange)
|
|
494
|
+
const deviceStatus: any = await body
|
|
495
|
+
await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
496
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
497
|
+
await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
498
498
|
await this.updateHomeKitCharacteristics()
|
|
499
499
|
} else {
|
|
500
|
-
await this.statusCode(statusCode)
|
|
501
500
|
await this.statusCode(deviceStatus.statusCode)
|
|
502
501
|
}
|
|
503
502
|
} catch (e: any) {
|
package/src/device/meter.ts
CHANGED
|
@@ -327,17 +327,17 @@ export class Meter extends deviceBase {
|
|
|
327
327
|
async openAPIRefreshStatus(): Promise<void> {
|
|
328
328
|
await this.debugLog('openAPIRefreshStatus')
|
|
329
329
|
try {
|
|
330
|
-
const { body
|
|
331
|
-
const deviceStatus: any = await body
|
|
332
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
333
|
-
if (await this.successfulStatusCodes(
|
|
334
|
-
await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
330
|
+
const { body } = await this.deviceRefreshStatus()
|
|
331
|
+
const deviceStatus: any = await body
|
|
332
|
+
await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
333
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
334
|
+
await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
335
335
|
this.deviceStatus = deviceStatus.body
|
|
336
336
|
await this.openAPIparseStatus()
|
|
337
337
|
await this.updateHomeKitCharacteristics()
|
|
338
338
|
} else {
|
|
339
|
-
await this.debugWarnLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
340
|
-
await this.debugWarnLog(
|
|
339
|
+
await this.debugWarnLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
340
|
+
await this.debugWarnLog(deviceStatus)
|
|
341
341
|
}
|
|
342
342
|
} catch (e: any) {
|
|
343
343
|
await this.apiError(e)
|
package/src/device/meterplus.ts
CHANGED
|
@@ -329,17 +329,17 @@ export class MeterPlus extends deviceBase {
|
|
|
329
329
|
async openAPIRefreshStatus(): Promise<void> {
|
|
330
330
|
await this.debugLog('openAPIRefreshStatus')
|
|
331
331
|
try {
|
|
332
|
-
const { body
|
|
333
|
-
const deviceStatus: any = await body
|
|
334
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
335
|
-
if (await this.successfulStatusCodes(
|
|
336
|
-
await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
332
|
+
const { body } = await this.deviceRefreshStatus()
|
|
333
|
+
const deviceStatus: any = await body
|
|
334
|
+
await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
335
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
336
|
+
await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
337
337
|
this.deviceStatus = deviceStatus.body
|
|
338
338
|
await this.openAPIparseStatus()
|
|
339
339
|
await this.updateHomeKitCharacteristics()
|
|
340
340
|
} else {
|
|
341
|
-
await this.debugWarnLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
342
|
-
await this.debugWarnLog(
|
|
341
|
+
await this.debugWarnLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
342
|
+
await this.debugWarnLog(deviceStatus)
|
|
343
343
|
}
|
|
344
344
|
} catch (e: any) {
|
|
345
345
|
await this.apiError(e)
|
package/src/device/motion.ts
CHANGED
|
@@ -304,17 +304,17 @@ export class Motion extends deviceBase {
|
|
|
304
304
|
async openAPIRefreshStatus(): Promise<void> {
|
|
305
305
|
await this.debugLog('openAPIRefreshStatus')
|
|
306
306
|
try {
|
|
307
|
-
const { body
|
|
308
|
-
const deviceStatus: any = await body
|
|
309
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
310
|
-
if (await this.successfulStatusCodes(
|
|
311
|
-
await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
307
|
+
const { body } = await this.deviceRefreshStatus()
|
|
308
|
+
const deviceStatus: any = await body
|
|
309
|
+
await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
310
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
311
|
+
await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
312
312
|
this.deviceStatus = deviceStatus.body
|
|
313
313
|
await this.openAPIparseStatus()
|
|
314
314
|
await this.updateHomeKitCharacteristics()
|
|
315
315
|
} else {
|
|
316
|
-
await this.debugWarnLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
317
|
-
await this.debugWarnLog(
|
|
316
|
+
await this.debugWarnLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
317
|
+
await this.debugWarnLog(deviceStatus)
|
|
318
318
|
}
|
|
319
319
|
} catch (e: any) {
|
|
320
320
|
await this.apiError(e)
|
package/src/device/plug.ts
CHANGED
|
@@ -228,17 +228,17 @@ export class Plug extends deviceBase {
|
|
|
228
228
|
async openAPIRefreshStatus(): Promise<void> {
|
|
229
229
|
await this.debugLog('openAPIRefreshStatus')
|
|
230
230
|
try {
|
|
231
|
-
const { body
|
|
232
|
-
const deviceStatus: any = await body
|
|
233
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
234
|
-
if (await this.successfulStatusCodes(
|
|
235
|
-
await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
231
|
+
const { body } = await this.deviceRefreshStatus()
|
|
232
|
+
const deviceStatus: any = await body
|
|
233
|
+
await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
234
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
235
|
+
await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
236
236
|
this.deviceStatus = deviceStatus.body
|
|
237
237
|
await this.openAPIparseStatus()
|
|
238
238
|
await this.updateHomeKitCharacteristics()
|
|
239
239
|
} else {
|
|
240
|
-
await this.debugWarnLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
241
|
-
await this.debugWarnLog(
|
|
240
|
+
await this.debugWarnLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
241
|
+
await this.debugWarnLog(deviceStatus)
|
|
242
242
|
}
|
|
243
243
|
} catch (e: any) {
|
|
244
244
|
await this.apiError(e)
|
|
@@ -351,14 +351,13 @@ export class Plug extends deviceBase {
|
|
|
351
351
|
}
|
|
352
352
|
await this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
|
|
353
353
|
try {
|
|
354
|
-
const { body
|
|
355
|
-
const deviceStatus: any = await body
|
|
356
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
357
|
-
if (await this.successfulStatusCodes(
|
|
358
|
-
await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
354
|
+
const { body } = await this.pushChangeRequest(bodyChange)
|
|
355
|
+
const deviceStatus: any = await body
|
|
356
|
+
await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
357
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
358
|
+
await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
359
359
|
await this.updateHomeKitCharacteristics()
|
|
360
360
|
} else {
|
|
361
|
-
await this.statusCode(statusCode)
|
|
362
361
|
await this.statusCode(deviceStatus.statusCode)
|
|
363
362
|
}
|
|
364
363
|
} catch (e: any) {
|
|
@@ -314,17 +314,17 @@ export class RobotVacuumCleaner extends deviceBase {
|
|
|
314
314
|
async openAPIRefreshStatus(): Promise<void> {
|
|
315
315
|
await this.debugLog('openAPIRefreshStatus')
|
|
316
316
|
try {
|
|
317
|
-
const { body
|
|
318
|
-
const deviceStatus: any = await body
|
|
319
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
320
|
-
if (await this.successfulStatusCodes(
|
|
321
|
-
await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
317
|
+
const { body } = await this.deviceRefreshStatus()
|
|
318
|
+
const deviceStatus: any = await body
|
|
319
|
+
await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
320
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
321
|
+
await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
322
322
|
this.deviceStatus = deviceStatus.body
|
|
323
323
|
await this.openAPIparseStatus()
|
|
324
324
|
await this.updateHomeKitCharacteristics()
|
|
325
325
|
} else {
|
|
326
|
-
await this.debugWarnLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
327
|
-
await this.debugWarnLog(
|
|
326
|
+
await this.debugWarnLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
327
|
+
await this.debugWarnLog(deviceStatus)
|
|
328
328
|
}
|
|
329
329
|
} catch (e: any) {
|
|
330
330
|
await this.apiError(e)
|
|
@@ -434,14 +434,13 @@ export class RobotVacuumCleaner extends deviceBase {
|
|
|
434
434
|
}
|
|
435
435
|
await this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
|
|
436
436
|
try {
|
|
437
|
-
const { body
|
|
438
|
-
const deviceStatus: any = await body
|
|
439
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
440
|
-
if (await this.successfulStatusCodes(
|
|
441
|
-
await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
437
|
+
const { body } = await this.pushChangeRequest(bodyChange)
|
|
438
|
+
const deviceStatus: any = await body
|
|
439
|
+
await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
440
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
441
|
+
await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
442
442
|
await this.updateHomeKitCharacteristics()
|
|
443
443
|
} else {
|
|
444
|
-
await this.statusCode(statusCode)
|
|
445
444
|
await this.statusCode(deviceStatus.statusCode)
|
|
446
445
|
}
|
|
447
446
|
} catch (e: any) {
|
|
@@ -471,14 +470,13 @@ export class RobotVacuumCleaner extends deviceBase {
|
|
|
471
470
|
}
|
|
472
471
|
await this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
|
|
473
472
|
try {
|
|
474
|
-
const { body
|
|
475
|
-
const deviceStatus: any = await body
|
|
476
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
477
|
-
if (await this.successfulStatusCodes(
|
|
478
|
-
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)}`)
|
|
479
478
|
await this.updateHomeKitCharacteristics()
|
|
480
479
|
} else {
|
|
481
|
-
await this.statusCode(statusCode)
|
|
482
480
|
await this.statusCode(deviceStatus.statusCode)
|
|
483
481
|
}
|
|
484
482
|
} catch (e: any) {
|
|
@@ -318,17 +318,17 @@ export class WaterDetector extends deviceBase {
|
|
|
318
318
|
async openAPIRefreshStatus(): Promise<void> {
|
|
319
319
|
await this.debugLog('openAPIRefreshStatus')
|
|
320
320
|
try {
|
|
321
|
-
const { body
|
|
322
|
-
const deviceStatus: any = await body
|
|
323
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
324
|
-
if (await this.successfulStatusCodes(
|
|
325
|
-
await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
321
|
+
const { body } = await this.deviceRefreshStatus()
|
|
322
|
+
const deviceStatus: any = await body
|
|
323
|
+
await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
324
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
325
|
+
await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
326
326
|
this.deviceStatus = deviceStatus.body
|
|
327
327
|
await this.openAPIparseStatus()
|
|
328
328
|
await this.updateHomeKitCharacteristics()
|
|
329
329
|
} else {
|
|
330
|
-
await this.debugWarnLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
331
|
-
await this.debugWarnLog(
|
|
330
|
+
await this.debugWarnLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
331
|
+
await this.debugWarnLog(deviceStatus)
|
|
332
332
|
}
|
|
333
333
|
} catch (e: any) {
|
|
334
334
|
await this.apiError(e)
|
|
@@ -316,14 +316,13 @@ export class AirConditioner extends irdeviceBase {
|
|
|
316
316
|
if (this.device.connectionType === 'OpenAPI' && !this.disablePushDetail) {
|
|
317
317
|
await this.infoLog(`Sending request to SwitchBot API, body: ${bodyChange},`)
|
|
318
318
|
try {
|
|
319
|
-
const { body
|
|
320
|
-
const deviceStatus: any = await body
|
|
321
|
-
await this.pushStatusCodes(
|
|
322
|
-
if (await this.successfulStatusCodes(
|
|
323
|
-
await this.successfulPushChange(
|
|
319
|
+
const { body } = await this.pushChangeRequest(bodyChange)
|
|
320
|
+
const deviceStatus: any = await body
|
|
321
|
+
await this.pushStatusCodes(deviceStatus)
|
|
322
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
323
|
+
await this.successfulPushChange(deviceStatus, bodyChange)
|
|
324
324
|
await this.updateHomeKitCharacteristics()
|
|
325
325
|
} else {
|
|
326
|
-
await this.statusCode(statusCode)
|
|
327
326
|
await this.statusCode(deviceStatus.statusCode)
|
|
328
327
|
}
|
|
329
328
|
} catch (e: any) {
|
|
@@ -213,14 +213,13 @@ export class AirPurifier extends irdeviceBase {
|
|
|
213
213
|
if (this.device.connectionType === 'OpenAPI') {
|
|
214
214
|
this.infoLog(`Sending request to SwitchBot API, body: ${bodyChange},`)
|
|
215
215
|
try {
|
|
216
|
-
const { body
|
|
217
|
-
const deviceStatus: any = await body
|
|
218
|
-
await this.pushStatusCodes(
|
|
219
|
-
if (await this.successfulStatusCodes(
|
|
220
|
-
await this.successfulPushChange(
|
|
216
|
+
const { body } = await this.pushChangeRequest(bodyChange)
|
|
217
|
+
const deviceStatus: any = await body
|
|
218
|
+
await this.pushStatusCodes(deviceStatus)
|
|
219
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
220
|
+
await this.successfulPushChange(deviceStatus, bodyChange)
|
|
221
221
|
await this.updateHomeKitCharacteristics()
|
|
222
222
|
} else {
|
|
223
|
-
await this.statusCode(statusCode)
|
|
224
223
|
await this.statusCode(deviceStatus.statusCode)
|
|
225
224
|
}
|
|
226
225
|
} catch (e: any) {
|
package/src/irdevice/camera.ts
CHANGED
|
@@ -100,14 +100,13 @@ export class Camera extends irdeviceBase {
|
|
|
100
100
|
if (this.device.connectionType === 'OpenAPI') {
|
|
101
101
|
this.infoLog(`Sending request to SwitchBot API, body: ${bodyChange},`)
|
|
102
102
|
try {
|
|
103
|
-
const { body
|
|
104
|
-
const deviceStatus: any = await body
|
|
105
|
-
await this.pushStatusCodes(
|
|
106
|
-
if (await this.successfulStatusCodes(
|
|
107
|
-
await this.successfulPushChange(
|
|
103
|
+
const { body } = await this.pushChangeRequest(bodyChange)
|
|
104
|
+
const deviceStatus: any = await body
|
|
105
|
+
await this.pushStatusCodes(deviceStatus)
|
|
106
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
107
|
+
await this.successfulPushChange(deviceStatus, bodyChange)
|
|
108
108
|
await this.updateHomeKitCharacteristics()
|
|
109
109
|
} else {
|
|
110
|
-
await this.statusCode(statusCode)
|
|
111
110
|
await this.statusCode(deviceStatus.statusCode)
|
|
112
111
|
}
|
|
113
112
|
} catch (e: any) {
|
package/src/irdevice/fan.ts
CHANGED
|
@@ -191,14 +191,13 @@ export class IRFan extends irdeviceBase {
|
|
|
191
191
|
if (this.device.connectionType === 'OpenAPI') {
|
|
192
192
|
this.infoLog(`Sending request to SwitchBot API, body: ${bodyChange},`)
|
|
193
193
|
try {
|
|
194
|
-
const { body
|
|
195
|
-
const deviceStatus: any = await body
|
|
196
|
-
await this.pushStatusCodes(
|
|
197
|
-
if (await this.successfulStatusCodes(
|
|
198
|
-
await this.successfulPushChange(
|
|
194
|
+
const { body } = await this.pushChangeRequest(bodyChange)
|
|
195
|
+
const deviceStatus: any = await body
|
|
196
|
+
await this.pushStatusCodes(deviceStatus)
|
|
197
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
198
|
+
await this.successfulPushChange(deviceStatus, bodyChange)
|
|
199
199
|
await this.updateHomeKitCharacteristics()
|
|
200
200
|
} else {
|
|
201
|
-
await this.statusCode(statusCode)
|
|
202
201
|
await this.statusCode(deviceStatus.statusCode)
|
|
203
202
|
}
|
|
204
203
|
} catch (e: any) {
|
package/src/irdevice/irdevice.ts
CHANGED
|
@@ -125,12 +125,12 @@ export abstract class irdeviceBase {
|
|
|
125
125
|
this.debugSuccessLog(`version: ${accessory.context.version}`)
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
async pushChangeRequest(bodyChange: bodyChange): Promise<{ body: any
|
|
128
|
+
async pushChangeRequest(bodyChange: bodyChange): Promise<{ body: any }> {
|
|
129
129
|
return this.platform.switchBotAPI.controlDevice(this.device.deviceId, bodyChange.command, bodyChange.parameter, bodyChange.commandType)
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
async successfulStatusCodes(
|
|
133
|
-
return (
|
|
132
|
+
async successfulStatusCodes(deviceStatus: any) {
|
|
133
|
+
return (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
/**
|
|
@@ -155,14 +155,13 @@ export abstract class irdeviceBase {
|
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
-
async pushStatusCodes(
|
|
159
|
-
await this.debugWarnLog(`statusCode: ${statusCode}`)
|
|
158
|
+
async pushStatusCodes(deviceStatus: any) {
|
|
160
159
|
await this.debugWarnLog(`deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
161
160
|
await this.debugWarnLog(`deviceStatus statusCode: ${deviceStatus.statusCode}`)
|
|
162
161
|
}
|
|
163
162
|
|
|
164
|
-
async successfulPushChange(
|
|
165
|
-
this.debugSuccessLog(`
|
|
163
|
+
async successfulPushChange(deviceStatus: any, bodyChange: any) {
|
|
164
|
+
this.debugSuccessLog(`deviceStatus StatusCode: ${deviceStatus.statusCode}`)
|
|
166
165
|
this.successLog(`request to SwitchBot API, body: ${JSON.stringify(JSON.parse(bodyChange))} sent successfully`)
|
|
167
166
|
}
|
|
168
167
|
|
package/src/irdevice/light.ts
CHANGED
|
@@ -198,15 +198,14 @@ export class Light extends irdeviceBase {
|
|
|
198
198
|
if (this.device.connectionType === 'OpenAPI') {
|
|
199
199
|
this.infoLog(`Sending request to SwitchBot API, body: ${bodyChange},`)
|
|
200
200
|
try {
|
|
201
|
-
const { body
|
|
202
|
-
const deviceStatus: any = await body
|
|
203
|
-
await this.pushStatusCodes(
|
|
204
|
-
if (await this.successfulStatusCodes(
|
|
205
|
-
await this.successfulPushChange(
|
|
201
|
+
const { body } = await this.pushChangeRequest(bodyChange)
|
|
202
|
+
const deviceStatus: any = await body
|
|
203
|
+
await this.pushStatusCodes(deviceStatus)
|
|
204
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
205
|
+
await this.successfulPushChange(deviceStatus, bodyChange)
|
|
206
206
|
this.accessory.context.On = On
|
|
207
207
|
await this.updateHomeKitCharacteristics()
|
|
208
208
|
} else {
|
|
209
|
-
await this.statusCode(statusCode)
|
|
210
209
|
await this.statusCode(deviceStatus.statusCode)
|
|
211
210
|
}
|
|
212
211
|
} catch (e: any) {
|
package/src/irdevice/other.ts
CHANGED
|
@@ -447,14 +447,13 @@ export class Others extends irdeviceBase {
|
|
|
447
447
|
if (this.device.connectionType === 'OpenAPI') {
|
|
448
448
|
this.infoLog(`Sending request to SwitchBot API, body: ${bodyChange},`)
|
|
449
449
|
try {
|
|
450
|
-
const { body
|
|
451
|
-
const deviceStatus: any = await body
|
|
452
|
-
await this.pushStatusCodes(
|
|
453
|
-
if (await this.successfulStatusCodes(
|
|
454
|
-
await this.successfulPushChange(
|
|
450
|
+
const { body } = await this.pushChangeRequest(bodyChange)
|
|
451
|
+
const deviceStatus: any = await body
|
|
452
|
+
await this.pushStatusCodes(deviceStatus)
|
|
453
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
454
|
+
await this.successfulPushChange(deviceStatus, bodyChange)
|
|
455
455
|
await this.updateHomeKitCharacteristics()
|
|
456
456
|
} else {
|
|
457
|
-
await this.statusCode(statusCode)
|
|
458
457
|
await this.statusCode(deviceStatus.statusCode)
|
|
459
458
|
}
|
|
460
459
|
} catch (e: any) {
|
package/src/irdevice/tv.ts
CHANGED
|
@@ -346,14 +346,13 @@ export class TV extends irdeviceBase {
|
|
|
346
346
|
if (this.device.connectionType === 'OpenAPI') {
|
|
347
347
|
await this.infoLog(`Sending request to SwitchBot API, body: ${bodyChange},`)
|
|
348
348
|
try {
|
|
349
|
-
const { body
|
|
350
|
-
const deviceStatus: any = await body
|
|
351
|
-
await this.pushStatusCodes(
|
|
352
|
-
if (await this.successfulStatusCodes(
|
|
353
|
-
await this.successfulPushChange(
|
|
349
|
+
const { body } = await this.pushChangeRequest(bodyChange)
|
|
350
|
+
const deviceStatus: any = await body
|
|
351
|
+
await this.pushStatusCodes(deviceStatus)
|
|
352
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
353
|
+
await this.successfulPushChange(deviceStatus, bodyChange)
|
|
354
354
|
await this.updateHomeKitCharacteristics()
|
|
355
355
|
} else {
|
|
356
|
-
await this.statusCode(statusCode)
|
|
357
356
|
await this.statusCode(deviceStatus.statusCode)
|
|
358
357
|
}
|
|
359
358
|
} catch (e: any) {
|
|
@@ -97,14 +97,13 @@ export class VacuumCleaner extends irdeviceBase {
|
|
|
97
97
|
if (this.device.connectionType === 'OpenAPI') {
|
|
98
98
|
await this.infoLog(`Sending request to SwitchBot API, body: ${bodyChange},`)
|
|
99
99
|
try {
|
|
100
|
-
const { body
|
|
101
|
-
const deviceStatus: any = await body
|
|
102
|
-
await this.pushStatusCodes(
|
|
103
|
-
if (await this.successfulStatusCodes(
|
|
104
|
-
await this.successfulPushChange(
|
|
100
|
+
const { body } = await this.pushChangeRequest(bodyChange)
|
|
101
|
+
const deviceStatus: any = await body
|
|
102
|
+
await this.pushStatusCodes(deviceStatus)
|
|
103
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
104
|
+
await this.successfulPushChange(deviceStatus, bodyChange)
|
|
105
105
|
await this.updateHomeKitCharacteristics()
|
|
106
106
|
} else {
|
|
107
|
-
await this.statusCode(statusCode)
|
|
108
107
|
await this.statusCode(deviceStatus.statusCode)
|
|
109
108
|
}
|
|
110
109
|
} catch (e: any) {
|
|
@@ -98,14 +98,13 @@ export class WaterHeater extends irdeviceBase {
|
|
|
98
98
|
if (this.device.connectionType === 'OpenAPI') {
|
|
99
99
|
this.infoLog(`Sending request to SwitchBot API, body: ${bodyChange},`)
|
|
100
100
|
try {
|
|
101
|
-
const { body
|
|
102
|
-
const deviceStatus: any = await body
|
|
103
|
-
await this.pushStatusCodes(
|
|
104
|
-
if (await this.successfulStatusCodes(
|
|
105
|
-
await this.successfulPushChange(
|
|
101
|
+
const { body } = await this.pushChangeRequest(bodyChange)
|
|
102
|
+
const deviceStatus: any = await body
|
|
103
|
+
await this.pushStatusCodes(deviceStatus)
|
|
104
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
105
|
+
await this.successfulPushChange(deviceStatus, bodyChange)
|
|
106
106
|
await this.updateHomeKitCharacteristics()
|
|
107
107
|
} else {
|
|
108
|
-
await this.statusCode(statusCode)
|
|
109
108
|
await this.statusCode(deviceStatus.statusCode)
|
|
110
109
|
}
|
|
111
110
|
} catch (e: any) {
|