node-switchbot 3.5.0-beta.0 → 3.5.0-beta.1
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/npm-version-script-esm.js +97 -0
- package/.github/workflows/beta-release.yml +1 -1
- package/.github/workflows/release.yml +1 -1
- package/BLE.md +14 -13
- package/CHANGELOG.md +68 -1
- package/OpenAPI.md +13 -12
- package/branding/Node_x_SwitchBot.svg +2 -3
- package/dist/device.d.ts +1193 -3
- package/dist/device.d.ts.map +1 -1
- package/dist/device.js +2478 -2
- package/dist/device.js.map +1 -1
- package/dist/index.d.ts +0 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -17
- package/dist/index.js.map +1 -1
- package/dist/{test/index.test.d.ts.map → index.test.d.ts.map} +1 -1
- package/dist/{test/index.test.js → index.test.js} +1 -1
- package/dist/index.test.js.map +1 -0
- package/dist/parameter-checker.d.ts +1 -1
- package/dist/parameter-checker.d.ts.map +1 -1
- package/dist/settings.d.ts +12 -28
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +24 -22
- package/dist/settings.js.map +1 -1
- package/dist/{test/settings.test.d.ts.map → settings.test.d.ts.map} +1 -1
- package/dist/{test/settings.test.js → settings.test.js} +6 -6
- package/dist/{test/settings.test.js.map → settings.test.js.map} +1 -1
- package/dist/switchbot-ble.d.ts +1 -1
- package/dist/switchbot-ble.d.ts.map +1 -1
- package/dist/switchbot-ble.js +8 -27
- package/dist/switchbot-ble.js.map +1 -1
- package/dist/switchbot-openapi.d.ts +33 -22
- package/dist/switchbot-openapi.d.ts.map +1 -1
- package/dist/switchbot-openapi.js +104 -64
- package/dist/switchbot-openapi.js.map +1 -1
- package/dist/types/bledevicestatus.d.ts +32 -8
- package/dist/types/bledevicestatus.d.ts.map +1 -1
- package/dist/types/devicestatus.d.ts +35 -1
- package/dist/types/devicestatus.d.ts.map +1 -1
- package/dist/types/devicewebhookstatus.d.ts +38 -1
- package/dist/types/devicewebhookstatus.d.ts.map +1 -1
- package/dist/types/types.d.ts +0 -223
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/types.js +1 -144
- package/dist/types/types.js.map +1 -1
- package/docs/assets/hierarchy.js +1 -0
- package/docs/assets/icons.js +1 -1
- package/docs/assets/icons.svg +1 -1
- package/docs/assets/main.js +5 -5
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/assets/style.css +1405 -1288
- package/docs/classes/Advertising.html +10 -10
- package/docs/classes/SwitchBotBLE.html +13 -13
- package/docs/classes/SwitchBotOpenAPI.html +38 -28
- package/docs/classes/SwitchbotDevice.html +26 -23
- package/docs/classes/WoBlindTilt.html +45 -42
- package/docs/classes/WoBulb.html +42 -39
- package/docs/classes/WoCeilingLight.html +50 -47
- package/docs/classes/WoContact.html +30 -27
- package/docs/classes/WoCurtain.html +40 -37
- package/docs/classes/WoHand.html +37 -34
- package/docs/classes/WoHub2.html +30 -27
- package/docs/classes/WoHumi.html +45 -40
- package/docs/classes/WoHumi2.html +67 -0
- package/docs/classes/WoIOSensorTH.html +30 -27
- package/docs/classes/WoKeypad.html +52 -0
- package/docs/classes/WoLeak.html +53 -0
- package/docs/classes/WoPlugMiniJP.html +78 -0
- package/docs/classes/WoPlugMiniUS.html +39 -36
- package/docs/classes/WoPresence.html +30 -27
- package/docs/classes/WoRelaySwitch1.html +57 -0
- package/docs/classes/WoRelaySwitch1PM.html +57 -0
- package/docs/classes/WoRemote.html +52 -0
- package/docs/classes/WoSensorTH.html +27 -24
- package/docs/classes/WoSensorTHPlus.html +46 -0
- package/docs/classes/WoSensorTHPro.html +46 -0
- package/docs/classes/WoSensorTHProCO2.html +46 -0
- package/docs/classes/WoSmartLock.html +49 -46
- package/docs/classes/WoSmartLockPro.html +49 -46
- package/docs/classes/WoStrip.html +44 -41
- package/docs/enums/LogLevel.html +10 -10
- package/docs/enums/SwitchBotBLEModel.html +29 -27
- package/docs/enums/SwitchBotBLEModelFriendlyName.html +30 -26
- package/docs/enums/SwitchBotBLEModelName.html +28 -26
- package/docs/enums/SwitchBotModel.html +47 -43
- package/docs/hierarchy.html +1 -1
- package/docs/index.html +13 -13
- package/docs/interfaces/AdvertisementData.html +3 -3
- package/docs/interfaces/Chars.html +2 -2
- package/docs/interfaces/ErrorObject.html +2 -2
- package/docs/interfaces/NobleTypes.html +2 -2
- package/docs/interfaces/Params.html +2 -2
- package/docs/interfaces/Rule.html +4 -4
- package/docs/interfaces/ServiceData.html +2 -2
- package/docs/interfaces/SwitchBotBLEDevice.html +23 -23
- package/docs/interfaces/WebhookDetail.html +4 -4
- package/docs/interfaces/ad.html +3 -3
- package/docs/interfaces/body.html +3 -3
- package/docs/interfaces/bodyChange.html +3 -3
- package/docs/interfaces/deleteWebhookResponse.html +3 -3
- package/docs/interfaces/device.html +6 -6
- package/docs/interfaces/deviceList.html +2 -2
- package/docs/interfaces/deviceStatus.html +6 -6
- package/docs/interfaces/deviceStatusRequest.html +3 -3
- package/docs/interfaces/deviceWebhook.html +4 -4
- package/docs/interfaces/deviceWebhookContext.html +4 -4
- package/docs/interfaces/devices.html +3 -3
- package/docs/interfaces/infraredRemoteList.html +2 -2
- package/docs/interfaces/irdevice.html +5 -5
- package/docs/interfaces/pushResponse.html +3 -3
- package/docs/interfaces/queryWebhookResponse.html +3 -3
- package/docs/interfaces/setupWebhookResponse.html +3 -3
- package/docs/interfaces/switchbot.html +2 -2
- package/docs/interfaces/updateWebhookResponse.html +3 -3
- package/docs/interfaces/webhookRequest.html +3 -3
- package/docs/media/BLE.md +14 -13
- package/docs/media/OpenAPI.md +13 -12
- package/docs/modules.html +1 -170
- package/docs/types/MacAddress.html +1 -1
- package/docs/types/batteryCirculatorFan.html +1 -1
- package/docs/types/batteryCirculatorFanServiceData.html +1 -1
- package/docs/types/batteryCirculatorFanStatus.html +1 -1
- package/docs/types/batteryCirculatorFanWebhookContext.html +1 -1
- package/docs/types/blindTilt.html +1 -1
- package/docs/types/blindTiltServiceData.html +1 -1
- package/docs/types/blindTiltStatus.html +1 -1
- package/docs/types/blindTiltWebhookContext.html +1 -1
- package/docs/types/bot.html +1 -1
- package/docs/types/botServiceData.html +1 -1
- package/docs/types/botStatus.html +1 -1
- package/docs/types/botWebhookContext.html +1 -1
- package/docs/types/ceilingLight.html +1 -1
- package/docs/types/ceilingLightPro.html +1 -1
- package/docs/types/ceilingLightProServiceData.html +1 -1
- package/docs/types/ceilingLightProStatus.html +1 -1
- package/docs/types/ceilingLightProWebhookContext.html +1 -1
- package/docs/types/ceilingLightServiceData.html +1 -1
- package/docs/types/ceilingLightStatus.html +1 -1
- package/docs/types/ceilingLightWebhookContext.html +1 -1
- package/docs/types/circulatorFanStatus.html +1 -0
- package/docs/types/circulatorFanWebhookContext.html +1 -0
- package/docs/types/colorBulb.html +1 -1
- package/docs/types/colorBulbServiceData.html +1 -1
- package/docs/types/colorBulbStatus.html +1 -1
- package/docs/types/colorBulbWebhookContext.html +1 -1
- package/docs/types/contactSensor.html +1 -1
- package/docs/types/contactSensorServiceData.html +1 -1
- package/docs/types/contactSensorStatus.html +1 -1
- package/docs/types/contactSensorWebhookContext.html +1 -1
- package/docs/types/curtain.html +1 -1
- package/docs/types/curtain3.html +1 -1
- package/docs/types/curtain3ServiceData.html +1 -1
- package/docs/types/curtain3WebhookContext.html +1 -1
- package/docs/types/curtainServiceData.html +1 -1
- package/docs/types/curtainStatus.html +1 -1
- package/docs/types/curtainWebhookContext.html +1 -1
- package/docs/types/floorCleaningRobotS10.html +1 -1
- package/docs/types/floorCleaningRobotS10Status.html +1 -1
- package/docs/types/floorCleaningRobotS10WebhookContext.html +1 -1
- package/docs/types/hub2.html +1 -1
- package/docs/types/hub2ServiceData.html +1 -1
- package/docs/types/hub2Status.html +1 -1
- package/docs/types/hub2WebhookContext.html +1 -1
- package/docs/types/humidifier.html +1 -1
- package/docs/types/humidifier2ServiceData.html +1 -0
- package/docs/types/humidifier2Status.html +1 -0
- package/docs/types/humidifier2WebhookContext.html +1 -0
- package/docs/types/humidifierServiceData.html +1 -1
- package/docs/types/humidifierStatus.html +1 -1
- package/docs/types/humidifierWebhookContext.html +1 -1
- package/docs/types/indoorCam.html +1 -1
- package/docs/types/indoorCameraWebhookContext.html +1 -1
- package/docs/types/keypad.html +1 -1
- package/docs/types/keypadDetectorServiceData.html +1 -1
- package/docs/types/keypadTouch.html +1 -1
- package/docs/types/keypadTouchWebhookContext.html +1 -1
- package/docs/types/keypadWebhookContext.html +1 -1
- package/docs/types/lock.html +1 -1
- package/docs/types/lockPro.html +1 -1
- package/docs/types/lockProServiceData.html +1 -1
- package/docs/types/lockProStatus.html +1 -1
- package/docs/types/lockProWebhookContext.html +1 -1
- package/docs/types/lockServiceData.html +1 -1
- package/docs/types/lockStatus.html +1 -1
- package/docs/types/lockWebhookContext.html +1 -1
- package/docs/types/meter.html +1 -1
- package/docs/types/meterPlus.html +1 -1
- package/docs/types/meterPlusServiceData.html +1 -1
- package/docs/types/meterPlusStatus.html +1 -1
- package/docs/types/meterPlusWebhookContext.html +1 -1
- package/docs/types/meterPro.html +1 -1
- package/docs/types/meterProCO2ServiceData.html +1 -1
- package/docs/types/meterProCO2Status.html +1 -1
- package/docs/types/meterProCO2WebhookContext.html +1 -1
- package/docs/types/meterProServiceData.html +1 -1
- package/docs/types/meterProStatus.html +1 -1
- package/docs/types/meterProWebhookContext.html +1 -1
- package/docs/types/meterServiceData.html +1 -1
- package/docs/types/meterStatus.html +1 -1
- package/docs/types/meterWebhookContext.html +1 -1
- package/docs/types/motionSensor.html +1 -1
- package/docs/types/motionSensorServiceData.html +1 -1
- package/docs/types/motionSensorStatus.html +1 -1
- package/docs/types/motionSensorWebhookContext.html +1 -1
- package/docs/types/onadvertisement.html +1 -1
- package/docs/types/ondiscover.html +1 -1
- package/docs/types/outdoorMeter.html +1 -1
- package/docs/types/outdoorMeterServiceData.html +1 -1
- package/docs/types/outdoorMeterStatus.html +1 -1
- package/docs/types/outdoorMeterWebhookContext.html +1 -1
- package/docs/types/panTiltCamWebhookContext.html +1 -1
- package/docs/types/pantiltCam.html +1 -1
- package/docs/types/pantiltCam2k.html +1 -1
- package/docs/types/plug.html +1 -1
- package/docs/types/plugMini.html +1 -1
- package/docs/types/plugMiniJPServiceData.html +1 -1
- package/docs/types/plugMiniJPWebhookContext.html +1 -1
- package/docs/types/plugMiniStatus.html +1 -1
- package/docs/types/plugMiniUSServiceData.html +1 -1
- package/docs/types/plugMiniUSWebhookContext.html +1 -1
- package/docs/types/plugStatus.html +1 -1
- package/docs/types/plugWebhookContext.html +1 -1
- package/docs/types/relaySwitch1Context.html +1 -0
- package/docs/types/relaySwitch1PMContext.html +1 -0
- package/docs/types/relaySwitch1PMServiceData.html +1 -1
- package/docs/types/relaySwitch1PMStatus.html +1 -0
- package/docs/types/relaySwitch1ServiceData.html +1 -0
- package/docs/types/relaySwitch1Status.html +1 -0
- package/docs/types/remote.html +1 -1
- package/docs/types/remoteServiceData.html +1 -0
- package/docs/types/robotVacuumCleanerS1.html +1 -1
- package/docs/types/robotVacuumCleanerS1Plus.html +1 -1
- package/docs/types/robotVacuumCleanerS1PlusStatus.html +1 -1
- package/docs/types/robotVacuumCleanerS1PlusWebhookContext.html +1 -1
- package/docs/types/robotVacuumCleanerS1Status.html +1 -1
- package/docs/types/robotVacuumCleanerS1WebhookContext.html +1 -1
- package/docs/types/robotVacuumCleanerServiceData.html +1 -1
- package/docs/types/stripLight.html +1 -1
- package/docs/types/stripLightServiceData.html +1 -1
- package/docs/types/stripLightStatus.html +1 -1
- package/docs/types/stripLightWebhookContext.html +1 -1
- package/docs/types/waterLeakDetector.html +1 -1
- package/docs/types/waterLeakDetectorServiceData.html +1 -1
- package/docs/types/waterLeakDetectorStatus.html +1 -1
- package/docs/types/waterLeakDetectorWebhookContext.html +1 -1
- package/package.json +16 -19
- package/.github/npm-version-script.cjs +0 -81
- package/dist/advertising.d.ts +0 -44
- package/dist/advertising.d.ts.map +0 -1
- package/dist/advertising.js +0 -163
- package/dist/advertising.js.map +0 -1
- package/dist/device/woblindtilt.d.ts +0 -78
- package/dist/device/woblindtilt.d.ts.map +0 -1
- package/dist/device/woblindtilt.js +0 -181
- package/dist/device/woblindtilt.js.map +0 -1
- package/dist/device/wobulb.d.ts +0 -70
- package/dist/device/wobulb.d.ts.map +0 -1
- package/dist/device/wobulb.js +0 -136
- package/dist/device/wobulb.js.map +0 -1
- package/dist/device/woceilinglight.d.ts +0 -74
- package/dist/device/woceilinglight.d.ts.map +0 -1
- package/dist/device/woceilinglight.js +0 -161
- package/dist/device/woceilinglight.js.map +0 -1
- package/dist/device/wocontact.d.ts +0 -19
- package/dist/device/wocontact.d.ts.map +0 -1
- package/dist/device/wocontact.js +0 -48
- package/dist/device/wocontact.js.map +0 -1
- package/dist/device/wocurtain.d.ts +0 -52
- package/dist/device/wocurtain.d.ts.map +0 -1
- package/dist/device/wocurtain.js +0 -135
- package/dist/device/wocurtain.js.map +0 -1
- package/dist/device/wohand.d.ts +0 -50
- package/dist/device/wohand.d.ts.map +0 -1
- package/dist/device/wohand.js +0 -82
- package/dist/device/wohand.js.map +0 -1
- package/dist/device/wohub2.d.ts +0 -19
- package/dist/device/wohub2.d.ts.map +0 -1
- package/dist/device/wohub2.js +0 -40
- package/dist/device/wohub2.js.map +0 -1
- package/dist/device/wohumi.d.ts +0 -50
- package/dist/device/wohumi.d.ts.map +0 -1
- package/dist/device/wohumi.js +0 -89
- package/dist/device/wohumi.js.map +0 -1
- package/dist/device/woiosensorth.d.ts +0 -20
- package/dist/device/woiosensorth.d.ts.map +0 -1
- package/dist/device/woiosensorth.js +0 -49
- package/dist/device/woiosensorth.js.map +0 -1
- package/dist/device/wokeypad.d.ts +0 -19
- package/dist/device/wokeypad.d.ts.map +0 -1
- package/dist/device/wokeypad.js +0 -51
- package/dist/device/wokeypad.js.map +0 -1
- package/dist/device/woleak.d.ts +0 -20
- package/dist/device/woleak.d.ts.map +0 -1
- package/dist/device/woleak.js +0 -52
- package/dist/device/woleak.js.map +0 -1
- package/dist/device/woplugmini.d.ts +0 -52
- package/dist/device/woplugmini.d.ts.map +0 -1
- package/dist/device/woplugmini.js +0 -110
- package/dist/device/woplugmini.js.map +0 -1
- package/dist/device/woplugmini_jp.d.ts +0 -52
- package/dist/device/woplugmini_jp.d.ts.map +0 -1
- package/dist/device/woplugmini_jp.js +0 -110
- package/dist/device/woplugmini_jp.js.map +0 -1
- package/dist/device/wopresence.d.ts +0 -19
- package/dist/device/wopresence.d.ts.map +0 -1
- package/dist/device/wopresence.js +0 -39
- package/dist/device/wopresence.js.map +0 -1
- package/dist/device/worelayswitch1plus.d.ts +0 -36
- package/dist/device/worelayswitch1plus.d.ts.map +0 -1
- package/dist/device/worelayswitch1plus.js +0 -141
- package/dist/device/worelayswitch1plus.js.map +0 -1
- package/dist/device/worelayswitch1pm.d.ts +0 -36
- package/dist/device/worelayswitch1pm.d.ts.map +0 -1
- package/dist/device/worelayswitch1pm.js +0 -144
- package/dist/device/worelayswitch1pm.js.map +0 -1
- package/dist/device/wosensorth.d.ts +0 -13
- package/dist/device/wosensorth.d.ts.map +0 -1
- package/dist/device/wosensorth.js +0 -38
- package/dist/device/wosensorth.js.map +0 -1
- package/dist/device/wosensorthplus.d.ts +0 -13
- package/dist/device/wosensorthplus.d.ts.map +0 -1
- package/dist/device/wosensorthplus.js +0 -38
- package/dist/device/wosensorthplus.js.map +0 -1
- package/dist/device/wosensorthpro.d.ts +0 -13
- package/dist/device/wosensorthpro.d.ts.map +0 -1
- package/dist/device/wosensorthpro.js +0 -38
- package/dist/device/wosensorthpro.js.map +0 -1
- package/dist/device/wosensorthproco2.d.ts +0 -13
- package/dist/device/wosensorthproco2.d.ts.map +0 -1
- package/dist/device/wosensorthproco2.js +0 -40
- package/dist/device/wosensorthproco2.js.map +0 -1
- package/dist/device/wosmartlock.d.ts +0 -86
- package/dist/device/wosmartlock.d.ts.map +0 -1
- package/dist/device/wosmartlock.js +0 -198
- package/dist/device/wosmartlock.js.map +0 -1
- package/dist/device/wosmartlockpro.d.ts +0 -86
- package/dist/device/wosmartlockpro.d.ts.map +0 -1
- package/dist/device/wosmartlockpro.js +0 -200
- package/dist/device/wosmartlockpro.js.map +0 -1
- package/dist/device/wostrip.d.ts +0 -63
- package/dist/device/wostrip.d.ts.map +0 -1
- package/dist/device/wostrip.js +0 -131
- package/dist/device/wostrip.js.map +0 -1
- package/dist/test/advertising.test.d.ts +0 -2
- package/dist/test/advertising.test.d.ts.map +0 -1
- package/dist/test/advertising.test.js +0 -99
- package/dist/test/advertising.test.js.map +0 -1
- package/dist/test/device.test.d.ts +0 -2
- package/dist/test/device.test.d.ts.map +0 -1
- package/dist/test/device.test.js +0 -38
- package/dist/test/device.test.js.map +0 -1
- package/dist/test/index.test.js.map +0 -1
- package/dist/test/parameter-checker.test.d.ts +0 -2
- package/dist/test/parameter-checker.test.d.ts.map +0 -1
- package/dist/test/parameter-checker.test.js +0 -108
- package/dist/test/parameter-checker.test.js.map +0 -1
- package/dist/test/switchbot-ble.test.d.ts +0 -2
- package/dist/test/switchbot-ble.test.d.ts.map +0 -1
- package/dist/test/switchbot-ble.test.js +0 -45
- package/dist/test/switchbot-ble.test.js.map +0 -1
- package/dist/test/switchbot-openapi.test.d.ts +0 -2
- package/dist/test/switchbot-openapi.test.d.ts.map +0 -1
- package/dist/test/switchbot-openapi.test.js +0 -96
- package/dist/test/switchbot-openapi.test.js.map +0 -1
- package/dist/test/woblindtilt.test.d.ts +0 -2
- package/dist/test/woblindtilt.test.d.ts.map +0 -1
- package/dist/test/woblindtilt.test.js +0 -76
- package/dist/test/woblindtilt.test.js.map +0 -1
- package/dist/test/wobulb.test.d.ts +0 -2
- package/dist/test/wobulb.test.d.ts.map +0 -1
- package/dist/test/wobulb.test.js +0 -95
- package/dist/test/wobulb.test.js.map +0 -1
- package/dist/test/woceilinglight.test.d.ts +0 -2
- package/dist/test/woceilinglight.test.d.ts.map +0 -1
- package/dist/test/woceilinglight.test.js +0 -81
- package/dist/test/woceilinglight.test.js.map +0 -1
- package/dist/test/wocontact.test.d.ts +0 -2
- package/dist/test/wocontact.test.d.ts.map +0 -1
- package/dist/test/wocontact.test.js +0 -65
- package/dist/test/wocontact.test.js.map +0 -1
- package/dist/test/wocurtain.test.d.ts +0 -2
- package/dist/test/wocurtain.test.d.ts.map +0 -1
- package/dist/test/wocurtain.test.js +0 -75
- package/dist/test/wocurtain.test.js.map +0 -1
- package/dist/test/wohand.test.d.ts +0 -2
- package/dist/test/wohand.test.d.ts.map +0 -1
- package/dist/test/wohand.test.js +0 -56
- package/dist/test/wohand.test.js.map +0 -1
- package/dist/test/wohub2.test.d.ts +0 -2
- package/dist/test/wohub2.test.d.ts.map +0 -1
- package/dist/test/wohub2.test.js +0 -80
- package/dist/test/wohub2.test.js.map +0 -1
- package/dist/test/wohumi.test.d.ts +0 -2
- package/dist/test/wohumi.test.d.ts.map +0 -1
- package/dist/test/wohumi.test.js +0 -82
- package/dist/test/wohumi.test.js.map +0 -1
- package/dist/test/woiosensorth.test.d.ts +0 -2
- package/dist/test/woiosensorth.test.d.ts.map +0 -1
- package/dist/test/woiosensorth.test.js +0 -40
- package/dist/test/woiosensorth.test.js.map +0 -1
- package/dist/test/wokeypad.test.d.ts +0 -2
- package/dist/test/wokeypad.test.d.ts.map +0 -1
- package/dist/test/wokeypad.test.js +0 -46
- package/dist/test/wokeypad.test.js.map +0 -1
- package/dist/test/woleak.test.d.ts +0 -2
- package/dist/test/woleak.test.d.ts.map +0 -1
- package/dist/test/woleak.test.js +0 -51
- package/dist/test/woleak.test.js.map +0 -1
- package/dist/test/woplugmini.test.d.ts +0 -2
- package/dist/test/woplugmini.test.d.ts.map +0 -1
- package/dist/test/woplugmini.test.js +0 -90
- package/dist/test/woplugmini.test.js.map +0 -1
- package/dist/test/woplugmini_jp.test.d.ts +0 -2
- package/dist/test/woplugmini_jp.test.d.ts.map +0 -1
- package/dist/test/woplugmini_jp.test.js +0 -90
- package/dist/test/woplugmini_jp.test.js.map +0 -1
- package/dist/test/wopresence.test.d.ts +0 -2
- package/dist/test/wopresence.test.d.ts.map +0 -1
- package/dist/test/wopresence.test.js +0 -68
- package/dist/test/wopresence.test.js.map +0 -1
- package/dist/test/wosensorth.test.d.ts +0 -2
- package/dist/test/wosensorth.test.d.ts.map +0 -1
- package/dist/test/wosensorth.test.js +0 -29
- package/dist/test/wosensorth.test.js.map +0 -1
- package/dist/test/wosensorthplus.test.d.ts +0 -2
- package/dist/test/wosensorthplus.test.d.ts.map +0 -1
- package/dist/test/wosensorthplus.test.js +0 -29
- package/dist/test/wosensorthplus.test.js.map +0 -1
- package/dist/test/wosensorthpro.test.d.ts +0 -2
- package/dist/test/wosensorthpro.test.d.ts.map +0 -1
- package/dist/test/wosensorthpro.test.js +0 -29
- package/dist/test/wosensorthpro.test.js.map +0 -1
- package/dist/test/wosensorthproco2.test.d.ts +0 -2
- package/dist/test/wosensorthproco2.test.d.ts.map +0 -1
- package/dist/test/wosensorthproco2.test.js +0 -32
- package/dist/test/wosensorthproco2.test.js.map +0 -1
- package/dist/test/wosmartlock.test.d.ts +0 -2
- package/dist/test/wosmartlock.test.d.ts.map +0 -1
- package/dist/test/wosmartlock.test.js +0 -151
- package/dist/test/wosmartlock.test.js.map +0 -1
- package/dist/test/wosmartlockpro.test.d.ts +0 -2
- package/dist/test/wosmartlockpro.test.d.ts.map +0 -1
- package/dist/test/wosmartlockpro.test.js +0 -150
- package/dist/test/wosmartlockpro.test.js.map +0 -1
- package/dist/test/wostrip.test.d.ts +0 -2
- package/dist/test/wostrip.test.d.ts.map +0 -1
- package/dist/test/wostrip.test.js +0 -102
- package/dist/test/wostrip.test.js.map +0 -1
- package/docs/types/relaySwitch1PlusServiceData.html +0 -1
- /package/dist/{test/index.test.d.ts → index.test.d.ts} +0 -0
- /package/dist/{test/settings.test.d.ts → settings.test.d.ts} +0 -0
package/dist/device/wokeypad.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { SwitchbotDevice } from '../device.js';
|
|
2
|
-
import { SwitchBotBLEModel, SwitchBotBLEModelFriendlyName, SwitchBotBLEModelName } from '../types/types.js';
|
|
3
|
-
/**
|
|
4
|
-
* Class representing a WoKeypad device.
|
|
5
|
-
*/
|
|
6
|
-
export class WoKeypad extends SwitchbotDevice {
|
|
7
|
-
/**
|
|
8
|
-
* Parses the service data for WoKeypad.
|
|
9
|
-
* @param {Buffer} serviceData - The service data buffer.
|
|
10
|
-
* @param {Buffer} manufacturerData - The manufacturer data buffer.
|
|
11
|
-
* @param {Function} emitLog - The function to emit log messages.
|
|
12
|
-
* @returns {Promise<keypadDetectorServiceData | null>} - Parsed service data or null if invalid.
|
|
13
|
-
*/
|
|
14
|
-
static async parseServiceData(serviceData, manufacturerData, emitLog) {
|
|
15
|
-
if (!serviceData || serviceData.length < 3) {
|
|
16
|
-
emitLog('debugerror', `[parseServiceDataForWoKeypad] Service Data Buffer length ${serviceData?.length ?? 0} < 3!`);
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
if (!manufacturerData || manufacturerData.length < 2) {
|
|
20
|
-
emitLog('debugerror', `[parseServiceDataForWoKeypad] Manufacturer Data Buffer length ${manufacturerData?.length ?? 0} < 2!`);
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
const modelId = serviceData.readUInt8(0);
|
|
24
|
-
if (modelId !== 0x26) {
|
|
25
|
-
// Not a Keypad
|
|
26
|
-
emitLog('debugerror', `[parseServiceDataForWoKeypad] Model ID ${modelId} !== 0x26!`);
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
const eventFlags = serviceData.readUInt8(1);
|
|
30
|
-
const keypadEventDetected = !!(eventFlags & 0b00000001); // Bit 0
|
|
31
|
-
const deviceTampered = !!(eventFlags & 0b00000010); // Bit 1
|
|
32
|
-
const batteryInfo = serviceData.readUInt8(2);
|
|
33
|
-
const batteryLevel = batteryInfo & 0b01111111; // Bits 0-6
|
|
34
|
-
const lowBattery = !!(batteryInfo & 0b10000000); // Bit 7
|
|
35
|
-
// Manufacturer data can be processed here if needed
|
|
36
|
-
const data = {
|
|
37
|
-
model: SwitchBotBLEModel.Keypad,
|
|
38
|
-
modelName: SwitchBotBLEModelName.Keypad,
|
|
39
|
-
modelFriendlyName: SwitchBotBLEModelFriendlyName.Keypad,
|
|
40
|
-
event: keypadEventDetected,
|
|
41
|
-
tampered: deviceTampered,
|
|
42
|
-
battery: batteryLevel,
|
|
43
|
-
low_battery: lowBattery,
|
|
44
|
-
};
|
|
45
|
-
return data;
|
|
46
|
-
}
|
|
47
|
-
constructor(peripheral, noble) {
|
|
48
|
-
super(peripheral, noble);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
//# sourceMappingURL=wokeypad.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wokeypad.js","sourceRoot":"","sources":["../../src/device/wokeypad.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,iBAAiB,EAAE,6BAA6B,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AAE3G;;GAEG;AACH,MAAM,OAAO,QAAS,SAAQ,eAAe;IAC3C;;;;;;OAMG;IACH,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAC3B,WAAmB,EACnB,gBAAwB,EACxB,OAAiD;QAEjD,IAAI,CAAC,WAAW,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC3C,OAAO,CAAC,YAAY,EAAE,4DAA4D,WAAW,EAAE,MAAM,IAAI,CAAC,OAAO,CAAC,CAAA;YAClH,OAAO,IAAI,CAAA;QACb,CAAC;QAED,IAAI,CAAC,gBAAgB,IAAI,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACrD,OAAO,CAAC,YAAY,EAAE,iEAAiE,gBAAgB,EAAE,MAAM,IAAI,CAAC,OAAO,CAAC,CAAA;YAC5H,OAAO,IAAI,CAAA;QACb,CAAC;QAED,MAAM,OAAO,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;QAExC,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;YACrB,eAAe;YACf,OAAO,CAAC,YAAY,EAAE,0CAA0C,OAAO,YAAY,CAAC,CAAA;YACpF,OAAO,IAAI,CAAA;QACb,CAAC;QAED,MAAM,UAAU,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;QAC3C,MAAM,mBAAmB,GAAG,CAAC,CAAC,CAAC,UAAU,GAAG,UAAU,CAAC,CAAA,CAAC,QAAQ;QAChE,MAAM,cAAc,GAAG,CAAC,CAAC,CAAC,UAAU,GAAG,UAAU,CAAC,CAAA,CAAC,QAAQ;QAE3D,MAAM,WAAW,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;QAC5C,MAAM,YAAY,GAAG,WAAW,GAAG,UAAU,CAAA,CAAC,WAAW;QACzD,MAAM,UAAU,GAAG,CAAC,CAAC,CAAC,WAAW,GAAG,UAAU,CAAC,CAAA,CAAC,QAAQ;QAExD,oDAAoD;QAEpD,MAAM,IAAI,GAAG;YACX,KAAK,EAAE,iBAAiB,CAAC,MAAM;YAC/B,SAAS,EAAE,qBAAqB,CAAC,MAAM;YACvC,iBAAiB,EAAE,6BAA6B,CAAC,MAAM;YACvD,KAAK,EAAE,mBAAmB;YAC1B,QAAQ,EAAE,cAAc;YACxB,OAAO,EAAE,YAAY;YACrB,WAAW,EAAE,UAAU;SACxB,CAAA;QAED,OAAO,IAAiC,CAAA;IAC1C,CAAC;IAED,YAAY,UAAoC,EAAE,KAA0B;QAC1E,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,CAAA;IAC1B,CAAC;CACF"}
|
package/dist/device/woleak.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { Buffer } from 'node:buffer';
|
|
2
|
-
import type { waterLeakDetectorServiceData } from '../types/bledevicestatus.js';
|
|
3
|
-
import type { NobleTypes } from '../types/types.js';
|
|
4
|
-
import { SwitchbotDevice } from '../device.js';
|
|
5
|
-
/**
|
|
6
|
-
* Class representing a WoLeak device.
|
|
7
|
-
* @see https://github.com/OpenWonderLabs/SwitchBotAPI-BLE/blob/latest/devicetypes/meter.md#outdoor-temperaturehumidity-sensor
|
|
8
|
-
*/
|
|
9
|
-
export declare class WoLeak extends SwitchbotDevice {
|
|
10
|
-
/**
|
|
11
|
-
* Parses the service data for WoLeak.
|
|
12
|
-
* @param {Buffer} serviceData - The service data buffer.
|
|
13
|
-
* @param {Buffer} manufacturerData - The manufacturer data buffer.
|
|
14
|
-
* @param {Function} emitLog - The function to emit log messages.
|
|
15
|
-
* @returns {Promise<leakServiceData | null>} - Parsed service data or null if invalid.
|
|
16
|
-
*/
|
|
17
|
-
static parseServiceData(serviceData: Buffer, manufacturerData: Buffer, emitLog: (level: string, message: string) => void): Promise<waterLeakDetectorServiceData | null>;
|
|
18
|
-
constructor(peripheral: NobleTypes['peripheral'], noble: NobleTypes['noble']);
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=woleak.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"woleak.d.ts","sourceRoot":"","sources":["../../src/device/woleak.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEzC,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,6BAA6B,CAAA;AAC/E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAEnD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAG9C;;;GAGG;AACH,qBAAa,MAAO,SAAQ,eAAe;IACzC;;;;;;OAMG;WACU,gBAAgB,CAC3B,WAAW,EAAE,MAAM,EACnB,gBAAgB,EAAE,MAAM,EACxB,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,GAChD,OAAO,CAAC,4BAA4B,GAAG,IAAI,CAAC;gBA0CnC,UAAU,EAAE,UAAU,CAAC,YAAY,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC;CAG7E"}
|
package/dist/device/woleak.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { SwitchbotDevice } from '../device.js';
|
|
2
|
-
import { SwitchBotBLEModel, SwitchBotBLEModelFriendlyName, SwitchBotBLEModelName } from '../types/types.js';
|
|
3
|
-
/**
|
|
4
|
-
* Class representing a WoLeak device.
|
|
5
|
-
* @see https://github.com/OpenWonderLabs/SwitchBotAPI-BLE/blob/latest/devicetypes/meter.md#outdoor-temperaturehumidity-sensor
|
|
6
|
-
*/
|
|
7
|
-
export class WoLeak extends SwitchbotDevice {
|
|
8
|
-
/**
|
|
9
|
-
* Parses the service data for WoLeak.
|
|
10
|
-
* @param {Buffer} serviceData - The service data buffer.
|
|
11
|
-
* @param {Buffer} manufacturerData - The manufacturer data buffer.
|
|
12
|
-
* @param {Function} emitLog - The function to emit log messages.
|
|
13
|
-
* @returns {Promise<leakServiceData | null>} - Parsed service data or null if invalid.
|
|
14
|
-
*/
|
|
15
|
-
static async parseServiceData(serviceData, manufacturerData, emitLog) {
|
|
16
|
-
if (!serviceData || serviceData.length < 3) {
|
|
17
|
-
emitLog('debugerror', `[parseServiceDataForWoLeakDetector] Service Data Buffer length ${serviceData?.length ?? 0} < 3!`);
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
if (!manufacturerData || manufacturerData.length < 2) {
|
|
21
|
-
emitLog('debugerror', `[parseServiceDataForWoLeakDetector] Manufacturer Data Buffer length ${manufacturerData?.length ?? 0} < 2!`);
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
const modelId = serviceData.readUInt8(0);
|
|
25
|
-
if (modelId !== 0x26) {
|
|
26
|
-
// Not a Water Leak Detector
|
|
27
|
-
emitLog('debugerror', `[parseServiceDataForWoLeakDetector] Model ID ${modelId} !== 0x26!`);
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
30
|
-
const eventFlags = serviceData.readUInt8(1);
|
|
31
|
-
const waterLeakDetected = !!(eventFlags & 0b00000001); // Bit 0
|
|
32
|
-
const deviceTampered = !!(eventFlags & 0b00000010); // Bit 1
|
|
33
|
-
const batteryInfo = serviceData.readUInt8(2);
|
|
34
|
-
const batteryLevel = batteryInfo & 0b01111111; // Bits 0-6
|
|
35
|
-
const lowBattery = !!(batteryInfo & 0b10000000); // Bit 7
|
|
36
|
-
// Manufacturer data can be processed here if needed
|
|
37
|
-
const data = {
|
|
38
|
-
model: SwitchBotBLEModel.Leak,
|
|
39
|
-
modelName: SwitchBotBLEModelName.Leak,
|
|
40
|
-
modelFriendlyName: SwitchBotBLEModelFriendlyName.Leak,
|
|
41
|
-
leak: waterLeakDetected,
|
|
42
|
-
tampered: deviceTampered,
|
|
43
|
-
battery: batteryLevel,
|
|
44
|
-
low_battery: lowBattery,
|
|
45
|
-
};
|
|
46
|
-
return data;
|
|
47
|
-
}
|
|
48
|
-
constructor(peripheral, noble) {
|
|
49
|
-
super(peripheral, noble);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
//# sourceMappingURL=woleak.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"woleak.js","sourceRoot":"","sources":["../../src/device/woleak.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,iBAAiB,EAAE,6BAA6B,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AAE3G;;;GAGG;AACH,MAAM,OAAO,MAAO,SAAQ,eAAe;IACzC;;;;;;OAMG;IACH,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAC3B,WAAmB,EACnB,gBAAwB,EACxB,OAAiD;QAEjD,IAAI,CAAC,WAAW,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC3C,OAAO,CAAC,YAAY,EAAE,kEAAkE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ED,OAAO,IAAoC,CAAA;IAC7C,CAAC;IAED,YAAY,UAAoC,EAAE,KAA0B;QAC1E,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,CAAA;IAC1B,CAAC;CACF"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import type { plugMiniUSServiceData } from '../types/bledevicestatus.js';
|
|
2
|
-
import type { NobleTypes } from '../types/types.js';
|
|
3
|
-
import { Buffer } from 'node:buffer';
|
|
4
|
-
import { SwitchbotDevice } from '../device.js';
|
|
5
|
-
/**
|
|
6
|
-
* Class representing a WoPlugMini device.
|
|
7
|
-
* @see https://github.com/OpenWonderLabs/SwitchBotAPI-BLE/blob/latest/devicetypes/plugmini.md
|
|
8
|
-
*/
|
|
9
|
-
export declare class WoPlugMiniUS extends SwitchbotDevice {
|
|
10
|
-
constructor(peripheral: NobleTypes['peripheral'], noble: NobleTypes['noble']);
|
|
11
|
-
/**
|
|
12
|
-
* Parses the service data for WoPlugMini US.
|
|
13
|
-
* @param {Buffer} manufacturerData - The manufacturer data buffer.
|
|
14
|
-
* @param {Function} emitLog - The function to emit log messages.
|
|
15
|
-
* @returns {Promise<plugMiniUSServiceData | null>} - Parsed service data or null if invalid.
|
|
16
|
-
*/
|
|
17
|
-
static parseServiceData(manufacturerData: Buffer, emitLog: (level: string, message: string) => void): Promise<plugMiniUSServiceData | null>;
|
|
18
|
-
/**
|
|
19
|
-
* Reads the state of the plug.
|
|
20
|
-
* @returns {Promise<boolean>} - Resolves with a boolean that tells whether the plug is ON (true) or OFF (false).
|
|
21
|
-
*/
|
|
22
|
-
readState(): Promise<boolean>;
|
|
23
|
-
/**
|
|
24
|
-
* Sets the state of the plug.
|
|
25
|
-
* @private
|
|
26
|
-
* @param {number[]} reqByteArray - The request byte array.
|
|
27
|
-
* @returns {Promise<boolean>} - Resolves with a boolean that tells whether the plug is ON (true) or OFF (false).
|
|
28
|
-
*/
|
|
29
|
-
private setState;
|
|
30
|
-
/**
|
|
31
|
-
* Turns on the plug.
|
|
32
|
-
* @returns {Promise<boolean>} - Resolves with a boolean that tells whether the plug is ON (true) or OFF (false).
|
|
33
|
-
*/
|
|
34
|
-
turnOn(): Promise<boolean>;
|
|
35
|
-
/**
|
|
36
|
-
* Turns off the plug.
|
|
37
|
-
* @returns {Promise<boolean>} - Resolves with a boolean that tells whether the plug is ON (true) or OFF (false).
|
|
38
|
-
*/
|
|
39
|
-
turnOff(): Promise<boolean>;
|
|
40
|
-
/**
|
|
41
|
-
* Toggles the state of the plug.
|
|
42
|
-
* @returns {Promise<boolean>} - Resolves with a boolean that tells whether the plug is ON (true) or OFF (false).
|
|
43
|
-
*/
|
|
44
|
-
toggle(): Promise<boolean>;
|
|
45
|
-
/**
|
|
46
|
-
* Operates the plug with the given bytes.
|
|
47
|
-
* @param {number[]} bytes - The byte array to send to the plug.
|
|
48
|
-
* @returns {Promise<boolean>} - Resolves with a boolean that tells whether the plug is ON (true) or OFF (false).
|
|
49
|
-
*/
|
|
50
|
-
operatePlug(bytes: number[]): Promise<boolean>;
|
|
51
|
-
}
|
|
52
|
-
//# sourceMappingURL=woplugmini.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"woplugmini.d.ts","sourceRoot":"","sources":["../../src/device/woplugmini.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAA;AACxE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAEnD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAG9C;;;GAGG;AACH,qBAAa,YAAa,SAAQ,eAAe;gBACnC,UAAU,EAAE,UAAU,CAAC,YAAY,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC;IAI5E;;;;;OAKG;WACU,gBAAgB,CAC3B,gBAAgB,EAAE,MAAM,EACxB,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,GAChD,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC;IAsCxC;;;OAGG;IACG,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC;IAInC;;;;;OAKG;YACW,QAAQ;IAKtB;;;OAGG;IACG,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC;IAIhC;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC;IAIjC;;;OAGG;IACG,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC;IAIhC;;;;OAIG;IACU,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;CAgB5D"}
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { Buffer } from 'node:buffer';
|
|
2
|
-
import { SwitchbotDevice } from '../device.js';
|
|
3
|
-
import { SwitchBotBLEModel, SwitchBotBLEModelFriendlyName, SwitchBotBLEModelName } from '../types/types.js';
|
|
4
|
-
/**
|
|
5
|
-
* Class representing a WoPlugMini device.
|
|
6
|
-
* @see https://github.com/OpenWonderLabs/SwitchBotAPI-BLE/blob/latest/devicetypes/plugmini.md
|
|
7
|
-
*/
|
|
8
|
-
export class WoPlugMiniUS extends SwitchbotDevice {
|
|
9
|
-
constructor(peripheral, noble) {
|
|
10
|
-
super(peripheral, noble);
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Parses the service data for WoPlugMini US.
|
|
14
|
-
* @param {Buffer} manufacturerData - The manufacturer data buffer.
|
|
15
|
-
* @param {Function} emitLog - The function to emit log messages.
|
|
16
|
-
* @returns {Promise<plugMiniUSServiceData | null>} - Parsed service data or null if invalid.
|
|
17
|
-
*/
|
|
18
|
-
static async parseServiceData(manufacturerData, emitLog) {
|
|
19
|
-
if (manufacturerData.length !== 14) {
|
|
20
|
-
emitLog('debugerror', `[parseServiceDataForWoPlugMini] Buffer length ${manufacturerData.length} should be 14`);
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
const [byte9, byte10, byte11, byte12, byte13] = [
|
|
24
|
-
manufacturerData.readUInt8(9),
|
|
25
|
-
manufacturerData.readUInt8(10),
|
|
26
|
-
manufacturerData.readUInt8(11),
|
|
27
|
-
manufacturerData.readUInt8(12),
|
|
28
|
-
manufacturerData.readUInt8(13),
|
|
29
|
-
];
|
|
30
|
-
const state = byte9 === 0x00 ? 'off' : byte9 === 0x80 ? 'on' : null;
|
|
31
|
-
const delay = !!(byte10 & 0b00000001);
|
|
32
|
-
const timer = !!(byte10 & 0b00000010);
|
|
33
|
-
const syncUtcTime = !!(byte10 & 0b00000100);
|
|
34
|
-
const wifiRssi = byte11;
|
|
35
|
-
const overload = !!(byte12 & 0b10000000);
|
|
36
|
-
const currentPower = (((byte12 & 0b01111111) << 8) + byte13) / 10; // in watt
|
|
37
|
-
const data = {
|
|
38
|
-
model: SwitchBotBLEModel.PlugMiniUS,
|
|
39
|
-
modelName: SwitchBotBLEModelName.PlugMini,
|
|
40
|
-
modelFriendlyName: SwitchBotBLEModelFriendlyName.PlugMini,
|
|
41
|
-
state: state ?? 'unknown',
|
|
42
|
-
delay,
|
|
43
|
-
timer,
|
|
44
|
-
syncUtcTime,
|
|
45
|
-
wifiRssi,
|
|
46
|
-
overload,
|
|
47
|
-
currentPower,
|
|
48
|
-
};
|
|
49
|
-
return data;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Reads the state of the plug.
|
|
53
|
-
* @returns {Promise<boolean>} - Resolves with a boolean that tells whether the plug is ON (true) or OFF (false).
|
|
54
|
-
*/
|
|
55
|
-
async readState() {
|
|
56
|
-
return this.operatePlug([0x57, 0x0F, 0x51, 0x01]);
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Sets the state of the plug.
|
|
60
|
-
* @private
|
|
61
|
-
* @param {number[]} reqByteArray - The request byte array.
|
|
62
|
-
* @returns {Promise<boolean>} - Resolves with a boolean that tells whether the plug is ON (true) or OFF (false).
|
|
63
|
-
*/
|
|
64
|
-
async setState(reqByteArray) {
|
|
65
|
-
const base = [0x57, 0x0F, 0x50, 0x01];
|
|
66
|
-
return this.operatePlug([...base, ...reqByteArray]);
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Turns on the plug.
|
|
70
|
-
* @returns {Promise<boolean>} - Resolves with a boolean that tells whether the plug is ON (true) or OFF (false).
|
|
71
|
-
*/
|
|
72
|
-
async turnOn() {
|
|
73
|
-
return this.setState([0x01, 0x80]);
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Turns off the plug.
|
|
77
|
-
* @returns {Promise<boolean>} - Resolves with a boolean that tells whether the plug is ON (true) or OFF (false).
|
|
78
|
-
*/
|
|
79
|
-
async turnOff() {
|
|
80
|
-
return this.setState([0x01, 0x00]);
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Toggles the state of the plug.
|
|
84
|
-
* @returns {Promise<boolean>} - Resolves with a boolean that tells whether the plug is ON (true) or OFF (false).
|
|
85
|
-
*/
|
|
86
|
-
async toggle() {
|
|
87
|
-
return this.setState([0x02, 0x80]);
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Operates the plug with the given bytes.
|
|
91
|
-
* @param {number[]} bytes - The byte array to send to the plug.
|
|
92
|
-
* @returns {Promise<boolean>} - Resolves with a boolean that tells whether the plug is ON (true) or OFF (false).
|
|
93
|
-
*/
|
|
94
|
-
async operatePlug(bytes) {
|
|
95
|
-
const reqBuf = Buffer.from(bytes);
|
|
96
|
-
const resBytes = await this.command(reqBuf);
|
|
97
|
-
const resBuf = Buffer.from(resBytes);
|
|
98
|
-
if (resBuf.length !== 2) {
|
|
99
|
-
throw new Error(`Expecting a 2-byte response, got instead: 0x${resBuf.toString('hex')}`);
|
|
100
|
-
}
|
|
101
|
-
const code = resBuf.readUInt8(1);
|
|
102
|
-
if (code === 0x00 || code === 0x80) {
|
|
103
|
-
return code === 0x80;
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
throw new Error(`The device returned an error: 0x${resBuf.toString('hex')}`);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
//# sourceMappingURL=woplugmini.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"woplugmini.js","sourceRoot":"","sources":["../../src/device/woplugmini.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,iBAAiB,EAAE,6BAA6B,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AAE3G;;;GAGG;AACH,MAAM,OAAO,YAAa,SAAQ,eAAe;IAC/C,YAAY,UAAoC,EAAE,KAA0B;QAC1E,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,CAAA;IAC1B,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAC3B,gBAAwB,EACxB,OAAiD;QAEjD,IAAI,gBAAgB,CAAC,MAAM,KAAK,EAAE,EAAE,CAAC;YACnC,OAAO,CAAC,YAAY,EAAE,iDAAiD,gBAAgB,CAAC,MAAM,eAAe,CAAC,CAAA;YAC9G,OAAO,IAAI,CAAA;QACb,CAAC;QAED,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG;YAC9C,gBAAgB,CAAC,SAAS,CAAC,CAAC,CAAC;YAC7B,gBAAgB,CAAC,SAAS,CAAC,EAAE,CAAC;YAC9B,gBAAgB,CAAC,SAAS,CAAC,EAAE,CAAC;YAC9B,gBAAgB,CAAC,SAAS,CAAC,EAAE,CAAC;YAC9B,gBAAgB,CAAC,SAAS,CAAC,EAAE,CAAC;SAC/B,CAAA;QAED,MAAM,KAAK,GAAG,KAAK,KAAK,IAAI,CAAC,CAAC,CAA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/types.js';
|
|
3
|
-
import { Buffer } from 'node:buffer';
|
|
4
|
-
import { SwitchbotDevice } from '../device.js';
|
|
5
|
-
/**
|
|
6
|
-
* Class representing a WoPlugMini device.
|
|
7
|
-
* @see https://github.com/OpenWonderLabs/SwitchBotAPI-BLE/blob/latest/devicetypes/plugmini.md
|
|
8
|
-
*/
|
|
9
|
-
export declare class WoPlugMiniJP extends SwitchbotDevice {
|
|
10
|
-
constructor(peripheral: NobleTypes['peripheral'], noble: NobleTypes['noble']);
|
|
11
|
-
/**
|
|
12
|
-
* Parses the service data for WoPlugMini JP.
|
|
13
|
-
* @param {Buffer} manufacturerData - The manufacturer data buffer.
|
|
14
|
-
* @param {Function} emitLog - The function to emit log messages.
|
|
15
|
-
* @returns {Promise<plugMiniJPServiceData | null>} - Parsed service data or null if invalid.
|
|
16
|
-
*/
|
|
17
|
-
static parseServiceData(manufacturerData: Buffer, emitLog: (level: string, message: string) => void): Promise<plugMiniJPServiceData | null>;
|
|
18
|
-
/**
|
|
19
|
-
* Reads the state of the plug.
|
|
20
|
-
* @returns {Promise<boolean>} - Resolves with a boolean that tells whether the plug is ON (true) or OFF (false).
|
|
21
|
-
*/
|
|
22
|
-
readState(): Promise<boolean>;
|
|
23
|
-
/**
|
|
24
|
-
* Sets the state of the plug.
|
|
25
|
-
* @private
|
|
26
|
-
* @param {number[]} reqByteArray - The request byte array.
|
|
27
|
-
* @returns {Promise<boolean>} - Resolves with a boolean that tells whether the plug is ON (true) or OFF (false).
|
|
28
|
-
*/
|
|
29
|
-
private setState;
|
|
30
|
-
/**
|
|
31
|
-
* Turns on the plug.
|
|
32
|
-
* @returns {Promise<boolean>} - Resolves with a boolean that tells whether the plug is ON (true) or OFF (false).
|
|
33
|
-
*/
|
|
34
|
-
turnOn(): Promise<boolean>;
|
|
35
|
-
/**
|
|
36
|
-
* Turns off the plug.
|
|
37
|
-
* @returns {Promise<boolean>} - Resolves with a boolean that tells whether the plug is ON (true) or OFF (false).
|
|
38
|
-
*/
|
|
39
|
-
turnOff(): Promise<boolean>;
|
|
40
|
-
/**
|
|
41
|
-
* Toggles the state of the plug.
|
|
42
|
-
* @returns {Promise<boolean>} - Resolves with a boolean that tells whether the plug is ON (true) or OFF (false).
|
|
43
|
-
*/
|
|
44
|
-
toggle(): Promise<boolean>;
|
|
45
|
-
/**
|
|
46
|
-
* Operates the plug with the given bytes.
|
|
47
|
-
* @param {number[]} bytes - The byte array to send to the plug.
|
|
48
|
-
* @returns {Promise<boolean>} - Resolves with a boolean that tells whether the plug is ON (true) or OFF (false).
|
|
49
|
-
*/
|
|
50
|
-
operatePlug(bytes: number[]): Promise<boolean>;
|
|
51
|
-
}
|
|
52
|
-
//# sourceMappingURL=woplugmini_jp.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"woplugmini_jp.d.ts","sourceRoot":"","sources":["../../src/device/woplugmini_jp.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAA;AACxE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAEnD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAG9C;;;GAGG;AACH,qBAAa,YAAa,SAAQ,eAAe;gBACnC,UAAU,EAAE,UAAU,CAAC,YAAY,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC;IAI5E;;;;;OAKG;WACU,gBAAgB,CAC3B,gBAAgB,EAAE,MAAM,EACxB,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,GAChD,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC;IAsCxC;;;OAGG;IACG,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC;IAInC;;;;;OAKG;YACW,QAAQ;IAKtB;;;OAGG;IACG,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC;IAIhC;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC;IAIjC;;;OAGG;IACG,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC;IAIhC;;;;OAIG;IACU,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;CAgB5D"}
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { Buffer } from 'node:buffer';
|
|
2
|
-
import { SwitchbotDevice } from '../device.js';
|
|
3
|
-
import { SwitchBotBLEModel, SwitchBotBLEModelFriendlyName, SwitchBotBLEModelName } from '../types/types.js';
|
|
4
|
-
/**
|
|
5
|
-
* Class representing a WoPlugMini device.
|
|
6
|
-
* @see https://github.com/OpenWonderLabs/SwitchBotAPI-BLE/blob/latest/devicetypes/plugmini.md
|
|
7
|
-
*/
|
|
8
|
-
export class WoPlugMiniJP extends SwitchbotDevice {
|
|
9
|
-
constructor(peripheral, noble) {
|
|
10
|
-
super(peripheral, noble);
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Parses the service data for WoPlugMini JP.
|
|
14
|
-
* @param {Buffer} manufacturerData - The manufacturer data buffer.
|
|
15
|
-
* @param {Function} emitLog - The function to emit log messages.
|
|
16
|
-
* @returns {Promise<plugMiniJPServiceData | null>} - Parsed service data or null if invalid.
|
|
17
|
-
*/
|
|
18
|
-
static async parseServiceData(manufacturerData, emitLog) {
|
|
19
|
-
if (manufacturerData.length !== 14) {
|
|
20
|
-
emitLog('debugerror', `[parseServiceDataForWoPlugMiniJP] Buffer length ${manufacturerData.length} should be 14`);
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
const [byte9, byte10, byte11, byte12, byte13] = [
|
|
24
|
-
manufacturerData.readUInt8(9),
|
|
25
|
-
manufacturerData.readUInt8(10),
|
|
26
|
-
manufacturerData.readUInt8(11),
|
|
27
|
-
manufacturerData.readUInt8(12),
|
|
28
|
-
manufacturerData.readUInt8(13),
|
|
29
|
-
];
|
|
30
|
-
const state = byte9 === 0x00 ? 'off' : byte9 === 0x80 ? 'on' : null;
|
|
31
|
-
const delay = !!(byte10 & 0b00000001);
|
|
32
|
-
const timer = !!(byte10 & 0b00000010);
|
|
33
|
-
const syncUtcTime = !!(byte10 & 0b00000100);
|
|
34
|
-
const wifiRssi = byte11;
|
|
35
|
-
const overload = !!(byte12 & 0b10000000);
|
|
36
|
-
const currentPower = (((byte12 & 0b01111111) << 8) + byte13) / 10; // in watt
|
|
37
|
-
const data = {
|
|
38
|
-
model: SwitchBotBLEModel.PlugMiniJP,
|
|
39
|
-
modelName: SwitchBotBLEModelName.PlugMini,
|
|
40
|
-
modelFriendlyName: SwitchBotBLEModelFriendlyName.PlugMini,
|
|
41
|
-
state: state ?? 'unknown',
|
|
42
|
-
delay,
|
|
43
|
-
timer,
|
|
44
|
-
syncUtcTime,
|
|
45
|
-
wifiRssi,
|
|
46
|
-
overload,
|
|
47
|
-
currentPower,
|
|
48
|
-
};
|
|
49
|
-
return data;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Reads the state of the plug.
|
|
53
|
-
* @returns {Promise<boolean>} - Resolves with a boolean that tells whether the plug is ON (true) or OFF (false).
|
|
54
|
-
*/
|
|
55
|
-
async readState() {
|
|
56
|
-
return this.operatePlug([0x57, 0x0F, 0x51, 0x01]);
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Sets the state of the plug.
|
|
60
|
-
* @private
|
|
61
|
-
* @param {number[]} reqByteArray - The request byte array.
|
|
62
|
-
* @returns {Promise<boolean>} - Resolves with a boolean that tells whether the plug is ON (true) or OFF (false).
|
|
63
|
-
*/
|
|
64
|
-
async setState(reqByteArray) {
|
|
65
|
-
const base = [0x57, 0x0F, 0x50, 0x01];
|
|
66
|
-
return this.operatePlug([...base, ...reqByteArray]);
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Turns on the plug.
|
|
70
|
-
* @returns {Promise<boolean>} - Resolves with a boolean that tells whether the plug is ON (true) or OFF (false).
|
|
71
|
-
*/
|
|
72
|
-
async turnOn() {
|
|
73
|
-
return this.setState([0x01, 0x80]);
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Turns off the plug.
|
|
77
|
-
* @returns {Promise<boolean>} - Resolves with a boolean that tells whether the plug is ON (true) or OFF (false).
|
|
78
|
-
*/
|
|
79
|
-
async turnOff() {
|
|
80
|
-
return this.setState([0x01, 0x00]);
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Toggles the state of the plug.
|
|
84
|
-
* @returns {Promise<boolean>} - Resolves with a boolean that tells whether the plug is ON (true) or OFF (false).
|
|
85
|
-
*/
|
|
86
|
-
async toggle() {
|
|
87
|
-
return this.setState([0x02, 0x80]);
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Operates the plug with the given bytes.
|
|
91
|
-
* @param {number[]} bytes - The byte array to send to the plug.
|
|
92
|
-
* @returns {Promise<boolean>} - Resolves with a boolean that tells whether the plug is ON (true) or OFF (false).
|
|
93
|
-
*/
|
|
94
|
-
async operatePlug(bytes) {
|
|
95
|
-
const reqBuf = Buffer.from(bytes);
|
|
96
|
-
const resBytes = await this.command(reqBuf);
|
|
97
|
-
const resBuf = Buffer.from(resBytes);
|
|
98
|
-
if (resBuf.length !== 2) {
|
|
99
|
-
throw new Error(`Expecting a 2-byte response, got instead: 0x${resBuf.toString('hex')}`);
|
|
100
|
-
}
|
|
101
|
-
const code = resBuf.readUInt8(1);
|
|
102
|
-
if (code === 0x00 || code === 0x80) {
|
|
103
|
-
return code === 0x80;
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
throw new Error(`The device returned an error: 0x${resBuf.toString('hex')}`);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
//# sourceMappingURL=woplugmini_jp.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"woplugmini_j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AC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;IACpC,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,MAAM;QACV,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;IACpC,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,WAAW,CAAC,KAAe;QACtC,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACjC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QAC3C,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QAEpC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,+CAA+C,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;QAC1F,CAAC;QAED,MAAM,IAAI,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;QAChC,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;YACnC,OAAO,IAAI,KAAK,IAAI,CAAA;QACtB,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,mCAAmC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;QAC9E,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { Buffer } from 'node:buffer';
|
|
2
|
-
import type { motionSensorServiceData } from '../types/bledevicestatus.js';
|
|
3
|
-
import type { NobleTypes } from '../types/types.js';
|
|
4
|
-
import { SwitchbotDevice } from '../device.js';
|
|
5
|
-
/**
|
|
6
|
-
* Class representing a WoPresence device.
|
|
7
|
-
* @see https://github.com/OpenWonderLabs/SwitchBotAPI-BLE/blob/latest/devicetypes/meter.md
|
|
8
|
-
*/
|
|
9
|
-
export declare class WoPresence extends SwitchbotDevice {
|
|
10
|
-
/**
|
|
11
|
-
* Parses the service data for WoPresence.
|
|
12
|
-
* @param {Buffer} serviceData - The service data buffer.
|
|
13
|
-
* @param {Function} emitLog - The function to emit log messages.
|
|
14
|
-
* @returns {Promise<motionSensorServiceData | null>} - Parsed service data or null if invalid.
|
|
15
|
-
*/
|
|
16
|
-
static parseServiceData(serviceData: Buffer, emitLog: (level: string, message: string) => void): Promise<motionSensorServiceData | null>;
|
|
17
|
-
constructor(peripheral: NobleTypes['peripheral'], noble: NobleTypes['noble']);
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=wopresence.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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;AAC1E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAEnD,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;gBAyB9B,UAAU,EAAE,UAAU,CAAC,YAAY,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC;CAG7E"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { SwitchbotDevice } from '../device.js';
|
|
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
|
-
export class WoPresence extends SwitchbotDevice {
|
|
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) {
|
|
15
|
-
if (serviceData.length !== 6) {
|
|
16
|
-
emitLog('debugerror', `[parseServiceDataForWoPresence] Buffer length ${serviceData.length} !== 6!`);
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
const [byte1, byte2, , , , byte5] = serviceData;
|
|
20
|
-
const data = {
|
|
21
|
-
model: SwitchBotBLEModel.MotionSensor,
|
|
22
|
-
modelName: SwitchBotBLEModelName.MotionSensor,
|
|
23
|
-
modelFriendlyName: SwitchBotBLEModelFriendlyName.MotionSensor,
|
|
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),
|
|
32
|
-
};
|
|
33
|
-
return data;
|
|
34
|
-
}
|
|
35
|
-
constructor(peripheral, noble) {
|
|
36
|
-
super(peripheral, noble);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=wopresence.js.map
|
|
@@ -1 +0,0 @@
|
|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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;IAED,YAAY,UAAoC,EAAE,KAA0B;QAC1E,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,CAAA;IAC1B,CAAC;CACF"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { relaySwitch1PlusServiceData } from '../types/bledevicestatus.js';
|
|
2
|
-
import type { NobleTypes } from '../types/types.js';
|
|
3
|
-
import { Buffer } from 'node:buffer';
|
|
4
|
-
import { SwitchbotDevice } from '../device.js';
|
|
5
|
-
/**
|
|
6
|
-
* Class representing a WoRelaySwitch1Plus device.
|
|
7
|
-
* @see https://github.com/OpenWonderLabs/SwitchBotAPI-BLE/
|
|
8
|
-
*/
|
|
9
|
-
export declare class WoRelaySwitch1Plus extends SwitchbotDevice {
|
|
10
|
-
private _iv;
|
|
11
|
-
private _cipher;
|
|
12
|
-
private _keyId;
|
|
13
|
-
private _encryptionKey;
|
|
14
|
-
constructor(peripheral: NobleTypes['peripheral'], noble: NobleTypes['noble']);
|
|
15
|
-
/**
|
|
16
|
-
* Parses the service data for WoRelaySwitch1Plus.
|
|
17
|
-
* @param {Buffer} serviceData - The service data buffer.
|
|
18
|
-
* @param {Buffer} manufacturerData - The manufacturer data buffer.
|
|
19
|
-
* @param {Function} emitLog - The function to emit log messages.
|
|
20
|
-
* @returns {Promise<relaySwitch1PlusServiceData | null>} - Parsed service data or null if invalid.
|
|
21
|
-
*/
|
|
22
|
-
static parseServiceData(serviceData: Buffer, manufacturerData: Buffer, emitLog: (level: string, message: string) => void): Promise<relaySwitch1PlusServiceData | null>;
|
|
23
|
-
turnOn(): Promise<boolean>;
|
|
24
|
-
turnOff(): Promise<boolean>;
|
|
25
|
-
toggle(): Promise<boolean>;
|
|
26
|
-
getVoltageAndCurrent(): Promise<{
|
|
27
|
-
voltage: number;
|
|
28
|
-
current: number;
|
|
29
|
-
} | null>;
|
|
30
|
-
private _sendCommand;
|
|
31
|
-
private _ensureEncryptionInitialized;
|
|
32
|
-
private _getCipher;
|
|
33
|
-
private _encrypt;
|
|
34
|
-
private _decrypt;
|
|
35
|
-
}
|
|
36
|
-
//# sourceMappingURL=worelayswitch1plus.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"worelayswitch1plus.d.ts","sourceRoot":"","sources":["../../src/device/worelayswitch1plus.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAA;AAC9E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAEnD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAGpC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAW9C;;;GAGG;AACH,qBAAa,kBAAmB,SAAQ,eAAe;IACrD,OAAO,CAAC,GAAG,CAAsB;IACjC,OAAO,CAAC,OAAO,CAAsB;IACrC,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,cAAc,CAAQ;gBAElB,UAAU,EAAE,UAAU,CAAC,YAAY,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC;IAkB5E;;;;;;OAMG;WACU,gBAAgB,CAC3B,WAAW,EAAE,MAAM,EACnB,gBAAgB,EAAE,MAAM,EACxB,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,GAChD,OAAO,CAAC,2BAA2B,GAAG,IAAI,CAAC;IAkBxC,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC;IAU1B,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC;IAU3B,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC;IAK1B,oBAAoB,IAAI,OAAO,CAAC;QAAE,OA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