@switchbot/homebridge-switchbot 3.8.3-beta.3 → 3.8.3-beta.30
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 +7 -4
- package/.github/workflows/release.yml +7 -6
- 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 +32 -34
- 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 +6 -14
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +105 -170
- 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/docs/assets/highlight.css +42 -0
- package/docs/assets/main.js +1 -1
- package/docs/functions/default.html +1 -1
- package/docs/index.html +61 -50
- package/docs/media/security-privacy-bluetooth.png +0 -0
- package/package.json +13 -14
- 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 +33 -38
- 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 +110 -171
- package/src/settings.ts +5 -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
|
@@ -3,13 +3,10 @@
|
|
|
3
3
|
* ceilinglight.ts: @switchbot/homebridge-switchbot.
|
|
4
4
|
*/
|
|
5
5
|
import type { CharacteristicValue, Controller, ControllerConstructor, ControllerServiceMap, PlatformAccessory, Service } from 'homebridge'
|
|
6
|
+
import type { bodyChange, ceilingLightProServiceData, ceilingLightProStatus, ceilingLightProWebhookContext, ceilingLightServiceData, ceilingLightStatus, ceilingLightWebhookContext, 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 { ceilingLightProServiceData, ceilingLightServiceData } from '../types/bledevicestatus.js'
|
|
10
|
-
import type { device } from '../types/devicelist.js'
|
|
11
|
-
import type { ceilingLightProStatus, ceilingLightStatus } from '../types/devicestatus.js'
|
|
12
|
-
import type { ceilingLightProWebhookContext, ceilingLightWebhookContext } from '../types/devicewebhookstatus.js'
|
|
13
10
|
|
|
14
11
|
/*
|
|
15
12
|
* For Testing Locally:
|
|
@@ -335,17 +332,17 @@ export class CeilingLight extends deviceBase {
|
|
|
335
332
|
async openAPIRefreshStatus(): Promise<void> {
|
|
336
333
|
await this.debugLog('openAPIRefreshStatus')
|
|
337
334
|
try {
|
|
338
|
-
const { body
|
|
339
|
-
const deviceStatus: any = await body
|
|
340
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
341
|
-
if (await this.successfulStatusCodes(
|
|
342
|
-
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)}`)
|
|
343
340
|
this.deviceStatus = deviceStatus.body
|
|
344
341
|
await this.openAPIparseStatus()
|
|
345
342
|
await this.updateHomeKitCharacteristics()
|
|
346
343
|
} else {
|
|
347
|
-
await this.debugWarnLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
348
|
-
await this.debugWarnLog(
|
|
344
|
+
await this.debugWarnLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
345
|
+
await this.debugWarnLog(deviceStatus)
|
|
349
346
|
}
|
|
350
347
|
} catch (e: any) {
|
|
351
348
|
await this.apiError(e)
|
|
@@ -466,21 +463,20 @@ export class CeilingLight extends deviceBase {
|
|
|
466
463
|
await this.debugLog('openAPIpushChanges')
|
|
467
464
|
if (this.LightBulb.On !== this.accessory.context.On) {
|
|
468
465
|
const command = this.LightBulb.On ? 'turnOn' : 'turnOff'
|
|
469
|
-
const bodyChange =
|
|
466
|
+
const bodyChange: bodyChange = {
|
|
470
467
|
command: `${command}`,
|
|
471
468
|
parameter: 'default',
|
|
472
469
|
commandType: 'command',
|
|
473
|
-
}
|
|
470
|
+
}
|
|
474
471
|
await this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
|
|
475
472
|
try {
|
|
476
|
-
const { body
|
|
477
|
-
const deviceStatus: any = await body
|
|
478
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
479
|
-
if (await this.successfulStatusCodes(
|
|
480
|
-
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)}`)
|
|
481
478
|
await this.updateHomeKitCharacteristics()
|
|
482
479
|
} else {
|
|
483
|
-
await this.statusCode(statusCode)
|
|
484
480
|
await this.statusCode(deviceStatus.statusCode)
|
|
485
481
|
}
|
|
486
482
|
} catch (e: any) {
|
|
@@ -499,21 +495,20 @@ export class CeilingLight extends deviceBase {
|
|
|
499
495
|
await this.debugLog(`Saturation: ${JSON.stringify(this.LightBulb.Saturation)}`)
|
|
500
496
|
const [red, green, blue] = hs2rgb(Number(this.LightBulb.Hue), Number(this.LightBulb.Saturation))
|
|
501
497
|
await this.debugLog(`rgb: ${JSON.stringify([red, green, blue])}`)
|
|
502
|
-
const bodyChange =
|
|
498
|
+
const bodyChange: bodyChange = {
|
|
503
499
|
command: 'setColor',
|
|
504
500
|
parameter: `${red}:${green}:${blue}`,
|
|
505
501
|
commandType: 'command',
|
|
506
|
-
}
|
|
502
|
+
}
|
|
507
503
|
await this.debugLog(`(pushHueSaturationChanges) SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
|
|
508
504
|
try {
|
|
509
|
-
const { body
|
|
510
|
-
const deviceStatus: any = await body
|
|
511
|
-
await this.debugLog(`(pushHueSaturationChanges) statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
512
|
-
if (await this.successfulStatusCodes(
|
|
513
|
-
await this.debugSuccessLog(`(pushHueSaturationChanges) statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
505
|
+
const { body } = await this.pushChangeRequest(bodyChange)
|
|
506
|
+
const deviceStatus: any = await body
|
|
507
|
+
await this.debugLog(`(pushHueSaturationChanges) statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
508
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
509
|
+
await this.debugSuccessLog(`(pushHueSaturationChanges) statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
514
510
|
await this.updateHomeKitCharacteristics()
|
|
515
511
|
} else {
|
|
516
|
-
await this.statusCode(statusCode)
|
|
517
512
|
await this.statusCode(deviceStatus.statusCode)
|
|
518
513
|
}
|
|
519
514
|
} catch (e: any) {
|
|
@@ -530,21 +525,20 @@ export class CeilingLight extends deviceBase {
|
|
|
530
525
|
if (this.LightBulb.ColorTemperature !== this.accessory.context.ColorTemperature) {
|
|
531
526
|
const kelvin = Math.round(1000000 * Number(this.LightBulb.ColorTemperature))
|
|
532
527
|
this.accessory.context.kelvin = kelvin
|
|
533
|
-
const bodyChange =
|
|
528
|
+
const bodyChange: bodyChange = {
|
|
534
529
|
command: 'setColorTemperature',
|
|
535
530
|
parameter: `${kelvin}`,
|
|
536
531
|
commandType: 'command',
|
|
537
|
-
}
|
|
532
|
+
}
|
|
538
533
|
await this.debugLog(`(pushColorTemperatureChanges) SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
|
|
539
534
|
try {
|
|
540
|
-
const { body
|
|
541
|
-
const deviceStatus: any = await body
|
|
542
|
-
await this.debugLog(`(pushColorTemperatureChanges) statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
543
|
-
if (await this.successfulStatusCodes(
|
|
544
|
-
await this.debugSuccessLog(`(pushColorTemperatureChanges) statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
535
|
+
const { body } = await this.pushChangeRequest(bodyChange)
|
|
536
|
+
const deviceStatus: any = await body
|
|
537
|
+
await this.debugLog(`(pushColorTemperatureChanges) statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
538
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
539
|
+
await this.debugSuccessLog(`(pushColorTemperatureChanges) statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
545
540
|
await this.updateHomeKitCharacteristics()
|
|
546
541
|
} else {
|
|
547
|
-
await this.statusCode(statusCode)
|
|
548
542
|
await this.statusCode(deviceStatus.statusCode)
|
|
549
543
|
}
|
|
550
544
|
} catch (e: any) {
|
|
@@ -559,21 +553,20 @@ export class CeilingLight extends deviceBase {
|
|
|
559
553
|
async pushBrightnessChanges(): Promise<void> {
|
|
560
554
|
await this.debugLog('pushBrightnessChanges')
|
|
561
555
|
if (this.LightBulb.Brightness !== this.accessory.context.Brightness) {
|
|
562
|
-
const bodyChange =
|
|
556
|
+
const bodyChange: bodyChange = {
|
|
563
557
|
command: 'setBrightness',
|
|
564
558
|
parameter: `${this.LightBulb.Brightness}`,
|
|
565
559
|
commandType: 'command',
|
|
566
|
-
}
|
|
560
|
+
}
|
|
567
561
|
await this.debugLog(`(pushBrightnessChanges) SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
|
|
568
562
|
try {
|
|
569
|
-
const { body
|
|
570
|
-
const deviceStatus: any = await body
|
|
571
|
-
await this.debugLog(`(pushBrightnessChanges) statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
572
|
-
if (await this.successfulStatusCodes(
|
|
573
|
-
await this.debugSuccessLog(`(pushBrightnessChanges) statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
563
|
+
const { body } = await this.pushChangeRequest(bodyChange)
|
|
564
|
+
const deviceStatus: any = await body
|
|
565
|
+
await this.debugLog(`(pushBrightnessChanges) statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
566
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
567
|
+
await this.debugSuccessLog(`(pushBrightnessChanges) statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
574
568
|
await this.updateHomeKitCharacteristics()
|
|
575
569
|
} else {
|
|
576
|
-
await this.statusCode(statusCode)
|
|
577
570
|
await this.statusCode(deviceStatus.statusCode)
|
|
578
571
|
}
|
|
579
572
|
} catch (e: any) {
|
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
|
/**
|