node-switchbot 2.5.0-beta.3 → 2.5.0-beta.31
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 +25 -2
- package/.github/workflows/release.yml +13 -0
- package/BLE.md +1109 -0
- package/CHANGELOG.md +14 -0
- package/OpenAPI.md +172 -0
- package/README.md +20 -1189
- package/branding/Node_x_SwitchBot.svg +9 -0
- package/branding/icon.png +0 -0
- package/branding/switchbot.png +0 -0
- package/dist/advertising.d.ts +32 -21
- package/dist/advertising.d.ts.map +1 -1
- package/dist/advertising.js +72 -76
- package/dist/advertising.js.map +1 -1
- package/dist/device/woblindtilt.d.ts +21 -51
- package/dist/device/woblindtilt.d.ts.map +1 -1
- package/dist/device/woblindtilt.js +40 -103
- package/dist/device/woblindtilt.js.map +1 -1
- package/dist/device/wobulb.d.ts +42 -15
- package/dist/device/wobulb.d.ts.map +1 -1
- package/dist/device/wobulb.js +71 -131
- package/dist/device/wobulb.js.map +1 -1
- package/dist/device/woceilinglight.d.ts +47 -21
- package/dist/device/woceilinglight.d.ts.map +1 -1
- package/dist/device/woceilinglight.js +94 -174
- package/dist/device/woceilinglight.js.map +1 -1
- package/dist/device/wocontact.d.ts +12 -1
- package/dist/device/wocontact.d.ts.map +1 -1
- package/dist/device/wocontact.js +23 -22
- package/dist/device/wocontact.js.map +1 -1
- package/dist/device/wocurtain.d.ts +40 -1
- package/dist/device/wocurtain.d.ts.map +1 -1
- package/dist/device/wocurtain.js +68 -106
- package/dist/device/wocurtain.js.map +1 -1
- package/dist/device/wohand.d.ts +38 -2
- package/dist/device/wohand.d.ts.map +1 -1
- package/dist/device/wohand.js +54 -92
- package/dist/device/wohand.js.map +1 -1
- package/dist/device/wohub2.d.ts +12 -1
- package/dist/device/wohub2.d.ts.map +1 -1
- package/dist/device/wohub2.js +21 -29
- package/dist/device/wohub2.js.map +1 -1
- package/dist/device/wohumi.d.ts +38 -2
- package/dist/device/wohumi.d.ts.map +1 -1
- package/dist/device/wohumi.js +51 -86
- package/dist/device/wohumi.js.map +1 -1
- package/dist/device/woiosensorth.d.ts +13 -1
- package/dist/device/woiosensorth.d.ts.map +1 -1
- package/dist/device/woiosensorth.js +25 -29
- package/dist/device/woiosensorth.js.map +1 -1
- package/dist/device/woplugmini.d.ts +44 -12
- package/dist/device/woplugmini.d.ts.map +1 -1
- package/dist/device/woplugmini.js +68 -80
- package/dist/device/woplugmini.js.map +1 -1
- package/dist/device/wopresence.d.ts +12 -1
- package/dist/device/wopresence.d.ts.map +1 -1
- package/dist/device/wopresence.js +21 -27
- package/dist/device/wopresence.js.map +1 -1
- package/dist/device/wosensorth.d.ts +18 -2
- package/dist/device/wosensorth.d.ts.map +1 -1
- package/dist/device/wosensorth.js +33 -50
- package/dist/device/wosensorth.js.map +1 -1
- package/dist/device/wosmartlock.d.ts +58 -13
- package/dist/device/wosmartlock.d.ts.map +1 -1
- package/dist/device/wosmartlock.js +108 -195
- package/dist/device/wosmartlock.js.map +1 -1
- package/dist/device/wosmartlockpro.d.ts +63 -18
- package/dist/device/wosmartlockpro.d.ts.map +1 -1
- package/dist/device/wosmartlockpro.js +116 -204
- package/dist/device/wosmartlockpro.js.map +1 -1
- package/dist/device/wostrip.d.ts +38 -18
- package/dist/device/wostrip.d.ts.map +1 -1
- package/dist/device/wostrip.js +79 -125
- package/dist/device/wostrip.js.map +1 -1
- package/dist/device.d.ts +85 -222
- package/dist/device.d.ts.map +1 -1
- package/dist/device.js +123 -407
- package/dist/device.js.map +1 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/parameter-checker.d.ts +79 -19
- package/dist/parameter-checker.d.ts.map +1 -1
- package/dist/parameter-checker.js +140 -335
- package/dist/parameter-checker.js.map +1 -1
- package/dist/settings.d.ts +46 -0
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +46 -2
- package/dist/settings.js.map +1 -1
- package/dist/{switchbot.d.ts → switchbot-ble.d.ts} +14 -8
- package/dist/switchbot-ble.d.ts.map +1 -0
- package/dist/switchbot-ble.js +428 -0
- package/dist/switchbot-ble.js.map +1 -0
- package/dist/switchbot-openapi.d.ts +131 -0
- package/dist/switchbot-openapi.d.ts.map +1 -0
- package/dist/switchbot-openapi.js +311 -0
- package/dist/switchbot-openapi.js.map +1 -0
- package/dist/test/advertising.test.d.ts +2 -0
- package/dist/test/advertising.test.d.ts.map +1 -0
- package/dist/test/advertising.test.js +96 -0
- package/dist/test/advertising.test.js.map +1 -0
- package/dist/test/device.test.d.ts +2 -0
- package/dist/test/device.test.d.ts.map +1 -0
- package/dist/test/device.test.js +38 -0
- package/dist/test/device.test.js.map +1 -0
- package/dist/test/index.test.d.ts +2 -0
- package/dist/test/index.test.d.ts.map +1 -0
- package/dist/test/index.test.js +35 -0
- package/dist/test/index.test.js.map +1 -0
- package/dist/test/parameter-checker.test.d.ts +2 -0
- package/dist/test/parameter-checker.test.d.ts.map +1 -0
- package/dist/test/parameter-checker.test.js +108 -0
- package/dist/test/parameter-checker.test.js.map +1 -0
- package/dist/test/settings.test.d.ts +2 -0
- package/dist/test/settings.test.d.ts.map +1 -0
- package/dist/test/settings.test.js +49 -0
- package/dist/test/settings.test.js.map +1 -0
- package/dist/test/switchbot-openapi.test.d.ts +2 -0
- package/dist/test/switchbot-openapi.test.d.ts.map +1 -0
- package/dist/test/switchbot-openapi.test.js +96 -0
- package/dist/test/switchbot-openapi.test.js.map +1 -0
- package/dist/test/switchbot.test.d.ts +2 -0
- package/dist/test/switchbot.test.d.ts.map +1 -0
- package/dist/test/switchbot.test.js +106 -0
- package/dist/test/switchbot.test.js.map +1 -0
- package/dist/test/woblindtilt.test.d.ts.map +1 -0
- package/dist/test/woblindtilt.test.js +2 -0
- package/dist/test/woblindtilt.test.js.map +1 -0
- package/dist/{device → test}/wobulb.test.d.ts.map +1 -1
- package/dist/test/wobulb.test.js +2 -0
- package/dist/test/wobulb.test.js.map +1 -0
- package/dist/test/woceilinglight.test.d.ts.map +1 -0
- package/dist/test/woceilinglight.test.js +2 -0
- package/dist/test/woceilinglight.test.js.map +1 -0
- package/dist/test/wocontact.test.d.ts.map +1 -0
- package/dist/test/wocontact.test.js +2 -0
- package/dist/test/wocontact.test.js.map +1 -0
- package/dist/test/wocurtain.test.d.ts.map +1 -0
- package/dist/test/wocurtain.test.js +2 -0
- package/dist/test/wocurtain.test.js.map +1 -0
- package/dist/{device → test}/wohand.test.d.ts.map +1 -1
- package/dist/test/wohand.test.js +2 -0
- package/dist/test/wohand.test.js.map +1 -0
- package/dist/test/wohub2.test.d.ts +2 -0
- package/dist/test/wohub2.test.d.ts.map +1 -0
- package/dist/test/wohub2.test.js +2 -0
- package/dist/test/wohub2.test.js.map +1 -0
- package/dist/{device → test}/wohumi.test.d.ts.map +1 -1
- package/dist/test/wohumi.test.js +2 -0
- package/dist/test/wohumi.test.js.map +1 -0
- package/dist/test/woiosensorth.test.d.ts.map +1 -0
- package/dist/test/woiosensorth.test.js +2 -0
- package/dist/test/woiosensorth.test.js.map +1 -0
- package/dist/test/woplugmini.test.d.ts.map +1 -0
- package/dist/test/woplugmini.test.js +2 -0
- package/dist/test/woplugmini.test.js.map +1 -0
- package/dist/test/wopresence.test.d.ts.map +1 -0
- package/dist/test/wopresence.test.js +2 -0
- package/dist/test/wopresence.test.js.map +1 -0
- package/dist/test/wosensorth.test.d.ts.map +1 -0
- package/dist/test/wosensorth.test.js +2 -0
- package/dist/test/wosensorth.test.js.map +1 -0
- package/dist/test/wosmartlock.test.d.ts.map +1 -0
- package/dist/test/wosmartlock.test.js +2 -0
- package/dist/test/wosmartlock.test.js.map +1 -0
- package/dist/test/wosmartlockpro.test.d.ts.map +1 -0
- package/dist/test/wosmartlockpro.test.js +2 -0
- package/dist/test/wosmartlockpro.test.js.map +1 -0
- package/dist/{device → test}/wostrip.test.d.ts.map +1 -1
- package/dist/test/wostrip.test.js +2 -0
- package/dist/test/wostrip.test.js.map +1 -0
- package/dist/types/bledevicestatus.d.ts +4 -12
- package/dist/types/bledevicestatus.d.ts.map +1 -1
- package/dist/types/devicelist.d.ts.map +1 -1
- package/dist/types/devicelist.js +0 -4
- package/dist/types/devicelist.js.map +1 -1
- package/dist/types/devicepush.d.ts +13 -0
- package/dist/types/devicepush.d.ts.map +1 -0
- package/dist/types/devicepush.js +2 -0
- package/dist/types/devicepush.js.map +1 -0
- package/dist/types/deviceresponse.d.ts +2 -3
- package/dist/types/deviceresponse.d.ts.map +1 -1
- package/dist/types/devicestatus.d.ts.map +1 -1
- package/dist/types/devicewebhookstatus.d.ts +32 -0
- package/dist/types/devicewebhookstatus.d.ts.map +1 -1
- package/dist/types/irdevicelist.d.ts.map +1 -1
- package/dist/types/types.d.ts +61 -120
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/types.js +10 -0
- package/dist/types/types.js.map +1 -1
- package/docs/assets/highlight.css +12 -47
- package/docs/assets/main.js +1 -1
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/SwitchBotBLE.html +61 -0
- package/docs/classes/SwitchBotOpenAPI.html +47 -0
- package/docs/classes/SwitchbotDevice.html +28 -33
- package/docs/enums/LogLevel.html +6 -0
- package/docs/enums/SwitchBotBLEModel.html +2 -2
- package/docs/enums/SwitchBotBLEModelFriendlyName.html +2 -2
- package/docs/enums/SwitchBotBLEModelName.html +2 -2
- package/docs/enums/SwitchBotModel.html +2 -2
- package/docs/hierarchy.html +1 -0
- package/docs/index.html +16 -993
- package/docs/interfaces/Ad-1.html +5 -0
- package/docs/interfaces/AdvertisementData.html +3 -0
- package/docs/interfaces/Chars.html +4 -0
- package/docs/interfaces/ErrorObject.html +3 -0
- package/docs/interfaces/Params.html +6 -0
- package/docs/interfaces/ServiceData.html +2 -0
- package/docs/interfaces/SwitchBotBLEDevice.html +21 -0
- package/docs/interfaces/WebhookDetail.html +6 -0
- package/docs/interfaces/ad.html +5 -0
- package/docs/interfaces/body.html +3 -0
- package/docs/interfaces/bodyChange.html +4 -0
- package/docs/interfaces/deleteWebhookResponse.html +4 -0
- package/docs/interfaces/device.html +7 -0
- package/docs/interfaces/deviceList.html +2 -0
- package/docs/interfaces/deviceStatus.html +7 -0
- package/docs/interfaces/deviceStatusRequest.html +4 -0
- package/docs/interfaces/deviceWebhook.html +4 -0
- package/docs/interfaces/deviceWebhookContext.html +4 -0
- package/docs/interfaces/devices.html +4 -0
- package/docs/interfaces/infraredRemoteList.html +2 -0
- package/docs/interfaces/irdevice.html +5 -0
- package/docs/interfaces/pushResponse.html +4 -0
- package/docs/interfaces/queryWebhookResponse.html +4 -0
- package/docs/interfaces/setupWebhookResponse.html +4 -0
- package/docs/interfaces/switchbot.html +3 -0
- package/docs/interfaces/updateWebhookResponse.html +4 -0
- package/docs/interfaces/webhookRequest.html +4 -0
- package/docs/media/BLE.md +1109 -0
- package/docs/media/OpenAPI.md +172 -0
- package/docs/modules.html +136 -3
- package/docs/types/MacAddress.html +1 -0
- package/docs/types/batteryCirculatorFan.html +1 -0
- package/docs/types/batteryCirculatorFanServiceData.html +1 -0
- package/docs/types/batteryCirculatorFanStatus.html +1 -0
- package/docs/types/batteryCirculatorFanWebhookContext.html +1 -0
- package/docs/types/blindTilt.html +1 -0
- package/docs/types/blindTiltServiceData.html +1 -0
- package/docs/types/blindTiltStatus.html +1 -0
- package/docs/types/blindTiltWebhookContext.html +1 -0
- package/docs/types/bot.html +1 -0
- package/docs/types/botServiceData.html +1 -0
- package/docs/types/botStatus.html +1 -0
- package/docs/types/botWebhookContext.html +1 -0
- package/docs/types/ceilingLight.html +1 -0
- package/docs/types/ceilingLightPro.html +1 -0
- package/docs/types/ceilingLightProServiceData.html +1 -0
- package/docs/types/ceilingLightProStatus.html +1 -0
- package/docs/types/ceilingLightProWebhookContext.html +1 -0
- package/docs/types/ceilingLightServiceData.html +1 -0
- package/docs/types/ceilingLightStatus.html +1 -0
- package/docs/types/ceilingLightWebhookContext.html +1 -0
- package/docs/types/colorBulb.html +1 -0
- package/docs/types/colorBulbServiceData.html +1 -0
- package/docs/types/colorBulbStatus.html +1 -0
- package/docs/types/colorBulbWebhookContext.html +1 -0
- package/docs/types/contactSensor.html +1 -0
- package/docs/types/contactSensorServiceData.html +1 -0
- package/docs/types/contactSensorStatus.html +1 -0
- package/docs/types/contactSensorWebhookContext.html +1 -0
- package/docs/types/curtain.html +1 -0
- package/docs/types/curtain3.html +1 -0
- package/docs/types/curtain3ServiceData.html +1 -0
- package/docs/types/curtain3WebhookContext.html +1 -0
- package/docs/types/curtainServiceData.html +1 -0
- package/docs/types/curtainStatus.html +1 -0
- package/docs/types/curtainWebhookContext.html +1 -0
- package/docs/types/floorCleaningRobotS10.html +1 -0
- package/docs/types/floorCleaningRobotS10Status.html +1 -0
- package/docs/types/floorCleaningRobotS10WebhookContext.html +1 -0
- package/docs/types/hub2.html +1 -0
- package/docs/types/hub2ServiceData.html +1 -0
- package/docs/types/hub2Status.html +1 -0
- package/docs/types/hub2WebhookContext.html +1 -0
- package/docs/types/humidifier.html +1 -0
- package/docs/types/humidifierServiceData.html +1 -0
- package/docs/types/humidifierStatus.html +1 -0
- package/docs/types/humidifierWebhookContext.html +1 -0
- package/docs/types/indoorCam.html +1 -0
- package/docs/types/indoorCameraWebhookContext.html +1 -0
- package/docs/types/keypad.html +1 -0
- package/docs/types/keypadTouch.html +1 -0
- package/docs/types/keypadTouchWebhookContext.html +1 -0
- package/docs/types/keypadWebhookContext.html +1 -0
- package/docs/types/lock.html +1 -0
- package/docs/types/lockPro.html +1 -0
- package/docs/types/lockProServiceData.html +1 -0
- package/docs/types/lockProStatus.html +1 -0
- package/docs/types/lockProWebhookContext.html +1 -0
- package/docs/types/lockServiceData.html +1 -0
- package/docs/types/lockStatus.html +1 -0
- package/docs/types/lockWebhookContext.html +1 -0
- package/docs/types/meter.html +1 -0
- package/docs/types/meterPlus.html +1 -0
- package/docs/types/meterPlusServiceData.html +1 -0
- package/docs/types/meterPlusStatus.html +1 -0
- package/docs/types/meterPlusWebhookContext.html +1 -0
- package/docs/types/meterServiceData.html +1 -0
- package/docs/types/meterStatus.html +1 -0
- package/docs/types/meterWebhookContext.html +1 -0
- package/docs/types/motionSensor.html +1 -0
- package/docs/types/motionSensorServiceData.html +1 -0
- package/docs/types/motionSensorStatus.html +1 -0
- package/docs/types/motionSensorWebhookContext.html +1 -0
- package/docs/types/outdoorMeter.html +1 -0
- package/docs/types/outdoorMeterServiceData.html +1 -0
- package/docs/types/outdoorMeterStatus.html +1 -0
- package/docs/types/outdoorMeterWebhookContext.html +1 -0
- package/docs/types/panTiltCamWebhookContext.html +1 -0
- package/docs/types/pantiltCam.html +1 -0
- package/docs/types/pantiltCam2k.html +1 -0
- package/docs/types/plug.html +1 -0
- package/docs/types/plugMini.html +1 -0
- package/docs/types/plugMiniJPServiceData.html +1 -0
- package/docs/types/plugMiniJPWebhookContext.html +1 -0
- package/docs/types/plugMiniStatus.html +1 -0
- package/docs/types/plugMiniUSServiceData.html +1 -0
- package/docs/types/plugMiniUSWebhookContext.html +1 -0
- package/docs/types/plugStatus.html +1 -0
- package/docs/types/plugWebhookContext.html +1 -0
- package/docs/types/remote.html +1 -0
- package/docs/types/robotVacuumCleanerS1.html +1 -0
- package/docs/types/robotVacuumCleanerS1Plus.html +1 -0
- package/docs/types/robotVacuumCleanerS1PlusStatus.html +1 -0
- package/docs/types/robotVacuumCleanerS1PlusWebhookContext.html +1 -0
- package/docs/types/robotVacuumCleanerS1Status.html +1 -0
- package/docs/types/robotVacuumCleanerS1WebhookContext.html +1 -0
- package/docs/types/robotVacuumCleanerServiceData.html +1 -0
- package/docs/types/stripLight.html +1 -0
- package/docs/types/stripLightServiceData.html +1 -0
- package/docs/types/stripLightStatus.html +1 -0
- package/docs/types/stripLightWebhookContext.html +1 -0
- package/docs/types/waterLeakDetector.html +1 -0
- package/docs/types/waterLeakDetectorServiceData.html +1 -0
- package/docs/types/waterLeakDetectorStatus.html +1 -0
- package/docs/types/waterLeakDetectorWebhookContext.html +1 -0
- package/package.json +12 -10
- package/dist/device/woblindtilt.test.d.ts.map +0 -1
- package/dist/device/woblindtilt.test.js +0 -26
- package/dist/device/woblindtilt.test.js.map +0 -1
- package/dist/device/wobulb.test.js +0 -52
- package/dist/device/wobulb.test.js.map +0 -1
- package/dist/device/woceilinglight.test.d.ts.map +0 -1
- package/dist/device/woceilinglight.test.js +0 -63
- package/dist/device/woceilinglight.test.js.map +0 -1
- package/dist/device/wocontact.test.d.ts.map +0 -1
- package/dist/device/wocontact.test.js +0 -34
- package/dist/device/wocontact.test.js.map +0 -1
- package/dist/device/wocurtain.test.d.ts.map +0 -1
- package/dist/device/wocurtain.test.js +0 -33
- package/dist/device/wocurtain.test.js.map +0 -1
- package/dist/device/wohand.test.js +0 -62
- package/dist/device/wohand.test.js.map +0 -1
- package/dist/device/wohand2.test.d.ts +0 -2
- package/dist/device/wohand2.test.d.ts.map +0 -1
- package/dist/device/wohand2.test.js +0 -50
- package/dist/device/wohand2.test.js.map +0 -1
- package/dist/device/wohumi.test.js +0 -61
- package/dist/device/wohumi.test.js.map +0 -1
- package/dist/device/woiosensorth.test.d.ts.map +0 -1
- package/dist/device/woiosensorth.test.js +0 -39
- package/dist/device/woiosensorth.test.js.map +0 -1
- package/dist/device/woplugmini.test.d.ts.map +0 -1
- package/dist/device/woplugmini.test.js +0 -91
- package/dist/device/woplugmini.test.js.map +0 -1
- package/dist/device/wopresence.test.d.ts.map +0 -1
- package/dist/device/wopresence.test.js +0 -42
- package/dist/device/wopresence.test.js.map +0 -1
- package/dist/device/wosensorth.test.d.ts.map +0 -1
- package/dist/device/wosensorth.test.js +0 -59
- package/dist/device/wosensorth.test.js.map +0 -1
- package/dist/device/wosmartlock.test.d.ts.map +0 -1
- package/dist/device/wosmartlock.test.js +0 -84
- package/dist/device/wosmartlock.test.js.map +0 -1
- package/dist/device/wosmartlockpro.test.d.ts.map +0 -1
- package/dist/device/wosmartlockpro.test.js +0 -124
- package/dist/device/wosmartlockpro.test.js.map +0 -1
- package/dist/device/wostrip.test.js +0 -115
- package/dist/device/wostrip.test.js.map +0 -1
- package/dist/switchbot.d.ts.map +0 -1
- package/dist/switchbot.js +0 -259
- package/dist/switchbot.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/docs/classes/SwitchBot.html +0 -16
- package/docs/types/SwitchBotBLEDevice.html +0 -1
- /package/dist/{device → test}/woblindtilt.test.d.ts +0 -0
- /package/dist/{device → test}/wobulb.test.d.ts +0 -0
- /package/dist/{device → test}/woceilinglight.test.d.ts +0 -0
- /package/dist/{device → test}/wocontact.test.d.ts +0 -0
- /package/dist/{device → test}/wocurtain.test.d.ts +0 -0
- /package/dist/{device → test}/wohand.test.d.ts +0 -0
- /package/dist/{device → test}/wohumi.test.d.ts +0 -0
- /package/dist/{device → test}/woiosensorth.test.d.ts +0 -0
- /package/dist/{device → test}/woplugmini.test.d.ts +0 -0
- /package/dist/{device → test}/wopresence.test.d.ts +0 -0
- /package/dist/{device → test}/wosensorth.test.d.ts +0 -0
- /package/dist/{device → test}/wosmartlock.test.d.ts +0 -0
- /package/dist/{device → test}/wosmartlockpro.test.d.ts +0 -0
- /package/dist/{device → test}/wostrip.test.d.ts +0 -0
|
@@ -1,282 +1,194 @@
|
|
|
1
1
|
import { Buffer } from 'node:buffer';
|
|
2
2
|
import * as Crypto from 'node:crypto';
|
|
3
|
-
/*
|
|
4
|
-
* wosmartlock.ts: Switchbot BLE API registration.
|
|
5
|
-
* adapted off the work done by [pySwitchbot](https://github.com/Danielhiversen/pySwitchbot)
|
|
6
|
-
*/
|
|
7
3
|
import { SwitchbotDevice } from '../device.js';
|
|
4
|
+
import { WoSmartLockProCommands } from '../settings.js';
|
|
8
5
|
import { SwitchBotBLEModel, SwitchBotBLEModelFriendlyName, SwitchBotBLEModelName } from '../types/types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Class representing a WoSmartLockPro device.
|
|
8
|
+
* @see https://github.com/OpenWonderLabs/SwitchBotAPI-BLE/blob/latest/devicetypes/lock.md
|
|
9
|
+
*/
|
|
9
10
|
export class WoSmartLockPro extends SwitchbotDevice {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
static COMMAND_LOCK_INFO = '570f4f8102';
|
|
15
|
-
static COMMAND_UNLOCK = '570f4e0101000080';
|
|
16
|
-
static COMMAND_UNLOCK_NO_UNLATCH = '570f4e01010000a0';
|
|
17
|
-
static COMMAND_LOCK = '570f4e0101000000';
|
|
18
|
-
static COMMAND_ENABLE_NOTIFICATIONS = '570e01001e00008101';
|
|
19
|
-
static COMMAND_DISABLE_NOTIFICATIONS = '570e00';
|
|
11
|
+
static switchBotBLE;
|
|
12
|
+
iv = null;
|
|
13
|
+
key_id = '';
|
|
14
|
+
encryption_key = null;
|
|
20
15
|
static Result = {
|
|
21
16
|
ERROR: 0x00,
|
|
22
17
|
SUCCESS: 0x01,
|
|
23
18
|
SUCCESS_LOW_BATTERY: 0x06,
|
|
24
19
|
};
|
|
25
|
-
static validateResponse(res) {
|
|
20
|
+
static async validateResponse(res) {
|
|
26
21
|
if (res.length >= 3) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
case WoSmartLockPro.Result.SUCCESS_LOW_BATTERY:
|
|
31
|
-
return WoSmartLockPro.Result.SUCCESS_LOW_BATTERY;
|
|
22
|
+
const result = res.readUInt8(0);
|
|
23
|
+
if (result === WoSmartLockPro.Result.SUCCESS || result === WoSmartLockPro.Result.SUCCESS_LOW_BATTERY) {
|
|
24
|
+
return result;
|
|
32
25
|
}
|
|
33
26
|
}
|
|
34
27
|
return WoSmartLockPro.Result.ERROR;
|
|
35
28
|
}
|
|
36
29
|
static getLockStatus(code) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return 'LOCKING_STOP';
|
|
48
|
-
case 0b1010000:
|
|
49
|
-
return 'UNLOCKING_STOP';
|
|
50
|
-
case 0b01100000: // Only EU lock type
|
|
51
|
-
return 'NOT_FULLY_LOCKED';
|
|
52
|
-
default:
|
|
53
|
-
return 'UNKNOWN';
|
|
54
|
-
}
|
|
30
|
+
const statusMap = {
|
|
31
|
+
0b0000000: 'LOCKED',
|
|
32
|
+
0b0010000: 'UNLOCKED',
|
|
33
|
+
0b0100000: 'LOCKING',
|
|
34
|
+
0b0110000: 'UNLOCKING',
|
|
35
|
+
0b1000000: 'LOCKING_STOP',
|
|
36
|
+
0b1010000: 'UNLOCKING_STOP',
|
|
37
|
+
0b01100000: 'NOT_FULLY_LOCKED', // Only EU lock type
|
|
38
|
+
};
|
|
39
|
+
return statusMap[code] || 'UNKNOWN';
|
|
55
40
|
}
|
|
56
|
-
static async parseServiceData(serviceData, manufacturerData
|
|
41
|
+
static async parseServiceData(serviceData, manufacturerData) {
|
|
57
42
|
if (manufacturerData.length < 11) {
|
|
58
|
-
|
|
59
|
-
onlog(`[parseServiceDataForWoSmartLockPro] Buffer length ${manufacturerData.length} is too short!`);
|
|
60
|
-
}
|
|
43
|
+
this.switchBotBLE.emitLog('error', `[parseServiceDataForWoSmartLockPro] Buffer length ${manufacturerData.length} is too short!`);
|
|
61
44
|
return null;
|
|
62
45
|
}
|
|
63
|
-
// adv data needs both service data and manufacturer data
|
|
64
|
-
// byte var names based on documentation
|
|
65
46
|
const byte2 = serviceData.readUInt8(2);
|
|
66
47
|
const byte7 = manufacturerData.readUInt8(7);
|
|
67
48
|
const byte8 = manufacturerData.readUInt8(8);
|
|
68
49
|
const byte9 = manufacturerData.readUInt8(9);
|
|
69
50
|
const byte11 = manufacturerData.readUInt8(11);
|
|
70
|
-
const battery = byte2 & 0b01111111; // %
|
|
71
|
-
const calibration = !!(byte7 & 0b10000000);
|
|
72
|
-
const status = WoSmartLockPro.getLockStatus((byte7 & 0b00111000) >> 3);
|
|
73
|
-
const door_open = !!(byte8 & 0b01100000);
|
|
74
|
-
// Double lock mode is not supported on Lock Pro
|
|
75
|
-
const update_from_secondary_lock = false; // !!(byte7 & 0b00001000)
|
|
76
|
-
const double_lock_mode = false; // !!(byte8 & 0b10000000)
|
|
77
|
-
const unclosed_alarm = !!(byte11 & 0b10000000);
|
|
78
|
-
const unlocked_alarm = !!(byte11 & 0b01000000);
|
|
79
|
-
const auto_lock_paused = !!(byte8 & 0b100000);
|
|
80
|
-
const night_latch = !!(byte9 & 0b00000001);
|
|
81
|
-
// const manual = byte7 & 0b100000;
|
|
82
51
|
const data = {
|
|
83
52
|
model: SwitchBotBLEModel.LockPro,
|
|
84
53
|
modelName: SwitchBotBLEModelName.LockPro,
|
|
85
54
|
modelFriendlyName: SwitchBotBLEModelFriendlyName.LockPro,
|
|
86
|
-
battery,
|
|
87
|
-
calibration,
|
|
88
|
-
status,
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
double_lock_mode,
|
|
92
|
-
unclosed_alarm,
|
|
93
|
-
unlocked_alarm,
|
|
94
|
-
auto_lock_paused,
|
|
95
|
-
night_latch,
|
|
55
|
+
battery: byte2 & 0b01111111,
|
|
56
|
+
calibration: !!(byte7 & 0b10000000),
|
|
57
|
+
status: WoSmartLockPro.getLockStatus((byte7 & 0b00111000) >> 3),
|
|
58
|
+
door_open: !!(byte8 & 0b01100000),
|
|
59
|
+
update_from_secondary_lock: false,
|
|
60
|
+
double_lock_mode: false,
|
|
61
|
+
unclosed_alarm: !!(byte11 & 0b10000000),
|
|
62
|
+
unlocked_alarm: !!(byte11 & 0b01000000),
|
|
63
|
+
auto_lock_paused: !!(byte8 & 0b100000),
|
|
64
|
+
night_latch: !!(byte9 & 0b00000001),
|
|
96
65
|
};
|
|
97
66
|
return data;
|
|
98
67
|
}
|
|
99
68
|
constructor(peripheral, noble) {
|
|
100
69
|
super(peripheral, noble);
|
|
101
|
-
this._iv = null;
|
|
102
|
-
this._key_id = '';
|
|
103
|
-
this._encryption_key = null;
|
|
104
70
|
}
|
|
105
|
-
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
|
|
110
|
-
* - keyId, encryptionKey
|
|
111
|
-
*
|
|
112
|
-
* [Return value]
|
|
113
|
-
* - void
|
|
114
|
-
* ---------------------------------------------------------------- */
|
|
71
|
+
/**
|
|
72
|
+
* Initializes the encryption key info for valid lock communication.
|
|
73
|
+
* @param {string} keyId - The key ID.
|
|
74
|
+
* @param {string} encryptionKey - The encryption key.
|
|
75
|
+
*/
|
|
115
76
|
async setKey(keyId, encryptionKey) {
|
|
116
|
-
this.
|
|
117
|
-
this.
|
|
118
|
-
this.
|
|
77
|
+
this.iv = null;
|
|
78
|
+
this.key_id = keyId;
|
|
79
|
+
this.encryption_key = Buffer.from(encryptionKey, 'hex');
|
|
119
80
|
}
|
|
120
|
-
|
|
121
|
-
*
|
|
122
|
-
* -
|
|
123
|
-
|
|
124
|
-
* [Arguments]
|
|
125
|
-
* - none
|
|
126
|
-
*
|
|
127
|
-
* [Return value]
|
|
128
|
-
* - Promise object
|
|
129
|
-
* WoSmartLockPro.LockResult will be passed to the `resolve()`.
|
|
130
|
-
* ---------------------------------------------------------------- */
|
|
81
|
+
/**
|
|
82
|
+
* Unlocks the Smart Lock.
|
|
83
|
+
* @returns {Promise<number>} - The result of the unlock operation.
|
|
84
|
+
*/
|
|
131
85
|
async unlock() {
|
|
132
|
-
await this.operateLockPro(
|
|
133
|
-
|
|
134
|
-
if (resBuf) {
|
|
135
|
-
return WoSmartLockPro.validateResponse(resBuf);
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
return WoSmartLockPro.Result.ERROR;
|
|
139
|
-
}
|
|
140
|
-
})
|
|
141
|
-
.catch((error) => {
|
|
142
|
-
throw error;
|
|
143
|
-
});
|
|
86
|
+
const resBuf = await this.operateLockPro(WoSmartLockProCommands.UNLOCK);
|
|
87
|
+
return resBuf ? WoSmartLockPro.validateResponse(resBuf) : WoSmartLockPro.Result.ERROR;
|
|
144
88
|
}
|
|
145
|
-
|
|
146
|
-
*
|
|
147
|
-
* -
|
|
148
|
-
|
|
149
|
-
* [Arguments]
|
|
150
|
-
* - none
|
|
151
|
-
*
|
|
152
|
-
* [Return value]
|
|
153
|
-
* - Promise object
|
|
154
|
-
* WoSmartLockPro.LockResult will be passed to the `resolve()`.
|
|
155
|
-
* ---------------------------------------------------------------- */
|
|
89
|
+
/**
|
|
90
|
+
* Unlocks the Smart Lock without unlatching the door.
|
|
91
|
+
* @returns {Promise<number>} - The result of the unlock operation.
|
|
92
|
+
*/
|
|
156
93
|
async unlockNoUnlatch() {
|
|
157
|
-
await this.operateLockPro(
|
|
158
|
-
|
|
159
|
-
if (resBuf) {
|
|
160
|
-
return WoSmartLockPro.validateResponse(resBuf);
|
|
161
|
-
}
|
|
162
|
-
else {
|
|
163
|
-
return WoSmartLockPro.Result.ERROR;
|
|
164
|
-
}
|
|
165
|
-
})
|
|
166
|
-
.catch((error) => {
|
|
167
|
-
throw error;
|
|
168
|
-
});
|
|
94
|
+
const resBuf = await this.operateLockPro(WoSmartLockProCommands.UNLOCK_NO_UNLATCH);
|
|
95
|
+
return resBuf ? WoSmartLockPro.validateResponse(resBuf) : WoSmartLockPro.Result.ERROR;
|
|
169
96
|
}
|
|
170
|
-
|
|
171
|
-
*
|
|
172
|
-
* -
|
|
173
|
-
|
|
174
|
-
* [Arguments]
|
|
175
|
-
* - none
|
|
176
|
-
*
|
|
177
|
-
* [Return value]
|
|
178
|
-
* - Promise object
|
|
179
|
-
* WoSmartLockPro.LockResult will be passed to the `resolve()`.
|
|
180
|
-
* ---------------------------------------------------------------- */
|
|
97
|
+
/**
|
|
98
|
+
* Locks the Smart Lock.
|
|
99
|
+
* @returns {Promise<number>} - The result of the lock operation.
|
|
100
|
+
*/
|
|
181
101
|
async lock() {
|
|
182
|
-
this.operateLockPro(
|
|
183
|
-
|
|
184
|
-
if (resBuf) {
|
|
185
|
-
return WoSmartLockPro.validateResponse(resBuf);
|
|
186
|
-
}
|
|
187
|
-
else {
|
|
188
|
-
return WoSmartLockPro.Result.ERROR;
|
|
189
|
-
}
|
|
190
|
-
})
|
|
191
|
-
.catch((error) => {
|
|
192
|
-
throw error;
|
|
193
|
-
});
|
|
102
|
+
const resBuf = await this.operateLockPro(WoSmartLockProCommands.LOCK);
|
|
103
|
+
return resBuf ? WoSmartLockPro.validateResponse(resBuf) : WoSmartLockPro.Result.ERROR;
|
|
194
104
|
}
|
|
195
|
-
|
|
196
|
-
* info
|
|
197
|
-
* -
|
|
198
|
-
|
|
199
|
-
* [Arguments]
|
|
200
|
-
* - none
|
|
201
|
-
*
|
|
202
|
-
* [Return value]
|
|
203
|
-
* - Promise object
|
|
204
|
-
* state object will be passed to the `resolve()`
|
|
205
|
-
* ---------------------------------------------------------------- */
|
|
105
|
+
/**
|
|
106
|
+
* Gets general state info from the Smart Lock.
|
|
107
|
+
* @returns {Promise<object | null>} - The state object or null if an error occurred.
|
|
108
|
+
*/
|
|
206
109
|
async info() {
|
|
207
|
-
await this.operateLockPro(
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}
|
|
219
|
-
else {
|
|
220
|
-
return null;
|
|
221
|
-
}
|
|
222
|
-
})
|
|
223
|
-
.catch((error) => {
|
|
224
|
-
throw error;
|
|
225
|
-
});
|
|
110
|
+
const resBuf = await this.operateLockPro(WoSmartLockProCommands.LOCK_INFO);
|
|
111
|
+
if (resBuf) {
|
|
112
|
+
return {
|
|
113
|
+
calibration: Boolean(resBuf[0] & 0b10000000),
|
|
114
|
+
status: WoSmartLockPro.getLockStatus((resBuf[0] & 0b01110000) >> 4),
|
|
115
|
+
door_open: Boolean(resBuf[0] & 0b00000100),
|
|
116
|
+
unclosed_alarm: Boolean(resBuf[1] & 0b00100000),
|
|
117
|
+
unlocked_alarm: Boolean(resBuf[1] & 0b00010000),
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
return null;
|
|
226
121
|
}
|
|
122
|
+
/**
|
|
123
|
+
* Encrypts a string using AES-128-CTR.
|
|
124
|
+
* @param {string} str - The string to encrypt.
|
|
125
|
+
* @returns {Promise<string>} - The encrypted string in hex format.
|
|
126
|
+
*/
|
|
227
127
|
async encrypt(str) {
|
|
228
|
-
const cipher = Crypto.createCipheriv('aes-128-ctr', this.
|
|
128
|
+
const cipher = Crypto.createCipheriv('aes-128-ctr', this.encryption_key, this.iv);
|
|
229
129
|
return Buffer.concat([cipher.update(str, 'hex'), cipher.final()]).toString('hex');
|
|
230
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* Decrypts a buffer using AES-128-CTR.
|
|
133
|
+
* @param {Buffer} data - The data to decrypt.
|
|
134
|
+
* @returns {Promise<Buffer>} - The decrypted data.
|
|
135
|
+
*/
|
|
231
136
|
async decrypt(data) {
|
|
232
|
-
const decipher = Crypto.createDecipheriv('aes-128-ctr', this.
|
|
137
|
+
const decipher = Crypto.createDecipheriv('aes-128-ctr', this.encryption_key, this.iv);
|
|
233
138
|
return Buffer.concat([decipher.update(data), decipher.final()]);
|
|
234
139
|
}
|
|
140
|
+
/**
|
|
141
|
+
* Retrieves the IV from the device.
|
|
142
|
+
* @returns {Promise<Buffer>} - The IV buffer.
|
|
143
|
+
*/
|
|
235
144
|
async getIv() {
|
|
236
|
-
if (this.
|
|
237
|
-
const res = await this.operateLockPro(
|
|
145
|
+
if (!this.iv) {
|
|
146
|
+
const res = await this.operateLockPro(WoSmartLockProCommands.GET_CKIV + this.key_id, false);
|
|
238
147
|
if (res) {
|
|
239
|
-
this.
|
|
148
|
+
this.iv = res.subarray(4);
|
|
240
149
|
}
|
|
241
150
|
else {
|
|
242
151
|
throw new Error('Failed to retrieve IV from the device.');
|
|
243
152
|
}
|
|
244
153
|
}
|
|
245
|
-
return this.
|
|
154
|
+
return this.iv;
|
|
246
155
|
}
|
|
156
|
+
/**
|
|
157
|
+
* Sends an encrypted command to the device.
|
|
158
|
+
* @param {string} key - The command key.
|
|
159
|
+
* @returns {Promise<Buffer>} - The response buffer.
|
|
160
|
+
*/
|
|
247
161
|
async encryptedCommand(key) {
|
|
248
162
|
const iv = await this.getIv();
|
|
249
|
-
const req = Buffer.from(key.substring(0, 2) + this.
|
|
163
|
+
const req = Buffer.from(key.substring(0, 2) + this.key_id + Buffer.from(iv.subarray(0, 2)).toString('hex') + await this.encrypt(key.substring(2)), 'hex');
|
|
250
164
|
const bytes = await this.command(req);
|
|
251
165
|
const buf = Buffer.from(bytes);
|
|
252
166
|
const code = WoSmartLockPro.validateResponse(buf);
|
|
253
|
-
if (code !== WoSmartLockPro.Result.ERROR) {
|
|
167
|
+
if (await code !== WoSmartLockPro.Result.ERROR) {
|
|
254
168
|
return Buffer.concat([buf.subarray(0, 1), await this.decrypt(buf.subarray(4))]);
|
|
255
169
|
}
|
|
256
170
|
else {
|
|
257
171
|
throw new Error(`The device returned an error: 0x${buf.toString('hex')}`);
|
|
258
172
|
}
|
|
259
173
|
}
|
|
174
|
+
/**
|
|
175
|
+
* Operates the lock with the given command.
|
|
176
|
+
* @param {string} key - The command key.
|
|
177
|
+
* @param {boolean} [encrypt] - Whether to encrypt the command.
|
|
178
|
+
* @returns {Promise<Buffer>} - The response buffer.
|
|
179
|
+
*/
|
|
260
180
|
async operateLockPro(key, encrypt = true) {
|
|
261
|
-
// encrypted command
|
|
262
181
|
if (encrypt) {
|
|
263
182
|
return this.encryptedCommand(key);
|
|
264
183
|
}
|
|
265
184
|
const req = Buffer.from(`${key.substring(0, 2)}000000${key.substring(2)}`, 'hex');
|
|
266
|
-
await this.command(req)
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
else {
|
|
274
|
-
return buf;
|
|
275
|
-
}
|
|
276
|
-
})
|
|
277
|
-
.catch((error) => {
|
|
278
|
-
throw error;
|
|
279
|
-
});
|
|
185
|
+
const bytes = await this.command(req);
|
|
186
|
+
const buf = Buffer.from(bytes);
|
|
187
|
+
const code = WoSmartLockPro.validateResponse(buf);
|
|
188
|
+
if (await code === WoSmartLockPro.Result.ERROR) {
|
|
189
|
+
throw new Error(`The device returned an error: 0x${buf.toString('hex')}`);
|
|
190
|
+
}
|
|
191
|
+
return buf;
|
|
280
192
|
}
|
|
281
193
|
}
|
|
282
194
|
//# sourceMappingURL=wosmartlockpro.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wosmartlockpro.js","sourceRoot":"","sources":["../../src/device/wosmartlockpro.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wosmartlockpro.js","sourceRoot":"","sources":["../../src/device/wosmartlockpro.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAErC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAA;AACvD,OAAO,EAAE,iBAAiB,EAAE,6BAA6B,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AAE3G;;;GAGG;AACH,MAAM,OAAO,cAAe,SAAQ,eAAe;IACjD,MAAM,CAAC,YAAY,CAAc;IAC1B,EAAE,GAAkB,IAAI,CAAA;IACxB,MAAM,GAAW,EAAE,CAAA;IACnB,cAAc,GAAkB,IAAI,CAAA;IAE3C,MAAM,CAAC,MAAM,GAAG;QACd,KAAK,EAAE,IAAI;QACX,OAAO,EAAE,IAAI;QACb,mBAAmB,EAAE,IAAI;KAC1B,CAAA;IAED,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAAC,GAAW;QACvC,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;YACpB,M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AG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,KAAK,CAAC,CAAA;QACjF,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;QACrC,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,KAAmB,CAAC,CAAA;QAC5C,MAAM,IAAI,GAAG,cAAc,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAA;QAEjD,IAAI,MAAM,IAAI,KAAK,cAAc,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YAC/C,MAAM,IAAI,KAAK,CAAC,mCAAmC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;QAC3E,CAAC;QACD,OAAO,GAAG,CAAA;IACZ,CAAC"}
|
package/dist/device/wostrip.d.ts
CHANGED
|
@@ -1,42 +1,62 @@
|
|
|
1
|
+
import type { SwitchBotBLE } from '../switchbot-ble.js';
|
|
1
2
|
import type { stripLightServiceData } from '../types/bledevicestatus.js';
|
|
2
3
|
import { Buffer } from 'node:buffer';
|
|
3
4
|
import { SwitchbotDevice } from '../device.js';
|
|
4
5
|
/**
|
|
5
|
-
*
|
|
6
|
+
* Class representing a WoStrip device.
|
|
7
|
+
* @see https://github.com/OpenWonderLabs/SwitchBotAPI-BLE/blob/latest/devicetypes/ledstriplight.md
|
|
6
8
|
*/
|
|
7
9
|
export declare class WoStrip extends SwitchbotDevice {
|
|
8
|
-
static
|
|
10
|
+
static switchBotBLE: SwitchBotBLE;
|
|
9
11
|
/**
|
|
10
|
-
*
|
|
12
|
+
* Parses the service data from the SwitchBot Strip Light.
|
|
13
|
+
* @param {Buffer} serviceData - The service data buffer.
|
|
14
|
+
* @returns {Promise<stripLightServiceData | null>} - Parsed service data or null if invalid.
|
|
11
15
|
*/
|
|
12
|
-
|
|
16
|
+
static parseServiceData(serviceData: Buffer): Promise<stripLightServiceData | null>;
|
|
13
17
|
/**
|
|
14
|
-
*
|
|
18
|
+
* Reads the state of the strip light.
|
|
19
|
+
* @returns {Promise<boolean>} - Resolves with true if the strip light is ON, false otherwise.
|
|
15
20
|
*/
|
|
16
|
-
|
|
21
|
+
readState(): Promise<boolean>;
|
|
17
22
|
/**
|
|
18
|
-
*
|
|
23
|
+
* Sets the state of the strip light.
|
|
24
|
+
* @public
|
|
25
|
+
* @param {number[]} reqByteArray - The request byte array.
|
|
26
|
+
* @returns {Promise<boolean>} - Resolves with true if the operation was successful.
|
|
19
27
|
*/
|
|
20
|
-
|
|
28
|
+
setState(reqByteArray: number[]): Promise<boolean>;
|
|
21
29
|
/**
|
|
22
|
-
*
|
|
30
|
+
* Turns the strip light on.
|
|
31
|
+
* @returns {Promise<boolean>} - Resolves with true if the strip light is ON.
|
|
23
32
|
*/
|
|
24
|
-
|
|
33
|
+
turnOn(): Promise<boolean>;
|
|
25
34
|
/**
|
|
26
|
-
*
|
|
35
|
+
* Turns the strip light off.
|
|
36
|
+
* @returns {Promise<boolean>} - Resolves with true if the strip light is OFF.
|
|
27
37
|
*/
|
|
28
|
-
|
|
38
|
+
turnOff(): Promise<boolean>;
|
|
29
39
|
/**
|
|
30
|
-
*
|
|
40
|
+
* Sets the brightness of the strip light.
|
|
41
|
+
* @param {number} brightness - The brightness percentage (0-100).
|
|
42
|
+
* @returns {Promise<boolean>} - Resolves with true if the operation was successful.
|
|
31
43
|
*/
|
|
32
|
-
|
|
44
|
+
setBrightness(brightness: number): Promise<boolean>;
|
|
33
45
|
/**
|
|
34
|
-
*
|
|
46
|
+
* Sets the RGB values of the strip light.
|
|
47
|
+
* @param {number} brightness - The brightness percentage (0-100).
|
|
48
|
+
* @param {number} red - The red value (0-255).
|
|
49
|
+
* @param {number} green - The green value (0-255).
|
|
50
|
+
* @param {number} blue - The blue value (0-255).
|
|
51
|
+
* @returns {Promise<boolean>} - Resolves with true if the operation was successful.
|
|
35
52
|
*/
|
|
36
|
-
setRGB(brightness: number, red: number, green: number, blue: number): Promise<
|
|
53
|
+
setRGB(brightness: number, red: number, green: number, blue: number): Promise<boolean>;
|
|
37
54
|
/**
|
|
38
|
-
*
|
|
55
|
+
* Operates the strip light with the given byte array.
|
|
56
|
+
* @public
|
|
57
|
+
* @param {number[]} bytes - The byte array to send.
|
|
58
|
+
* @returns {Promise<boolean>} - Resolves with true if the operation was successful.
|
|
39
59
|
*/
|
|
40
|
-
operateStripLight(bytes: number[]): Promise<
|
|
60
|
+
operateStripLight(bytes: number[]): Promise<boolean>;
|
|
41
61
|
}
|
|
42
62
|
//# sourceMappingURL=wostrip.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wostrip.d.ts","sourceRoot":"","sources":["../../src/device/wostrip.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wostrip.d.ts","sourceRoot":"","sources":["../../src/device/wostrip.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAA;AAExE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAG9C;;;GAGG;AACH,qBAAa,OAAQ,SAAQ,eAAe;IAC1C,MAAM,CAAC,YAAY,EAAE,YAAY,CAAA;IACjC;;;;OAIG;WACU,gBAAgB,CAC3B,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC;IAoCxC;;;OAGG;IACG,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC;IAInC;;;;;OAKG;IACU,QAAQ,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;IAK/D;;;OAGG;IACG,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC;IAIhC;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC;IAIjC;;;;OAIG;IACG,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAOzD;;;;;;;OAOG;IACG,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAa5F;;;;;OAKG;IACU,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;CAelE"}
|