node-switchbot 2.5.0-beta.8 → 3.0.0
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 +1144 -0
- package/CHANGELOG.md +14 -0
- package/OpenAPI.md +185 -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 +3 -3
- package/dist/advertising.d.ts.map +1 -1
- package/dist/advertising.js +26 -26
- package/dist/advertising.js.map +1 -1
- package/dist/device/woblindtilt.d.ts +19 -50
- package/dist/device/woblindtilt.d.ts.map +1 -1
- package/dist/device/woblindtilt.js +41 -100
- package/dist/device/woblindtilt.js.map +1 -1
- package/dist/device/wobulb.d.ts +41 -15
- package/dist/device/wobulb.d.ts.map +1 -1
- package/dist/device/wobulb.js +72 -128
- 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 +96 -171
- package/dist/device/woceilinglight.js.map +1 -1
- package/dist/device/wocontact.d.ts +11 -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 +39 -1
- package/dist/device/wocurtain.d.ts.map +1 -1
- package/dist/device/wocurtain.js +69 -103
- package/dist/device/wocurtain.js.map +1 -1
- package/dist/device/wohand.d.ts +37 -2
- package/dist/device/wohand.d.ts.map +1 -1
- package/dist/device/wohand.js +55 -89
- package/dist/device/wohand.js.map +1 -1
- package/dist/device/wohub2.d.ts +11 -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 +37 -2
- package/dist/device/wohumi.d.ts.map +1 -1
- package/dist/device/wohumi.js +52 -83
- package/dist/device/wohumi.js.map +1 -1
- package/dist/device/woiosensorth.d.ts +12 -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 +45 -12
- package/dist/device/woplugmini.d.ts.map +1 -1
- package/dist/device/woplugmini.js +71 -77
- package/dist/device/woplugmini.js.map +1 -1
- package/dist/device/wopresence.d.ts +11 -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 +34 -50
- package/dist/device/wosensorth.js.map +1 -1
- package/dist/device/wosmartlock.d.ts +63 -13
- package/dist/device/wosmartlock.d.ts.map +1 -1
- package/dist/device/wosmartlock.js +114 -195
- package/dist/device/wosmartlock.js.map +1 -1
- package/dist/device/wosmartlockpro.d.ts +16 -12
- package/dist/device/wosmartlockpro.d.ts.map +1 -1
- package/dist/device/wosmartlockpro.js +34 -29
- package/dist/device/wosmartlockpro.js.map +1 -1
- package/dist/device/wostrip.d.ts +4 -3
- package/dist/device/wostrip.d.ts.map +1 -1
- package/dist/device/wostrip.js +5 -4
- package/dist/device/wostrip.js.map +1 -1
- package/dist/device.d.ts +13 -5
- package/dist/device.d.ts.map +1 -1
- package/dist/device.js +13 -2
- 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 +10 -13
- package/dist/parameter-checker.d.ts.map +1 -1
- package/dist/parameter-checker.js +16 -1
- package/dist/parameter-checker.js.map +1 -1
- package/dist/settings.d.ts +41 -0
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +43 -0
- package/dist/settings.js.map +1 -1
- package/dist/{switchbot.d.ts → switchbot-ble.d.ts} +13 -8
- package/dist/switchbot-ble.d.ts.map +1 -0
- package/dist/switchbot-ble.js +427 -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 +99 -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 +76 -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 +95 -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 +81 -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 +65 -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 +75 -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 +56 -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 +80 -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 +82 -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 +40 -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 +114 -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 +68 -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 +51 -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 +151 -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 +151 -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 +102 -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 +23 -0
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/types.js +14 -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 +64 -0
- package/docs/classes/SwitchBotOpenAPI.html +47 -0
- package/docs/classes/SwitchbotDevice.html +32 -33
- package/docs/enums/LogLevel.html +10 -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 +185 -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 +13 -11
- package/.github/npm-version-script.cjs +0 -81
- 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,7 +1,17 @@
|
|
|
1
1
|
import type { Buffer } from 'node:buffer';
|
|
2
2
|
import type { motionSensorServiceData } from '../types/bledevicestatus.js';
|
|
3
3
|
import { SwitchbotDevice } from '../device.js';
|
|
4
|
+
/**
|
|
5
|
+
* Class representing a WoPresence device.
|
|
6
|
+
* @see https://github.com/OpenWonderLabs/SwitchBotAPI-BLE/blob/latest/devicetypes/meter.md
|
|
7
|
+
*/
|
|
4
8
|
export declare class WoPresence extends SwitchbotDevice {
|
|
5
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Parses the service data for WoPresence.
|
|
11
|
+
* @param {Buffer} serviceData - The service data buffer.
|
|
12
|
+
* @param {Function} emitLog - The function to emit log messages.
|
|
13
|
+
* @returns {Promise<motionSensorServiceData | null>} - Parsed service data or null if invalid.
|
|
14
|
+
*/
|
|
15
|
+
static parseServiceData(serviceData: Buffer, emitLog: (level: string, message: string) => void): Promise<motionSensorServiceData | null>;
|
|
6
16
|
}
|
|
7
17
|
//# sourceMappingURL=wopresence.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wopresence.d.ts","sourceRoot":"","sources":["../../src/device/wopresence.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wopresence.d.ts","sourceRoot":"","sources":["../../src/device/wopresence.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEzC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAA;AAE1E,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAG9C;;;GAGG;AACH,qBAAa,UAAW,SAAQ,eAAe;IAC7C;;;;;OAKG;WACU,gBAAgB,CAC3B,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,GAChD,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC;CAwB3C"}
|
|
@@ -1,40 +1,34 @@
|
|
|
1
|
-
/* Copyright(C) 2024, donavanbecker (https://github.com/donavanbecker). All rights reserved.
|
|
2
|
-
*
|
|
3
|
-
* wopresence.ts: Switchbot BLE API registration.
|
|
4
|
-
*/
|
|
5
1
|
import { SwitchbotDevice } from '../device.js';
|
|
6
2
|
import { SwitchBotBLEModel, SwitchBotBLEModelFriendlyName, SwitchBotBLEModelName } from '../types/types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Class representing a WoPresence device.
|
|
5
|
+
* @see https://github.com/OpenWonderLabs/SwitchBotAPI-BLE/blob/latest/devicetypes/meter.md
|
|
6
|
+
*/
|
|
7
7
|
export class WoPresence extends SwitchbotDevice {
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Parses the service data for WoPresence.
|
|
10
|
+
* @param {Buffer} serviceData - The service data buffer.
|
|
11
|
+
* @param {Function} emitLog - The function to emit log messages.
|
|
12
|
+
* @returns {Promise<motionSensorServiceData | null>} - Parsed service data or null if invalid.
|
|
13
|
+
*/
|
|
14
|
+
static async parseServiceData(serviceData, emitLog) {
|
|
9
15
|
if (serviceData.length !== 6) {
|
|
10
|
-
|
|
11
|
-
onlog(`[parseServiceDataForWoPresence] Buffer length ${serviceData.length} !== 6!`);
|
|
12
|
-
}
|
|
16
|
+
emitLog('debugerror', `[parseServiceDataForWoPresence] Buffer length ${serviceData.length} !== 6!`);
|
|
13
17
|
return null;
|
|
14
18
|
}
|
|
15
|
-
const byte1 = serviceData
|
|
16
|
-
const byte2 = serviceData.readUInt8(2);
|
|
17
|
-
const byte5 = serviceData.readUInt8(5);
|
|
18
|
-
const tested = !!(byte1 & 0b10000000);
|
|
19
|
-
const movement = !!(byte1 & 0b01000000);
|
|
20
|
-
const battery = byte2 & 0b01111111;
|
|
21
|
-
const led = (byte5 & 0b00100000) >> 5;
|
|
22
|
-
const iot = (byte5 & 0b00010000) >> 4;
|
|
23
|
-
const sense_distance = (byte5 & 0b00001100) >> 2;
|
|
24
|
-
const lightLevel = byte5 & 0b00000011;
|
|
25
|
-
const is_light = !!(byte5 & 0b00000010);
|
|
19
|
+
const [byte1, byte2, , , , byte5] = serviceData;
|
|
26
20
|
const data = {
|
|
27
21
|
model: SwitchBotBLEModel.MotionSensor,
|
|
28
22
|
modelName: SwitchBotBLEModelName.MotionSensor,
|
|
29
23
|
modelFriendlyName: SwitchBotBLEModelFriendlyName.MotionSensor,
|
|
30
|
-
tested,
|
|
31
|
-
movement,
|
|
32
|
-
battery,
|
|
33
|
-
led,
|
|
34
|
-
iot,
|
|
35
|
-
sense_distance,
|
|
36
|
-
lightLevel:
|
|
37
|
-
is_light,
|
|
24
|
+
tested: !!(byte1 & 0b10000000),
|
|
25
|
+
movement: !!(byte1 & 0b01000000),
|
|
26
|
+
battery: byte2 & 0b01111111,
|
|
27
|
+
led: (byte5 & 0b00100000) >> 5,
|
|
28
|
+
iot: (byte5 & 0b00010000) >> 4,
|
|
29
|
+
sense_distance: (byte5 & 0b00001100) >> 2,
|
|
30
|
+
lightLevel: (byte5 & 0b00000011) === 1 ? 'dark' : (byte5 & 0b00000011) === 2 ? 'bright' : 'unknown',
|
|
31
|
+
is_light: !!(byte5 & 0b00000010),
|
|
38
32
|
};
|
|
39
33
|
return data;
|
|
40
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wopresence.js","sourceRoot":"","sources":["../../src/device/wopresence.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wopresence.js","sourceRoot":"","sources":["../../src/device/wopresence.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,iBAAiB,EAAE,6BAA6B,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AAE3G;;;GAGG;AACH,MAAM,OAAO,UAAW,SAAQ,eAAe;IAC7C;;;;;OAKG;IACH,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAC3B,WAAmB,EACnB,OAAiD;QAEjD,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC7B,OAAO,CAAC,YAAY,EAAE,iDAAiD,WAAW,CAAC,MAAM,SAAS,CAAC,CAAA;YACnG,OAAO,IAAI,CAAA;QACb,CAAC;QAED,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,AAAD,EAAG,AAAD,EAAG,AAAD,EAAG,KAAK,CAAC,GAAG,WAAW,CAAA;QAE/C,MAAM,IAAI,GAA4B;YACpC,KAAK,EAAE,iBAAiB,CAAC,YAAY;YACrC,SAAS,EAAE,qBAAqB,CAAC,YAAY;YAC7C,iBAAiB,EAAE,6BAA6B,CAAC,YAAY;YAC7D,MAAM,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,UAAU,CAAC;YAC9B,QAAQ,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,UAAU,CAAC;YAChC,OAAO,EAAE,KAAK,GAAG,UAAU;YAC3B,GAAG,EAAE,CAAC,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC;YAC9B,GAAG,EAAE,CAAC,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC;YAC9B,cAAc,EAAE,CAAC,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC;YACzC,UAAU,EAAE,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;YACnG,QAAQ,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,UAAU,CAAC;SACjC,CAAA;QAED,OAAO,IAAI,CAAA;IACb,CAAC;CACF"}
|
|
@@ -1,8 +1,24 @@
|
|
|
1
1
|
import type { Buffer } from 'node:buffer';
|
|
2
2
|
import type { meterPlusServiceData, meterServiceData } from '../types/bledevicestatus.js';
|
|
3
3
|
import { SwitchbotDevice } from '../device.js';
|
|
4
|
+
/**
|
|
5
|
+
* Class representing a WoSensorTH device.
|
|
6
|
+
* @see https://github.com/OpenWonderLabs/SwitchBotAPI-BLE/blob/latest/devicetypes/meter.md
|
|
7
|
+
*/
|
|
4
8
|
export declare class WoSensorTH extends SwitchbotDevice {
|
|
5
|
-
|
|
6
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Parses the service data for WoSensorTH.
|
|
11
|
+
* @param {Buffer} serviceData - The service data buffer.
|
|
12
|
+
* @param {Function} emitLog - The function to emit log messages.
|
|
13
|
+
* @returns {Promise<meterServiceData | null>} - Parsed service data or null if invalid.
|
|
14
|
+
*/
|
|
15
|
+
static parseServiceData(serviceData: Buffer, emitLog: (level: string, message: string) => void): Promise<meterServiceData | null>;
|
|
16
|
+
/**
|
|
17
|
+
* Parses the service data for WoSensorTH Plus.
|
|
18
|
+
* @param {Buffer} serviceData - The service data buffer.
|
|
19
|
+
* @param {Function} emitLog - The function to emit log messages.
|
|
20
|
+
* @returns {Promise<meterPlusServiceData | null>} - Parsed service data or null if invalid.
|
|
21
|
+
*/
|
|
22
|
+
static parseServiceData_Plus(serviceData: Buffer, emitLog: (level: string, message: string) => void): Promise<meterPlusServiceData | null>;
|
|
7
23
|
}
|
|
8
24
|
//# sourceMappingURL=wosensorth.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wosensorth.d.ts","sourceRoot":"","sources":["../../src/device/wosensorth.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wosensorth.d.ts","sourceRoot":"","sources":["../../src/device/wosensorth.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEzC,OAAO,KAAK,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAEzF,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAG9C;;;GAGG;AACH,qBAAa,UAAW,SAAQ,eAAe;IAC7C;;;;;OAKG;WACU,gBAAgB,CAC3B,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,GAChD,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAuBnC;;;;;OAKG;WACU,qBAAqB,CAChC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,GAChD,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;CAsBxC"}
|
|
@@ -1,77 +1,61 @@
|
|
|
1
|
-
/* Copyright(C) 2024, donavanbecker (https://github.com/donavanbecker). All rights reserved.
|
|
2
|
-
*
|
|
3
|
-
* wosensorth.ts: Switchbot BLE API registration.
|
|
4
|
-
*/
|
|
5
1
|
import { SwitchbotDevice } from '../device.js';
|
|
6
2
|
import { SwitchBotBLEModel, SwitchBotBLEModelFriendlyName, SwitchBotBLEModelName } from '../types/types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Class representing a WoSensorTH device.
|
|
5
|
+
* @see https://github.com/OpenWonderLabs/SwitchBotAPI-BLE/blob/latest/devicetypes/meter.md
|
|
6
|
+
*/
|
|
7
7
|
export class WoSensorTH extends SwitchbotDevice {
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Parses the service data for WoSensorTH.
|
|
10
|
+
* @param {Buffer} serviceData - The service data buffer.
|
|
11
|
+
* @param {Function} emitLog - The function to emit log messages.
|
|
12
|
+
* @returns {Promise<meterServiceData | null>} - Parsed service data or null if invalid.
|
|
13
|
+
*/
|
|
14
|
+
static async parseServiceData(serviceData, emitLog) {
|
|
9
15
|
if (serviceData.length !== 6) {
|
|
10
|
-
|
|
11
|
-
onlog(`[parseServiceDataForWoSensorTH] Buffer length ${serviceData.length} !== 6!`);
|
|
12
|
-
}
|
|
16
|
+
emitLog('debugerror', `[parseServiceDataForWoSensorTH] Buffer length ${serviceData.length} !== 6!`);
|
|
13
17
|
return null;
|
|
14
18
|
}
|
|
15
|
-
const byte2 = serviceData.readUInt8(2);
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
const temp_c = temp_sign * ((byte4 & 0b01111111) + (byte3 & 0b00001111) / 10);
|
|
21
|
-
const temp_f = Math.round(((temp_c * 9 / 5) + 32) * 10) / 10;
|
|
22
|
-
const data = {
|
|
19
|
+
const [byte2, byte3, byte4, byte5] = [serviceData.readUInt8(2), serviceData.readUInt8(3), serviceData.readUInt8(4), serviceData.readUInt8(5)];
|
|
20
|
+
const tempSign = byte4 & 0b10000000 ? 1 : -1;
|
|
21
|
+
const tempC = tempSign * ((byte4 & 0b01111111) + (byte3 & 0b00001111) / 10);
|
|
22
|
+
const tempF = Math.round(((tempC * 9 / 5) + 32) * 10) / 10;
|
|
23
|
+
return {
|
|
23
24
|
model: SwitchBotBLEModel.Meter,
|
|
24
25
|
modelName: SwitchBotBLEModelName.Meter,
|
|
25
26
|
modelFriendlyName: SwitchBotBLEModelFriendlyName.Meter,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
* Use the `celcius` and `fahrenheit` properties directly instead.
|
|
29
|
-
*/
|
|
30
|
-
temperature: {
|
|
31
|
-
c: temp_c,
|
|
32
|
-
f: temp_f,
|
|
33
|
-
},
|
|
34
|
-
celcius: temp_c,
|
|
35
|
-
fahrenheit: temp_f,
|
|
27
|
+
celsius: tempC,
|
|
28
|
+
fahrenheit: tempF,
|
|
36
29
|
fahrenheit_mode: !!(byte5 & 0b10000000),
|
|
37
30
|
humidity: byte5 & 0b01111111,
|
|
38
31
|
battery: byte2 & 0b01111111,
|
|
39
32
|
};
|
|
40
|
-
return data;
|
|
41
33
|
}
|
|
42
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Parses the service data for WoSensorTH Plus.
|
|
36
|
+
* @param {Buffer} serviceData - The service data buffer.
|
|
37
|
+
* @param {Function} emitLog - The function to emit log messages.
|
|
38
|
+
* @returns {Promise<meterPlusServiceData | null>} - Parsed service data or null if invalid.
|
|
39
|
+
*/
|
|
40
|
+
static async parseServiceData_Plus(serviceData, emitLog) {
|
|
43
41
|
if (serviceData.length !== 6) {
|
|
44
|
-
|
|
45
|
-
onlog(`[parseServiceDataForWoSensorTHPlus] Buffer length ${serviceData.length} !== 6!`);
|
|
46
|
-
}
|
|
42
|
+
emitLog('debugerror', `[parseServiceDataForWoSensorTHPlus] Buffer length ${serviceData.length} !== 6!`);
|
|
47
43
|
return null;
|
|
48
44
|
}
|
|
49
|
-
const byte2 = serviceData.readUInt8(2);
|
|
50
|
-
const
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
const temp_c = temp_sign * ((byte4 & 0b01111111) + (byte3 & 0b00001111) / 10);
|
|
55
|
-
const temp_f = Math.round(((temp_c * 9 / 5) + 32) * 10) / 10;
|
|
56
|
-
const data = {
|
|
45
|
+
const [byte2, byte3, byte4, byte5] = [serviceData.readUInt8(2), serviceData.readUInt8(3), serviceData.readUInt8(4), serviceData.readUInt8(5)];
|
|
46
|
+
const tempSign = byte4 & 0b10000000 ? 1 : -1;
|
|
47
|
+
const tempC = tempSign * ((byte4 & 0b01111111) + (byte3 & 0b00001111) / 10);
|
|
48
|
+
const tempF = Math.round(((tempC * 9 / 5) + 32) * 10) / 10;
|
|
49
|
+
return {
|
|
57
50
|
model: SwitchBotBLEModel.MeterPlus,
|
|
58
51
|
modelName: SwitchBotBLEModelName.MeterPlus,
|
|
59
52
|
modelFriendlyName: SwitchBotBLEModelFriendlyName.MeterPlus,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
* Use the `celcius` and `fahrenheit` properties directly instead.
|
|
63
|
-
*/
|
|
64
|
-
temperature: {
|
|
65
|
-
c: temp_c,
|
|
66
|
-
f: temp_f,
|
|
67
|
-
},
|
|
68
|
-
celcius: temp_c,
|
|
69
|
-
fahrenheit: temp_f,
|
|
53
|
+
celsius: tempC,
|
|
54
|
+
fahrenheit: tempF,
|
|
70
55
|
fahrenheit_mode: !!(byte5 & 0b10000000),
|
|
71
56
|
humidity: byte5 & 0b01111111,
|
|
72
57
|
battery: byte2 & 0b01111111,
|
|
73
58
|
};
|
|
74
|
-
return data;
|
|
75
59
|
}
|
|
76
60
|
}
|
|
77
61
|
//# sourceMappingURL=wosensorth.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wosensorth.js","sourceRoot":"","sources":["../../src/device/wosensorth.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wosensorth.js","source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AAC,SAAS;YAC1D,OAAO,EAAE,KAAK;YACd,UAAU,EAAE,KAAK;YACjB,eAAe,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,UAAU,CAAC;YACvC,QAAQ,EAAE,KAAK,GAAG,UAAU;YAC5B,OAAO,EAAE,KAAK,GAAG,UAAU;SAC5B,CAAA;IACH,CAAC;CACF"}
|
|
@@ -2,17 +2,14 @@ import type * as Noble from '@stoprocent/noble';
|
|
|
2
2
|
import type { lockServiceData } from '../types/bledevicestatus.js';
|
|
3
3
|
import { Buffer } from 'node:buffer';
|
|
4
4
|
import { SwitchbotDevice } from '../device.js';
|
|
5
|
+
/**
|
|
6
|
+
* Class representing a WoSmartLock device.
|
|
7
|
+
* @see https://github.com/OpenWonderLabs/SwitchBotAPI-BLE/blob/latest/devicetypes/lock.md
|
|
8
|
+
*/
|
|
5
9
|
export declare class WoSmartLock extends SwitchbotDevice {
|
|
6
10
|
iv: Buffer | null;
|
|
7
11
|
key_id: string;
|
|
8
12
|
encryption_key: Buffer | null;
|
|
9
|
-
static COMMAND_GET_CKiv: string;
|
|
10
|
-
static COMMAND_LOCK_INFO: string;
|
|
11
|
-
static COMMAND_UNLOCK: string;
|
|
12
|
-
static COMMAND_UNLOCK_NO_UNLATCH: string;
|
|
13
|
-
static COMMAND_LOCK: string;
|
|
14
|
-
static COMMAND_ENABLE_NOTIFICATIONS: string;
|
|
15
|
-
static COMMAND_DISABLE_NOTIFICATIONS: string;
|
|
16
13
|
static Result: {
|
|
17
14
|
ERROR: number;
|
|
18
15
|
SUCCESS: number;
|
|
@@ -20,17 +17,70 @@ export declare class WoSmartLock extends SwitchbotDevice {
|
|
|
20
17
|
};
|
|
21
18
|
static validateResponse(res: Buffer): Promise<number>;
|
|
22
19
|
static getLockStatus(code: number): string;
|
|
23
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Parses the service data from the SwitchBot Strip Light.
|
|
22
|
+
* @param {Buffer} serviceData - The service data buffer.
|
|
23
|
+
* @param {Buffer} manufacturerData - The manufacturer data buffer.
|
|
24
|
+
* @param {Function} emitLog - The function to emit log messages.
|
|
25
|
+
* @returns {Promise<lockServiceData | null>} - Parsed service data or null if invalid.
|
|
26
|
+
*/
|
|
27
|
+
static parseServiceData(serviceData: Buffer, manufacturerData: Buffer, emitLog: (level: string, message: string) => void): Promise<lockServiceData | null>;
|
|
24
28
|
constructor(peripheral: Noble.Peripheral, noble: typeof Noble);
|
|
29
|
+
/**
|
|
30
|
+
* Initializes the encryption key info for valid lock communication.
|
|
31
|
+
* @param {string} keyId - The key ID.
|
|
32
|
+
* @param {string} encryptionKey - The encryption key.
|
|
33
|
+
*/
|
|
25
34
|
setKey(keyId: string, encryptionKey: string): Promise<void>;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Unlocks the Smart Lock.
|
|
37
|
+
* @returns {Promise<number>} - The result of the unlock operation.
|
|
38
|
+
*/
|
|
39
|
+
unlock(): Promise<number>;
|
|
40
|
+
/**
|
|
41
|
+
* Unlocks the Smart Lock without unlatching the door.
|
|
42
|
+
* @returns {Promise<number>} - The result of the unlock operation.
|
|
43
|
+
*/
|
|
44
|
+
unlockNoUnlatch(): Promise<number>;
|
|
45
|
+
/**
|
|
46
|
+
* Locks the Smart Lock.
|
|
47
|
+
* @returns {Promise<number>} - The result of the lock operation.
|
|
48
|
+
*/
|
|
49
|
+
lock(): Promise<number>;
|
|
50
|
+
/**
|
|
51
|
+
* Gets general state info from the Smart Lock.
|
|
52
|
+
* @returns {Promise<object | null>} - The state object or null if an error occurred.
|
|
53
|
+
*/
|
|
54
|
+
info(): Promise<object | null>;
|
|
55
|
+
/**
|
|
56
|
+
* Encrypts a string using AES-128-CTR.
|
|
57
|
+
* @param {string} str - The string to encrypt.
|
|
58
|
+
* @returns {Promise<string>} - The encrypted string in hex format.
|
|
59
|
+
*/
|
|
30
60
|
encrypt(str: string): Promise<string>;
|
|
61
|
+
/**
|
|
62
|
+
* Decrypts a buffer using AES-128-CTR.
|
|
63
|
+
* @param {Buffer} data - The data to decrypt.
|
|
64
|
+
* @returns {Promise<Buffer>} - The decrypted data.
|
|
65
|
+
*/
|
|
31
66
|
decrypt(data: Buffer): Promise<Buffer>;
|
|
67
|
+
/**
|
|
68
|
+
* Retrieves the IV from the device.
|
|
69
|
+
* @returns {Promise<Buffer>} - The IV buffer.
|
|
70
|
+
*/
|
|
32
71
|
getIv(): Promise<Buffer>;
|
|
72
|
+
/**
|
|
73
|
+
* Sends an encrypted command to the device.
|
|
74
|
+
* @param {string} key - The command key.
|
|
75
|
+
* @returns {Promise<Buffer>} - The response buffer.
|
|
76
|
+
*/
|
|
33
77
|
encryptedCommand(key: string): Promise<Buffer>;
|
|
34
|
-
|
|
78
|
+
/**
|
|
79
|
+
* Operates the lock with the given command.
|
|
80
|
+
* @param {string} key - The command key.
|
|
81
|
+
* @param {boolean} [encrypt] - Whether to encrypt the command.
|
|
82
|
+
* @returns {Promise<Buffer>} - The response buffer.
|
|
83
|
+
*/
|
|
84
|
+
operateLock(key: string, encrypt?: boolean): Promise<Buffer>;
|
|
35
85
|
}
|
|
36
86
|
//# sourceMappingURL=wosmartlock.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wosmartlock.d.ts","sourceRoot":"","sources":["../../src/device/wosmartlock.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wosmartlock.d.ts","sourceRoot":"","sources":["../../src/device/wosmartlock.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,KAAK,MAAM,mBAAmB,CAAA;AAE/C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAElE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAGpC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAI9C;;;GAGG;AACH,qBAAa,WAAY,SAAQ,eAAe;IACvC,EAAE,EAAE,MAAM,GAAG,IAA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