@switchbot/homebridge-switchbot 3.8.3-beta.2 → 3.8.3-beta.21
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/.github/workflows/beta-release.yml +2 -1
- package/CHANGELOG.md +8 -0
- package/dist/device/blindtilt.d.ts +1 -4
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +18 -19
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts +1 -4
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +15 -16
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts +1 -4
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +35 -39
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts +1 -4
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +35 -39
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +1 -4
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +7 -7
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +1 -4
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +16 -17
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/device.d.ts +6 -6
- package/dist/device/device.d.ts.map +1 -1
- package/dist/device/device.js +30 -14
- package/dist/device/device.js.map +1 -1
- package/dist/device/fan.d.ts +1 -4
- package/dist/device/fan.d.ts.map +1 -1
- package/dist/device/fan.js +28 -31
- package/dist/device/fan.js.map +1 -1
- package/dist/device/hub.d.ts +1 -4
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +7 -7
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts +1 -4
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +28 -31
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts +1 -4
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +7 -7
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts +1 -4
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +28 -31
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts +1 -4
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +15 -16
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +1 -4
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +7 -7
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +1 -4
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +7 -7
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts +1 -4
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +7 -7
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts +1 -4
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +14 -15
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts +1 -4
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +21 -23
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/device/waterdetector.d.ts +1 -4
- package/dist/device/waterdetector.d.ts.map +1 -1
- package/dist/device/waterdetector.js +7 -7
- package/dist/device/waterdetector.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts +1 -1
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +11 -12
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +1 -1
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +11 -12
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts +1 -1
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +9 -10
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +1 -1
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +15 -16
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/irdevice.d.ts +6 -6
- package/dist/irdevice/irdevice.d.ts.map +1 -1
- package/dist/irdevice/irdevice.js +7 -13
- package/dist/irdevice/irdevice.js.map +1 -1
- package/dist/irdevice/light.d.ts +1 -1
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +9 -10
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts +1 -1
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +9 -10
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts +1 -1
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +27 -28
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +9 -10
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts +1 -1
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +9 -10
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts +5 -14
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +53 -161
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +1 -3
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js.map +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js.map +1 -1
- package/package.json +9 -10
- package/src/device/blindtilt.ts +20 -24
- package/src/device/bot.ts +16 -20
- package/src/device/ceilinglight.ts +36 -43
- package/src/device/colorbulb.ts +36 -43
- package/src/device/contact.ts +8 -11
- package/src/device/curtain.ts +18 -22
- package/src/device/device.ts +29 -18
- package/src/device/fan.ts +29 -35
- package/src/device/hub.ts +8 -11
- package/src/device/humidifier.ts +29 -35
- package/src/device/iosensor.ts +8 -11
- package/src/device/lightstrip.ts +29 -35
- package/src/device/lock.ts +16 -20
- package/src/device/meter.ts +8 -11
- package/src/device/meterplus.ts +8 -11
- package/src/device/motion.ts +8 -11
- package/src/device/plug.ts +15 -19
- package/src/device/robotvacuumcleaner.ts +22 -31
- package/src/device/waterdetector.ts +8 -11
- package/src/irdevice/airconditioner.ts +12 -14
- package/src/irdevice/airpurifier.ts +12 -13
- package/src/irdevice/camera.ts +10 -11
- package/src/irdevice/fan.ts +16 -17
- package/src/irdevice/irdevice.ts +9 -17
- package/src/irdevice/light.ts +10 -11
- package/src/irdevice/other.ts +10 -11
- package/src/irdevice/tv.ts +28 -29
- package/src/irdevice/vacuumcleaner.ts +10 -11
- package/src/irdevice/waterheater.ts +10 -11
- package/src/platform.ts +55 -161
- package/src/settings.ts +1 -4
- package/src/utils.ts +2 -1
- package/dist/types/bledevicestatus.d.ts +0 -281
- package/dist/types/bledevicestatus.d.ts.map +0 -1
- package/dist/types/bledevicestatus.js +0 -2
- package/dist/types/bledevicestatus.js.map +0 -1
- package/dist/types/devicelist.d.ts +0 -89
- package/dist/types/devicelist.d.ts.map +0 -1
- package/dist/types/devicelist.js +0 -6
- package/dist/types/devicelist.js.map +0 -1
- package/dist/types/deviceresponse.d.ts +0 -13
- package/dist/types/deviceresponse.d.ts.map +0 -1
- package/dist/types/deviceresponse.js +0 -2
- package/dist/types/deviceresponse.js.map +0 -1
- package/dist/types/devicestatus.d.ts +0 -149
- package/dist/types/devicestatus.d.ts.map +0 -1
- package/dist/types/devicestatus.js +0 -3
- package/dist/types/devicestatus.js.map +0 -1
- package/dist/types/devicewebhookstatus.d.ts +0 -156
- package/dist/types/devicewebhookstatus.d.ts.map +0 -1
- package/dist/types/devicewebhookstatus.js +0 -2
- package/dist/types/devicewebhookstatus.js.map +0 -1
- package/dist/types/irdevicelist.d.ts +0 -10
- package/dist/types/irdevicelist.d.ts.map +0 -1
- package/dist/types/irdevicelist.js +0 -2
- package/dist/types/irdevicelist.js.map +0 -1
- package/dist/types/pushbody.d.ts +0 -6
- package/dist/types/pushbody.d.ts.map +0 -1
- package/dist/types/pushbody.js +0 -2
- package/dist/types/pushbody.js.map +0 -1
- package/src/types/bledevicestatus.ts +0 -303
- package/src/types/devicelist.ts +0 -124
- package/src/types/deviceresponse.ts +0 -14
- package/src/types/devicestatus.ts +0 -178
- package/src/types/devicewebhookstatus.ts +0 -191
- package/src/types/irdevicelist.ts +0 -15
- package/src/types/pushbody.ts +0 -9
package/src/device/colorbulb.ts
CHANGED
|
@@ -3,13 +3,10 @@
|
|
|
3
3
|
* blindtilt.ts: @switchbot/homebridge-switchbot.
|
|
4
4
|
*/
|
|
5
5
|
import type { CharacteristicValue, Controller, ControllerConstructor, ControllerServiceMap, PlatformAccessory, Service } from 'homebridge'
|
|
6
|
+
import type { bodyChange, colorBulbServiceData, colorBulbStatus, colorBulbWebhookContext, device } from 'node-switchbot'
|
|
6
7
|
|
|
7
8
|
import type { SwitchBotPlatform } from '../platform.js'
|
|
8
9
|
import type { devicesConfig } from '../settings.js'
|
|
9
|
-
import type { colorBulbServiceData } from '../types/bledevicestatus.js'
|
|
10
|
-
import type { device } from '../types/devicelist.js'
|
|
11
|
-
import type { colorBulbStatus } from '../types/devicestatus.js'
|
|
12
|
-
import type { colorBulbWebhookContext } from '../types/devicewebhookstatus.js'
|
|
13
10
|
|
|
14
11
|
/*
|
|
15
12
|
* For Testing Locally:
|
|
@@ -358,17 +355,17 @@ export class ColorBulb extends deviceBase {
|
|
|
358
355
|
async openAPIRefreshStatus(): Promise<void> {
|
|
359
356
|
await this.debugLog('openAPIRefreshStatus')
|
|
360
357
|
try {
|
|
361
|
-
const { body
|
|
362
|
-
const deviceStatus: any = await body
|
|
363
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
364
|
-
if (await this.successfulStatusCodes(
|
|
365
|
-
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)}`)
|
|
366
363
|
this.deviceStatus = deviceStatus.body
|
|
367
364
|
await this.openAPIparseStatus()
|
|
368
365
|
await this.updateHomeKitCharacteristics()
|
|
369
366
|
} else {
|
|
370
|
-
await this.debugWarnLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
371
|
-
await this.debugWarnLog(
|
|
367
|
+
await this.debugWarnLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
368
|
+
await this.debugWarnLog(deviceStatus)
|
|
372
369
|
}
|
|
373
370
|
} catch (e: any) {
|
|
374
371
|
await this.apiError(e)
|
|
@@ -614,21 +611,20 @@ export class ColorBulb extends deviceBase {
|
|
|
614
611
|
await this.debugLog('openAPIpushChanges')
|
|
615
612
|
if (this.LightBulb.On !== this.accessory.context.On) {
|
|
616
613
|
const command = this.LightBulb.On ? 'turnOn' : 'turnOff'
|
|
617
|
-
const bodyChange =
|
|
614
|
+
const bodyChange: bodyChange = {
|
|
618
615
|
command: `${command}`,
|
|
619
616
|
parameter: 'default',
|
|
620
617
|
commandType: 'command',
|
|
621
|
-
}
|
|
618
|
+
}
|
|
622
619
|
await this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
|
|
623
620
|
try {
|
|
624
|
-
const { body
|
|
625
|
-
const deviceStatus: any = await body
|
|
626
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
627
|
-
if (await this.successfulStatusCodes(
|
|
628
|
-
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)}`)
|
|
629
626
|
await this.updateHomeKitCharacteristics()
|
|
630
627
|
} else {
|
|
631
|
-
await this.statusCode(statusCode)
|
|
632
628
|
await this.statusCode(deviceStatus.statusCode)
|
|
633
629
|
}
|
|
634
630
|
} catch (e: any) {
|
|
@@ -646,21 +642,20 @@ export class ColorBulb extends deviceBase {
|
|
|
646
642
|
await this.debugLog(`Hue: ${JSON.stringify(this.LightBulb.Hue)}, Saturation: ${JSON.stringify(this.LightBulb.Saturation)}`)
|
|
647
643
|
const [red, green, blue] = hs2rgb(this.LightBulb.Hue, this.LightBulb.Saturation)
|
|
648
644
|
await this.debugLog(`rgb: ${JSON.stringify([red, green, blue])}`)
|
|
649
|
-
const bodyChange =
|
|
645
|
+
const bodyChange: bodyChange = {
|
|
650
646
|
command: 'setColor',
|
|
651
647
|
parameter: `${red}:${green}:${blue}`,
|
|
652
648
|
commandType: 'command',
|
|
653
|
-
}
|
|
649
|
+
}
|
|
654
650
|
await this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
|
|
655
651
|
try {
|
|
656
|
-
const { body
|
|
657
|
-
const deviceStatus: any = await body
|
|
658
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
659
|
-
if (await this.successfulStatusCodes(
|
|
660
|
-
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)}`)
|
|
661
657
|
await this.updateHomeKitCharacteristics()
|
|
662
658
|
} else {
|
|
663
|
-
await this.statusCode(statusCode)
|
|
664
659
|
await this.statusCode(deviceStatus.statusCode)
|
|
665
660
|
}
|
|
666
661
|
} catch (e: any) {
|
|
@@ -677,21 +672,20 @@ export class ColorBulb extends deviceBase {
|
|
|
677
672
|
if (this.LightBulb.ColorTemperature !== this.accessory.context.ColorTemperature) {
|
|
678
673
|
const kelvin = Math.round(1000000 / Number(this.LightBulb.ColorTemperature))
|
|
679
674
|
this.accessory.context.kelvin = kelvin
|
|
680
|
-
const bodyChange =
|
|
675
|
+
const bodyChange: bodyChange = {
|
|
681
676
|
command: 'setColorTemperature',
|
|
682
677
|
parameter: `${kelvin}`,
|
|
683
678
|
commandType: 'command',
|
|
684
|
-
}
|
|
679
|
+
}
|
|
685
680
|
await this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
|
|
686
681
|
try {
|
|
687
|
-
const { body
|
|
688
|
-
const deviceStatus: any = await body
|
|
689
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
690
|
-
if (await this.successfulStatusCodes(
|
|
691
|
-
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)}`)
|
|
692
687
|
await this.updateHomeKitCharacteristics()
|
|
693
688
|
} else {
|
|
694
|
-
await this.statusCode(statusCode)
|
|
695
689
|
await this.statusCode(deviceStatus.statusCode)
|
|
696
690
|
}
|
|
697
691
|
} catch (e: any) {
|
|
@@ -706,21 +700,20 @@ export class ColorBulb extends deviceBase {
|
|
|
706
700
|
async pushBrightnessChanges(): Promise<void> {
|
|
707
701
|
await this.debugLog('pushBrightnessChanges')
|
|
708
702
|
if (this.LightBulb.Brightness !== this.accessory.context.Brightness) {
|
|
709
|
-
const bodyChange =
|
|
703
|
+
const bodyChange: bodyChange = {
|
|
710
704
|
command: 'setBrightness',
|
|
711
705
|
parameter: `${this.LightBulb.Brightness}`,
|
|
712
706
|
commandType: 'command',
|
|
713
|
-
}
|
|
707
|
+
}
|
|
714
708
|
await this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
|
|
715
709
|
try {
|
|
716
|
-
const { body
|
|
717
|
-
const deviceStatus: any = await body
|
|
718
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
719
|
-
if (await this.successfulStatusCodes(
|
|
720
|
-
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)}`)
|
|
721
715
|
await this.updateHomeKitCharacteristics()
|
|
722
716
|
} else {
|
|
723
|
-
await this.statusCode(statusCode)
|
|
724
717
|
await this.statusCode(deviceStatus.statusCode)
|
|
725
718
|
}
|
|
726
719
|
} catch (e: any) {
|
package/src/device/contact.ts
CHANGED
|
@@ -3,13 +3,10 @@
|
|
|
3
3
|
* contact.ts: @switchbot/homebridge-switchbot.
|
|
4
4
|
*/
|
|
5
5
|
import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge'
|
|
6
|
+
import type { contactSensorServiceData, contactSensorStatus, contactSensorWebhookContext, device } from 'node-switchbot'
|
|
6
7
|
|
|
7
8
|
import type { SwitchBotPlatform } from '../platform.js'
|
|
8
9
|
import type { devicesConfig } from '../settings.js'
|
|
9
|
-
import type { contactSensorServiceData } from '../types/bledevicestatus.js'
|
|
10
|
-
import type { device } from '../types/devicelist.js'
|
|
11
|
-
import type { contactSensorStatus } from '../types/devicestatus.js'
|
|
12
|
-
import type { contactSensorWebhookContext } from '../types/devicewebhookstatus.js'
|
|
13
10
|
|
|
14
11
|
/*
|
|
15
12
|
* For Testing Locally:
|
|
@@ -348,17 +345,17 @@ export class Contact extends deviceBase {
|
|
|
348
345
|
async openAPIRefreshStatus(): Promise<void> {
|
|
349
346
|
await this.debugLog('openAPIRefreshStatus')
|
|
350
347
|
try {
|
|
351
|
-
const { body
|
|
352
|
-
const deviceStatus: any = await body
|
|
353
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
354
|
-
if (await this.successfulStatusCodes(
|
|
355
|
-
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)}`)
|
|
356
353
|
this.deviceStatus = deviceStatus.body
|
|
357
354
|
await this.openAPIparseStatus()
|
|
358
355
|
await this.updateHomeKitCharacteristics()
|
|
359
356
|
} else {
|
|
360
|
-
await this.debugWarnLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
361
|
-
await this.debugWarnLog(
|
|
357
|
+
await this.debugWarnLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
358
|
+
await this.debugWarnLog(deviceStatus)
|
|
362
359
|
}
|
|
363
360
|
} catch (e: any) {
|
|
364
361
|
await this.apiError(e)
|
package/src/device/curtain.ts
CHANGED
|
@@ -3,13 +3,10 @@
|
|
|
3
3
|
* curtain.ts: @switchbot/homebridge-switchbot.
|
|
4
4
|
*/
|
|
5
5
|
import type { CharacteristicChange, CharacteristicValue, PlatformAccessory, Service } from 'homebridge'
|
|
6
|
+
import type { bodyChange, curtain3ServiceData, curtain3WebhookContext, curtainServiceData, curtainStatus, curtainWebhookContext, device } from 'node-switchbot'
|
|
6
7
|
|
|
7
8
|
import type { SwitchBotPlatform } from '../platform.js'
|
|
8
9
|
import type { devicesConfig } from '../settings.js'
|
|
9
|
-
import type { curtain3ServiceData, curtainServiceData } from '../types/bledevicestatus.js'
|
|
10
|
-
import type { device } from '../types/devicelist.js'
|
|
11
|
-
import type { curtainStatus } from '../types/devicestatus.js'
|
|
12
|
-
import type { curtain3WebhookContext, curtainWebhookContext } from '../types/devicewebhookstatus.js'
|
|
13
10
|
|
|
14
11
|
import { hostname } from 'node:os'
|
|
15
12
|
|
|
@@ -505,17 +502,17 @@ export class Curtain extends deviceBase {
|
|
|
505
502
|
async openAPIRefreshStatus(): Promise<void> {
|
|
506
503
|
await this.debugLog('openAPIRefreshStatus')
|
|
507
504
|
try {
|
|
508
|
-
const { body
|
|
509
|
-
const deviceStatus: any = await body
|
|
510
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
511
|
-
if (await this.successfulStatusCodes(
|
|
512
|
-
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)}`)
|
|
513
510
|
this.deviceStatus = deviceStatus.body
|
|
514
511
|
await this.openAPIparseStatus()
|
|
515
512
|
await this.updateHomeKitCharacteristics()
|
|
516
513
|
} else {
|
|
517
|
-
await this.debugWarnLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
518
|
-
await this.debugWarnLog(
|
|
514
|
+
await this.debugWarnLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
515
|
+
await this.debugWarnLog(deviceStatus)
|
|
519
516
|
}
|
|
520
517
|
} catch (e: any) {
|
|
521
518
|
await this.apiError(e)
|
|
@@ -641,30 +638,29 @@ export class Curtain extends deviceBase {
|
|
|
641
638
|
const { setPositionMode, Mode }: { setPositionMode: number, Mode: string } = await this.setPerformance()
|
|
642
639
|
await this.debugLog(`Mode: ${Mode}, setPositionMode: ${setPositionMode}`)
|
|
643
640
|
const adjustedMode = setPositionMode || 'ff'
|
|
644
|
-
let bodyChange:
|
|
641
|
+
let bodyChange: bodyChange
|
|
645
642
|
if (this.WindowCovering.HoldPosition) {
|
|
646
|
-
bodyChange =
|
|
643
|
+
bodyChange = {
|
|
647
644
|
command: 'pause',
|
|
648
645
|
parameter: 'default',
|
|
649
646
|
commandType: 'command',
|
|
650
|
-
}
|
|
647
|
+
}
|
|
651
648
|
} else {
|
|
652
|
-
bodyChange =
|
|
649
|
+
bodyChange = {
|
|
653
650
|
command: 'setPosition',
|
|
654
651
|
parameter: `0,${adjustedMode},${adjustedTargetPosition}`,
|
|
655
652
|
commandType: 'command',
|
|
656
|
-
}
|
|
653
|
+
}
|
|
657
654
|
}
|
|
658
655
|
await this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
|
|
659
656
|
try {
|
|
660
|
-
const { body
|
|
661
|
-
const deviceStatus: any = await body
|
|
662
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
663
|
-
if (await this.successfulStatusCodes(
|
|
664
|
-
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)}`)
|
|
665
662
|
await this.updateHomeKitCharacteristics()
|
|
666
663
|
} else {
|
|
667
|
-
await this.statusCode(statusCode)
|
|
668
664
|
await this.statusCode(deviceStatus.statusCode)
|
|
669
665
|
}
|
|
670
666
|
} catch (e: any) {
|
package/src/device/device.ts
CHANGED
|
@@ -5,18 +5,15 @@
|
|
|
5
5
|
|
|
6
6
|
import type { API, CharacteristicValue, HAP, Logging, PlatformAccessory, Service } from 'homebridge'
|
|
7
7
|
import type { MqttClient } from 'mqtt'
|
|
8
|
+
import type { ad, bodyChange, device } from 'node-switchbot'
|
|
8
9
|
|
|
9
10
|
import type { SwitchBotPlatform } from '../platform.js'
|
|
10
11
|
import type { devicesConfig, SwitchBotPlatformConfig } from '../settings.js'
|
|
11
|
-
import type { ad } from '../types/bledevicestatus.js'
|
|
12
|
-
import type { device } from '../types/devicelist.js'
|
|
13
12
|
|
|
14
13
|
import { hostname } from 'node:os'
|
|
15
14
|
|
|
16
15
|
import { SwitchBotBLEModel, SwitchBotBLEModelFriendlyName, SwitchBotBLEModelName, SwitchBotModel } from 'node-switchbot'
|
|
17
|
-
import { request } from 'undici'
|
|
18
16
|
|
|
19
|
-
import { Devices } from '../settings.js'
|
|
20
17
|
import { BlindTiltMappingMode, formatDeviceIdAsMac, sleep } from '../utils.js'
|
|
21
18
|
|
|
22
19
|
export abstract class deviceBase {
|
|
@@ -293,7 +290,11 @@ export abstract class deviceBase {
|
|
|
293
290
|
|
|
294
291
|
async monitorAdvertisementPackets(switchbot: any) {
|
|
295
292
|
await this.debugLog(`Scanning for ${this.device.bleModelName} devices...`)
|
|
296
|
-
|
|
293
|
+
try {
|
|
294
|
+
await switchbot.startScan({ model: this.device.bleModel, id: this.device.bleMac })
|
|
295
|
+
} catch (e: any) {
|
|
296
|
+
await this.errorLog(`Failed to start BLE scanning. Error:${e}`)
|
|
297
|
+
}
|
|
297
298
|
// Set an event handler
|
|
298
299
|
let serviceData = { model: this.device.bleModel, modelName: this.device.bleModelName } as ad['serviceData']
|
|
299
300
|
switchbot.onadvertisement = async (ad: ad) => {
|
|
@@ -310,7 +311,11 @@ export abstract class deviceBase {
|
|
|
310
311
|
// Wait
|
|
311
312
|
await switchbot.wait(this.scanDuration * 1000)
|
|
312
313
|
// Stop to monitor
|
|
313
|
-
|
|
314
|
+
try {
|
|
315
|
+
await switchbot.stopScan()
|
|
316
|
+
} catch (e: any) {
|
|
317
|
+
await this.errorLog(`Failed to stop BLE scanning. Error:${e}`)
|
|
318
|
+
}
|
|
314
319
|
return serviceData
|
|
315
320
|
}
|
|
316
321
|
|
|
@@ -319,32 +324,38 @@ export abstract class deviceBase {
|
|
|
319
324
|
this.debugLog(`customBLEaddress: ${this.device.customBLEaddress}`);
|
|
320
325
|
(async () => {
|
|
321
326
|
// Start to monitor advertisement packets
|
|
322
|
-
|
|
327
|
+
try {
|
|
328
|
+
await switchbot.startScan({ model: this.device.bleModel })
|
|
329
|
+
} catch (e: any) {
|
|
330
|
+
await this.errorLog(`Failed to start BLE scanning. Error:${e}`)
|
|
331
|
+
}
|
|
323
332
|
// Set an event handler
|
|
324
333
|
switchbot.onadvertisement = async (ad: ad) => {
|
|
325
334
|
this.warnLog(`ad: ${JSON.stringify(ad, null, ' ')}`)
|
|
326
335
|
}
|
|
327
336
|
await sleep(10000)
|
|
328
337
|
// Stop to monitor
|
|
329
|
-
|
|
338
|
+
try {
|
|
339
|
+
switchbot.stopScan()
|
|
340
|
+
} catch (e: any) {
|
|
341
|
+
await this.errorLog(`Failed to stop BLE scanning. Error:${e}`)
|
|
342
|
+
}
|
|
330
343
|
})()
|
|
331
344
|
}
|
|
332
345
|
}
|
|
333
346
|
|
|
334
|
-
async pushChangeRequest(bodyChange:
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
method: 'POST',
|
|
338
|
-
headers: this.platform.generateHeaders(),
|
|
339
|
-
})
|
|
347
|
+
async pushChangeRequest(bodyChange: bodyChange): Promise<{ body: any, statusCode: number }> {
|
|
348
|
+
const { response, statusCode } = await this.platform.switchBotAPI.controlDevice(this.device.deviceId, bodyChange.command, bodyChange.parameter, bodyChange.commandType)
|
|
349
|
+
return { body: response, statusCode }
|
|
340
350
|
}
|
|
341
351
|
|
|
342
|
-
async deviceRefreshStatus(): Promise<{ body: any, statusCode:
|
|
343
|
-
|
|
352
|
+
async deviceRefreshStatus(): Promise<{ body: any, statusCode: number }> {
|
|
353
|
+
const { response, statusCode } = await this.platform.retryRequest(this.device.deviceId, this.deviceMaxRetries, this.deviceDelayBetweenRetries)
|
|
354
|
+
return { body: response, statusCode }
|
|
344
355
|
}
|
|
345
356
|
|
|
346
|
-
async successfulStatusCodes(
|
|
347
|
-
return (
|
|
357
|
+
async successfulStatusCodes(deviceStatus: any) {
|
|
358
|
+
return (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)
|
|
348
359
|
}
|
|
349
360
|
|
|
350
361
|
/**
|
package/src/device/fan.ts
CHANGED
|
@@ -3,13 +3,10 @@
|
|
|
3
3
|
* plug.ts: @switchbot/homebridge-switchbot.
|
|
4
4
|
*/
|
|
5
5
|
import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge'
|
|
6
|
+
import type { batteryCirculatorFanServiceData, batteryCirculatorFanStatus, batteryCirculatorFanWebhookContext, bodyChange, device } from 'node-switchbot'
|
|
6
7
|
|
|
7
8
|
import type { SwitchBotPlatform } from '../platform.js'
|
|
8
9
|
import type { devicesConfig } from '../settings.js'
|
|
9
|
-
import type { batteryCirculatorFanServiceData } from '../types/bledevicestatus.js'
|
|
10
|
-
import type { device } from '../types/devicelist.js'
|
|
11
|
-
import type { batteryCirculatorFanStatus } from '../types/devicestatus.js'
|
|
12
|
-
import type { batteryCirculatorFanWebhookContext } from '../types/devicewebhookstatus.js'
|
|
13
10
|
|
|
14
11
|
/*
|
|
15
12
|
* For Testing Locally:
|
|
@@ -372,17 +369,17 @@ export class Fan extends deviceBase {
|
|
|
372
369
|
async openAPIRefreshStatus(): Promise<void> {
|
|
373
370
|
await this.debugLog('openAPIRefreshStatus')
|
|
374
371
|
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)}`)
|
|
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)}`)
|
|
380
377
|
this.deviceStatus = deviceStatus.body
|
|
381
378
|
await this.openAPIparseStatus()
|
|
382
379
|
await this.updateHomeKitCharacteristics()
|
|
383
380
|
} else {
|
|
384
|
-
await this.debugWarnLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
385
|
-
await this.debugWarnLog(
|
|
381
|
+
await this.debugWarnLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
382
|
+
await this.debugWarnLog(deviceStatus)
|
|
386
383
|
}
|
|
387
384
|
} catch (e: any) {
|
|
388
385
|
await this.apiError(e)
|
|
@@ -498,21 +495,20 @@ export class Fan extends deviceBase {
|
|
|
498
495
|
await this.debugLog('openAPIpushChanges')
|
|
499
496
|
if (this.Fan.Active !== this.accessory.context.Active) {
|
|
500
497
|
const command = this.Fan.Active ? 'turnOn' : 'turnOff'
|
|
501
|
-
const bodyChange =
|
|
498
|
+
const bodyChange: bodyChange = {
|
|
502
499
|
command: `${command}`,
|
|
503
500
|
parameter: 'default',
|
|
504
501
|
commandType: 'command',
|
|
505
|
-
}
|
|
502
|
+
}
|
|
506
503
|
await this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
|
|
507
504
|
try {
|
|
508
|
-
const { body
|
|
509
|
-
const deviceStatus: any = await body
|
|
510
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
511
|
-
if (await this.successfulStatusCodes(
|
|
512
|
-
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)}`)
|
|
513
510
|
await this.updateHomeKitCharacteristics()
|
|
514
511
|
} else {
|
|
515
|
-
await this.statusCode(statusCode)
|
|
516
512
|
await this.statusCode(deviceStatus.statusCode)
|
|
517
513
|
}
|
|
518
514
|
} catch (e: any) {
|
|
@@ -527,21 +523,20 @@ export class Fan extends deviceBase {
|
|
|
527
523
|
async pushRotationSpeedChanges(): Promise<void> {
|
|
528
524
|
await this.debugLog('pushRotationSpeedChanges')
|
|
529
525
|
if (this.Fan.SwingMode !== this.accessory.context.SwingMode) {
|
|
530
|
-
const bodyChange =
|
|
526
|
+
const bodyChange: bodyChange = {
|
|
531
527
|
command: 'setWindSpeed',
|
|
532
528
|
parameter: `${this.Fan.RotationSpeed}`,
|
|
533
529
|
commandType: 'command',
|
|
534
|
-
}
|
|
530
|
+
}
|
|
535
531
|
await this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
|
|
536
532
|
try {
|
|
537
|
-
const { body
|
|
538
|
-
const deviceStatus: any = await body
|
|
539
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
540
|
-
if (await this.successfulStatusCodes(
|
|
541
|
-
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)}`)
|
|
542
538
|
await this.updateHomeKitCharacteristics()
|
|
543
539
|
} else {
|
|
544
|
-
await this.statusCode(statusCode)
|
|
545
540
|
await this.statusCode(deviceStatus.statusCode)
|
|
546
541
|
}
|
|
547
542
|
} catch (e: any) {
|
|
@@ -557,21 +552,20 @@ export class Fan extends deviceBase {
|
|
|
557
552
|
await this.debugLog('pushSwingModeChanges')
|
|
558
553
|
if (this.Fan.SwingMode !== this.accessory.context.SwingMode) {
|
|
559
554
|
const parameter = this.Fan.SwingMode === this.hap.Characteristic.SwingMode.SWING_ENABLED ? 'on' : 'off'
|
|
560
|
-
const bodyChange =
|
|
555
|
+
const bodyChange: bodyChange = {
|
|
561
556
|
command: 'setOscillation',
|
|
562
557
|
parameter: `${parameter}`,
|
|
563
558
|
commandType: 'command',
|
|
564
|
-
}
|
|
559
|
+
}
|
|
565
560
|
await this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
|
|
566
561
|
try {
|
|
567
|
-
const { body
|
|
568
|
-
const deviceStatus: any = await body
|
|
569
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
570
|
-
if (await this.successfulStatusCodes(
|
|
571
|
-
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)}`)
|
|
572
567
|
await this.updateHomeKitCharacteristics()
|
|
573
568
|
} else {
|
|
574
|
-
await this.statusCode(statusCode)
|
|
575
569
|
await this.statusCode(deviceStatus.statusCode)
|
|
576
570
|
}
|
|
577
571
|
} catch (e: any) {
|
package/src/device/hub.ts
CHANGED
|
@@ -3,13 +3,10 @@
|
|
|
3
3
|
* hub.ts: @switchbot/homebridge-switchbot.
|
|
4
4
|
*/
|
|
5
5
|
import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge'
|
|
6
|
+
import type { device, hub2ServiceData, hub2Status, hub2WebhookContext } from 'node-switchbot'
|
|
6
7
|
|
|
7
8
|
import type { SwitchBotPlatform } from '../platform.js'
|
|
8
9
|
import type { devicesConfig } from '../settings.js'
|
|
9
|
-
import type { hub2ServiceData } from '../types/bledevicestatus.js'
|
|
10
|
-
import type { device } from '../types/devicelist.js'
|
|
11
|
-
import type { hub2Status } from '../types/devicestatus.js'
|
|
12
|
-
import type { hub2WebhookContext } from '../types/devicewebhookstatus.js'
|
|
13
10
|
|
|
14
11
|
import { Units } from 'homebridge'
|
|
15
12
|
/*
|
|
@@ -340,17 +337,17 @@ export class Hub extends deviceBase {
|
|
|
340
337
|
async openAPIRefreshStatus(): Promise<void> {
|
|
341
338
|
await this.debugLog('openAPIRefreshStatus')
|
|
342
339
|
try {
|
|
343
|
-
const { body
|
|
344
|
-
const deviceStatus: any = await body
|
|
345
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
346
|
-
if (await this.successfulStatusCodes(
|
|
347
|
-
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)}`)
|
|
348
345
|
this.deviceStatus = deviceStatus.body
|
|
349
346
|
await this.openAPIparseStatus()
|
|
350
347
|
await this.updateHomeKitCharacteristics()
|
|
351
348
|
} else {
|
|
352
|
-
await this.debugWarnLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
353
|
-
await this.debugWarnLog(
|
|
349
|
+
await this.debugWarnLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
350
|
+
await this.debugWarnLog(deviceStatus)
|
|
354
351
|
}
|
|
355
352
|
} catch (e: any) {
|
|
356
353
|
await this.apiError(e)
|